Skip to main content
gamedev.net
🔒 Locked

My Graphics engine problem

Started by illadel4life Oct 29, 2004 at 11:24 AM 4 replies 1.1k views
Original Post
illadel4life
illadel4life
My graphics engine is based on a queue. Elements are put in by Vertex arries, Index arries, Texture ID, and cell shading flag. just when the objects are put into the queue it loads Identity, manipulates the "Model" matrix then pushes it. This system seems to be working, I render models and everything shows up in its correct place. I aslo want to add that I come from a Direct X system...now the problem is a basic one, how can I expand this Viewing Volume? I call glFrustrum right before I render and also right before I push the matrix. I'm so used to having the "Direct X" way where if I want to see a larger area I just move the camera back, but here since everything is in "Model" mode I can look at it in different ways using gluLookAt but the "Box" is still from (seems like) -1 1 along the X Y Z so all my varibles I have to scale by a factor of 1000ths but I want to be able to work with integers! Any thoughts?
zedzeek
zedzeek
>>how can I expand this Viewing Volume? I call glFrustrum right before I render and also right before I push the matrix. I'm so used to having the "Direct X" way where if I want to see a larger area I just move the camera back, but here since everything is in "Model" mode <<

im not 100% sure what u meant,
*u are calling glFrustum (or gluPerspective) only once per frame (at the start) and not per object. to make it so u can see a larger area make the first 4 number of the frustum call bigger (if u use gluPerspective make the first number bigger).

>>I can look at it in different ways using gluLookAt but the "Box" is still from (seems like) -1 1 along the X Y Z so all my varibles I have to scale by a factor of 1000ths but I want to be able to work with integers! Any thoughts?<<

im not to sure, do u want the original size to change from -1,1 to say -100,100. if so the best way is to change the meshes size when u load it (or in the modelling program). ekse u can let opengl do this with glScale(100,100,100) beware though if u use lighting the normals are also scaled.
illadel4life
illadel4life
I looked into it, I think my correct path would be changing the
Matrix mode to GL_Perspective

glMatrixMode(GL_PERSPECTIVE);
glFrustum(-100,100,-100,100,0,100);
glMatrixMode(GL_MODELVIEW);

but sigh the viewing volume is still -1 to 1 on all axes. When my character jumps 20 "units" he disappears....because the volume is too small : (. I do this every "frame". every time I render...

How do you guys change the volume?
In addition without changing the matrix mode still does nothing :'('' any thoughts?
illadel4life
illadel4life
Biggest fool ever.

I don't need to change the Matrix mode...?

Ok that frustum call I can change the near plane, I know that for sure because when its greater than 0 nothing appears...

The object is still the same size tho. I would figure if I make the volume bigger...the objects would get smaller?

I'm gonna google this thing but if anybody knows exactly what I need plz feel free to jump in while i'm trying to figure this thing out.
extralongpants
extralongpants
Objects will not appear any smaller when they are farther away if your viewing frustum is a box. They will all be projected in an orthographic way. If you want a distance effect, then you need to use gluPerspective(...) (sets up a pyramid shaped viewing frustum) and gluLookAt(...) (positions the 'camera' and tells it where to look). It might look something like this, in your rendering code:
//set up the viewing frustumglMatrixMode(GL_PROJECTION);glLoadIdentity();gluPerspective(fieldOfViewAngle, windowHieght/windowWidth, nearClippingPlaneDistance, FarClippingPlaneDistance);//now setup the frustum's position and orientationglMatrixMode(GL_MODELVIEW);glLoadIdentity();gluLookAt(camLookAt.x, camLookAt.y, camLookAt.z, camPos.x, camPos.y, camPos.z, 0.0f, 1.0f, 0.0f);


In the case that I misunderstood you, and you want an orthographic projection, use glOrtho(...), instead of glFrustum(...).
Well, I hope that helps. Good luck with your program.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.