Applied patch [ 802596 ] warning and error free Open GL samples

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@23491 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Julian Smart
2003-09-11 07:20:55 +00:00
parent 5f58391f70
commit 2db98bf520
8 changed files with 127 additions and 70 deletions

View File

@@ -27,10 +27,6 @@
#include "wx/log.h"
#if !wxUSE_GLCANVAS
#error Please set wxUSE_GLCANVAS to 1 in setup.h.
#endif
#include "cube.h"
#ifndef __WXMSW__ // for wxStopWatch, see remark below
@@ -70,15 +66,16 @@ END_EVENT_TABLE()
ScanCodeCtrl::ScanCodeCtrl( wxWindow* parent, wxWindowID id, int code,
const wxPoint& pos, const wxSize& size )
: wxTextCtrl( parent, id, "", pos, size )
: wxTextCtrl( parent, id, wxEmptyString, pos, size )
{ wxString buf;
buf.Printf( "0x%04x", code );
buf.Printf( _T("0x%04x"), code );
SetValue( buf );
}
void ScanCodeCtrl::OnKeyDown( wxKeyEvent& event )
{ wxString buf;
buf.Printf( "0x%04x", event.GetKeyCode() );
{
wxString buf;
buf.Printf( _T("0x%04x"), event.GetKeyCode() );
SetValue( buf );
}
@@ -101,18 +98,18 @@ ScanCodeDialog::ScanCodeDialog( wxWindow* parent, wxWindowID id,
const int code, const wxString &descr, const wxString& title )
: wxDialog( parent, id, title, wxPoint(-1, -1), wxSize(96*2,76*2) )
{
new wxStaticText( this, -1, "Scancode", wxPoint(4*2,3*2),
new wxStaticText( this, -1, _T("Scancode"), wxPoint(4*2,3*2),
wxSize(31*2,12*2) );
m_ScanCode = new ScanCodeCtrl( this, -1, code, wxPoint(37*2,6*2),
wxSize(53*2,14*2) );
new wxStaticText( this, -1, "Description", wxPoint(4*2,24*2),
new wxStaticText( this, -1, _T("Description"), wxPoint(4*2,24*2),
wxSize(32*2,12*2) );
m_Description = new wxTextCtrl( this, -1, descr, wxPoint(37*2,27*2),
wxSize(53*2,14*2) );
new wxButton( this, wxID_OK, "Ok", wxPoint(20*2,50*2), wxSize(20*2,13*2) );
new wxButton( this, wxID_CANCEL, "Cancel", wxPoint(44*2,50*2),
new wxButton( this, wxID_OK, _T("Ok"), wxPoint(20*2,50*2), wxSize(20*2,13*2) );
new wxButton( this, wxID_CANCEL, _T("Cancel"), wxPoint(44*2,50*2),
wxSize(25*2,13*2) );
}
@@ -120,7 +117,7 @@ int ScanCodeDialog::GetValue()
{
int code;
wxString buf = m_ScanCode->GetValue();
sscanf( buf.c_str(), "%i", &code );
wxSscanf( buf.c_str(), _T("%i"), &code );
return( code );
}
@@ -160,6 +157,8 @@ unsigned long wxStopWatch( unsigned long *sec_base )
Implementation of Test-GLCanvas
-----------------------------------------------------------------*/
#if wxUSE_GLCANVAS
BEGIN_EVENT_TABLE(TestGLCanvas, wxGLCanvas)
EVT_SIZE(TestGLCanvas::OnSize)
EVT_PAINT(TestGLCanvas::OnPaint)
@@ -263,12 +262,12 @@ void TestGLCanvas::Render()
SwapBuffers();
}
void TestGLCanvas::OnEnterWindow( wxMouseEvent& event )
void TestGLCanvas::OnEnterWindow( wxMouseEvent& WXUNUSED(event) )
{
SetFocus();
}
void TestGLCanvas::OnPaint( wxPaintEvent& event )
void TestGLCanvas::OnPaint( wxPaintEvent& WXUNUSED(event) )
{
Render();
}
@@ -290,7 +289,7 @@ void TestGLCanvas::OnSize(wxSizeEvent& event)
}
}
void TestGLCanvas::OnEraseBackground(wxEraseEvent& event)
void TestGLCanvas::OnEraseBackground(wxEraseEvent& WXUNUSED(event))
{
// Do nothing, to avoid flashing.
}
@@ -415,6 +414,8 @@ void TestGLCanvas::Rotate( GLfloat deg )
}
#endif // wxUSE_GLCANVAS
/* -----------------------------------------------------------------------
Main Window
-------------------------------------------------------------------------*/
@@ -435,57 +436,64 @@ MyFrame::MyFrame(wxFrame *frame, const wxString& title, const wxPoint& pos,
}
// Intercept menu commands
void MyFrame::OnExit(wxCommandEvent& event)
void MyFrame::OnExit(wxCommandEvent& WXUNUSED(event))
{
Destroy();
}
void MyFrame::OnNewWindow(wxCommandEvent& event)
void MyFrame::OnNewWindow(wxCommandEvent& WXUNUSED(event))
{
MyFrame *frame = new MyFrame(NULL, "Cube OpenGL Demo Clone",
MyFrame *frame = new MyFrame(NULL, _T("Cube OpenGL Demo Clone"),
wxPoint(50, 50), wxSize(400, 300));
// Give it an icon
#ifdef __WXMSW__
frame->SetIcon(wxIcon("mondrian"));
frame->SetIcon(wxIcon(_T("mondrian")));
#endif
// Make a menubar
wxMenu *winMenu = new wxMenu;
winMenu->Append(wxID_EXIT, "&Close");
winMenu->Append(ID_NEW_WINDOW, "&New" );
winMenu->Append(wxID_EXIT, _T("&Close"));
winMenu->Append(ID_NEW_WINDOW, _T("&New") );
wxMenuBar *menuBar = new wxMenuBar;
menuBar->Append(winMenu, "&Window");
menuBar->Append(winMenu, _T("&Window"));
winMenu = new wxMenu;
winMenu->Append(ID_DEF_ROTATE_LEFT_KEY, "Rotate &left");
winMenu->Append(ID_DEF_ROTATE_RIGHT_KEY, "Rotate &right");
menuBar->Append(winMenu, "&Key");
winMenu->Append(ID_DEF_ROTATE_LEFT_KEY, _T("Rotate &left"));
winMenu->Append(ID_DEF_ROTATE_RIGHT_KEY, _T("Rotate &right"));
menuBar->Append(winMenu, _T("&Key"));
frame->SetMenuBar(menuBar);
#if wxUSE_GLCANVAS
frame->m_canvas = new TestGLCanvas( frame, *m_canvas, -1,
wxDefaultPosition, wxDefaultSize );
#endif
// Show the frame
frame->Show(TRUE);
}
void MyFrame::OnDefRotateLeftKey(wxCommandEvent& event)
void MyFrame::OnDefRotateLeftKey(wxCommandEvent& WXUNUSED(event))
{
#if wxUSE_GLCANVAS
ScanCodeDialog dial( this, -1, m_canvas->m_rleft,
wxString("Left"), "Define key" );
wxString(_T("Left")), _T("Define key") );
int result = dial.ShowModal();
if( result == wxID_OK )
m_canvas->m_rleft = dial.GetValue();
#endif
}
void MyFrame::OnDefRotateRightKey(wxCommandEvent& event)
void MyFrame::OnDefRotateRightKey(wxCommandEvent& WXUNUSED(event))
{
#if wxUSE_GLCANVAS
ScanCodeDialog dial( this, -1, m_canvas->m_rright,
wxString("Right"), "Define key" );
wxString(_T("Right")), _T("Define key") );
int result = dial.ShowModal();
if( result == wxID_OK )
m_canvas->m_rright = dial.GetValue();
#endif
}
/*------------------------------------------------------------------
@@ -499,7 +507,7 @@ bool MyApp::OnInit(void)
wxLog::SetTraceMask(wxTraceMessages);
// Create the main frame window
MyFrame *frame = new MyFrame(NULL, "Cube OpenGL Demo", wxPoint(50, 50),
MyFrame *frame = new MyFrame(NULL, _T("Cube OpenGL Demo"), wxPoint(50, 50),
wxSize(400, 300));
// Give it an icon
#ifdef wx_msw
@@ -509,22 +517,33 @@ bool MyApp::OnInit(void)
// Make a menubar
wxMenu *winMenu = new wxMenu;
winMenu->Append(wxID_EXIT, "&Close");
winMenu->Append(ID_NEW_WINDOW, "&New" );
winMenu->Append(wxID_EXIT, _T("&Close"));
winMenu->Append(ID_NEW_WINDOW, _T("&New") );
wxMenuBar *menuBar = new wxMenuBar;
menuBar->Append(winMenu, "&Window");
menuBar->Append(winMenu, _T("&Window"));
winMenu = new wxMenu;
winMenu->Append(ID_DEF_ROTATE_LEFT_KEY, "Rotate &left");
winMenu->Append(ID_DEF_ROTATE_RIGHT_KEY, "Rotate &right");
menuBar->Append(winMenu, "&Key");
winMenu->Append(ID_DEF_ROTATE_LEFT_KEY, _T("Rotate &left"));
winMenu->Append(ID_DEF_ROTATE_RIGHT_KEY, _T("Rotate &right"));
menuBar->Append(winMenu, _T("&Key"));
frame->SetMenuBar(menuBar);
#if wxUSE_GLCANVAS
frame->m_canvas = new TestGLCanvas(frame, -1, wxDefaultPosition, wxDefaultSize);
// Show the frame
frame->Show(TRUE);
return TRUE;
#else
wxMessageBox( _T("This sample has to be compiled with wxUSE_GLCANVAS"), _T("Building error"), wxOK);
return FALSE;
#endif
}

View File

@@ -40,17 +40,19 @@ public:
DECLARE_EVENT_TABLE()
};
#if wxUSE_GLCANVAS
class TestGLCanvas: public wxGLCanvas
{
friend class MyFrame;
public:
TestGLCanvas(wxWindow *parent, const wxWindowID id = -1,
const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize,
long style = 0, const wxString& name = "TestGLCanvas");
long style = 0, const wxString& name = _T("TestGLCanvas"));
TestGLCanvas(wxWindow *parent, const TestGLCanvas &other,
const wxWindowID id = -1, const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize, long style = 0,
const wxString& name = "TestGLCanvas" );
const wxString& name = _T("TestGLCanvas") );
~TestGLCanvas(void);
@@ -91,3 +93,5 @@ DECLARE_EVENT_TABLE()
#endif
#endif

View File

@@ -25,10 +25,6 @@
#include "wx/wx.h"
#endif
#if !wxUSE_GLCANVAS
#error Please set wxUSE_GLCANVAS to 1 in setup.h.
#endif
#include "wx/timer.h"
#include "wx/glcanvas.h"
@@ -76,13 +72,13 @@ static GLfloat xrot;
static GLfloat yrot;
static void read_surface( char *filename )
static void read_surface( wxChar *filename )
{
FILE *f;
f = fopen(filename,"r");
f = wxFopen(filename,_T("r"));
if (!f) {
wxString msg("Couldn't read ");
wxString msg(_T("Couldn't read "));
msg += filename;
wxMessageBox(msg);
return;
@@ -97,7 +93,7 @@ static void read_surface( char *filename )
}
numverts--;
printf("%d vertices, %d triangles\n", numverts, numverts-2);
wxPrintf(_T("%d vertices, %d triangles\n"), numverts, numverts-2);
fclose(f);
}
@@ -203,26 +199,26 @@ static void Init(void)
#endif
}
static GLenum Args(int argc, char **argv)
static GLenum Args(int argc, wxChar **argv)
{
GLint i;
for (i = 1; i < argc; i++) {
if (strcmp(argv[i], "-sb") == 0) {
if (wxStrcmp(argv[i], _T("-sb")) == 0) {
doubleBuffer = GL_FALSE;
}
else if (strcmp(argv[i], "-db") == 0) {
else if (wxStrcmp(argv[i], _T("-db")) == 0) {
doubleBuffer = GL_TRUE;
}
else if (strcmp(argv[i], "-speed") == 0) {
else if (wxStrcmp(argv[i], _T("-speed")) == 0) {
speed_test = GL_TRUE;
doubleBuffer = GL_TRUE;
}
else if (strcmp(argv[i], "-va") == 0) {
else if (wxStrcmp(argv[i], _T("-va")) == 0) {
use_vertex_arrays = GL_TRUE;
}
else {
wxString msg("Bad option: ");
wxString msg(_T("Bad option: "));
msg += argv[i];
wxMessageBox(msg);
return GL_FALSE;
@@ -243,17 +239,17 @@ bool MyApp::OnInit(void)
Args(argc, argv);
// Create the main frame window
frame = new MyFrame(NULL, "Isosurf GL Sample", wxPoint(50, 50), wxSize(200, 200));
frame = new MyFrame(NULL, _T("Isosurf GL Sample"), wxPoint(50, 50), wxSize(200, 200));
// Give it an icon
frame->SetIcon(wxIcon("mondrian"));
frame->SetIcon(wxIcon(_T("mondrian")));
// Make a menubar
wxMenu *fileMenu = new wxMenu;
fileMenu->Append(wxID_EXIT, "E&xit");
fileMenu->Append(wxID_EXIT, _T("E&xit"));
wxMenuBar *menuBar = new wxMenuBar;
menuBar->Append(fileMenu, "&File");
menuBar->Append(fileMenu, _T("&File"));
frame->SetMenuBar(menuBar);
// Make a TestGLCanvas
@@ -281,18 +277,27 @@ bool MyApp::OnInit(void)
doubleBuffer = GL_FALSE;
}
#if wxUSE_GLCANVAS
frame->m_canvas = new TestGLCanvas(frame, -1, wxDefaultPosition, wxDefaultSize,
0, "TestGLCanvas", gl_attrib );
0, _T("TestGLCanvas"), gl_attrib );
// Show the frame
frame->Show(TRUE);
frame->m_canvas->SetCurrent();
read_surface( "isosurf.dat" );
read_surface( _T("isosurf.dat") );
Init();
return TRUE;
#else
wxMessageBox( _T("This sample has to be compiled with wxUSE_GLCANVAS"), _T("Building error"), wxOK);
return FALSE;
#endif
}
BEGIN_EVENT_TABLE(MyFrame, wxFrame)
@@ -304,11 +309,13 @@ MyFrame::MyFrame(wxFrame *frame, const wxString& title, const wxPoint& pos,
const wxSize& size, long style):
wxFrame(frame, -1, title, pos, size, style)
{
#if wxUSE_GLCANVAS
m_canvas = NULL;
#endif
}
// Intercept menu commands
void MyFrame::OnExit(wxCommandEvent& event)
void MyFrame::OnExit(wxCommandEvent& WXUNUSED(event))
{
Destroy();
}
@@ -317,6 +324,8 @@ void MyFrame::OnExit(wxCommandEvent& event)
* TestGLCanvas implementation
*/
#if wxUSE_GLCANVAS
BEGIN_EVENT_TABLE(TestGLCanvas, wxGLCanvas)
EVT_SIZE(TestGLCanvas::OnSize)
EVT_PAINT(TestGLCanvas::OnPaint)
@@ -344,7 +353,7 @@ TestGLCanvas::~TestGLCanvas(void)
{
}
void TestGLCanvas::OnPaint( wxPaintEvent& event )
void TestGLCanvas::OnPaint( wxPaintEvent& WXUNUSED(event) )
{
// This is a dummy, to avoid an endless succession of paint messages.
// OnPaint handlers must always create a wxPaintDC.
@@ -440,8 +449,9 @@ void TestGLCanvas::OnMouseEvent(wxMouseEvent& event)
dragging = 0;
}
void TestGLCanvas::OnEraseBackground(wxEraseEvent& event)
void TestGLCanvas::OnEraseBackground(wxEraseEvent& WXUNUSED(event))
{
// Do nothing, to avoid flashing.
}
#endif

