mirror of
https://git.do.srb2.org/KartKrew/Kart-Public.git
synced 2025-01-13 21:31:32 +00:00
Open Graphics Library (OpenGL) is a cross-language, cross-platform application programming interface (API) for rendering 2D and 3D vector graphics. The API is
typically used to interact with a graphics processing unit (GPU), to achieve hardware-accelerated rendering.
This commit is contained in:
parent
53df420546
commit
df789e1d67
8 changed files with 52 additions and 20 deletions
|
@ -573,6 +573,10 @@ GLTexture_t *HWR_GetTexture(INT32 tex)
|
|||
|
||||
static void HWR_CacheFlat(GLMipmap_t *grMipmap, lumpnum_t flatlumpnum)
|
||||
{
|
||||
#ifdef GLENCORE
|
||||
UINT8 *flat;
|
||||
INT32 steppy;
|
||||
#endif
|
||||
size_t size, pflatsize;
|
||||
|
||||
// setup the texture info
|
||||
|
@ -614,6 +618,13 @@ static void HWR_CacheFlat(GLMipmap_t *grMipmap, lumpnum_t flatlumpnum)
|
|||
// the flat raw data needn't be converted with palettized textures
|
||||
W_ReadLump(flatlumpnum, Z_Malloc(W_LumpLength(flatlumpnum),
|
||||
PU_HWRCACHE, &grMipmap->grInfo.data));
|
||||
|
||||
#ifdef GLENCORE
|
||||
flat = grMipmap->grInfo.data;
|
||||
for (steppy = 0; steppy < size; steppy++)
|
||||
if (flat[steppy] != HWR_PATCHES_CHROMAKEY_COLORINDEX)
|
||||
flat[steppy] = grMipmap->colormap[flat[steppy]];
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
@ -859,4 +870,4 @@ void HWR_GetFadeMask(lumpnum_t fademasklumpnum)
|
|||
Z_ChangeTag(grmip->grInfo.data, PU_HWRCACHE_UNLOCKED);
|
||||
}
|
||||
|
||||
#endif //HWRENDER
|
||||
#endif //HWRENDER
|
||||
|
|
|
@ -241,6 +241,7 @@ enum hwdsetspecialstate
|
|||
HWD_SET_SHADERS,
|
||||
|
||||
HWD_SET_FOG_MODE,
|
||||
HWD_SET_FOG_FUNCTION,
|
||||
HWD_SET_FOG_DENSITY,
|
||||
|
||||
HWD_SET_TEXTUREFILTERMODE,
|
||||
|
@ -263,4 +264,4 @@ enum hwdfiltermode
|
|||
HWD_SET_TEXTUREFILTER_MIXED3,
|
||||
};
|
||||
|
||||
#endif //_HWR_DEFS_
|
||||
#endif //_HWR_DEFS_
|
||||
|
|
|
@ -161,15 +161,16 @@ void HWR_Lighting(FSurfaceInfo *Surface, INT32 light_level, UINT32 mixcolor, UIN
|
|||
fog_color.s.green = (UINT8)(((float)fog_color.s.green) * fog_alpha);
|
||||
fog_color.s.blue = (UINT8)(((float)fog_color.s.blue) * fog_alpha);
|
||||
|
||||
if (cv_grfog.value)
|
||||
{
|
||||
// be careful, this may get negative for high lightlevel values.
|
||||
float fog = (fog_alpha - (light_level/255.0f))*3/2;
|
||||
if (fog < 0)
|
||||
fog = 0;
|
||||
|
||||
float red = (fog_color.s.red/255.0f) * fog / 1.0f + (final_color.s.red/255.0f) * (1.0f - fog) / 1.0f;
|
||||
float green = (fog_color.s.green/255.0f) * fog / 1.0f + (final_color.s.green/255.0f) * (1.0f - fog) / 1.0f;
|
||||
float blue = (fog_color.s.blue/255.0f) * fog / 1.0f + (final_color.s.blue/255.0f) * (1.0f - fog) / 1.0f;
|
||||
float red = ((fog_color.s.red/255.0f) * fog) + ((final_color.s.red/255.0f) * (1.0f - fog));
|
||||
float green = ((fog_color.s.green/255.0f) * fog) + ((final_color.s.green/255.0f) * (1.0f - fog));
|
||||
float blue = ((fog_color.s.blue/255.0f) * fog) + ((final_color.s.blue/255.0f) * (1.0f - fog));
|
||||
final_color.s.red = (UINT8)(red*255.0f);
|
||||
final_color.s.green = (UINT8)(green*255.0f);
|
||||
final_color.s.blue = (UINT8)(blue*255.0f);
|
||||
|
@ -4540,6 +4541,12 @@ void HWR_DrawSkyBackground(void)
|
|||
angle = (viewangle + xtoviewangle[0]);
|
||||
dimensionmultiply = ((float)textures[skytexture]->width/256.0f)*2;
|
||||
|
||||
if (atransform.mirror)
|
||||
{
|
||||
angle = InvAngle(angle);
|
||||
dimensionmultiply *= -1;
|
||||
}
|
||||
|
||||
v[0].s = v[3].s = ((float) angle / ((ANGLE_90-1)*dimensionmultiply));
|
||||
v[2].s = v[1].s = (-1.0f/dimensionmultiply)+((float) angle / ((ANGLE_90-1)*dimensionmultiply));
|
||||
|
||||
|
@ -4547,12 +4554,6 @@ void HWR_DrawSkyBackground(void)
|
|||
angle = aimingangle;
|
||||
dimensionmultiply = ((float)textures[skytexture]->height/(128.0f*aspectratio));
|
||||
|
||||
if (atransform.mirror)
|
||||
{
|
||||
angle = InvAngle(angle);
|
||||
dimensionmultiply *= -1;
|
||||
}
|
||||
|
||||
if (splitscreen == 1)
|
||||
{
|
||||
dimensionmultiply *= 2;
|
||||
|
@ -4726,6 +4727,7 @@ void HWR_RenderFrame(INT32 viewnumber, player_t *player, boolean skybox)
|
|||
if (*postprocessor == postimg_flip)
|
||||
atransform.flip = true;
|
||||
|
||||
atransform.mirror = false;
|
||||
if (*postprocessor == postimg_mirror)
|
||||
atransform.mirror = true;
|
||||
|
||||
|
@ -4832,6 +4834,7 @@ void HWR_RenderPlayerView(INT32 viewnumber, player_t *player)
|
|||
void HWR_FoggingOn(void)
|
||||
{
|
||||
HWD.pfnSetSpecialState(HWD_SET_FOG_MODE, cv_grsoftwarefog.value ? 2 : 1);
|
||||
HWD.pfnSetSpecialState(HWD_SET_FOG_FUNCTION, cv_grfogfunction.value);
|
||||
HWD.pfnSetSpecialState(HWD_SET_FOG_DENSITY, cv_grfogdensity.value);
|
||||
}
|
||||
|
||||
|
@ -5258,4 +5261,4 @@ skip_field:
|
|||
return;
|
||||
}
|
||||
|
||||
#endif // HWRENDER
|
||||
#endif // HWRENDER
|
||||
|
|
|
@ -137,6 +137,7 @@ extern consvar_t cv_grmdls;
|
|||
extern consvar_t cv_grfog;
|
||||
extern consvar_t cv_grfogdensity;
|
||||
extern consvar_t cv_grsoftwarefog;
|
||||
extern consvar_t cv_grfogfunction;
|
||||
extern consvar_t cv_grgammared;
|
||||
extern consvar_t cv_grgammagreen;
|
||||
extern consvar_t cv_grgammablue;
|
||||
|
@ -150,4 +151,4 @@ extern consvar_t cv_grfallbackplayermodel;
|
|||
|
||||
extern CV_PossibleValue_t granisotropicmode_cons_t[];
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
|
|
@ -490,6 +490,7 @@ boolean SetupGLfunc(void)
|
|||
}
|
||||
|
||||
static INT32 glstate_fog_mode = 0;
|
||||
static INT32 glstate_fog_function = 0;
|
||||
static float glstate_fog_density = 0;
|
||||
|
||||
INT32 gl_leveltime = 0;
|
||||
|
@ -572,12 +573,17 @@ static PFNglGetUniformLocation pglGetUniformLocation;
|
|||
|
||||
#define GLSL_SHARED_FOG_MIX \
|
||||
"float fog_distance = gl_FragCoord.z / gl_FragCoord.w;\n" \
|
||||
"float fog_attenuation = fog(fog_distance, 0.0001 * ((256-lighting)/24), fog_density);\n" \
|
||||
"float fog_attenuation = 0.0001 * ((256-lighting)/24);\n" \
|
||||
"if (fog_function == 2)\n" \
|
||||
"fog_attenuation = fog2(fog_distance, fog_attenuation, fog_density);\n" \
|
||||
"else\n" \
|
||||
"fog_attenuation = fog(fog_distance, fog_attenuation, fog_density);\n" \
|
||||
"if (fog_mode == 2)\n" \
|
||||
"fog_attenuation = floor(fog_attenuation*10)/10;\n" \
|
||||
"vec4 fog_color = vec4(fade_color[0], fade_color[1], fade_color[2], 1.0);\n" \
|
||||
"vec4 mixed_color = texel * mix_color;\n" \
|
||||
"vec4 final_color = mix(mixed_color, fog_color, fog_attenuation);\n" \
|
||||
"vec4 fog_mix = mix(mixed_color, fog_color, fog_attenuation);\n" \
|
||||
"vec4 final_color = mix(fog_mix, fog_color, ((256-lighting)/256));\n" \
|
||||
"final_color[3] = mixed_color[3];\n"
|
||||
|
||||
#define GLSL_FRAGMENT_SHADER_HEADER \
|
||||
|
@ -586,6 +592,7 @@ static PFNglGetUniformLocation pglGetUniformLocation;
|
|||
"uniform vec4 fade_color;\n" \
|
||||
"uniform float lighting;\n" \
|
||||
"uniform int fog_mode;\n" \
|
||||
"uniform int fog_function;\n" \
|
||||
"uniform float fog_density;\n" \
|
||||
|
||||
#define SHARED_FRAGMENT_SHADER \
|
||||
|
@ -1596,6 +1603,7 @@ static void load_shaders(FSurfaceInfo *Surface, GLRGBAFloat *mix, GLRGBAFloat *f
|
|||
{
|
||||
#define GETUNI(uniform) pglGetUniformLocation(gl_shaderprograms[gl_currentshaderprogram], uniform);
|
||||
GLint UNIFORM_fog_mode = GETUNI("fog_mode");
|
||||
GLint UNIFORM_fog_function = GETUNI("fog_function");
|
||||
GLint UNIFORM_fog_density = GETUNI("fog_density");
|
||||
|
||||
GLint UNIFORM_mix_color = GETUNI("mix_color");
|
||||
|
@ -1624,6 +1632,7 @@ static void load_shaders(FSurfaceInfo *Surface, GLRGBAFloat *mix, GLRGBAFloat *f
|
|||
|
||||
// glstate
|
||||
UNIFORM_1(UNIFORM_fog_mode, glstate_fog_mode, pglUniform1i);
|
||||
UNIFORM_1(UNIFORM_fog_function, glstate_fog_function, pglUniform1i);
|
||||
UNIFORM_1(UNIFORM_fog_density, glstate_fog_density, pglUniform1f);
|
||||
|
||||
// polygon
|
||||
|
@ -1724,6 +1733,10 @@ EXPORT void HWRAPI(SetSpecialState) (hwdspecialstate_t IdState, INT32 Value)
|
|||
glstate_fog_mode = Value;
|
||||
break;
|
||||
|
||||
case HWD_SET_FOG_FUNCTION:
|
||||
glstate_fog_function = Value;
|
||||
break;
|
||||
|
||||
case HWD_SET_FOG_DENSITY:
|
||||
glstate_fog_density = FIXED_TO_FLOAT(Value);
|
||||
break;
|
||||
|
@ -2686,4 +2699,4 @@ EXPORT void HWRAPI(DrawScreenFinalTexture)(int width, int height)
|
|||
tex_downloaded = finalScreenTexture;
|
||||
}
|
||||
|
||||
#endif //HWRENDER
|
||||
#endif //HWRENDER
|
||||
|
|
|
@ -1300,6 +1300,7 @@ static menuitem_t OP_OpenGLFogMenu[] =
|
|||
{IT_STRING|IT_CVAR, NULL, "Fog", &cv_grfog, 10},
|
||||
{IT_STRING|IT_CVAR, NULL, "Fog density", &cv_grfogdensity, 20},
|
||||
{IT_STRING|IT_CVAR, NULL, "Software fog",&cv_grsoftwarefog,30},
|
||||
{IT_STRING|IT_CVAR, NULL, "Fog algorithm",&cv_grfogfunction,40},
|
||||
};
|
||||
|
||||
static menuitem_t OP_OpenGLColorMenu[] =
|
||||
|
|
|
@ -1552,7 +1552,7 @@ void R_RegisterEngineStuff(void)
|
|||
CV_RegisterVar(&cv_grfovchange);
|
||||
CV_RegisterVar(&cv_grfog);
|
||||
//CV_RegisterVar(&cv_grfogcolor);
|
||||
CV_RegisterVar(&cv_grsoftwarefog);
|
||||
CV_RegisterVar(&cv_grfogfunction);
|
||||
#ifdef ALAM_LIGHTING
|
||||
CV_RegisterVar(&cv_grstaticlighting);
|
||||
CV_RegisterVar(&cv_grdynamiclighting);
|
||||
|
|
|
@ -59,11 +59,13 @@ static void CV_Gammaxxx_ONChange(void);
|
|||
// but they won't do anything.
|
||||
static CV_PossibleValue_t grgamma_cons_t[] = {{1, "MIN"}, {255, "MAX"}, {0, NULL}};
|
||||
static CV_PossibleValue_t grfogdensity_cons_t[] = {{FRACUNIT/2, "MIN"}, {FRACUNIT*2, "MAX"}, {0, NULL}};
|
||||
static CV_PossibleValue_t grfogfunction_cons_t[] = {{1, "exp"}, {2, "exp2"}, {0, NULL}};
|
||||
|
||||
consvar_t cv_grshaders = {"gr_shaders", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
|
||||
consvar_t cv_grfog = {"gr_fog", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
|
||||
consvar_t cv_grsoftwarefog = {"gr_softwarefog", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
|
||||
consvar_t cv_grfogdensity = {"gr_fogdensity", "1", CV_SAVE|CV_FLOAT, grfogdensity_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
|
||||
consvar_t cv_grfogfunction = {"gr_fogfunction", "exp2", CV_SAVE, grfogfunction_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
|
||||
consvar_t cv_grfogdensity = {"gr_fogdensity", "1.0", CV_SAVE|CV_FLOAT, grfogdensity_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
|
||||
consvar_t cv_grfovchange = {"gr_fovchange", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
|
||||
consvar_t cv_grgammared = {"gr_gammared", "127", CV_SAVE|CV_CALL, grgamma_cons_t,
|
||||
CV_Gammaxxx_ONChange, 0, NULL, NULL, 0, 0, NULL};
|
||||
|
@ -77,8 +79,8 @@ consvar_t cv_grgammablue = {"gr_gammablue", "127", CV_SAVE|CV_CALL, grgamma_cons
|
|||
consvar_t cv_grmdls = {"gr_mdls", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
|
||||
consvar_t cv_grfallbackplayermodel = {"gr_fallbackplayermodel", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
|
||||
|
||||
consvar_t cv_grshearing = {"gr_shearing", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
|
||||
consvar_t cv_grspritebillboarding = {"gr_spritebillboarding", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
|
||||
consvar_t cv_grshearing = {"gr_shearing", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
|
||||
consvar_t cv_grspritebillboarding = {"gr_spritebillboarding", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
|
||||
#endif
|
||||
|
||||
const UINT8 gammatable[5][256] =
|
||||
|
|
Loading…
Reference in a new issue