5,530,111 members and growing! (15,713 online)
Email Password   helpLost your password?
Multimedia » OpenGL » General     Intermediate

OpenGL Win32 AppWizard

By Ulf Öhlén

This Custom AppWizard for VC++ 6.0 or VC++.NET creates an OpenGL enabled Win32 application suitable for demos and simple games.
VC6, VC7, C++Windows, NT4, OpenGL, VS.NET2002, VS6, Visual Studio, Dev

Posted: 26 Jul 2001
Updated: 19 May 2003
Views: 242,934
Bookmarked: 72 times
Announcements
Want a new Job?



Search    
Advanced Search
Sitemap
54 votes for this Article.
Popularity: 8.31 Rating: 4.80 out of 5
0 votes, 0.0%
1
0 votes, 0.0%
2
1 vote, 2.6%
3
2 votes, 5.3%
4
35 votes, 92.1%
5

Sample Image - OGLWiz.gif
An example of a generated application

Installation (VC6 version)

Copy OGLWiz.awx and Oglwiz.hlp to your Custom AppWizard directory (probably "C:\Program Files\Microsoft Visual Studio\Common\MSDev98\Template").

Overview of the generated project (VC6 version)

Projects generated with this AppWizard contains two classes:
  • CApp
  • CMainWnd
There is a global instance of CApp (gApp) that owns an instance of CMainWnd (m_pMainWnd). CApp creates the main window, initializes OpenGL, maintains the message pump and manages screen updates. CMainWnd encapsulates the main window and its OpenGL rendering context. CApp notifies CMainWnd of different phases of the OpenGL RC life cycle (by calling CMainWnd::InitScene(), CMainWnd::KillScene() and CMainWnd::DrawScene()). CMainWnd::Tick() is called (by CApp) each time the windows message queue is empty.

This may not be the most elegant OO solution; some of the code in CApp really belongs in CMainWnd, like window creation and (some of the) message handling. But the idea is to let CApp do the grunt work of Win32API and OpenGL setup and leave CMainWnd free to concentrate on what's displayed in the client area.

Using the wizard

Chose to create a new project, selecting "OpenGL Win32 Application" from the list of project types, enter a project name and press OK.

The following options to customize the project are available:

Application

Menu: Check this box to add a menu to the main window.
Keyboard accelerator: Adds a keyboard accelerator resource and processes accelerator keys.
About box: Creates an about dialog and a dialog callback routine. Also adds an About command to the menu (if available).

Main window

Select appearance of the main window.

Window: Creates an overlapped main window with default size.
Fullscreen: Creates a topmost popup window that occupies the entire screen.
Both: Appearence is determined with a switch: If FULLSCREEN is not #defined, the application runs in a window.
Show FPS in caption: Adds code to show Frames Per Second on regular intervals. (Not available in fullscreen mode)

OpenGL Support

Use OpenGL: Adds code to initialize and maintain an OpenGL RC. If this box is not checked, a plain Win32 application is created.
Sample code: Adds code that renders a simple OpenGL scene (spinning cube).
Double buffering: Creates a double-buffered pixel buffer.
Color depth: Number of color bitplanes in each color buffer.
Z-buffer depth: Bit-depth of the Z-buffer.
Background color: Press the button to select background color for main window.

Notes on the VC++.NET appwizard

In VC++.NET, appwizards are no longer compiled plugins, but rather a collection of scripts and template files, with a HTML-based UI. See Readme.txt for installation instructions.

I took the opportunity to change the object model into something that, IMO, is a bit cleaner. Instead of having one class for the window and one class for the application, there is now one abstract base class, CApp, that takes care of window creation, OpenGL initialization etc. The "meat" of the generated app goes in a derived class that overrides a number of virtual functions of CApp. For example, InitScene(), DrawScene() and KillScene() are virtual.

Other than that, the VC++.NET version of the AppWizard behaves basically the same as the VC++6 version.

History

  • 20 May 2003 - Updated VS.NET download

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

Ulf Öhlén



Location: Sweden Sweden

Other popular OpenGL articles:

Article Top
Sign Up to vote for this article
You must Sign In to use this message board.
FAQ FAQ Noise ToleranceSearch Search Messages 
 Layout  Per page   
 Msgs 1 to 25 of 60 (Total in Forum: 60) (Refresh)FirstPrevNext
Subject  Author Date 
GeneralglReadPixels()memberJeanFilion4:33 12 Aug '07  
QuestionRe: glReadPixels()memberBilica7:02 29 Nov '07  
AnswerRe: glReadPixels()memberJeanFilion9:02 29 Nov '07  
Generalhow to do real-time image processing using VC++?memberli zhiyuan23:01 25 Jun '07  
GeneralRe: how to do real-time image processing using VC++?memberzafersavas3:22 8 Jun '08  
GeneralErrors in scriptmemberBruzak5:32 12 Apr '07  
GeneralStart Maximizedmemberrfs671815:25 16 Dec '06  
Generalhow to combine two program??membermallie20:28 26 Mar '06  
QuestionVisual Studio 2005memberjpummill8:02 23 Nov '05  
AnswerRe: Visual Studio 2005memberbrianpoteat11:01 24 Aug '07  
GeneralAbout coding a simple human facesussAnonymous9:46 26 Sep '05  
GeneralI need help on using this for an MDI appmembersardaukar_siet13:18 12 Feb '05  
GeneralGetting an error when trying to start a projectmemberTheTroll12311:49 10 Oct '04  
GeneralRe: Getting an error when trying to start a projectmembergulumulu0:07 8 Oct '05  
GeneralHow to run 2 different(or same) OpenGL objects in one DialogBox?memberwerter122:11 3 May '04  
GeneralA suggestion.memberSevenCat0:49 16 Dec '03  
Generalhow can i add my own class to applicationsusswuling12915:07 1 Dec '03  
GeneralAll I get is a Blank form when I select this as a projectmemberMike_in_Paradise7:12 26 May '03  
GeneralRe: All I get is a Blank form when I select this as a projectmemberdpaquc6:19 22 Oct '03  
GeneralRe: All I get is a Blank form when I select this as a projectmemberwebbsk10:34 24 Nov '03  
GeneralRe: All I get is a Blank form when I select this as a projectmemberSevenCat0:44 16 Dec '03  
Generalbug fix with Microsoft Visual Studio .NET 2003membermarkthecoder22:01 15 May '03  
GeneralListen to this guy!sussAnonymous5:33 4 Jul '03  
GeneralThanks, what about Microsoft Visual Studio .NET 2005memberceman824:03 28 Jan '07  
GeneralRe: Thanks, what about Microsoft Visual Studio .NET 2005membermarkthecoder14:19 29 Jan '07  

General General    News News    Question Question    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

PermaLink | Privacy | Terms of Use
Last Updated: 19 May 2003
Editor: Chris Maunder
Copyright 2001 by Ulf Öhlén
Everything else Copyright © CodeProject, 1999-2008
Web20 | Advertise on the Code Project