Q about speed

Hi,
i want to make my own simple sprite engine.And of course i need to make
it fast. The question. How should i blit to make it as fast as it can?
Make temporary drawing surface and blit it? Or blit it direct to screen
and call flip? Pls help.
And another question is about timer. Can someone tell me how to define
timer function and how to send parametrs to it? Please can u send litle
example?
Thanks Jan Kratochvil

Hi,
i want to make my own simple sprite engine.And of course i need to make
it fast. The question. How should i blit to make it as fast as it can?
Make temporary drawing surface and blit it? Or blit it direct to screen
and call flip? Pls help.

The fastest blit possible is the simplest one; just blit to the screen.
However, make sure to convert the sprites to the pixel format of the screen
after loading them. If you can get the video card to do the blitting, make
sure that all data is in VRAM. If not, make sure the sprite data is not in
VRAM, as the CPU will have to read it.

Also, be careful about how you preserve the background; in a heavily animated
and/or scrolling game, you’re usually better off just repainting the entire
screen every frame. Don’t copy the background from VRAM unless you’re sure
the video card does the actual blit!

If you have a lot of overdraw that you can’t eliminate, it may be faster to
render the entire screen in a software surface and blitting that to the
screen surface. This also goes for anything more advanced than colorkeyed
blits; alpha blending, pixel effect etc are either not supported by 2D
graphics APIs, or is better done in software.

Finally, you might want to try doing it all using OpenGL… (Still using SDL
for init and all other stuff.) Pretty much all blitting effects you can dream
of (alpha, “tinting” with any color, rotation, scaling, blurring,
antialiazing, sub-pixel accuracy etc), and it’s lightning fast on all by the
crappiest video cards, especially compared to software rendering at higher
resolutions. However, it obviously does require a 3D video card!

And another question is about timer. Can someone tell me how to define
timer function and how to send parametrs to it? Please can u send litle
example?

Well, I could read the docs and try to explain them, but it’s probably better
if someone who actually used that feature explains it! :slight_smile:

//David Olofson — Programmer, Reologica Instruments AB

.- 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 22 June 2001 10:40, Jan Kratochvil wrote:

Finally, you might want to try doing it all using OpenGL… (Still using SDL
for init and all other stuff.) Pretty much all blitting effects you can dream
of (alpha, “tinting” with any color, rotation, scaling, blurring,
antialiazing, sub-pixel accuracy etc), and it’s lightning fast on all by the
crappiest video cards, especially compared to software rendering at higher
resolutions. However, it obviously does require a 3D video card!

It sounds good. But i don’t know much about OpenGL. If i understand it
correctly i shouldn’t need much from OpenGL just some function for
bliting?? I searched OpenGL tutorials (link from www.libsdl.org) but i
didn’t find such an easy example. (just place picture to screen…using
alpha channel) Other question where can i find some good OpenGL api
documentation?
Thanks Jan Kratochvil

Tutorials for OpenGL

http://www.opengl.org/developers/code/tutorials.html

Murlock> ----- Original Message -----

From: honza@twin.jikos.cz (Jan Kratochvil)
To:
Sent: Wednesday, June 27, 2001 8:15 AM
Subject: Re: [SDL] Q about speed

Finally, you might want to try doing it all using OpenGL… (Still using
SDL

for init and all other stuff.) Pretty much all blitting effects you can
dream

of (alpha, “tinting” with any color, rotation, scaling, blurring,
antialiazing, sub-pixel accuracy etc), and it’s lightning fast on all by
the

crappiest video cards, especially compared to software rendering at
higher

resolutions. However, it obviously does require a 3D video card!

It sounds good. But i don’t know much about OpenGL. If i understand it
correctly i shouldn’t need much from OpenGL just some function for
bliting?? I searched OpenGL tutorials (link from www.libsdl.org) but i
didn’t find such an easy example. (just place picture to screen…using
alpha channel) Other question where can i find some good OpenGL api
documentation?
Thanks Jan Kratochvil

http://www.opengl.org

Mikael> ----- Original Message -----

From: honza@twin.jikos.cz (Jan Kratochvil)
To:
Sent: Wednesday, June 27, 2001 8:15 AM
Subject: Re: [SDL] Q about speed

Finally, you might want to try doing it all using OpenGL… (Still using
SDL

for init and all other stuff.) Pretty much all blitting effects you can
dream

of (alpha, “tinting” with any color, rotation, scaling, blurring,
antialiazing, sub-pixel accuracy etc), and it’s lightning fast on all by
the

