OpenGL enabled view for MDI

Introduction

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 services:

  • a function to get various information about OpenGL implementation.
  • manages internally the creation of up to 20 stock display list and offers a basic interface for display list creation, execution and deletion (this function has been surpassed by CGLDispList child class,see below).
  • let you choose a mouse cursor to use inside the views.

Three child classes offer an object oriented interface to OpenGL tessellation routines, quadrics objects and display lists:

  1. CGLDispList: let you manage display lists individually.
  2. CGLTesselator: let you create tesselator objects by which draw non simple polygons (that is convex or self intersecting ones).
  3. CGLQuadric: let you draw spheres, cylinders and disks specifying draw style, textures coordinates generation, normals generation and orientation.

Basic Use

The minimal setup to start experimenting OpenGL drawing is as follows:
  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 would like to set the number of colors, the accuracy of the Z-buffer (note that some accelerated video cards don't support 32 bit accurate z-buffer) and activation of double-buffer.
  5. Override the OnDrawGL function and issue some GL commands.
  6. If you must issue GL commands outside overridable functions (e.g. in menu handlers) enclose them in a BeginGLCommands(), EndGLCommands() pair.
Remember to link OpenGL libraries (look at the beginning of GLEnabledView.cpp for explanations). Other details are in the sample project and in the source (wich should be well commented).

Notes

Since it's not adviseable to mix Windows GDI and OpenGL drawing commands some WM message handlers have been made private, use the supplied overridable virtual functions instead (OnDrawGL,OnSizeGL and OnCreateGL).

Download demo project - 133KB

Download source - 13KB

Date Posted: ??/??/98



Comments

Leave a Comment
  • Your email address will not be published. All fields are required.

Top White Papers and Webcasts

  • Live Event Date: December 11, 2014 @ 1:00 p.m. ET / 10:00 a.m. PT Market pressures to move more quickly and develop innovative applications are forcing organizations to rethink how they develop and release applications. The combination of public clouds and physical back-end infrastructures are a means to get applications out faster. However, these hybrid solutions complicate DevOps adoption, with application delivery pipelines that span across complex hybrid cloud and non-cloud environments. Check out this …

  • CentreCorp is a fully integrated and diversified property management and real estate service company, specializing in the "shopping center" segment, and is one of the premier retail service providers in North America. Company executives travel a great deal, carrying a number of traveling laptops with critical current business data, and no easy way to back up to the network outside the office. Read this case study to learn how CentreCorp implemented a suite of business continuity services that included …

Most Popular Programming Stories

More for Developers

RSS Feeds