Problem with windowed SDL apps

Hey,

I’m having a problem with windowed SDL applications. Whenever I start them,
the frame appears, but the graphics do not; whatever was running in the
background
appears in the screen. Has anyone else had this problem, and what is the
easiest solution to this problem?

I’m having a problem with windowed SDL applications. Whenever I start
them, the frame appears, but the graphics do not; whatever was running
in the background
appears in the screen. Has anyone else had this problem, and what is the
easiest solution to this problem?

What platform are you using, and can you show us a simple program that
does it? (or just an existing SDL program that does it)?

Thanks,
–ryan.

Have you tried to view informations about your graphic environment first?----- Original Message -----
From: James Buchwald
To: sdl at libsdl.org
Sent: Thursday, August 18, 2005 11:25 PM
Subject: [SDL] Problem with windowed SDL apps

Hey,

I’m having a problem with windowed SDL applications. Whenever I start them, the frame appears, but the graphics do not; whatever was running in the background
appears in the screen. Has anyone else had this problem, and what is the easiest solution to this problem?



SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

Ryan C. Gordon <icculus clutteredmind.org> writes:

I’m having a problem with windowed SDL applications. Whenever I start
them, the frame appears, but the graphics do not; whatever was running
in the background
appears in the screen. Has anyone else had this problem, and what is the
easiest solution to this problem?

What platform are you using, and can you show us a simple program that
does it? (or just an existing SDL program that does it)?

Thanks,
–ryan.

I’m using Windows XP SP2 with Visual C++ 6 for a compiler. Here’s some of the
code that gives me this problem:

SDL_Surface *screen;

void render()
{
// Lock surface if needed
if (SDL_MUSTLOCK(screen))
if (SDL_LockSurface(screen) < 0)
return;

// Ask SDL for the time in milliseconds
int tick = SDL_GetTicks();

// Declare a couple of variables
int i, j, yofs, ofs;

// Draw to screen
yofs = 0;
for (i = 0; i < 480; i++)
{
for (j = 0, ofs = yofs; j < 640; j++, ofs++)
{
((unsigned int*)screen->pixels)[ofs] = i * i + j * j + tick;
}
yofs += screen->pitch / 4;
}

// Unlock if needed
if (SDL_MUSTLOCK(screen))
SDL_UnlockSurface(screen);

// Tell SDL to update the whole screen
SDL_UpdateRect(screen, 0, 0, 640, 480);
}

// Entry point
int main(int argc, char *argv[])
{
// Initialize SDL’s subsystems - in this case, only video.
if ( SDL_Init(SDL_INIT_VIDEO) < 0 )
{
fprintf(stderr, “Unable to init SDL: %s\n”, SDL_GetError());
exit(1);
}

// Register SDL_Quit to be called at exit; makes sure things are
// cleaned up when we quit.
atexit(SDL_Quit);

// Attempt to create a 640x480 window with 32bit pixels.
screen = SDL_SetVideoMode(640, 480, 32, SDL_SWSURFACE);

// If we fail, return error.
if ( screen == NULL )
{
fprintf(stderr, “Unable to set 640x480 video: %s\n”, SDL_GetError());
exit(1);
}

// Main loop: loop forever.
while (1)
{
// Render stuff
render();

// Poll for events, and handle the ones we care about.
SDL_Event event;
while (SDL_PollEvent(&event)) 
{
  switch (event.type) 
  {
  case SDL_KEYDOWN:
    break;
  case SDL_KEYUP:
    // If escape is pressed, return (and thus, quit)
    if (event.key.keysym.sym == SDLK_ESCAPE)
      return 0;
    break;
  case SDL_QUIT:
    return(0);
  }
}

}
return 0;
}

I’m including all the necessary files(there’s a bunch of commented-out old code
inbetween the includes and this code, so I didn’t post them). This code is from
Sol’s SDL tutorial. If I change the video type from SDL_SWSURFACE to
SDL_FULLSCREEN, then it works fine. The problem is, the application I am
developing needs to be contained within a window.

James Buchwald wrote:

I’m having a problem with windowed SDL applications. Whenever I start them,
the frame appears, but the graphics do not; whatever was running in the
background
appears in the screen. Has anyone else had this problem, and what is the
easiest solution to this problem?

Are you running Xorg with the Composite extension enabled ? If so, try
disabling the Composite extension, or set the environment variable
XLIB_SKIP_ARGB_VISUALS=1 before running your SDL apps.

  • Gerry

