PDA

View Full Version : Frustum and texture mapping



jenwrenfer
04-26-2002, 09:16 PM
Hi everyone. I have two (hopefully quick) questions:

1) I am simply trying to use glFrustum for a graphics program. However, no matter
what I do, when I use it instead of glOrtho, nothing will come up on the screen.
Could someone tell me exactly where it needs to go (display, init, main, etc.) and what I need to do to make it work?

And....

2) Is there a simple way to texture map a small rectangular picture onto a rectangle? I'm trying to use a small picture to make a TV look like there is a video game on it, and while my books describe texture mapping, it seems to be way too complicated for something simple like this. It is a jpeg, but I could convert it to anything else through a graphics program I have.

Just FYI, I'm using OpenGL with MSVC++.

Thanks so much to anyone who helps.

reubenhawkins
04-27-2002, 01:06 PM
glFrustum()? Na, don't use that. Use the glu function gluPerspective(90,w/h,1,50) The 90 is an angle in degrees. It the angle stuff you can see in front of you, but I can't remember the real name for it. w/h is width/height and that's the aspect ration. 1 is the near clipping plane and 50 is the far clipping plane. My reshape function, that is when the window is resized, looks like this...

void reshape(int w, int h)
{
glViewport(0,0,w,h);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(90,w/(float)h,1,50);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
gluLookAt(0,0,10,0,0,0,0,1,0);
}


gluLookAt(x1,y1,z1,x2,y2,z2,0,1,0);
x1,y1,z1 is the position of the eye.
x2,y2,z2 is the position the eye is looking at.
0,1,0 says that the y axis is up.

Miguel_dup1
04-27-2002, 04:55 PM
gluPerspective( FOV ,w/h,1,50) http://www.opengl.org/discussion_boards/ubb/smile.gif



Originally posted by reubenhawkins:
glFrustum()? Na, don't use that. Use the glu function gluPerspective(90,w/h,1,50) The 90 is an angle in degrees. It the angle stuff you can see in front of you, but I can't remember the real name for it. w/h is width/height and that's the aspect ration. 1 is the near clipping plane and 50 is the far clipping plane. My reshape function, that is when the window is resized, looks like this...

void reshape(int w, int h)
{
glViewport(0,0,w,h);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(90,w/(float)h,1,50);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
gluLookAt(0,0,10,0,0,0,0,1,0);
}


gluLookAt(x1,y1,z1,x2,y2,z2,0,1,0);
x1,y1,z1 is the position of the eye.
x2,y2,z2 is the position the eye is looking at.
0,1,0 says that the y axis is up.

Zuraffo
04-28-2002, 01:01 AM
i) The gluPerspective or glFrustum should go right before your rendering, after glMatrixMode( GL_PROJECTION ).

ii) There is no quick way to do a texture map. All the parameters setup is quite necessary. I suggest you follow the book. Or if you want a fater way, d/l some tutorial and rip the texture mapping part out. Just make sure you know what are you ripping off. http://www.opengl.org/discussion_boards/ubb/wink.gif