Skip to main content
GameDev.net gamedev.net
🔒 Locked

Seeking optimization advice for OpenGL based 2D engine...

Started by core-nuts Jan 11, 2006 at 3:28 PM 3 replies 850+ views
Original Post
core-nuts
core-nuts
Well I've read around a bit and found a few sources regarding using OpenGl for 2D applications, but nothing that really went too in-depth. I'm working on an engine with a couple other people, and I'm basically learning OpenGL as I go. I guess mainly, I don't just want to learn HOW to do it, but learn how to do it best. So I was hoping for a little advice, if anyone can spare it. The way I am handling drawing images - its pretty basic, I just load an image file and bind it to a texture, which I save in a vector of GLuints. I created a new image type which saves the images' index in that vector, along with the dimensions and a couple other things. Then to draw an image, I just access that texture, apply it to a Quad and draw it. My concern is whether this is the fastest, most 'optimized' way to do this? If I were using this with a tile based game and had a whole lot of tiles to draw, would this be able to keep up or would it put a lot of pressure on the GPU? Or if I also wanted to apply some more effects to the scene? So if anyone took the time to read this and can fill me in on a more efficient way to handle this, or let me know if the way I am doing it is sufficient...I would greatly appreciate it. THANKS!
If you want the rainbow, you've gotta put up with the rain - do you know which philosopher said that? Dolly Parton. And people say she's just a big pair of tits.
CableGuy
CableGuy
hi.

when you draw the entire screen,
i would recomment drawing all tiles with the same texture
in one go, this way u wouldn't have lots of
texture state changes which would slow down things.

besides that u might want to check out point sprite, as u can draw a whole quad
by specifying only on vertex.
gold
gold
I agree, point sprites are what you want. The functionality is described here:

http://oss.sgi.com/projects/ogl-sample/registry/ARB/point_sprite.txt

The extension was promoted to the core, as of OpenGL 2.0.
Ranger_One
Ranger_One
Point sprite extension? I don't see that listed on my Radeon 9000 pro :P That would seem to indicate to me you'd have a portability issue across hardware.

My idea would be to use vertex arrays (I can explain if you want). You won't get an amazing speed boost, but you can keep the cpu<->gpu bridge overhead down when drawing many sprites from the same texture.

core-nuts
core-nuts
Thanks! I'll check those things out. And you don't have to explain it further(unless you want to...) I was just looking for some advice on other methods and I have no problem researching them myself. I was just having trouble finding out what I needed to look for. So thanks for the suggestions, I really appreciate it.
If you want the rainbow, you've gotta put up with the rain - do you know which philosopher said that? Dolly Parton. And people say she's just a big pair of tits.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.