#include <sys/time.h>
-#define GL_GLEXT_PROTOTYPES
-#include <GL/gl.h>
+#include "fips-dispatch-gl.h"
#include "metrics.h"
context_t current_context;
unsigned
-metrics_add_counter (void)
+metrics_counter_new (void)
{
counter_t *counter;
return counter->id;
}
+void
+metrics_counter_start (unsigned counter)
+{
+ glBeginQuery (GL_TIME_ELAPSED, counter);
+}
+
+void
+metrics_counter_stop (void)
+{
+ glEndQuery (GL_TIME_ELAPSED);
+}
+
void
metrics_set_current_program (unsigned program)
{
frames++;
-
- if (frames % 60 == 0) {
- double fps;
- gettimeofday (&tv_now, NULL);
-
- fps = (double) frames / (tv_now.tv_sec - tv_start.tv_sec +
- (tv_now.tv_usec - tv_start.tv_usec) / 1.0e6);
-
- printf("FPS: %.3f\n", fps);
-
- print_program_metrics ();
- }
+ gettimeofday (&tv_now, NULL);
/* Consume all counters that are ready. */
counter_t *counter = current_context.counter_head;
while (counter) {
- GLint available;
- GLuint elapsed;
+ GLuint available, elapsed;
- glGetQueryObjectiv (counter->id, GL_QUERY_RESULT_AVAILABLE,
- &available);
+ glGetQueryObjectuiv (counter->id, GL_QUERY_RESULT_AVAILABLE,
+ &available);
if (! available)
break;
free (counter);
counter = current_context.counter_head;
}
+
+ if (frames % 60 == 0) {
+ double fps;
+
+ fps = (double) frames / (tv_now.tv_sec - tv_start.tv_sec +
+ (tv_now.tv_usec - tv_start.tv_usec) / 1.0e6);
+
+ printf("FPS: %.3f\n", fps);
+
+ print_program_metrics ();
+ }
}