View Full Version : Not Power Of Tow textures problem

05-10-2011, 10:48 AM
Hi everyone,
I need a help ...some one how can tell me what kind of error I am doing

What I had a textures that carry my height field which are now working fine. Well, those textures use borders i.e the resolution (1026X1026) since I wanted to use (1024X1024) with 2 pixels borders as:

glTexImage2D(GL_TEXTURE_2D,0,GL_RGBA32F_ARB,1026,1 026,0,GL_RGBA,GL_FLOAT,&data]);

now is the problem
I want to use same thing i.e textures with borders for data from Bitmaps
Well, I have loaded the Bitmap into and RGB array and then do the same like before. The problem that I faced is that I get weird colors which means clearly that some thing wrong but I am sure that all the settings of the texture and data array are correct.

glTexImage2D(GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGB16F_ARB, 1026, 1026, 0, GL_RGB, GL_UNSIGNED_BYTE,bitmapdata);

What I have done to understand the problem:
1. use another Bitmap with resolution (1024X1024) ::: every thing is working fine.
2. So,I expected that the problem might be that I am using not power of tow textures, therefore I have tested the code with


BUT stil working fine for bitmaps with (1024X1024) and also
bitmaps for NPOT but till 1024 not more that this resolution

However, I think the problem is not the my driver is not supporting resolution more that 1024 because I had used it for height field as I mensioned before :p

I really now feel that I am missing some important things which is honestly I do not know them.....

So, if anyone can know why or at least know some important references that would be helpful

05-10-2011, 11:46 AM
More likely, your data alignment is wrong.
It defaults to 4 bytes, which means no problem for GL_RGBA8, or if width and height are multiples of 4.
But with GL_RGB and 1026 : problems.

So call these once at the begining of GL program, to be safe :

glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
glPixelStorei(GL_PACK_ALIGNMENT, 1);

05-10-2011, 12:26 PM
You can query openGL to find put the max texture size supported

GLint texSize;
glGetIntegerv(GL_MAX_TEXTURE_SIZE, &texSize);

05-11-2011, 03:49 AM
Thank you all,
the problem is solved by the suggestion of ZbuffeR.