A diminutive wannabe king tortures the Gingerbread Man of storybook fame, trying to get information from him. The Gingerbread Man’s taunting reply? “Eat me!”

The Brothers Grimm this isn’t. What it is, is “Shrek,” a new computer-animated film that is a legitimate fairy tale every bit as much as it makes fun of legitimate fairy tales.

It’s all set in an unnamed far-off kingdom, as these stories often are, where the title ogre (voice of Mike Myers) leads a happy, quiet existence in his own personal swamp. One day, however, the aforementioned ruler, Lord Farquaad (John Lithgow), rounds up all the fairy-tale characters and dumps them into Shrek’s land as a means of getting them out of the way.

Furious, Shrek heads to Farquaad’s amusement park (an obvious Disneyland spoof), Duloc, to see what gives. Accompanying him is a jive-talking donkey named Donkey (Eddie Murphy), who wants to be Shrek’s friend despite Shrek’s having no interest in friendship with anyone.

Farquaad knows he must marry a princess to become a real king, so he makes Shrek a deal: If he’ll go rescue the winsome Princess Fiona (Cameron Diaz) from the dragon and bring her back to him, he’ll get all the squatters off Shrek’s land and leave him in peace.

Princess Fiona is dismayed to be rescued by a hideous ogre, as she had a very specific romantic scenario in mind while waiting to be rescued all those years. But on the trip back to Farquaad, she and Shrek begin to fall in love — a particular dilemma since as soon as they’re back to Duloc, he’s supposed to be handing her over to the little runt.

Some scenes are a who’s-who of fairy tales, recalling the joyful mixing and matching that went on in “Who Framed Roger Rabbit?” (Actually, for the theater-minded, it more closely resembles Stephen Sondheim’s “Into the Woods.”) When Farquaad offers a reward to anyone turning in a magical creature, Gepetto can be seen in line waiting to get a few bucks out of Pinocchio, and someone has Tinkerbell in a bird cage. Non-Disney icons abound, too, including the Three Blind Mice and the Three Little Pigs.

But it’s the parodies of Disney animation and paraphernalia that provide the most amusement, and only hard-core aficionados will catch them all. (In the dragon’s castle are gargoyles reminiscent of those in “The Hunchback of Notre Dame,” for instance; blink and you’ll miss them.) Some are blatant, like Shrek’s insistence that Donkey not do any singing; others are more sublime, like the inclusion of bears from Disneyland’s Country Bear Jamboree in the crowd scenes.

And some are just twisted and hysterical, like a wedding bouquet being tossed and Cinderella slapping Snow White in the face to keep her from catching it.

It’s a movie with a semi-cynical attitude, to be sure, though it does allow itself a few lapses into sentimentalism. The story has some serious flaws — it’s not explained what goes on at Duloc, for example, nor why Farquaad was rounding up the fairy-tale folks in the first place — and occasionally seems to go in certain directions just for the parodies available to it there.

As for characters, only Eddie Murphy is very memorable, and one suspects he ad-libbed a lot of Donkey’s lines. Myers, Diaz and Lithgow are serviceable, but not great — and is this really the third movie in which Myers has done a Scottish accent? Yes, I believe it is. (“So I Married an Axe Murderer” and “Austin Powers: The Spy Who Shagged Me” being the other two.)

The film earns its PG rating. Ogres tend to be gross; I counted 700,000 toilet-related jokes just in the first five minutes (it does calm down quite a bit after that). But you have to respect a movie that has a character named Donkey, yet only has two jokes playing on the double meaning of “ass.” You may not want young, impressionable kids seeing it and reveling in the gross stuff, but everyone else should find it a wickedly funny diversion.

B+ (; PG, some very mild profanity, a lot of potty humor.)