For all who search a SDL_OPENGLBLIT example

Hi,
I noticed that the requests for an explanation about SDL_OPENGLBLIT
mode are always present. For those that want to go a little beyond the
"testgl -logo" experience, I just want to signal that my SDL port of the
NeHeGL Basecode includes a basic documented example on how to set up the
graphic mode and how to use it. Plus, it’s a basecode, a framework, so you
can start developing you SDL_OPENGLBLIT app wight into it.

The code can be downloaded here: http://nehe.gamedev.net/files/nehegl_sdl.zip

If you’re interested in OpenGL and 3d graphics you should definitely take a
look at Jeff Molofee’s Site: http://nehe.gamedev.net

Thanks,__
Fabio " ‘- nowDruid " Franchello
—’---------
@Fabio_Franchello

ahem

Let me try to put this in as simple terms as I can put it:

  ____   ___       _   _  ___ _____       _   _ ____  _____ 
 |  _ \ / _ \     | \ | |/ _ \_   _|     | | | / ___|| ____|
 | | | | | | |    |  \| | | | || |       | | | \___ \|  _|  
 | |_| | |_| |    | |\  | |_| || |       | |_| |___) | |___ 
 |____/ \___/     |_| \_|\___/ |_|        \___/|____/|_____|

   ___  ____  _____ _   _  ____ _     ____  _     ___ _____ 
  / _ \|  _ \| ____| \ | |/ ___| |   | __ )| |   |_ _|_   _|
 | | | | |_) |  _| |  \| | |  _| |   |  _ \| |    | |  | |  
 | |_| |  __/| |___| |\  | |_| | |___| |_) | |___ | |  | |  
  \___/|_|   |_____|_| \_|\____|_____|____/|_____|___| |_|  

Just DO NOT use it. Ten good reasons why SDL_OPENGLBLIT should be
outright removed from SDL:

1. It is a terrible hack.
2. It is slow.
3. It doesn't work with some cards and drivers.
4. It is slow.
5. It is a matter of public record Sam advises against using it.
6. It is slow.
7. It is possible to upload any surface to OpenGL.
8. It is slow.
9. It is easy to get OpenGL to give you raw screen coordinates.
10. IT IS SLOW!

CAN WE PLEASE finally have a FAQ item about this? Every week someone who
apparently feels no inclination to read the damned list archives for all
of the multitudes of previous discussions about how WRONG it is to EVER
use SDL_OPENGLBLIT, many of them including code examples demonstrating how
to never have to use it again.

Rather than actually discover this, people continue to insist on trying to
use it rather than actually learning what a projection matrix is and how
to actually set one up so they can feed raw pixel coordinates to OpenGL
for glVertex2f/glVertex2fv… It should be clear to everyone by now that
people will continue to make this massive leap of ignorance until the main
libsdl.org website screams in big blinking letters not to. I’m not even
sure that’ll communicate the point to some people.

It’s only fitting that a mess like SDL_OPENGLBLIT be combined with NeHe
stuff, a mess of its own. But unfortunately people mistakenly believe
that NeHe stuff is actually useful for something.On Mon, Nov 05, 2001 at 01:22:05PM +0100, Fabio Franchello wrote:

    I  noticed that  the requests for an  explanation about

SDL_OPENGLBLIT mode are always present. For those that want to go a
little beyond the “testgl -logo” experience, I just want to signal
that my SDL port of the NeHeGL Basecode includes a basic documented
example on how to set up the graphic mode and how to use it. Plus,
it’s a basecode, a framework, so you can start developing you
SDL_OPENGLBLIT app wight into it.


Joseph Carter Free software developer

I still think you guys are nuts merging Q and QW. :stuck_out_tongue:
Of course we’re nuts. Even John said so. =>
Zoid: we’re nuts, but we’re productive nuts:)

-------------- next part --------------
A non-text attachment was scrubbed…
Name: not available
Type: application/pgp-signature
Size: 273 bytes
Desc: not available
URL: http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20011105/734a37a9/attachment.pgp

[…]

ahem

Let me try to put this in as simple terms as I can put it:


