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

Popular posts from this blog

ios - RestKit 0.20 — CoreData: error: Failed to call designated initializer on NSManagedObject class (again) -

java - Digest auth with Spring Security using javaconfig -

laravel - PDOException in Connector.php line 55: SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES) -