Basic Image AlgorithmS Library 2.8.0

ExampleGLShared.hh

00001 /* This file is part of the BIAS library (Basic ImageAlgorithmS).
00002 
00003    Copyright (C) 2003-2009    (see file CONTACT for details)
00004    Vision N GmbH
00005    Schauenburgerstr. 116
00006    24118 Kiel
00007    
00008    BIAS is free software; you can redistribute it and/or modify
00009    it under the terms of the GNU Lesser General Public License as published by
00010    the Free Software Foundation; either version 2.1 of the License, or
00011    (at your option) any later version.
00012    
00013    BIAS is distributed in the hope that it will be useful,
00014    but WITHOUT ANY WARRANTY; without even the implied warranty of
00015    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00016    GNU Lesser General Public License for more details.
00017    
00018    You should have received a copy of the GNU Lesser General Public License
00019    along with BIAS; if not, write to the Free Software
00020    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA*/
00021 
00022 /** 
00023  * @example ExampleGLShared.cpp
00024  * @ingroup g_examples
00025  * @brief OpenGL example for 
00026  * - using multiple canvases sharing the same canvas inlcuding didplay lists etc.
00027  * - drawing text in OpenGL Using fonts.
00028  * Demonstrates
00029  * - usage of wx OpenGL canvas,
00030  * - setting up a shared context,
00031  * - using fonts with OpenGL in absolute and relative mode. Resize the window to see the effect.
00032  * @author Jan Woetzel 
00033  */
00034 
00035 //BIAS
00036 #include <Gui/OpenGLCanvas.hh>
00037 #ifdef BIAS_HAVE_FONTGL
00038 #  include <Utils/DrawTextGL.hh>
00039 #endif
00040 #include <wx/wx.h>
00041 
00042 
00043 using namespace BIAS;
00044 using namespace std;
00045 
00046 /** \cond HIDDEN_SYMBOLS*/
00047 class ExampleGLSharedApp 
00048   : public /*wxApp*/ wxGLApp
00049 {
00050   virtual bool OnInit(); 
00051 }; // end of ExampleGLSharedApp -----------------------
00052 
00053 
00054 enum _ExampleGLSharedMyFrameIDs_ {
00055   ID_ABOUT=wxID_ABOUT,
00056   ID_QUIT
00057 };
00058 
00059 
00060 // --------------------------------------------------------
00061 
00062 
00063 /** Implement your own OopenGLCanvas derived class
00064 and override one of the Display functions
00065 to plug in your own GL calls / GL scene
00066 @author Jan Woetzl */
00067 class MyGLCanvas : public OpenGLCanvas {
00068 public:
00069   MyGLCanvas(wxFrame* parent);
00070 
00071   /// constructor using a shared context 
00072   MyGLCanvas(
00073     wxFrame* parent
00074     ,wxGLContext* sharedContext
00075     ,wxWindowID id = -1
00076     ,const wxPoint& pos = wxDefaultPosition
00077     ,const wxSize& size = wxDefaultSize
00078     ,long style=0
00079     ,const wxString& name=wxT("MyGLCanvas sharedContext")
00080     ,int* attribList = 0
00081     ,const wxPalette& palette = wxNullPalette
00082     );
00083 
00084   // override to fire our own Display calls: 
00085   void DisplayCalls();
00086 
00087   //
00088   // additional members:
00089   //
00090 
00091   // additional function to load and init geometry, dipsla ylistst etc. JW
00092   void InitGeometry();
00093 
00094   // data mebers:
00095   int dplist;
00096 #ifdef BIAS_HAVE_FONTGL
00097   DrawTextGL font;
00098 #endif
00099 };
00100 
00101 
00102 class MyGLCanvas2 : public OpenGLCanvas {
00103 public:
00104   MyGLCanvas2(wxFrame* parent);
00105 
00106   /// constructor using a shared context 
00107   MyGLCanvas2(
00108     wxFrame* parent
00109     ,wxGLContext* sharedContext
00110     ,wxWindowID id = -1
00111     ,const wxPoint& pos = wxDefaultPosition
00112     ,const wxSize& size = wxDefaultSize
00113     ,long style=0
00114     ,const wxString& name=wxT("MyGLCanvas sharedContext")
00115     ,int* attribList = 0
00116     ,const wxPalette& palette = wxNullPalette
00117     );
00118 
00119   // override to fire our own Display calls: 
00120   void DisplayCalls();
00121 
00122   int dplist;
00123 };
00124 
00125 
00126 // --------------------------------------------------------
00127 
00128 class MyFrame: public wxFrame {
00129 public:
00130   MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size);
00131   void OnQuit(wxCommandEvent& event);
00132   void OnAbout(wxCommandEvent& event);
00133 
00134   // data member ---
00135   //BIAS::OpenGLCanvas * p_canvas;
00136   MyGLCanvas * p_canvas;
00137   MyGLCanvas2 * p_2nd_canvas;
00138 
00139   DECLARE_EVENT_TABLE()
00140 }; // end of MyFrame --------------------------------------
00141 /** \endcond */
 All Classes Functions Variables Typedefs Enumerations Enumerator Friends