Fastest 2D blit when using SDL/OpenGL

Greetings fellow SDL users/developers,

I’ve got a screenbuffer (SDL_Surface) with a size of 240x160.
This buffer has all the drawing/pixels/etc which has to be
blit to the main SDL_Surface.

Currently I’ve implented the testgl.c example to fiddle around
with SDL/OpenGL (no, not OPENGL_BLIT) but found out that normal
SDL rendering is much faster (I’m converting the screenbuffer
to an OpenGL texture and blit it to the main SDL_Surface). I’m
positive that this can be much faster.

Yet, I’m not an OpenGL guru and seeking help or information
(links, example source, etc) how to archieve the possibly fastest
2D blit code with SDL/OpenGL.

Any help is appreciated!

Regards,

Niels Wagenaar

Yet, I’m not an OpenGL guru and seeking help or information
(links, example source, etc) how to archieve the possibly fastest
2D blit code with SDL/OpenGL.

Niels Wagenaar

Make the image data you want to blit into an OpenGL texture and render it
into the screen as a glQuad. Some limitations occur, such as the image needs
to be a power of 2 in both x & y dimensions- but you can either place your
blit source inside a larger image and grab your image data via UV
coordinates that only contain your image, or you can scale your image to the
next largest power of two (if they are not already) and then specify a
glQuad that scales the image back to your desired size.

This is not really blitting, but achieves the same effect. You’re rendering
a quad with your image as the texture. This renders to the screen rather
than an off screen buffer, so you eliminate the copy to your screen after
the “blits”. You can specify a “z plane” for the various “blits” and
automatically get the correct “blits” to layer on top of each other. This
also enables you to add nice alpha effects via an alpha channel in the image
or by specifying alpha with the guad’s vertex colors. You’ll also gain
subpixel accuracy in the placement of your image data. And finally, YES,
this is as fast as you can get with OpenGL (short of getting into batching
many quads into a structure and then building a display list or vertex
array.)

Using textured quads should be able to handle hundreds of thousands of these
"blits" per frame at 60+ frames per second.

OpenGL will do 2D things screamingly fast. And as a really nice effect, keep
the entire game.application in 2D for 99% of the time- then for special
effect (like killing the final boss) do a 3D camera shake and freak the hell
out of your players. It’s fun.

-BlakeFrom: nwagenaar@digitaldynamics.nl (Niels Wagenaar)
Sent: Wednesday, May 29, 2002 2:16 AM
Subject: [SDL] Fastest 2D blit when using SDL/OpenGL

Using textured quads should be able to handle hundreds of thousands of
these
"blits" per frame at 60+ frames per second.

OpenGL will do 2D things screamingly fast. And as a really nice effect,
keep
the entire game.application in 2D for 99% of the time- then for special
effect (like killing the final boss) do a 3D camera shake and freak the
hell
out of your players. It’s fun.

As long as player has well configured OpenGl. What on linux box happends not
very often.
I have fe VooDoo 3 box, where no opengl is possible (nobody knows why,
becouse with voodoo 2 on the same box mesa is working fine). And i’ve tried
few months ago to setup my friends box (pIII and geforce II mx) and also
none of games can work with opengl…

GJ.

As long as player has well configured OpenGl. What on linux box happends not
very often.
I have fe VooDoo 3 box, where no opengl is possible (nobody knows why,
becouse with voodoo 2 on the same box mesa is working fine). And i’ve tried
few months ago to setup my friends box (pIII and geforce II mx) and also
none of games can work with opengl…

GJ.

Continue trying … I dont know how to do it with a Voodoo3 , but with Nvidia's chips i've configured OpenGL for a GeForce 2 MX and for Riva TNT2, and wasnt so hard. Games and applications runs perfectly .

Sioux

Right, that’s fine and all – it’s possible to get 3d acceleration going on
a Linux box. It’s just not the norm.On Wed, May 29, 2002 at 08:36:26PM +0200, Sioux wrote:

Continue trying … I dont know how to do it with a Voodoo3 , but with Nvidia's chips i've configured OpenGL for a GeForce 2 MX and for Riva TNT2, and wasnt so hard. Games and applications runs perfectly .


Matthew Miller @Matthew_Miller http://www.mattdm.org/
Boston University Linux ------> http://linux.bu.edu/

I want to include for Daimonin RPG OpenGL support - mainly for linux.
Under win32 p3/500 i got >30 fps with alpha transparency windowed or maximum
160fps
without alpha and vsync fullscreen (what makes no sense of course because
heavy flickering).

It just depends on settings, but you got always a usable setup for your
system.

Under unix/linux i thought OpenGL can help to give also native hardware
speed / alpha support.

But i want make me the work only when really needed.

So, on how much system OpenGL really works fine?

Lets ask me this: If we ask 100 linux user - how much really usable OpenGL
settings
will you find and how much will or will be able to run a game on it?>

