problems with Ortho in OpenGL

Nov 27, 2011 at 6:46pm

problems with Ortho in OpenGL

Hey all,
I have a project in which I’ve got shapes following other shapes around in OpenGL using gridshape. The problem is that unless I enable @ortho 2, the shapes have a strange lens effect in which they aren’t right on top of one another but sort of perspectively scaled. Why not just use ortho 2 you ask? It makes my usable area into a square for some reason, and I want the full 640×480. I can post the patch, but it’s getting huge…

Nov 27, 2011 at 7:10pm

Instead of posting a mega patch, you could always make a small patch that shows just the problem. You don’t need to add any of the shape chasing, just simply drawing static objects to show the problem is best. Without a patch, your post is too vague to help. You don’t mention if you’re doing 3D or 2D drawing. I’m assuming 2D, but you never know.

Nov 27, 2011 at 7:11pm

Hell, I’ll post it.
To start the patch, hit the toggle under start, read, then click the read You’ll see some masking I did that follows where the redball would be. The problem is, if you click on the NYPD subpatch, there is a target that is following that redball, but when you goto GLcircles, the target gridshape doesn’t work. THE FUNNY PART is if you change a value, like the red value on the color, or anything, it will work.

– Pasted Max Patch, click to expand. –

What’s the deal with layers? And how can I get ortho 1 to work? Please help!!

Nov 27, 2011 at 7:31pm

Wes, just read your post. If it’s too big I can chop it down. I’m doing 2d drawing as well.

Nov 27, 2011 at 7:38pm

yes. your patch has a lot going on.
please just post the drawing part that you are having trouble with.
the simpler you can make your patch that still exhibits your problem, the better we will be able to help you.

Nov 27, 2011 at 8:06pm

Ok here is the simplified patch:

– Pasted Max Patch, click to expand. –

So click start and then read in the redball and dozer movies. You’ll notice the perspective effect right away. Click in GLcircles subpatch to check out the rendering engine. It works with ortho2, but i dont like that fisheye that it does…

Nov 27, 2011 at 8:32pm

Looking at the patch, I don’t see any perspective effects. Usually that term refers to 3D drawing. All I see here is 2D. Do you mean aspect ratio? Things look fine on my machine. Can you illustrate with a captured image?

Nov 27, 2011 at 8:55pm

Sure thing. You can see that the grey square isn't centered on the circle (not the blue one, ignore that for now). In the center, they appear directly in line, but the further towards the edges they get, they are separated, as if there was a gap in the distance between them, know what I mean?


  1. Screenshot20111126at4.36.22PM.png
Nov 27, 2011 at 8:56pm

that was the wrong shot! here it is


  1. Screenshot20111127at3.53.52PM.png
Nov 27, 2011 at 9:13pm

This is a problem with the coordinate system your objects are drawing in. One is in OpenGL coodinates with @ortho from gl.render, the other is in an image. They probably have different horizontal scaling factors, which is why you’re seeing problems. You’ll just need to do some experiments to figure out what the scaling factor is. My suggestion:

1) figure out what the x-coordinate range for the plane is
2) figure out what the x-coordinate range for the spotlight is
3) make a mapping between them

Nov 27, 2011 at 11:11pm

Worked like a charm. Thanks, Wes.


You must be logged in to reply to this topic.