crappiest video cards, especially compared to software rendering at
higher

resolutions. However, it obviously does require a 3D video card!

It sounds good. But i don’t know much about OpenGL. If i understand it
correctly i shouldn’t need much from OpenGL just some function for
bliting?? I searched OpenGL tutorials (link from www.libsdl.org) but i
didn’t find such an easy example. (just place picture to screen…using
alpha channel) Other question where can i find some good OpenGL api
documentation?
Thanks Jan Kratochvil

Finally, you might want to try doing it all using OpenGL… (Still using SDL
for init and all other stuff.) Pretty much all blitting effects you can dream
of (alpha, “tinting” with any color, rotation, scaling, blurring,
antialiazing, sub-pixel accuracy etc), and it’s lightning fast on all by the
crappiest video cards, especially compared to software rendering at higher
resolutions. However, it obviously does require a 3D video card!

It sounds good. But i don’t know much about OpenGL. If i understand it
correctly i shouldn’t need much from OpenGL just some function for
bliting?? I searched OpenGL tutorials (link from www.libsdl.org) but i
didn’t find such an easy example. (just place picture to screen…using
alpha channel) Other question where can i find some good OpenGL api
documentation?
Thanks Jan Kratochvil

the ‘nehe’ tutorials are pretty crappy and actually do some things wrong :confused: (imho)

The two ways of shoving a picture on the screen in opengl are either to use
glDrawPixels() or to apply the image as a texture to a quad or tristrip or
something. The glDrawPixels() routine is slower than textures and precludes
rotation and blurring. The texture deal gets into some accuracy problems…

OpenGL textures must be (2^m) x (2^n), so some legal texture sizes are
256x256, 128x128, 256x128, 64x256… but some cards put arbitrary limits.
VoodooG and voodoo2 cards have a limit of 256x256, and trying to use a
512x256 texture will result in that texture being ignored. To cope with
some of these lesser cards, you have to put an arbitrary limit of 256x256
on your image chunks, and page the parts of the picture into texture memory.
Then you get to reassemble them on the card :slight_smile:

If you’re looking for good information on opengl programming, do yourself
a favor and get the ‘red book’. The title is something like “the official
guide to learning opengl” by mason woo, jack neider, tom davis, and paula
womack. ISBN 0201604582. It’ll save you a whole lot of headache and confusion
compared to the nehe ‘tutorials’. :slight_smile:

-Erik <erik at floatingmind.com> [http://math.smsu.edu/~erik/]

I’ve been working on porting NeHe’s tutorials to SDL. Check out
http://nehe.gamedev.net. Also for man pages go
http://www.eecs.tulane.edu/www/graphics/doc/OpenGL-Man-Pages/
Hope that helps.On Wed, 27 Jun 2001, Jan Kratochvil wrote:

Finally, you might want to try doing it all using OpenGL… (Still using SDL
for init and all other stuff.) Pretty much all blitting effects you can dream
of (alpha, “tinting” with any color, rotation, scaling, blurring,
antialiazing, sub-pixel accuracy etc), and it’s lightning fast on all by the
crappiest video cards, especially compared to software rendering at higher
resolutions. However, it obviously does require a 3D video card!

It sounds good. But i don’t know much about OpenGL. If i understand it
correctly i shouldn’t need much from OpenGL just some function for
bliting?? I searched OpenGL tutorials (link from www.libsdl.org) but i
didn’t find such an easy example. (just place picture to screen…using
alpha channel) Other question where can i find some good OpenGL api
documentation?
Thanks Jan Kratochvil

I’ve been working on porting NeHe’s tutorials to SDL.

Heheh, have you looked at:
http://www.libsdl.org/opengl/intro.html

See ya,
-Sam Lantinga, Lead Programmer, Loki Software, Inc.

Ya know I had been to that page before I started porting and never noticed
the tar file at the top of the page… dur. It’s been fun and a good way to
learn both SDL and OpenGL at the same time, though. :slight_smile: I’ll probably go
ahead and finish porting them on my own since I’ve only got maybe 7 more
left… Ah well.

Ti Leggett
leggett at eecs.tulane.edu> ----- Original Message -----

From: slouken@devolution.com (Sam Lantinga)
To:
Sent: Thursday, June 28, 2001 11:10 PM
Subject: Re: [SDL] Q about speed

I’ve been working on porting NeHe’s tutorials to SDL.

Heheh, have you looked at:
http://www.libsdl.org/opengl/intro.html

See ya,
-Sam Lantinga, Lead Programmer, Loki Software, Inc.