On Wed, May 29, 2002 at 08:36:26PM +0200, Sioux wrote:

Continue trying … I dont know how to do it with a Voodoo3 , but with Nvidia's chips i've configured OpenGL for a GeForce 2 MX and for Riva TNT2, and wasnt so hard. Games and applications runs perfectly .

Right, that’s fine and all – it’s possible to get 3d
acceleration going on
a Linux box. It’s just not the norm.


Matthew Miller mattdm at mattdm.org http://www.mattdm.org/
Boston University Linux ------> http://linux.bu.edu/


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

Given modern Linux distributions, and anyone who uses it enough to be
playing their games under Linux, I imagine you’d have a low instance of
OpenGL not working for them. I’m mainly basing this off of the many
distribution reviews I’ve seen on the web recently where someone has
remarked ‘Video card detected correctly, 3D works well’. I’m inclined to
say that functioning OpenGL is the norm with a modern distribution, rather
than the exception.

You may’ve just asked 100+ Linux users that question. I don’t know what
the Linux ratio on the list is, but here’re my statistics:

Compaq 1200Z Laptop (Athlon 900, ATI Mobility M1/8MB)
Runs OpenGL fine, zero problems out of the box using Slackware Linux 8.0.

Custom-built desktop Athlon 700 with GeForce 256/32MB
Runs OpenGL fine, zero problems with NVidia drivers using Slackware Linux
8.0. Haven’t had a single crash in Unreal Tournament, Tribes 2, Rune, or
Quake 3.On Wed, 29 May 2002, Michael Toennies wrote:

So, on how much system OpenGL really works fine?

Lets ask me this: If we ask 100 linux user - how much really usable OpenGL
settings will you find and how much will or will be able to run a game
on it?


Michael Vieths
Foeclan at Visi.com

don’t use blit with open gl use open gl in 2D mod it is better!!

You may’ve just asked 100+ Linux users that question. I don’t know what
the Linux ratio on the list is, but here’re my statistics:
that’s what i am doing on that list.
Shortly, as many of you know - i am happy to start commercial game project.
i am happy linux user since 1999, and gaming user since 1.5 years. But since
i have voodoo 3 opengl games are not working on my box. Once i am about to
setup nvidia card on my friends computers they are always saying the same to
me: Why it is so thoght, readmes and blablabla. No good setup for it. I have
just installed acrobad reader 5.05. It’s lacks of good graphics setup too,
and this is X application so instaling in console is really strange. As an
example of good software (for simple users) to setup are loki games (thx sam
for setup :wink: ) and HP desk jet printer drivers (also very good). This is
what makes people think that linux is freaks only OS. As long as nvidia and
others will not release good setup program for their drivers you may forget
about “easy install”, and that is first step to make people want to play
games on linux !

GJ

| setup nvidia card on my friends computers they are always saying the same to
| me: Why it is so thoght, readmes and blablabla. No good setup for it. I have

Because you’ve been accustomed to thinking computers are “easy”? DOS
didn’t used to be that nice, but nobody complained about editing their
autoexec.bat or typing things in. It’s only recently people have come to
assume everything must have point-and-click wizards where you can whack
the “Next” button 5 times and be done. Remember back in the 80’s when we
all had Spectrums, C64’s and suchlike? We thought nothing about typing
’load “”’ or pressing various key combinations to get things running.

| just installed acrobad reader 5.05. It’s lacks of good graphics setup too,

Yeah, acrobat is a bit weird. The fonts don’t look very nice either.
Infact fonts in X look bad in general. And while I understand the
reasons, not being able to do 2D stuff in hardware with X is a bit lame
too. Installing plugins for Netscape/Mozilla can be a bit tricky too.

| and this is X application so instaling in console is really strange. As an
| example of good software (for simple users) to setup are loki games (thx sam
| for setup :wink: ) and HP desk jet printer drivers (also very good). This is

The Loki installer is nice. When I first saw it I thought “hang on,
it’s going to be RPM-only or put things in silly locations”, but no, it
asked me where things should go and was very nice to use. I was a bit
dubious about running a 32MB shell archive, but after looking in it
with vi I was happy :slight_smile:

| what makes people think that linux is freaks only OS. As long as nvidia and
| others will not release good setup program for their drivers you may forget
| about “easy install”, and that is first step to make people want to play
| games on linux !

You can use nice installers for programs, but when it comes to hardware
and drivers, you need to compile source. Linux is specifically written
that binary-only drivers are definate no-nos (why? there’s a famous
email by Linus on google somewhere that explains it quite well). And
then you need to edit the XF86Config file, get the user to enter proper
refresh rates, and then be root to install the kernel module.

There’s nothing “hard” about it, people are just accustomed to having
all the thinking done for them. You don’t need to be a whizzo programmer
to be able to type “./configure” or “make”. Even the world’s most
user-friendly computer (the Mac) has a shell now.