| _ \ / _ \ | \ | |/ _ _ | | | | / || |
| | | | | | | | | | | | || | | | | _
| |
| |
| | |
| | | |\ | |
| || | | |
| |
) | |_
|/ ___/ || _|___/ || _/|____/|___|


/ _ | _ | | \ | |/ _| | | __ )| | | | |
| | | | |
) | | | | | | | | | _ | | | | | |
| |
| | /| |
| |\ | |
| | |
| |
) | |___ | | | |
_/|| |___|| _|_||____/||| |_|

Nice ASCII art, but it was probably not clear enough… :wink:

[…]

Rather than actually discover this, people continue to insist on trying
to use it rather than actually learning what a projection matrix is and
how to actually set one up so they can feed raw pixel coordinates to
OpenGL for glVertex2f/glVertex2fv… It should be clear to everyone by
now that people will continue to make this massive leap of ignorance
until the main libsdl.org website screams in big blinking letters not
to. I’m not even sure that’ll communicate the point to some people.

Programmer with no interest in digging into the library implementation,
upon finding a feature:

"Hey, it exists, so it must be meant to be used!"

The only way to keep people from using it is probably to remove it…

BTW, no, this is not the same thing as “SDL 2D on OpenGL” - that’s a
rendering backend for pure SDL applications (ie not OpenGL applications).
SDL_OPENGLBLIT is a boobie trap for OpenGL programmers that think SDL’s
2D blitting API looks nice for overlays, thinking that it probably works
along the lines of how OpenGL should be used.

(Indeed, a proper “SDL on OpenGL” backend would be more efficient than
SDL_OPENGLBLIT in OpenGL applications, but it’s still not optimal; SDL
can’t keep track of the OpenGL state, so it has to restore everything
before doing any other OpenGL calls itself. That is, the rule would still
be: “If you’re using OpenGL, use it for everything.”)

It’s only fitting that a mess like SDL_OPENGLBLIT be combined with NeHe
stuff, a mess of its own. But unfortunately people mistakenly believe
that NeHe stuff is actually useful for something.

Why doesn’t someone write some proper examples, or just clean up the NeHe
code? (Can’t do it myself - not enough OpenGL experience yet.)

//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.linuxdj.com/maia -' .- David Olofson -------------------------------------------. | Audio Hacker - Open Source Advocate - Singer - Songwriter |-------------------------------------> http://olofson.net -'On Monday 05 November 2001 15:33, Joseph Carter wrote:

[…]

ahem

Let me try to put this in as simple terms as I can put it:


| _ \ / _ \ | \ | |/ _ _ | | | | / || |
|
| | | | | | | | | | | | || | | | | _
| |
| |
| |
| | |
| | | |\ | |
| || | | |
| |
) | |_
|
|/ ___/ || _|___/ || _/|____/|___|


/ _ | _ | ____| \ | |/ __| | | __ )| | | | _|

| | | | |) | | | | | | | | | _ | | | | | |
| |
| |
| | /| |
| |\ | |
| | |__| |) | |___ | | | |

_/|| |___|| _|_||____/||| |_|

Nice ASCII art, but it was probably not clear enough… :wink:

Well, it showed up in nice colors in my email-proggie (kmail) =)

– 8< –

The only way to keep people from using it is probably to remove it…

Just make it NOT work without first execing the following code sequence …
SDL_EnableSDLOPENGLBLITWhichShouldNotUnderAnyCircumstancesBeUsed();
SDL_IRealizeThatIAmStupidToEvenConsiderUsingSDLOPENGLBLIT();
SDL_NeverthelessIChooseToGoAgaistAllSenseAndUseTheUglySDLOPENGLBLITHack();
=)

– 8< –

It’s only fitting that a mess like SDL_OPENGLBLIT be combined with NeHe
stuff, a mess of its own. But unfortunately people mistakenly believe
that NeHe stuff is actually useful for something.

Why doesn’t someone write some proper examples, or just clean up the NeHe
code? (Can’t do it myself - not enough OpenGL experience yet.)