View File

@@ -18,11 +18,12 @@ class MyApp: public wxApp
bool OnInit(void);
};
#if wxUSE_GLCANVAS
class TestGLCanvas: public wxGLCanvas
{
public:
TestGLCanvas(wxWindow *parent, const wxWindowID id = -1, const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize, long style = 0, const wxString& name = "TestGLCanvas",
const wxSize& size = wxDefaultSize, long style = 0, const wxString& name = _T("TestGLCanvas"),
int* gl_attrib = NULL);
~TestGLCanvas(void);
@@ -34,6 +35,7 @@ class TestGLCanvas: public wxGLCanvas
DECLARE_EVENT_TABLE()
};
#endif
class MyFrame: public wxFrame
{
@@ -43,7 +45,9 @@ public:
void OnExit(wxCommandEvent& event);
public:
#if wxUSE_GLCANVAS
TestGLCanvas* m_canvas;
#endif
DECLARE_EVENT_TABLE()
};

View File

@@ -36,6 +36,8 @@
#include <stdio.h>
#include <math.h>
#if wxUSE_GLCANVAS
#define MK_ID(a,b,c,d) ((((wxUint32)(a))<<24)| \
(((wxUint32)(b))<<16)| \
(((wxUint32)(c))<< 8)| \
@@ -435,4 +437,5 @@ void lw_object_scale(lwObject *lwo, GLfloat scale)
}
}
#endif

