Archived

This topic is now archived and is closed to further replies.

gimp

glTexImage2D gives 'invalid value' error

2 posts in this topic

I''ve been having some problems with getting some of my tga images to be be created as textures. I naturally though there was something wrong with my code so I created a hard coded call to the api and that failed too: glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 640, 128, 0, GL_RGB, GL_UNSIGNED_BYTE, a_Image.GetData()); My card supports 2048x2048 textures. Size of my image data array is 640*128*3 bytes. The funny thing is, when you call gluBuild2DMipmaps with the same data(args differ a little) the texture creation works fine. Which leads me to two possible conclusions: 1) gluBuild2DMipmaps is smarter and fixed some error I''m making. 2) The difference in args is the key. 2 seems more plausable so I check and rechecked the args. they look good to me... Any thoughts much appreciated... Many thanks Chris Brodie http:\\fourth.flipcode.com
0

Share this post


Link to post
Share on other sites
Hi there,

the problem is you are passing a rectangular ( not square )
image, all opengl textures need to be to the power of 2 and
square ( although i believe there are extensions to support
rectangular textures ).

The reason why it works with gluBuild2DMipmaps is that
this scales the image so it is square ( from what I can
gather from the red book ).

Hope it helps

Mark
0

Share this post


Link to post
Share on other sites
hmm... i never knew they textures had to be square. afaik, all they had to have is a height and a width that is a power of 2.

MENTAL
0

Share this post


Link to post
Share on other sites