• Advertisement

Archived

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

glGenTextures problem

This topic is 5346 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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...

Share this post


Link to post
Share on other sites
Advertisement
Guest Anonymous Poster
Make sure than OpenGL has been initialized before calling glGenTextures ... if you trying to call this function before ... it returns 0

Share this post


Link to post
Share on other sites
I can already see a quad and a triangle rotating.....so i think i initialized ogl in the right way....

Share this post


Link to post
Share on other sites
Guest 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 ...

Share this post


Link to post
Share on other sites
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]

Share this post


Link to post
Share on other sites
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 ?

Share this post


Link to post
Share on other sites
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"

Share this post


Link to post
Share on other sites

  • Advertisement