Click here to Skip to main content
Click here to Skip to main content

The GLU functions and hit testing using OpenGL and MFC

By , 1 Oct 2000
 
  • 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

    About the Author

    Masoud Samimi
    Technical Lead Samimi Information Technology
    United Arab Emirates United Arab Emirates
    Member
    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

    Sign Up to vote   Poor Excellent
    Add a reason or comment to your vote: x
    Votes of 3 or less require a comment

    Comments and Discussions

     
    You must Sign In to use this message board.
    Search this forum  
        Spacing  Noise  Layout  Per page   
    GeneralMy vote of 4memberMrLonely250425 Jul '10 - 18:30 
    I am looking for it, thanks! :P
    QuestionHow to run 2 different(or same) OpenGL objects in one DialogBox?memberwerter13 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 problemsmemberedsela2 Apr '04 - 9:05 
    Downloaded code, and ran it... (W2K & .net) Suspicious | :suss: Frown | :(
    Doesn't always report object under mouse/cursor and sometimes reports wrong object.
     

     
    Edsel
    QuestionHow is OpenGL compared to DirectX?memberThorell12 May '03 - 4:56 
    How is it to program OpenGL compared to Direct-X?
    Advantages / disadvantages?
    (Assuming that I am only interested in the Windows platform.)
    Learning curve? Features? Performance?

    GeneralExactly what i was looking for - Thankx !sussMayuresh Kadu31 Oct '00 - 18:10 
    Exactly what the doctor (and my project leader !) ordered for me. Thankx a lot !!
     
    OpenGL programming suddenly seems easy after all
    GeneralRe: Exactly what i was looking for - Thankx !member123456723 Oct '01 - 23:14 
    thanx a lot.
    GeneralOpenGl + Windows 2000sussSanjay17 Oct '00 - 23:56 

    Does windows 2000 support opengl fully?
    While working on window 2000 opengl screen clips some times.But same program is working fine on Windos NT.
     


    GeneralRe: OpenGl + Windows 2000memberAnonymous11 Sep '01 - 1:51 
    stupid get lost of here

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

    Permalink | Advertise | Privacy | Mobile
    Web03 | 2.6.130523.1 | Last Updated 2 Oct 2000
    Article Copyright 2000 by Masoud Samimi
    Everything else Copyright © CodeProject, 1999-2013
    Terms of Use
    Layout: fixed | fluid