Hi! This post is about my essay to create a Tutorial about 2d Graphics
with sdl+opengl. I’ve tried to use only SDL but it is way slow. I don’t
like to use root+SDL_SETVIDEODRIVER, so I decided to use OpenGL (I
DON’T use Openglblit ). Now I’m posting 2 versions of my first
program. One uses glDrawPixels that is very slow on 99% of the Pc’s.
The other version uses glVertex (I’ve tried with glRectf but I don’t
know how to map a texture, any idea?).
Now I need to do the same thing using only SDL to show what’s the
difference using OGL and SDL…
But I have some problems… I don’t know how to create a Tile engine. In
fact, my first Idea was to create it using SDL, but now with opengl I
don’t know how to build a virtual screen bigger than the actual screen.
Example: My screen is 640x480, but my tiled world is 1000x1000. How can
I do it with Opengl? Does I have to put everithing on a SDL surface and
then draw it as one big GL_Quads? (I think that’s stupid, because I
lose the performances of my hardware).
Can anybody help me?
Check out the parallax scrolling examples on
http://olofson.net/mixed.html
(There’s also a simpler example with just one level… Where did it go?)
What you do (for each frame) is basically just to figure out what area of
the virtual map is currently covered by the screen, and then render all
tiles from that area. The approach is exactly the same with OpenGL and
SDL.
ps. why this line doesn’t work in my program?
“glGetIntegerv(GL_MAX_PROJECTION_STACK_DEPTH,&maxdepth);”
No idea… Why do you need it anyway? 2D applications generally don’t
push the projection stack very hard. (In glSDL, I’m changing it whenever
someone calls SDL_SetClipRect(), but that cannot be optimized with the
stack anyway. Don’t know if it would be faster to do the clipping some
other way; haven’t looked into it yet…)
If somebody think that my programs are interesting, I will put them on
a webpage with some docs…but first I have to leave some code from Sam
(and some other piece that I dont know )
Yeah, I’m messing with 2D on OpenGL as well, although my approach is
focused on getting ordinary (ie not OpenGL aware) applications to render
with OpenGL.
My code still isn’t available as a stand-alone package, but you can find
it in later versions of Kobo Deluxe, in graphics/glSDL.[ch]. Version
0.4-pre5 was released today, and contains the latest glSDL featurs and
fixes, as well as some improvements of the game.
http://olofson.net/download/kobodeluxe-0.4-pre5.tar.bz2
http://olofson.net/download/kobodeluxe-0.4-pre5.tar.gz
glSDL splits large surfaces up to handle the OpenGL texture size
limitations, as well as to utilize texture size optimally. (Textures have
to be square…) It can use multiple textures for a single surface to
handle either very wide or very tall surfaces, but wide and tall
surfaces aren’t handled as of now.
glSDL is also a pretty dirty hack in some areas, so don’t look too
carefully! (That applies to the SDL_Surface interfacing part in
particular - although at least, it’s not using ‘unused1’ as a pointer any
more…)
//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 Thursday 20 December 2001 00:31, ma0 wrote: