Click here to Skip to main content
14,977,142 members
Articles / Desktop Programming / MFC
Posted 1 Oct 2000


62 bookmarked

The GLU functions and hit testing using OpenGL and MFC

Rate me:
Please Sign up or sign in to vote.
4.62/5 (11 votes)
1 Oct 2000
This sample teaches you how to create an OpenGL based 3D Drawing application and demonstrates the GLU functions and hit testing using OpenGL and MFC
  • Download source files - 51 Kb
  • Sample Image - mfchittest.gif


    This sample teaches you how to create an OpenGL based 3D Drawing application using the MFC library. It shows how to setup the View's class for OpenGL by using special setup methods that would enable the view window to show 3D shapes.


    The sample MFC program demontrates how to setup OpenGL with MFC. It also demonstrates how to make 3D Shapes using the glu... and aux... functions, for example 3D Sphere or 3D Teapot. It also shows the very important Hit Selection process in MFC with OpenGL. You can click the shape you want to select it, then it is selected and reported with a message dialog.

    User Interactions:

    • By using the Command Toolbar, you can change program flow mode to Selection, Rotations or Translation modes.
    • While in Selection Mode, with Left Mouse click on the 3D Shapes in the scene will result in selection and report the shape.
    • When in Translation Mode, you can move the scene around every where. Also you may Zoom In & Out by Right Mouse button pressed and moved.
    • When in Rotation Mode, you can rotate the scene around any where. Also you could toggle the Rotation Axes between X, Y or Z by pressing the TAB key.
    • Toggle the Camera View Angle to X, Y or Z.
    • Toggle the Camera projection type between Perspective or Ortho.
    • Toggle Show or Hide axis.
    • Change the Draw, Shading and Lighting Orientation from the Draw Mode menu.

    Notes & Credits:

    The source code for the Camera, Scene and Co-Ordinate axis classes are from the sample application posted on's OpenGL link. Please ckeck the sample.


    The application requires opengl32.dll for windows which can be obtained from


    This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

    A list of licenses authors might use can be found here


    About the Author

    Masoud Samimi
    Technical Lead Samimi Information Technology
    United Arab Emirates United Arab Emirates
    My company provides services in the fields of:

    LAN/WAN Networking
    Data Management and Security
    Data Recovery
    ERP/CRM Solutions
    IT Infrastructure Solutions
    Software/Hardware Sales/Service

    Comments and Discussions

    GeneralMy vote of 4 Pin
    MrLonely250425-Jul-10 18:30
    MemberMrLonely250425-Jul-10 18:30 
    QuestionHow to run 2 different(or same) OpenGL objects in one DialogBox? Pin
    werter13-May-04 21:17
    Memberwerter13-May-04 21:17 
    GeneralLooks like there's some coordinate problems Pin
    edsela2-Apr-04 9:05
    Memberedsela2-Apr-04 9:05 
    QuestionHow is OpenGL compared to DirectX? Pin
    Thorell12-May-03 4:56
    MemberThorell12-May-03 4:56 
    GeneralExactly what i was looking for - Thankx ! Pin
    Mayuresh Kadu31-Oct-00 18:10
    sussMayuresh Kadu31-Oct-00 18:10 
    GeneralRe: Exactly what i was looking for - Thankx ! Pin
    23-Oct-01 23:14
    suss23-Oct-01 23:14 
    GeneralOpenGl + Windows 2000 Pin
    Sanjay BORA17-Oct-00 23:56
    MemberSanjay BORA17-Oct-00 23:56 
    GeneralRe: OpenGl + Windows 2000 Pin
    11-Sep-01 1:51
    suss11-Sep-01 1:51 

    General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

    Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.