Bug in SDL_GetVideInfo()?

Hi

Hmmm, if there’s no bug in the following code and that’s not windib fault, then it looks that there’s bug in SDL_GetVideoInfo() in SDL 1.2.8.
My specs: WinXP (no SP), GeForce4 MX 440, drivers were updated 2 months before.-----------------------

#include
#include <SDL.h>

void DumpVideoInfo()
{
const SDL_VideoInfo * videoInfo = SDL_GetVideoInfo();
int videoMemory = videoInfo->video_mem;
fprintf(stderr, “Total amount of video memory: %i kilobytes.\n”, videoMemory);
}

int main (int argc, char *argv[])
{
if (SDL_Init (SDL_INIT_VIDEO) < 0)
return 1;

atexit (SDL_Quit);

DumpVideoInfo();

char driver[128];
if ( SDL_VideoDriverName(driver, sizeof(driver)) )
fprintf(stderr, “Video driver: %s\n”, driver);

SDL_Surface * screen = SDL_SetVideoMode (640, 480, 16, SDL_SWSURFACE | SDL_DOUBLEBUF);

if (screen == 0)
return 1;

DumpVideoInfo();

if ( SDL_VideoDriverName(driver, sizeof(driver)) )
fprintf(stderr, “Video driver: %s\n”, driver);

int done = 0;

while (!done)
{
SDL_Event event;

 while (SDL_PollEvent (&event))
   {
    switch (event.type)
     {
      case SDL_KEYDOWN:
       DumpVideoInfo();
      break;

      case SDL_QUIT:
        done = 1;
       break;
      }
  }

  SDL_Flip (screen);
  SDL_Delay (1);
}

return 0;
}


Problem probably lies within DumpVideoInfo() function, output in stderr goes like this:

Total amount of video memory: 0 kilobytes.
Video driver: windib
Total amount of video memory: 0 kilobytes.
Video driver: windib
Total amount of video memory: 0 kilobytes.
Total amount of video memory: 0 kilobytes.

I think those 0 shouldn’t be there… IIRC, in 1.2.7 it was working fine.

Koshmaar

I think those 0 shouldn’t be there… IIRC, in 1.2.7 it was working fine.

Software surfaces don’t have video memory.

–ryan.

I think those 0 shouldn’t be there… IIRC, in 1.2.7 it was working fine.

Software surfaces don’t have video memory.

–ryan.

Ok, so I added: SDL_HWSURFACE | SDL_FULLSCREEN to SetVideMode, and this before first DumpVideInfo():

if (screen->flags & SDL_HWSURFACE == 0)
fprintf(stderr, “Can’t get hardware surface\n”);

It looks now like this:

SDL_Surface * screen = SDL_SetVideoMode (640, 480, 16, SDL_HWSURFACE | SDL_FULLSCREEN );

if (screen == 0)
return 1;

if (screen->flags & SDL_HWSURFACE == 0)
fprintf(stderr, “Can’t get hardware surface\n”);

DumpVideoInfo();

If there’s no SDL_FULLSCREEN, there’s “Can’t get hardware surface” in stderr. However, when there are both SDL_HWSURFACE | SDL_FULLSCREEN, there’s no “Can’t get hardware surface”, what means - video surface is in hardware. And even then, it still returns 0.

Koshmaar

Doesn’t that just mean SDL_SetVideoMode failed? Have you checked
SDL_GetError() in that case? e.g.:

if (screen == NULL)
{
fprintf(stderr, “Can’t open video: %s\n”, SDL_GetError());
return(1);
}

???

-bill!On Tue, Aug 09, 2005 at 12:36:42PM +0200, Koshmaar wrote:

SDL_Surface * screen = SDL_SetVideoMode (640, 480, 16, SDL_HWSURFACE | SDL_FULLSCREEN );

if (screen == 0)
return 1;

if (screen->flags & SDL_HWSURFACE == 0)
fprintf(stderr, “Can’t get hardware surface\n”);

DumpVideoInfo();

If there’s no SDL_FULLSCREEN, there’s “Can’t get hardware surface” in stderr. However, when there are both SDL_HWSURFACE | SDL_FULLSCREEN, there’s no “Can’t get hardware surface”, what means - video surface is in hardware. And even then, it still returns 0.

Doesn’t that just mean SDL_SetVideoMode failed? Have you checked
SDL_GetError() in that case? e.g.:

if (screen == NULL)
{
fprintf(stderr, “Can’t open video: %s\n”, SDL_GetError());
return(1);
}

???

-bill!

No, SDL_SetVideoMode in those example programs, on my hardware, always succeeds - that is, blank window is created and no errors are set. After your mail I tried even single fprintf(stderr, “Can’t open video: %s\n”, SDL_GetError()); statement, but that would just output "Can’t open video: " and nothing else.

Don’t know, maybe it’s something else with that program. Are there any other test programs…

(stop)

I’ve just found testvidinfo.c and inside it this line:

if ( info->hw_available )
printf(“Hardware surfaces are available (%dK video memory)\n”, info->video_mem);

So it looks like hadware surfaces have to be available in order to get amount of free video memory (ok, logical). So I changed that test in a way you can see in attachment.

If there’s only SDL_HWSURFACE I get: “It ISN’T possible to create hardware surfaces, but screen surface IS hardware, 0 kilobytes video memory”. When there’s also SDL_FULLSCREEN I get the same. With other flags (SDL_ANYFORMAT, SDL_DOUBLEBUF), results were identical.

Ok, so it appears that SDL_GetVideoInfo works ok, the only thing that worries me, is:

  • why I can’t get hardware surfaces but my screen surface is hardware? that’s strange…
  • value of available hardware memory equals to 0 - this stays true even in tests with OpenGL

Btw, if I putenv(“SDL_VIDEODRIVER=directx”); before SDL_Init, it fails and error is: “No available video device”. I’ve got Directx 9.0b - maybe it’ll help with sth.

Koshmaar
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed…
Name: main.cpp
URL: http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20050809/7dfaf273/attachment.asc

Total amount of video memory: 0 kilobytes.
Video driver: windib

This is the problem right here. Your SDL DLL doesn’t have DirectX support
for some reason. Did you build it yourself?

See ya,
-Sam Lantinga, Software Engineer, Blizzard Entertainment

Total amount of video memory: 0 kilobytes.
Video driver: windib

This is the problem right here. Your SDL DLL doesn’t have DirectX support
for some reason. Did you build it yourself?

See ya,
-Sam Lantinga, Software Engineer, Blizzard Entertainment

? Hmmm, no, it’s normal SDL 1.2.8 downloaded from libsdl.org… :-? Strange… btw, if I force directx (putenv etc.) then SDL_Init returns error code.

Koshmaar