View Full Version : GluLookAt
02-24-2001, 05:02 AM
Can someone tell me whats wrong here... When ever i run this I always get a black screen... Im prety sure its with glulookat function...
GLvoid ReSizeGLScene(GLsizei width, GLsizei height)
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glBegin(GL_QUADS); glVertex3f( 1.0f, 2.0f, 0.0f); glVertex3f( 1.0f,-2.0f, 0.0f); glVertex3f(-.05f,-2.0f, 0.0f); glVertex3f(-.05f, 2.0f, 0.0f);
this isnt the entire code but if you could give a look at how i use the gluLookAt and drawing. The code will display an object without the gluLookAt
if you are using orthographic projection then glulookat probably won't work (i had this same problem when i started using GL)
try putting this (or a variant) in your glResize() function after glViewport(), if you don't have it...
gluPerspective(60, (double) width / height, 1, 4096);
where width & height are the width & height of your gl window.
then, in your rendering function:
gluLookAt(-4, 2, 2, 0, 0, 0, 0, 1, 0);
glutSolidCube(2.0f); or whatever you are gonna draw
02-25-2001, 02:30 PM
Is basically equivalent to
glTranslate(0, 0, 10);
You then do...
The loadIdentity is basically going to reset what you set in gluLookAt, so I'm not sure why it would work without the gluLookAt, but won't work with it.
Try using glPushMatrix, glPopMatrix instead of resetting the matrix every time.
// draw your scene
You don't show how you setup your projection matrix so I'm not sure if that will keep your object in the scene or not.
Even though you said this is not the entire code, I must ask you about a missing function.
In the Draw-function, you call glBegin, but I can see no glEnd. All I can see is the end of the Draw-function. Do you have any glEnd at all?
02-26-2001, 02:43 AM
I had the same problem. It was because the objects wheren't in the cam-range. try something like
gluLookAt(10*sin(t/100),10*cos(t/100),0, 0,0,0, 0,1,0);
this will look throug the scene. it's good to "find" an object http://www.opengl.org/discussion_boards/ubb/smile.gif
also, if you are using gluLookAt to look directly into the up vector that you specify, you will get a blank screen. [another pull-my-hair-out-because-this-should-be-working-but-it-isn't GL nightmare]. but i guess its all part of the experience
02-26-2001, 09:04 PM
Yes, you must check the rest of the code. you need to call glEnd(); function and SwapBuffer() since you are using double buffers. Also the object is small in size and placed at (12, 0, -24) and camra at (0, 0, -10) and focused at (0,0,0). This suggest that (1) object is ou of feild-of-vision becasue 12-units translation along x-axis or (2) it is in the scene but since it is very far away from the camer (at a distance of "14"- units along z-axis) so its not visible.
Also try focussing your camer at the object by passing (12, 0, -24) as the focus point.... If the object is there you'll see it.
In order to make object more visible uyou can also use glPointSize(); funcion.
Well...hope any of these things work http://www.opengl.org/discussion_boards/ubb/smile.gif
Powered by vBulletin® Version 4.2.2 Copyright © 2014 vBulletin Solutions, Inc. All rights reserved.