Jump to content

  • Log In with Google      Sign In   
  • Create Account

Interested in a FREE copy of HTML5 game maker Construct 2?

We'll be giving away three Personal Edition licences in next Tuesday's GDNet Direct email newsletter!

Sign up from the right-hand sidebar on our homepage and read Tuesday's newsletter for details!


We're also offering banner ads on our site from just $5! 1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


How to use OpenGL for picture-drawing games?


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
1 reply to this topic

#1 shinypixel   Members   -  Reputation: 150

Like
0Likes
Like

Posted 15 May 2014 - 06:40 PM

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, 15 May 2014 - 07:13 PM.


Sponsor:

#2 C0lumbo   Crossbones+   -  Reputation: 2345

Like
0Likes
Like

Posted 15 May 2014 - 10:56 PM

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.






Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS