diff options
author | taw27 <taw27@84d2e878-0bd5-11dd-ad15-13eda11d74c5> | 2008-06-04 17:33:44 +0000 |
---|---|---|
committer | taw27 <taw27@84d2e878-0bd5-11dd-ad15-13eda11d74c5> | 2008-06-04 17:33:44 +0000 |
commit | 997a3c23ad0175f82feb37f400762ecf08545e2c (patch) | |
tree | c4b8ea95f49ef2138972188f1cdf2ed38371d2aa /src | |
parent | f30bb8be1f801d66590699e317fae455e35af3eb (diff) |
Disable OpenGL stuff at the command line
git-svn-id: svn://cook.msm.cam.ac.uk:745/thrust3d/thrust3d@71 84d2e878-0bd5-11dd-ad15-13eda11d74c5
Diffstat (limited to 'src')
-rw-r--r-- | src/game.c | 4 | ||||
-rw-r--r-- | src/game.h | 2 | ||||
-rw-r--r-- | src/main.c | 31 | ||||
-rw-r--r-- | src/render.c | 43 | ||||
-rw-r--r-- | src/render.h | 2 |
5 files changed, 62 insertions, 20 deletions
@@ -219,7 +219,7 @@ static void game_load_all_connected(Game *game) { } /* Create a new "game" structure */ -Game *game_new(int width, int height) { +Game *game_new(int width, int height, int disable_vbos, int disable_fbos, int disable_shaders) { Game *g; @@ -247,7 +247,7 @@ Game *game_new(int width, int height) { g->radiation = 0.1; /* Renderer setup */ - g->render = render_setup(width, height); + g->render = render_setup(width, height, disable_vbos, disable_fbos, disable_shaders); if ( g->render == NULL ) { fprintf(stderr, "Couldn't initialise renderer\n"); free(g); @@ -21,7 +21,7 @@ #include "types.h" extern void game_check_handoff(Game *game); -extern Game *game_new(int width, int height); +extern Game *game_new(int width, int height, int disable_vbos, int disable_fbos, int disable_shaders); extern Room *game_find_room(Game *game, int rx, int ry, int rz); extern void game_pause(Game *game); @@ -18,6 +18,7 @@ #include <unistd.h> #include <SDL.h> #include <assert.h> +#include <getopt.h> #include "types.h" #include "model.h" @@ -51,11 +52,24 @@ int main(int argc, char *argv[]) { ScreenResolution res; Uint32 t; + int disable_vbos = 0; + int disable_fbos = 0; + int disable_shaders = 0; + const struct option longopts[] = { {"fullscreen", 0, NULL, 'f'}, + {"resolution", 1, NULL, 'r'}, + {"help", 0, NULL, 'h'}, + {"version", 0, NULL, 'v'}, + {"disable-vbos", 0, &disable_vbos, 1}, + {"disable-fbos", 0, &disable_fbos, 1}, + {"disable-shaders", 0, &disable_shaders, 1}, + {0, 0, NULL, 0} }; + + res = RES_800; width = 800; height = 600; video_flags = SDL_OPENGL; - while ((c = getopt(argc, argv, "hvr:f")) != -1) { + while ((c = getopt_long(argc, argv, "hvr:f", longopts, NULL)) != -1) { switch ( c ) { @@ -87,10 +101,11 @@ int main(int argc, char *argv[]) { case 'h' : { printf("Syntax: %s [-hvf] [-r <res>]\n\n", argv[0]); printf("Post-apocalyptic Jet Set Willy, set in a 3D nuclear power station.\n\n"); - printf(" -h Display this help message and exit.\n"); - printf(" -v Display version number and exit.\n"); - printf(" -r <res> Set display resolution. See below for possible values for <res>.\n"); - printf(" -f Use the full screen.\n\n"); + printf(" -h, --help Display this help message and exit.\n"); + printf(" -v, --version Display version number and exit.\n"); + printf(" -r, --resolution <res> Set display resolution. See below for possible values for <res>.\n"); + printf(" --disable-shaders Disable the use of OpenGL shaders (advanced).\n"); + printf(" -f, --fullscreen Use the full screen.\n\n"); printf("Allowable values for <res> are as follows:\n\n"); printf("<res> Width Height\n"); printf(" 640 - 640 x 480\n"); @@ -105,6 +120,10 @@ int main(int argc, char *argv[]) { return 0; } + case 0 : { + break; + } + default : { return 1; } @@ -143,7 +162,7 @@ int main(int argc, char *argv[]) { /* World setup */ Game *game; - game = game_new(width, height); + game = game_new(width, height, disable_vbos, disable_fbos, disable_shaders); /* Main loop */ finished = 0; diff --git a/src/render.c b/src/render.c index d64f2cf..1ef1880 100644 --- a/src/render.c +++ b/src/render.c @@ -133,7 +133,7 @@ static void render_delete_shaders(RenderContext *r) { i++; /* OpenGL initial setup */ -RenderContext *render_setup(int width, int height) { +RenderContext *render_setup(int width, int height, int disable_vbos, int disable_fbos, int disable_shaders) { RenderContext *r; @@ -142,27 +142,50 @@ RenderContext *render_setup(int width, int height) { glewInit(); - if ( GLEW_VERSION_1_5 || GLEW_ARB_vertex_buffer_object ) { - r->vbos = 1; + if ( disable_vbos == 0 ) { + if ( GLEW_VERSION_1_5 || GLEW_ARB_vertex_buffer_object ) { + r->vbos = 1; + } else { + r->vbos = 0; + fprintf(stderr, "Vertex buffer objects are not supported by your graphics card (or maybe just by its driver).\n"); + fprintf(stderr, " -> Geometry performance may be less than optimal.\n"); + } } else { + printf("The use of vertex buffer objects has been disabled at your request.\n"); r->vbos = 0; - fprintf(stderr, "Vertex buffer objects are not supported by your graphics card (or maybe just by its driver).\n"); + } + if ( r->vbos == 0 ) { fprintf(stderr, " -> Geometry performance may be less than optimal.\n"); } - if ( GLEW_EXT_framebuffer_object ) { - r->fbos = 1; + if ( disable_fbos == 0 ) { + if ( GLEW_EXT_framebuffer_object ) { + r->fbos = 1; + } else { + r->fbos = 0; + fprintf(stderr, "Framebuffer objects are not supported by your graphics card (or maybe just by its driver).\n"); + } } else { + printf("The use of framebuffer objects has been disabled at your request.\n"); r->fbos = 0; - fprintf(stderr, "Framebuffer objects are not supported by your graphics card (or maybe just by its driver).\n"); + } + if ( r->fbos == 0 ) { fprintf(stderr, " -> Reflections and GPU dynamic textures disabled.\n"); } - if ( ( GLEW_ARB_vertex_shader && GLEW_ARB_fragment_shader && GLEW_ARB_shader_objects && GLEW_ARB_shading_language_100 ) || GLEW_VERSION_2_0 ) { - r->shaders = 1; + if ( disable_shaders == 0 ) { + if ( ( GLEW_ARB_vertex_shader && GLEW_ARB_fragment_shader && GLEW_ARB_shader_objects && GLEW_ARB_shading_language_100 ) + || GLEW_VERSION_2_0 ) { + r->shaders = 1; + } else { + r->shaders = 0; + fprintf(stderr, "Shaders are not supported by your graphics card (or maybe just by its driver).\n"); + } } else { + printf("The use of shaders has been disabled at your request.\n"); r->shaders = 0; - fprintf(stderr, "Shaders are not supported by your graphics card (or maybe just by its driver).\n"); + } + if ( r->shaders == 0 ) { fprintf(stderr, " -> Per-fragment lighting and GPU dynamic textures disabled.\n"); } diff --git a/src/render.h b/src/render.h index b480da2..e9cb4ff 100644 --- a/src/render.h +++ b/src/render.h @@ -18,7 +18,7 @@ #include "types.h" -extern RenderContext *render_setup(int width, int height); +extern RenderContext *render_setup(int width, int height, int disable_vbos, int disable_fbos, int disable_shaders); extern void render_shutdown(RenderContext *ctx); extern void render_draw(Game *game, Uint32 t); extern void render_set_wireframe(int wireframe); |