Jump to content
  • Advertisement
Sign in to follow this  
MainBrain

SDL - Blank Screen In Release Version

This topic is 4435 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 My application runs fine in debug mode but i get a blank screen in release mode. Unfortunately i have no idea how to debug this issue. I'm using MSVC6. And here comes an excerpt of my code. I have adopted a tutorial to display YUV-Images in an overlay. ... // zzzip if ( SDL_Init(SDL_INIT_VIDEO) < 0 ) { fprintf(stderr, "Unable to init SDL: %s\n", SDL_GetError()); exit(EXIT_FAILURE); } atexit(SDL_Quit); _screen = SDL_SetVideoMode(_width, _height, 32, SDL_HWSURFACE | SDL_DOUBLEBUF); if ( _screen == NULL ) { fprintf(stderr, "Unable to set video: %s\n", SDL_GetError()); exit(EXIT_FAILURE); } _overlay = SDL_CreateYUVOverlay(_width, _height, SDL_IYUV_OVERLAY, _screen); if ( _overlay == NULL ) { fprintf(stderr, "Unable to set overlay: %s\n", SDL_GetError()); exit(EXIT_FAILURE); } ... // zzzip while(running) { ... // zzzip if (SDL_MUSTLOCK(_screen)) if (SDL_LockSurface(_screen) < 0) return; if (SDL_LockYUVOverlay(_overlay) < 0) return; memcpy(_overlay->pixels[0], &frame[0][0], _width * _height * sizeof(unsigned char) ); memcpy(_overlay->pixels[1], &frame[1][0], frame[1].getHeight() * frame[1].getWidth() * sizeof(unsigned char) ); memcpy(_overlay->pixels[2], &frame[2][0], frame[2].getHeight() * frame[2].getWidth() * sizeof(unsigned char) ); SDL_Rect r = {0, 0, _width, _height}; SDL_DisplayYUVOverlay(_overlay, &r); SDL_UnlockYUVOverlay(_overlay); if (SDL_MUSTLOCK(_screen)) SDL_UnlockSurface(_screen); SDL_Flip(_screen); ... // zzzip }

Share this post


Link to post
Share on other sites
Advertisement
Have you included all the images, fonts etc. in your release directory aswell? Are the project release properties set?

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Thanks alot for the pointer! T'was indeed an interresting bug.

While verifying your idea i realized that the program never reached the renderer in the main loop in release mode. Disabling code optimization mysteriously solved the problem. But why?

Debug memory is always preinitialized. There was a variable i forgot to initialize with zero. "_last_tick" stores the time it takes until the next frame has to be rendered. In my case it had the value (2^31) so it would have taken about 25 days until the app would have run correctly :p

The critical code looks like this:

... // zzzip
while(running)
{
... // zzzip
int tick = SDL_GetTicks();
if (tick <

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Thanks alot for the pointer! T'was indeed an interresting bug.

While verifying your idea i realized that the program never reached the renderer in the main loop in release mode. Disabling code optimization mysteriously solved the problem. But why?

Debug memory is always preinitialized. There was a variable i forgot to initialize with zero. "_last_tick" stores the time it takes until the next frame has to be rendered. In my case it had the value (2^31) so it would have taken about 25 days until the app would have run correctly :p

The critical code looks like this:

... // zzzip
while(running)
{
... // zzzip
int tick = SDL_GetTicks();
if (tick <

Share this post


Link to post
Share on other sites
Sorry for the crippled double posting. Gamedev.net runs very slow and frequently returns a "HTTP Error 500.13 - Server error: Web server is too busy." message.
So i never know wich click on the reply button really posts the message :(

Thanks, MainBrain



... // zzzip
while(running)
{
... // zzzip
int tick = SDL_GetTicks();
if (tick <= _last_tick)
{
SDL_Delay(1);
} else {
... // render
_last_tick += (1000 / _framerate);
}
}
... // zzzip

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!