SDL_HWACCEL and SDL_HWPALETTE not available?

Hi.

I’m trying to set the SDL video mode using the flags SDL_HWACCEL and
SDL_HWPALETTE. SDL_SetVideoMode() returns a pointer to the surface as
expected, but if I check for the flags afterwards with SDL_GetVideoSurface()
they are both 0, and my call to SDL_SetPalette() always fails. What could be
wrong?

I am using VC7, WindowsXP, NVidia Quadro FX 2000 with newest display
drivers. Code looks like this:

unsigned int flags =
SDL_OPENGL|SDL_HWPALETTE|SDL_HWSURFACE|SDL_HWACCEL|SDL_FULLSCREEN;
if(fullScreen) flags|= SDL_FULLSCREEN;

SDL_Color colors[256];
int i;
/* Fill colors with color information */
for(i=0;i<256;i++){
  colors[i].r=0;
  colors[i].g=0;
  colors[i].b=0;
}

/* Create display */

SDL_Surface* screen = NULL;
if((screen=SDL_SetVideoMode( winSizeX, winSizeY, bpp, flags )) == NULL )

{
cerr << “deviceWindow ERROR: Video mode set failed:
”<<SDL_GetError() <<"\n";
return;
}

SDL_Surface* check = SDL_GetVideoSurface();
unsigned int fl = check->flags;
if(fl & SDL_HWPALETTE)
  cout << "yes" << endl;
else
  cout << "no" << endl;
if(fl & SDL_HWSURFACE)
  cout << "yes" << endl;
else
  cout << "no" << endl;
if(fl & SDL_HWACCEL)
  cout << "yes" << endl;
else
  cout << "no" << endl;
if(fl & SDL_OPENGL)
  cout << "yes" << endl;
else
  cout << "no" << endl;

/* Set palette */
int ret = SDL_SetPalette(screen, SDL_LOGPAL|SDL_PHYSPAL, colors, 0,

256);

I’m trying to set the SDL video mode using the flags SDL_HWACCEL and
SDL_HWPALETTE.

Not related to the problem, but this is a great opportunity to find out
the reason for the biggest misbelief there is about SDL_SetVideoMode.

Where do people get that SDL_HWACCEL from? It isn’t a flag you can give
to SetVideoMode. It’s a SDL_Surface flag, and a read-only one, you can’t
set it yourself. Where did you get the information that you could use
it?–
Petri Latvala

Petri Latvala wrote:

I’m trying to set the SDL video mode using the flags SDL_HWACCEL and
SDL_HWPALETTE.

Not related to the problem, but this is a great opportunity to find out
the reason for the biggest misbelief there is about SDL_SetVideoMode.

Where do people get that SDL_HWACCEL from? It isn’t a flag you can give
to SetVideoMode. It’s a SDL_Surface flag, and a read-only one, you can’t
set it yourself. Where did you get the information that you could use
it?

Setting that flag yourself is pointless. That was asked recently :
http://twomix.devolution.com/pipermail/sdl/2004-June/062657.html

Stephane

Okay, thanks.

But I’m still wondering why my graphics card doesn’t support hardware
acceleration (or at least why SDL doesn’t recognize) and why I’m not able to
set the SDL_HWPALETTE, which is of more importance to me. Have I missed some
flag while compiling SDL?

Any guesses?
Michael> -----Original Message-----

From: sdl-bounces+michael.weyel=tuebingen.mpg.de at libsdl.org [mailto:sdl-
bounces+michael.weyel=tuebingen.mpg.de at libsdl.org] On Behalf Of Stephane
Marchesin
Sent: Mittwoch, 30. Juni 2004 20:47
To: A list for developers using the SDL library. (includes SDL-announce)
Subject: Re: [SDL] SDL_HWACCEL and SDL_HWPALETTE not available?

Petri Latvala wrote:

I’m trying to set the SDL video mode using the flags SDL_HWACCEL and
SDL_HWPALETTE.

Not related to the problem, but this is a great opportunity to find out
the reason for the biggest misbelief there is about SDL_SetVideoMode.

Where do people get that SDL_HWACCEL from? It isn’t a flag you can give
to SetVideoMode. It’s a SDL_Surface flag, and a read-only one, you can’t
set it yourself. Where did you get the information that you could use
it?

Setting that flag yourself is pointless. That was asked recently :
http://twomix.devolution.com/pipermail/sdl/2004-June/062657.html

Stephane


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

Michael Weyel wrote:

Okay, thanks.

But I’m still wondering why my graphics card doesn’t support hardware
acceleration (or at least why SDL doesn’t recognize) and why I’m not able to
set the SDL_HWPALETTE, which is of more importance to me. Have I missed some
flag while compiling SDL?

Any guesses?
Michael

Your code looks correct. Are you sure the bpp value is 8 ?
Also, keep in mind that SDL doesn’t always satisfy the flags you ask,
SDL_HWPALETTE in particular (but I think in your case, i.e. a full
screen windows app, it should).

Stephane

Your code looks correct. Are you sure the bpp value is 8 ?
Also, keep in mind that SDL doesn’t always satisfy the flags you ask,
SDL_HWPALETTE in particular (but I think in your case, i.e. a full
screen windows app, it should).

Stephane

I check my bpp value before I set it by using SDL_GetVideoInfo() and set it
accordingly (to 32). Is it of any use to give a constant value like 8 or 16?
Strange thing that both ifs

if (info->blit_hw)
flags |= SDL_HWACCEL;
if (info->hw_available)
flags|=SDL_HWSURFACE;

are true…

What I found in the SDL docs is this:

"Two versions, one safe for all systems based on Win32 APIs, and one with
higher performance, based on DirectX APIs. "
"Safe version uses GDI for video display. High performance version uses
DirectDraw for video display, taking advantage of hardware acceleration if
available. "
“Safe version uses waveOut APIs for sound. High performace version uses
DirectSound for audio playback.”

So there are two version for Win32? How do I choose between them then? Or is
it done automatically?

Your code looks correct. Are you sure the bpp value is 8 ?
Also, keep in mind that SDL doesn’t always satisfy the flags you ask,
SDL_HWPALETTE in particular (but I think in your case, i.e. a full
screen windows app, it should).

Stephane

I check my bpp value before I set it by using SDL_GetVideoInfo() and set it
accordingly (to 32). Is it of any use to give a constant value like 8 or 16?

Yes, to get a paletted display, you need to ask for 8bpp.

Strange thing that both ifs

if (info->blit_hw)
flags |= SDL_HWACCEL;
if (info->hw_available)
flags|=SDL_HWSURFACE;

are true…

What I found in the SDL docs is this:

"Two versions, one safe for all systems based on Win32 APIs, and one with
higher performance, based on DirectX APIs. "
"Safe version uses GDI for video display. High performance version uses
DirectDraw for video display, taking advantage of hardware acceleration if
available. "
“Safe version uses waveOut APIs for sound. High performace version uses
DirectSound for audio playback.”

So there are two version for Win32? How do I choose between them then? Or is
it done automatically?

Yes, there are two video drivers under windows. The choice is made automatically at SDL startup and favors directx. However, if you want to force one or the other, you can use the SDL env variable SDL_VIDEODRIVER. Look at the SDL doc for the available drivers :
http://sdldoc.csn.ul.ie/sdlenvvars.php

Stephane