mirror of https://github.com/BOINC/boinc.git
formatting, organization changes
svn path=/trunk/boinc/; revision=913
This commit is contained in:
parent
23b85623eb
commit
b7eb4f3b58
|
@ -126,19 +126,19 @@ int boinc_init() {
|
|||
f = fopen(GRAPHICS_DATA_FILE, "r");
|
||||
if (!f) {
|
||||
fprintf(stderr, "boinc_init(): can't open graphics data file\n");
|
||||
fprintf(stderr, "Using default graphics settings.\n");
|
||||
gi.refresh_period = 0.5;
|
||||
gi.xsize = 640;
|
||||
gi.ysize = 480;
|
||||
fprintf(stderr, "Using default graphics settings.\n");
|
||||
gi.refresh_period = 0.5;
|
||||
gi.xsize = 640;
|
||||
gi.ysize = 480;
|
||||
}
|
||||
if (f) {
|
||||
retval = parse_graphics_file(f, &gi);
|
||||
if (retval) {
|
||||
fprintf(stderr, "boinc_init(): can't parse graphics data file\n");
|
||||
return retval;
|
||||
}
|
||||
fclose(f);
|
||||
}
|
||||
if (f) {
|
||||
retval = parse_graphics_file(f, &gi);
|
||||
if (retval) {
|
||||
fprintf(stderr, "boinc_init(): can't parse graphics data file\n");
|
||||
return retval;
|
||||
}
|
||||
fclose(f);
|
||||
}
|
||||
|
||||
f = fopen(FD_INIT_FILE, "r");
|
||||
if (f) {
|
||||
|
@ -575,8 +575,8 @@ int parse_init_data_file(FILE* f, APP_INIT_DATA& ai) {
|
|||
int write_fraction_done_file(double pct, double cpu, double checkpoint_cpu) {
|
||||
FILE* f = fopen(FRACTION_DONE_TEMP_FILE, "w");
|
||||
|
||||
if (!f)
|
||||
return -1;
|
||||
if (!f)
|
||||
return -1;
|
||||
|
||||
fprintf(f,
|
||||
"<fraction_done>%f</fraction_done>\n"
|
||||
|
|
|
@ -167,4 +167,45 @@ GLvoid glPrint(GLuint font, const char *fmt, ...) // Custom GL "Print" Routine
|
|||
glPopAttrib(); // Pops The Display List Bits
|
||||
}
|
||||
|
||||
GLenum InitGL(GLvoid) { // All Setup For OpenGL Goes Here
|
||||
GLenum err;
|
||||
|
||||
glShadeModel(GL_SMOOTH); // Enable Smooth Shading
|
||||
if (err=glGetError()) return err;
|
||||
|
||||
glClearColor(0.0f, 0.0f, 0.0f, 0.5f); // Black Background
|
||||
if (err=glGetError()) return err;
|
||||
|
||||
glClearDepth(1.0f); // Depth Buffer Setup
|
||||
if (err=glGetError()) return err;
|
||||
|
||||
glEnable(GL_DEPTH_TEST); // Enables Depth Testing
|
||||
if (err=glGetError()) return err;
|
||||
|
||||
glDepthFunc(GL_LEQUAL); // The Type Of Depth Testing To Do
|
||||
if (err=glGetError()) return err;
|
||||
|
||||
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST); // Really Nice Perspective Calculations
|
||||
if (err=glGetError()) return err;
|
||||
|
||||
return GL_NO_ERROR; // Initialization Went OK
|
||||
}
|
||||
|
||||
GLenum ReSizeGLScene(GLsizei width, GLsizei height) { // Resize And Initialize The GL Window
|
||||
GLenum err;
|
||||
double aspect_ratio = 4.0/3.0;
|
||||
|
||||
if (height<=0) height=1; // Prevent A Divide By Zero By Making Height Equal One
|
||||
if (width<=0) width=1;
|
||||
|
||||
if (height*aspect_ratio > width)
|
||||
glViewport(0,0,(int)width,(int)(width/aspect_ratio)); // Reset The Current Viewport
|
||||
else
|
||||
glViewport(0,0,(int)(height*aspect_ratio),(height)); // Reset The Current Viewport
|
||||
|
||||
if (err=glGetError()) return err;
|
||||
|
||||
return GL_NO_ERROR;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -23,5 +23,13 @@ int boinc_finish_opengl();
|
|||
|
||||
#ifdef BOINC_APP_GRAPHICS
|
||||
GLvoid glPrint(GLuint font, const char *fmt, ...);
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
GLenum InitGL(GLvoid);
|
||||
GLenum ReSizeGLScene(GLsizei width, GLsizei height);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
bool app_render(int xs, int ys, double time_of_day);
|
||||
#endif
|
||||
|
|
|
@ -69,6 +69,7 @@ GLuint main_font;
|
|||
structGLWindowInfo glInfo;
|
||||
|
||||
bool user_requested_exit = false;
|
||||
extern bool using_opengl;
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
|
@ -154,22 +155,25 @@ int InitGLWindow(int xsize, int ysize, int depth)
|
|||
aglUpdateContext (boincAGLContext);
|
||||
aglReportError ();
|
||||
|
||||
glClearColor(0.0f, 0.0f, 0.0f, 1.0f); // Clear color buffer to dark grey
|
||||
aglDisable (boincAGLContext, AGL_BUFFER_RECT);
|
||||
aglReportError ();
|
||||
ReSizeGLScene( rectPort.right - rectPort.left, rectPort.bottom - rectPort.top );
|
||||
glReportError ();
|
||||
|
||||
InitGL();
|
||||
|
||||
glClear (GL_COLOR_BUFFER_BIT);
|
||||
glReportError ();
|
||||
aglSwapBuffers (boincAGLContext);
|
||||
aglReportError ();
|
||||
|
||||
aglDisable (boincAGLContext, AGL_BUFFER_RECT);
|
||||
aglReportError ();
|
||||
glViewport (0, 0, rectPort.right - rectPort.left, rectPort.bottom - rectPort.top);
|
||||
glReportError ();
|
||||
|
||||
GetFNum("\pTimes New Roman", &fNum); // build font
|
||||
main_font = BuildFontGL (boincAGLContext, fNum, normal, 9);
|
||||
|
||||
aglUpdateContext (boincAGLContext);
|
||||
aglReportError ();
|
||||
|
||||
using_opengl = true;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
@ -241,7 +245,7 @@ pascal OSStatus MainAppEventHandler(EventHandlerCallRef appHandler, EventRef the
|
|||
case kHICommandMaximizeWindow: // 'mini'
|
||||
case kHICommandZoomWindow: // 'zoom'
|
||||
GetWindowPortBounds (appGLWindow, &rectPort);
|
||||
glViewport (0, 0, rectPort.right - rectPort.left, rectPort.bottom - rectPort.top);
|
||||
ReSizeGLScene(rectPort.right - rectPort.left, rectPort.bottom - rectPort.top);
|
||||
glReportError ();
|
||||
break;
|
||||
case kHICommandOK: // 'ok '
|
||||
|
|
|
@ -61,20 +61,6 @@ void ChangeMode( int mode );
|
|||
BOOL reg_win_class();
|
||||
BOOL unreg_win_class();
|
||||
|
||||
GLvoid ReSizeGLScene(GLsizei width, GLsizei height) // Resize And Initialize The GL Window
|
||||
{
|
||||
double aspect_ratio = 4.0/3.0;
|
||||
|
||||
if (height==0) { // Prevent A Divide By Zero By
|
||||
height=1; // Making Height Equal One
|
||||
}
|
||||
|
||||
if (height*aspect_ratio > width)
|
||||
glViewport(0,0,(int)width,(int)(width/aspect_ratio)); // Reset The Current Viewport
|
||||
else
|
||||
glViewport(0,0,(int)(height*aspect_ratio),(height)); // Reset The Current Viewport
|
||||
}
|
||||
|
||||
GLvoid BuildFont(GLvoid) // Build Our Bitmap Font
|
||||
{
|
||||
HFONT font; // Windows Font ID
|
||||
|
@ -108,18 +94,6 @@ GLvoid KillFont(GLvoid) // Delete The Font List
|
|||
glDeleteLists(main_font, 256); // Delete All 96 Characters
|
||||
}
|
||||
|
||||
int InitGL(GLvoid) // All Setup For OpenGL Goes Here
|
||||
{
|
||||
glShadeModel(GL_SMOOTH); // Enable Smooth Shading
|
||||
glClearColor(0.0f, 0.0f, 0.0f, 0.5f); // Black Background
|
||||
glClearDepth(1.0f); // Depth Buffer Setup
|
||||
glEnable(GL_DEPTH_TEST); // Enables Depth Testing
|
||||
glDepthFunc(GL_LEQUAL); // The Type Of Depth Testing To Do
|
||||
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST); // Really Nice Perspective Calculations
|
||||
BuildFont(); // Build The Font
|
||||
return TRUE; // Initialization Went OK
|
||||
}
|
||||
|
||||
GLvoid KillGLWindow(GLvoid) // Properly Kill The Window
|
||||
{
|
||||
while(ShowCursor(true) < 0); // Show Mouse Pointer
|
||||
|
@ -335,6 +309,7 @@ BOOL CreateGLWindow(char* title, int width, int height, int bits, bool initially
|
|||
MessageBox(NULL,"Initialization Failed.","ERROR",MB_OK|MB_ICONEXCLAMATION);
|
||||
return FALSE; // Return FALSE
|
||||
}
|
||||
BuildFont(); // Build The Font
|
||||
|
||||
return TRUE; // Success
|
||||
}
|
||||
|
@ -357,22 +332,6 @@ LRESULT CALLBACK WndProc( HWND hWnd, // Handle For This Window
|
|||
return 0;
|
||||
}
|
||||
|
||||
/*case WM_SYSCOMMAND: // Intercept System Commands
|
||||
{
|
||||
switch (wParam) { // Check System Calls
|
||||
case SC_SCREENSAVE: // Screensaver Trying To Start?
|
||||
if (!fullscreen) {
|
||||
GetCursorPos(&initCursorPos);
|
||||
ChangeMode(!fullscreen);
|
||||
|
||||
counter = 5;
|
||||
}
|
||||
case SC_MONITORPOWER: // Monitor Trying To Enter Powersave?
|
||||
return 0; // Prevent From Happening
|
||||
}
|
||||
break; // Exit
|
||||
}*/
|
||||
|
||||
case WM_KEYDOWN: // Is A Key Being Held Down?
|
||||
// If a key is pressed in full screen mode, go back to old mode
|
||||
if (fullscreen) {
|
||||
|
|
|
@ -77,6 +77,8 @@ void *p_graphics_loop( void *duff ) {
|
|||
fprintf(stderr, "glXMakeCurrent failed (window)!\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
InitGL();
|
||||
|
||||
win_open = true;
|
||||
buildFont();
|
||||
|
@ -115,7 +117,7 @@ void process_input(Display *dpy) {
|
|||
GLvoid buildFont(GLvoid)
|
||||
{
|
||||
XFontStruct *font;
|
||||
|
||||
|
||||
main_font = glGenLists(256); /* storage for 256 characters */
|
||||
/* load a font with a specific name in "Host Portable Character Encoding" */
|
||||
/*font = XLoadQueryFont(dpy,
|
||||
|
|
Loading…
Reference in New Issue