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

CGLEnabledView - An MDI view class supporting OpenGL

By , 30 Nov 1999
 
  • Download demo project - 82 Kb
  • Download source files - 15 Kb
  • Sample Image - glenabledview.gif

    What is it

    CGEnabledView is a view class designed to wrap all OpenGL stuff (initialization, managing of Rendering Contexts and palettes, destruction, etc.) allowing the creation of multiple views in a MDI application.

    CGEnabledView also offers these basic services:

    • a function to get various information about the OpenGL implementation which is currently being used (separate information for the OPENGL and GLU libraries).
    • manages internally the creation of display lists and offers a primitive interface for display lists execution.
    • defines mouse cursor to be used inside the views.
    • offers an object oriented encapsulation of quadric objects for drawing of spheres, cylinders and disks.
    • offers an object oriented encapsulation of glu tessellator routines for translating non simple polygons (concave, self-intersecting and with holes) in groups of simple ones (triangle strips and fans).
    • presents a simple interface to draw text strings as 2D bitmaps or complete 3D glyphs.

    Use

    This article uses the trackball code introduced in the companion article A virtual trackball rotation controller .

    To start experimenting OpenGL drawing you just need to follow these steps:

    1. Use AppWizard to geneate an MDI project.
    2. Substitute CView with CGLEnabledView in [YourProject]View.cpp and [YourProject]View.h.
    3. Use ClassWizard to remove the OnDraw and PreCreateWindow functions (delete the bodies too).
    4. Override the VideoMode function if you need to ask for a particular combination of color-buffer depth,depth-buffer depth and double-buffering mode.
    5. Override the OnCreateGL if you need to perform some initializations
    6. Override the OnDrawGL function and issue some GL calls.
    7. Remember to link OpenGL libraries (look at the top of GLEnabledView.cpp for explanations) before building your project.

    Since it's not adviseable to mix Windows GDI and OpenGL drawing commands some WM handlers have been made private, use the overridable virtual functions instead.
    Other details are in the demo code (wich should be well commented) which can be used as a good starting point.

    The Demo

    In the sample project you can open multiple views each presenting a sample scene and rotate them interactively with the mouse. You can get some information about OpenGL implementation via the Help/View OGL Info menu item. Look at the about dialog box for some shortcut-keys.
    This demo project shows the use of a virtual trackball controller which permits to rotate the scene as if you are manipulating a virtual sphere superimposed on the application child window.

    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

    Alessandro Falappa
    Software Developer (Senior)
    Italy Italy
    Member
    Male.
    Living in Rome, Italy
    Computer addict since 12 years old (first computer: Commodore 64).
    Master degree in Computer Science.
    Very interested in computer generated graphics both real time (mainly OpenGL) and photorealistic rendering.

    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   
    GeneralHi,dear Alessandro,I have some question about your articsmemberaqing1 Jul '04 - 7:20 
    I know you have developed an application supporting the Mutil-View. Yes, It is very good.But I don't know how the button(changeScene) blend to the different Views,when they were actived. Are there other setting in your application?
     
    I have developed a program similiar to yours, but the message sending by the button on the tool bar have only effect on the first active view. You can draw the opengl objects on the first view, but others can not.
     
    have anything different between them?
     
    Thank you very much!
     
    -Anqin
     

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

    Permalink | Advertise | Privacy | Mobile
    Web02 | 2.6.130516.1 | Last Updated 1 Dec 1999
    Article Copyright 1999 by Alessandro Falappa
    Everything else Copyright © CodeProject, 1999-2013
    Terms of Use
    Layout: fixed | fluid