diff --git a/direct/src/plugin/p3dInstance.cxx b/direct/src/plugin/p3dInstance.cxx index d28ba5019e..d5d7f275fc 100644 --- a/direct/src/plugin/p3dInstance.cxx +++ b/direct/src/plugin/p3dInstance.cxx @@ -994,6 +994,37 @@ paint_window() { memcpy(_reversed_buffer + (y_size - 1 - yi) * rowsize, (char *)framebuffer + yi * rowsize, rowsize); + +#ifdef __BIG_ENDIAN__ + // It appears that kBGRAPixelFormat, below, is ignored on + // big-endian machines, and it is treated as KARGBPixelFormat + // regardless of what we specify. Vexing. To compensate for + // this, we have to reverse the color channels ourselves on + // big-endian machines. + + /* + unsigned int *b = (unsigned int *)(_reversed_buffer + (y_size - 1 - yi) * rowsize); + for (int xi = 0; xi < x_size; ++xi) { + unsigned int w = *b; + *b = ((w >> 24) & 0xff) | ((w >> 8) & 0xff00) | ((w << 8) & 0xff0000) | ((w << 24) & 0xff000000); + ++b; + } + */ + + // This was measured to be faster than the above. + unsigned char *t = (unsigned char *)(_reversed_buffer + (y_size - 1 - yi) * rowsize); + for (int xi = 0; xi < x_size; ++xi) { + unsigned char b = t[0]; + unsigned char g = t[1]; + unsigned char r = t[2]; + unsigned char a = t[3]; + t[0] = a; + t[1] = r; + t[2] = g; + t[3] = b; + t += 4; + } +#endif } _swbuffer->close_read_framebuffer(); diff --git a/direct/src/plugin/p3dSession.cxx b/direct/src/plugin/p3dSession.cxx index 350d214463..ab1e6fce69 100644 --- a/direct/src/plugin/p3dSession.cxx +++ b/direct/src/plugin/p3dSession.cxx @@ -140,7 +140,7 @@ shutdown() { struct timeval now; gettimeofday(&now, NULL); int now_ms = now.tv_sec * 1000 + now.tv_usec / 1000; - double elapsed = now_ms - start_ms; + int elapsed = now_ms - start_ms; if (elapsed > max_wait_ms) { // Tired of waiting. Kill the process.