Jump to content
  • Advertisement
Sign in to follow this  
RichardoX

wxWindows, OpenGL and textures

This topic is 4974 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 am coding a space strategy game, that has OpenGL 3d graphics and lots of GUI stuff, which I intend to do with wxWindows. I have succesfully so far made a window with a gl canvas and other gui stuff and I can draw stuff in the gl canvas. However, the problem which I have is that textures don't work. I am creating a texture from a png image and I have verified that my png loading works, but for some reason the textures don't work. When I try to draw a quad with a texture surface it appears white as if the texture I bound was invalid. GL_TEXTURE_2D is enabled and I call SetCurrent before I load the texture and before I draw anything. I have also tried to change the texture environment to GL_REPLACE instead of GL_MODULATE for debuggin purposes, but it seems as if the texture is not created or the image not applied to the texture. Anyone got any idea what is behind this? Does anyone know a good debugging technique to get started with this? -Richardo

Share this post


Link to post
Share on other sites
Advertisement
Yes, I am enabling GL_TEXTURE_2D and glIsEnabled(GL_TEXTURE_2D) says it's enabled. I have enabled it in several places, but there is no difference where I enable it. Is there a general (non wx-specific) method to check what's inside a texture. It seems as if there's nothing in the texture (glTexImage2D seems to do nothing). The image data that goes in has been verified (by comparing the stuff in the data and the actual image) and glTexImage2D gives no errors. I have also tried to debug this by trying to render my scene into the texture, but there's no difference either. This might have something to do with wxGLContexts, but I've understood that wxGLCanvas' SetCurrent sets the appropriate context as the current in use.

This all is giving me a headache (such a trivial task) and my deadlines start to get on my nerves (this is a project for school). I think that I'll take the easy way out and do a tetris clone with SDL and ditch wxWindows.

I thaught that wx is a good library and really worth using but now I think that it's just plain bullshit. It resembles the (ugly) win32 api all too much. Does anyone know any cross platform GUI library that would take advantage of native GUI elements whenever it is possible? WX seems kinda bloated to me.

-Richardo

Share this post


Link to post
Share on other sites
Yes, my texture's width and height are powers of two (it's 512x256) and the very same texture (and most of the same code) works with SDL, but with wxWindows it does not. Go figure.

-Richardo

Share this post


Link to post
Share on other sites
Try adding scaling functions after you create the texture. i spent a good 6 hours trying to figure out the same stupid problem:


// create the texture (just my local example)
glBindTexture( GL_TEXTURE_2D, texture_num );
glTexImage2D( GL_TEXTURE_2D, 0, 3, 1024, 1024, 0, GL_RGB, GL_UNSIGNED_BYTE, texture_pixels );

// IMPORTANT PART: set the min/max filtering
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );


Share this post


Link to post
Share on other sites
I think I might have had a similar problem to this.

Verify that at the point you are loading and binding your textures and generally doing everything GL that you definitely have the correct GL resource context (or whatever it is called) bound and that you are using the GL Canvas.

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!