From 09eba7f48ac0e65473f1a163d4ff6240aed82f77 Mon Sep 17 00:00:00 2001 From: Kp Date: Sun, 13 Dec 2015 18:00:48 +0000 Subject: [PATCH] Use inline namespace dsx for similar/arch/ogl/ --- common/include/fwd-gr.h | 16 ++++++++++++++-- common/include/internal.h | 10 ++++++++++ common/include/ogl_init.h | 13 +++++++++---- common/include/palette.h | 2 +- common/main/game.h | 6 ++++++ similar/arch/ogl/gr.cpp | 24 ++++++++++++++++++++++-- similar/arch/ogl/ogl.cpp | 12 ++++++++++-- similar/arch/sdl/gr.cpp | 4 ++++ 8 files changed, 76 insertions(+), 11 deletions(-) diff --git a/common/include/fwd-gr.h b/common/include/fwd-gr.h index 104fd0d34..c23387802 100644 --- a/common/include/fwd-gr.h +++ b/common/include/fwd-gr.h @@ -100,9 +100,12 @@ typedef std::unique_ptr grs_subcanvas_ptr; class grs_main_bitmap; typedef std::unique_ptr grs_bitmap_ptr; +uint_fast32_t gr_list_modes(array &modes); + } -uint_fast32_t gr_list_modes(array &modes); +#if defined(DXX_BUILD_DESCENT_I) || defined(DXX_BUILD_DESCENT_II) +inline namespace dsx { int gr_set_mode(screen_mode mode); int gr_init(); @@ -110,6 +113,8 @@ int gr_init(); void gr_set_attributes(); #endif void gr_close(); +} +#endif inline namespace dcx { @@ -343,9 +348,11 @@ void gr_palette_step_up(int r, int g, int b); // best matches the input. color_t gr_find_closest_color(int r, int g, int b); int gr_find_closest_color_15bpp(int rgb); +void gr_flip(); } -void gr_flip(); +#if defined(DXX_BUILD_DESCENT_I) || defined(DXX_BUILD_DESCENT_II) +inline namespace dsx { /* * must return 0 if windowed, 1 if fullscreen @@ -357,9 +364,14 @@ int gr_check_fullscreen(); * check_fullscreen immediatly after) */ void gr_toggle_fullscreen(); + +} +#endif +inline namespace dcx { void ogl_do_palfx(); void ogl_init_pixel_buffers(unsigned w, unsigned h); void ogl_close_pixel_buffers(); +} void ogl_cache_polymodel_textures(int model_num);; #endif diff --git a/common/include/internal.h b/common/include/internal.h index 1ec388b6d..dbc79ebc4 100644 --- a/common/include/internal.h +++ b/common/include/internal.h @@ -21,9 +21,11 @@ void ogl_init_texture_list_internal(void); void ogl_smash_texture_list_internal(void); void ogl_vivify_texture_list_internal(void); +inline namespace dcx { extern int linedotscale; extern int GL_TEXTURE_2D_enabled; +} #define OGL_SET_FEATURE_STATE(G,V,F) static_cast(G != V && (G = V, F, 0)) #define OGL_ENABLE(a) OGL_SET_FEATURE_STATE(GL_##a##_enabled, 1, glEnable(GL_##a)) @@ -35,6 +37,7 @@ extern int GL_TEXTURE_2D_enabled; //#define OGL_TEXENV(p,m) OGL_SETSTATE(p,m,glTexEnvi(GL_TEXTURE_ENV, p,m)); //#define OGL_TEXPARAM(p,m) OGL_SETSTATE(p,m,glTexParameteri(GL_TEXTURE_2D,p,m)) +inline namespace dcx { extern unsigned last_width,last_height; static inline void OGL_VIEWPORT(const unsigned x, const unsigned y, const unsigned w, const unsigned h) { @@ -45,10 +48,17 @@ static inline void OGL_VIEWPORT(const unsigned x, const unsigned y, const unsign last_height=h; } } +} + +#if defined(DXX_BUILD_DESCENT_I) || defined(DXX_BUILD_DESCENT_II) +inline namespace dsx { //platform specific funcs extern void ogl_swap_buffers_internal(void); +} +#endif + //whee #define CPAL2Tr(c) ((gr_current_pal[c].r)/63.0) #define CPAL2Tg(c) ((gr_current_pal[c].g)/63.0) diff --git a/common/include/ogl_init.h b/common/include/ogl_init.h index dee5048a3..045c05556 100644 --- a/common/include/ogl_init.h +++ b/common/include/ogl_init.h @@ -78,11 +78,9 @@ void ogl_init_texture(ogl_texture &t, int w, int h, int flags); void ogl_init_shared_palette(void); -extern int active_texture_unit; +inline namespace dcx { extern GLfloat ogl_maxanisotropy; -void ogl_setActiveTexture(int t); - #define OGL_FLAG_MIPMAP (1 << 0) #define OGL_FLAG_NOCOLOR (1 << 1) #define OGL_FLAG_ALPHA (1 << 31) // not required for ogl_loadbmtexture, since it uses the BM_FLAG_TRANSPARENT, but is needed for ogl_init_texture. @@ -92,7 +90,6 @@ void ogl_freebmtexture(grs_bitmap &bm); void ogl_start_frame(void); void ogl_end_frame(void); void ogl_set_screen_mode(void); -void ogl_cache_level_textures(void); void ogl_urect(int left, int top, int right, int bot); bool ogl_ubitmapm_cs(int x, int y,int dw, int dh, grs_bitmap &bm,int c, int scale); @@ -101,6 +98,12 @@ bool ogl_ubitblt(unsigned w, unsigned h, unsigned dx, unsigned dy, unsigned sx, void ogl_upixelc(int x, int y, int c); unsigned char ogl_ugpixel(const grs_bitmap &bitmap, unsigned x, unsigned y); void ogl_ulinec(int left, int top, int right, int bot, int c); +} +#if defined(DXX_BUILD_DESCENT_I) || defined(DXX_BUILD_DESCENT_II) +inline namespace dsx { +void ogl_cache_level_textures(); +} +#endif #include "3d.h" void _g3_draw_tmap_2(unsigned nv, const g3s_point *const *const pointlist, const g3s_uvl *uvl_list, const g3s_lrgb *light_rgb, grs_bitmap *bmbot, grs_bitmap *bm, int orient); @@ -117,9 +120,11 @@ static inline void g3_draw_tmap_2(unsigned nv, const array &poi } void ogl_draw_vertex_reticle(int cross,int primary,int secondary,int color,int alpha,int size_offs); +inline namespace dcx { void ogl_toggle_depth_test(int enable); void ogl_set_blending(); unsigned pow2ize(unsigned x);//from ogl.c +} #endif diff --git a/common/include/palette.h b/common/include/palette.h index 46a34eb15..537c75eec 100644 --- a/common/include/palette.h +++ b/common/include/palette.h @@ -55,9 +55,9 @@ void copy_diminish_palette(palette_array_t &palette, const ubyte *p); void diminish_palette(palette_array_t &palette); extern void gr_palette_set_gamma( int gamma ); extern int gr_palette_get_gamma(); +void gr_palette_load( palette_array_t &pal ); } #endif -void gr_palette_load( palette_array_t &pal ); inline namespace dcx { color_t gr_find_closest_color_current( int r, int g, int b ); } diff --git a/common/main/game.h b/common/main/game.h index 5117a0cc9..5ae83a58d 100644 --- a/common/main/game.h +++ b/common/main/game.h @@ -159,9 +159,15 @@ extern void stop_time(void); extern void start_time(void); extern void reset_time(void); // called when starting level +#if defined(DXX_BUILD_DESCENT_I) || defined(DXX_BUILD_DESCENT_II) +inline namespace dsx { + // If automap_flag == 1, then call automap routine to write message. extern void save_screen_shot(int automap_flag); +} +#endif + enum cockpit_mode_t { //valid modes for cockpit diff --git a/similar/arch/ogl/gr.cpp b/similar/arch/ogl/gr.cpp index 5a3085d76..7cf01c039 100644 --- a/similar/arch/ogl/gr.cpp +++ b/similar/arch/ogl/gr.cpp @@ -80,6 +80,8 @@ using std::max; +inline namespace dcx { + static int ogl_brightness_r, ogl_brightness_g, ogl_brightness_b; #ifdef OGLES @@ -104,6 +106,8 @@ static int sdl_no_modeswitch; enum { sdl_no_modeswitch = 0 }; #endif +} + #ifdef OGLES static EGLDisplay eglDisplay=EGL_NO_DISPLAY; static EGLConfig eglConfig; @@ -128,6 +132,8 @@ static bool TestEGLError(const char* pszLocation) } #endif +inline namespace dsx { + void ogl_swap_buffers_internal(void) { #ifdef OGLES @@ -571,6 +577,10 @@ static void ogl_get_verinfo(void) #endif } +} + +inline namespace dcx { + // returns possible (fullscreen) resolutions if any. uint_fast32_t gr_list_modes(array &gsmodes) { @@ -614,6 +624,10 @@ uint_fast32_t gr_list_modes(array &gsmodes) } } +} + +inline namespace dsx { + static int gr_check_mode(const screen_mode mode) { if (sdl_no_modeswitch == 0) { @@ -811,6 +825,10 @@ void gr_close() #endif } +} + +inline namespace dcx { + void ogl_upixelc(int x, int y, int c) { GLfloat vertex_array[] = { @@ -960,8 +978,6 @@ void ogl_do_palfx(void) glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); } -inline namespace dcx { - static int ogl_brightness_ok; static int old_b_r, old_b_g, old_b_b; @@ -991,6 +1007,8 @@ void gr_palette_step_up(int r, int g, int b) } +inline namespace dsx { + #undef min using std::min; @@ -1093,3 +1111,5 @@ void save_screen_shot(int automap_flag) write_bmp(savename, grd_curscreen->get_screen_width(), grd_curscreen->get_screen_height()); } + +} diff --git a/similar/arch/ogl/ogl.cpp b/similar/arch/ogl/ogl.cpp index 5bcae9e85..140932b6c 100644 --- a/similar/arch/ogl/ogl.cpp +++ b/similar/arch/ogl/ogl.cpp @@ -83,6 +83,8 @@ using std::max; #define sinf(a) sin(a) #endif +inline namespace dcx { + static std::unique_ptr texbuf; static palette_array_t *ogl_pal = &gr_palette; @@ -119,6 +121,8 @@ static void ogl_loadbmtexture(grs_bitmap &bm) ogl_loadbmtexture_f(bm, GameCfg.TexFilt); } +} + #ifdef OGLES // Replacement for gluPerspective static void perspective(double fovy, double aspect, double zNear, double zFar) @@ -382,6 +386,8 @@ static void ogl_cache_weapon_textures(int weapon_type) } } +inline namespace dsx { + void ogl_cache_level_textures(void) { int side; @@ -539,6 +545,8 @@ void ogl_cache_level_textures(void) r_cachedtexcount = r_texcount; } +} + inline namespace dcx { void g3_draw_line(const g3s_point &p0,const g3s_point &p1) @@ -1127,8 +1135,6 @@ void g3_draw_bitmap(const vms_vector &pos, const fix iwidth, const fix iheight, glDisableClientState(GL_TEXTURE_COORD_ARRAY); } -} - /* * Movies * Since this function will create a new texture each call, mipmapping can be very GPU intensive - so it has an optional setting for texture filtering. @@ -1773,3 +1779,5 @@ bool ogl_ubitmapm_cs(int x, int y,int dw, int dh, grs_bitmap &bm,int c, int scal return 0; } + +} diff --git a/similar/arch/sdl/gr.cpp b/similar/arch/sdl/gr.cpp index 59800cd73..25cf4ea54 100644 --- a/similar/arch/sdl/gr.cpp +++ b/similar/arch/sdl/gr.cpp @@ -49,6 +49,8 @@ void gr_flip() SDL_Flip(screen); } +inline namespace dcx { + // returns possible (fullscreen) resolutions if any. uint_fast32_t gr_list_modes(array &gsmodes) { @@ -85,6 +87,8 @@ uint_fast32_t gr_list_modes(array &gsmodes) } } +} + int gr_set_mode(screen_mode mode) { screen=NULL;