Oblique projection


I’ve been trying to draw my scene using cabinet projection. Though I was able to get something resembling the desired result, it has become pretty clear that I’m doing something wrong. For this reason, I decided to start from scratch, and this time ask people who actually know what they’re doing first. :slight_smile:

How exactly do I implement cabinet projection using OpenGL? I’m working with Java and LWJGL.

Did your try loading this transformation matrix as the GL projection matrix ?
Make sure the object is facing the camera, and it should be ok.

Thanks for the quick reply!

My primary talent is as an artist, and as a mathematician I’m completely inept. Sorry in advance for the stupidity that will no doubt follow. :stuck_out_tongue:

My matrix looks like this (it’s a double array):

1, 0, 0.5*Math.cos(45), 0,
0, 1, 0.5*Math.sin(45), 0,
0, 0, 0,                0,
0, 0, 0,                1

Then in my render method, I do this:

DoubleBuffer mat = BufferUtils.createDoubleBuffer(16);

The problem is, there’s a lot of what appears to be z-fighting. I think this makes sense, because that matrix I loaded pretty much gets rid of depth entirely, right? As soon as I set the number at 3,3 to 1, for instance, everything disappears, though.

The image appears too wide, but I guess that’s because the projection matrix doesn’t take the window’s dimensions into account or something? I really don’t know, I’m doing way more guesswork here than I’d like. :S

What am I doing wrong?

EDIT: I somehow forgot to mention that the scene doesn’t resemble cabinet projection at all.

I gave it a go, and in fact this oblique matrix should be applied on top of a standard glOrtho projection.
I added two missing 1.0s in the diagonal so that it will not delete depth information, I had to transpose the matrix too (OpenGL convention), and it worked :

// C code
glOrtho(-10,10,-10,10,-10,10); // to see a scene inside a cube centered on origin and 20 units wide
GLdouble projOblique[] =
{1.0, 0.0, 0.0, 0.0,
 0.0, 1.0, 0.0, 0.0,
 -.5, -.5, 1.0, 0.0,
 0.0, 0.0, 0.0, 1.0};

// draw here in oblique projection

This thread helped, even if not that good :

Thanks ZbuffeR. I actually read through that thread and managed to get a pretty terrible oblique projection going before posting this thread. I’ll give your code a try as soon as possible. :slight_smile:

EDIT: Works beautifully. Thank you very much! :smiley: