Various things

Just ramblings after working with the library for a month:

  1. Resource files. Having folders full of graphics in their native
    format, but if you wanted to release a game with copyright graphics,
    you’d not want them to be sitting there for anyone to just copy.
    Possibly a SDL_Resource file function? Either a wrapper that can be put
    over a custom format, or a format built into the SDL library so that
    it’d be easily ported anywhere.

  2. Windows icons. How do you change the file icon of a windows program?
    I know you can set the icon on the taskbar and title bar, but what about
    the one you see in a folder listing?

  3. Inline Surfaces. Would it be possible/feasbible to declare a
    surface? I believe it’s just struct, yes? So if I had a 60x60 pixel
    surface, I could put it in tile_surface.h and just include it, then use
    it like: tile = tile_surface; This would make for a faster load
    time, and allow smaller things to be kept inside so that you don’t have
    a directory full of 1k graphics.

CK

Just ramblings after working with the library for a month:

  1. Resource files. Having folders full of graphics in their native
    format, but if you wanted to release a game with copyright graphics,
    you’d not want them to be sitting there for anyone to just copy.
    Possibly a SDL_Resource file function? Either a wrapper that can be put
    over a custom format, or a format built into the SDL library so that
    it’d be easily ported anywhere.

I know work has been done to allow zip file reading in the past you
might want to check the mailing list archives to see if you can track
any of the posts down. BTW this would best be done with a custom
library and not directly in SDL.

  1. Windows icons. How do you change the file icon of a windows program?
    I know you can set the icon on the taskbar and title bar, but what about
    the one you see in a folder listing?

You have to do that in with your compiler/linker because windows
stores icons directly in the Application. (In visual C you can do it
by setting an option and including a resource file with icon in your
project).

  1. Inline Surfaces. Would it be possible/feasbible to declare a
    surface? I believe it’s just struct, yes? So if I had a 60x60 pixel
    surface, I could put it in tile_surface.h and just include it, then use
    it like: tile = tile_surface; This would make for a faster load
    time, and allow smaller things to be kept inside so that you don’t have
    a directory full of 1k graphics.

Easiest way to do this would probably just include the data as an
array and then call SDL_CreateSurfaceFrom on it. Never tried it
though so I don’t know how it would work.>

CK

The SDL_RWops can easily be tailored to your needs. Check out a previous
example: http://www.lokigames.com/ml/sdl/7105.htmlOn Tue, Jan 09, 2001 at 10:25:04AM -0600, James Littlefield wrote:

  1. Resource files. Having folders full of graphics in their native
    format, but if you wanted to release a game with copyright graphics,
    you’d not want them to be sitting there for anyone to just copy.
    Possibly a SDL_Resource file function? Either a wrapper that can be put
    over a custom format, or a format built into the SDL library so that
    it’d be easily ported anywhere.

    Martin

    Bother! said Pooh, as his rubber woman sprung a leak.

Tue, 09 Jan 2001 Phoenix Kokido wrote:
[…]

BTW this would best be done with a custom
library and not directly in SDL.

I’m not sure it’s as simple as that. From a technical POV, you’re right, but if
we’re talking about open source, code reuse etc, it starts to complicate things
if people are using too many different libraries that do basically the same
thing. Choice is good, but it doesn’t come entirely free.

As an example, I’m hacking a high level graphics library/engine. (Loading
data, converting tiles and sprites into the most suitable formats for the
current target, rendering in ways similar to OpenGL etc.) To be useful to
others without too much hacking, it’ll probably have to use either a callback
based resource file access interface, or a very popular library. In that case,
a solution that comes with SDL would be the natural choice, as the
library/engine itself is based on SDL.

Another reasons to go with an SDL alternative would be that it’s most likely
going to work on all platforms supported by SDL.

  1. Inline Surfaces. Would it be possible/feasbible to declare a
    surface? I believe it’s just struct, yes? So if I had a 60x60 pixel
    surface, I could put it in tile_surface.h and just include it, then use
    it like: tile = tile_surface; This would make for a faster load
    time, and allow smaller things to be kept inside so that you don’t have
    a directory full of 1k graphics.

