how to set an orthographic rendering?

43 views
Skip to first unread message

Andrew

unread,
Mar 18, 2012, 1:21:51 PM3/18/12
to phi...@googlegroups.com
Hi, I'm new to OpenGL, to webGL and to philoGL ... !

I'm trying to make a scene based on the example lesson #9, and so far it's going well, I can see my objects whirling through space.

I'm using whatever the default shaders are (because I don't want to do blending, just normal texture mapping), and set depth testing.

Now I want to set an orthographic projection. My objects lie roughly in the box [-1,1] x [-1,1] x [-1,1], so I thought I could just do this:

      camera.view.ortho(-1, 1, -1, 1, -1, 1);

instead of calling camera update... but I see nothing.

I tried setting an identity matrix with

      camera.view.set([1,0,0,0, 0,1,0,0, 0,0,1,0, 0,0,0,1]);

but again, I see nothing. I was hoping later to set the z multiplier to 0 to get an orthographic transform.

I can manipulate the view with this:

     camera.view.perspective(90, 1, 5, -2);

which seems to work (though the values for "near" and "far" puzzle me), but obviously this is perspective, not orthographic

can anyone give me a pointer?  thanks

Andrew

unread,
Mar 18, 2012, 2:52:56 PM3/18/12
to phi...@googlegroups.com
I have some kind of solution:

        camera.view.set(new Float32Array(16));
        for (i = 0; i < 16; i++) camera.view[i] = ([1,0,0,0, 0,1,0,0, 0,0,0,-1, 0,0,-2.5,0])[i];

this seems to work now, so actually I was just struggling with the javascript types.

I'm still mystified by the coordinates in the "perspective" transformation though.


Reply all
Reply to author
Forward
0 new messages