Right. NeHe isn’t useless, it’s just a little messy … Besides, there’s no
(real) free alternative, and buying expensive books is out of the question
for poor students … So, you can flame all you want, but if you’re really
that pissed off of NeHe, shut up and write a proper OpenGL tutorial yourself.

I’d appreciate that btw =)On Monday 5. November 2001 19:29, David Olofson wrote:

On Monday 05 November 2001 15:33, Joseph Carter wrote:


Trick


Linux User #229006 * http://counter.li.org

Thanks to Mr. Carter for his opinion on the matter.

Quoted from the README file from the NeHeGL port:

As a matter if fact SDL_OPENGLBLIT mode is not fast. Is not the fastest
mode you can use. But have another great advantage IMHO:it’s easy to use.
If you use the glOrtho() GL call to set up a proper ortho viewport (and
so use IE GL Quads to display “sprites”) you will obtain a much more
smooth running code. So which mode to use? It depends on what you need.

If you need an OpenGL scene with some (maybe fixed) 2D elements,
like a IE a GUI. SDL_OPENGLBLIT is the way to go. If you’re needing a
3D scenery for a mainly 2D action game, maybe you should try glOrtho()
technique. In the next release of this framework I’ll add both modes.

Have a nice day!

SDL_OPENGLBLIT is a feature SDL offers, and it can be useful at times.I am
aware it has problems and it’s not fast, but if it’s a flaw, why leave it?
There are many ways to express an opinion, I think to denigrate other
people’s work it’s not the currect one.

Thanks,__
Fabio " ‘- nowDruid " Franchello
—’---------
— snowdruid at tiscalinet.it

The only way to keep people from using it is probably to remove it…

Just make it NOT work without first execing the following code sequence …
SDL_EnableSDLOPENGLBLITWhichShouldNotUnderAnyCircumstancesBeUsed();
SDL_IRealizeThatIAmStupidToEvenConsiderUsingSDLOPENGLBLIT();
SDL_NeverthelessIChooseToGoAgaistAllSenseAndUseTheUglySDLOPENGLBLITHack();
=)

wow, a few hundred iterations of these kinda modifications and sdl will be
just like directx

– 8< –

It’s only fitting that a mess like SDL_OPENGLBLIT be combined with NeHe
stuff, a mess of its own. But unfortunately people mistakenly believe
that NeHe stuff is actually useful for something.

Why doesn’t someone write some proper examples, or just clean up the NeHe
code? (Can’t do it myself - not enough OpenGL experience yet.)

Right. NeHe isn’t useless, it’s just a little messy … Besides, there’s no
(real) free alternative, and buying expensive books is out of the question
for poor students … So, you can flame all you want, but if you’re really
that pissed off of NeHe, shut up and write a proper OpenGL tutorial yourself.

I’d appreciate that btw =)

http://www.gamedev.net/download/redbook.pdf
http://ask.ii.uib.no/ebt-bin/nph-dweb/dynaweb/SGI_Developer/OpenGL_PG/%40Generic__BookTextView/73;cs=fullhtml;pt=69;lang=nb

those are a little outdated, covering opengl 1.1, but they do it RIGHT, and
explain everything well and correctly. Buy the book if you’re serious, I
got mine at college used bookstore for $25 (they looked at me funny for buying
a book without taking the class, but I got my book)

