N00b questions... (I'm sorry! Stop slapping me with old fish ; ))

Hi,

I’ve recently decided to start coding some games in C, and i want to use
SDL, sofar SDL seems like an ideal solution, but finding your way around
the available documentation is rather lots of hitting google with the
right questions type of thing, is there an online API reference page or
something with a list of available functions & their parameters (plus
short description)? Or did i miss a big link on the SDL site & deserve a
public flogging for even asking this? :stuck_out_tongue:

Currently i’m looking for a way to save an 8bit surface’s content &
palette into a file with fwrite to be loaded into a surface afterwards
with fread, anyone have some pointers?

Cheers

hehe

Ok; I’m all out of fish now, so I figure I might as well reply. :wink:

Hi,

I’ve recently decided to start coding some games in C, and i want to
use SDL, sofar SDL seems like an ideal solution, but finding your
way around the available documentation is rather lots of hitting
google with the right questions type of thing, is there an online
API reference page or something with a list of available functions &
their parameters (plus short description)? Or did i miss a big link
on the SDL site & deserve a public flogging for even asking this? :stuck_out_tongue:

Well, I’ve been using Linux for some years, so I never ran into that
problem. I just type “man SDL_BlitSurface” or whatever, and I get
exactly the kind of information you’re asking for. :slight_smile:

Now, if there are Un*x man pages, there usually are online versions,
off-line HTML versions and whatnot of them as well…

having a look around

Yes - try these:
http://www.libsdl.org/docs.php
http://www.libsdl.org/cgi/docwiki.cgi/SDL_20API

Currently i’m looking for a way to save an 8bit surface’s content &
palette into a file with fwrite to be loaded into a surface
afterwards with fread, anyone have some pointers?

That’s possible, of course (you’ll find what you need in the
SDL_Surface, SDL_PixelFormat and SDL_Palette structs), but it’s
probably easier to just use SDL_SaveBMP() and SDL_LoadBMP(). :slight_smile:

//David Olofson - Programmer, Composer, Open Source Advocate

.------- http://olofson.net - Games, SDL examples -------.
| http://zeespace.net - 2.5D rendering engine |
| http://audiality.org - Music/audio engine |
| http://eel.olofson.net - Real time scripting |
’-- http://www.reologica.se - Rheology instrumentation --'On Thursday 07 December 2006 20:42, Ochal Christophe wrote:

2006/12/7, Ochal Christophe :

Hi,

I’ve recently decided to start coding some games in C, and i want to use
SDL, sofar SDL seems like an ideal solution, but finding your way around
the available documentation is rather lots of hitting google with the
right questions type of thing, is there an online API reference page or
something with a list of available functions & their parameters (plus
short description)? Or did i miss a big link on the SDL site & deserve a
public flogging for even asking this? :stuck_out_tongue:

Look here: http://www.libsdl.org/cgi/docwiki.cgi/SDL_20API>

Currently i’m looking for a way to save an 8bit surface’s content &
palette into a file with fwrite to be loaded into a surface afterwards
with fread, anyone have some pointers?

Cheers


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

I’ve recently decided to start coding some games in C, and i want to use
SDL, sofar SDL seems like an ideal solution, but finding your way around
the available documentation is rather lots of hitting google with the
right questions type of thing, is there an online API reference page or
something with a list of available functions & their parameters (plus
short description)? Or did i miss a big link on the SDL site & deserve a
public flogging for even asking this? :stuck_out_tongue:

There’s a big “DOCUMENTATION” section on the left of http://libsdl.org/

You might want this specifically:
http://www.libsdl.org/cgi/docwiki.cgi/SDL_20API

Or this generally:
http://www.libsdl.org/cgi/docwiki.cgi/

Currently i’m looking for a way to save an 8bit surface’s content &
palette into a file with fwrite to be loaded into a surface afterwards
with fread, anyone have some pointers?

You could always just use SDL_LoadBMP(), or the SDL_image library, but
if you want to do this yourself, create the surface, and then fread()
the content into the surface’s “pixels” field, and call SDL_SetPalette
with the rest of the data you read. (and, uh, the reverse of all of that
for writing it out).

–ryan.

Well, I’ve been using Linux for some years, so I never ran into that
problem. I just type “man SDL_BlitSurface” or whatever, and I get
exactly the kind of information you’re asking for. :slight_smile:

Now, if there are Un*x man pages, there usually are online versions,
off-line HTML versions and whatnot of them as well…

having a look around

Yes - try these:
http://www.libsdl.org/docs.php
http://www.libsdl.org/cgi/docwiki.cgi/SDL_20API

Thx!

Currently i’m looking for a way to save an 8bit surface’s content &
palette into a file with fwrite to be loaded into a surface
afterwards with fread, anyone have some pointers?

That’s possible, of course (you’ll find what you need in the
SDL_Surface, SDL_PixelFormat and SDL_Palette structs), but it’s
probably easier to just use SDL_SaveBMP() and SDL_LoadBMP(). :slight_smile:

Yea, but i want to dump several things into one file instead of lots of
little files, so SDL_SaveBMP etc won’t do, i think i have a pretty
decent idea of how to proceed tho…On Thu, 2006-12-07 at 21:04 +0100, David Olofson wrote:

You could always just use SDL_LoadBMP(), or the SDL_image library, but
if you want to do this yourself, create the surface, and then fread()
the content into the surface’s “pixels” field, and call SDL_SetPalette
with the rest of the data you read. (and, uh, the reverse of all of that
for writing it out).

Thx for the tips!On Thu, 2006-12-07 at 15:09 -0500, Ryan C. Gordon wrote:

[…]

Currently i’m looking for a way to save an 8bit surface’s
content &
palette into a file with fwrite to be loaded into a surface
afterwards with fread, anyone have some pointers?

That’s possible, of course (you’ll find what you need in the
SDL_Surface, SDL_PixelFormat and SDL_Palette structs), but it’s
probably easier to just use SDL_SaveBMP() and SDL_LoadBMP(). :slight_smile:

Yea, but i want to dump several things into one file instead of lots
of little files, so SDL_SaveBMP etc won’t do, i think i have a
pretty decent idea of how to proceed tho…

I see. Have a look at this then:
http://www.kekkai.org/roger/sdl/rwops/rwops.html

//David Olofson - Programmer, Composer, Open Source Advocate

.------- http://olofson.net - Games, SDL examples -------.
| http://zeespace.net - 2.5D rendering engine |
| http://audiality.org - Music/audio engine |
| http://eel.olofson.net - Real time scripting |
’-- http://www.reologica.se - Rheology instrumentation --'On Thursday 07 December 2006 21:29, Ochal Christophe wrote:

Yea, but i want to dump several things into one file instead of lots
of little files, so SDL_SaveBMP etc won’t do, i think i have a
pretty decent idea of how to proceed tho…

I see. Have a look at this then:
http://www.kekkai.org/roger/sdl/rwops/rwops.html

Looks intresting, i’ll have to look into that.

On a sidenote, can someone tell me why the following doesn’t work?

fwrite((screen->format->BitsPerPixel, sizeof(unsigned int),
(sizeof(unsigned int)/sizeof(unsigned int)), file);

Where screen is a *Surface and file a filepointer, i know it’s related
to the way i passed screen->format->BitsPerPixel, fwrite expects a
pointer to the value of BitsPerPixel, but for the life of me i can’t
remember how it was done, digged up my C manuals to read up on pointers
again, but if someone could tell me what my obvious error is i’d
appreciate it ;)On Thu, 2006-12-07 at 21:58 +0100, David Olofson wrote:

Ochal Christophe wrote:

On a sidenote, can someone tell me why the following doesn’t work?

fwrite((screen->format->BitsPerPixel, sizeof(unsigned int),
(sizeof(unsigned int)/sizeof(unsigned int)), file);

Where screen is a *Surface and file a filepointer, i know it’s related
to the way i passed screen->format->BitsPerPixel, fwrite expects a
pointer to the value of BitsPerPixel, but for the life of me i can’t
remember how it was done, digged up my C manuals to read up on pointers
again, but if someone could tell me what my obvious error is i’d
appreciate it :wink:

Wthout digging out my pointer reference, I think it’s

&screen->format->BitsPerPixel

Jim

Yep, it is, thx mate!On Thu, 2006-12-07 at 17:43 -0500, James Barrett wrote:

Ochal Christophe wrote:

On a sidenote, can someone tell me why the following doesn’t work?

fwrite((screen->format->BitsPerPixel, sizeof(unsigned int),
(sizeof(unsigned int)/sizeof(unsigned int)), file);

Where screen is a *Surface and file a filepointer, i know it’s related
to the way i passed screen->format->BitsPerPixel, fwrite expects a
pointer to the value of BitsPerPixel, but for the life of me i can’t
remember how it was done, digged up my C manuals to read up on pointers
again, but if someone could tell me what my obvious error is i’d
appreciate it :wink:

Wthout digging out my pointer reference, I think it’s

&screen->format->BitsPerPixel

There’s also an extra open parenthesis there… I’m sure you’d notice when compiling.> From: ochal at kefren.be> To: sdl at libsdl.org> Date: Thu, 7 Dec 2006 23:41:23 +0100> Subject: Re: [SDL] N00b questions… (I’m sorry! Stop slapping me with old fish ; ))> > On Thu, 2006-12-07 at 17:43 -0500, James Barrett wrote:> > Ochal Christophe wrote:> > >> > > On a sidenote, can someone tell me why the following doesn’t work?> > >> > > fwrite((screen->format->BitsPerPixel, sizeof(unsigned int),> > > (sizeof(unsigned int)/sizeof(unsigned int)), file);> > >> > > Where screen is a *Surface and file a filepointer, i know it’s related> > > to the way i passed screen->format->BitsPerPixel, fwrite expects a> > > pointer to the value of BitsPerPixel, but for the life of me i can’t> > > remember how it was done, digged up my C manuals to read up on pointers> > > again, but if someone could tell me what my obvious error is i’d> > > appreciate it ;)> > > > Wthout digging out my pointer reference, I think it’s> > > > &screen->format->BitsPerPixel> > Yep, it is, thx mate!> > > _______________________________________________> SDL mailing list> SDL at libsdl.org> http://www.libsdl.org/mailman/listinfo/sdl


Express yourself with gadgets on Windows Live Spaces
http://discoverspaces.live.com?source=hmtag1&loc=us