diff --git a/api/boinc_api.C b/api/boinc_api.C index 6da8c40210..cb240c57c8 100644 --- a/api/boinc_api.C +++ b/api/boinc_api.C @@ -184,7 +184,7 @@ double boinc_worker_thread_cpu_time() { static double last_cpu=0; static time_t last_time=0; time_t now = time(0); - double cpu, time_diff = now - last_time; + double cpu, time_diff = (double)(now - last_time); #ifdef _WIN32 int retval; if (options.all_threads_cpu_time) { @@ -763,6 +763,7 @@ static void timer_handler() { static HANDLE timer_quit_event; UINT WINAPI timer_thread(void *) { + diagnostics_set_thread_name("Timer"); while (1) { Sleep(TIMER_PERIOD*1000); diff --git a/api/graphics_data.C b/api/graphics_data.C index 0f4343725d..af5907c8fc 100644 --- a/api/graphics_data.C +++ b/api/graphics_data.C @@ -17,7 +17,10 @@ // or write to the Free Software Foundation, Inc., // 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +#ifndef _WIN32 #include "config.h" +#endif + #include "graphics_data.h" void GRAPHICS_BUFFER::clear() { diff --git a/api/graphics_impl.C b/api/graphics_impl.C index 24df0e41ed..8a33b6f0df 100755 --- a/api/graphics_impl.C +++ b/api/graphics_impl.C @@ -23,6 +23,10 @@ // and thus can be put in a shared library, // separate from the application. +#ifndef _WIN32 +#include "config.h" +#endif + #if defined(_WIN32) && !defined(__STDWX_H__) && !defined(_BOINC_WIN_) && !defined(_AFX_STDAFX_H_) #include "boinc_win.h" #endif diff --git a/api/gutil.C b/api/gutil.C index 666da38d2e..1cf8660af5 100755 --- a/api/gutil.C +++ b/api/gutil.C @@ -190,7 +190,7 @@ void HLStoRGB( double H, double L, double S, COLOR& c) { double m1, m2; if(S==0) { - c.r=c.g=c.b=L; + c.r=c.g=c.b=(float)L; } else { if(L <=0.5) { m2 = L*(1.0+S); @@ -198,9 +198,9 @@ void HLStoRGB( double H, double L, double S, COLOR& c) { m2 = L+S-L*S; } m1 = 2.0*L-m2; - c.r = HuetoRGB(m1,m2,H+1.0/3.0); - c.g = HuetoRGB(m1,m2,H); - c.b = HuetoRGB(m1,m2,H-1.0/3.0); + c.r = (float)HuetoRGB(m1,m2,(H+1.0/3.0)); + c.g = (float)HuetoRGB(m1,m2,H); + c.b = (float)HuetoRGB(m1,m2,H-1.0/3.0); } } @@ -209,26 +209,26 @@ static inline float frand() { } void scale_screen(int iw, int ih) { - double aspect_ratio = 4.0/3.0; - double w=iw, h=ih; - double xs, ys; + float aspect_ratio = 4.0f/3.0f; + float w=(float)iw, h=(float)ih; + float xs, ys; if (h*aspect_ratio > w) { - xs = 1.0; + xs = 1.0f; ys = (w/aspect_ratio)/h; } else { xs = (h*aspect_ratio)/w; - ys = 1.0; + ys = 1.0f; } - glScalef(xs, ys*4./3., 1); + glScalef(xs, ys*aspect_ratio, 1.0f); } void center_screen(int iw, int ih) { - double aspect_ratio = 4.0/3.0; - double w=iw, h=ih; + float aspect_ratio = 4.0f/3.0f; + float w=(float)iw, h=(float)ih; if (h*aspect_ratio > w) { - glTranslatef(0.0, (h/2.0-(w/aspect_ratio/2.0))/h, 0.0); + glTranslatef(0.0f, (h/2.0f-(w/aspect_ratio/2.0f))/h, 0.0f); } else { - glTranslatef((w/2.0-(h*aspect_ratio/2.0))/w, 0.0, 0.0); + glTranslatef((w/2.0f-(h*aspect_ratio/2.0f))/w, 0.0f, 0.0f); } } @@ -299,7 +299,7 @@ void PROGRESS_2D::draw(float x) { glEnd(); float dif=width-inner_width; - float zoffset=.01; + float zoffset=.01f; glBegin(GL_QUADS); glColor4d(inner_color[0],inner_color[1],inner_color[2],inner_color[3]); glVertex3d(pos[0],pos[1]-(dif/2.),pos[2]+zoffset); @@ -346,8 +346,8 @@ static float zvec[] = {0, 0, 1}; // void RIBBON_GRAPH::draw_x(int i) { GLfloat pt[3]; - double r1 = i/(double)len; - double r2 = (i+1)/(double)len; + float r1 = i/(float)len; + float r2 = (i+1)/(float)len; glNormal3fv(yvec); pt[0] = pos[0] + r1*size[0]; @@ -379,7 +379,7 @@ void RIBBON_GRAPH::draw_x(int i) { // void RIBBON_GRAPH::draw_y(int i) { GLfloat pt[3]; - double r1 = i/(double)len; + float r1 = i/(float)len; (data[i]>data[i-1])?glNormal3fv(xvecneg):glNormal3fv(xvec); pt[0] = pos[0] + r1*size[0]; @@ -396,17 +396,17 @@ void RIBBON_GRAPH::draw_y(int i) { void RIBBON_GRAPH::draw_tick(int i) { GLfloat pt[3]; - double r1 = ticks[i]/(double)len; + float r1 = ticks[i]/(float)len; pt[0] = pos[0] + r1*size[0]; - pt[1] = pos[1] + (1.-tick_yfrac)*size[1]; + pt[1] = pos[1] + (1.0f-tick_yfrac)*size[1]; pt[2] = pos[2]; glVertex3fv(pt); - pt[1] = pos[1] + size[1]*1.1; + pt[1] = pos[1] + size[1]*1.1f; glVertex3fv(pt); pt[2] = pos[2] + size[2]; glVertex3fv(pt); - pt[1] = pos[1] + (1.-tick_yfrac)*size[1]; + pt[1] = pos[1] + (1.0f-tick_yfrac)*size[1]; glVertex3fv(pt); } @@ -520,7 +520,7 @@ void STARFIELD::update_stars(float dt) { if (stars[i].z > zmax/2) glPointSize(1); else glPointSize(2); glBegin(GL_POINTS); - glVertex2f(x, y); + glVertex2f((GLfloat)x, (GLfloat)y); glEnd(); } ortho_done(); @@ -601,24 +601,24 @@ int read_ppm_file(const char* name, int& w, int& h, unsigned char** arrayp) { // void TEXTURE_DESC::draw(float* p, float* size, int xalign, int yalign) { float pos[3]; - double tratio, sratio, new_size; + float tratio, sratio, new_size; memcpy(pos, p, sizeof(pos)); glColor4f(1.,1.,1.,1.); glEnable(GL_TEXTURE_2D); glBindTexture(GL_TEXTURE_2D, id); - tratio = xsize/ysize; + tratio = static_cast(xsize/ysize); sratio = size[0]/size[1]; if (tratio > sratio) { // texture is wider than space new_size = size[0]/tratio; - if (yalign == ALIGN_CENTER) pos[1] += (size[1]-new_size)/2; + if (yalign == ALIGN_CENTER) pos[1] += (size[1]-new_size)/2.0f; if (yalign == ALIGN_TOP) pos[1] += size[1]-new_size; size[1] = new_size; } if (sratio > tratio) { // space is wider than texture new_size = size[1]*tratio; - if (xalign == ALIGN_CENTER) pos[0] += (size[0]-new_size)/2; + if (xalign == ALIGN_CENTER) pos[0] += (size[0]-new_size)/2.0f; if (xalign == ALIGN_TOP) pos[0] += size[0]-new_size; size[0] = new_size; } diff --git a/api/texture.C b/api/texture.C index adb8858dc2..1b46ed9533 100644 --- a/api/texture.C +++ b/api/texture.C @@ -1,3 +1,4 @@ + #include #include #include @@ -224,11 +225,11 @@ int checkSize (int x){ unsigned int texFormat; -unsigned char* getRGBA (FILE *s, int size){ +unsigned char* getRGBA (FILE *s, size_t size){ unsigned char *rgba; unsigned char temp; - int bread; - int i; + size_t bread; + size_t i; rgba=(unsigned char*)malloc(size * 4); if (rgba == NULL) return 0; bread = fread (rgba, sizeof (unsigned char), size * 4, s); @@ -250,11 +251,11 @@ unsigned char* getRGBA (FILE *s, int size){ // getRGB // Reads in RGB data for a 24bit image. // ============= -unsigned char* getRGB (FILE *s, int size){ +unsigned char* getRGB (FILE *s, size_t size){ unsigned char *rgb; unsigned char temp; - int bread; - int i; + size_t bread; + size_t i; rgb=(unsigned char*)malloc(size * 3); if (rgb == NULL) return 0; bread = fread (rgb, sizeof (unsigned char), size * 3, s); @@ -276,9 +277,9 @@ unsigned char* getRGB (FILE *s, int size){ // getGray // Gets the grayscale image data. Used as an alpha channel. // ============= -unsigned char* getGray (FILE *s, int size){ +unsigned char* getGray (FILE *s, size_t size){ unsigned char *grayData; - int bread; + size_t bread; grayData=(unsigned char*)malloc (size); if (grayData == NULL) return 0; bread = fread (grayData, sizeof (unsigned char), size, s); diff --git a/api/tgalib.h b/api/tgalib.h index a6de515792..eeba871151 100644 --- a/api/tgalib.h +++ b/api/tgalib.h @@ -19,4 +19,4 @@ struct tImageTGA tImageTGA *LoadTGA(const char *filename); -#endif \ No newline at end of file +#endif diff --git a/api/windows_opengl.C b/api/windows_opengl.C index 4922d0094b..37a896626a 100755 --- a/api/windows_opengl.C +++ b/api/windows_opengl.C @@ -46,6 +46,7 @@ static HDESK hInteractiveDesktop = NULL; static bool visible = true; static bool window_ready=false; static UINT_PTR gfx_timer_id = 0; +HANDLE graphics_threadh; #define GLUT_CTRL_KEY 17 @@ -80,6 +81,7 @@ void KillWindow() { } } + void SetupPixelFormat(HDC hDC) { int nPixelFormat; @@ -255,7 +257,7 @@ static void set_mode(int mode) { BOINCTRACE("Retrieved the required window station\n"); SetProcessWindowStation(hInteractiveWindowStation); hInteractiveDesktop = OpenDesktop( - graphics_msg.desktop, NULL, FALSE, + graphics_msg.desktop, (DWORD)NULL, FALSE, GENERIC_READ | DESKTOP_CREATEWINDOW | DESKTOP_CREATEMENU ); if (NULL == hInteractiveDesktop) { @@ -377,6 +379,7 @@ LRESULT CALLBACK WndProc( PAINTSTRUCT ps; RECT winRect; HDC pdc; + if (!graphics_threadh) graphics_threadh=(HANDLE)GetCurrentThreadId(); pdc = BeginPaint(hWnd, &ps); GetClientRect(hWnd, &winRect); FillRect(pdc, &winRect, (HBRUSH)GetStockObject(BLACK_BRUSH));