View Full Version : Problems with glGenTextures
When i try to generate a texture object with glGenTextures i do not get any identifier back.
What am i doing wrong and how can i solve this problem?
Well, you don't give much information, except that something is wrong. Please tell us more, how do you use it for example?
This is an extraction from my source code:
void World::addtexture(String id)
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
In this source I do not get any identifier (index) for the texture object I wanted, therefore I believe that it was not created.
I have looked at an example that uses glGenTextures and it worked, therefore I started to remove code from it to see if the same problem occurred there as in my code.
And indeed it did.
But when the glutCreateWindow() function was executed it started to work again. Iím confused.
I havenít found any good documentation on glGenTextures and if there should be any premises and constraints to make it work.
I have also thought about if errors reported by OpenGL affects the functionality of certain functions, and if this is the case with my problem?
glutCreateWindow does not only creates a window on the screen. It also creates an OpenGL rendering context, which is a requirement for OpenGL to work at all. If you remove that function, a context will not be created, and no calls to OpenGL will work as expected.
As long as you create a context before doing anything else, there should be no problem with your code. You can do some error checking after glGenTexture. If index is zero, no texture was allocated, otherwise a texture was properly allocated.
Thanks for the help, could been lost out there for ages without your help http://www.opengl.org/discussion_boards/ubb/smile.gif
Now it works as it should.
Powered by vBulletin® Version 4.2.2 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.