Jump to content
  • Advertisement
Sign in to follow this  
core-nuts

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

This topic is 4575 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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!

Share this post


Link to post
Share on other sites
Advertisement
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!