]> git.saurik.com Git - wxWidgets.git/blame - samples/opengl/cube/cube.h
added 'wxgui' template to make writing makefiles for gui apps a bit easier
[wxWidgets.git] / samples / opengl / cube / cube.h
CommitLineData
8b089c5e
JS
1/////////////////////////////////////////////////////////////////////////////
2// Name: cube.h
3// Purpose: wxGLCanvas demo program
4// Author: Julian Smart
5// Modified by:
6// Created: 04/01/98
7// RCS-ID: $Id$
8// Copyright: (c) Julian Smart
2f6c54eb 9// Licence: wxWindows licence
8b089c5e
JS
10/////////////////////////////////////////////////////////////////////////////
11
12#ifndef _WX_CUBE_H_
13#define _WX_CUBE_H_
14
9d705dfa 15#include "wx/glcanvas.h"
8b089c5e 16
50f5d508
VZ
17// the rendering context used by all GL canvases
18class TestGLContext : public wxGLContext
19{
20public:
21 TestGLContext(wxGLCanvas *canvas);
22
23 // render the cube showing it at given angles
24 void DrawRotatedCube(float xangle, float yangle);
25
26private:
378a3872
VZ
27 // textures for the cube faces
28 GLuint m_textures[6];
50f5d508
VZ
29};
30
8b089c5e
JS
31// Define a new application type
32class MyApp: public wxApp
33{
34public:
43c742d0
VZ
35 MyApp() { m_glContext = NULL; }
36
50f5d508
VZ
37 // get the context we use creating it on demand (and set it as current)
38 TestGLContext& GetContext(wxGLCanvas *canvas);
43c742d0
VZ
39
40 // virtual wxApp methods
41 virtual bool OnInit();
42 virtual int OnExit();
43
44private:
45 // the GL context we use for all our windows
50f5d508 46 TestGLContext *m_glContext;
8b089c5e
JS
47};
48
49// Define a new frame type
8b089c5e
JS
50class MyFrame: public wxFrame
51{
52public:
43c742d0 53 MyFrame();
8b089c5e 54
264f2261 55private:
1f602af6 56 void OnClose(wxCommandEvent& event);
ec299508
VZ
57 void OnNewWindow(wxCommandEvent& event);
58 void OnDefRotateLeftKey(wxCommandEvent& event);
59 void OnDefRotateRightKey(wxCommandEvent& event);
8b089c5e 60
5cf036d0 61 DECLARE_EVENT_TABLE()
8b089c5e
JS
62};
63
43c742d0 64class TestGLCanvas : public wxGLCanvas
8b089c5e 65{
8b089c5e 66public:
43c742d0 67 TestGLCanvas(wxWindow *parent);
5cf036d0 68
264f2261 69private:
5cf036d0
DS
70 void OnPaint(wxPaintEvent& event);
71 void OnSize(wxSizeEvent& event);
5cf036d0 72 void OnKeyDown(wxKeyEvent& event);
5cf036d0 73
50f5d508
VZ
74 // angles of rotation around x- and y- axis
75 float m_xangle,
76 m_yangle;
8b089c5e 77
43c742d0 78 DECLARE_EVENT_TABLE()
8b089c5e
JS
79};
80
43c742d0 81#endif // _WX_CUBE_H_
2db98bf5 82