]> git.saurik.com Git - wxWidgets.git/blame - samples/opengl/cube/cube.cpp
use specific linker flags under Mac OS X when linking executables against the
[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 301.
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
12#ifdef __GNUG__
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#include "wx/log.h"
29
5fa399c9
JS
30#if !wxUSE_GLCANVAS
31#error Please set wxUSE_GLCANVAS to 1 in setup.h.
32#endif
33
8b089c5e
JS
34#include "cube.h"
35
f4a7108f 36#ifndef __WXMSW__ // for wxStopWatch, see remark below
e195c8c9
GD
37 #if defined(__WXMAC__) && !defined(__DARWIN__)
38 #include <utime.h>
39 #include <unistd.h>
40 #else
41 #include <sys/time.h>
42 #include <sys/unistd.h>
43 #endif
8b089c5e
JS
44#else
45#include <sys/timeb.h>
46#endif
47
48#define ID_NEW_WINDOW 10000
49#define ID_DEF_ROTATE_LEFT_KEY 10001
50#define ID_DEF_ROTATE_RIGHT_KEY 10002
51
52/*----------------------------------------------------------
53 Control to get a keycode
54 ----------------------------------------------------------*/
55class ScanCodeCtrl : public wxTextCtrl
56{
57public:
58 ScanCodeCtrl( wxWindow* parent, wxWindowID id, int code,
59 const wxPoint& pos, const wxSize& size );
60 void OnChar( wxKeyEvent& event ) { } /* do nothing */
61 void OnKeyDown(wxKeyEvent& event);
62private:
63// any class wishing to process wxWindows events must use this macro
64 DECLARE_EVENT_TABLE()
65};
66BEGIN_EVENT_TABLE( ScanCodeCtrl, wxTextCtrl )
67 EVT_CHAR( ScanCodeCtrl::OnChar )
68 EVT_KEY_DOWN( ScanCodeCtrl::OnKeyDown )
69END_EVENT_TABLE()
70
71ScanCodeCtrl::ScanCodeCtrl( wxWindow* parent, wxWindowID id, int code,
72 const wxPoint& pos, const wxSize& size )
73 : wxTextCtrl( parent, id, "", pos, size )
74{ wxString buf;
75 buf.Printf( "0x%04x", code );
76 SetValue( buf );
77}
78
79void ScanCodeCtrl::OnKeyDown( wxKeyEvent& event )
80{ wxString buf;
81 buf.Printf( "0x%04x", event.KeyCode() );
82 SetValue( buf );
83}
84
85/*------------------------------------------------------------------
86 Dialog for defining a keypress
87-------------------------------------------------------------------*/
88
89class ScanCodeDialog : public wxDialog
90{
91public:
92 ScanCodeDialog( wxWindow* parent, wxWindowID id, const int code,
93 const wxString &descr, const wxString& title );
f4a7108f 94 int GetValue();
8b089c5e
JS
95private:
96 ScanCodeCtrl *m_ScanCode;
97 wxTextCtrl *m_Description;
98};
99
f4a7108f 100ScanCodeDialog::ScanCodeDialog( wxWindow* parent, wxWindowID id,
8b089c5e
JS
101 const int code, const wxString &descr, const wxString& title )
102 : wxDialog( parent, id, title, wxPoint(-1, -1), wxSize(96*2,76*2) )
103{
f4a7108f 104 new wxStaticText( this, -1, "Scancode", wxPoint(4*2,3*2),
8b089c5e 105 wxSize(31*2,12*2) );
f4a7108f 106 m_ScanCode = new ScanCodeCtrl( this, -1, code, wxPoint(37*2,6*2),
8b089c5e
JS
107 wxSize(53*2,14*2) );
108
109 new wxStaticText( this, -1, "Description", wxPoint(4*2,24*2),
110 wxSize(32*2,12*2) );
111 m_Description = new wxTextCtrl( this, -1, descr, wxPoint(37*2,27*2),
112 wxSize(53*2,14*2) );
113
114 new wxButton( this, wxID_OK, "Ok", wxPoint(20*2,50*2), wxSize(20*2,13*2) );
115 new wxButton( this, wxID_CANCEL, "Cancel", wxPoint(44*2,50*2),
116 wxSize(25*2,13*2) );
117}
118
119int ScanCodeDialog::GetValue()
120{
121 int code;
122 wxString buf = m_ScanCode->GetValue();
123 sscanf( buf.c_str(), "%i", &code );
124 return( code );
125}
126
127/*----------------------------------------------------------------------
128 Utility function to get the elapsed time (in msec) since a given point
f4a7108f
VZ
129