i novice opengl , read glutwirecubedraws wire cube. not appearing on when run code, wondering do? draw cube or have gone wrong in code?
#include<gl/glut.h> gldouble cubesize= 10.0; //functions declarations - prototypes void init(void); void display(void); int main(int argc, char ** argv){ glutinit(&argc,argv); glutinitdisplaymode(glut_single |glut_rgba); glutinitwindowposition(100,100); glutinitwindowsize(500,500); glutcreatewindow("wire cube"); init(); glutdisplayfunc(display); glutmainloop(); } //functions implementaion - definition void init(void){ glclearcolor(0.0,0.0,1.0,0.0); glclear(gl_color_buffer_bit); } void display(void){ glbegin(gl_polygon); glutwirecube(5.0); glend(); glflush(); }
calling glutwirecube not allowed inside glbegin/glend block. glvertex specify vertices , functions set current values of vertex attributes (like glnormal, glcolor, ...) can used there.
how glutwirecube internally works not specified. might use immediate mode, in case, own glbegin/glend calls.
conceptually, trying put cube gl_polygon not going work. gl_polygon drawing single, flat, convex polygon, , totally impossible draw whole cube 1 polygon.
furthermore, not set of gl_modelview or gl_projection matrices. means directly draw in clip space, , glutwirecube size 5 draw cube lies outside of viewing frustum, see nothing.
Comments
Post a Comment