2000-02-28 08:22:57 +00:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Name: cube.h
|
|
|
|
// Purpose: wxGLCanvas demo program
|
|
|
|
// Author: Julian Smart
|
|
|
|
// Modified by:
|
|
|
|
// Created: 04/01/98
|
|
|
|
// Copyright: (c) Julian Smart
|
2002-03-17 14:16:03 +00:00
|
|
|
// Licence: wxWindows licence
|
2000-02-28 08:22:57 +00:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#ifndef _WX_CUBE_H_
|
|
|
|
#define _WX_CUBE_H_
|
|
|
|
|
2001-11-16 07:17:37 +00:00
|
|
|
#include "wx/glcanvas.h"
|
2000-02-28 08:22:57 +00:00
|
|
|
|
2007-04-15 00:54:32 +00:00
|
|
|
// the rendering context used by all GL canvases
|
|
|
|
class TestGLContext : public wxGLContext
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
TestGLContext(wxGLCanvas *canvas);
|
|
|
|
|
|
|
|
// render the cube showing it at given angles
|
|
|
|
void DrawRotatedCube(float xangle, float yangle);
|
|
|
|
|
|
|
|
private:
|
2007-04-15 15:13:49 +00:00
|
|
|
// textures for the cube faces
|
|
|
|
GLuint m_textures[6];
|
2007-04-15 00:54:32 +00:00
|
|
|
};
|
|
|
|
|
2000-02-28 08:22:57 +00:00
|
|
|
// Define a new application type
|
2008-02-10 13:26:01 +00:00
|
|
|
class MyApp : public wxApp
|
2000-02-28 08:22:57 +00:00
|
|
|
{
|
|
|
|
public:
|
2013-09-15 00:16:44 +00:00
|
|
|
MyApp() { m_glContext = NULL; m_glStereoContext = NULL; }
|
2007-04-09 22:54:40 +00:00
|
|
|
|
2008-02-10 13:26:01 +00:00
|
|
|
// Returns the shared context used by all frames and sets it as current for
|
|
|
|
// the given canvas.
|
2013-09-15 00:16:44 +00:00
|
|
|
TestGLContext& GetContext(wxGLCanvas *canvas, bool useStereo);
|
2007-04-09 22:54:40 +00:00
|
|
|
|
|
|
|
// virtual wxApp methods
|
2014-03-30 00:02:23 +00:00
|
|
|
virtual bool OnInit() wxOVERRIDE;
|
|
|
|
virtual int OnExit() wxOVERRIDE;
|
2007-04-09 22:54:40 +00:00
|
|
|
|
|
|
|
private:
|
2013-09-15 00:16:44 +00:00
|
|
|
// the GL context we use for all our mono rendering windows
|
2007-04-15 00:54:32 +00:00
|
|
|
TestGLContext *m_glContext;
|
2013-09-15 00:16:44 +00:00
|
|
|
// the GL context we use for all our stereo rendering windows
|
|
|
|
TestGLContext *m_glStereoContext;
|
2000-02-28 08:22:57 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
// Define a new frame type
|
2008-02-10 13:26:01 +00:00
|
|
|
class MyFrame : public wxFrame
|
2000-02-28 08:22:57 +00:00
|
|
|
{
|
|
|
|
public:
|
2013-09-15 00:16:44 +00:00
|
|
|
MyFrame(bool stereoWindow = false);
|
2000-02-28 08:22:57 +00:00
|
|
|
|
2007-04-10 00:02:15 +00:00
|
|
|
private:
|
2007-04-10 16:51:52 +00:00
|
|
|
void OnClose(wxCommandEvent& event);
|
2001-10-10 16:37:33 +00:00
|
|
|
void OnNewWindow(wxCommandEvent& event);
|
2013-09-15 00:16:44 +00:00
|
|
|
void OnNewStereoWindow(wxCommandEvent& event);
|
2000-02-28 08:22:57 +00:00
|
|
|
|
2003-11-15 04:21:10 +00:00
|
|
|
DECLARE_EVENT_TABLE()
|
2000-02-28 08:22:57 +00:00
|
|
|
};
|
|
|
|
|
2007-04-09 22:54:40 +00:00
|
|
|
class TestGLCanvas : public wxGLCanvas
|
2000-02-28 08:22:57 +00:00
|
|
|
{
|
|
|
|
public:
|
2013-09-15 00:16:44 +00:00
|
|
|
TestGLCanvas(wxWindow *parent, int *attribList = NULL);
|
2003-11-15 04:21:10 +00:00
|
|
|
|
2007-04-10 00:02:15 +00:00
|
|
|
private:
|
2003-11-15 04:21:10 +00:00
|
|
|
void OnPaint(wxPaintEvent& event);
|
2010-10-24 22:40:58 +00:00
|
|
|
void Spin(float xSpin, float ySpin);
|
2003-11-15 04:21:10 +00:00
|
|
|
void OnKeyDown(wxKeyEvent& event);
|
2010-10-24 22:40:58 +00:00
|
|
|
void OnSpinTimer(wxTimerEvent& WXUNUSED(event));
|
2003-11-15 04:21:10 +00:00
|
|
|
|
2007-04-15 00:54:32 +00:00
|
|
|
// angles of rotation around x- and y- axis
|
|
|
|
float m_xangle,
|
|
|
|
m_yangle;
|
2000-02-28 08:22:57 +00:00
|
|
|
|
2010-10-24 22:40:58 +00:00
|
|
|
wxTimer m_spinTimer;
|
2013-09-15 00:16:44 +00:00
|
|
|
bool m_useStereo,
|
|
|
|
m_stereoWarningAlreadyDisplayed;
|
2010-10-24 22:40:58 +00:00
|
|
|
|
2007-04-09 22:54:40 +00:00
|
|
|
DECLARE_EVENT_TABLE()
|
2000-02-28 08:22:57 +00:00
|
|
|
};
|
|
|
|
|
2013-09-15 00:16:44 +00:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
NEW_STEREO_WINDOW = wxID_HIGHEST + 1
|
|
|
|
};
|
|
|
|
|
2007-04-09 22:54:40 +00:00
|
|
|
#endif // _WX_CUBE_H_
|