No, I’m not running that. Heck, I’ve never even heard of it.On 8/19/05, Gerry JJ wrote:

James Buchwald wrote:

I’m having a problem with windowed SDL applications. Whenever I start
them,
the frame appears, but the graphics do not; whatever was running in the
background
appears in the screen. Has anyone else had this problem, and what is the
easiest solution to this problem?

Are you running Xorg with the Composite extension enabled ? If so, try
disabling the Composite extension, or set the environment variable
XLIB_SKIP_ARGB_VISUALS=1 before running your SDL apps.

  • Gerry

SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

I noticed this as well, when I tried to run a sample mandelbrot
program from http://www.temnet.org/wendigo/fractals. The executable
that came with the download had that effect; I tried compiling it from
source with Dev-C++ and it still had the same effect.

This computer thinks it has an Intel 82915G/GV/910GL Express Chipset
family in the display adapters, with whatever drivers came with a
stock install of XP, which has been updated to SP2, if that helps any.

I normally use a mac at home; I tried this program at work and that’s
how I found it. Didn’t bother to research a fix or anything.> > James Buchwald wrote:

I’m having a problem with windowed SDL applications. Whenever I start
them,

the frame appears, but the graphics do not; whatever was running in the
background
appears in the screen. Has anyone else had this problem, and what is the
easiest solution to this problem?

Ryan C. Gordon <icculus clutteredmind.org> writes:

I’m having a problem with windowed SDL applications. Whenever I
start them, the frame appears, but the graphics do not; whatever
was running in the background
appears in the screen. Has anyone else had this problem, and what
is the easiest solution to this problem?

What platform are you using, and can you show us a simple program
that does it? (or just an existing SDL program that does it)?

Thanks,
–ryan.

I’m using Windows XP SP2 with Visual C++ 6 for a compiler. Here’s
some of the code that gives me this problem:

SDL_Surface *screen;

void render()
{
// Lock surface if needed
if (SDL_MUSTLOCK(screen))
if (SDL_LockSurface(screen) < 0)
return;

Have you tried to print something instead of this return?
Just wondering if this part is broken in your SDL in your configuration.On Friday 19 August 2005 20:49, James Buchwald wrote:

// Ask SDL for the time in milliseconds
int tick = SDL_GetTicks();

// Declare a couple of variables
int i, j, yofs, ofs;

// Draw to screen
yofs = 0;
for (i = 0; i < 480; i++)
{
for (j = 0, ofs = yofs; j < 640; j++, ofs++)
{
((unsigned int*)screen->pixels)[ofs] = i * i + j * j + tick;
}
yofs += screen->pitch / 4;
}

// Unlock if needed
if (SDL_MUSTLOCK(screen))
SDL_UnlockSurface(screen);

// Tell SDL to update the whole screen
SDL_UpdateRect(screen, 0, 0, 640, 480);
}

// Entry point
int main(int argc, char *argv[])
{
// Initialize SDL’s subsystems - in this case, only video.
if ( SDL_Init(SDL_INIT_VIDEO) < 0 )
{
fprintf(stderr, “Unable to init SDL: %s\n”, SDL_GetError());
exit(1);
}

// Register SDL_Quit to be called at exit; makes sure things are
// cleaned up when we quit.
atexit(SDL_Quit);

// Attempt to create a 640x480 window with 32bit pixels.
screen = SDL_SetVideoMode(640, 480, 32, SDL_SWSURFACE);

// If we fail, return error.
if ( screen == NULL )
{
fprintf(stderr, “Unable to set 640x480 video: %s\n”,
SDL_GetError()); exit(1);
}

// Main loop: loop forever.
while (1)
{
// Render stuff
render();

// Poll for events, and handle the ones we care about.
SDL_Event event;
while (SDL_PollEvent(&event))
{
  switch (event.type)
  {
  case SDL_KEYDOWN:
    break;
  case SDL_KEYUP:
    // If escape is pressed, return (and thus, quit)
    if (event.key.keysym.sym == SDLK_ESCAPE)
      return 0;
    break;
  case SDL_QUIT:
    return(0);
  }
}

}
return 0;
}

I’m including all the necessary files(there’s a bunch of
commented-out old code inbetween the includes and this code, so I
didn’t post them). This code is from Sol’s SDL tutorial. If I change
the video type from SDL_SWSURFACE to SDL_FULLSCREEN, then it works
fine. The problem is, the application I am developing needs to be
contained within a window.


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

