c - GLUT won't draw -


when try draw torus,nothing displayed, code runs on friends pc. don't have problems when drawing cubes or other simple shapes. did forget or problem?

code:

#include <gl/glut.h> #include <stdio.h>   glint width = 600; glint height = 600;  gldouble eyex = 3.0, eyey = 0.0, eyez = 5.0; gldouble atx = 0.0, aty = 0.0, atz = 0.0; gldouble vupx = 0.0, vupy = 1.0, vupz = 0.0;  gldouble fovy = 120.0, aspect = 1.0, znear = 1.0, zfar = 10.0;  glfloat position[] = {10.0, 0.0, 1.5, 10.0 };   static void display(void) {  glclear(gl_color_buffer_bit); glcolor3f(0.5,0.1,1.1); glmatrixmode(gl_modelview); glloadidentity(); glulookat(eyex, eyey, eyez, atx, aty, atz, vupx, vupy, vupz); glcolor3f(1.0,0.0,0.0);   glutsolidtorus(1.0,2.0,100,100); glflush();  }   void init(void) { glclearcolor(1.0, 1.0, 1.0, 0.0); glenable(gl_depth_test); glenable(gl_lighting); glenable(gl_light0); glshademodel(gl_flat); }   void reshape(int winw, int winh) { glviewport(0,0,winw,winh); //otvor glmatrixmode(gl_projection); glloadidentity(); gluperspective(fovy, aspect, znear, zfar);  }  static void key(unsigned char key, int x, int y) { switch (key) {     case 27 :         exit(0);         break; } }  void mouse(int button, int state, int x, int y) {  if (button == glut_left_button) {     glpushmatrix(); glrotatef(60,0.0,5.0,0.0);;  gllightfv(gl_light0,gl_position,position); glpopmatrix(); glflush(); } }   int main(int argc, char *argv[]) { glutinit(&argc, argv); glutinitwindowsize(width,height); glutinitwindowposition(10,10); glutinitdisplaymode(glut_single | glut_rgb);  glutcreatewindow("light"); init();  glutdisplayfunc(display); glutreshapefunc(reshape); gllightfv(gl_light0,gl_position,position);   glutkeyboardfunc(key); glutmainloop();  //return exit_success; //return exit_success; } 

request depth buffer:

glutinitdisplaymode(glut_single | glut_rgb | glut_depth); 

and make sure clear it:

glclear(gl_color_buffer_bit | gl_depth_buffer_bit); 

Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -