diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/render.c | 15 | ||||
-rw-r--r-- | src/types.h | 1 |
2 files changed, 13 insertions, 3 deletions
diff --git a/src/render.c b/src/render.c index 5f3445c..9a5fbdf 100644 --- a/src/render.c +++ b/src/render.c @@ -142,6 +142,15 @@ RenderContext *render_setup(int width, int height, int disable_vbos, int disable fprintf(stderr, " -> Per-fragment lighting and GPU dynamic textures disabled.\n"); } + if ( GLEW_EXT_timer_query ) { + r->timer_queries = 1; + } else { + r->timer_queries = 0; + fprintf(stderr, "Timer queries are not supported by your graphics card" + "(or maybe just by its driver).\n"); + fprintf(stderr, " -> A default estimated time will be used. Framerate may be a little low.\n"); + } + r->width = width; r->height = height; r->aspect = (GLfloat)width/(GLfloat)height; @@ -558,7 +567,7 @@ void render_draw(Game *game, Uint32 t) { r = game->render; - if ( game->query_this_frame ) { + if ( r->timer_queries && game->query_this_frame ) { glGenQueries(1, &game->timer_query); glBeginQuery(GL_TIME_ELAPSED_EXT, game->timer_query); } @@ -679,11 +688,11 @@ void render_draw(Game *game, Uint32 t) { render_draw_2d(r, game); - if ( game->query_this_frame) glEndQuery(GL_TIME_ELAPSED_EXT); + if ( r->timer_queries && game->query_this_frame) glEndQuery(GL_TIME_ELAPSED_EXT); SDL_GL_SwapBuffers(); - if ( !game->query_this_frame ) { + if ( r->timer_queries && !game->query_this_frame ) { GLint available; glGetQueryObjectiv(game->timer_query, GL_QUERY_RESULT_AVAILABLE, &available); if ( available ) { diff --git a/src/types.h b/src/types.h index d45f474..7f1119f 100644 --- a/src/types.h +++ b/src/types.h @@ -134,6 +134,7 @@ typedef struct { int shaders; int vbos; int fbos; + int timer_queries; /* Lighting shaders */ GLuint lighting_vert; |