Jump to content
  • Advertisement
Sign in to follow this  
fatak

OpenGL glEnable(GL_TEXTURE_2D) FAILS!

This topic is 4546 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

I am trying to texturemap a cube in opengl. I have initialised the texturing functionality by setting glEnable(GL_TEXTURE_2D). But when I test this, glIsEnabled(GL_TEXTURE_2D) return false, and glGenTextures(1, texture), where texture is declared as GLuint texture[1]; does not populate the texture name array. When queried, texture[1] carries junk data. All other functions, such as blending and lighting are working fine, even color shading. Texture mapping fails. please advise on what the issue may be, and what a possible solution would be. Thanks. Dhruva

Share this post


Link to post
Share on other sites
Advertisement
Guest Anonymous Poster
yes i tried that as well, and it didn't work, I even tried populating an array of 5 members, not just one....but still the same error.

Anyway, I have just found that glGenTextures populates the array in certain functions of my Setup Class, and not others. I basically have a setup class that carries out initialisation of the OpenGL API, and a mesh class that holds the geometry and the render function for each object.

Now, the glGenTextures function works fine when called in the Setup::Initialise function, but does not work when called in the Setup::registerTexture function, which the Mesh class calls when it loads the object geometry and texture. The Setup::registerTexture function is a static function, so that it can be called from the mesh class without the necessity of the Mesh class actually carrying an instance of the Setup Class.

Further, the glGenTextures function doesn't work in the Mesh class at all, so i can't include it in there either. I dont want to have to initialise the Mesh Class with an instance of its calling Setup class.

I could paste my code here for your consideration, since this description is unwieldy. How do i paste my code, should i just copy paste, or are there some tags that I can use.

Thanks...

Dhruva

Share this post


Link to post
Share on other sites
Post source using the source tags.
[source]
source goes here
[/source]

And what Rick said was what I was thinking aswell; have you initialized OpenGL before trying to load textures?

Share this post


Link to post
Share on other sites
Oh my god guys! Thats the problem. I was instancing the mesh before I initialised OpenGL. I dunno how i completely missed that. Sorry for wasting your time, and thanks a ton for your help.

Dhruva

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!