Click to See Complete Forum and Search --> : MFC drawing capability and OpenGL


Naron Souksaly
April 8th, 1999, 09:25 AM
Hi everyone,

I just want to know how good is the MFC drawing capability. Is it easy to draw some simple things
like circle, lines, squares, etc with MFC? I know they have some Graphical Drawing Objects but I want
to know if they are easy to use for drawing simple forms.

My second question is the use of OpenGL with VC++. Does somebody know if OpenGL can support
mouse event like double click? What I want to do is to draw some objects with OpenGL and when the
user double-clicks on that object, I want to open, for example, a dialog or just attach a handler to that
event.

Thanks,
Naron

April 8th, 1999, 11:34 AM
MFC/Win32 GDI drawing capabilities are perfectly adequate for most 2D drawing tasks and can be used to do simple 3D, if you know enough math to do required transformations.

For more sophisticated 3D, you would probably want to look into OpenGL, DirectX or a similar graphics library. Unfortunately, I think there is a significant learning curve in any graphics library.

In general hit-testing should not be a problem in with the graphics libraries, since they would generally be used to draw to a CView anyway and all you would need to do is respond to a mouse button click message in the CView in a way that does the appropriate calculations to relate the mouse location to appropriate graphic object. This is generally easy to do in 2D. In 3D, however, you will generally be supplying the graphics library with shape information and then transforming the shape information (for instance, describing a cube with 100 unit sides and then rotating it and applying perspective to it), making the relationship between a view coordinate and the underlying 3D object arbitrarily complex. OpenGL (at which I am a total beginner) has a facility for selection or "picking" (as they sometimes call it) of objects out of a 3D scene, but I think it is a somewhat sophisticated technique that would take a while to learn to use (I'm trying to learn OpenGL in my spare time and have just finished reading The OpenGL Programming Guide, but do not think I will be doing any "picking" for a good while.) There are also apparently "cheat" techniques for picking in OpenGL whereby (i) an image parallelling the front buffer image would be written to the back buffer in solid colors, using a different color for each object, (ii) the mouse selection coordinates would be used to find the color of the image in the back buffer at such coordinate and (iii) the color would be used to find the object (using a map of color to object that you would have to create).

As you can probably guess from the above, unless you need to do sophisticated things in 3D and are interested in devoting a significant amount of time getting up to speed on a graphics library, you would probably want to stick with MFC/Win32 GDI.

Hardeep Singh
April 9th, 1999, 06:20 AM
Hey, Don't scare the poor fellow! Picking isn't all that tough in OpenGL. In fact, one big advantage OpenGL has over DirectX is that picking objects is quite easy.