Forums > Jitter

problems with Ortho in OpenGL

November 27, 2011 | 6:46 pm

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…


November 27, 2011 | 7:10 pm

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.


November 27, 2011 | 7:11 pm

Hell, I’ll post it.
To start the patch, hit the toggle under start, read redball.mov, then click the read dozer.mov. 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!!


November 27, 2011 | 7:31 pm

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


November 27, 2011 | 7:38 pm

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.


November 27, 2011 | 8:06 pm

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…


November 27, 2011 | 8:32 pm

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?


November 27, 2011 | 8:55 pm

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?

[attachment=177566,2987]

Attachments:
  1. Screenshot20111126at4.36.22PM.png

November 27, 2011 | 8:56 pm

that was the wrong shot! here it is

[attachment=177567,2988]

Attachments:
  1. Screenshot20111127at3.53.52PM.png

November 27, 2011 | 9:13 pm

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


November 27, 2011 | 11:11 pm

Worked like a charm. Thanks, Wes.


Viewing 11 posts - 1 through 11 (of 11 total)