]> git.saurik.com Git - wxWidgets.git/blame - samples/opengl/cube/cube.cpp
Forgot to remove wxBackingFile from the changes.txt. It was kept internal
[wxWidgets.git] / samples / opengl / cube / cube.cpp
Content-type: text/html ]> git.saurik.com Git - wxWidgets.git/blame - samples/opengl/cube/cube.cpp


500 - Internal Server Error

Malformed UTF-8 character (fatal) at /usr/lib/x86_64-linux-gnu/perl5/5.40/HTML/Entities.pm line 485, <$fd> line 360.
CommitLineData
8b089c5e
JS
1/////////////////////////////////////////////////////////////////////////////
2// Name: cube.cpp
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
f4a7108f 9// Licence: wxWindows licence
8b089c5e
JS
10/////////////////////////////////////////////////////////////////////////////
11
8b089c5e
JS
12// For compilers that support precompilation, includes "wx.h".
13#include "wx/wxprec.h"
14
15#ifdef __BORLANDC__
16#pragma hdrstop
17#endif
18
19#ifndef WX_PRECOMP
20#include "wx/wx.h"
21#endif
22
806e2f15
VZ
23#if !wxUSE_GLCANVAS
24 #error "OpenGL required: set wxUSE_GLCANVAS to 1 and rebuild the library"
25#endif
26
8b089c5e 27#include "cube.h"
3a992940 28#include "../../sample.xpm"
8b089c5e 29
be517567 30#ifndef __WXMSW__ // for StopWatch, see remark below
e195c8c9
GD
31 #if defined(__WXMAC__) && !defined(__DARWIN__)
32 #include <utime.h>
33 #include <unistd.h>
34 #else
35 #include <sys/time.h>
36 #include <sys/unistd.h>
37 #endif
8b089c5e
JS
38#else
39#include <sys/timeb.h>
40#endif
41
42#define ID_NEW_WINDOW 10000
43#define ID_DEF_ROTATE_LEFT_KEY 10001
44#define ID_DEF_ROTATE_RIGHT_KEY 10002
45
46/*----------------------------------------------------------
47 Control to get a keycode
48 ----------------------------------------------------------*/
49class ScanCodeCtrl : public wxTextCtrl
50{
51public:
5cf036d0
DS
52 ScanCodeCtrl( wxWindow* parent, wxWindowID id, int code,
53 const wxPoint& pos, const wxSize& size );
54
55 void OnChar( wxKeyEvent& WXUNUSED(event) )
56 {
57 // Do nothing
58 }
59
60 void OnKeyDown(wxKeyEvent& event);
61
8b089c5e 62private:
5cf036d0 63
be5a51fb 64 // Any class wishing to process wxWidgets events must use this macro
5cf036d0 65 DECLARE_EVENT_TABLE()
8b089c5e 66};
5cf036d0 67
8b089c5e 68BEGIN_EVENT_TABLE( ScanCodeCtrl, wxTextCtrl )
5cf036d0
DS
69 EVT_CHAR( ScanCodeCtrl::OnChar )
70 EVT_KEY_DOWN( ScanCodeCtrl::OnKeyDown )
8b089c5e
JS
71END_EVENT_TABLE()
72
73ScanCodeCtrl::ScanCodeCtrl( wxWindow* parent, wxWindowID id, int code,
5cf036d0
DS
74 const wxPoint& pos, const wxSize& size )
75 : wxTextCtrl( parent, id, wxEmptyString, pos, size )
76{
77 SetValue( wxString::Format(wxT("0x%04x"), code) );
8b089c5e
JS
78}
79
80void ScanCodeCtrl::OnKeyDown( wxKeyEvent& event )
2db98bf5 81{
5cf036d0 82 SetValue( wxString::Format(wxT("0x%04x"), event.GetKeyCode()) );
8b089c5e
JS
83}
84
85/*------------------------------------------------------------------
86 Dialog for defining a keypress
87-------------------------------------------------------------------*/
88
89class ScanCodeDialog : public wxDialog
90{
91public:
5cf036d0
DS
92 ScanCodeDialog( wxWindow* parent, wxWindowID id, const int code,
93 const wxString &descr, const wxString& title );
94 int GetValue();
95
8b089c5e 96private:
5cf036d0
DS
97
98 ScanCodeCtrl *m_ScanCode;
99 wxTextCtrl *m_Description;
8b089c5e
JS
100};
101
f4a7108f 102ScanCodeDialog::ScanCodeDialog( wxWindow* parent, wxWindowID id,
5cf036d0
DS
103 const int code, const wxString &descr, const wxString& title )
104 : wxDialog( parent, id, title, wxDefaultPosition, wxSize(96*2,76*2) )
8b089c5e 105{
5cf036d0
DS
106 new wxStaticText( this, wxID_ANY, _T("Scancode"), wxPoint(4*2,3*2),
107 wxSize(31*2,12*2) );
108 m_ScanCode = new ScanCodeCtrl( this, wxID_ANY, code, wxPoint(37*2,6*2),
109 wxSize(53*2,14*2) );
110
111 new wxStaticText( this, wxID_ANY, _T("Description"), wxPoint(4*2,24*2),
112 wxSize(32*2,12*2) );
113 m_Description = new wxTextCtrl( this, wxID_ANY, descr, wxPoint(37*2,27*2),
114 wxSize(53*2,14*2) );
115
116 new wxButton( this, wxID_OK, _T("Ok"), wxPoint(20*2,50*2), wxSize(20*2,13*2) );
117 new wxButton( this, wxID_CANCEL, _T("Cancel"), wxPoint(44*2,50*2),
118 wxSize(25*2,13*2) );
8b089c5e
JS
119}
120
121int ScanCodeDialog::GetValue()
122{
5cf036d0
DS
123 int code;
124 wxString buf = m_ScanCode->GetValue();
125 wxSscanf( buf.c_str(), _T("%i"), &code );
126 return code;
8b089c5e
JS
127}
128
129/*----------------------------------------------------------------------
130 Utility function to get the elapsed time (in msec) since a given point
f4a7108f
VZ
131