diff options
Diffstat (limited to 'src/glut/dos')
-rw-r--r-- | src/glut/dos/glutint.h | 5 | ||||
-rw-r--r-- | src/glut/dos/init.c | 13 | ||||
-rw-r--r-- | src/glut/dos/mouse.c | 14 | ||||
-rw-r--r-- | src/glut/dos/window.c | 18 |
4 files changed, 34 insertions, 16 deletions
diff --git a/src/glut/dos/glutint.h b/src/glut/dos/glutint.h index 77a8322c44..bbabf0fdb2 100644 --- a/src/glut/dos/glutint.h +++ b/src/glut/dos/glutint.h @@ -105,6 +105,9 @@ extern GLboolean g_redisplay; extern GLuint g_bpp; /* HW: bits per pixel */
extern GLuint g_refresh; /* HW: vertical refresh rate */
extern GLuint g_screen_w, g_screen_h; /* HW: physical screen size */
+extern GLint g_driver_caps;
+
+extern GLuint g_fps;
extern GLuint g_display_mode; /* display bits */
extern int g_init_x, g_init_y; /* initial window position */
@@ -132,7 +135,7 @@ extern void __glutFatalUsage(char *format,...); -#define MAX_WINDOWS 2
+#define MAX_WINDOWS 2
#define DEFAULT_WIDTH 300
#define DEFAULT_HEIGHT 300
diff --git a/src/glut/dos/init.c b/src/glut/dos/init.c index 0f848f6f36..6c034ff5e2 100644 --- a/src/glut/dos/init.c +++ b/src/glut/dos/init.c @@ -38,6 +38,9 @@ GLboolean g_redisplay = GL_FALSE; GLuint g_bpp = DEFAULT_BPP;
GLuint g_refresh = 0;
GLuint g_screen_w, g_screen_h;
+GLint g_driver_caps;
+
+GLuint g_fps = 0;
GLuint g_display_mode = 0;
int g_init_x = 0, g_init_y = 0;
@@ -68,6 +71,13 @@ void APIENTRY glutInit (int *argc, char **argv) }
__glutProgramName = __glutStrdup(str);
+ /* check if GLUT_FPS env var is set */
+ if ((env = getenv("GLUT_FPS")) != NULL) {
+ if ((g_fps = atoi(env)) <= 0) {
+ g_fps = 5000; /* 5000 milliseconds */
+ }
+ }
+
/* Initialize timer */
glutGet(GLUT_ELAPSED_TIME);
}
@@ -106,9 +116,10 @@ void APIENTRY glutMainLoop (void) {
GLint screen_size[2];
- DMesaGetIntegerv(DMESA_SCREEN_SIZE, screen_size);
+ DMesaGetIntegerv(DMESA_GET_SCREEN_SIZE, screen_size);
g_screen_w = screen_size[0];
g_screen_h = screen_size[1];
+ DMesaGetIntegerv(DMESA_GET_DRIVER_CAPS, &g_driver_caps);
}
pc_install_keyb();
diff --git a/src/glut/dos/mouse.c b/src/glut/dos/mouse.c index c67f8093b1..d82f5e8a8c 100644 --- a/src/glut/dos/mouse.c +++ b/src/glut/dos/mouse.c @@ -39,19 +39,7 @@ int g_mouse_x = 0, g_mouse_y = 0; void __glutInitMouse (void)
{
if ((g_mouse = pc_install_mouse())) {
- GLint yorg;
- GLint rect[4];
-
- DMesaGetIntegerv(DMESA_Y_ORIGIN, &yorg);
- if (yorg) {
- rect[1] = g_screen_h - g_curwin->height;
- } else {
- rect[1] = g_curwin->ypos;
- }
- rect[0] = g_curwin->xpos;
- rect[2] = rect[0] + g_curwin->width - 1;
- rect[3] = rect[1] + g_curwin->height - 1;
- pc_mouse_area(rect[0], rect[1], rect[2], rect[3]);
+ pc_mouse_area(g_curwin->xpos, g_curwin->ypos, g_curwin->xpos + g_curwin->width - 1, g_curwin->ypos + g_curwin->height - 1);
g_curwin->show_mouse = (g_curwin->mouse || g_curwin->motion || g_curwin->passive);
}
diff --git a/src/glut/dos/window.c b/src/glut/dos/window.c index a7a7d9ca59..cad4726936 100644 --- a/src/glut/dos/window.c +++ b/src/glut/dos/window.c @@ -27,12 +27,15 @@ */
+#include <stdio.h>
+
#include "glutint.h"
#include "GL/dmesa.h"
GLUTwindow *g_curwin;
+static GLuint swaptime, swapcount;
static DMesaVisual visual = NULL;
static DMesaContext context = NULL;
@@ -59,7 +62,6 @@ static void clean (void) int APIENTRY glutCreateWindow (const char *title)
{
int i;
- GLint screen_size[2];
int m8width = (g_init_w + 7) & ~7;
if (!visual) {
@@ -154,6 +156,20 @@ void APIENTRY glutSwapBuffers (void) } else {
DMesaSwapBuffers(g_curwin->buffer);
}
+
+ if (g_fps) {
+ GLint t = glutGet(GLUT_ELAPSED_TIME);
+ swapcount++;
+ if (swaptime == 0)
+ swaptime = t;
+ else if (t - swaptime > g_fps) {
+ double time = 0.001 * (t - swaptime);
+ double fps = (double)swapcount / time;
+ fprintf(stderr, "GLUT: %d frames in %.2f seconds = %.2f FPS\n", swapcount, time, fps);
+ swaptime = t;
+ swapcount = 0;
+ }
+ }
}
|