2000-02-28 08:22:57 +00: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 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:
|
2007-04-09 22:54:40 +00:00
|
|
|
MyApp() { m_glContext = NULL; }
|
|
|
|
|
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.
|
2007-04-15 00:54:32 +00:00
|
|
|
TestGLContext& GetContext(wxGLCanvas *canvas);
|
2007-04-09 22:54:40 +00:00
|
|
|
|
|
|
|
// virtual wxApp methods
|
|
|
|
virtual bool OnInit();
|
|
|
|
virtual int OnExit();
|
|
|
|
|
|
|
|
private:
|
|
|
|
// the GL context we use for all our windows
|
2007-04-15 00:54:32 +00:00
|
|
|
TestGLContext *m_glContext;
|
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:
|
2007-04-09 22:54:40 +00:00
|
|
|
MyFrame();
|
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);
|
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:
|
2007-04-09 22:54:40 +00:00
|
|
|
TestGLCanvas(wxWindow *parent);
|
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);
|
|
|
|
void OnKeyDown(wxKeyEvent& event);
|
|
|
|
|
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
|
|
|
|
2007-04-09 22:54:40 +00:00
|
|
|
DECLARE_EVENT_TABLE()
|
2000-02-28 08:22:57 +00:00
|
|
|
};
|
|
|
|
|
2007-04-09 22:54:40 +00:00
|
|
|
#endif // _WX_CUBE_H_
|