Jump to content
  • Advertisement
Sign in to follow this  
shinypixel

OpenGL How to use OpenGL for picture-drawing games?

This topic is 1671 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

Generally you tap on a color you want, then tap on an object like a hat or block. The hat/block turns the user's requested color. I've seen this done on the iPad, and this site is exactly what I'm thinking of. Do you separate all the objects and just apply glColor3f() to it? Or is there a way to fill in an area?

Edited by shinypixel

Share this post


Link to post
Share on other sites
Advertisement

I would think that for the sake of simplicity, it is worth having an entire copy of the image on the CPU, so whenever the user manipulates the image, you modify the CPU copy, then you use glTexImage2D or glTexSubImage2D to apply the modifications from the CPU copy to an OpenGL texture, then you use that OpenGL texture to render onto screen.

 

If you use that approach, then you can write nice simple CPU code. The particular thing you are asking about is a flood fill algorithm, which is relatively straightforward to implement on the CPU. http://en.wikipedia.org/wiki/Flood_fill

 

Actually, I just followed your link and see that you're thinking of pre-set areas rather than a free-form art tool. The CPU buffer approach is still a simple, flexible solution, However, for your particular special case, what you could do is have your pictures broken into triangles, and as the user colours a block, you just change the vertex colours of the relevant triangles. The black outlines could then be rendered over the top at the end. That'd be the efficient solution, but I think if you're targeting iOS, then the devices you're targeting are powerful enough for you to choose the more flexible approach.

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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!