I'm trying to do some fairly simple openGL stuff and I'm probably making it a lot harder for myself than it really is. Right now I have:
http://gyazo.com/c36...6b93d8a94fb.png
That's meant to be a red cube, I can't figure out setting up the view at all though. Here's my setup code:
void winReshapeFunc(GLint w, GLint h)
{
// specify current matrix
glMatrixMode(GL_PROJECTION);
// load an identity matrix
glLoadIdentity();
// create a projection matrix... i.e. 2D projection onto xy plane
glOrtho( -500, 500, -500, 500, -100, 100);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
// set up the viewport
glViewport(
0, // lower left x position
-100, // lower left y position
(GLsizei) 800, // viewport width
(GLsizei) 800 // viewport height
);
}
void init(){
GLfloat light_diffuse[] = {1.0, 1.0, 1.0, 1.0};
GLfloat light_position[] = {1.0, 1.0, 1.0, 0.0}; // Infinite light location.
// Enable a single OpenGL light.
glLightfv(GL_LIGHT0, GL_DIFFUSE, light_diffuse);
glLightfv(GL_LIGHT0, GL_POSITION, light_position);
glEnable(GL_LIGHT0);
//glEnable(GL_LIGHTING);
// Use depth buffering for hidden surface elimination.
glEnable(GL_DEPTH_TEST);
// Setup the view
glMatrixMode(GL_PROJECTION);
//perspective FOV, aspect ratio, Z near, Z far
gluPerspective( 40.0, 1.0, 1.0, 10.0);
glMatrixMode(GL_MODELVIEW);
gluLookAt(0.0, 0.0, 5.0, // eye is at (0,0,5)
0.0, 0.0, 0.0, // center is at (0,0,0)
0.0, 1.0, 0.0); // up is in positive Y direction
}
int _tmain(int argc, char** argv){
load_AZ("test.az");
//import_OBJ("car.obj");
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH);
glutInitWindowPosition(100, 100);
glutInitWindowSize(800, 600);
glutCreateWindow("Autobench Aztec 2011");
//callback funcs
//glutReshapeFunc(winReshapeFunc);
glutDisplayFunc(renderScene);
glutIdleFunc(update);
init();
glutMainLoop();
return 0;
}
When I uncomment the glutReshapeFunc I get a black window.
How do I set up my viewport properly?

New Topic/Question
Reply



MultiQuote




|