Gizmo3D

showWindow.cpp

Create a gzWindow This example illustrates how a gzApplication and a gzWindow is created.
The gzWindow is created and drawn when the application is running.

00001 // *****************************************************************************
00002 // File         : showWindow.cpp
00003 // Module       : 
00004 // Description  : Test program for creating an application with a gzWindow
00005 // Author       : Lisa Johansson
00006 // Product      : Gizmo3D 1.3 beta 7
00007 //              
00008 // Copyright © 2003- Saab Training Systems AB, Sweden   
00009 //                      
00010 // NOTE:    Gizmo3D is a high performance 3D Scene Graph and effect visualisation 
00011 //          C++ toolkit for Linux, Mac OS X, Windows (Win32) and IRIX® for  
00012 //          usage in Game or VisSim development.
00013 //
00014 //
00015 // Revision History...                                                  
00016 //                                                                      
00017 // Who  Date    Description                                             
00018 //                                                                      
00019 // LJH  041019  Created file    
00020 //
00021 // ******************************************************************************
00022 
00023 #include "gzGizmo3DLibrary.h"
00024 
00025 
00026 class ShowGzWindow : public gzApplication
00027 {
00028 public:
00029 
00030     // constructor
00031     ShowGzWindow();
00032 
00033     // destructor
00034     virtual ~ShowGzWindow();
00035 
00036     // onIdle method. This method is called when the application is running.
00037     void onIdle(); 
00038 
00039 private:
00040     gzRefPointer<gzWindow> win;
00041 
00042 };
00043 
00044 
00045 ShowGzWindow::ShowGzWindow()
00046 {
00047     // instantiating a gzWindow.
00048     win = new gzWindow("Window Test",(gzWindowHandle)NULL,(gzGraphicsFormat *)NULL,FALSE);
00049 
00050     // sets the size for the window.
00051     win->setSize(300, 300);
00052 
00053     // sets the position for the window on the screen.
00054     win->setPosition(100, 100);
00055 
00056     // Let the window be visible.
00057     win->show();
00058 }
00059 
00060 ShowGzWindow::~ShowGzWindow()
00061 {
00062 }
00063 
00064 // this method is called when the application is running. 
00065 // When the cpu don't have anything to do the onIdle is called.
00066 gzVoid ShowGzWindow::onIdle()
00067 {
00068     // refresh the contents in the window.
00069     win->refreshWindow();
00070 }
00071 
00072 int main(int argc, char *argv[])
00073 {
00074     // Needed for some systems to install external graphics engines
00075     gzStartUpGizmo();   
00076     
00077     // Run your gizmo code. If anything goes wrong an exception will be thrown.
00078     try
00079     {     
00080         // Make the application
00081         ShowGzWindow win;
00082 
00083         // Start the application
00084         win.run();
00085             
00086     }
00087     catch(gzBaseError &error)       
00088     {
00089         // In case of exceptions thrown we want to print the message
00090         error.reportError();
00091     }
00092     
00093     gzShutDownGizmo();
00094     
00095     return 0;
00096 }
00097 

Documentation for Gizmo3D generated at Wed Feb 20 11:54:02 2008 by   Saab Training Systems AB, ¸ (c) 2003-and beyond