Parallax Scrolling 2 & 3

Hi!

Back again with another scrolling example, and a nicer distro of the
last one. The files are at;

http://www.angelfire.com/ar/agc/download/

or, just in case the server doesn’t feel like showing the directory
(as it does right now…);

http://www.angelfire.com/ar/agc/download/parallax2.tgz
http://www.angelfire.com/ar/agc/download/parallax3.tgz

The new version is a simple and unoptimized implementation of
"overdraw elimination". It’s recursive and eliminates all overdraw
if only opaque tiles are rendered, and still supports color keyed and
aplha blended tiles.

However, it does not group “holes” together in any way, which
quickly results in extreme amounts of overhead due to recursion and
clipping when increasing the number of tiles on screen. (Either by
increasing the resolution, or by using smaller tiles.)

This is what I’m going to address in the next version. It may or may
not still be recursive - the algorithm I have in mind doesn’t seem to
get any simpler with recursion, so I might as well do it the faster,
non-recursive way. (Avoiding recursion means that you loop rather
than call, which in turn means that you avoid a lot of pointless
extra pre-loop initializations.)

//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 -’

Nice. However, use sdl-config in your makefiles.On Fri, Feb 23, 2001 at 11:38:57AM +0100, David Olofson wrote:

http://www.angelfire.com/ar/agc/download/parallax2.tgz
http://www.angelfire.com/ar/agc/download/parallax3.tgz

The new version is a simple and unoptimized implementation of
"overdraw elimination". It’s recursive and eliminates all overdraw
if only opaque tiles are rendered, and still supports color keyed and
aplha blended tiles.


Martin

Bother! said Pooh, as the Ravanous Bugblatter Beast of Trall ate Owl.

Hi folks,

I tried to compile your attractive parallax examples, but it failed, as Martin
said, using sdl-config works fine. You will find below the Makefile for
parallax-3. Nice work David, I think it can be very helpful as a tutorial for
SDL and more generally game-programming newbies.--------
CC = gcc
CPATH = -I/usr/include/SDL
CLIBS = $(shell sdl-config --libs)
CFLAGS = -O3 -Wall $(shell sdl-config --cflags)
HEADERS = parallax3.h
SOURCES = parallax3.c

all: parallax3

clean:
rm -f *.o
rm parallax3

parallax3: ${HEADERS} ${SOURCES}
${CC} ${CLIBS} ${CFLAGS} -o parallax3 ${CPATH} ${SOURCES} -lSDL

Cheers,

wwp

CLIBS = $(shell sdl-config --libs)
[snip]
parallax3: ${HEADERS} ${SOURCES}
${CC} ${CLIBS} ${CFLAGS} -o parallax3 ${CPATH} ${SOURCES} -lSDL

that last line should be

	${CC} ${CFLAGS} -o parallax3 ${SOURCES} ${CLIBS}

since libs must come after the objects to make sense

    http://www.angelfire.com/ar/agc/download/parallax2.tgz
    http://www.angelfire.com/ar/agc/download/parallax3.tgz

The new version is a simple and unoptimized implementation of
"overdraw elimination". It’s recursive and eliminates all overdraw
if only opaque tiles are rendered, and still supports color keyed and
aplha blended tiles.

hey, i like this scrolling example, reminds me of some great games in the old
days :slight_smile:

i’m just asking myself if this couldn’t be all done with opengl, the graphics
card would do all overdraw elimination. do you think it would run slower using
opengl? (assuming you have a 3d-acceleration card, of course;)

is it for people who don’t own a 3d-card or am i missing another important
point?

timo

ps: just kick me to the right topic if this has all been discussed somewhere
else.

Hi folks,

I tried to compile your attractive parallax examples, but it failed, as Martin
said, using sdl-config works fine.


CC = gcc
CPATH = -I/usr/include/SDL
CLIBS = $(shell sdl-config --libs)
CFLAGS = -O3 -Wall $(shell sdl-config --cflags)

Just curious… Is this how one can use sdl-config in general? I must confess I
am yet to use it, mainly as I have never taken the time to learn how…On Fri, 23 Feb 2001, you wrote:


