[SDL] 2D with openGL & SDL
benang at cs.its.ac.id
benang at cs.its.ac.id
Tue Jul 17 20:04:07 PDT 2007
Thanks for the reply. The graphics card is a VIA Unichrome. And as
Matthias Weigand said, probably it's not as good as I want it to be. Also
the VGA has no driver for Linux. So I use the standard one in the machine.
I think I should reconsider this some more. But I think I will still
redesign my rendering engine (or recreate it again from scratch) with
openGL, but not for the current game. Thanks again.
Mike Powell said:
> benang at cs.its.ac.id wrote:
>> 1. Performance wise, will this make my application faster or slower?
>> FYI,
>> the intended machine is a VIA EPIA Mini ITX embedded with Linux openSuSE
>> 10.1 as the OS.
>
> On this point I'm really not sure, but I would guess that, so long as you
> have a good graphics card, and you keep the sprites in video RAM as
> textures, it'll probably be faster. Plus, certain types of operations,
> such as scaling or rotating sprites, will be much faster.
>
>> 2. Do I need to implement shader languages (I think maybe Cg)?
>
> Not unless you want to do some pretty fancy special effects. If your game
> is based entirely on drawing 2D images on top of each other with alpha
> channels, then just use OpenGL's standard blending modes and you'll be
> fine.
>
>> 3. What's the settings for openGL so that the 2D environment looked just
>> like when I blit it directly to an SDL Surface (eg, the viewport, 1
>> points
>> equals to 1 pixel, etc)?
>
> Leave the viewport alone unless you actually want to restrict drawing to
> limited portion of the screen. The standard state of the viewport is the
> same as the screen/window that the game is drawn into.
>
> For setting it up to have 1 point per pixel, gluOrtho2D() is your friend.
> Specifically:
>
> glMatrixMode(GL_PROJECTION);
> glLoadIdentity();
> gluOrtho2D(0, width, 0, height);
>
> Where "width" and "height" are the screen resolution.
>
> Note that OpenGL's coordinate system is based in the lower-left corner,
> not the upper-left corner like you might be used to. I BELIEVE the the
> call to gluOrtho2D, as I just demonstrated, will flip it vertically so it
> will map to what you expect. However, no promises on that. If that doesn't
> work, you can always use the modelview matrix to scale everything by -1.0
> on the y axis.
>
>> 4. AFAIK, to add a texture, the width & height of the image should be a
>> power of 2. So how do I make a sprite with width and/or height not of
>> power of 2?
>
> This was true in the old versions of OpenGL, but I know it's been fixed by
> OpenGL 2.0. Not sure, offhand, exactly which version made the shift, but
> if your version is up to date, you should be able to use any texture size.
> Provided, of course, it's not larger then your implementation's maximum
> texture size. These days, that's usually either 512 or 1024, so you
> probably won't have a problem there.
> _______________________________________________
> SDL mailing list
> SDL at lists.libsdl.org
> http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
>
Fare thee well,
Bawenang R. P. P.
----------------
ERROR: Brain not found. Please insert a new brain!
Do nothing which is of no use. - Miyamoto Musashi.
"I live for my dream. And my dream is to live my life to the fullest."
More information about the SDL
mailing list