views:

147

answers:

3

I'm looking for one to build a MS-paint like app.

+1  A: 

OpenGL is for making 3D applications. Using it for pixel-based things like a paint program will make things very hard.

The closest thing I can imagine is to paint the pixels for the ellipse to texture surface and then show it as sprite. Be sure that you always have identity transform set, otherwise the result may look blurry.

A good alternative for OpenGl in your case would be SDL. It is simpler and pixel based.

codymanix
I'll look into this out of curiosity. Still, the homework demands an opengl implementation.
omgzor
Maybe you could consider doing another type of project if openGL is demanded.
codymanix
The homework is a MS-paint like application in openGL.
omgzor
+2  A: 

Bresenham's drawing algorithm is used to scan convert the ellipse, i.e. correctly draw and fill the edges of it. OpenGL is a polygon based graphics library that does it's own scan conversion, so I'd say you are thinking of doing it the wrong way.

Personally I'd calculate some points round the edge of the polygon, e.g. by regularly stepping from 0 to 360 degrees and then draw a GL_FAN with the center as the first point and the calculated points as the rest (and including the 0 degree point again at the end).

This will not be perfectly accurate, but good and fast for most purposes.

You could be more sophisticated and generate more edge points if the ellipse is larger, which will improve the accuracy.

andrewmu
Nah, I've been asked to supply an implementation of bresenham's midpoint algorithm in opengl for the ellipse explicitly.
omgzor
In that case codymanix's answer will probably help you more. From reading it, I think the suggestion is to draw a window sized quad with a texture that you have created containing the ellipse.
andrewmu
A: 

I ended up implementing the pseudocode here. Worked pretty good.

omgzor