Sign in to follow this  

OpenGL: gluLookAt & gluPerspective

This topic is 4671 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'm new to OpenGL and I have problems I didnt had when i tried it in GLUT (i think i tried gluPerspective). now, in my own engine, i have problems. 1) When I use gluPerspective or gluLookAt I can't see my triangle. what can cause it? the resizing function is (for gluPerspective):
void Device::resize()
	{
		int width=win->getWidth();
		int height=win->getHeight();
		if (device==LN_OPENGL)
		{
			glViewport(0,0,width,height);
			glMatrixMode(GL_PROJECTION);
			glLoadIdentity();
			gluPerspective(45.0f,(GLfloat)width/(GLfloat)height,.1f,100.0f);
			glMatrixMode(GL_MODELVIEW);
			glLoadIdentity();
		}
	}
I re-init (without releasing) opengl in the resize function for now instead of this function. This step make my window flash when i return from window mode to fullscreen mode to window mode (with opengl only. im sure this is the reason, i hope). Oh, and here is the rest opengl code:
Device d;
			// Where to put cam.update() ? (calls gluLookAt)
                        // And with what pos & vector to use so i'll see this triangle?
                        d.clear();
                        // I used to put cam.update() here in the GLUT project
			d.start();
			d.rotate(rotate,V(rotate,rotate,rotate));
			d.color(RGB(0,0,50));
			d.vertex(V(0.0,1.0,0.0));
			d.color(RGB(0,50,0));
			d.vertex(V(0.87,-0.5,0.0));
			d.color(RGB(50,0,0));
			d.vertex(V(-0.87,-0.5,0.0));
			d.finish();
			d.swap();
			rotate+=1.0;
thanks, pex. [Edited by - pex22 on April 1, 2005 8:52:17 AM]

Share this post


Link to post
Share on other sites
The triangle vertex ordering is clockwise, this will cause the triangle to not show up if you have backface culling enabled (and front face GL_CCW).
If it's not that, the problem is more likely to be with how LookAt is called.

Hope it will help you.

Share this post


Link to post
Share on other sites
I glDisable(GL_CULL_FACE), and also tried glFrontFace(GL_CW) before running the game loop but i still cant see it after resizing the window.
i didnt used cam.update() this time, i must use gluLookAt with gluPerspective?
my problem with the camera is probably same problem as with the gluPerspective or position/direction problem. because it worked in GLUT.
what is the default pos/dir of the camera? pos[0,0,0] and dir[?,?,?]?

EDIT: btw, is it good that i use doubles instead of floats? (except for the W param in Vector class of course). or its just more space that i won't use and i can save 1/2 of the program RAM? or it'll be better to let the (me) choose if to use floats or doubles (e.g. if i'll program a game that doesn't require doubles, i won't use it. but in games it is, i'll use it)?.
Is this topic should be in the OpenGL forum or here its fine?

[Edited by - pex22 on April 1, 2005 10:20:31 AM]

Share this post


Link to post
Share on other sites
Quote:

what is the default pos/dir of the camera? pos[0,0,0] and dir[?,?,?]?

The default direction is [0, 0, -1].

Quote:

is it good that i use doubles instead of floats? (except for the W param in Vector class of course).

I don't understand what you mean, why the W coordinate should have a different type?

Quote:

...or its just more space that i won't use and i can save 1/2 of the program RAM? or it'll be better to let the (me) choose if to use floats or doubles (e.g. if i'll program a game that doesn't require doubles, i won't use it. but in games it is, i'll use it)?.

Using templates you could support both float and doubles at no cost. Anyway, in 99% of the cases, you'll be using floats, because they are smaller, and the graphic hardware handles them natively.

Quote:

Is this topic should be in the OpenGL forum or here its fine?

This is not really important, until you start posting about D3D in the OpenGL forum, or vice-versa :D!!!

Edit:
Anyway, if you want me to find the problem, you should post more code.

[Edited by - cyberquiet on April 4, 2005 12:04:58 PM]

Share this post


Link to post
Share on other sites

This topic is 4671 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this