Re: [PyOpenGL-Users] PyOpenGL Deprecation & New Methods
Brought to you by:
mcfletch
From: Mike C. F. <mcf...@vr...> - 2009-12-10 16:11:58
|
Prashant Saxena wrote: > Hi, > > Are there any docs, article available for the deprecated function equivalent in 3.x api. Converting old school code completely > using new api would be difficult with out good docs and references. > > For example > > glEnableClientState(GL_COLOR_ARRAY) > glEnableClientState(GL_VERTEX_ARRAY) > > glColorPointer(4, GL_FLOAT, 0, self.colors) > glVertexPointer(2, GL_FLOAT, 0, self.vertices) > > glPushMatrix() > glTranslatef(self.x, self.y, 0) # > glDrawArrays(GL_QUADS, 0, 4) > glPopMatrix() > > # Disable vertex arrays > glDisableClientState(GL_VERTEX_ARRAY) > glDisableClientState(GL_COLOR_ARRAY) > > This is new way to draw quads using array method but glPushMatrix, glPopMatrix, glTranslate & glColor has been deprecated. > Actually, that's the pretty-old-but-not-quite-the-oldest way to draw quads (it's from OpenGL 1.1, January 1997), which is about 1/2 of the way to legacy free. To go legacy-free you then convert the code to use shader attributes instead of the hard-coded color, vertex, texture-coordinate etc. arrays (that's a trivial textual change) and write shaders to render *all* of the quads with a single call (that's a bit of work if you don't know GLSL yet). Oh, and quads are deprecated... you render two triangles... Matrix operations are deprecated in their entirety, with only shader-uniform matrices being available, i.e. you define a uniform called "mv_matrix", another called "norm_matrix" and calculate the matrices, passing them fully-formed to the shader alongside your data for each object. Point form description of what needs to happen is on the deprecations page[1]. At this point I'd say "move to using arrays (and VBOs), investigate shaders" is the best path to take, rather than trying to go fully legacy-free all in one go. Legacy-free operation has a higher barrier to entry than the original OpenGL API, and when you go legacy free you either have to provide fallback code for older hardware or just give up on the less featureful hardware (e.g. my 2-year-old laptop with a crappy Intel Integrated Graphics chip doesn't support GLSL at all). I'm trying to write a series of introductory tutorials[2] for legacy-free operation, but I'm short on time (perennially), so you might not want to hold your breath on it. HTH, Mike [1] http://pyopengl.sourceforge.net/documentation/deprecations.html [2] http://pyopengl.sourceforge.net/context/tutorials/index.xhtml -- ________________________________________________ Mike C. Fletcher Designer, VR Plumber, Coder http://www.vrplumber.com http://blog.vrplumber.com |