2000-02-28 03:22:57 -05:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Name: cube.h
|
|
|
|
// Purpose: wxGLCanvas demo program
|
|
|
|
// Author: Julian Smart
|
|
|
|
// Modified by:
|
|
|
|
// Created: 04/01/98
|
|
|
|
// RCS-ID: $Id$
|
|
|
|
// Copyright: (c) Julian Smart
|
2002-03-17 09:16:03 -05:00
|
|
|
// Licence: wxWindows licence
|
2000-02-28 03:22:57 -05:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#ifndef _WX_CUBE_H_
|
|
|
|
#define _WX_CUBE_H_
|
|
|
|
|
2001-11-16 02:17:37 -05:00
|
|
|
#include "wx/glcanvas.h"
|
2000-02-28 03:22:57 -05:00
|
|
|
|
2007-04-14 20:54:32 -04: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 11:13:49 -04:00
|
|
|
// textures for the cube faces
|
|
|
|
GLuint m_textures[6];
|
2007-04-14 20:54:32 -04:00
|
|
|
};
|
|
|
|
|
2000-02-28 03:22:57 -05:00
|
|
|
// Define a new application type
|
|
|
|
class MyApp: public wxApp
|
|
|
|
{
|
|
|
|
public:
|
2007-04-09 18:54:40 -04:00
|
|
|
MyApp() { m_glContext = NULL; }
|
|
|
|
|
2007-04-14 20:54:32 -04:00
|
|
|
// get the context we use creating it on demand (and set it as current)
|
|
|
|
TestGLContext& GetContext(wxGLCanvas *canvas);
|
2007-04-09 18:54:40 -04:00
|
|
|
|
|
|
|
// virtual wxApp methods
|
|
|
|
virtual bool OnInit();
|
|
|
|
virtual int OnExit();
|
|
|
|
|
|
|
|
private:
|
|
|
|
// the GL context we use for all our windows
|
2007-04-14 20:54:32 -04:00
|
|
|
TestGLContext *m_glContext;
|
2000-02-28 03:22:57 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
// Define a new frame type
|
|
|
|
class MyFrame: public wxFrame
|
|
|
|
{
|
|
|
|
public:
|
2007-04-09 18:54:40 -04:00
|
|
|
MyFrame();
|
2000-02-28 03:22:57 -05:00
|
|
|
|
2007-04-09 20:02:15 -04:00
|
|
|
private:
|
2007-04-10 12:51:52 -04:00
|
|
|
void OnClose(wxCommandEvent& event);
|
2001-10-10 12:37:33 -04:00
|
|
|
void OnNewWindow(wxCommandEvent& event);
|
|
|
|
void OnDefRotateLeftKey(wxCommandEvent& event);
|
|
|
|
void OnDefRotateRightKey(wxCommandEvent& event);
|
2000-02-28 03:22:57 -05:00
|
|
|
|
2003-11-14 23:21:10 -05:00
|
|
|
DECLARE_EVENT_TABLE()
|
2000-02-28 03:22:57 -05:00
|
|
|
};
|
|
|
|
|
2007-04-09 18:54:40 -04:00
|
|
|
class TestGLCanvas : public wxGLCanvas
|
2000-02-28 03:22:57 -05:00
|
|
|
{
|
|
|
|
public:
|
2007-04-09 18:54:40 -04:00
|
|
|
TestGLCanvas(wxWindow *parent);
|
2003-11-14 23:21:10 -05:00
|
|
|
|
2007-04-09 20:02:15 -04:00
|
|
|
private:
|
2003-11-14 23:21:10 -05:00
|
|
|
void OnPaint(wxPaintEvent& event);
|
|
|
|
void OnSize(wxSizeEvent& event);
|
|
|
|
void OnKeyDown(wxKeyEvent& event);
|
|
|
|
|
2007-04-14 20:54:32 -04:00
|
|
|
// angles of rotation around x- and y- axis
|
|
|
|
float m_xangle,
|
|
|
|
m_yangle;
|
2000-02-28 03:22:57 -05:00
|
|
|
|
2007-04-09 18:54:40 -04:00
|
|
|
DECLARE_EVENT_TABLE()
|
2000-02-28 03:22:57 -05:00
|
|
|
};
|
|
|
|
|
2007-04-09 18:54:40 -04:00
|
|
|
#endif // _WX_CUBE_H_
|
2003-09-11 03:20:55 -04:00
|
|
|
|