Click here to Skip to main content
15,880,427 members
Articles / Desktop Programming / MFC
Article

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 136K   5.7K   62   8
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

    Introduction

    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.

    Sample:

    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 www.codeguru.com's OpenGL link. Please ckeck the sample.

    Rquirements

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

    License

    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


    Written By
    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
    MrLonely250425-Jul-10 18:30 
    QuestionHow to run 2 different(or same) OpenGL objects in one DialogBox? Pin
    werter13-May-04 21:17
    werter13-May-04 21:17 
    How to run 2 different(or same) OpenGL objects in one DialogBox?
    IDC_STATIC1 is a first OpenGL objects Scene window.
    IDC_STATIC2 is a second OpenGL objects Scene window.
    IDC_STATIC1 and IDC_STATIC2 ,they are placed on IDD_DIALOG1.

    code:
    pclStatic = (CStatic *)GetDlgItem(IDC_OpenGL_Window);
    pclGlView = new CGlView(pclStatic);
    pclGlView->OnCreate();
    pclGlView->InitGL();
    pclGlView->DrawGLScene();

    pclStatic1 = (CStatic *)GetDlgItem(IDC_OpenGL_Window);
    pclGlView1 = new CGlView(pclStatic1);
    pclGlView1->OnCreate();
    pclGlView1->InitGL();
    pclGlView1->DrawGLScene();

    Will not involve both windows (IDC_STATIC2,IDC_STATIC1)
    GeneralLooks like there's some coordinate problems Pin
    edsela2-Apr-04 9:05
    edsela2-Apr-04 9:05 
    QuestionHow is OpenGL compared to DirectX? Pin
    Thorell12-May-03 4:56
    Thorell12-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
    Sanjay 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.