New empty surface

Hi

How can i get an new empty surface of a size?
I made a variable SDL_Surface* menu.
I want it to be 100x50 to blit buttons on it and then later blit the
whole menu surface to the screen.

I tried SDL_ConvertSurface, but than i couldn’t change the size.
I tried SDL_CreateRGBSurface, but this semme to complicated for me. Such
an long function just to make a surface?

Isn’t there a function to create a surface of the screen’s format but
with differnt size?

Mirko

Assuming the SDL_Surface* screen is your main window, something like

ur_surface = SDL_CreateRGBSurface(SDL_SWSURFACE | SDL_SRCCOLORKEY |
SDL_SRCALPHA, 100, 50, screen->format->BitsPerPixel,
screen->format->Rmask, screen->format->Gmask, screen->format->Bmask,
screen->format->Amask);

would work in creating an empty surface of the screen’s format.On Mon, 2002-07-08 at 12:52, Mirko Koenig wrote:

Hi

How can i get an new empty surface of a size?
I made a variable SDL_Surface* menu.
I want it to be 100x50 to blit buttons on it and then later blit the
whole menu surface to the screen.

I tried SDL_ConvertSurface, but than i couldn’t change the size.
I tried SDL_CreateRGBSurface, but this semme to complicated for me. Such
an long function just to make a surface?

Isn’t there a function to create a surface of the screen’s format but
with differnt size?

Mirko


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

Hi Mirko,

allthough SDL_CreateRGBSurface seems to be complicated, it’s the
function you require to make a new empty surface :

menu = SDL_CreateRGBSurface(
SDL_SWSURFACE,
100, 50, // Sizes
16, // BPP
#if SDL_BYTEORDER == SDL_LIL_ENDIAN /* OpenGL RGBA masks */
0x000000FF,
0x0000FF00,
0x00FF0000,
0xFF000000);
#else
0xFF000000,
0x00FF0000,
0x0000FF00,
0x000000FF);
#endif

Voila! A new SDL_Surface named menu. This should do for you :slight_smile:

Regards,

Niels Wagenaar> -----Oorspronkelijk bericht-----

Van: koenig [mailto:koenig at v-i-t.de]
Verzonden: maandag 8 juli 2002 21:53
Aan: sdl
Onderwerp: [SDL] new empty surface

Hi

How can i get an new empty surface of a size?
I made a variable SDL_Surface* menu.
I want it to be 100x50 to blit buttons on it and then later blit the
whole menu surface to the screen.

I tried SDL_ConvertSurface, but than i couldn’t change the size.
I tried SDL_CreateRGBSurface, but this semme to complicated
for me. Such
an long function just to make a surface?

Isn’t there a function to create a surface of the screen’s format but
with differnt size?

Mirko


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

nwagenaar at digitaldynamics.nl wrote:

Hi Mirko,

allthough SDL_CreateRGBSurface seems to be complicated, it’s the
function you require to make a new empty surface :

menu = SDL_CreateRGBSurface(
SDL_SWSURFACE,
100, 50, // Sizes
16, // BPP
#if SDL_BYTEORDER == SDL_LIL_ENDIAN /* OpenGL RGBA masks */
0x000000FF,
0x0000FF00,
0x00FF0000,
0xFF000000);
#else
0xFF000000,
0x00FF0000,
0x0000FF00,
0x000000FF);
#endif

Voila! A new SDL_Surface named menu. This should do for you :slight_smile:

Regards,

Niels Wagenaar

except that this is not the optimal solution, Chris Thielen had the optimal solution.
it’s faster to blit a surface that is already in display format…of course.–
-==-
Jon Atkins
http://jonatkins.org/

What is the display format for OpenGL? Optimal compatibility dictates
that the display format always is RGBA (even though it is typically BGRA
for compatibility with DirectX which understands nothing else…)

The patch to make SDL_DisplayFormat do something sane was trivial, and Sam
asked me to do it, but AFAIK it has never been applied. Not sure, he also
forgot to make the CVS commits list… ;)On Tue, Jul 09, 2002 at 04:37:15AM -0500, Jonathan Atkins wrote:

Voila! A new SDL_Surface named menu. This should do for you :slight_smile:

except that this is not the optimal solution, Chris Thielen had the optimal
solution.
it’s faster to blit a surface that is already in display format…of course.


Joseph Carter You’re entitled to my opinion

There are worse things than Perl…ASP comes to mind

-------------- next part --------------
A non-text attachment was scrubbed…
Name: not available
Type: application/pgp-signature
Size: 273 bytes
Desc: not available
URL: http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20020709/8b74f7eb/attachment.pgp