From ffb51e7e2b1b1224a8e4f0582921e5e5cddd4ef0 Mon Sep 17 00:00:00 2001 From: Taylor Richards Date: Tue, 9 Feb 2016 16:15:34 -0500 Subject: [PATCH] add stubbed graphics for standalone server --- include/2d.h | 1 + include/CMakeLists.txt | 1 + include/grstub.h | 17 ++++ src/CMakeLists.txt | 1 + src/freespace2/freespace.cpp | 8 +- src/graphics/2d.cpp | 21 +++++ src/graphics/grstub.cpp | 153 +++++++++++++++++++++++++++++++++++ 7 files changed, 196 insertions(+), 6 deletions(-) create mode 100644 include/grstub.h create mode 100644 src/graphics/grstub.cpp diff --git a/include/2d.h b/include/2d.h index e40b03d..be224b3 100644 --- a/include/2d.h +++ b/include/2d.h @@ -530,6 +530,7 @@ typedef struct screen { #define GR_OPENGL (100) // OpenGL (generic) #define GR_WXGL (101) // OpenGL for use with wxWidgets toolkit +#define GR_STUB (102) // Stubbed out for standalone server // resolution constants - always keep resolutions in ascending order and starting from 0 #define GR_NUM_RESOLUTIONS 2 diff --git a/include/CMakeLists.txt b/include/CMakeLists.txt index 8fff2bc..f3d4525 100644 --- a/include/CMakeLists.txt +++ b/include/CMakeLists.txt @@ -63,6 +63,7 @@ set(code_HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/grgl1.h ${CMAKE_CURRENT_SOURCE_DIR}/gropengl.h ${CMAKE_CURRENT_SOURCE_DIR}/gropenglinternal.h + ${CMAKE_CURRENT_SOURCE_DIR}/grstub.h ${CMAKE_CURRENT_SOURCE_DIR}/grwxgl.h ${CMAKE_CURRENT_SOURCE_DIR}/gtrack.h ${CMAKE_CURRENT_SOURCE_DIR}/helpeddoc.h diff --git a/include/grstub.h b/include/grstub.h new file mode 100644 index 0000000..f90a8a4 --- /dev/null +++ b/include/grstub.h @@ -0,0 +1,17 @@ +/* + * Copyright (C) Volition, Inc. 1999. All rights reserved. + * + * All source code herein is the property of Volition, Inc. You may not sell + * or otherwise commercially exploit the source or things you created based on + * the source. + */ + + +#ifndef GRSTUB_H +#define GRSTUB_H + + +void gr_stub_init(); + + +#endif // GRSTUB_H diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 5eac7ad..bec7c9c 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -40,6 +40,7 @@ set(code_SOURCE ${CMAKE_CURRENT_SOURCE_DIR}/graphics/grgl1render.cpp ${CMAKE_CURRENT_SOURCE_DIR}/graphics/grgl1texture.cpp ${CMAKE_CURRENT_SOURCE_DIR}/graphics/gropengl.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/graphics/grstub.cpp ${CMAKE_CURRENT_SOURCE_DIR}/graphics/grwxgl.cpp ${CMAKE_CURRENT_SOURCE_DIR}/hud/hud.cpp ${CMAKE_CURRENT_SOURCE_DIR}/hud/hudartillery.cpp diff --git a/src/freespace2/freespace.cpp b/src/freespace2/freespace.cpp index 7f26da0..f2f922e 100644 --- a/src/freespace2/freespace.cpp +++ b/src/freespace2/freespace.cpp @@ -2370,12 +2370,8 @@ void game_init() // SOUND INIT END ///////////////////////////// - if ( !Is_standalone ) { - gr_init(); - } else { - STUB_FUNCTION; - Int3(); - } + + gr_init(); #if defined(FS2_DEMO) || defined(OEM_BUILD) || defined(FS1_DEMO) diff --git a/src/graphics/2d.cpp b/src/graphics/2d.cpp index 4bdef20..c5282a5 100644 --- a/src/graphics/2d.cpp +++ b/src/graphics/2d.cpp @@ -490,6 +490,8 @@ // Includes for different rendering systems #include "gropengl.h" #include "grwxgl.h" +#include "grstub.h" + screen gr_screen; @@ -537,6 +539,9 @@ void gr_close() gr_wxgl_cleanup(); break; + case GR_STUB: + break; + default: Int3(); // Invalid graphics mode break; @@ -654,6 +659,13 @@ static int gr_get_best_res(int *max_w, int *max_h) return GR_640; } + if (Is_standalone) { + (*max_w) = 640; + (*max_h) = 480; + + return GR_640; + } + // defaults int res = GR_640; (*max_w) = 640; @@ -713,6 +725,9 @@ int gr_init() case GR_WXGL: gr_wxgl_cleanup(); + case GR_STUB: + break; + default: Int3(); // Invalid graphics mode break; @@ -723,6 +738,8 @@ int gr_init() if (Fred_running || Pofview_running) { mode = GR_WXGL; + } else if (Is_standalone) { + mode = GR_STUB; } else { ptr = os_config_read_string("Video", "Renderer", "OpenGL"); @@ -770,6 +787,10 @@ int gr_init() SDL_assert( Pofview_running || Fred_running ); gr_wxgl_init(); break; + case GR_STUB: + SDL_assert(Is_standalone); + gr_stub_init(); + break; default: Int3(); // Invalid graphics mode break; diff --git a/src/graphics/grstub.cpp b/src/graphics/grstub.cpp new file mode 100644 index 0000000..df9c5ad --- /dev/null +++ b/src/graphics/grstub.cpp @@ -0,0 +1,153 @@ +/* + * Copyright (C) Volition, Inc. 1999. All rights reserved. + * + * All source code herein is the property of Volition, Inc. You may not sell + * or otherwise commercially exploit the source or things you created based on + * the source. + */ + + +#include "pstypes.h" +#include "2d.h" + + +static void stub_void_void() +{ +} + +static void stub_void_int(int) +{ +} + +static void stub_void_int2(int, int) +{ +} + +static void stub_void_int3(int, int, int) +{ +} + +static void stub_void_int4(int, int, int, int) +{ +} + +static void stub_void_int6(int, int, int, int, int, int) +{ +} + +static void stub_void_vertex2(vertex *, vertex *) +{ +} + +static void stub_string(int, int, const char *) +{ +} + +static void stub_tmapper(int, vertex *[], uint) +{ +} + +static void stub_print_screen(const char *) +{ +} + +static int stub_save_screen() +{ + return -1; +} + +static void stub_set_gamma(float) +{ +} + +static uint stub_lock() +{ + return 0; +} + +static void stub_fog_set(int, int, int, int, float, float) +{ +} + +static void stub_get_region(int, int, int, ubyte *) +{ +} + +static void stub_cross_fade(int, int, int, int, int, int, float) +{ +} + +static int stub_preload(int, int) +{ + return 1; +} + + +void gr_stub_init() +{ + gr_screen.gf_flip = stub_void_void; + gr_screen.gf_set_clip = stub_void_int4; + gr_screen.gf_reset_clip = stub_void_void; + + gr_screen.gf_clear = stub_void_void; + + gr_screen.gf_aabitmap = stub_void_int2; + gr_screen.gf_aabitmap_ex = stub_void_int6; + + gr_screen.gf_rect = stub_void_int4; + gr_screen.gf_shade = stub_void_int4; + gr_screen.gf_string = stub_string; + gr_screen.gf_circle = stub_void_int3; + + gr_screen.gf_line = stub_void_int4; + gr_screen.gf_aaline = stub_void_vertex2; + gr_screen.gf_pixel = stub_void_int2; + gr_screen.gf_scaler = stub_void_vertex2; + gr_screen.gf_tmapper = stub_tmapper; + + gr_screen.gf_gradient = stub_void_int4; + + gr_screen.gf_print_screen = stub_print_screen; + + gr_screen.gf_fade_in = stub_void_int; + gr_screen.gf_fade_out = stub_void_int; + gr_screen.gf_flash = stub_void_int3; + + gr_screen.gf_zbuffer_clear = stub_void_int; + + gr_screen.gf_save_screen = stub_save_screen; + gr_screen.gf_restore_screen = stub_void_int; + gr_screen.gf_free_screen = stub_void_int; + + gr_screen.gf_dump_frame_start = stub_void_int2; + gr_screen.gf_dump_frame_stop = stub_void_void; + gr_screen.gf_dump_frame = stub_void_void; + + gr_screen.gf_set_gamma = stub_set_gamma; + + gr_screen.gf_lock = stub_lock; + gr_screen.gf_unlock = stub_void_void; + + gr_screen.gf_fog_set = stub_fog_set; + + gr_screen.gf_get_region = stub_get_region; + + gr_screen.gf_set_cull = stub_void_int; + + gr_screen.gf_cross_fade = stub_cross_fade; + + gr_screen.gf_preload_init = stub_void_void; + gr_screen.gf_preload = stub_preload; + + gr_screen.gf_zbias = stub_void_int; + + gr_screen.gf_force_windowed = stub_void_void; + gr_screen.gf_force_fullscreen = stub_void_void; + gr_screen.gf_toggle_fullscreen = stub_void_void; + + gr_screen.gf_set_viewport = stub_void_int2; + + gr_screen.gf_activate = stub_void_int; + + gr_screen.gf_release_texture = stub_void_int; +} -- 2.39.2