Question

I have an NSOpenGLView setup and working great, but I need to draw a rectangle that always completely fills the view and is not clipped (does that make sense?). I have a view that is always going to be 1100x850 pixels in size. Basically, what I am trying to do is find a way to ensure that a y value of 0.4 is always going to draw the object at the very top of the view, -0.4 at the bottom, ect. I do also need it to have some sense of perspective though, so I cannot do glOrtho

Is there a way to do this?

If I did not explain it well, here is what I mean:

---------
|   |   |
|   |   |
---------
  • That center line always has an x value of 0.0.

  • The left line has an x value of -0.55, the right has a value of 0.55

  • The top line has a y value of 0.4, the bottom has a value of -0.4

So, I need a rectangle with the following vertices to completely fill, but not leave, the screen:

{
  -0.55,  0.40, 0.00,
   0.55,  0.40, 0.00,
   0.55, -0.40, 0.00,
  -0.55, -0.40, 0.00,
}
Was it helpful?

Solution

There's no requirement that everything you draw use the same projection matrix. Draw your 'perspective' part of the scene with a perspective matrix, then switch to orthographic matrix and draw your quad.

Make sure to disable the depth test for the second part, as the orthographic values won't make any sense compared to the perspective values.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top