| 1 |
/* |
| 2 |
* This file is part of the DXX-Rebirth project <https://www.dxx-rebirth.com/>. |
| 3 |
* It is copyright by its individual contributors, as recorded in the |
| 4 |
* project's Git history. See COPYING.txt at the top level for license |
| 5 |
* terms and a link to the Git history. |
| 6 |
*/ |
| 7 |
/* prototypes for function calls between files within the OpenGL module */ |
| 8 |
|
| 9 |
#pragma once |
| 10 |
|
| 11 |
#include "dxxsconf.h" |
| 12 |
#if DXX_USE_OGL |
| 13 |
#include "ogl_init.h" // interface to OpenGL module |
| 14 |
#include "ogl_extensions.h" |
| 15 |
#include "gr.h" |
| 16 |
|
| 17 |
namespace dcx { |
| 18 |
void ogl_init_texture_list_internal(void); |
| 19 |
void ogl_smash_texture_list_internal(void); |
| 20 |
|
| 21 |
extern int linedotscale; |
| 22 |
|
| 23 |
extern int GL_TEXTURE_2D_enabled; |
| 24 |
|
| 25 |
static constexpr const rgb_t &CPAL2T(const color_palette_index c) |
| 26 |
{ |
| 27 |
return gr_current_pal[static_cast<std::size_t>(c)]; |
| 28 |
} |
| 29 |
|
| 30 |
static constexpr GLfloat CPAL2Tr(const color_palette_index c) |
| 31 |
{ |
| 32 |
return CPAL2T(c).r / 63.0; |
| 33 |
} |
| 34 |
|
| 35 |
static constexpr GLfloat CPAL2Tg(const color_palette_index c) |
| 36 |
{ |
| 37 |
return CPAL2T(c).g / 63.0; |
| 38 |
} |
| 39 |
|
| 40 |
static constexpr GLfloat CPAL2Tb(const color_palette_index c) |
| 41 |
{ |
| 42 |
return CPAL2T(c).b / 63.0; |
| 43 |
} |
| 44 |
|
| 45 |
} |
| 46 |
|
| 47 |
#define OGL_SET_FEATURE_STATE(G,V,F) static_cast<void>(G != V && (G = V, F, 0)) |
| 48 |
#define OGL_ENABLE(a) OGL_SET_FEATURE_STATE(GL_##a##_enabled, 1, glEnable(GL_##a)) |
| 49 |
#define OGL_DISABLE(a) OGL_SET_FEATURE_STATE(GL_##a##_enabled, 0, glDisable(GL_##a)) |
| 50 |
|
| 51 |
//#define OGL_TEXCLAMP() OGL_ENABLE2(GL_texclamp,glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);) |
| 52 |
//#define OGL_TEXREPEAT() OGL_DISABLE2(GL_texclamp,glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);) |
| 53 |
//#define OGL_SETSTATE(a,s,f) {if (a ## _state!=s) {f;a ## _state=s;}} |
| 54 |
//#define OGL_TEXENV(p,m) OGL_SETSTATE(p,m,glTexEnvi(GL_TEXTURE_ENV, p,m)); |
| 55 |
//#define OGL_TEXPARAM(p,m) OGL_SETSTATE(p,m,glTexParameteri(GL_TEXTURE_2D,p,m)) |
| 56 |
|
| 57 |
namespace dcx { |
| 58 |
extern unsigned last_width,last_height; |
| 59 |
static inline void OGL_VIEWPORT(const unsigned x, const unsigned y, const unsigned w, const unsigned h) |
| 60 |
{ |
| 61 |
if (w!=last_width || h!=last_height) |
| 62 |
{ |
| 63 |
last_width = w; |
| 64 |
last_height = h; |
| 65 |
glViewport(x,grd_curscreen->sc_canvas.cv_bitmap.bm_h-y-h,w,h); |
| 66 |
} |
| 67 |
} |
| 68 |
|
| 69 |
#ifdef DXX_BUILD_DESCENT |
| 70 |
//platform specific funcs |
| 71 |
void ogl_swap_buffers_internal(); |
| 72 |
#endif |
| 73 |
} |
| 74 |
|
| 75 |
#endif |