Damnit, I'm sure this is lurking in the depths of the forums somewhere, but I canne find it anywhere. Cas mentioned his perspective projection matrix he used for 'Flux which has 1:1 pixel ratio of the z=0 plane, does anybody still have the code snippet lying around?
Cheers.
float div = 1.0f / 64.0f;
GL11.glFrustum(
- Game.WIDTH * div,
Game.WIDTH * div,
- Game.HEIGHT * div,
Game.HEIGHT * div,
8,
65536);
Cas :)
So, what's the advantage of this vs glOrtho?
Coz you can fiddle with the Z coordinate and get cool 3D :)
Cas :)
Does it convert easily from glOrtho?
Convert what?
Cas :)
Meaning, in glOrtho you setup your board to draw 0 to width of screen, and 0 to height of screen (the cullfacing stuff also acts a bit funny). How do you use glFrustum instead? Do you have to completely convert your coordinate system?
No, the whole point of that particular frustum setup is that if Z=0.0 then you've actually got an orthographic projection!
Cas :)
Hmmm... I went ahead and tried it in place of my glOrtho command:
GL11.glOrtho(0, WIDTH, HEIGHT, 0, -2000, 2000);
No go however. I just get a blank screen.
One subtle difference: 0,0 is in the middle of the screen I think.
I've been trying to do this, but something is strange. I can't seem to zoom out, away from the playing board. I've been trying to use gluLookat to set my position and perspective, but it's not working. Any ideas?
My textures and things are still being rendered for orthographic mode with the full size being used (i.e., when I draw a sprite, I'm drawing it from 0,0 to 0,30, etc.). Do I need to shrink my stuff down to fractional sizes for this to work?
Just doing some more experimenting, it seems that the gluLookAt command simply doesn't work on the z-axis.
Cas, what Z-level do you draw things on? I have to glTranslatef(0,0,-800f) to start seeing things.
I've tested this "magical matrix" too, it works well but I must call a glTranslatef(0,0,-10) if I want to start seeing things...
I'm not very familiar with the glFrustrum method, so maybe I'm doing something wrong as elias4444 do...
Chman
Something I'm noticing is that it seems to work better if you use fractions for your sizes and points rather than large "resolution" type numbers (i.e., 0.2f rather than 200f).
I found this site talking about all the different perspectives... Personally, I've always needed pictures to help me understand something. This site did a great job:
http://mecadserv1.technion.ac.il/public_html/LabCourses/interActiveGraphics/ogl_course/ogl_lab/ogl_trans.htm