1 #ifndef __OpenGLCanvasBase_hh__
2 #define __OpenGLCanvasBase_hh__
5 #include <bias_config.h>
6 #ifndef BIAS_HAVE_WXWIDGETS
7 # error Please recompile BIAS with USE_WXWIDGETS to use this lib.
8 #endif // BIAS_HAVE_WXWIDGETS
10 #ifndef BIAS_HAVE_OPENGL
11 # error Please recompile BIAS with USE_OPENGL to use this file.
12 #endif // BIAS_HAVE_OPENGL
20 #ifndef _CRT_SECURE_NO_DEPRECATE
21 # define _CRT_SECURE_NO_DEPRECATE
24 #include <Gui/biasgl.h>
25 #include <wx/glcanvas.h>
27 #include <Base/Common/W32Compat.hh>
32 #if defined(wxUSE_GLCANVAS) && wxUSE_GLCANVAS
35 # error wx has not been compiled with wxUSE_GLCANVAS=1. BIASGUi needs a ww with gl support. Please set wx/setup.h: wxUSE_GLCANVAS=1 and recompile WX.
45 #include <Base/Debug/Error.hh>
46 #include <Base/Debug/DebugSimple.hh>
47 #include <Base/Math/Vector3.hh>
48 #include <Base/Math/Vector4.hh>
49 #include <Base/Image/Image.hh>
50 #include <Gui/StringConv.hh>
57 #include <Gui/RenderModeGL.hh>
58 #ifdef BIAS_HAVE_FONTGL
59 # include <Utils/DrawTextGL.hh>
64 #ifndef OPENGLCANVASBASE_DEFAULT_animationUpdateEnabled
65 # define OPENGLCANVASBASE_DEFAULT_animationUpdateEnabled true
69 #ifndef BIAS_SCREENSHOT_DEFAULT_EXTENSION
70 # define BIAS_SCREENSHOT_DEFAULT_EXTENSION ".mip"
74 #define OpenGLCanvasBase_DEFAULT_FULLSCREEN_STYLE wxFULLSCREEN_NOMENUBAR|wxFULLSCREEN_NOTOOLBAR|wxFULLSCREEN_NOSTATUSBAR|wxFULLSCREEN_NOBORDER|wxFULLSCREEN_NOCAPTION|wxFULLSCREEN_ALL
92 WX_GL_STENCIL_SIZE, 0,
105 WX_GL_STENCIL_SIZE, 1,
158 ,
const wxPoint& pos = wxDefaultPosition
159 ,
const wxSize& size = wxDefaultSize
161 ,
const wxString& name =
AsciiToWx(
"OpenGLCanvasBase")
162 ,
int* attribList = NULL
163 ,
const wxPalette& palette = wxNullPalette
170 ,wxGLContext* sharedContext = NULL
172 ,
const wxPoint& pos = wxDefaultPosition
173 ,
const wxSize& size = wxDefaultSize
175 ,
const wxString& name=
AsciiToWx(
"OpenGLCanvasBase")
176 ,
int* attribList = NULL
177 ,
const wxPalette& palette = wxNullPalette
183 virtual void InitMembers();
187 virtual void InitWithContext();
202 virtual void Display();
204 virtual void DisplayCalls();
207 virtual void DisplayRenderMode();
210 virtual std::ostream & PrintHelp(std::ostream & os);
213 void DisplaySelectBuffer();
216 virtual void DisplayClear(
const GLbitfield & mask=CLEAR_DEFAULT_MASK );
219 static void DisplaySampleScene();
223 void DisplayCoordCross(
const float & size=1.0f,
const float & linewidth=1.0f);
228 virtual void Reshape();
231 virtual void GetInfoGL(std::ostream & os);
238 float GetPixelValueDepth(
const wxPoint & pos2d)
const;
242 bool IsContextAvailable();
249 unsigned int GetWidth()
const;
251 unsigned int GetHeight()
const;
254 float GetAspectRatio()
const;
262 void ShowFPS(
const int & framecounter,
263 const float & minUpdateIntervalSec,
264 const unsigned int & minNewFrames,
265 const unsigned int nField);
270 static void SetVSync(
const bool & trueForOn );
274 static bool GetVSync();
278 static bool ToggleVSync();
280 void OnPaint( wxPaintEvent &event );
281 void OnSize(wxSizeEvent& event);
282 void OnEraseBackground(wxEraseEvent& event);
283 virtual void OnChar(wxKeyEvent& event);
289 const bool & flipY=
true,
290 const GLenum & format=GL_RGB,
291 const bool &force8Bit=
false);
293 void ScreenShot(
const std::string & filename,
294 const bool & flipY=
true,
295 const GLenum & format=GL_RGB,
296 const bool &force8Bit=
false);
304 wxFrame* GetOwnerframe();
306 void SetOwnerframe(wxFrame* ptr);
309 void SetStatusText(
const wxString& text,
const int c_field=0 );
311 void ShowValue(
const wxPoint & pos);
315 void ToggleFullScreen();
319 static bool ToggleIP(
bool & value);
323 virtual void UpdateTime();
326 #ifdef BIAS_HAVE_STEREOI
331 static int StereoI_Init();
334 static void StereoI_GetInfo(std::ostream &os=std::cout);
337 static int StereoI_GetStereoState();
338 static int StereoI_SetStereoState(
const int & val);
339 static float StereoI_GetSeparation();
340 static float StereoI_SetSeparation(
const float & val);
341 static float StereoI_GetConvergence();
342 static float StereoI_SetConvergence(
const float & val);
345 static void StereoI_CaptureStereoImage(
const int & format,
const int & quality);
347 #endif // BIAS_HAVE_STEREOI
375 #ifdef BIAS_HAVE_FONTGL
379 DECLARE_EVENT_TABLE()
unsigned long framecount_
static bool animationUpdateEnabled
wxString AsciiToWx(const char *thestring)
Converts a C string to a wxString.
BIAS::RenderModeGL rendermode
const int attribsRGBAD[]
helper to simplify setting up format "red,green,blue,alpha,depth" JW to be used as (int*)&attribsRG...
const int attribsRGBASD[]
helper to simplify setting up format "red,green,blue,alpha,stencil,depth" JW to be used as (int*)...
unsigned long GetFrameCount() const
static unsigned int instancesTotalNo_
base class for OpenGL canvases you could derive from to get base functionality (JW) ...
BIAS::DrawTextGL * p_font
bool InitWithContextDone_
void SetFrameCount(const unsigned long &newVal)
GLRenderMode describes mode for rendering.
This is the base class for images in BIAS.
Draw text to OpenGL as 2D bitmap font.