99
108
static const int kTimerFreq = 10;
101
110
GPG_Application::GPG_Application(GHOST_ISystem* system, struct Main *maggie, STR_String startSceneName)
102
: m_maggie(maggie), m_startSceneName(startSceneName), m_exitRequested(0),
103
m_system(system), m_mainWindow(0), m_frameTimer(0), m_cursor(GHOST_kStandardCursorFirstCursor),
104
m_mouse(0), m_keyboard(0), m_rasterizer(0), m_canvas(0), m_rendertools(0), m_kxsystem(0), m_networkdevice(0), m_audiodevice(0), m_sceneconverter(0),
105
m_engineInitialized(0), m_engineRunning(0), m_ketsjiengine(0)
111
: m_startSceneName(startSceneName),
117
m_cursor(GHOST_kStandardCursorFirstCursor),
118
m_engineInitialized(0),
107
131
fSystem = system;
160
#define SCR_SAVE_MOUSE_MOVE_THRESHOLD 15
162
static HWND found_ghost_window_hwnd;
163
static GHOST_IWindow* ghost_window_to_find;
164
static WNDPROC ghost_wnd_proc;
165
static POINT scr_save_mouse_pos;
167
static LRESULT CALLBACK screenSaverWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
176
LONG dx = scr_save_mouse_pos.x - pt.x;
177
LONG dy = scr_save_mouse_pos.y - pt.y;
178
if (abs(dx) > SCR_SAVE_MOUSE_MOVE_THRESHOLD
179
|| abs(dy) > SCR_SAVE_MOUSE_MOVE_THRESHOLD)
183
scr_save_mouse_pos = pt;
193
PostMessage(hwnd,WM_CLOSE,0,0);
194
return CallWindowProc(ghost_wnd_proc, hwnd, uMsg, wParam, lParam);
197
BOOL CALLBACK findGhostWindowHWNDProc(HWND hwnd, LPARAM lParam)
199
GHOST_IWindow *p = (GHOST_IWindow*) GetWindowLong(hwnd, GWL_USERDATA);
201
if (p == ghost_window_to_find)
203
found_ghost_window_hwnd = hwnd;
209
static HWND findGhostWindowHWND(GHOST_IWindow* window)
211
found_ghost_window_hwnd = NULL;
212
ghost_window_to_find = window;
213
EnumWindows(findGhostWindowHWNDProc, NULL);
214
return found_ghost_window_hwnd;
217
bool GPG_Application::startScreenSaverPreview(
219
const bool stereoVisual,
220
const int stereoMode)
222
bool success = false;
225
if (GetWindowRect(parentWindow, &rc))
227
int windowWidth = rc.right - rc.left;
228
int windowHeight = rc.bottom - rc.top;
229
STR_String title = "";
231
m_mainWindow = fSystem->createWindow(title, 0, 0, windowWidth, windowHeight, GHOST_kWindowStateMinimized,
232
GHOST_kDrawingContextTypeOpenGL, stereoVisual);
234
printf("error: could not create main window\n");
238
HWND ghost_hwnd = findGhostWindowHWND(m_mainWindow);
240
printf("error: could find main window\n");
244
SetParent(ghost_hwnd, parentWindow);
245
LONG style = GetWindowLong(ghost_hwnd, GWL_STYLE);
246
LONG exstyle = GetWindowLong(ghost_hwnd, GWL_EXSTYLE);
248
RECT adjrc = { 0, 0, windowWidth, windowHeight };
249
AdjustWindowRectEx(&adjrc, style, FALSE, exstyle);
251
style = (style & (~(WS_POPUP|WS_OVERLAPPEDWINDOW|WS_OVERLAPPED|WS_CAPTION|WS_SYSMENU|WS_THICKFRAME|WS_MINIMIZEBOX|WS_MAXIMIZEBOX|WS_TILEDWINDOW ))) | WS_CHILD;
252
SetWindowLong(ghost_hwnd, GWL_STYLE, style);
253
SetWindowPos(ghost_hwnd, NULL, adjrc.left, adjrc.top, 0, 0, SWP_NOZORDER|SWP_NOSIZE|SWP_NOACTIVATE);
255
/* Check the size of the client rectangle of the window and resize the window
256
* so that the client rectangle has the size requested.
258
m_mainWindow->setClientSize(windowWidth, windowHeight);
260
success = initEngine(m_mainWindow, stereoMode);
262
success = startEngine();
269
bool GPG_Application::startScreenSaverFullScreen(
272
int bpp,int frequency,
273
const bool stereoVisual,
274
const int stereoMode)
276
bool ret = startFullScreen(width, height, bpp, frequency, stereoVisual, stereoMode);
279
HWND ghost_hwnd = findGhostWindowHWND(m_mainWindow);
280
if (ghost_hwnd != NULL)
282
GetCursorPos(&scr_save_mouse_pos);
283
ghost_wnd_proc = (WNDPROC) GetWindowLong(ghost_hwnd, GWL_WNDPROC);
284
SetWindowLong(ghost_hwnd,GWL_WNDPROC, (LONG) screenSaverWindowProc);
136
292
bool GPG_Application::startWindow(STR_String& title,
329
485
// SYS_WriteCommandLineInt(syshandle, "fixedtime", 0);
330
SYS_WriteCommandLineInt(syshandle, "vertexarrays",1);
331
//bool properties = (SYS_GetCommandLineInt(syshandle, "show_properties", 0) != 0);
332
//bool profile = (SYS_GetCommandLineInt(syshandle, "show_profile", 0) != 0);
486
// SYS_WriteCommandLineInt(syshandle, "vertexarrays",1);
487
bool properties = (SYS_GetCommandLineInt(syshandle, "show_properties", 0) != 0);
488
bool profile = (SYS_GetCommandLineInt(syshandle, "show_profile", 0) != 0);
333
489
bool frameRate = (SYS_GetCommandLineInt(syshandle, "show_framerate", 0) != 0);
334
490
bool useVertexArrays = SYS_GetCommandLineInt(syshandle,"vertexarrays",1) != 0;
335
491
// create the canvas, rasterizer and rendertools