mirror of https://github.com/BOINC/boinc.git
parent
8a0feee2fc
commit
843aa91865
|
@ -55,7 +55,7 @@ MMRESULT timer_id;
|
|||
#include <gl\gl.h> // Header File For The OpenGL32 Library
|
||||
#include <gl\glu.h> // Header File For The GLu32 Library
|
||||
#include <gl\glaux.h> // Header File For The Glaux Library
|
||||
HANDLE hGlobalDrawEvent,hQuitEvent;
|
||||
HANDLE hDoneDrawingEvent,hQuitEvent, hGraphicsDrawEvent;
|
||||
extern HANDLE graphics_threadh;
|
||||
extern BOOL win_loop_done;
|
||||
#endif
|
||||
|
@ -311,11 +311,14 @@ bool boinc_time_to_checkpoint() {
|
|||
ok_to_draw = 1;
|
||||
// And wait for the graphics thread to notify us that it's done drawing
|
||||
#ifdef _WIN32
|
||||
ResetEvent(hGlobalDrawEvent);
|
||||
// Notify the graphics thread
|
||||
SetEvent(hGraphicsDrawEvent);
|
||||
// Reset the draw done event
|
||||
ResetEvent(hDoneDrawingEvent);
|
||||
while (ok_to_draw) {
|
||||
// Wait for drawing to finish. We don't do an infinite wait here to avoid the
|
||||
// possibility of deadlock (which was happening with an infinite wait value)
|
||||
WaitForSingleObject( hGlobalDrawEvent, 10 );
|
||||
WaitForSingleObject( hDoneDrawingEvent, 10 );
|
||||
}
|
||||
#endif _WIN32
|
||||
#ifdef __APPLE_CC__
|
||||
|
@ -516,7 +519,13 @@ int set_timer(double period) {
|
|||
#ifdef BOINC_APP_GRAPHICS
|
||||
// Create the event object used to signal between the
|
||||
// worker and event threads
|
||||
hGlobalDrawEvent = CreateEvent(
|
||||
hDoneDrawingEvent = CreateEvent(
|
||||
NULL, // no security attributes
|
||||
TRUE, // manual reset event
|
||||
TRUE, // initial state is signaled
|
||||
NULL); // object not named
|
||||
|
||||
hGraphicsDrawEvent = CreateEvent(
|
||||
NULL, // no security attributes
|
||||
TRUE, // manual reset event
|
||||
TRUE, // initial state is signaled
|
||||
|
|
|
@ -53,7 +53,7 @@ bool active=TRUE; // Window Active Flag Set To TRUE By Default
|
|||
bool fullscreen=TRUE; // Fullscreen Flag Set To Fullscreen Mode By Default
|
||||
BOOL win_loop_done=FALSE; // Bool Variable To Exit Loop
|
||||
int counter,old_left,old_top,old_right,old_bottom,cur_gfx_mode,old_gfx_mode;
|
||||
extern HANDLE hGlobalDrawEvent,hQuitEvent;
|
||||
extern HANDLE hGraphicsDrawEvent,hQuitEvent,hDoneDrawingEvent;
|
||||
|
||||
int DrawGLScene(GLvoid);
|
||||
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM); // Declaration For WndProc
|
||||
|
@ -164,6 +164,11 @@ void ChangeMode( int mode ) {
|
|||
switch (mode) {
|
||||
case MODE_NO_GRAPHICS:
|
||||
if (fullscreen) while(ShowCursor(true) < 0); // Show Mouse Pointer
|
||||
GetWindowRect( hWnd, &WindowRect );
|
||||
old_left = WindowRect.left;
|
||||
old_top = WindowRect.top;
|
||||
old_right = WindowRect.right;
|
||||
old_bottom = WindowRect.bottom;
|
||||
fullscreen = false;
|
||||
break;
|
||||
case MODE_WINDOW:
|
||||
|
@ -420,6 +425,21 @@ LRESULT CALLBACK WndProc( HWND hWnd, // Handle For This Window
|
|||
ReSizeGLScene(LOWORD(lParam),HIWORD(lParam)); // LoWord=Width, HiWord=Height
|
||||
return 0; // Jump Back
|
||||
}
|
||||
|
||||
// If we get a redraw request outside of our normal
|
||||
// redraw framework, just fill the window with black
|
||||
case WM_PAINT:
|
||||
{
|
||||
PAINTSTRUCT ps;
|
||||
HDC hdc;
|
||||
RECT winRect;
|
||||
|
||||
hdc = BeginPaint(hWnd, &ps);
|
||||
GetClientRect(hWnd, &winRect);
|
||||
FillRect(hdc, &winRect, (HBRUSH) GetStockObject(BLACK_BRUSH));
|
||||
EndPaint(hWnd, &ps);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
// Pass All Unhandled Messages To DefWindowProc
|
||||
|
@ -428,6 +448,7 @@ LRESULT CALLBACK WndProc( HWND hWnd, // Handle For This Window
|
|||
|
||||
DWORD WINAPI win_graphics_event_loop( LPVOID gi ) {
|
||||
MSG msg; // Windows Message Structure
|
||||
HANDLE objs[1];
|
||||
|
||||
fullscreen=FALSE; // Windowed Mode
|
||||
|
||||
|
@ -461,21 +482,23 @@ DWORD WINAPI win_graphics_event_loop( LPVOID gi ) {
|
|||
TranslateMessage(&msg); // Translate The Message
|
||||
DispatchMessage(&msg); // Dispatch The Message
|
||||
}
|
||||
} else {
|
||||
objs[0] = hGraphicsDrawEvent;
|
||||
MsgWaitForMultipleObjects( 1, objs, FALSE, 1000, QS_ALLEVENTS|QS_POSTMESSAGE );
|
||||
}
|
||||
else // If There Are No Messages
|
||||
{
|
||||
if (ok_to_draw) { // Window Active?
|
||||
if (active) { // Not Time To Quit, Update Screen
|
||||
// Draw The Scene
|
||||
DrawGLScene();
|
||||
// Swap Buffers (Double Buffering). This seems to take lots of CPU time
|
||||
SwapBuffers(hDC);
|
||||
}
|
||||
// TODO: Do we need a mutex for ok_to_draw?
|
||||
ok_to_draw = 0;
|
||||
// Signal the worker thread that we're done drawing
|
||||
SetEvent(hGlobalDrawEvent);
|
||||
if (ok_to_draw) { // Window Active?
|
||||
if (active) { // Time To Update Screen
|
||||
// Draw The Scene
|
||||
DrawGLScene();
|
||||
// Swap Buffers (Double Buffering). This seems to take lots of CPU time
|
||||
SwapBuffers(hDC);
|
||||
}
|
||||
// TODO: Do we need a mutex for ok_to_draw?
|
||||
ok_to_draw = 0;
|
||||
// Signal the worker thread that we're done drawing
|
||||
SetEvent(hDoneDrawingEvent);
|
||||
// Put hGraphicsDrawEvent in unsignaled state so we don't immediately wake up
|
||||
ResetEvent(hGraphicsDrawEvent);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -151,7 +151,7 @@ int read_file_malloc(char* pathname, char*& str) {
|
|||
// replace XML element contents. not currently used
|
||||
//
|
||||
void replace_element(char* buf, char* start, char* end, char* replacement) {
|
||||
char temp[MAX_BLOB_SIZE], *p, *q;
|
||||
char temp[4096], *p, *q;
|
||||
|
||||
p = strstr(buf, start);
|
||||
p += strlen(start);
|
||||
|
|
|
@ -18,7 +18,6 @@
|
|||
//
|
||||
|
||||
#include <stdio.h>
|
||||
#include <db.h>
|
||||
|
||||
extern bool parse(char*, char*);
|
||||
extern bool parse_int(char*, char*, int&);
|
||||
|
|
Loading…
Reference in New Issue