From ba8cc0c527ee9bbc2e0be1d33317f833f1fbb65d Mon Sep 17 00:00:00 2001 From: Eric Heien Date: Wed, 18 Sep 2002 21:54:36 +0000 Subject: [PATCH] opengl uppercase app svn path=/trunk/boinc/; revision=423 --- apps/upper_case.C | 47 ++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 44 insertions(+), 3 deletions(-) diff --git a/apps/upper_case.C b/apps/upper_case.C index a1aa804463..39d87edcc3 100755 --- a/apps/upper_case.C +++ b/apps/upper_case.C @@ -31,25 +31,37 @@ #include #include +#include "glut.h" +#include // Header File For The OpenGL32 Library +#include // Header File For The GLu32 Library +#include // Header File For The Glaux Library + #include "util.h" #include "filesys.h" #include "boinc_api.h" +int DrawGLScene(GLvoid); +void renderBitmapString( float x, float y, void *font, char *string); + #define CHECKPOINT_FILE "upper_case_state" +char the_char[10]; +double xPos=0, yPos=0; +double xDelta=0.03, yDelta=0.07; + int run_slow=0,cpu_time=0; time_t my_start_time; +APP_INIT_DATA uc_aid; int do_checkpoint(MFILE& mf, int nchars) { int retval; char resolved_name[512],res_name2[512]; FILE *app_time, *client_time; - APP_INIT_DATA aid; if (cpu_time) { app_time = fopen("../../app.time", "w"), client_time = fopen("../../client.time", "w"); - boinc_get_init_data(aid); + boinc_get_init_data(uc_aid); } boinc_resolve_filename( "temp", resolved_name ); FILE* f = fopen(resolved_name, "w"); @@ -74,7 +86,7 @@ int do_checkpoint(MFILE& mf, int nchars) { fclose(app_time); // print what the client thinks is our cpu time - fprintf(client_time, "%f\n", aid.wu_cpu_time + boinc_cpu_time()); + fprintf(client_time, "%f\n", uc_aid.wu_cpu_time + boinc_cpu_time()); fflush(client_time); fclose(client_time); } @@ -114,9 +126,12 @@ int main(int argc, char **argv) { my_start_time = time(0); + strcpy( the_char, "(none)\0" ); retval = boinc_init(); if (retval) exit(retval); + boinc_get_init_data(uc_aid); + boinc_resolve_filename( "in", resolved_name ); fprintf( stderr, "APP: upper_case: starting, argc %d\n", argc ); for (i=0; i %c\0", c, toupper(c) ); c = toupper(c); out._putchar(c); nchars++; @@ -186,3 +203,27 @@ int main(int argc, char **argv) { boinc_finish(0); return 0; } + + +int DrawGLScene(GLvoid) // Here's Where We Do All The Drawing +{ + char text[1024]; + + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // Clear Screen And Depth Buffer + glLoadIdentity(); // Reset The Current Modelview Matrix + glColor3f(1,1,1); + renderBitmapString(xPos,yPos,GLUT_BITMAP_HELVETICA_12,the_char); + xPos += xDelta; + yPos += yDelta; + if( xPos < -1 || xPos > 1 ) xDelta *= -1; + if( yPos < -1 || yPos > 1 ) yDelta *= -1; + + sprintf( text, "User: %s", uc_aid.user_name ); + renderBitmapString(-1.3,1.1,GLUT_BITMAP_HELVETICA_12, text); + sprintf( text, "Team: %s", uc_aid.team_name ); + renderBitmapString(-1.3,1.0,GLUT_BITMAP_HELVETICA_12, text); + sprintf( text, "CPU Time: %f", uc_aid.wu_cpu_time ); + renderBitmapString(-1.3,0.9,GLUT_BITMAP_HELVETICA_12, text); + + return TRUE; // Everything Went OK +}