Direct image draw

Hello, been playing around with some direct drawing routines, i.e
plotting pixels directly on the screen, (or another surface and then blit it
on.) I’m using basically the same routines that’s used in the examples in the
docs and in for ex. the stars demo, but they’re a bit slow. The code used in
the PTC demos seems fast enough, but since I don’t program C++ I have a somewhat
hard time reading the code. Anyone have a good method to do some direct pixel ->
surface plotting? Or just some tips?

//Anders–
“Programming is partially an artform and, like artists,
programmers will do it even if the don’t get money.”
- Linus Torvalds

At 05:08 PM 5/2/99 +0200, you wrote:

Hello, been playing around with some direct drawing routines, i.e
plotting pixels directly on the screen, (or another surface and then blit it
on.) I’m using basically the same routines that’s used in the examples in the
docs and in for ex. the stars demo, but they’re a bit slow. The code used in
the PTC demos seems fast enough, but since I don’t program C++ I have a
somewhat
hard time reading the code. Anyone have a good method to do some direct
pixel ->
surface plotting? Or just some tips?

//Anders

Some tips

Tip 1
Draw to memory.
Then call a routine to blitz from memory to screen.

Advantages are:
a)Reading/writing to memory is faster than on a video card if you have to
test or modify pixels. Some video cards are slow despite how fast a CPU
can run.
b)Ghosting is eliminated on the screen since the person viewing sees the
final results versus all this repainting that may happen when you are
constructing a new or updated picture.

Tip 2
Blitz to the video screen only as fast as needed.
Here’s a rather long explanation, but the more Everybody knows,
the better…

Technical History
When television was created, it was figured out that the human eye can
only distinguish individual frames upto 24 pictures-per-second at best.
You may know TV is 60 frames-per-second, but this is for interlacing,
which is a “trick” to get more resolution into a TV picture. The actual
picture only changes 30x per-second (30hz).
Why is the TV running at 30 instead of 24?
So that you don’t get flicker on the TV screen due to the power coming
into the TV. Back then, when TV was invented, it was a problem.

Where’s the Tip?
For TV quality action, nobody will notice if you update at 24, 30 or 60x
per second since 24 is the magic number.
Only difference is that you need a faster computer to draw at 30 or 60x
which means fewer people will see what you’ve done since fewer people
will have faster machines.
If you want more people to see your magic, keep the number as low as
possible.
If you use tip#1, then frankly, 18.2 times a second will do fine.
If you do low resolution stuff, you could probably go slower at 9.1x
or 6x per second and still get fluid motion.
6 and 9 is pretty slow numbers compared to computers out there,
especially if you practice using tip#1.

Hope these tips help.

Silva wrote:

At 05:08 PM 5/2/99 +0200, you wrote:

Hello, been playing around with some direct drawing routines, i.e
plotting pixels directly on the screen, (or another surface and then blit it
on.) I’m using basically the same routines that’s used in the examples in the
docs and in for ex. the stars demo, but they’re a bit slow. The code used in
the PTC demos seems fast enough, but since I don’t program C++ I have a
somewhat
hard time reading the code. Anyone have a good method to do some direct
pixel ->
surface plotting? Or just some tips?

//Anders

Are you coding in 8, 16, 24, or 32 bpp? I have something that might help you out
a bit.

Paul Lowe
spazz at ulink.net