glGenTextures problem

Started by
5 comments, last by j0k3r 20 years, 9 months ago
Hi, i''m coding a framework to manage OpenGL (and i''m reading nehe tuts of course ! ). The problem is : i load the bmp file ( auxDIBImageLoad() ), the relative struct contains the right infos about the picture, i prepare a GLuint variable, but when i do : glGenTextures ( n, &mytex ) // n != 0 it returns to me mytex = 0 (and i can get no texture on any quad...;( ) What can i try to debug ? I''ve got neither compile errors nor warnings.... Thanks in advance...
Advertisement
Make sure than OpenGL has been initialized before calling glGenTextures ... if you trying to call this function before ... it returns 0
I can already see a quad and a triangle rotating.....so i think i initialized ogl in the right way....
Make sure that n > 0 ...
does "mytex" an array ? if n > 1 it must

and you can''t call glGenTextures between a call to glBegin and glEnd ...
bool Texture::LoadGLTextures( char * T )
{

AUX_RGBImageRec *TextureImage[1];
memset(TextureImage,0,sizeof(void *)*1);

if (TextureImage[0]=LoadBMP( T ) )
{

glGenTextures(1, &new_texture); glBindTexture( GL_TEXTURE_2D, new_texture );
glTexImage2D( GL_TEXTURE_2D, 0, 3, TextureImage[0]->sizeX, TextureImage[0]->sizeY, 0, GL_RGB, GL_UNSIGNED_BYTE, TextureImage[0]->data );
glTexParameteri( GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR );
glTexParameteri( GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR );
}

....
....

This's the method of interest....

new_texture is a private member of Texture class...a GLuint (remember that in this example n = 1 !)

[edited by - j0k3r on July 4, 2003 6:03:29 PM]
quote:Original post by Anonymous Poster
Make sure that n > 0 ...
does "mytex" an array ? if n > 1 it must

and you can''t call glGenTextures between a call to glBegin and glEnd ...


Well,

the method LoadGLTexture occurs in the Framework constructor (EngineApplication()), where i load the polygons... when i loaded them i call LoadGLTexture ( as u can see many replys ago ), and when the constructor ends the main loop keeps on going...

The problem is that i obtain an error via glGetError called after glGenTexture, and the error is :

GL_INVALID_OPERATION

that (straight from MSDN) means i called glGenTexture between glBegin() and glEnd(), but that''s not right beacuse NO Render method (where i do glBEgin / glEnd ) is yet called !!!!

Why this error ?
Try loading the textures after the stuff like glClearcolor, glShadeModel etc. had been called and before the rendering.

Hyperdev

"To err is human, to really mess up requires a computer"
"To err is human, to really mess up requires a computer"

This topic is closed to new replies.

Advertisement