I put an fprintf there, and stderr came out as an empty file… so no, it’s
not a problem there… I’m going to try using the SDL source instead of the
prebuilt development libraries. ALL windowed SDL apps are doing this to me
now, maybe there’s a problem with my copy of SDL.dll…On 8/20/05, Sami N??t?nen <sn.ml at bayminer.com> wrote:

On Friday 19 August 2005 20:49, James Buchwald wrote:

Ryan C. Gordon <icculus clutteredmind.orghttp://clutteredmind.org>
writes:

I’m having a problem with windowed SDL applications. Whenever I
start them, the frame appears, but the graphics do not; whatever
was running in the background
appears in the screen. Has anyone else had this problem, and what
is the easiest solution to this problem?

What platform are you using, and can you show us a simple program
that does it? (or just an existing SDL program that does it)?

Thanks,
–ryan.

I’m using Windows XP SP2 with Visual C++ 6 for a compiler. Here’s
some of the code that gives me this problem:

SDL_Surface *screen;

void render()
{
// Lock surface if needed
if (SDL_MUSTLOCK(screen))
if (SDL_LockSurface(screen) < 0)
return;

Have you tried to print something instead of this return?
Just wondering if this part is broken in your SDL in your configuration.

// Ask SDL for the time in milliseconds
int tick = SDL_GetTicks();

// Declare a couple of variables
int i, j, yofs, ofs;

// Draw to screen
yofs = 0;
for (i = 0; i < 480; i++)
{
for (j = 0, ofs = yofs; j < 640; j++, ofs++)
{
((unsigned int*)screen->pixels)[ofs] = i * i + j * j + tick;
}
yofs += screen->pitch / 4;
}

// Unlock if needed
if (SDL_MUSTLOCK(screen))
SDL_UnlockSurface(screen);

// Tell SDL to update the whole screen
SDL_UpdateRect(screen, 0, 0, 640, 480);
}

// Entry point
int main(int argc, char *argv[])
{
// Initialize SDL’s subsystems - in this case, only video.
if ( SDL_Init(SDL_INIT_VIDEO) < 0 )
{
fprintf(stderr, “Unable to init SDL: %s\n”, SDL_GetError());
exit(1);
}

// Register SDL_Quit to be called at exit; makes sure things are
// cleaned up when we quit.
atexit(SDL_Quit);

// Attempt to create a 640x480 window with 32bit pixels.
screen = SDL_SetVideoMode(640, 480, 32, SDL_SWSURFACE);

// If we fail, return error.
if ( screen == NULL )
{
fprintf(stderr, “Unable to set 640x480 video: %s\n”,
SDL_GetError()); exit(1);
}

// Main loop: loop forever.
while (1)
{
// Render stuff
render();

// Poll for events, and handle the ones we care about.
SDL_Event event;
while (SDL_PollEvent(&event))
{
switch (event.type)
{
case SDL_KEYDOWN:
break;
case SDL_KEYUP:
// If escape is pressed, return (and thus, quit)
if (event.key.keysym.sym == SDLK_ESCAPE)
return 0;
break;
case SDL_QUIT:
return(0);
}
}
}
return 0;
}

I’m including all the necessary files(there’s a bunch of
commented-out old code inbetween the includes and this code, so I
didn’t post them). This code is from Sol’s SDL tutorial. If I change
the video type from SDL_SWSURFACE to SDL_FULLSCREEN, then it works
fine. The problem is, the application I am developing needs to be
contained within a window.


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

James Buchwald wrote:

I put an fprintf there, and stderr came out as an empty file… so no,
it’s not a problem there… I’m going to try using the SDL source
instead of the prebuilt development libraries. ALL windowed SDL apps are
doing this to me now, maybe there’s a problem with my copy of SDL.dll…

Try forcing the windib target, just for sanity’s sake, too.

Set the environment variable SDL_VIDEODRIVER=windib

This will disable the DirectDraw target.

–ryan.

THANK YOU THANK YOU THANK YOU!!!
It works now! I thought I was going to have to get a new video card. Thanks!On 8/20/05, Ryan C. Gordon wrote:

James Buchwald wrote:

I put an fprintf there, and stderr came out as an empty file… so no,
it’s not a problem there… I’m going to try using the SDL source
instead of the prebuilt development libraries. ALL windowed SDL apps are
doing this to me now, maybe there’s a problem with my copy of SDL.dll…

Try forcing the windib target, just for sanity’s sake, too.

Set the environment variable SDL_VIDEODRIVER=windib

This will disable the DirectDraw target.

–ryan.


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl