Re: [PyOpenGL-Users] glTexCoordPointer
Brought to you by:
mcfletch
From: Mike C. F. <mcf...@ro...> - 2003-05-01 02:49:26
|
Your code works (though it doesn't actually use the tex coords) on 2.0.1.04 (CVS) version of PyOpenGL. You can find lots of samples of glTexCoordPointer in OpenGLContext (though normally the d, rather than the f variant). Here's a sample of use from the indexedpolygons geometry node: def _enableTextures( self ): """Enable the normal array if possible""" tex = self.texCoord if tex: tex = tex.point if tex: glTexCoordPointerd( tex ) glEnableClientState( GL_TEXTURE_COORD_ARRAY ) return 1 Note: had to change the drawing line in your code to: glDrawElementsui( GL_QUADS, indicies) but since that's after the error you were seeing I doubt that was the problem. I'm assuming you've moved on since this email (it's been sitting in my "should check out what's going on here pile" for too long, sorry about that), if not, let me know and I'll put it back in the hopper. Enjoy, Mike Sean Riley wrote: >Hello, > >I can't get glTexCoordPointer to work in PyOpenGL. I have tried every >variation of it and parameters to it and setup states, but I always get this >error: > >$ python texcoords.py >Traceback (most recent call last): > File "texcoords.py", line 15, in display > glTexCoordPointerf(texcoords) >OpenGL.GL.GLerror: [Errno 1282] invalid operation > > >Here is a simple program that demonstrates it in action. > >#--------------- begin code ------------------------ >import sys > >from OpenGL.GL import * >from OpenGL.GLUT import * > >points = [ (100,100), (200,100), (200,200), (100,200) ] >indicies = (0,1,2,3) >texcoords = [ (0.0, 0.0), (1.0, 0.0), (1.0, 1.0), (0.0, 1.0) ] > > >def display(): > glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT) > > glVertexPointerf(points) > glTexCoordPointerf(texcoords) > glDrawElements( GL_QUADS, indicies) > > glutSwapBuffers() > >glutInit(sys.argv) >glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE | GLUT_ALPHA | GLUT_DEPTH) >glutInitWindowSize(400,400) >glutCreateWindow('texcoords') >glOrtho(0,400,0,400,0,1) > >glutDisplayFunc(display) >glutMainLoop() > >#--------------- end code ------------------------ > >Has anyone else actually gotten this funationality to work? It is not used >at all in the examples provided with the distribution. > > ... _______________________________________ Mike C. Fletcher Designer, VR Plumber, Coder http://members.rogers.com/mcfletch/ |