1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
|
Index: source/g3d_viewer/main.cpp
===================================================================
--- source/g3d_viewer/main.cpp (Revision 191)
+++ source/g3d_viewer/main.cpp (Arbeitskopie)
@@ -2,7 +2,6 @@
#include <stdexcept>
-#include "graphics_factory_basic_gl.h"
#include "graphics_interface.h"
#include "util.h"
@@ -11,8 +10,15 @@
using namespace Shared::Graphics::Gl;
using namespace Shared::Util;
-using namespace std;
+using std::exception;
+#if (wxUSE_UNICODE == 1)
+#define STRCONV(x) wxConvUTF8.cMB2WC(x)
+#else
+#define STRCONV(x) x
+#endif
+
+
namespace Shared{ namespace G3dViewer{
// ===============================================
@@ -24,7 +30,7 @@
MainWindow::MainWindow(const string &modelPath):
wxFrame(
- NULL, -1, winHeader.c_str(),
+ NULL, -1, STRCONV(winHeader.c_str()),
wxPoint(Renderer::windowX, Renderer::windowY),
wxSize(Renderer::windowW, Renderer::windowH))
{
@@ -37,38 +43,33 @@
glCanvas = new GlCanvas(this);
- glCanvas->SetCurrent();
-
- renderer->init();
-
-
menu= new wxMenuBar();
//menu
menuFile= new wxMenu();
- menuFile->Append(miFileLoad, "Load");
- menu->Append(menuFile, "File");
+ menuFile->Append(miFileLoad, wxT("Load"));
+ menu->Append(menuFile, wxT("File"));
//mode
menuMode= new wxMenu();
- menuMode->AppendCheckItem(miModeNormals, "Normals");
- menuMode->AppendCheckItem(miModeWireframe, "Wireframe");
- menuMode->AppendCheckItem(miModeGrid, "Grid");
- menu->Append(menuMode, "Mode");
+ menuMode->AppendCheckItem(miModeNormals, wxT("Normals"));
+ menuMode->AppendCheckItem(miModeWireframe, wxT("Wireframe"));
+ menuMode->AppendCheckItem(miModeGrid, wxT("Grid"));
+ menu->Append(menuMode, wxT("Mode"));
//mode
menuSpeed= new wxMenu();
- menuSpeed->Append(miSpeedSlower, "Slower");
- menuSpeed->Append(miSpeedFaster, "Faster");
- menu->Append(menuSpeed, "Speed");
+ menuSpeed->Append(miSpeedSlower, wxT("Slower"));
+ menuSpeed->Append(miSpeedFaster, wxT("Faster"));
+ menu->Append(menuSpeed, wxT("Speed"));
//custom color
menuCustomColor= new wxMenu();
- menuCustomColor->AppendCheckItem(miColorRed, "Red");
- menuCustomColor->AppendCheckItem(miColorBlue, "Blue");
- menuCustomColor->AppendCheckItem(miColorYellow, "Yellow");
- menuCustomColor->AppendCheckItem(miColorGreen, "Green");
- menu->Append(menuCustomColor, "Custom Color");
+ menuCustomColor->AppendCheckItem(miColorRed, wxT("Red"));
+ menuCustomColor->AppendCheckItem(miColorBlue, wxT("Blue"));
+ menuCustomColor->AppendCheckItem(miColorYellow, wxT("Yellow"));
+ menuCustomColor->AppendCheckItem(miColorGreen, wxT("Green"));
+ menu->Append(menuCustomColor, wxT("Custom Color"));
menuMode->Check(miModeGrid, true);
menuCustomColor->Check(miColorRed, true);
@@ -88,13 +89,6 @@
timer = new wxTimer(this);
timer->Start(40);
-
- if(!modelPath.empty()){
- Model *tmpModel= new ModelGl();
- renderer->loadTheModel(tmpModel, modelPath);
- model= tmpModel;
- GetStatusBar()->SetStatusText(getModelInfo().c_str());
- }
}
MainWindow::~MainWindow(){
@@ -104,6 +98,17 @@
delete glCanvas;
}
+void MainWindow::init(){
+ glCanvas->SetCurrent();
+ renderer->init();
+ if(!modelPath.empty()){
+ Model *tmpModel= new ModelGl();
+ renderer->loadTheModel(tmpModel, modelPath);
+ model= tmpModel;
+ GetStatusBar()->SetStatusText(STRCONV(getModelInfo().c_str()));
+ }
+}
+
void MainWindow::onPaint(wxPaintEvent &event){
renderer->reset(GetClientSize().x, GetClientSize().y, playerColor);
renderer->transform(rotX, rotY, zoom);
@@ -141,13 +146,14 @@
void MainWindow::onMenuFileLoad(wxCommandEvent &event){
string fileName;
wxFileDialog fileDialog(this);
- fileDialog.SetWildcard("G3D files (*.g3d)|*.g3d");
+ fileDialog.SetWildcard(wxT("G3D files (*.g3d)|*.g3d"));
if(fileDialog.ShowModal()==wxID_OK){
delete model;
Model *tmpModel= new ModelGl();
- renderer->loadTheModel(tmpModel, fileDialog.GetPath().c_str());
+ fileName = wxFNCONV(fileDialog.GetPath());
+ renderer->loadTheModel(tmpModel, fileName);
model= tmpModel;
- GetStatusBar()->SetStatusText(getModelInfo().c_str());
+ GetStatusBar()->SetStatusText(wxString(getModelInfo().c_str(), wxConvUTF8));
}
}
@@ -252,7 +258,7 @@
// =====================================================
GlCanvas::GlCanvas(MainWindow * mainWindow):
- wxGLCanvas(mainWindow, -1)
+ wxGLCanvas(mainWindow, -1, wxDefaultPosition)
{
this->mainWindow = mainWindow;
}
@@ -261,13 +267,8 @@
mainWindow->onMouseMove(event);
}
-void GlCanvas::onPaint(wxPaintEvent &event){
- mainWindow->onPaint(event);
-}
-
BEGIN_EVENT_TABLE(GlCanvas, wxGLCanvas)
EVT_MOTION(GlCanvas::onMouseMove)
- EVT_PAINT(GlCanvas::onPaint)
END_EVENT_TABLE()
// ===============================================
@@ -277,11 +278,12 @@
bool App::OnInit(){
string modelPath;
if(argc==2){
- modelPath= argv[1];
+ modelPath = wxFNCONV(argv[1]);
}
mainWindow= new MainWindow(modelPath);
mainWindow->Show();
+ mainWindow->init();
return true;
}
@@ -290,9 +292,9 @@
return wxApp::MainLoop();
}
catch(const exception &e){
- wxMessageDialog(NULL, e.what(), "Exception", wxOK | wxICON_ERROR).ShowModal();
- return 0;
+ wxMessageDialog(NULL, STRCONV(e.what()), wxT("Exception"), wxOK | wxICON_ERROR).ShowModal();
}
+ return 0;
}
int App::OnExit(){
Index: source/g3d_viewer/main.h
===================================================================
--- source/g3d_viewer/main.h (Revision 191)
+++ source/g3d_viewer/main.h (Arbeitskopie)
@@ -7,12 +7,13 @@
#include <wx/timer.h>
#include <wx/glcanvas.h>
+#include "graphics_factory_basic_gl.h"
#include "renderer.h"
#include "util.h"
#include "window.h"
-using Shared::Platform::Window;
-using Shared::Platform::MouseState;
+//using Shared::Platform::Window;
+//using Shared::Platform::MouseState;
using std::string;
@@ -70,6 +71,8 @@
MainWindow(const string &modelPath);
~MainWindow();
+ void init();
+
void Notify();
void onPaint(wxPaintEvent &event);
Index: mk/linux/Jamfile
===================================================================
--- mk/linux/Jamfile (Revision 191)
+++ mk/linux/Jamfile (Arbeitskopie)
@@ -26,7 +26,7 @@
}
Library glestlib : $(LIB_SOURCES) ;
-ExternalLibs glestlib : SDL GL GLU XERCES VORBIS VORBISFILE OGG OPENAL LUA ;
+ExternalLibs glestlib : SDL GL GLU XERCES VORBISFILE OPENAL LUA ;
IncludeDir glestlib : $(LIB_INCLUDE_DIRS) ;
#### Game ####
@@ -55,7 +55,7 @@
Application glest : $(GLEST_SOURCES) ;
LinkWith glest : glestlib ;
-ExternalLibs glest : SDL GL GLU XERCES VORBIS VORBISFILE OGG OPENAL LUA ;
+ExternalLibs glest : SDL GL GLU XERCES VORBISFILE OPENAL LUA ;
IncludeDir glest : ../shared_lib/include/$(LIB_INCLUDE_DIRS) $(GLEST_DIRS) ;
#### Editor ####
@@ -69,7 +69,22 @@
Application glest_editor : $(GLEST_MAP_SOURCES) ;
LinkWith glest_editor : glestlib ;
- ExternalLibs glest_editor : SDL GL GLU XERCES VORBIS VORBISFILE OGG OPENAL WX ;
+ ExternalLibs glest_editor : SDL GL GLU XERCES VORBISFILE OPENAL WX ;
IncludeDir glest_editor : ../shared_lib/include/$(LIB_INCLUDE_DIRS) $(GLEST_MAP_DIRS) ;
}
+### Viewer ###
+if $(WX_AVAILABLE) = "yes" {
+ SubDir TOP g3d_viewer ;
+
+ GLEST_VIEWER_DIRS = . ;
+ for i in $(GLEST_DIRS) {
+ GLEST_VIEWER_SOURCES += [ Wildcard $(i) : *.cpp *.h ] ;
+ }
+
+ Application glest_g3dviewer : $(GLEST_VIEWER_SOURCES) ;
+ LinkWith glest_g3dviewer : glestlib ;
+ ExternalLibs glest_g3dviewer : SDL GL GLU XERCES VORBISFILE OPENAL WX ;
+ IncludeDir glest_g3dviewer : ../shared_lib/include/$(LIB_INCLUDE_DIRS) $(GLEST_VIEWER_DIRS) ;
+}
+
Index: mk/linux/autogen.sh
===================================================================
--- mk/linux/autogen.sh (Revision 191)
+++ mk/linux/autogen.sh (Arbeitskopie)
@@ -34,4 +34,6 @@
if [ ! -d glest_map_editor ]; then
ln -sf ../../source/glest_map_editor .
fi
-
+if [ ! -d g3d_viewer ]; then
+ ln -sf ../../source/g3d_viewer .
+fi
|