Nehe is fine if you already are a strong coder and understand why that style of
structure and commenting is stupid, provided you don’t use the webpage version
and grab a glut or sdl version (glaux is dead, anyone who uses it should be
shot :slight_smile:

    -Erik <@Erik_Greenwald> [http://math.smsu.edu/~erik]

The opinions expressed by me are not necessarily opinions. In all probability,
they are random rambling, and to be ignored. Failure to ignore may result in
severe boredom or confusion. Shake well before opening. Keep Refrigerated.

[reasons omitted]

For those of you who may want an example of how to do this the “right way”,
I’ve modified the source for testgl (in test/testgl.c) so that both methods
can be used, but the default method (-logo argument) is the “correct” one.
http://www.libsdl.org/cvs.html

See ya,
-Sam Lantinga, Software Engineer, Blizzard Entertainment> On Mon, Nov 05, 2001 at 01:22:05PM +0100, Fabio Franchello wrote:

    I  noticed that  the requests for an  explanation about

SDL_OPENGLBLIT mode are always present. For those that want to go a
little beyond the “testgl -logo” experience, I just want to signal
that my SDL port of the NeHeGL Basecode includes a basic documented
example on how to set up the graphic mode and how to use it. Plus,
it’s a basecode, a framework, so you can start developing you
SDL_OPENGLBLIT app wight into it.

ahem

Let me try to put this in as simple terms as I can put it:


| _ \ / _ \ | \ | |/ _ _ | | | | / || |
| | | | | | | | | | | | || | | | | _
| |
| |
| | |
| | | |\ | |
| || | | |
| |
) | |_
|/ ___/ || _|___/ || _/|____/|___|


/ _ | _ | | \ | |/ _| | | __ )| | | | |
| | | | |
) | | | | | | | | | _ | | | | | |
| |
| | /| |
| |\ | |
| | |
| |
) | |___ | | | |
_/|| |___|| _|_||____/||| |_|

For those of you who may want an example of how to do this the “right way”,
I’ve modified the source for testgl (in test/testgl.c) so that both methods
can be used, but the default method (-logo argument) is the “correct” one.
http://www.libsdl.org/cvs.html

Also note that the code given there only works for images with width and height
which are a power of two. Example code will be written later that handles any
size image and returns the correct set of texture coordinates to use.

See ya,
-Sam Lantinga, Software Engineer, Blizzard Entertainment

your new testgl example is great ! indeed…

For those of you who may want an example of how to do this the “right way”,
I’ve modified the source for testgl (in test/testgl.c) so that both methods
can be used, but the default method (-logo argument) is the “correct” one.
http://www.libsdl.org/cvs.html

The code in CVS now has a function to load images with dimensions that are
not powers of two. I didn’t bother adding logic to break down the images
into multiple textures, to handle texture size limitations. You are probably
better off designing your artwork with these limitations in mind for your
target hardware.

OpenGL gurus, please let me know if there are any problems with the code,
or anything I’ve forgotten.

Enjoy! :slight_smile:
-Sam Lantinga, Software Engineer, Blizzard Entertainment

If anyone is interested in an example of using OpenGL for a 2D, you’re
welcome to check out the game I’m working on:

It’s a 2D vector shoot-em-up. It’s SDL-based, but the graphics are pure GL.

It’s currently only available via anonymous CVS, and requires SDL_image and
SDL_mixer to compile. Recently I’ve been compiling it on Linux, but it should
compile fine on any SDL supported platform. For win32 there are some Visual
Studio project files, but they’ll require some minor updating.

Ben.

En dt, 2001-11-06 a 02:55, Sam Lantinga escribi?:

For those of you who may want an example of how to do this the "right way",
I've modified the source for testgl (in test/testgl.c) so that both methods
can be used, but the default method (-logo argument) is the "correct" one.
http://www.libsdl.org/cvs.html

I’ve used testgl.c example, and the function for load textures ignores
alpha channel (it disconnect it).

is there a way for load textures with alpha channel and draw it?

If people shouldn’t use SDL_OPENGLBLIT - please remove it from SDL source, but
not in the future - but soon. If something is inside - should be used. Or
library is unstable.On Mon, Nov 05, 2001 at 06:33:34AM -0800, Joseph Carter wrote:

Just DO NOT use it. Ten good reasons why SDL_OPENGLBLIT should be
outright removed from SDL:


Well it’s a cold world And I’m in the middle
Caught in the in-between I don’t belong here
So I’m writing to you It’s wrong here "Letters From Earth"
Where I’m sending you some Letters from Earth - Ronnie James Dio

There is existing code that relies on it, so it will stay in the SDL 1.2 API.
However, it will not be present in SDL 1.3 -> 2.0

See ya,
-Sam Lantinga, Software Engineer, Blizzard Entertainment> On Mon, Nov 05, 2001 at 06:33:34AM -0800, Joseph Carter wrote:

Just DO NOT use it. Ten good reasons why SDL_OPENGLBLIT should be
outright removed from SDL:

