Jump to content
  • Advertisement
Sign in to follow this  
MarkyMark

problems with setting up camera

This topic is 4818 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, I have a problem simply setting up a camera to look at a single textured quad (dimensions of 512x172) set up to be in the centre of a 800x600 viewport. I could get it working using orthographic mode, but I've been trying to get it to work using perspective mode and the fact I can't has been bugging me. Instead of a simple texture centered on the viewport, I get a large scaled part of the texture taking up the whole viewport. the code showing the geometry and camera setup is shown below: glMatrixMode(GL_PROJECTION); glPushMatrix(); glLoadIdentity(); glPerspective(45.0f,(GLfloat)800/(GLfloat)600,0,100); glMatrixMode(GL_MODELVIEW); glPushMatrix(); glLoadIdentity(); glLookAt(400,300,100,400,300,1,0,1,0); float x=144 float w=512 float y=172 float h=256 glBegin(GL_QUADS); glTexCoord2f(0,0); glVertex3f(x,y,z); glTexCoord2f(1,0); glVertex3f(x+w,y,z); glTexCoord2f(1,1); glVertex3f(x+w,y+h,z); glTexCoord2f(0,1); glVertex3f(x,y+h,z); glEnd();

Share this post


Link to post
Share on other sites
Advertisement
1) perspective coordinates will never match screen-pixel coordinates
2) your ZFar clipping plane is only 100
3) your killing your ZBuffer precisssion by using a ZNear of 0
4) Why is your quad such odd dimensions?

try using these in the right places (ballpark guesses):
glPerspective( 90.0f, 1.33f, 1, 350 );
glLookAt( 0,0, -250, 0,0,0, 0,1,0 );

if you describe your situation (the need for this) someone might be able to offer a "better" solution[smile].

Cheers
-Danu

Share this post


Link to post
Share on other sites
what , ultimately ,I'm trying to do is this:

1)render an object to a texture.
2)slap that texture on a two sided quad in a 3D scene
with a fragment shader on it to do some fx work on the image.
4)possibly animate that quad.

The code shown above was just example code of slapping
an arbitrary texture on a quad and rendering it in 3space.


Mark

Share this post


Link to post
Share on other sites
so why does the quad have to be so "big"? why not just use a close eye position like (0,0,-5) and change your quad to something around (-1,-1,1,1) ?

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!