Jump to content
  • Advertisement
Sign in to follow this  
mjs2000

OpenGL Display corruption and hanging in Linux (with SDL)

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

This is a really odd error...I have a program that loads a bitmap font (from an RGBA PNG file with SDL_image) and displays text. However, whenever I try to render text onto a solid white background, the display gets severely munged, and the X server hangs. The font texture gets corrupted, random pixels are displayed around polygon edges, and sometimes, if the program is running in a window, random pixels flicker over the entire screen. Usually a quick Ctrl-Alt-Backspace will save the program, but often a hard reset is required. Moreover, if there is another window on top of the OpenGL window, or even if the background is RGB (254, 254, 254), the corruption does not occur. For a picture of the pixel corruption effect I'm talking about, click here. (I had to photograph the screen, because the computer was hung...) It's probably worth noting that the characters are colored white in the PNG file (and I use glColor() to change it, but that doesn't make a difference in this case). Maybe it has something to do with the pixel format I'm using. I do this:
glTexImage2D(GL_TEXTURE_2D, 0, 4, charMap->w, charMap->h,
               0, GL_RGBA, GL_UNSIGNED_BYTE, charMap->pixels);

where charMap is the SDL_Surface with the bitmap data. Oddly enough, this phenomenon does not occur on Windows and another Linux machine I've tested it on. I have a GeForce 6800 with NVIDIA's 1.0-6629 drivers. WTF! :-P -matt

Share this post


Link to post
Share on other sites
Advertisement
Try this...it works fine in Windows, but crashes spectacularly in Linux.

I can't guarantee that it'll crash for you...as I said before, other Linux machines I've tried this on don't crash. Either way, see what you can make of it.

Thanks,
-matt

Share this post


Link to post
Share on other sites
Only possible problem I can see from looking at your code is the call to glTexImage2D. You use surface->pixels, which isn't guaranteed to be valid until the surface is locked.

Just do:


SDL_LockSurface(charMap);
glTexImage2D(GL_TEXTURE_2D, 0, 4, charMap->w, charMap->h,
0, GL_RGBA, GL_UNSIGNED_BYTE, charMap->pixels);
SDL_UnlockSurface(charMap);


The only other thing I can think of is the printf-code. (vsnprintf and family always scares me, they just seem so easy to mess up)

Does it still crash if you replace:

font.printf(CENTERED, SCREEN_TOP-5.0, 5.0, 5.0, "TEXT TEXT TEXT");

with

font.print(CENTERED, SCREEN_TOP-5.0, 5.0, 5.0, "TEXT TEXT TEXT");

?

Share this post


Link to post
Share on other sites
Interesting, but neither of those fix the problem...(although locking the surface is a good idea)

Still, it's odd that I'm only getting it with a white background...

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!