for three days I try to texture my objects without succeed …
My work is based on the good understandable “NeHe”-Tutorial. Unmodified all sources of this tutorial run very well but when I edit the texture-section it drops out …
here is my source:
Traceback (most recent call last):
File “texturetest.py”, line 182, in ?
File “texturetest.py”, line 178, in main
File “texturetest.py”, line 121, in InitGL
File “texturetest.py”, line 109, in LoadTextures
glTexImage2D(GL_TEXTURE_2D, 0, 3, 150, 150, 0, GL_RGBA, GL_UNSIGNED_BYTE, image)
OpenGL.GL.GLerror: [Errno 1281] invalid value
Sadly I never found an example or a documentation of “glTexImage2D” I realy understand
That’s easy, glTexImage width and height need to be power of two values, 150 is not.
Instead of the internalFormat parameter set to three, you should use GL_RGB8.
You have an GL_RGBA source image, are you sure you don’t need the alpha in the internalFormat? It would be GL_RGBA8 then.
Don’t set the glTexParameter for WRAP_S and _T twice, only the last will be used.
OK, thanks but it does not run …
imageout_tex() #known function which sets "im"
image = im
image = image.tostring("raw", "RGBX", 0, -1)
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB8, 150, 150, 0, GL_RGBA, GL_UNSIGNED_BYTE, image)
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT)
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT)
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST)
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST)
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL)
Of course I set 150 two times (for width and height)
I typed “GL_RGB8” in the internalFormat-section and deleted the needless WRAP_S and _T glTextParameters but it does not run now (same error) !?
width and height must be powers of two. that means 2^x = width and 2^x = height. x must be an integer type.
you cannot find any integer x for 2^x = 150. thats why opengl is complaining.
try a width and a height of 128 or 256 (that are powers of two, x = 7 or 8). width and height dont have to be the same but both values MUST be powers of two. powers of two!
… doh’ …
Thanks for this explanation even I understand.
You see english is not my first language. g
Now I am going to write “power of two: 2, 4, 8, 16, 32, 64 …”) on the blackboard again and again …