Karl Scholz, the prosecuting barrister, told a jury that the first incident occurred when the defendant asked him during an English class if he wanted to have sex with him.
He added: "It was an usual question for a ten-year-old boy to ask another."
After the lesson it is claimed the victim was attacked in the toilet.
The court also heard that the allegations came to light last year when the complainant was spoken to by teachers following rumours in the school of sexual behaviour with his "girlfriend".
It was then that he revealed what the defendant was alleged to have done to him.
That night he told his parents and the matter was reported to the police.
Scholz revealed that both the alleged victim and attacker had viewed online porn, adding that the jury may conclude that the availability of pornography on the internet was behind the incident.
That was almost certainly the case, he said, adding that the boy was "acting out" what had been seen.
"It is that which may lie behind the corruption of the minds of the people involved in this case."
The defendant, who is now aged 12, denied that anything sexual had happened between him and the complainant.
The trial, before Judge Philip Hughes, is proceeding.