Sam “Criswell” Hart <@Sam_Hart> AIM, Yahoo!:
Homepage: < http://www.geekcomix.com/snh/ >
PGP Info: < http://www.geekcomix.com/snh/contact/ >
Advogato: < http://advogato.org/person/criswell/ >

Oops - will fix. :slight_smile:

//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 -'On Friday 23 February 2001 12:32, Martin Donlon wrote:

On Fri, Feb 23, 2001 at 11:38:57AM +0100, David Olofson wrote:

http://www.angelfire.com/ar/agc/download/parallax2.tgz
http://www.angelfire.com/ar/agc/download/parallax3.tgz

The new version is a simple and unoptimized implementation of
"overdraw elimination". It’s recursive and eliminates all overdraw
if only opaque tiles are rendered, and still supports color keyed and
aplha blended tiles.

Nice. However, use sdl-config in your makefiles.

    http://www.angelfire.com/ar/agc/download/parallax2.tgz
    http://www.angelfire.com/ar/agc/download/parallax3.tgz

The new version is a simple and unoptimized implementation of
"overdraw elimination". It’s recursive and eliminates all overdraw
if only opaque tiles are rendered, and still supports color keyed and
aplha blended tiles.

hey, i like this scrolling example, reminds me of some great games in the
old days :slight_smile:

i’m just asking myself if this couldn’t be all done with opengl, the
graphics card would do all overdraw elimination.

Yep, I’m working on that as well. :slight_smile:

do you think it would run slower using opengl? (assuming you have a
3d-acceleration card, of course;)

Nope, it’s fast as h*ll, even on cards that aren’t exactly state-of-the-art.
The animation quality is also very much higher than anything software based,
as the texture filtering can be used for sub-pixel accurate positioning (ie
speed becomes independent of refresh rate without compromizing animation
smoothness), and alpha blending can be used to implement antialiasing. (Well,
both of those are of course possible to o in software as well, but the former
is beyond the power of today’s workstation CPUs, at least for sensible
resolutions, like 640x480+.)

is it for people who don’t own a 3d-card or am i missing another important
point?

That’s basically it, although software rendering does have the advantage of
always producing the same result, as opposed to hardware accelerators.

Then again, from what I’ve seen so far, any card with any kind of texture
filtering does better than a software rasterizer, even if it doesn’t filter
the alpha channel, so I think most gaming machines will produce better
results with OpenGL. Basically any AGP card and most of the PCI "gaming"
cards should be up to it. (Alpha blending and texture filtering must be
possible to do at the same time.)

timo

ps: just kick me to the right topic if this has all been discussed
somewhere else.

Look for “Accelerated 2D APIs” and “hw filled polygons & hw l ines”. We have
discussed related stuff in other threads as well, IIRC, but I wouldn’t say
there is any single right answer here - it depends on how heavy effects you
need, what kind of quality you demand and what kind of users (ie “hardware
requirements”) you target.

Personally, I really want perfectly smooth animation (scrolling in particular

  • that’s where it’s most important) at full frame rate, which basically
    requires OpenGL regardless of the amount of graphical effects. This is partly
    because you can’t reliably select any specific screen refresh rate, but also
    because if even if that was possible, it would still constrain scrolling and
    object movement speeds to fixed integer pixel/frame numbers. A third problem
    is that modern hardware isn’t designed for software rendering, which makes it
    virtually impossible to achieve full frame rate that way, regardless of CPU
    power.

(You’d think a P-III 933 should handle 640x480x24 @ 100Hz easily, but there’s
actually no way to do it, at least not with the drivers and methods I’ve
tried so far! Meanwhile, I can do that with some 2-4 times overdraw with
alpha blending using OpenGL on the Matrox G400 - and it makes any 2D
animation I’ve ever seen before look ridiculous…)

//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 -'On Friday 23 February 2001 16:40, Timo Peichl wrote:

The makefiles have now been updated as suggested by Martin Donlon, wpp and
Mattias Engdeg?rd; URLs are the same as before:

http://www.angelfire.com/ar/agc/download/parallax2.tgz
http://www.angelfire.com/ar/agc/download/parallax3.tgz

//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 -’