View File

@@ -61,6 +61,7 @@ typedef struct {
extern "C" {
#endif
#if wxUSE_GLCANVAS
int lw_is_lwobject(const char *lw_file);
lwObject *lw_object_read(const char *lw_file);
void lw_object_free( lwObject *lw_object);
@@ -68,6 +69,7 @@ void lw_object_show(const lwObject *lw_object);
GLfloat lw_object_radius(const lwObject *lw_object);
void lw_object_scale (lwObject *lw_object, GLfloat scale);
#endif
#ifdef __cplusplus
}

View File

@@ -25,10 +25,6 @@
#include "wx/wx.h"
#endif
#if !wxUSE_GLCANVAS
#error Please set wxUSE_GLCANVAS to 1 in setup.h.
#endif
#include "penguin.h"
#ifdef __WXMAC__
# ifdef __DARWIN__
@@ -57,6 +53,7 @@ bool MyApp::OnInit()
menuBar->Append(fileMenu, wxT("&File"));
frame->SetMenuBar(menuBar);
#if wxUSE_GLCANVAS
frame->SetCanvas( new TestGLCanvas(frame, -1, wxPoint(0, 0), wxSize(200, 200), wxSUNKEN_BORDER) );
/* Load file wiht mesh data */
@@ -66,6 +63,13 @@ bool MyApp::OnInit()
frame->Show(TRUE);
return TRUE;
#else
wxMessageBox( _T("This sample has to be compiled with wxUSE_GLCANVAS"), _T("Building error"), wxOK);
return FALSE;
#endif
}
IMPLEMENT_APP(MyApp)
@@ -79,15 +83,19 @@ MyFrame::MyFrame(wxFrame *frame, const wxString& title, const wxPoint& pos,
const wxSize& size, long style):
wxFrame(frame, -1, title, pos, size, style)
{
#if wxUSE_GLCANVAS
m_canvas = NULL;
#endif
}
/* Intercept menu commands */
void MyFrame::OnExit(wxCommandEvent& event)
void MyFrame::OnExit(wxCommandEvent& WXUNUSED(event))
{
Destroy();
}
#if wxUSE_GLCANVAS
BEGIN_EVENT_TABLE(TestGLCanvas, wxGLCanvas)
EVT_SIZE(TestGLCanvas::OnSize)
EVT_PAINT(TestGLCanvas::OnPaint)
@@ -108,7 +116,7 @@ TestGLCanvas::~TestGLCanvas(void)
lw_object_free(info.lwobject);
}
void TestGLCanvas::OnPaint( wxPaintEvent& event )
void TestGLCanvas::OnPaint( wxPaintEvent& WXUNUSED(event) )
{
/* must always be here */
wxPaintDC dc(this);
@@ -170,7 +178,7 @@ void TestGLCanvas::OnSize(wxSizeEvent& event)
}
}
void TestGLCanvas::OnEraseBackground(wxEraseEvent& event)
void TestGLCanvas::OnEraseBackground(wxEraseEvent& WXUNUSED(event))
{
/* Do nothing, to avoid flashing on MSW */
}
@@ -249,3 +257,4 @@ void TestGLCanvas::InitGL(void)
}
#endif

View File

@@ -55,15 +55,19 @@ public:
void OnExit(wxCommandEvent& event);
#if wxUSE_GLCANVAS
void SetCanvas( TestGLCanvas *canvas ) { m_canvas = canvas; }
TestGLCanvas *GetCanvas() { return m_canvas; }
private:
TestGLCanvas* m_canvas;
#endif
DECLARE_EVENT_TABLE()
};
#if wxUSE_GLCANVAS
class TestGLCanvas: public wxGLCanvas
{
public:
@@ -87,3 +91,5 @@ private:
#endif
#endif