bourriquet42
09-30-2010, 01:43 PM
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.
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.