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