mirror of
https://github.com/kevinbentley/Descent3.git
synced 2025-01-22 11:28:56 +00:00
Minor cleanups to HardwareOpenGL.cpp
This commit is contained in:
parent
1de5da7777
commit
4aa17f36d4
@ -477,7 +477,7 @@ void rend_Close();
|
||||
// Draws a scaled 2d bitmap to our buffer
|
||||
// NOTE: scripts are expecting the old prototype that has a zvalue (which is ignored) before color
|
||||
void rend_DrawScaledBitmap(int x1, int y1, int x2, int y2, int bm, float u0, float v0, float u1, float v1,
|
||||
int color = -1, float *alphas = NULL);
|
||||
int color = -1, const float *alphas = nullptr);
|
||||
|
||||
// Sets the state of bilinear filtering for our textures
|
||||
void rend_SetFiltering(int8_t state);
|
||||
@ -535,7 +535,7 @@ void rend_SetAlphaValue(uint8_t val);
|
||||
void rend_SetAlphaFactor(float val);
|
||||
|
||||
// Returns the current Alpha factor
|
||||
float rend_GetAlphaFactor(void);
|
||||
float rend_GetAlphaFactor();
|
||||
|
||||
// Sets the wrap parameter
|
||||
void rend_SetWrapType(wrap_type val);
|
||||
|
@ -18,13 +18,15 @@
|
||||
|
||||
// TODO: This is missing a good way of overriding base behavior (like, you know, method overrides...)
|
||||
|
||||
#include <algorithm>
|
||||
#include <cstring>
|
||||
|
||||
#include "pserror.h"
|
||||
#include "mono.h"
|
||||
#include "3d.h"
|
||||
#include "renderer.h"
|
||||
#include "bitmap.h"
|
||||
#include "grdefs.h"
|
||||
#include <cstring>
|
||||
|
||||
#include "HardwareInternal.h"
|
||||
#include "lightmap.h"
|
||||
@ -72,7 +74,7 @@ float rend_GetAlphaMultiplier() {
|
||||
case AT_SATURATE_VERTEX:
|
||||
case AT_SATURATE_TEXTURE_VERTEX:
|
||||
case AT_SPECULAR:
|
||||
return 1.0;
|
||||
return 1.0f;
|
||||
case AT_CONSTANT:
|
||||
case AT_CONSTANT_TEXTURE:
|
||||
case AT_CONSTANT_TEXTURE_VERTEX:
|
||||
@ -81,10 +83,10 @@ float rend_GetAlphaMultiplier() {
|
||||
case AT_LIGHTMAP_BLEND_SATURATE:
|
||||
case AT_SATURATE_TEXTURE:
|
||||
case AT_SATURATE_CONSTANT_VERTEX:
|
||||
return gpu_state.cur_alpha / 255.0;
|
||||
return gpu_state.cur_alpha / 255.0f;
|
||||
default:
|
||||
// Int3(); // no type defined,get jason
|
||||
return 0;
|
||||
return 0.0f;
|
||||
}
|
||||
}
|
||||
|
||||
@ -146,20 +148,20 @@ void rend_DrawFontCharacter(int bm_handle, int x1, int y1, int x2, int y2, float
|
||||
pnts[i].p3_flags = PF_PROJECTED;
|
||||
ptr_pnts[i] = &pnts[i];
|
||||
}
|
||||
pnts[0].p3_sx = x1;
|
||||
pnts[0].p3_sy = y1;
|
||||
pnts[0].p3_sx = (float)x1;
|
||||
pnts[0].p3_sy = (float)y1;
|
||||
pnts[0].p3_u = u;
|
||||
pnts[0].p3_v = v;
|
||||
pnts[1].p3_sx = x2;
|
||||
pnts[1].p3_sy = y1;
|
||||
pnts[1].p3_sx = (float)x2;
|
||||
pnts[1].p3_sy = (float)y1;
|
||||
pnts[1].p3_u = u + w;
|
||||
pnts[1].p3_v = v;
|
||||
pnts[2].p3_sx = x2;
|
||||
pnts[2].p3_sy = y2;
|
||||
pnts[2].p3_sx = (float)x2;
|
||||
pnts[2].p3_sy = (float)y2;
|
||||
pnts[2].p3_u = u + w;
|
||||
pnts[2].p3_v = v + h;
|
||||
pnts[3].p3_sx = x1;
|
||||
pnts[3].p3_sy = y2;
|
||||
pnts[3].p3_sx = (float)x1;
|
||||
pnts[3].p3_sy = (float)y2;
|
||||
pnts[3].p3_u = u;
|
||||
pnts[3].p3_v = v + h;
|
||||
rend_DrawPolygon2D(bm_handle, ptr_pnts, 4);
|
||||
@ -188,15 +190,11 @@ void rend_SetZBias(float z_bias) {
|
||||
// Sets the overall alpha scale factor (all alpha values are scaled by this value)
|
||||
// usefull for motion blur effect
|
||||
void rend_SetAlphaFactor(float val) {
|
||||
if (val < 0.0f)
|
||||
val = 0.0f;
|
||||
if (val > 1.0f)
|
||||
val = 1.0f;
|
||||
gpu_Alpha_factor = val;
|
||||
gpu_Alpha_factor = std::clamp(val, 0.0f, 1.0f);
|
||||
}
|
||||
|
||||
// Returns the current Alpha factor
|
||||
float rend_GetAlphaFactor(void) { return gpu_Alpha_factor; }
|
||||
float rend_GetAlphaFactor() { return gpu_Alpha_factor; }
|
||||
|
||||
// Gets a pointer to a linear frame buffer
|
||||
void rend_GetLFBLock(renderer_lfb *lfb) {}
|
||||
@ -218,7 +216,7 @@ void rend_GetProjectionScreenParameters(int &screenLX, int &screenTY, int &scree
|
||||
}
|
||||
|
||||
// Returns the aspect ratio of the physical screen
|
||||
float rend_GetAspectRatio(void) {
|
||||
float rend_GetAspectRatio() {
|
||||
float aspect_ratio = (float)((3.0f * gpu_state.screen_width) / (4.0f * gpu_state.screen_height));
|
||||
return aspect_ratio;
|
||||
}
|
||||
@ -228,14 +226,14 @@ void rend_DrawLFBBitmap(int sx, int sy, int w, int h, int dx, int dy, uint16_t *
|
||||
|
||||
// draws a scaled 2d bitmap to our buffer
|
||||
void rend_DrawScaledBitmap(int x1, int y1, int x2, int y2, int bm, float u0, float v0, float u1, float v1, int color,
|
||||
float *alphas) {
|
||||
const float *alphas) {
|
||||
g3Point *ptr_pnts[4];
|
||||
g3Point pnts[4];
|
||||
float r, g, b;
|
||||
if (color != -1) {
|
||||
r = GR_COLOR_RED(color) / 255.0;
|
||||
g = GR_COLOR_GREEN(color) / 255.0;
|
||||
b = GR_COLOR_BLUE(color) / 255.0;
|
||||
r = GR_COLOR_RED(color) / 255.0f;
|
||||
g = GR_COLOR_GREEN(color) / 255.0f;
|
||||
b = GR_COLOR_BLUE(color) / 255.0f;
|
||||
}
|
||||
for (int i = 0; i < 4; i++) {
|
||||
if (color == -1)
|
||||
@ -253,20 +251,20 @@ void rend_DrawScaledBitmap(int x1, int y1, int x2, int y2, int bm, float u0, flo
|
||||
pnts[i].p3_flags = PF_PROJECTED;
|
||||
}
|
||||
|
||||
pnts[0].p3_sx = x1;
|
||||
pnts[0].p3_sy = y1;
|
||||
pnts[0].p3_sx = (float)x1;
|
||||
pnts[0].p3_sy = (float)y1;
|
||||
pnts[0].p3_u = u0;
|
||||
pnts[0].p3_v = v0;
|
||||
pnts[1].p3_sx = x2;
|
||||
pnts[1].p3_sy = y1;
|
||||
pnts[1].p3_sx = (float)x2;
|
||||
pnts[1].p3_sy = (float)y1;
|
||||
pnts[1].p3_u = u1;
|
||||
pnts[1].p3_v = v0;
|
||||
pnts[2].p3_sx = x2;
|
||||
pnts[2].p3_sy = y2;
|
||||
pnts[2].p3_sx = (float)x2;
|
||||
pnts[2].p3_sy = (float)y2;
|
||||
pnts[2].p3_u = u1;
|
||||
pnts[2].p3_v = v1;
|
||||
pnts[3].p3_sx = x1;
|
||||
pnts[3].p3_sy = y2;
|
||||
pnts[3].p3_sx = (float)x1;
|
||||
pnts[3].p3_sy = (float)y2;
|
||||
pnts[3].p3_u = u0;
|
||||
pnts[3].p3_v = v1;
|
||||
ptr_pnts[0] = &pnts[0];
|
||||
@ -408,10 +406,10 @@ void rend_PreUploadTextureToCard(int handle, int map_type) {}
|
||||
void rend_FreePreUploadedTexture(int handle, int map_type) {}
|
||||
|
||||
// Returns 1 if there is mid video memory, 2 if there is low vid memory, or 0 if there is large vid memory
|
||||
int rend_LowVidMem(void) { return 0; }
|
||||
int rend_LowVidMem() { return 0; }
|
||||
|
||||
// Returns 1 if the renderer supports bumpmapping
|
||||
int rend_SupportsBumpmapping(void) { return 0; }
|
||||
int rend_SupportsBumpmapping() { return 0; }
|
||||
|
||||
// Sets a bumpmap to be rendered, or turns off bumpmapping altogether
|
||||
void rend_SetBumpmapReadyState(int state, int map) {}
|
||||
@ -453,8 +451,7 @@ void rend_DrawPolygon2D(int handle, g3Point **p, int nv) {
|
||||
PosColorUVVertex *vData = &vArray[0];
|
||||
|
||||
// Specify our coordinates
|
||||
int i;
|
||||
for (i = 0; i < nv; ++i, ++vData) {
|
||||
for (int i = 0; i < nv; ++i, ++vData) {
|
||||
g3Point *pnt = p[i];
|
||||
|
||||
vData->color = DeterminePointColor(pnt, false, true);
|
||||
@ -498,9 +495,6 @@ color_array DeterminePointColor(g3Point const* pnt, bool disableGouraud, bool ch
|
||||
// Uses bitmap "handle" as a texture
|
||||
void rend_DrawPolygon3D(int handle, g3Point **p, int nv, int map_type) {
|
||||
g3Point *pnt;
|
||||
int i;
|
||||
float fr, fg, fb;
|
||||
float alpha;
|
||||
|
||||
ASSERT(nv < 100);
|
||||
|
||||
@ -523,7 +517,7 @@ void rend_DrawPolygon3D(int handle, g3Point **p, int nv, int map_type) {
|
||||
PosColorUVVertex *vData = &vArray[0];
|
||||
|
||||
// Specify our coordinates
|
||||
for (i = 0; i < nv; i++, vData++) {
|
||||
for (int i = 0; i < nv; i++, vData++) {
|
||||
pnt = p[i];
|
||||
|
||||
// all points should be original
|
||||
@ -556,9 +550,8 @@ void rend_DrawPolygon3D(int handle, g3Point **p, int nv, int map_type) {
|
||||
// as a texture
|
||||
void rend_DrawMultitexturePolygon3D(int handle, g3Point **p, int nv, int map_type) {
|
||||
g3Point *pnt;
|
||||
int i;
|
||||
|
||||
float one_over_square_res = 1.0 / GameLightmaps[gpu_Overlay_map].square_res;
|
||||
float one_over_square_res = 1.0f / GameLightmaps[gpu_Overlay_map].square_res;
|
||||
float xscalar = (float)GameLightmaps[gpu_Overlay_map].width * one_over_square_res;
|
||||
float yscalar = (float)GameLightmaps[gpu_Overlay_map].height * one_over_square_res;
|
||||
|
||||
@ -567,7 +560,7 @@ void rend_DrawMultitexturePolygon3D(int handle, g3Point **p, int nv, int map_typ
|
||||
PosColorUV2Vertex *vData = &vArray2[0];
|
||||
|
||||
// Specify our coordinates
|
||||
for (i = 0; i < nv; i++, vData++) {
|
||||
for (int i = 0; i < nv; i++, vData++) {
|
||||
pnt = p[i];
|
||||
ASSERT(pnt->p3_flags & PF_ORIGPOINT);
|
||||
|
||||
|
@ -63,7 +63,6 @@ float Z_bias = 0.0f;
|
||||
uint8_t Renderer_close_flag = 0;
|
||||
extern uint8_t Renderer_initted;
|
||||
renderer_type Renderer_type = RENDERER_OPENGL;
|
||||
int WindowGL = 0;
|
||||
|
||||
struct Renderer {
|
||||
Renderer() : shader_{shaders::vertex, shaders::fragment, {
|
||||
@ -154,26 +153,25 @@ std::optional<Renderer> gRenderer;
|
||||
|
||||
#define CHECK_ERROR(x)
|
||||
|
||||
SDL_Window *GSDLWindow = NULL;
|
||||
SDL_GLContext GSDLGLContext = NULL;
|
||||
SDL_Window *GSDLWindow = nullptr;
|
||||
SDL_GLContext GSDLGLContext = nullptr;
|
||||
char loadedLibrary[_MAX_PATH];
|
||||
|
||||
#define GET_WRAP_STATE(x) (x >> 4)
|
||||
#define GET_FILTER_STATE(x) (x & 0x0f)
|
||||
#define GET_WRAP_STATE(x) ((x) >> 4)
|
||||
#define GET_FILTER_STATE(x) ((x) & 0x0f)
|
||||
|
||||
#define SET_WRAP_STATE(x, s) \
|
||||
{ \
|
||||
x &= 0x0F; \
|
||||
x |= (s << 4); \
|
||||
(x) &= 0x0F; \
|
||||
(x) |= ((s) << 4); \
|
||||
}
|
||||
#define SET_FILTER_STATE(x, s) \
|
||||
{ \
|
||||
x &= 0xF0; \
|
||||
x |= (s); \
|
||||
(x) &= 0xF0; \
|
||||
(x) |= (s); \
|
||||
}
|
||||
|
||||
// OpenGL Stuff
|
||||
static int OpenGL_window_initted = 0;
|
||||
static int OpenGL_polys_drawn = 0;
|
||||
static int OpenGL_verts_processed = 0;
|
||||
static int OpenGL_uploads = 0;
|
||||
@ -190,28 +188,28 @@ extern int gpu_last_uploaded;
|
||||
extern float gpu_Alpha_factor;
|
||||
extern float gpu_Alpha_multiplier;
|
||||
|
||||
uint16_t *OpenGL_bitmap_remap = NULL;
|
||||
uint16_t *OpenGL_lightmap_remap = NULL;
|
||||
uint8_t *OpenGL_bitmap_states = NULL;
|
||||
uint8_t *OpenGL_lightmap_states = NULL;
|
||||
uint16_t *OpenGL_bitmap_remap = nullptr;
|
||||
uint16_t *OpenGL_lightmap_remap = nullptr;
|
||||
uint8_t *OpenGL_bitmap_states = nullptr;
|
||||
uint8_t *OpenGL_lightmap_states = nullptr;
|
||||
|
||||
uint32_t *opengl_Upload_data = NULL;
|
||||
uint32_t *opengl_Translate_table = NULL;
|
||||
uint32_t *opengl_4444_translate_table = NULL;
|
||||
uint32_t *opengl_Upload_data = nullptr;
|
||||
uint32_t *opengl_Translate_table = nullptr;
|
||||
uint32_t *opengl_4444_translate_table = nullptr;
|
||||
|
||||
uint16_t *opengl_packed_Upload_data = NULL;
|
||||
uint16_t *opengl_packed_Translate_table = NULL;
|
||||
uint16_t *opengl_packed_4444_translate_table = NULL;
|
||||
uint16_t *opengl_packed_Upload_data = nullptr;
|
||||
uint16_t *opengl_packed_Translate_table = nullptr;
|
||||
uint16_t *opengl_packed_4444_translate_table = nullptr;
|
||||
|
||||
extern rendering_state gpu_state;
|
||||
extern renderer_preferred_state gpu_preferred_state;
|
||||
|
||||
bool OpenGL_multitexture_state = false;
|
||||
module *OpenGLDLLHandle = NULL;
|
||||
module *OpenGLDLLHandle = nullptr;
|
||||
int Already_loaded = 0;
|
||||
bool opengl_Blending_on = 0;
|
||||
bool opengl_Blending_on = false;
|
||||
|
||||
static oeApplication *ParentApplication = NULL;
|
||||
static oeApplication *ParentApplication = nullptr;
|
||||
|
||||
static GLuint GOpenGLFBO = 0;
|
||||
static GLuint GOpenGLRBOColor = 0;
|
||||
@ -262,7 +260,7 @@ int opengl_MakeTextureObject(int tn) {
|
||||
return num;
|
||||
}
|
||||
|
||||
int opengl_InitCache(void) {
|
||||
int opengl_InitCache() {
|
||||
|
||||
OpenGL_bitmap_remap = (uint16_t *)mem_malloc(MAX_BITMAPS * 2);
|
||||
ASSERT(OpenGL_bitmap_remap);
|
||||
@ -341,7 +339,7 @@ void opengl_SetDefaults() {
|
||||
|
||||
extern renderer_preferred_state Render_preferred_state;
|
||||
|
||||
int opengl_Setup(oeApplication *app, int *width, int *height) {
|
||||
int opengl_Setup(oeApplication *app, const int *width, const int *height) {
|
||||
int winw = Video_res_list[Game_video_resolution].width;
|
||||
int winh = Video_res_list[Game_video_resolution].height;
|
||||
|
||||
@ -434,7 +432,7 @@ int opengl_Setup(oeApplication *app, int *width, int *height) {
|
||||
if (!GSDLGLContext) {
|
||||
mprintf(0, "OpenGL: OpenGL context creation failed: %s", SDL_GetError());
|
||||
SDL_DestroyWindow(GSDLWindow);
|
||||
GSDLWindow = NULL;
|
||||
GSDLWindow = nullptr;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@ -502,8 +500,8 @@ int opengl_Setup(oeApplication *app, int *width, int *height) {
|
||||
GOpenGLFBO = GOpenGLRBOColor = GOpenGLRBODepth = 0;
|
||||
SDL_GL_DeleteContext(GSDLGLContext);
|
||||
SDL_DestroyWindow(GSDLWindow);
|
||||
GSDLGLContext = NULL;
|
||||
GSDLWindow = NULL;
|
||||
GSDLGLContext = nullptr;
|
||||
GSDLWindow = nullptr;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -538,12 +536,10 @@ int opengl_Init(oeApplication *app, renderer_preferred_state *pref_state) {
|
||||
gpu_preferred_state = *pref_state;
|
||||
}
|
||||
|
||||
if (app != NULL) {
|
||||
if (app != nullptr) {
|
||||
ParentApplication = app;
|
||||
}
|
||||
|
||||
int windowX = 0, windowY = 0;
|
||||
|
||||
/***********************************************************
|
||||
* LINUX OPENGL
|
||||
***********************************************************
|
||||
@ -706,15 +702,15 @@ void opengl_Close(const bool just_resizing) {
|
||||
gRenderer.reset();
|
||||
|
||||
if (GSDLGLContext) {
|
||||
SDL_GL_MakeCurrent(NULL, NULL);
|
||||
SDL_GL_MakeCurrent(nullptr, nullptr);
|
||||
SDL_GL_DeleteContext(GSDLGLContext);
|
||||
GSDLGLContext = NULL;
|
||||
GSDLGLContext = nullptr;
|
||||
GOpenGLFBOWidth = GOpenGLFBOHeight = GOpenGLFBO = GOpenGLRBOColor = GOpenGLRBODepth = 0;
|
||||
}
|
||||
|
||||
if (!just_resizing && GSDLWindow) {
|
||||
SDL_DestroyWindow(GSDLWindow);
|
||||
GSDLWindow = NULL;
|
||||
GSDLWindow = nullptr;
|
||||
}
|
||||
|
||||
|
||||
@ -728,9 +724,9 @@ void opengl_Close(const bool just_resizing) {
|
||||
if (opengl_packed_4444_translate_table) {
|
||||
mem_free(opengl_packed_4444_translate_table);
|
||||
}
|
||||
opengl_packed_Upload_data = NULL;
|
||||
opengl_packed_Translate_table = NULL;
|
||||
opengl_packed_4444_translate_table = NULL;
|
||||
opengl_packed_Upload_data = nullptr;
|
||||
opengl_packed_Translate_table = nullptr;
|
||||
opengl_packed_4444_translate_table = nullptr;
|
||||
} else {
|
||||
if (opengl_Upload_data)
|
||||
mem_free(opengl_Upload_data);
|
||||
@ -738,9 +734,9 @@ void opengl_Close(const bool just_resizing) {
|
||||
mem_free(opengl_Translate_table);
|
||||
if (opengl_4444_translate_table)
|
||||
mem_free(opengl_4444_translate_table);
|
||||
opengl_Upload_data = NULL;
|
||||
opengl_Translate_table = NULL;
|
||||
opengl_4444_translate_table = NULL;
|
||||
opengl_Upload_data = nullptr;
|
||||
opengl_Translate_table = nullptr;
|
||||
opengl_4444_translate_table = nullptr;
|
||||
}
|
||||
|
||||
if (OpenGL_cache_initted) {
|
||||
@ -791,8 +787,6 @@ void opengl_TranslateBitmapToOpenGL(int texnum, int bm_handle, int map_type, int
|
||||
OpenGL_last_bound[tn] = texnum;
|
||||
}
|
||||
|
||||
int i;
|
||||
|
||||
if (OpenGL_packed_pixels) {
|
||||
if (map_type == MAP_TYPE_LIGHTMAP) {
|
||||
uint16_t *left_data = (uint16_t *)opengl_packed_Upload_data;
|
||||
@ -841,10 +835,10 @@ void opengl_TranslateBitmapToOpenGL(int texnum, int bm_handle, int map_type, int
|
||||
if (bm_format(bm_handle) == BITMAP_FORMAT_4444) {
|
||||
// Do 4444
|
||||
if (bm_mipped(bm_handle)) {
|
||||
for (i = 0; i < w * h; i++)
|
||||
for (int i = 0; i < w * h; i++)
|
||||
opengl_packed_Upload_data[i] = 0xf | (opengl_packed_4444_translate_table[bm_ptr[i]]);
|
||||
} else {
|
||||
for (i = 0; i < w * h; i++)
|
||||
for (int i = 0; i < w * h; i++)
|
||||
opengl_packed_Upload_data[i] = opengl_packed_4444_translate_table[bm_ptr[i]];
|
||||
}
|
||||
|
||||
@ -857,7 +851,7 @@ void opengl_TranslateBitmapToOpenGL(int texnum, int bm_handle, int map_type, int
|
||||
}
|
||||
} else {
|
||||
// Do 1555
|
||||
for (i = 0; i < w * h; i++) {
|
||||
for (int i = 0; i < w * h; i++) {
|
||||
opengl_packed_Upload_data[i] = opengl_packed_Translate_table[bm_ptr[i]];
|
||||
}
|
||||
|
||||
@ -907,16 +901,16 @@ void opengl_TranslateBitmapToOpenGL(int texnum, int bm_handle, int map_type, int
|
||||
// Do 4444
|
||||
|
||||
if (bm_mipped(bm_handle)) {
|
||||
for (i = 0; i < w * h; i++)
|
||||
for (int i = 0; i < w * h; i++)
|
||||
opengl_Upload_data[i] = INTEL_INT((255 << 24)) | opengl_4444_translate_table[bm_ptr[i]];
|
||||
} else {
|
||||
for (i = 0; i < w * h; i++)
|
||||
for (int i = 0; i < w * h; i++)
|
||||
opengl_Upload_data[i] = opengl_4444_translate_table[bm_ptr[i]];
|
||||
}
|
||||
} else {
|
||||
// Do 1555
|
||||
|
||||
for (i = 0; i < w * h; i++)
|
||||
for (int i = 0; i < w * h; i++)
|
||||
opengl_Upload_data[i] = opengl_Translate_table[bm_ptr[i]];
|
||||
}
|
||||
|
||||
@ -1129,15 +1123,12 @@ void gpu_DrawFlatPolygon3D(g3Point **p, int nv) {
|
||||
|
||||
// Sets the gamma correction value
|
||||
void rend_SetGammaValue(float val) {
|
||||
// if( WindowGL )
|
||||
// return;
|
||||
|
||||
gpu_preferred_state.gamma = val;
|
||||
mprintf(0, "Setting gamma to %f\n", val);
|
||||
}
|
||||
|
||||
// Resets the texture cache
|
||||
void opengl_ResetCache(void) {
|
||||
void opengl_ResetCache() {
|
||||
if (OpenGL_cache_initted) {
|
||||
mem_free(OpenGL_lightmap_remap);
|
||||
mem_free(OpenGL_bitmap_remap);
|
||||
@ -1250,8 +1241,8 @@ void rend_SetMipState(int8_t mipstate) {}
|
||||
|
||||
// Init our renderer
|
||||
int rend_Init(renderer_type state, oeApplication *app, renderer_preferred_state *pref_state) {
|
||||
#ifndef DEDICATED_ONLY
|
||||
int retval = 0;
|
||||
#ifndef DEDICATED_ONLY
|
||||
rend_SetRendererType(state);
|
||||
if (!Renderer_initted) {
|
||||
if (!Renderer_close_flag) {
|
||||
@ -1262,42 +1253,22 @@ int rend_Init(renderer_type state, oeApplication *app, renderer_preferred_state
|
||||
Renderer_initted = 1;
|
||||
}
|
||||
|
||||
if (OpenGL_window_initted) {
|
||||
rend_CloseOpenGLWindow();
|
||||
OpenGL_window_initted = 0;
|
||||
}
|
||||
|
||||
mprintf(0, "Renderer init is set to %d\n", Renderer_initted);
|
||||
|
||||
#ifndef OEM_V3
|
||||
int flags = app->flags();
|
||||
if (flags & OEAPP_WINDOWED) {
|
||||
// initialize for windowed
|
||||
retval = rend_InitOpenGLWindow(app, pref_state);
|
||||
} else {
|
||||
// initialize for full screen
|
||||
retval = opengl_Init(app, pref_state);
|
||||
}
|
||||
retval = opengl_Init(app, pref_state);
|
||||
#endif
|
||||
|
||||
return retval;
|
||||
#else
|
||||
return 0;
|
||||
#endif // #ifdef DEDICATED_ONLY
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
void rend_Close(void) {
|
||||
void rend_Close() {
|
||||
mprintf(0, "CLOSE:Renderer init is set to %d\n", Renderer_initted);
|
||||
if (!Renderer_initted)
|
||||
return;
|
||||
|
||||
if (OpenGL_window_initted) {
|
||||
if (Renderer_type == RENDERER_OPENGL) {
|
||||
rend_CloseOpenGLWindow();
|
||||
}
|
||||
OpenGL_window_initted = 0;
|
||||
}
|
||||
|
||||
opengl_Close();
|
||||
|
||||
Renderer_initted = 0;
|
||||
@ -1440,7 +1411,7 @@ void rend_StartFrame(int x1, int y1, int x2, int y2, int clear_flags) {
|
||||
|
||||
|
||||
// Flips the screen
|
||||
void rend_Flip(void) {
|
||||
void rend_Flip() {
|
||||
#ifndef RELEASE
|
||||
int i;
|
||||
|
||||
@ -1500,7 +1471,7 @@ void rend_Flip(void) {
|
||||
}
|
||||
}
|
||||
|
||||
void rend_EndFrame(void) {}
|
||||
void rend_EndFrame() {}
|
||||
|
||||
// Sets the state of z-buffering to on or off
|
||||
void rend_SetZBufferState(int8_t state) {
|
||||
@ -1534,10 +1505,10 @@ void rend_ClearScreen(ddgr_color color) {
|
||||
}
|
||||
|
||||
// Clears the zbuffer for the screen
|
||||
void rend_ClearZBuffer(void) { dglClear(GL_DEPTH_BUFFER_BIT); }
|
||||
void rend_ClearZBuffer() { dglClear(GL_DEPTH_BUFFER_BIT); }
|
||||
|
||||
// Clears the zbuffer for the screen
|
||||
void rend_ResetCache(void) {
|
||||
void rend_ResetCache() {
|
||||
mprintf(0, "Resetting texture cache!\n");
|
||||
opengl_ResetCache();
|
||||
}
|
||||
@ -1556,7 +1527,7 @@ void rend_FillRect(ddgr_color color, int x1, int y1, int x2, int y2) {
|
||||
|
||||
dglEnable(GL_SCISSOR_TEST);
|
||||
dglScissor(x1, gpu_state.screen_height - (height + y1), width, height);
|
||||
dglClearColor((float)r / 255.0, (float)g / 255.0, (float)b / 255.0, 0);
|
||||
dglClearColor((float)r / 255.0f, (float)g / 255.0f, (float)b / 255.0f, 0);
|
||||
dglClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
|
||||
width = gpu_state.clip_x2 - gpu_state.clip_x1;
|
||||
@ -1764,7 +1735,7 @@ void rend_SetZBufferWriteMask(int state) {
|
||||
|
||||
int rend_ReInit() {
|
||||
opengl_Close(true);
|
||||
return opengl_Init(NULL, &gpu_preferred_state);
|
||||
return opengl_Init(nullptr, &gpu_preferred_state);
|
||||
}
|
||||
|
||||
// Takes a bitmap and blits it to the screen using linear frame buffer stuff
|
||||
@ -1800,15 +1771,12 @@ void rend_SetFrameBufferCopyState(bool state) {
|
||||
|
||||
// Gets OpenGL ready to work in a window
|
||||
int rend_InitOpenGLWindow(oeApplication *app, renderer_preferred_state *pref_state) {
|
||||
WindowGL = 1;
|
||||
return opengl_Init(app, pref_state);
|
||||
}
|
||||
|
||||
// Shuts down OpenGL in a window
|
||||
void rend_CloseOpenGLWindow(void) {
|
||||
void rend_CloseOpenGLWindow() {
|
||||
opengl_Close();
|
||||
WindowGL = 0;
|
||||
OpenGL_window_initted = 0;
|
||||
mprintf(1, "SHUTTING DOWN WINDOWED OPENGL!");
|
||||
}
|
||||
|
||||
@ -1825,12 +1793,12 @@ void rend_SetCoplanarPolygonOffset(float factor) {
|
||||
|
||||
// returns the direct draw object
|
||||
void *rend_RetrieveDirectDrawObj(void **frontsurf, void **backsurf) {
|
||||
*frontsurf = NULL;
|
||||
*backsurf = NULL;
|
||||
return NULL;
|
||||
*frontsurf = nullptr;
|
||||
*backsurf = nullptr;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void rend_TransformSetToPassthru(void) {
|
||||
void rend_TransformSetToPassthru() {
|
||||
int width = gpu_state.screen_width;
|
||||
int height = gpu_state.screen_height;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user