python - Drawing in OpenGL is always white -
i'm trying draw simple triangles in opengl. problem triangle white, wheras put color glcolor3f function:
def ondraw(self): glclear(gl_color_buffer_bit | gl_depth_buffer_bit) glclearcolor(.1, 0.1, 0.1, 1.0) glbegin (gl_triangles) glcolor3f (1.0, 0.0, 0.0) glvertex2f (0.25, 0.25) glcolor3f (0.0, 1.0, 0.0) glvertex2f (0.12, 0.25) glcolor3f (0.0, 0.0, 1.0) glvertex2f (0.25, 0.4) glend()
and here initialization:
def initgl(self): # set viewing projection glmatrixmode(gl_projection) glfrustum(-0.5, 0.5, -0.5, 0.5, 1.0, 3.0) # position viewer glmatrixmode(gl_modelview) gltranslatef(0.0, 0.0, -2.0) glenable(gl_depth_test) glenable(gl_lighting) glenable(gl_light0)
any idea?
with lighting enabled vertex colors no longer considered calculations. instead have set material properties. vertex colors quite convenient there's method use vertex colors set material properties.
glenable(gl_color_material); glcolormaterial(gl_front_and_back, gl_ambient_and_diffuse);
however note lighting work must provide vertex normals otherwise things strange. might best disable lighting time being.
on different note: please stop using old , dusted immediate mode, fixed function pipeline opengl. instead learn modern opengl. recommend http://arcsynthesis.org/gltut start.
Comments
Post a Comment