3d - OpenGL scene centering problems -
i'm trying make scene looking @ xy plane z coming towards , away camera view. want see objects further away @ different size objects in front of face imagine supposed use gluperspective this. should have axes on screen coming origin out, however, don't see @ all. had working bunch of translations want make sure understand how manipulate because guess , check before.
void resizewindow(glint newwidth, glint newheight) { glviewport(0, 0, newwidth, newheight); glmatrixmode(gl_projection); glloadidentity(); gluperspective(60.0f, (glfloat)newwidth / (glfloat)newheight, 0.1f, 100.0f); glclear(gl_color_buffer_bit | gl_depth_buffer_bit); glmatrixmode(gl_modelview); glloadidentity(); glulookat(0.0, 0.0, -1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0); } glpushmatrix(); glcolor4ub(0, 120, 20, 255); glbegin(gl_line_strip); glvertex3f(0.0f, 0.0f, 0.0f); glvertex3f(3.0f, 0.0f, 0.0f); glvertex3f(2.85f, 0.10f, 0.0f); glvertex3f(2.85f, -0.10f, 0.0f); glvertex3f(3.0f, 0.0f, 0.0f); glvertex3f(2.85f, 0.0f, 0.10f); glvertex3f(2.85f, 0.0f, -0.10f); glvertex3f(3.0f, 0.0f, 0.0f); glend(); glbegin(gl_line_strip); glvertex3f(0.0f, 0.0f, 0.0f); glvertex3f(0.0f, 3.0f, 0.0f); glvertex3f(0.0f, 2.85f, 0.10f); glvertex3f(0.0f, 2.85f, -0.10f); glvertex3f(0.0f, 3.0f, 0.0f); glvertex3f(0.10f, 2.85f, 0.0f); glvertex3f(-0.10f, 2.85f, 0.0f); glvertex3f(0.0f, 3.0f, 0.0f); glend(); glbegin(gl_line_strip); glvertex3f(0.0f, 0.0f, 0.0f); glvertex3f(0.0f, 0.0f, 3.0f); glvertex3f(0.10f, 0.0f, 2.85f); glvertex3f(-0.10f, 0.0f, 2.85f); glvertex3f(0.0f, 0.0f, 3.0f); glvertex3f(0.0f, 0.10f, 2.85f); glvertex3f(0.0f, -0.10f, 2.85f); glvertex3f(0.0f, 0.0f, 3.0f); glend();
didn't try run code, quick glance :
- remove glpushmatrix(). you're not popping anywhere ... , not modifying them either
- your "eye" coordinates (0.0, 0.0, -1.0) seem bit close original give axises 3.0 unit in length. try (0.0, 0.0, -20.0) or so.
Comments
Post a Comment