mirror of
https://github.com/kevinbentley/Descent3.git
synced 2025-01-22 11:28:56 +00:00
[gl] extracted some common GPU rendering code
This commit is contained in:
parent
9b936995ce
commit
f1941de990
@ -65,6 +65,33 @@ int gpu_last_frame_verts_processed = 0;
|
||||
int gpu_last_uploaded = 0;
|
||||
|
||||
float gpu_Alpha_factor = 1.0f;
|
||||
float gpu_Alpha_multiplier = 1.0f;
|
||||
|
||||
// returns the alpha that we should use
|
||||
float rend_GetAlphaMultiplier() {
|
||||
switch (gpu_state.cur_alpha_type) {
|
||||
case AT_ALWAYS:
|
||||
case AT_TEXTURE:
|
||||
case AT_VERTEX:
|
||||
case AT_TEXTURE_VERTEX:
|
||||
case AT_SATURATE_VERTEX:
|
||||
case AT_SATURATE_TEXTURE_VERTEX:
|
||||
case AT_SPECULAR:
|
||||
return 1.0;
|
||||
case AT_CONSTANT:
|
||||
case AT_CONSTANT_TEXTURE:
|
||||
case AT_CONSTANT_TEXTURE_VERTEX:
|
||||
case AT_CONSTANT_VERTEX:
|
||||
case AT_LIGHTMAP_BLEND:
|
||||
case AT_LIGHTMAP_BLEND_SATURATE:
|
||||
case AT_SATURATE_TEXTURE:
|
||||
case AT_SATURATE_CONSTANT_VERTEX:
|
||||
return gpu_state.cur_alpha / 255.0;
|
||||
default:
|
||||
// Int3(); // no type defined,get jason
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
// Retrieves an error message
|
||||
const char *rend_GetErrorMessage() { return Renderer_error_message; }
|
||||
@ -96,6 +123,12 @@ void rend_SetCharacterParameters(ddgr_color color1, ddgr_color color2, ddgr_colo
|
||||
rend_FontAlpha[3] = (color4 >> 24) / 255.0f;
|
||||
}
|
||||
|
||||
// Sets the alpha value for constant alpha
|
||||
void rend_SetAlphaValue(ubyte val) {
|
||||
gpu_state.cur_alpha = val;
|
||||
gpu_Alpha_multiplier = rend_GetAlphaMultiplier();
|
||||
}
|
||||
|
||||
// Sets the texture wrapping type
|
||||
void rend_SetWrapType(wrap_type val) { gpu_state.cur_wrap_type = val; }
|
||||
|
||||
|
@ -59,5 +59,6 @@ void rend_TransformSetProjection(float trans[4][4]);
|
||||
void rend_TransformSetModelView(float trans[4][4]);
|
||||
|
||||
int rend_ReInit();
|
||||
float rend_GetAlphaMultiplier();
|
||||
|
||||
#endif
|
||||
|
@ -128,6 +128,7 @@ extern int gpu_last_frame_verts_processed;
|
||||
extern int gpu_last_uploaded;
|
||||
|
||||
extern float gpu_Alpha_factor;
|
||||
extern float gpu_Alpha_multiplier;
|
||||
|
||||
#if defined(_USE_OGL_ACTIVE_TEXTURES)
|
||||
PFNGLACTIVETEXTUREARBPROC oglActiveTextureARB = NULL;
|
||||
@ -149,8 +150,6 @@ ushort *opengl_packed_Translate_table = NULL;
|
||||
ushort *opengl_packed_4444_translate_table = NULL;
|
||||
|
||||
extern rendering_state gpu_state;
|
||||
static float gpu_Alpha_multiplier = 1.0f;
|
||||
|
||||
extern renderer_preferred_state gpu_preferred_state;
|
||||
|
||||
// These structs are for drawing with OpenGL vertex arrays
|
||||
@ -1425,32 +1424,6 @@ void opengl_MakeFilterTypeCurrent(int handle, int map_type, int tn) {
|
||||
CHECK_ERROR(9)
|
||||
}
|
||||
|
||||
// returns the alpha that we should use
|
||||
float opengl_GetAlphaMultiplier(void) {
|
||||
switch (gpu_state.cur_alpha_type) {
|
||||
case AT_ALWAYS:
|
||||
case AT_TEXTURE:
|
||||
case AT_VERTEX:
|
||||
case AT_TEXTURE_VERTEX:
|
||||
case AT_SATURATE_VERTEX:
|
||||
case AT_SATURATE_TEXTURE_VERTEX:
|
||||
case AT_SPECULAR:
|
||||
return 1.0;
|
||||
case AT_CONSTANT:
|
||||
case AT_CONSTANT_TEXTURE:
|
||||
case AT_CONSTANT_TEXTURE_VERTEX:
|
||||
case AT_CONSTANT_VERTEX:
|
||||
case AT_LIGHTMAP_BLEND:
|
||||
case AT_LIGHTMAP_BLEND_SATURATE:
|
||||
case AT_SATURATE_TEXTURE:
|
||||
case AT_SATURATE_CONSTANT_VERTEX:
|
||||
return gpu_state.cur_alpha / 255.0;
|
||||
default:
|
||||
// Int3(); // no type defined,get jason
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
// Turns on/off multitexture blending
|
||||
void opengl_SetMultitextureBlendMode(bool state) {
|
||||
if (OpenGL_multitexture_state == state)
|
||||
@ -2682,16 +2655,10 @@ void rend_SetAlphaType(sbyte atype) {
|
||||
break;
|
||||
}
|
||||
gpu_state.cur_alpha_type = atype;
|
||||
gpu_Alpha_multiplier = opengl_GetAlphaMultiplier();
|
||||
gpu_Alpha_multiplier = rend_GetAlphaMultiplier();
|
||||
CHECK_ERROR(15)
|
||||
}
|
||||
|
||||
// Sets the alpha value for constant alpha
|
||||
void rend_SetAlphaValue(ubyte val) {
|
||||
gpu_state.cur_alpha = val;
|
||||
gpu_Alpha_multiplier = opengl_GetAlphaMultiplier();
|
||||
}
|
||||
|
||||
// Draws a line using the states of the renderer
|
||||
void rend_DrawSpecialLine(g3Point *p0, g3Point *p1) {
|
||||
g3_RefreshTransforms(true);
|
||||
|
Loading…
Reference in New Issue
Block a user