And as far as it concerns NVIDIA, we should be thankful they’ve
produced drivers at all. Even if they sometimes lock your PC up.On Wed, May 29, 2002 at 09:52:19PM +0200, Grzegorz Jaskiewicz wrote:


Ralph won’t morph if you squeeze him hard enough

6AD6 865A BF6E 76BB 1FC2 | www.piku.org.uk/public-key.asc
E4C4 DEEA 7D08 D511 E149 | www.piku.org.uk wnzrf at cvxh.bet.hx (rot13’d)

blablbalbbla… another “i’m against linux” guy…

| setup nvidia card on my friends computers they are always saying the
same to
| me: Why it is so thoght, readmes and blablabla. No good setup for it. I
have

Because you’ve been accustomed to thinking computers are “easy”? DOS
didn’t used to be that nice, but nobody complained about editing their
autoexec.bat or typing things in. It’s only recently people have come to
assume everything must have point-and-click wizards where you can whack
the “Next” button 5 times and be done. Remember back in the 80’s when we
all had Spectrums, C64’s and suchlike? We thought nothing about typing
’load “”’ or pressing various key combinations to get things running.

| just installed acrobad reader 5.05. It’s lacks of good graphics setup
too,

Yeah, acrobat is a bit weird. The fonts don’t look very nice either.
Infact fonts in X look bad in general. And while I understand the
reasons, not being able to do 2D stuff in hardware with X is a bit lame
too. Installing plugins for Netscape/Mozilla can be a bit tricky too.

| and this is X application so instaling in console is really strange. As
an
| example of good software (for simple users) to setup are loki games (thx
sam
| for setup :wink: ) and HP desk jet printer drivers (also very good). This
is

The Loki installer is nice. When I first saw it I thought “hang on,
it’s going to be RPM-only or put things in silly locations”, but no, it
asked me where things should go and was very nice to use. I was a bit
dubious about running a 32MB shell archive, but after looking in it
with vi I was happy :slight_smile:

| what makes people think that linux is freaks only OS. As long as nvidia
and
| others will not release good setup program for their drivers you may
forget> On Wed, May 29, 2002 at 09:52:19PM +0200, Grzegorz Jaskiewicz wrote:
| about “easy install”, and that is first step to make people want to play
| games on linux !

You can use nice installers for programs, but when it comes to hardware
and drivers, you need to compile source. Linux is specifically written
that binary-only drivers are definate no-nos (why? there’s a famous
email by Linus on google somewhere that explains it quite well). And
then you need to edit the XF86Config file, get the user to enter proper
refresh rates, and then be root to install the kernel module.

There’s nothing “hard” about it, people are just accustomed to having
all the thinking done for them. You don’t need to be a whizzo programmer
to be able to type “./configure” or “make”. Even the world’s most
user-friendly computer (the Mac) has a shell now.

And as far as it concerns NVIDIA, we should be thankful they’ve
produced drivers at all. Even if they sometimes lock your PC up.


Ralph won’t morph if you squeeze him hard enough

6AD6 865A BF6E 76BB 1FC2 | www.piku.org.uk/public-key.asc
E4C4 DEEA 7D08 D511 E149 | www.piku.org.uk wnzrf at cvxh.bet.hx (rot13’d)


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

blablbalbbla… another “i’m against linux” guy…

This is degenerating off topic. Please, if you want to respond to somebody
off topic to the list, please do so directly.

Thanks,
-Sam Lantinga, Software Engineer, Blizzard Entertainment

blablbalbbla… another “i’m against linux” guy…

This is degenerating off topic. Please, if you want to respond to
somebody
off topic to the list, please do so directly.

sorry for that :frowning:

but i don’t like this type of answers.

i am sorry again.

| blablbalbbla… another “i’m against linux” guy…

Who me? I’m not… and you’re probably not either.

Linux is built on choice, not on restricting people to one way of doing
things, which is what makes it so hard to dumb-down for normal people.
So instead, we make the normal people smarter so they can cope with
shellscripts and “chmod +x setup.sh”.

And if you’re really stuck, you can always ask for help. Ask sane
questions, no matter how basic or silly they might sound, and someone
will help you.On Fri, May 31, 2002 at 02:06:04AM +0200, Grzegorz Jaskiewicz wrote:


I will not squeak chalk

6AD6 865A BF6E 76BB 1FC2 | www.piku.org.uk/public-key.asc
E4C4 DEEA 7D08 D511 E149 | www.piku.org.uk wnzrf at cvxh.bet.hx (rot13’d)

OpenGL is a tricky thing under Windows(expect WinXP)
be’cas depend on mircosoft’s implementation,
is seems only WinXP version uses really 3D hardware accel.

with other versions (like win9x,win2000,NT), programmers should
use low-level functions like “get proccess address” to get different
hardware accel. functions and the hell is: different cards have different
extend. functions.

so even we just blits 2D, is it really use hardware accel. under
win9x/2000/NT?

regards,