Easiest way to do this would probably just include the data as an
array and then call SDL_CreateSurfaceFrom on it. Never tried it
though so I don’t know how it would work.

Should work, I think. Have the “source generator” include the size and data
format first in the data, and you don’t have to fiddle with the code after
changing the graphics. (That does get messy pretty soon, especially when
tweaking the graphics + code interaction…)

//David

…- M A I A -------------------------------------------------.
| Multimedia Application Integration Architecture |
| A Free/Open Source Plugin API for Professional Multimedia |
----------------------> http://www.linuxaudiodev.com/maia -' ..- David Olofson -------------------------------------------. | Audio Hacker - Open Source Advocate - Singer - Songwriter |--------------------------------------> david at linuxdj.com -’

Tue, 09 Jan 2001 James Littlefield wrote:

Just ramblings after working with the library for a month:

  1. Resource files. Having folders full of graphics in their native
    format, but if you wanted to release a game with copyright graphics,
    you’d not want them to be sitting there for anyone to just copy.
    Possibly a SDL_Resource file function? Either a wrapper that can be put
    over a custom format, or a format built into the SDL library so that
    it’d be easily ported anywhere.

tar, tar.gz or tar.bz2?

But one reason to invent Yet Another Resource File Format is based on
the Security Through Obscurity idea - ie the point (besides keeping everything
in one file to speed up loading and reduce the amount of space wasted by the
file system) is to make it harder for people to mess with the data.

An SDL framework with callbacks that implement things like open(), close(),
read(), write(), seek() etc could still be handy, though. (It would make file
handling code more reusable and portable, if nothing else.) And of course, not
all developers want to deliberately make their data hard to access!

  1. Windows icons. How do you change the file icon of a windows program?
    I know you can set the icon on the taskbar and title bar, but what about
    the one you see in a folder listing?

The icons are stored as resources inside EXEs or DLLs. I don’t know the
details about how to make a cross compiler throw them in, though. (I rarely
touch Windows these days, except for some Delphi hacking…)

  1. Inline Surfaces. Would it be possible/feasbible to declare a
    surface? I believe it’s just struct, yes?

Well, yes, but it’s a structure that contains pointers. Unfortunately, I have
a faint memory of experiences indicating that support for relocation of
pointers inside data chunks isn’t standardized, so there might be trouble
getting it to build on some platforms.

However, it shouldn’t be a problem including raw data (either as hexdumps or
as object files ready for linking) - just throw in a tiny header followed by
raw data, and then build a little function that can turn that into an
SDL_Surface. You’ll lose compression, though…

Another method would be to include files as raw data, and use a (perhaps
slightly modified) image library to unpack them.

The next step is to include an entire resource file as a virtual file system
inside the binary - that’s how single file demos are made on most platforms.
There are basically two variants of this;

1) compile or link the resource file in a build time, as a part
   of the application (basically the previous method, although
   using a single data chunk for all files), or

2) build the application, write the executable length into a
   variable in the data segment, and then append the resource
   file at the end of the executable. The application will
   open it's own binary, seek to the position indicated by the
   aforementioned variable, and then read it's data from there.

//David

…- M A I A -------------------------------------------------.
| Multimedia Application Integration Architecture |
| A Free/Open Source Plugin API for Professional Multimedia |
----------------------> http://www.linuxaudiodev.com/maia -' ..- David Olofson -------------------------------------------. | Audio Hacker - Open Source Advocate - Singer - Songwriter |--------------------------------------> david at linuxdj.com -’

James Littlefield wrote:

  1. Windows icons. How do you change the file icon of a windows program?
    I know you can set the icon on the taskbar and title bar, but what about
    the one you see in a folder listing?

This can be done fairly easily with mingw32, even when cross compiling.
The tool is called “windres”, and it compiles a “.rc” file into a ".o"
file,
which can be linked with your app.

-Ray