Basic Image AlgorithmS Library  2.8.0
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
ExampleGLShared.hh
1 /* This file is part of the BIAS library (Basic ImageAlgorithmS).
2 
3  Copyright (C) 2003-2009 (see file CONTACT for details)
4  Vision N GmbH
5  Schauenburgerstr. 116
6  24118 Kiel
7 
8  BIAS is free software; you can redistribute it and/or modify
9  it under the terms of the GNU Lesser General Public License as published by
10  the Free Software Foundation; either version 2.1 of the License, or
11  (at your option) any later version.
12 
13  BIAS is distributed in the hope that it will be useful,
14  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  GNU Lesser General Public License for more details.
17 
18  You should have received a copy of the GNU Lesser General Public License
19  along with BIAS; if not, write to the Free Software
20  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA*/
21 
22 /**
23  * @example ExampleGLShared.cpp
24  * @ingroup g_examples
25  * @brief OpenGL example for
26  * - using multiple canvases sharing the same canvas inlcuding didplay lists etc.
27  * - drawing text in OpenGL Using fonts.
28  * Demonstrates
29  * - usage of wx OpenGL canvas,
30  * - setting up a shared context,
31  * - using fonts with OpenGL in absolute and relative mode. Resize the window to see the effect.
32  * @author Jan Woetzel
33  */
34 
35 //BIAS
36 #include <Gui/OpenGLCanvas.hh>
37 #ifdef BIAS_HAVE_FONTGL
38 # include <Utils/DrawTextGL.hh>
39 #endif
40 #include <wx/wx.h>
41 
42 
43 using namespace BIAS;
44 using namespace std;
45 
46 /** \cond HIDDEN_SYMBOLS*/
47 class ExampleGLSharedApp
48  : public /*wxApp*/ wxGLApp
49 {
50  virtual bool OnInit();
51 }; // end of ExampleGLSharedApp -----------------------
52 
53 
54 enum _ExampleGLSharedMyFrameIDs_ {
55  ID_ABOUT=wxID_ABOUT,
56  ID_QUIT
57 };
58 
59 
60 // --------------------------------------------------------
61 
62 
63 /** Implement your own OopenGLCanvas derived class
64 and override one of the Display functions
65 to plug in your own GL calls / GL scene
66 @author Jan Woetzl */
67 class MyGLCanvas : public OpenGLCanvas {
68 public:
69  MyGLCanvas(wxFrame* parent);
70 
71  /// constructor using a shared context
72  MyGLCanvas(
73  wxFrame* parent
74  ,wxGLContext* sharedContext
75  ,wxWindowID id = -1
76  ,const wxPoint& pos = wxDefaultPosition
77  ,const wxSize& size = wxDefaultSize
78  ,long style=0
79  ,const wxString& name=wxT("MyGLCanvas sharedContext")
80  ,int* attribList = 0
81  ,const wxPalette& palette = wxNullPalette
82  );
83 
84  // override to fire our own Display calls:
85  void DisplayCalls();
86 
87  //
88  // additional members:
89  //
90 
91  // additional function to load and init geometry, dipsla ylistst etc. JW
92  void InitGeometry();
93 
94  // data mebers:
95  int dplist;
96 #ifdef BIAS_HAVE_FONTGL
97  DrawTextGL font;
98 #endif
99 };
100 
101 
102 class MyGLCanvas2 : public OpenGLCanvas {
103 public:
104  MyGLCanvas2(wxFrame* parent);
105 
106  /// constructor using a shared context
107  MyGLCanvas2(
108  wxFrame* parent
109  ,wxGLContext* sharedContext
110  ,wxWindowID id = -1
111  ,const wxPoint& pos = wxDefaultPosition
112  ,const wxSize& size = wxDefaultSize
113  ,long style=0
114  ,const wxString& name=wxT("MyGLCanvas sharedContext")
115  ,int* attribList = 0
116  ,const wxPalette& palette = wxNullPalette
117  );
118 
119  // override to fire our own Display calls:
120  void DisplayCalls();
121 
122  int dplist;
123 };
124 
125 
126 // --------------------------------------------------------
127 
128 class MyFrame: public wxFrame {
129 public:
130  MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size);
131  void OnQuit(wxCommandEvent& event);
132  void OnAbout(wxCommandEvent& event);
133 
134  // data member ---
135  //BIAS::OpenGLCanvas * p_canvas;
136  MyGLCanvas * p_canvas;
137  MyGLCanvas2 * p_2nd_canvas;
138 
139  DECLARE_EVENT_TABLE()
140 }; // end of MyFrame --------------------------------------
141 /** \endcond */
OpenGL canvases with additinal event handling (JW)
Definition: OpenGLCanvas.hh:68
Draw text to OpenGL as 2D bitmap font.
Definition: DrawTextGL.hh:71