View Full Version : 2D Photoshop-like paint program using OpenGL?

08-09-2009, 06:52 PM
Hey guys, I am working on a Photoshop like paint/image-editing program using C++. Currently I was going to use GDI/GDI+ for the 2D rendering but it seems slow for what I want to do. I was thinking maybe OpenGL would let me leverage the GPU for the program, but I am unsure if it fits my needs. Let me explain.

The program I am making requires the user to load an image file (jpg, etc.) and then allows them to paint on a greyscale "mask"-type layer. They should be able to draw with different brush shapes/sizes and also make arbitrary polygon shapes and fill them (solid or linear/radial gradient fills). While you are drawing you do not see the "mask" layer directly but you see a real-time preview of the resulting process. This would involve taking the greyscale image data and running a color-conversion operation and then super-imposing that over the original jpg bitmap. I hope thats not too confusing.

Basically I am trying to figure out if OpenGL will support what I need. At the most basic level I would need to be able to draw shapes into a bitmap object (texture buffer, etc.), be able to access the raw pixel data (get the RGB values) so I can process them, and ultimately composite the two bitmaps together (an alpha blend will suffice, but different blending modes would be nice). Is OpenGL up to the task or am I totally off-base here? Is there another library that is more suited for 2D hardware-accelerated rendering on the Windows platform? Any help will be appreciated.

Ilian Dinev
08-09-2009, 07:24 PM
Modern OpenGL is completely suitable for that. You just need to use FBOs, and preferably shaders.

08-10-2009, 05:29 AM
Keep in mind that implementations do not 100% guarantee accurate rasterization (e.g. colors may be slightly off), though you probably can build in a conformance test. Typically this is not a problem though.