If people shouldn’t use SDL_OPENGLBLIT - please remove it from SDL source, but
not in the future - but soon. If something is inside - should be used. Or
library is unstable.

Why was SDL_OPENGLBLIT originally added Sam?

-EvilTypeGuyOn Tue, Nov 06, 2001 at 09:58:15AM -0800, Sam Lantinga wrote:

On Mon, Nov 05, 2001 at 06:33:34AM -0800, Joseph Carter wrote:
There is existing code that relies on it, so it will stay in the SDL 1.2 API.
However, it will not be present in SDL 1.3 -> 2.0

See ya,
-Sam Lantinga, Software Engineer, Blizzard Entertainment

Why was SDL_OPENGLBLIT originally added Sam?

I originally added it for the port of Sim City 3000 Unlimited’s Building
Architect Tool.

  • Daniel Vogel, Programmer, Epic Games Inc.

I’ve just browsed the CVS using the web interface a bit so far, but just
happened to notice that you’re calling glEnable() and glDisable() at
least once each per rendered primitive in some places.

It seems that those calls are very time consuming, at least on some
drivers, so it might be a good idea to call them only when you actually
need to change the state of something. (The calls slow down even if
nothing has to be changed, at least on the DRI drivers for the Matrox
G400… The difference in frame rate is in the order of tens of percents
when rendering a few hundred quads per frame.)

Of course, that goes for texture binding as well, and that applies to
all cards and drivers, AFAIK, perhaps with the exception of some high
end cards. It’s generally a good idea to use fewer textures with larger
numbers of images on each (“tile/sprite palettes”), and as far as
possible, group “blits” from the same texture together. (Now, doing that
properly in an engine with per-sprite Z order control is going to be a
bit tricky… :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.linuxdj.com/maia -' .- David Olofson -------------------------------------------. | Audio Hacker - Open Source Advocate - Singer - Songwriter |-------------------------------------> http://olofson.net -'On Tuesday 06 November 2001 07:27, Ben Campbell wrote:

If anyone is interested in an example of using OpenGL for a 2D, you’re
welcome to check out the game I’m working on:

http://sourceforge.net/projects/movezig

It’s a 2D vector shoot-em-up. It’s SDL-based, but the graphics are pure
GL.

It’s currently only available via anonymous CVS, and requires SDL_image
and SDL_mixer to compile. Recently I’ve been compiling it on Linux, but
it should compile fine on any SDL supported platform. For win32 there
are some Visual Studio project files, but they’ll require some minor
updating.

Ahhh, makes sense. I own both the Linux and Windows version of SC3U so it would
be interesting to compare the two performance wise…

Does SC3U and the Architect tool use OpenGL or just the architect tool?

-EvilTypeGuyOn Tue, Nov 06, 2001 at 03:33:36PM -0500, Daniel Vogel wrote:

Why was SDL_OPENGLBLIT originally added Sam?

I originally added it for the port of Sim City 3000 Unlimited’s Building
Architect Tool.

  • Daniel Vogel, Programmer, Epic Games Inc.

Ahhh, makes sense. I own both the Linux and Windows version of
SC3U so it would
be interesting to compare the two performance wise…

Does SC3U and the Architect tool use OpenGL or just the architect tool?

Just BAT and it is sloooooow. It’s more a hack than a port.

  • Daniel Vogel, Programmer, Epic Games Inc.

sloooooow eh? A little unfinished porting }:> At least it’s functional
though (at least it appears to be from what I remember…) Most Linux users get
left out in the cold when it comes to game editing tools :confused: If people would just
write ANSI standard C and use non-platform specific libraries the world would be
so much better IMHO…

BTW, your OpenGL improvements to UT were/still are greatly appreciated…

-EvilTypeGuyOn Tue, Nov 06, 2001 at 04:25:56PM -0500, Daniel Vogel wrote:

Ahhh, makes sense. I own both the Linux and Windows version of
SC3U so it would
be interesting to compare the two performance wise…

Does SC3U and the Architect tool use OpenGL or just the architect tool?

Just BAT and it is sloooooow. It’s more a hack than a port.

  • Daniel Vogel, Programmer, Epic Games Inc.