Sign in to follow this  
XTAL256

Unity [SDL] SDL_Surface or OpenGL for graphics

Recommended Posts

XTAL256    106
I am making a 2D game using SDL. So far i have used OpenGL for the graphics because i have used it before and i initially used Win32 API for everything else before moving to SDL. But i am having a lot of problems using glDrawPixels for my map (see my posts here and here). I need one large map and i need to be able to access each individual pixel so i can do some cool particle effects (like Falling Sand Game), so i can't use an OpenGL texture. But i use textures for everything else, especially my GUI. It's very easy to draw the images, i simply draw a quad with the texture coords. This also allows my to stretch and/or tile the image with no additional coding. So given this information, do you think i should continue to use OpenGL and somehow overcome the problems i am having (maybe it has something to do with the pixel format) or is it better to use SDL's graphics routines?

Share this post


Link to post
Share on other sites
Lazy Foo    1113
Quote:
Original post by XTAL256
so i can do some cool particle effects (like Falling Sand Game)


SDL isn't hardware accelerated and neither is using glDrawPixels(). Generally you should avoid glDrawPixels or anything that directly accesses the screen pixels because it slows things down a lot.

Have you tried using glPoints for all the little dust pixels? You can store your pixel offsets in VBOs.

Share this post


Link to post
Share on other sites
XTAL256    106
Quote:
Original post by Lazy Foo
SDL isn't hardware accelerated

Oh, isn't it? I thought it used DirectX on Windows, or maybe that was Allegro.
I don't know what VBOs are although i saw a tutorial on it at NeHe. It sounds like a good idea but i think it would be better if i worked entirely on pixels, that way i can make huge amounts of dirt fall down with no extra memory needed. For example, a player can shoot their laser into a mountain destroying all pixels in it's path and making the whole mountain collapse. In this case i would only move each pixel down rather that using complex fluid dynamics formulas.
If it is better to use OpenGL then i think i will just split the map up into smaller textures, it will be harder to work across multiple textures but it's going to be hard anyway, so...

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this