Window resizing

A while back there was some talk about adding support for user-resizable
windows in SDL. At the time I didn’t think it would be worth the effort,
but I’m now thinking it’d be a really nice feature to have.

Did anyone ever come up with some code to do it?
Would anyone else find it useful if I had a go at adding it?

Should have spoken up when I had the chance. Doh!

Ben.–
Ben Campbell (Antipodean Straggler)
Programmer, Creature Labs
ben.campbell at creaturelabs.com
www.creatures.co.uk

ive been contemplateing messing with doing it, feel free to go ahead and
take a shot at it ill probly never get around to it, i was thinking about
adding some scaled/stretched blitting a while back for various reasons and
its been running through my head how that with the ability to do it on the
fly (probly just require changing the blitter used to a stretching one and
alter the params it uses for scaling as the window is resized) is all thats
really needed for window resizeing code. Hermes has some scaled/stretched
blitting code that might be useful for it, and i know there was a c++ lib
floating around that did something like that, also LsdlDoom
(http://firehead.org/~jessh/lsdldoom/) has some slow scaled blitting code
(C and inline ASM). please keep me posted if you do do any work on it.

Jess

Ben Campbell wrote:> A while back there was some talk about adding support for user-resizable

windows in SDL. At the time I didn’t think it would be worth the effort,
but I’m now thinking it’d be a really nice feature to have.

Did anyone ever come up with some code to do it?
Would anyone else find it useful if I had a go at adding it?

Should have spoken up when I had the chance. Doh!

Ben.

Ben Campbell (Antipodean Straggler)
Programmer, Creature Labs
ben.campbell at creaturelabs.com
www.creatures.co.uk

Does anyone here know how to load a tga into a SDL surface?
the sdl image lib doesnt seem to have it …

At 17:14 28/04/00 +1200, you wrote:

Does anyone here know how to load a tga into a SDL surface?
the sdl image lib doesnt seem to have it …
How many images do you have? Set up a GIMP script to convert your
TGAs to PNG and you’ll be all set, with smaller (lossless compression)
files which are still 32 bpp with full alpha support–and SDL is ready
to go.

If you simply must use TGA then have a look at the SDL_image library
and modify one of the extant files to load TGAs. Depending on how
familiar you are with TGAs, and the level of support you need to provide,
this could take two days or five weeks–it’s
not as simple as merely modifying a few variables; the extant format
loaders will only serve as a guide to the procedure. You’ll need to go
surfing and find the spec for TGA files and build in support for any tags
you need, make sure you take care of big/little endian byte order, etc.

I modified SDL_image to load TIFFs (using libtiff, which made life much
easier but still not that easy) but ended up going with PNGs in the end.

Steve Madsen
H2Eye Ltd.
24-28 Hatton Wall
London EC1N 8JH
UNITED KINGDOM (UK)
Tel: +44 (0) 207 404 9600
Fax: +44 (0) 207 404 9490
Email: @Steve_Madsen

What tga’s do you have? If non compressed, then writing a functions which
loads them should be work of max 1h, because uncompressed tga format is
very simple- somthing like id, width, height, bits per pixel and raw
image data, if not, then maybe you just should convert them to another
format and load them with imglib or whatever.

KovacsOn Fri, 28 Apr 2000, Oliver Batchelor wrote:

Does anyone here know how to load a tga into a SDL surface?
the sdl image lib doesnt seem to have it …

Hmm I was using an app to generate hieght fields and it outputs the
files as 16 bit tgas (terraform)
It instead of putting the usual rgb info in eg 5,6,5 for each color
it just puts all 16 bits for the height of that part of terrain …
If I use gimp to convert tga->png would it mess all that up ?

OliverOn Fri, 28 Apr 2000, you wrote:

At 17:14 28/04/00 +1200, you wrote:

Does anyone here know how to load a tga into a SDL surface?
the sdl image lib doesnt seem to have it …
How many images do you have? Set up a GIMP script to convert your
TGAs to PNG and you’ll be all set, with smaller (lossless compression)
files which are still 32 bpp with full alpha support–and SDL is ready
to go.

If you simply must use TGA then have a look at the SDL_image library
and modify one of the extant files to load TGAs. Depending on how
familiar you are with TGAs, and the level of support you need to provide,
this could take two days or five weeks–it’s
not as simple as merely modifying a few variables; the extant format
loaders will only serve as a guide to the procedure. You’ll need to go
surfing and find the spec for TGA files and build in support for any tags
you need, make sure you take care of big/little endian byte order, etc.

I modified SDL_image to load TIFFs (using libtiff, which made life much
easier but still not that easy) but ended up going with PNGs in the end.

Steve Madsen
H2Eye Ltd.
24-28 Hatton Wall
London EC1N 8JH
UNITED KINGDOM (UK)
Tel: +44 (0) 207 404 9600
Fax: +44 (0) 207 404 9490
Email: steve at h2eye.com

It seems then that there are two sorts of resizing

  1. One that keeps the underlying SDLSurface the same size, and blits it in a
    scaled way.

  2. One that resizes the underlying SDLSurface.

To do number 2, it would presumably need some kind of callback so the
application can build the contents of the larger surface.

Francis> -----Original Message-----

From: Jess
Sent: 28 April 2000 12:36
To: sdl at lokigames.com
Subject: [SDL] Re: Window resizing

ive been contemplateing messing with doing it, feel free to
go ahead and
take a shot at it ill probly never get around to it, i was
thinking about
adding some scaled/stretched blitting a while back for
various reasons and
its been running through my head how that with the ability to
do it on the
fly (probly just require changing the blitter used to a
stretching one and
alter the params it uses for scaling as the window is
resized) is all thats
really needed for window resizeing code. Hermes has some
scaled/stretched
blitting code that might be useful for it, and i know there
was a c++ lib
floating around that did something like that, also LsdlDoom
(http://firehead.org/~jessh/lsdldoom/) has some slow scaled
blitting code
(C and inline ASM). please keep me posted if you do do any work on it.

Jess

Ben Campbell wrote:

A while back there was some talk about adding support for
user-resizable
windows in SDL. At the time I didn’t think it would be
worth the effort,
but I’m now thinking it’d be a really nice feature to have.

Did anyone ever come up with some code to do it?
Would anyone else find it useful if I had a go at adding it?

Should have spoken up when I had the chance. Doh!

Ben.

Ben Campbell (Antipodean Straggler)
Programmer, Creature Labs
ben.campbell at creaturelabs.com
www.creatures.co.uk

ahahah I tried it and it absolutely wastes it !!

I suppose I could just do my hf’s in gimp and read the height from
the addition of the r g and b values … then image formats wouldnt
get stuffed up .

png formats are 8 bits/channel ? because
SDL_surfaces are 8 bits/channel in memory arent they ?

thanks,
Oliver BatchelorOn Fri, 28 Apr 2000, you wrote:

What tga’s do you have? If non compressed, then writing a functions which
loads them should be work of max 1h, because uncompressed tga format is
very simple- somthing like id, width, height, bits per pixel and raw
image data, if not, then maybe you just should convert them to another
format and load them with imglib or whatever.

Kovacs

On Fri, 28 Apr 2000, Oliver Batchelor wrote:

Does anyone here know how to load a tga into a SDL surface?
the sdl image lib doesnt seem to have it …

using a png and loading into a sdl surface with imglib to use as an
opengl texture is the format abgr of the pixels or something wierd
like that?

I know that loading a bmp where there is 3 bytes / pixel its bgr and
I have to convert to rgb for opengl … so can anyone tell me what the
pixel format is for 4 bytes/pixel ?

thanks,
Oliver BatchelorOn Fri, 28 Apr 2000, you wrote:

ahahah I tried it and it absolutely wastes it !!

I suppose I could just do my hf’s in gimp and read the height from
the addition of the r g and b values … then image formats wouldnt
get stuffed up .

png formats are 8 bits/channel ? because
SDL_surfaces are 8 bits/channel in memory arent they ?

thanks,
Oliver Batchelor

On Fri, 28 Apr 2000, you wrote:

What tga’s do you have? If non compressed, then writing a functions which
loads them should be work of max 1h, because uncompressed tga format is
very simple- somthing like id, width, height, bits per pixel and raw
image data, if not, then maybe you just should convert them to another
format and load them with imglib or whatever.

Kovacs

On Fri, 28 Apr 2000, Oliver Batchelor wrote:

Does anyone here know how to load a tga into a SDL surface?
the sdl image lib doesnt seem to have it …

You can’t depend on the channel position being constant. You need to check
the masks and shift on a per-image basis (you might be able to get away
with it if you’re only using one image format, but you will need to check
the masks and shift values anyway, to set up the hardcode!)

See the “Video Function Reference” page on the SDL website, and investigate
the “format” member of the SDL_Surface struct.

HTH

Steve Madsen

At 23:32 28/04/00 +1200, you wrote:>using a png and loading into a sdl surface with imglib to use as an

opengl texture is the format abgr of the pixels or something wierd
like that?

I know that loading a bmp where there is 3 bytes / pixel its bgr and
I have to convert to rgb for opengl … so can anyone tell me what the
pixel format is for 4 bytes/pixel ?

thanks,
Oliver Batchelor

“Francis Irving” wrote

It seems then that there are two sorts of resizing

  1. One that keeps the underlying SDLSurface the same
    size, and blits it in a scaled way.

  2. One that resizes the underlying SDLSurface.

To do number 2, it would presumably need some kind
of callback so the application can build the contents of
the larger surface.

I am definitely in favor of resizing the underlying surface versus
stretching it. We would need an “SDL_SizeEvent” since a callback would have
the same multi-thread issues an event filter. We would also need an
"SDL_RESIZEABLE" flag to pass when setting the video mode so that the window
manager will allow the window to be resized.

Without a callback there are synchronization issues between the window
manager and the SDL internal event queue. Maybe SDL should just use the
original shadow surface until the application receives the “SDL_SizeEvent”.
You would end up with an unpainted border on the bottom and right-hand sides
(assuming you are making the window bigger) until the event made it through
the internal event queue but at least things wouldn’t change while the
application wasn’t looking.

  • Randi

Regimental Command
Generic Armored Combat System
http://www-users.cs.umn.edu/~relander/regcom/index.html

Does anyone here know how to load a tga into a SDL surface?
the sdl image lib doesnt seem to have it …

Having written a number of TGA encoders/decoders, I can assure you it is
nearly trivial since it is a very simple format (even if you allow RLE
encoding). The only major drawback is its lack of magic number in the header,
so you have to identify them by the file suffix.

Does anyone here know how to load a tga into a SDL surface?
the sdl image lib doesnt seem to have it …

Having written a number of TGA encoders/decoders, I can assure you it is
nearly trivial since it is a very simple format (even if you allow RLE
encoding). The only major drawback is its lack of magic number in the header,
so you have to identify them by the file suffix.

Why not compare the width/height/bpp information to the size of the raw data as
a sanity check?

Nicholas

Why not compare the width/height/bpp information to the size of the raw data as
a sanity check?

It still doesn’t guarantee against a false positive, and it requires decoding
the entire file in the presence of RLE compression. Worse, it makes the
magic numbers of other formats hazardous as they might mistakenly identify
a .tga as (say) a Group 3 Fax file. (The last case actually did happen in
the Gimp. It has now been fixed, so the file suffix is tested against
magicless formats first.)

A while back there was some talk about adding support for user-resizable
windows in SDL. At the time I didn’t think it would be worth the effort,
but I’m now thinking it’d be a really nice feature to have.

Did anyone ever come up with some code to do it?
Would anyone else find it useful if I had a go at adding it?

Yup, I just implemented it. :slight_smile:

See my next post for details.

See ya!
-Sam Lantinga, Lead Programmer, Loki Entertainment Software

Sam Lantinga wrote:

A while back there was some talk about adding support for user-resizable
windows in SDL. At the time I didn’t think it would be worth the effort,
but I’m now thinking it’d be a really nice feature to have.

Did anyone ever come up with some code to do it?
Would anyone else find it useful if I had a go at adding it?

Yup, I just implemented it. :slight_smile:

Man… Why don’t you just take all the fun out of it… :wink:

Nice one Sam - I’ll buy you a beer next time I go Californiawards!

Ben.–
Ben Campbell (Antipodean Straggler)
Programmer, Creature Labs
ben.campbell at creaturelabs.com
www.creaturelabs.com

Oliver Batchelor wrote:

Hmm I was using an app to generate hieght fields and it outputs the
files as 16 bit tgas (terraform)
It instead of putting the usual rgb info in eg 5,6,5 for each color
it just puts all 16 bits for the height of that part of terrain …
If I use gimp to convert tga->png would it mess all that up ?

Gimp should do it OK… I’ve not done much 16bit stuff wiht it.
The PNG format itself does support what you want: 16 bit grayscale.

For the game I’m working on (Beasts) we’re using PNG for most of the
artwork. It’s a great general-purpose format.

Ben.–
Ben Campbell (Antipodean Straggler)
Programmer, Creature Labs
ben.campbell at creaturelabs.com
www.creaturelabs.com

Nice one Sam - I’ll buy you a beer next time I go Californiawards!

Sounds good, I’ll take you up on that. :slight_smile:

Will you be at E3?

See ya,
-Sam Lantinga, Lead Programmer, Loki Entertainment Software

Nice one Sam - I’ll buy you a beer next time I go Californiawards!

Sounds good, I’ll take you up on that. :slight_smile:

Right… let me know when you’re buying him a beer; I seem to recall that I
owe him a pizza, so he can have a night out. :slight_smile:

Will you be at E3?

Christ, you folks get all the good gigs. :slight_smile:

See ya,
-Sam Lantinga, Lead Programmer, Loki Entertainment Software

Nicholas

----- Original Message -----
From: slouken@devolution.com (Sam Lantinga)
To: sdl at lokigames.com
Date: Monday, May 01, 2000 9:49 AM
Subject: Re: [SDL] Window resizing

Sam Lantinga wrote:

Nice one Sam - I’ll buy you a beer next time I go Californiawards!

Sounds good, I’ll take you up on that. :slight_smile:

Will you be at E3?

No (un?)fortunately. The project I’m on is still in the
’looks-like-crap-nothing-to-see-here-move-along-please’ phase.

BTW, I’ve now tried the window-resize support - it worked first time and
I’ve had no problems with it, so thanks again!

Ben.–
Ben Campbell (Antipodean Straggler)
Programmer, Creature Labs
ben.campbell at creaturelabs.com
www.creaturelabs.com