elect
elect

Reputation: 7190

How can I make the glOrtho parallelepiped rotating?

I have my world rendered. Based on some specific requirements it includes (some time) some lights on the floor. I am rendering these lights using triangle primitives. Right now I have the following code to zoom and limit the rendering area:

if(aspect>1)    
    gl.glOrtho(-scale*aspect, scale*aspect, -scale, scale, 0, 2);
else
    gl.glOrtho(-scale, scale, -scale/aspect, scale/aspect, 0, 2);

As you can see in this image, the far plane is cutting the light through a line (parallel to the line on the circle between B and D):

enter image description here

The problem arises when I rotate my scene. The glOrtho "box" stays fixed. You can notice it by looking always at the cutting line on the light. It is no more parallel to the line between B and D.

enter image description here

One of my friends suggested my this document. Basically, it explains how to extract frustum planes, but this would mean that I should check manually for each primitive if it is inside or not.

Is there a method using the glOrtho call?

I would like to obtain something like this:

enter image description here

Upvotes: 0

Views: 762

Answers (1)

datenwolf
datenwolf

Reputation: 162164

Okay, after explanation by elect in the comments the answer is: You've got a misconception of what the viewing volume clip planes are.

They are not some sort of bounding box aligned with the scene.

The near and far clipping plane are sort of projections of the screen into the world and they are, by definition, alway aligned with the view. There's nothing you can do about this, because this is fundamental to the math used by OpenGL.

It is also impossible in OpenGL to let primitives expand toward infinity, so geometry has to be limited in some way anyhow.

Upvotes: 1

Related Questions