Multitexturing / glEnd : invalid Operation

Hello,

I’m trying to use OpenGL’s multitexturing.
I’ve already succeed before, but either I’m doing it wrong, either it is because I’m not on the same OS as before (Linux -> Windows).

I’m using python-opengl (but that should not change anything).

Rather than a long complicated talk, I will show the (simplified) code that works (without multitexturing) and the one that doesn’t work (with multitexturing).

Here is the one that works (without multitexturing):


while not done:
 
  glColor4f(1.0, 1.0, 1.0, 1.0)
  glEnable(GL_TEXTURE_2D)
  glBindTexture(GL_TEXTURE_2D, rayangleTexture)
  glBegin(GL_POLYGON)
            
  glTexCoord2f(0.0, 0.0)
  glVertex2f(50.0, 50.0)
            
  glTexCoord2f(1.0, 1.0)
  glVertex2f(100.0, 100.0)
            
  glTexCoord2f(1.0,0.0)
  glVertex2f(100.0, 50.0)
            
  glEnd()

  pygame.display.flip()
  done = handleEvents()
  glClear(GL_COLOR_BUFFER_BIT)


And here is the one that does not work (with multitexturing) :


while not done:
 
  glActiveTextureARB( GL_TEXTURE0_ARB )
  glEnable(GL_TEXTURE_2D)
  glBindTexture(GL_TEXTURE_2D, rayangleTexture)
    
  glActiveTextureARB( GL_TEXTURE1_ARB )
  glEnable(GL_TEXTURE_2D)
  glBindTexture(GL_TEXTURE_2D, raydistanceTexture)
    
  glColor4f(1.0,1.0,1.0,1.0)
    
  glBegin(GL_POLYGON)  
  
  glMultiTexCoord2fARB(GL_TEXTURE0_ARB, 0.0, 0.0) 
  glMultiTexCoord2fARB(GL_TEXTURE1_ARB, 0.0, 0.0)
  glVertex2f(50.0, 50.0)
    
  glMultiTexCoord2fARB(GL_TEXTURE0_ARB, 1.0, 1.0)
  glMultiTexCoord2fARB(GL_TEXTURE1_ARB, 1.0, 1.0)
  glVertex2f(100.0, 100.0)
    
  glMultiTexCoord2fARB(GL_TEXTURE0_ARB, 1.0, 0.0)
  glMultiTexCoord2fARB(GL_TEXTURE1_ARB, 1.0, 0.0)
  glVertex2f(100.0, 50.0)
 
  glEnd()

  pygame.display.flip()
  done = handleEvents()
  glClear(GL_COLOR_BUFFER_BIT)


The second one crashes on the glEnd call, and gives me this :


Traceback (most recent call last):
  File "E:\blabla\src\main.py", line 119, in <module>
    glEnd()
  File "C:\Python26\lib\site-packages\OpenGL\latebind.py", line 61, in __call__
    return self.wrapperFunction( self.baseFunction, *args, **named )
  File "C:\Python26\lib\site-packages\OpenGL\GL\exceptional.py", line 57, in glEnd
    return baseFunction( )
  File "C:\Python26\lib\site-packages\OpenGL\error.py", line 208, in glCheckError
    baseOperation = baseOperation,
OpenGL.error.GLError: GLError(
	err = 1282,
	description = 'invalid operation',
	baseOperation = glEnd,
	cArguments = ()
)

And here is my initialization :


pygame.init()
pygame.display.set_mode((800,600), pygame.DOUBLEBUF | pygame.OPENGL, 32)
 
glClearColor(0.0, 0.0, 0.0, 1.0)
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT)
 
glMatrixMode(GL_PROJECTION)
glLoadIdentity()
gluOrtho2D(0, 100, 0, 100)
glMatrixMode(GL_MODELVIEW)
 
glEnable(GL_TEXTURE_2D)
glEnable(GL_BLEND)
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)

Would anyone have an idea what’s going on? What’s missing?
I heard about wglGetProcAddress which can be useful for windows but I’m not sure?

For information, I use the 1.4.0 version of OpenGL, and when I call glGetIntegerv(GL_MAX_TEXTURE_UNITS_ARB), it returns 8 (so multitexturing should work…)

Don’t hesitate if I forgot some information.

Thanks a lot

J.

There are only few functions that can be called between glBegin/glEnd. glEnd reports “invalid operation” when you call disallowed function. Even calling glGetError() produces this error. It could be problem in Python wrapper. (maybe connected to late binding).

Try to call glMultiTexCoord2fARB when you start your application, catch the error.

So after a few tests :

  • When I put only a call to glMultiTexCoord2fARB between glBegin and glEnd, it brings me the error (invalid operation…)
  • When I put other calls like glVertex2f or glTexCoord2f it doesn’t get any error.
  • When I put a glGetError, it’s the very same error.

So does it mean the binding is not working well and calls a disallowed function for glMultiTexCoord2fARB?

Who should I contact then?

I’m trying to get back to an old version of the binding (but it’s not that simple…) to see if the errors keeps occuring.

It happens to be a bug in the pyopengl binding.
It has been added on the bug tracker of the project on source forge since february, but not corrected yet.

Page of the bug :

http://sourceforge.net/tracker/?func=detail&aid=2817196&group_id=5988&atid=105988