mirror of
https://github.com/ENSL/NS.git
synced 2024-11-10 07:11:38 +00:00
add postprocessing
- add GLSL postprocessing shader to world view and have it replicate the old gamma ramp - clear framebuffer between frames to fix visual bugs outside map - remove old gamma ramp code (was disabled) and remove gamma adjustments to hud elements as they're now unaffected by the shader - additional visual preset config updates
This commit is contained in:
parent
5636d7a103
commit
8ab1a69972
44 changed files with 65457 additions and 232 deletions
|
@ -2,7 +2,7 @@
|
|||
brightness "1"
|
||||
gamma "2.5"
|
||||
lightgamma "2.5"
|
||||
gl_use_shaders "1" // Use temporary gamma ramp replacement that utilizes HL25 shaders. It only adjusts to the average gamma value of ns maps instead of per-map.
|
||||
cl_shader "1"
|
||||
|
||||
// Bobbing
|
||||
cl_bob "0.01"
|
||||
|
@ -33,5 +33,4 @@ echo "- Original dark lighting"
|
|||
echo "- Original HUD and crosshairs"
|
||||
echo "- Original weapon and view bob"
|
||||
echo "- Original mix volumes for ambient sound and music"
|
||||
echo " "
|
||||
echo "Note: 25th aniversary Half-Life and sv_allow_shaders 1 are required for the graphics to display properly at the moment."
|
||||
echo " "
|
|
@ -1,8 +1,8 @@
|
|||
// Lighting - temporary until new gamma ramp shader.
|
||||
brightness "1"
|
||||
brightness "0"
|
||||
gamma "2.5"
|
||||
lightgamma "2.25"
|
||||
gl_use_shaders "1"
|
||||
lightgamma "1.81"
|
||||
cl_shader "1"
|
||||
|
||||
// Bobbing
|
||||
cl_bob "0.006"
|
||||
|
@ -33,5 +33,4 @@ echo "- Brighter shadows"
|
|||
echo "- Minimal marine HUD and new crosshair system"
|
||||
echo "- Reduced weapon bobbing and no view bobbing"
|
||||
echo "- Reduced ambient sound and music volumes"
|
||||
echo " "
|
||||
echo "Note: 25th aniversary Half-Life and sv_allow_shaders 1 are required for the graphics to display properly at the moment."
|
||||
echo " "
|
|
@ -2,7 +2,7 @@
|
|||
brightness "2"
|
||||
gamma "3"
|
||||
lightgamma "2"
|
||||
gl_use_shaders "0"
|
||||
cl_shader "0"
|
||||
|
||||
// No bobbing
|
||||
cl_bob "0"
|
||||
|
|
15
main/shaders/fs.shaders
Normal file
15
main/shaders/fs.shaders
Normal file
|
@ -0,0 +1,15 @@
|
|||
#version 330 core
|
||||
|
||||
in vec2 texCoord;
|
||||
out vec4 fragColor;
|
||||
|
||||
uniform sampler2D textureSampler;
|
||||
uniform float colorMultiplier; // Uniform float to multiply color by
|
||||
|
||||
void main() {
|
||||
// Sample the texture
|
||||
vec4 texColor = texture(textureSampler, texCoord);
|
||||
|
||||
// Multiply the color by the uniform float
|
||||
fragColor = texColor * colorMultiplier;
|
||||
}
|
10
main/shaders/vs.shaders
Normal file
10
main/shaders/vs.shaders
Normal file
|
@ -0,0 +1,10 @@
|
|||
#version 330 core
|
||||
|
||||
layout(location = 0) in vec2 vertexPosition;
|
||||
out vec2 texCoord;
|
||||
|
||||
void main() {
|
||||
// Pass the vertex position to the fragment shader
|
||||
texCoord = (vertexPosition + 1.0) * 0.5; // Convert vertex position to texture coordinates
|
||||
gl_Position = vec4(vertexPosition, 0.0, 1.0);
|
||||
}
|
|
@ -69,6 +69,8 @@ TeamFortressViewport *gViewPort = NULL;
|
|||
HINTERFACEMODULE g_hTrackerModule = NULL;
|
||||
//ITrackerUser *g_pTrackerUser = NULL;
|
||||
|
||||
CPostProcessShader g_PostProcessShader;
|
||||
|
||||
void InitInput (void);
|
||||
void EV_HookEvents( void );
|
||||
void IN_Commands( void );
|
||||
|
@ -216,6 +218,8 @@ void CL_DLLEXPORT HUD_Init( void )
|
|||
InitInput();
|
||||
gHUD.Init();
|
||||
Scheme_Init();
|
||||
g_PostProcessShader.Init();
|
||||
//gEngfuncs.Con_Printf("waterrenderer init %d", success);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -261,6 +265,8 @@ HUD_Redraw
|
|||
|
||||
int CL_DLLEXPORT HUD_Redraw( float time, int intermission )
|
||||
{
|
||||
g_PostProcessShader.DrawShader();
|
||||
|
||||
// RecClHudRedraw(time, intermission);
|
||||
|
||||
gHUD.Redraw( time, intermission );
|
||||
|
|
|
@ -158,8 +158,8 @@
|
|||
<Optimization>MaxSpeed</Optimization>
|
||||
<InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<AdditionalIncludeDirectories>$(SolutionDir);$(SolutionDir)\particles;$(SolutionDir)\includes\lpng1251;$(SolutionDir)\includes\zlib-1.2.8;$(SolutionDir)\includes\fmod\inc;$(SolutionDir)\includes\vgui\include;../public;../common;../external;../pm_shared;../game_shared;../mod;../util;../ui;../engine;../cl_dll;../dlls</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;NDEBUG;WIN32;_WINDOWS;AVH_CLIENT;USE_OLDAUTH;_X86_</PreprocessorDefinitions>
|
||||
<AdditionalIncludeDirectories>$(SolutionDir);$(SolutionDir)\particles;$(SolutionDir)\includes\lpng1251;$(SolutionDir)\includes\zlib-1.2.8;$(SolutionDir)\includes\fmod\inc;$(SolutionDir)\includes\vgui\include;$(SolutionDir)\includes\glew;../public;../common;../external;../pm_shared;../game_shared;../mod;../util;../ui;../engine;../cl_dll;../dlls</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;NDEBUG;WIN32;_WINDOWS;AVH_CLIENT;USE_OLDAUTH;_X86_;GLEW_STATIC</PreprocessorDefinitions>
|
||||
<StringPooling>true</StringPooling>
|
||||
<RuntimeTypeInfo>true</RuntimeTypeInfo>
|
||||
<PrecompiledHeader>
|
||||
|
@ -281,6 +281,22 @@
|
|||
</ResourceCompile>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\includes\glew\GL\glew.c">
|
||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='Client - Playtest|Win32'">MaxSpeed</Optimization>
|
||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='Client - Release|Win32'">MaxSpeed</Optimization>
|
||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='Client - Debug|Win32'">MaxSpeed</Optimization>
|
||||
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Client - Playtest|Win32'">%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Client - Release|Win32'">%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Client - Debug|Win32'">%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\util\ShaderUtil.cpp">
|
||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='Client - Playtest|Win32'">MaxSpeed</Optimization>
|
||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='Client - Release|Win32'">MaxSpeed</Optimization>
|
||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='Client - Debug|Win32'">MaxSpeed</Optimization>
|
||||
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Client - Playtest|Win32'">%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Client - Release|Win32'">%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Client - Debug|Win32'">%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
<ClCompile Include="ammo.cpp">
|
||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='Client - Playtest|Win32'">MaxSpeed</Optimization>
|
||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='Client - Release|Win32'">MaxSpeed</Optimization>
|
||||
|
@ -564,6 +580,14 @@
|
|||
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Client - Release|Win32'">%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Client - Debug|Win32'">%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
<ClCompile Include="shader.cpp">
|
||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='Client - Playtest|Win32'">MaxSpeed</Optimization>
|
||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='Client - Release|Win32'">MaxSpeed</Optimization>
|
||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='Client - Debug|Win32'">MaxSpeed</Optimization>
|
||||
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Client - Playtest|Win32'">%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Client - Release|Win32'">%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Client - Debug|Win32'">%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
<ClCompile Include="status_icons.cpp">
|
||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='Client - Playtest|Win32'">MaxSpeed</Optimization>
|
||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='Client - Release|Win32'">MaxSpeed</Optimization>
|
||||
|
@ -1615,7 +1639,6 @@
|
|||
</ClCompile>
|
||||
<ClCompile Include="..\util\Balance.cpp" />
|
||||
<ClCompile Include="..\util\Checksum.cpp" />
|
||||
<ClCompile Include="..\util\GammaTable.cpp" />
|
||||
<ClCompile Include="..\util\LinuxSupport.cpp" />
|
||||
<ClCompile Include="..\util\Mat3.cpp" />
|
||||
<ClCompile Include="..\util\MathUtil.cpp" />
|
||||
|
@ -1627,6 +1650,10 @@
|
|||
<ClCompile Include="..\textrep\TRFactory.cpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\includes\glew\GL\eglew.h" />
|
||||
<ClInclude Include="..\includes\glew\GL\glew.h" />
|
||||
<ClInclude Include="..\includes\glew\GL\glxew.h" />
|
||||
<ClInclude Include="..\includes\glew\GL\wglew.h" />
|
||||
<ClInclude Include="..\mod\AvHAlienAbilities.h" />
|
||||
<ClInclude Include="..\mod\AvHAlienWeaponConstants.h" />
|
||||
<ClInclude Include="..\mod\AvHAlienWeapons.h" />
|
||||
|
@ -1634,6 +1661,7 @@
|
|||
<ClInclude Include="..\mod\AvHMarineWeapon.h" />
|
||||
<ClInclude Include="..\mod\AvHMarineWeaponConstants.h" />
|
||||
<ClInclude Include="..\mod\AvHMarineWeapons.h" />
|
||||
<ClInclude Include="..\util\ShaderUtil.h" />
|
||||
<ClInclude Include="ammo.h" />
|
||||
<ClInclude Include="ammohistory.h" />
|
||||
<ClInclude Include="..\game_shared\bitvec.h" />
|
||||
|
@ -1763,7 +1791,6 @@
|
|||
<ClInclude Include="..\util\Balance.h" />
|
||||
<ClInclude Include="..\util\Checksum.h" />
|
||||
<ClInclude Include="..\util\CString.h" />
|
||||
<ClInclude Include="..\util\GammaTable.h" />
|
||||
<ClInclude Include="..\util\LinuxSupport.h" />
|
||||
<ClInclude Include="..\util\Mat3.h" />
|
||||
<ClInclude Include="..\util\MathUtil.h" />
|
||||
|
|
|
@ -31,6 +31,9 @@
|
|||
<Filter Include="textrep">
|
||||
<UniqueIdentifier>{ad5bbb2c-1092-4ba3-ab5b-fdfa0a33f1f5}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Source Files\glew">
|
||||
<UniqueIdentifier>{57cad65d-80b8-4d06-abb5-8ff8dc1d60cc}</UniqueIdentifier>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="ammo.cpp">
|
||||
|
@ -552,9 +555,6 @@
|
|||
<ClCompile Include="..\util\Checksum.cpp">
|
||||
<Filter>util</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\util\GammaTable.cpp">
|
||||
<Filter>util</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\util\LinuxSupport.cpp">
|
||||
<Filter>util</Filter>
|
||||
</ClCompile>
|
||||
|
@ -600,6 +600,15 @@
|
|||
<ClCompile Include="hudgl.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="shader.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\util\ShaderUtil.cpp">
|
||||
<Filter>util</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\includes\glew\GL\glew.c">
|
||||
<Filter>Source Files\glew</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\mod\AvHAlienAbilities.h">
|
||||
|
@ -1004,9 +1013,6 @@
|
|||
<ClInclude Include="..\util\CString.h">
|
||||
<Filter>util</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\util\GammaTable.h">
|
||||
<Filter>util</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\util\LinuxSupport.h">
|
||||
<Filter>util</Filter>
|
||||
</ClInclude>
|
||||
|
@ -1052,6 +1058,21 @@
|
|||
<ClInclude Include="hudgl.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\util\ShaderUtil.h">
|
||||
<Filter>util</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\includes\glew\GL\glxew.h">
|
||||
<Filter>Source Files\glew</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\includes\glew\GL\wglew.h">
|
||||
<Filter>Source Files\glew</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\includes\glew\GL\eglew.h">
|
||||
<Filter>Source Files\glew</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\includes\glew\GL\glew.h">
|
||||
<Filter>Source Files\glew</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Library Include="..\lib\public\game_controls.lib" />
|
||||
|
|
|
@ -30,6 +30,7 @@ class TeamFortressViewport;
|
|||
class AvHHud;
|
||||
#include "AvHHud.h"
|
||||
extern AvHHud gHUD;
|
||||
extern CPostProcessShader g_PostProcessShader;
|
||||
|
||||
#include "wrect.h"
|
||||
#include "cl_dll.h"
|
||||
|
|
|
@ -561,7 +561,7 @@ void CHudSpectator::DrawOverviewMap()
|
|||
gEngfuncs.pTriAPI->CullFace(TRI_NONE);
|
||||
|
||||
gEngfuncs.pTriAPI->SpriteTexture((struct model_s*)(gEngfuncs.GetSpritePointer(m_hsprWhite)), 0);
|
||||
float gammaScale = 1.0f / gHUD.GetGammaSlope();
|
||||
float gammaScale = 1.0f/* / gHUD.GetGammaSlope()*/;
|
||||
|
||||
// Draw the background.
|
||||
|
||||
|
|
|
@ -1565,8 +1565,6 @@ void NsPreset(void)
|
|||
char execText[1024];
|
||||
//char localizedText[1024];
|
||||
|
||||
inGameAdditional = gViewPort ? " See console for details." : "";
|
||||
|
||||
switch (presetChoice)
|
||||
{
|
||||
case 1:
|
||||
|
|
214
main/source/cl_dll/shader.cpp
Normal file
214
main/source/cl_dll/shader.cpp
Normal file
|
@ -0,0 +1,214 @@
|
|||
#include "hud.h"
|
||||
#include "cl_util.h"
|
||||
|
||||
//#include "PlatformHeaders.h"
|
||||
#ifdef _WIN32
|
||||
#include "windows.h"
|
||||
#endif
|
||||
|
||||
#include <GL/glew.h>
|
||||
//#include <gl/GL.h>
|
||||
#include "util/ShaderUtil.h"
|
||||
|
||||
cvar_t* cl_postprocess = NULL;
|
||||
cvar_t* cl_intensity = NULL;
|
||||
|
||||
GLuint screenTexture;
|
||||
GLenum glew;
|
||||
ShaderUtil shaderUtil;
|
||||
|
||||
void CPostProcessShader::Init()
|
||||
{
|
||||
//glActiveTexture(GL_TEXTURE0);
|
||||
//glGetIntegerv(GL_ACTIVE_TEXTURE, &activeTextAtInit);
|
||||
|
||||
// Create the screen texture
|
||||
glGenTextures(1, &screenTexture);
|
||||
glBindTexture(GL_TEXTURE_2D, screenTexture);
|
||||
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, ScreenWidth(), ScreenHeight(), 0, GL_RGB, GL_UNSIGNED_BYTE, NULL);
|
||||
|
||||
cl_postprocess = CVAR_CREATE("cl_postprocess", "1", FCVAR_ARCHIVE);
|
||||
cl_intensity = CVAR_CREATE("cl_intensity", "1", FCVAR_ARCHIVE);
|
||||
|
||||
// Store shaders in dll so swapping in different ones is harder.
|
||||
const std::string vertShader =
|
||||
"#version 330 core\n"
|
||||
|
||||
"layout(location = 0) in vec2 vertexPosition;\n"
|
||||
"out vec2 texCoord;\n"
|
||||
|
||||
"void main() {\n"
|
||||
// Convert vertex position to texture coordinates
|
||||
"texCoord = (vertexPosition + 1.0) * 0.5;\n"
|
||||
"gl_Position = vec4(vertexPosition, 0.0, 1.0);\n"
|
||||
"}\n"
|
||||
;
|
||||
|
||||
const std::string fragShader =
|
||||
"#version 330 core\n"
|
||||
|
||||
"in vec2 texCoord;\n"
|
||||
"out vec4 fragColor;\n"
|
||||
|
||||
"uniform sampler2D textureSampler;\n"
|
||||
"uniform float colorMultiplier;\n"
|
||||
|
||||
"void main() {\n"
|
||||
// Sample the texture
|
||||
"vec4 texColor = texture(textureSampler, texCoord);\n"
|
||||
// Multiply the color
|
||||
"fragColor = vec4(texColor.rgb * colorMultiplier, 1.0f);\n"
|
||||
"}\n"
|
||||
;
|
||||
|
||||
glew = glewInit();
|
||||
|
||||
if (GLEW_OK != glew)
|
||||
{
|
||||
/* Problem: glewInit failed, something is seriously wrong. */
|
||||
// fprintf(stderr, "Error: %s\n", glewGetErrorString(err));
|
||||
gEngfuncs.Con_DPrintf("[GLEW] Error: %s\n", glewGetErrorString(glew));
|
||||
}
|
||||
else
|
||||
{
|
||||
gEngfuncs.Con_DPrintf("[GLEW] Initialize success!\n");
|
||||
//shaderUtil.LoadFromFile(std::string(gEngfuncs.pfnGetGameDirectory() + (std::string) "/shaders/vs.shaders"), std::string(gEngfuncs.pfnGetGameDirectory() + (std::string) "/shaders/fs.shaders"));
|
||||
shaderUtil.LoadFromString(vertShader, fragShader);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void CPostProcessShader::ClearFrameBuffer()
|
||||
{
|
||||
if (cl_postprocess->value <= 0 || cl_intensity->value <= 0)
|
||||
return;
|
||||
|
||||
//glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
//glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
|
||||
|
||||
//GLfloat clearColors[] = { 0.0f, 0.0f, 0.0f, 1.0f };
|
||||
//GLint drawFboId;
|
||||
//GLint readFboId;
|
||||
//GLint FboId;
|
||||
//glGetIntegerv(GL_DRAW_FRAMEBUFFER_BINDING, &drawFboId);
|
||||
//glBindFramebuffer(GL_FRAMEBUFFER, drawFboId);
|
||||
//glClearBufferfv(GL_COLOR, 0, clearColors);
|
||||
|
||||
//glGetIntegerv(GL_READ_FRAMEBUFFER_BINDING, &readFboId);
|
||||
//glBindFramebuffer(GL_FRAMEBUFFER, readFboId);
|
||||
//glClearBufferfv(GL_COLOR, 0, clearColors);
|
||||
|
||||
//glGetIntegerv(GL_FRAMEBUFFER_BINDING, &FboId);
|
||||
//glBindFramebuffer(GL_FRAMEBUFFER, FboId);
|
||||
//glClearBufferfv(GL_COLOR, 0, clearColors);
|
||||
}
|
||||
|
||||
void CPostProcessShader::DrawShader()
|
||||
{
|
||||
if (cl_postprocess->value <= 0 || cl_intensity->value <= 0)
|
||||
return;
|
||||
|
||||
// TO DO: Check NPOT texture support and shader support for older systems. HL might already check NPOT for FBO mode.
|
||||
|
||||
const int error1 = glGetError();
|
||||
if (error1 != 0)
|
||||
gEngfuncs.Con_DPrintf("before shader error %d\n", error1);
|
||||
|
||||
glPushAttrib(GL_TEXTURE_BIT);
|
||||
glPushClientAttrib(GL_CLIENT_VERTEX_ARRAY_BIT);
|
||||
|
||||
//// Might need some of these if things break.
|
||||
//glViewport(0, 0, ScreenWidth(), ScreenHeight());
|
||||
//glActiveTexture(GL_TEXTURE0);
|
||||
//glEnable(GL_TEXTURE_RECTANGE_NV);
|
||||
//glColor3f(1, 1, 1);
|
||||
//glDisable(GL_DEPTH_TEST);
|
||||
//glMatrixMode(GL_MODELVIEW);
|
||||
//glPushMatrix();
|
||||
//glLoadIdentity();
|
||||
//glMatrixMode(GL_PROJECTION);
|
||||
//glPushMatrix();
|
||||
//glLoadIdentity();
|
||||
//glOrtho(0, 1, 1, 0, 0.1, 100);
|
||||
//glReadBuffer(GL_COLOR_ATTACHMENT0);
|
||||
|
||||
//glEnable(GL_TEXTURE_2D);
|
||||
glBindTexture(GL_TEXTURE_2D, screenTexture);
|
||||
|
||||
//// Solokiller's code to copy from MSAA/scaling framebuffer
|
||||
//glFinish(); // Significant performance hit with this and it seems to work without it.
|
||||
GLint drawFboId;
|
||||
glGetIntegerv(GL_DRAW_FRAMEBUFFER_BINDING, &drawFboId);
|
||||
glBindFramebuffer(GL_READ_FRAMEBUFFER, drawFboId);
|
||||
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0);
|
||||
|
||||
glBlitFramebuffer(0, 0, ScreenWidth(), ScreenHeight(), 0, 0, ScreenWidth(), ScreenHeight(), GL_COLOR_BUFFER_BIT, GL_NEAREST);
|
||||
|
||||
glBindFramebuffer(GL_READ_FRAMEBUFFER, 0);
|
||||
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, drawFboId);
|
||||
|
||||
glReadBuffer(GL_BACK);
|
||||
glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 0, 0, ScreenWidth(), ScreenHeight(), 0);
|
||||
|
||||
const int error2 = glGetError();
|
||||
if (error2 != 0)
|
||||
gEngfuncs.Con_DPrintf("framebuffer copy error %d\n", error2);
|
||||
|
||||
|
||||
float colorMultiplier = 1.0f;
|
||||
const float scalarCvar = min(2.0f, max( 0.0f, cl_intensity->value));
|
||||
//const float colorMultiplier = max( 1.0f, max(scalarCvar, 1.0f + (gHUD.GetGammaSlope() - 1.0f) * scalarCvar));
|
||||
|
||||
// Scale the map's gamma value.
|
||||
if (gHUD.GetGammaSlope() > 1.0f)
|
||||
{
|
||||
colorMultiplier = 1.0f + (gHUD.GetGammaSlope() - 1.0f) * scalarCvar;
|
||||
}
|
||||
// If the map has no gamma value, override it with the cvar's value.
|
||||
else
|
||||
{
|
||||
colorMultiplier = min(1.0f, scalarCvar);
|
||||
}
|
||||
|
||||
// Use shader.
|
||||
glUseProgram(shaderUtil.GetProgramID());
|
||||
//glUniform1f(glGetUniformLocation(shaderUtil.GetProgramID(), "textureMap"), 0);
|
||||
glUniform1f(glGetUniformLocation(shaderUtil.GetProgramID(), "colorMultiplier"), colorMultiplier);
|
||||
|
||||
// Draw the quad.
|
||||
glBegin(GL_QUADS);
|
||||
glTexCoord2f(0, 0);
|
||||
glVertex3f(-1, 1, -1);
|
||||
glTexCoord2f(0, 1);
|
||||
glVertex3f(-1, -1, -1);
|
||||
glTexCoord2f(1, 1);
|
||||
glVertex3f(1, -1, -1);
|
||||
glTexCoord2f(1, 0);
|
||||
glVertex3f(1, 1, -1);
|
||||
glEnd();
|
||||
|
||||
// Restore state.
|
||||
glUseProgram(0);
|
||||
//glBindTexture(GL_TEXTURE_2D, 0);
|
||||
//glBindVertexArray(0);
|
||||
glPopAttrib();
|
||||
glPopClientAttrib();
|
||||
|
||||
//glMatrixMode(GL_PROJECTION);
|
||||
//glPopMatrix();
|
||||
//glMatrixMode(GL_MODELVIEW);
|
||||
//glPopMatrix();
|
||||
//glDisable(GL_TEXTURE_RECTANGE_NV); // Don't disable texture_2d or ui bugs out.
|
||||
//glEnable(GL_DEPTH_TEST);
|
||||
|
||||
const int error3 = glGetError();
|
||||
if (error3 != 0)
|
||||
gEngfuncs.Con_DPrintf("shader error %d\n", error3);
|
||||
}
|
|
@ -212,8 +212,11 @@ void ScorePanel::HitTestPanel::internalMousePressed(MouseCode code)
|
|||
|
||||
vgui::Color BuildColor( int R, int G, int B, float gamma )
|
||||
{
|
||||
ASSERT( gamma != 0 );
|
||||
return vgui::Color( R/gamma, G/gamma, B/gamma, 0 );
|
||||
// 2024 - remove old gamma ramp compensation
|
||||
//ASSERT( gamma != 0 );
|
||||
//return vgui::Color( R/gamma, G/gamma, B/gamma, 0 );
|
||||
|
||||
return vgui::Color(R, G, B, 0);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
|
|
@ -148,13 +148,13 @@ void SpectatorPanel::Initialize()
|
|||
CSchemeManager * pSchemes = gViewPort->GetSchemeManager();
|
||||
|
||||
|
||||
int colorR = 128 / gHUD.GetGammaSlope();
|
||||
int colorG = 128 / gHUD.GetGammaSlope();
|
||||
int colorB = 128 / gHUD.GetGammaSlope();
|
||||
int colorR = 128/* / gHUD.GetGammaSlope()*/;
|
||||
int colorG = 128/* / gHUD.GetGammaSlope()*/;
|
||||
int colorB = 128/* / gHUD.GetGammaSlope()*/;
|
||||
|
||||
int armedColorR = 255 / gHUD.GetGammaSlope();
|
||||
int armedColorG = 255 / gHUD.GetGammaSlope();
|
||||
int armedColorB = 255 / gHUD.GetGammaSlope();
|
||||
int armedColorR = 255/* / gHUD.GetGammaSlope()*/;
|
||||
int armedColorG = 255/* / gHUD.GetGammaSlope()*/;
|
||||
int armedColorB = 255/* / gHUD.GetGammaSlope()*/;
|
||||
|
||||
|
||||
SchemeHandle_t hSmallScheme = pSchemes->getSchemeHandle( /*"Team Info Text"*/ "PieMenuScheme" );
|
||||
|
|
|
@ -157,15 +157,15 @@ public:
|
|||
case PLAYERCLASS_DEAD_MARINE:
|
||||
case PLAYERCLASS_DEAD_ALIEN:
|
||||
case PLAYERCLASS_REINFORCING:
|
||||
r = 255 / gHUD.GetGammaSlope();
|
||||
g = 0 / gHUD.GetGammaSlope();
|
||||
b = 0 / gHUD.GetGammaSlope();
|
||||
r = 255/* / gHUD.GetGammaSlope()*/;
|
||||
g = 0/* / gHUD.GetGammaSlope()*/;
|
||||
b = 0/* / gHUD.GetGammaSlope()*/;
|
||||
break;
|
||||
|
||||
default:
|
||||
r = kTeamColors[theTeamNumber][0] / gHUD.GetGammaSlope();
|
||||
g = kTeamColors[theTeamNumber][1] / gHUD.GetGammaSlope();
|
||||
b = kTeamColors[theTeamNumber][2] / gHUD.GetGammaSlope();
|
||||
r = kTeamColors[theTeamNumber][0]/* / gHUD.GetGammaSlope()*/;
|
||||
g = kTeamColors[theTeamNumber][1]/* / gHUD.GetGammaSlope()*/;
|
||||
b = kTeamColors[theTeamNumber][2]/* / gHUD.GetGammaSlope()*/;
|
||||
break;
|
||||
|
||||
}
|
||||
|
|
|
@ -2218,6 +2218,8 @@ void CL_DLLEXPORT V_CalcRefdef( struct ref_params_s *pparams )
|
|||
{
|
||||
// RecClCalcRefdef(pparams);
|
||||
|
||||
g_PostProcessShader.ClearFrameBuffer();
|
||||
|
||||
// intermission / finale rendering
|
||||
if ( pparams->intermission )
|
||||
{
|
||||
|
|
|
@ -1357,7 +1357,6 @@
|
|||
</ClCompile>
|
||||
<ClCompile Include="..\util\Balance.cpp" />
|
||||
<ClCompile Include="..\util\Checksum.cpp" />
|
||||
<ClCompile Include="..\util\GammaTable.cpp" />
|
||||
<ClCompile Include="..\util\LinuxSupport.cpp" />
|
||||
<ClCompile Include="..\util\Mat3.cpp" />
|
||||
<ClCompile Include="..\util\MathUtil.cpp" />
|
||||
|
@ -1485,7 +1484,6 @@
|
|||
<ClInclude Include="..\util\Balance.h" />
|
||||
<ClInclude Include="..\util\Checksum.h" />
|
||||
<ClInclude Include="..\util\CString.h" />
|
||||
<ClInclude Include="..\util\GammaTable.h" />
|
||||
<ClInclude Include="..\util\LinuxSupport.h" />
|
||||
<ClInclude Include="..\util\Mat3.h" />
|
||||
<ClInclude Include="..\util\MathUtil.h" />
|
||||
|
|
|
@ -473,9 +473,6 @@
|
|||
<ClCompile Include="..\util\Checksum.cpp">
|
||||
<Filter>util</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\util\GammaTable.cpp">
|
||||
<Filter>util</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\util\LinuxSupport.cpp">
|
||||
<Filter>util</Filter>
|
||||
</ClCompile>
|
||||
|
@ -856,9 +853,6 @@
|
|||
<ClInclude Include="..\util\CString.h">
|
||||
<Filter>util</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\util\GammaTable.h">
|
||||
<Filter>util</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\util\LinuxSupport.h">
|
||||
<Filter>util</Filter>
|
||||
</ClInclude>
|
||||
|
|
3051
main/source/includes/glew/GL/eglew.h
Normal file
3051
main/source/includes/glew/GL/eglew.h
Normal file
File diff suppressed because it is too large
Load diff
31949
main/source/includes/glew/GL/glew.c
Normal file
31949
main/source/includes/glew/GL/glew.c
Normal file
File diff suppressed because it is too large
Load diff
26427
main/source/includes/glew/GL/glew.h
Normal file
26427
main/source/includes/glew/GL/glew.h
Normal file
File diff suppressed because it is too large
Load diff
1831
main/source/includes/glew/GL/glxew.h
Normal file
1831
main/source/includes/glew/GL/glxew.h
Normal file
File diff suppressed because it is too large
Load diff
1468
main/source/includes/glew/GL/wglew.h
Normal file
1468
main/source/includes/glew/GL/wglew.h
Normal file
File diff suppressed because it is too large
Load diff
|
@ -26,9 +26,9 @@ GAME_SHARED_OBJ_DIR=$(HL1_OBJ_DIR)/game_shared
|
|||
PM_SHARED_OBJ_DIR=$(HL1_OBJ_DIR)/pm_shared
|
||||
HL1_SERVER_OBJ_DIR=$(HL1_OBJ_DIR)/server
|
||||
|
||||
CFLAGS=$(BASE_CFLAGS) $(ARCH_CFLAGS) -DCLIENT_DLL -I/usr/include/malloc -D_snwprintf=swprintf -DAVH_CLIENT -DUSE_OLDAUTH -DAVH_NO_NEXUS -DNDEBUG -DASSERT=assert -Dsprintf_s=snprintf -DDISABLE_VEC_FUNCS -DDISABLE_VEC_ORIGIN
|
||||
CFLAGS=$(BASE_CFLAGS) $(ARCH_CFLAGS) -DCLIENT_DLL -I/usr/include/malloc -D_snwprintf=swprintf -DAVH_CLIENT -DUSE_OLDAUTH -DAVH_NO_NEXUS -DNDEBUG -DASSERT=assert -Dsprintf_s=snprintf -DDISABLE_VEC_FUNCS -DDISABLE_VEC_ORIGIN -DGLEW_STATIC -DGLEW_NO_GLU
|
||||
|
||||
INCLUDEDIRS= -I$(HL_SRC_DIR) -I$(NS_MOD_SRC_DIR) -I$(COMMON_SRC_DIR) -I$(PUBLIC_SRC_DIR) -I$(PM_SHARED_SRC_DIR) -I../engine -I$(GAME_SHARED_SRC_DIR) -I../external/ -I../particles -I../includes/fmodapi375linux/api/inc -I$(HL_SERVER_SRC_DIR) -I$(HL_SRC_DIR)/cl_dll -I$(VGUI_INCLUDE_DIR) -I$(UI_INCLUDE_DIR) -I$(UTIL_SRC_DIR) -I../ -I../includes/fmodapi375linux/api -I../includes/lpng1251
|
||||
INCLUDEDIRS= -I$(HL_SRC_DIR) -I$(NS_MOD_SRC_DIR) -I$(COMMON_SRC_DIR) -I$(PUBLIC_SRC_DIR) -I$(PM_SHARED_SRC_DIR) -I../engine -I$(GAME_SHARED_SRC_DIR) -I../external/ -I../particles -I../includes/fmodapi375linux/api/inc -I$(HL_SERVER_SRC_DIR) -I$(HL_SRC_DIR)/cl_dll -I$(VGUI_INCLUDE_DIR) -I$(UI_INCLUDE_DIR) -I$(UTIL_SRC_DIR) -I../ -I../includes/fmodapi375linux/api -I../includes/lpng1251 -I../includes/glew
|
||||
|
||||
ifeq ($(OS),Darwin)
|
||||
LDFLAGS=$(SHLIBLDFLAGS) $(CPP_LIB) -framework Carbon -framework OpenGL vgui.dylib -L. -lSDL2-2.0.0 -L. libparticleMP.a
|
||||
|
@ -86,6 +86,7 @@ HL1_OBJS = \
|
|||
$(HL1_OBJ_DIR)/view.o \
|
||||
$(HL1_OBJ_DIR)/message.o \
|
||||
$(HL1_OBJ_DIR)/parsemsg.o \
|
||||
$(HL1_OBJ_DIR)/shader.o \
|
||||
$(HL1_OBJ_DIR)/saytext.o \
|
||||
$(HL1_OBJ_DIR)/status_icons.o \
|
||||
$(HL1_OBJ_DIR)/statusbar.o \
|
||||
|
@ -246,11 +247,12 @@ UI_OBJS = \
|
|||
UTIL_OBJS = \
|
||||
$(UTIL_OBJ_DIR)/Balance.o \
|
||||
$(UTIL_OBJ_DIR)/Checksum.o \
|
||||
$(UTIL_OBJ_DIR)/GammaTable.o \
|
||||
#$(UTIL_OBJ_DIR)/GammaTable.o \
|
||||
$(UTIL_OBJ_DIR)/LinuxSupport.o \
|
||||
$(UTIL_OBJ_DIR)/Mat3.o \
|
||||
$(UTIL_OBJ_DIR)/MathUtil.o \
|
||||
$(UTIL_OBJ_DIR)/Quat.o \
|
||||
$(UTIL_OBJ_DIR)/ShaderUtil.o \
|
||||
$(UTIL_OBJ_DIR)/Stacktrace.o \
|
||||
$(UTIL_OBJ_DIR)/STLUtil.o \
|
||||
$(UTIL_OBJ_DIR)/Tokenizer.o \
|
||||
|
|
|
@ -203,7 +203,7 @@ GAME_SHARED_OBJS = \
|
|||
UTIL_OBJS = \
|
||||
$(UTIL_OBJ_DIR)/Balance.o \
|
||||
$(UTIL_OBJ_DIR)/Checksum.o \
|
||||
$(UTIL_OBJ_DIR)/GammaTable.o \
|
||||
#$(UTIL_OBJ_DIR)/GammaTable.o \
|
||||
$(UTIL_OBJ_DIR)/LinuxSupport.o \
|
||||
$(UTIL_OBJ_DIR)/Mat3.o \
|
||||
$(UTIL_OBJ_DIR)/MathUtil.o \
|
||||
|
|
|
@ -227,10 +227,9 @@ extern void __CmdFunc_Close(void);
|
|||
extern int CL_ButtonBits(int);
|
||||
extern int g_iVisibleMouse;
|
||||
|
||||
//@2014 make this work for linux
|
||||
|
||||
GammaTable AvHHud::sPregameGammaTable;
|
||||
GammaTable AvHHud::sGameGammaTable;
|
||||
//// 2024 - replaced windows gamma table with shader
|
||||
//GammaTable AvHHud::sPregameGammaTable;
|
||||
//GammaTable AvHHud::sGameGammaTable;
|
||||
|
||||
|
||||
bool AvHHud::sShowMap = false;
|
||||
|
@ -312,7 +311,7 @@ void NumericalInfoEffect::SetPosition(float inPosition[3])
|
|||
void AvHHud::OnActivateSteamUI()
|
||||
{
|
||||
// Set the normal gamma so the Steam UI looks correct.
|
||||
/*
|
||||
/*
|
||||
#ifdef _WIN32
|
||||
sPregameGammaTable.InitializeToVideoState();
|
||||
#endif*/
|
||||
|
@ -323,7 +322,7 @@ void AvHHud::OnDeactivateSteamUI()
|
|||
{
|
||||
|
||||
// Set the special NS gamma. //@2014 no more gamma
|
||||
/*
|
||||
/*
|
||||
#ifdef _WIN32
|
||||
SetGamma(mDesiredGammaSlope);
|
||||
#endif */
|
||||
|
@ -695,7 +694,7 @@ AvHHud::~AvHHud(void)
|
|||
//this->ResetGamma();
|
||||
//delete [] sOriginalGammaTable;
|
||||
//delete [] sGammaTable;
|
||||
AvHHud::ResetGammaAtExit();
|
||||
//AvHHud::ResetGammaAtExit();
|
||||
}
|
||||
|
||||
void DummyFunction()
|
||||
|
@ -1787,7 +1786,10 @@ AvHMessageID AvHHud::HotKeyHit(char inChar)
|
|||
//@2014 make this work for linux
|
||||
float AvHHud::GetGammaSlope() const
|
||||
{
|
||||
return sGameGammaTable.GetGammaSlope();
|
||||
//gEngfuncs.Con_DPrintf("Map gamma set to %f\n", this->mShaderGamma);
|
||||
return this->mShaderGamma;
|
||||
|
||||
//return sGameGammaTable.GetGammaSlope();
|
||||
}
|
||||
string AvHHud::GetMapName(bool inLocalOnly) const
|
||||
{
|
||||
|
@ -1848,57 +1850,65 @@ int AvHHud::GetMaxAlienResources() const
|
|||
|
||||
bool AvHHud::SetGamma(float inSlope)
|
||||
{
|
||||
bool theSuccess = false;
|
||||
bool theSuccess = true;
|
||||
|
||||
// Disable gamma stuff in debug for sanity
|
||||
// #ifndef DEBUG
|
||||
this->mShaderGamma = inSlope;
|
||||
|
||||
//@2014
|
||||
/*
|
||||
#ifdef _WIN32
|
||||
HDC theDC = GetDC(NULL); // this is a windows func call
|
||||
if(theDC != 0)
|
||||
{
|
||||
const float kGammaIncrement = 0.05f;
|
||||
float theGammaToTry = inSlope + kGammaIncrement;
|
||||
while(!theSuccess && (theGammaToTry > 1.0f))
|
||||
{
|
||||
theGammaToTry -= kGammaIncrement;
|
||||
//sGameGammaTable.ProcessSlope(inSlope);
|
||||
|
||||
sGameGammaTable.ProcessSlope(theGammaToTry);
|
||||
// : fakes a successful gamma ramp change if cl_gammaramp is set to 0
|
||||
if((CVAR_GET_FLOAT(kvGammaRamp) == 0) || sGameGammaTable.InitializeToVideoState())
|
||||
{
|
||||
// Tell UI components so they can change shading to look the same
|
||||
this->GetManager().NotifyGammaChange(theGammaToTry);
|
||||
|
||||
// aww yeah
|
||||
theSuccess = true;
|
||||
}
|
||||
}
|
||||
|
||||
char theMessage[256];
|
||||
if(theSuccess)
|
||||
{
|
||||
sprintf(theMessage, "Gamma set to %f.", theGammaToTry);
|
||||
}
|
||||
else
|
||||
{
|
||||
sprintf(theMessage, "Display doesn't support downloadable gamma ramps.");
|
||||
}
|
||||
|
||||
if(!theSuccess || (gEngfuncs.GetMaxClients() == 1))
|
||||
{
|
||||
CenterPrint(theMessage);
|
||||
}
|
||||
|
||||
if(!ReleaseDC(NULL, theDC))
|
||||
{
|
||||
// emit error about leak
|
||||
}
|
||||
}
|
||||
|
||||
#endif */
|
||||
// 2024 - Replaced windows gamma ramp with shader
|
||||
//
|
||||
// bool theSuccess = false;
|
||||
//
|
||||
// // Disable gamma stuff in debug for sanity
|
||||
//// #ifndef DEBUG
|
||||
//
|
||||
////@2014
|
||||
//
|
||||
//#ifdef _WIN32
|
||||
// HDC theDC = GetDC(NULL); // this is a windows func call
|
||||
// if(theDC != 0)
|
||||
// {
|
||||
// const float kGammaIncrement = 0.05f;
|
||||
// float theGammaToTry = inSlope + kGammaIncrement;
|
||||
// while(!theSuccess && (theGammaToTry > 1.0f))
|
||||
// {
|
||||
// theGammaToTry -= kGammaIncrement;
|
||||
//
|
||||
// sGameGammaTable.ProcessSlope(theGammaToTry);
|
||||
// // : fakes a successful gamma ramp change if cl_gammaramp is set to 0
|
||||
// if((CVAR_GET_FLOAT(kvGammaRamp) == 0) || sGameGammaTable.InitializeToVideoState())
|
||||
// {
|
||||
// // Tell UI components so they can change shading to look the same
|
||||
// this->GetManager().NotifyGammaChange(theGammaToTry);
|
||||
//
|
||||
// // aww yeah
|
||||
// theSuccess = true;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// char theMessage[256];
|
||||
// if(theSuccess)
|
||||
// {
|
||||
// sprintf(theMessage, "Gamma set to %f.", theGammaToTry);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// sprintf(theMessage, "Display doesn't support downloadable gamma ramps.");
|
||||
// }
|
||||
//
|
||||
// if(!theSuccess || (gEngfuncs.GetMaxClients() == 1))
|
||||
// {
|
||||
// CenterPrint(theMessage);
|
||||
// }
|
||||
//
|
||||
// if(!ReleaseDC(NULL, theDC))
|
||||
// {
|
||||
// // emit error about leak
|
||||
// }
|
||||
// }
|
||||
//
|
||||
//#endif
|
||||
return theSuccess;
|
||||
}
|
||||
|
||||
|
@ -1944,25 +1954,25 @@ int AvHHud::Redraw( float flTime, int intermission )
|
|||
return theRC;
|
||||
}
|
||||
|
||||
void AvHHud::ResetGammaAtExit()
|
||||
{
|
||||
/*#ifdef _WIN32
|
||||
sPregameGammaTable.InitializeToVideoState();
|
||||
#endif*/
|
||||
}
|
||||
|
||||
int AvHHud::ResetGammaAtExitForOnExit()
|
||||
{
|
||||
/*#ifdef _WIN32
|
||||
sPregameGammaTable.InitializeToVideoState();
|
||||
#endif*/
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void AvHHud::ResetGammaAtExit(int inSig)
|
||||
{
|
||||
AvHHud::ResetGammaAtExit();
|
||||
}
|
||||
//void AvHHud::ResetGammaAtExit()
|
||||
//{
|
||||
//#ifdef _WIN32
|
||||
//sPregameGammaTable.InitializeToVideoState();
|
||||
//#endif
|
||||
//}
|
||||
//
|
||||
//int AvHHud::ResetGammaAtExitForOnExit()
|
||||
//{
|
||||
//#ifdef _WIN32
|
||||
// sPregameGammaTable.InitializeToVideoState();
|
||||
//#endif
|
||||
// return TRUE;
|
||||
//}
|
||||
//
|
||||
//void AvHHud::ResetGammaAtExit(int inSig)
|
||||
//{
|
||||
// AvHHud::ResetGammaAtExit();
|
||||
//}
|
||||
|
||||
void AvHHud::ResetTopDownUI()
|
||||
{
|
||||
|
@ -2591,6 +2601,7 @@ void AvHHud::ResetGame(bool inMapChanged)
|
|||
|
||||
this->mHiveInfoList.clear();
|
||||
|
||||
this->mShaderGamma = kDefaultMapGamma;
|
||||
this->mDesiredGammaSlope = kDefaultMapGamma;
|
||||
this->mRecordingLastFrame = false;
|
||||
this->mTimeOfLastHelpText = -1;
|
||||
|
@ -3791,6 +3802,7 @@ void AvHHud::Init(void)
|
|||
signal(SIGBREAK, AvHHud::ResetGammaAtExit);
|
||||
signal(SIGABRT, AvHHud::ResetGammaAtExit);
|
||||
#endif */
|
||||
this->mShaderGamma = 1.0f;
|
||||
//memset(this->mAlienUILifeforms, 0, sizeof(HSPRITE)*kNumAlienLifeforms);
|
||||
this->mAlienUIUpgrades = 0;
|
||||
this->mAlienUIUpgradeCategories = 0;
|
||||
|
@ -4917,13 +4929,13 @@ void AvHHud::InitExploitPrevention() {
|
|||
ForceCvar("r_detailtextures", r_detailtextures, 0.0f);
|
||||
ForceCvar("gl_max_size", gl_max_size, 512.0f);
|
||||
|
||||
RemoveAlias("lightgamma");
|
||||
if(lightgamma && lightgamma->value < 2.0) {
|
||||
ForceCvar("lightgamma", lightgamma, 2.0f);
|
||||
}
|
||||
if(lightgamma && lightgamma->value > 5.0) {
|
||||
ForceCvar("lightgamma", lightgamma, 5.0f);
|
||||
}
|
||||
//RemoveAlias("lightgamma");
|
||||
//if(lightgamma && lightgamma->value < 2.0) {
|
||||
// ForceCvar("lightgamma", lightgamma, 2.0f);
|
||||
//}
|
||||
//if(lightgamma && lightgamma->value > 5.0) {
|
||||
// ForceCvar("lightgamma", lightgamma, 5.0f);
|
||||
//}
|
||||
RemoveAlias("texgamma");
|
||||
if(texgamma && texgamma->value < 1.0) {
|
||||
ForceCvar("texgamma", texgamma, 1.0f);
|
||||
|
@ -4949,8 +4961,8 @@ void AvHHud::UpdateExploitPrevention()
|
|||
ForceCvar("r_detailtextures", r_detailtextures, 0.0f);
|
||||
ForceCvar("gl_max_size", gl_max_size, 512.0f);
|
||||
|
||||
if(lightgamma && lightgamma->value < 2.0) {
|
||||
ForceCvar("lightgamma", lightgamma, 2.0f);
|
||||
if(lightgamma && lightgamma->value < 1.81f) {
|
||||
ForceCvar("lightgamma", lightgamma, 1.81f);
|
||||
}
|
||||
if(lightgamma && lightgamma->value > 5.0) {
|
||||
ForceCvar("lightgamma", lightgamma, 5.0f);
|
||||
|
@ -7405,7 +7417,7 @@ LONG WINAPI ExceptionFilter(EXCEPTION_POINTERS* pExp)
|
|||
}
|
||||
*/
|
||||
|
||||
AvHHud::ResetGammaAtExit();
|
||||
//AvHHud::ResetGammaAtExit();
|
||||
|
||||
return EXCEPTION_EXECUTE_HANDLER;
|
||||
|
||||
|
@ -7425,7 +7437,7 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL,
|
|||
}
|
||||
else if (fdwReason == DLL_PROCESS_DETACH)
|
||||
{
|
||||
AvHHud::ResetGammaAtExit();
|
||||
//AvHHud::ResetGammaAtExit();
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
|
|
@ -128,7 +128,7 @@
|
|||
#include "AvHVisibleBlipList.h"
|
||||
#include "AvHMapExtents.h"
|
||||
#include "AvHSpecials.h"
|
||||
#include "GammaTable.h"
|
||||
//#include "GammaTable.h"
|
||||
#include "AvHBaseInfoLocation.h"
|
||||
#include "AvHTooltip.h"
|
||||
#include "AvHTechSlotManager.h"
|
||||
|
@ -430,9 +430,9 @@ public:
|
|||
// This function should be used instead of the global SetCrosshair.
|
||||
void SetCurrentCrosshair(AVHHSPRITE hspr, wrect_t rc, int r, int g, int b);
|
||||
|
||||
static void ResetGammaAtExit();
|
||||
static int ResetGammaAtExitForOnExit();
|
||||
static void ResetGammaAtExit(int inSig);
|
||||
//static void ResetGammaAtExit();
|
||||
//static int ResetGammaAtExitForOnExit();
|
||||
//static void ResetGammaAtExit(int inSig);
|
||||
|
||||
void SetViewport(const int inViewport[4]);
|
||||
void GetViewport(int outViewport[4]) const;
|
||||
|
@ -679,9 +679,9 @@ private:
|
|||
int mFramesSinceEnteredTopdownMode;
|
||||
int mNumLocalSelectEvents;
|
||||
AvHMapMode mMapMode;
|
||||
//@2014 make this work for linux
|
||||
static GammaTable sPregameGammaTable;
|
||||
static GammaTable sGameGammaTable;
|
||||
//// 2024 - Replaced gamma ramp with shader.
|
||||
//static GammaTable sPregameGammaTable;
|
||||
//static GammaTable sGameGammaTable;
|
||||
|
||||
|
||||
float mDesiredGammaSlope;
|
||||
|
@ -882,6 +882,16 @@ private:
|
|||
bool mReInitHUD;
|
||||
float mLastHudStyle;
|
||||
|
||||
float mShaderGamma;
|
||||
|
||||
};
|
||||
|
||||
class CPostProcessShader
|
||||
{
|
||||
public:
|
||||
void Init();
|
||||
void ClearFrameBuffer();
|
||||
void DrawShader();
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -511,8 +511,8 @@ void DrawScaledHUDSprite(AVHHSPRITE inSpriteHandle, int inMode, int inRowsInSpri
|
|||
}
|
||||
|
||||
// Compensate for gamma
|
||||
float theGammaSlope = gHUD.GetGammaSlope();
|
||||
float theColorComponent = 1.0f/theGammaSlope;
|
||||
//float theGammaSlope = gHUD.GetGammaSlope();
|
||||
float theColorComponent = 1.0f/* / theGammaSlope*/;
|
||||
gEngfuncs.pTriAPI->Color4f(theColorComponent, theColorComponent, theColorComponent, 1.0f);
|
||||
|
||||
Vector thePoint;
|
||||
|
@ -627,9 +627,9 @@ void DrawSpriteOnGroundAtPoint(vec3_t inOrigin, int inRadius, AVHHSPRITE inSprit
|
|||
// Draw one quad
|
||||
vec3_t thePoint = inOrigin;
|
||||
|
||||
float theGammaSlope = gHUD.GetGammaSlope();
|
||||
ASSERT(theGammaSlope > 0.0f);
|
||||
float theColorComponent = 1.0f/theGammaSlope;
|
||||
//float theGammaSlope = gHUD.GetGammaSlope();
|
||||
//ASSERT(theGammaSlope > 0.0f);
|
||||
float theColorComponent = 1.0f/* / theGammaSlope*/;
|
||||
|
||||
gEngfuncs.pTriAPI->Color4f(theColorComponent, theColorComponent, theColorComponent, inAlpha);
|
||||
gEngfuncs.pTriAPI->Brightness(1.6f);
|
||||
|
@ -1707,8 +1707,8 @@ void AvHHud::DrawMouseCursor(int inBaseX, int inBaseY)
|
|||
|
||||
if (theCursorSprite > 0)
|
||||
{
|
||||
float theGammaSlope = this->GetGammaSlope();
|
||||
ASSERT(theGammaSlope > 0.0f);
|
||||
//float theGammaSlope = this->GetGammaSlope();
|
||||
//ASSERT(theGammaSlope > 0.0f);
|
||||
|
||||
/*
|
||||
int theColorComponent = 255/theGammaSlope;
|
||||
|
@ -2025,15 +2025,15 @@ void AvHHud::GetPrimaryHudColor(int& outR, int& outG, int& outB, bool inIgnoreUp
|
|||
UnpackRGB(outR, outG, outB, RGB_YELLOWISH);
|
||||
//}
|
||||
}
|
||||
|
||||
if (gammaCorrect)
|
||||
{
|
||||
// Take into account current gamma?
|
||||
float theGammaSlope = this->GetGammaSlope();
|
||||
outR /= theGammaSlope;
|
||||
outG /= theGammaSlope;
|
||||
outB /= theGammaSlope;
|
||||
}
|
||||
// 2024 - Remove old gamma ramp correction.
|
||||
//if (gammaCorrect)
|
||||
//{
|
||||
// // Take into account current gamma?
|
||||
// float theGammaSlope = this->GetGammaSlope();
|
||||
// outR /= theGammaSlope;
|
||||
// outG /= theGammaSlope;
|
||||
// outB /= theGammaSlope;
|
||||
//}
|
||||
|
||||
}
|
||||
|
||||
|
@ -2638,10 +2638,10 @@ void AvHHud::DrawHUDNumber(int inX, int inY, int inFlags, int inNumber)
|
|||
int theR, theG, theB;
|
||||
this->GetPrimaryHudColor(theR, theG, theB, false, false);
|
||||
|
||||
int theGammaSlope = this->GetGammaSlope();
|
||||
theR /= theGammaSlope;
|
||||
theG /= theGammaSlope;
|
||||
theB /= theGammaSlope;
|
||||
//int theGammaSlope = this->GetGammaSlope();
|
||||
//theR /= theGammaSlope;
|
||||
//theG /= theGammaSlope;
|
||||
//theB /= theGammaSlope;
|
||||
|
||||
this->DrawHudNumber(inX, inY, inFlags, inNumber, theR, theG, theB);
|
||||
}
|
||||
|
@ -2740,7 +2740,7 @@ void AvHHud::Render()
|
|||
int theWidth;
|
||||
int theHeight;
|
||||
|
||||
float gammaScale = 1.0f / GetGammaSlope();
|
||||
float gammaScale = 1.0f/* / GetGammaSlope()*/;
|
||||
|
||||
gEngfuncs.pfnDrawSetTextColor(0, gammaScale, 0);
|
||||
gEngfuncs.pfnDrawConsoleStringLen(theMessage, &theWidth, &theHeight);
|
||||
|
@ -2876,11 +2876,11 @@ void AvHHud::RenderShowSpeed()
|
|||
|
||||
float theGroundSpeed = sqrtf(pmove->velocity[0] * pmove->velocity[0] + pmove->velocity[1] * pmove->velocity[1]);
|
||||
maxGroundSpeed = max(theGroundSpeed, maxGroundSpeed);
|
||||
sprintf(buffer, "Ground speed = %d (%d)", (int)theGroundSpeed, maxGroundSpeed);
|
||||
mFont.DrawString(10, 12 + mFont.GetStringHeight(), buffer, theR, theG, theB);
|
||||
//sprintf(buffer, "Ground speed = %d (%d)", (int)theGroundSpeed, maxGroundSpeed);
|
||||
//mFont.DrawString(10, 12 + mFont.GetStringHeight(), buffer, theR, theG, theB);
|
||||
|
||||
//sprintf(buffer, "vangle0= %f vangle1= %f vangle2= %f)", pmove->angles[0], pmove->angles[1], pmove->angles[2]);
|
||||
//mFont.DrawString(10, 12 + mFont.GetStringHeight() * 2, buffer, theR, theG, theB);
|
||||
sprintf(buffer, "vangle0= %f vangle1= %f vangle2= %f)", pmove->angles[0], pmove->angles[1], pmove->angles[2]);
|
||||
mFont.DrawString(10, 12 + mFont.GetStringHeight() * 2, buffer, theR, theG, theB);
|
||||
speedMeasured = true;
|
||||
}
|
||||
else if (speedMeasured == true) {
|
||||
|
|
|
@ -73,7 +73,7 @@ void AvHOverviewControl::paint()
|
|||
|
||||
gEngfuncs.pTriAPI->SpriteTexture((struct model_s*)(gEngfuncs.GetSpritePointer(m_hsprWhite)), 0);
|
||||
|
||||
float gammaScale = 1.0f / gHUD.GetGammaSlope();
|
||||
float gammaScale = 1.0f/* / gHUD.GetGammaSlope()*/;
|
||||
|
||||
// Draw the background.
|
||||
|
||||
|
|
|
@ -404,7 +404,7 @@ void AvHSpriteDraw(AVHHSPRITE spriteHandle, int frame, float x1, float y1, float
|
|||
|
||||
// Compensate for the overbrightening effect.
|
||||
|
||||
float gammaScale = 1.0f / gHUD.GetGammaSlope();
|
||||
float gammaScale = 1.0f/* / gHUD.GetGammaSlope()*/;
|
||||
gEngfuncs.pTriAPI->Color4f(gammaScale * gColor[0], gammaScale * gColor[1], gammaScale * gColor[2], gColor[3]);
|
||||
|
||||
// Output the vertices.
|
||||
|
|
|
@ -93,10 +93,10 @@ void FadingImageLabel::DoPaint()
|
|||
int r, g, b, a;
|
||||
this->getBgColor(r, g, b, a);
|
||||
|
||||
float theGammaSlope = gHUD.GetGammaSlope();
|
||||
r = r/theGammaSlope;
|
||||
g = g/theGammaSlope;
|
||||
b = b/theGammaSlope;
|
||||
//float theGammaSlope = gHUD.GetGammaSlope();
|
||||
//r = r/theGammaSlope;
|
||||
//g = g/theGammaSlope;
|
||||
//b = b/theGammaSlope;
|
||||
|
||||
// Don't take gamma slope into account for alpha
|
||||
a = 255 - a;
|
||||
|
|
|
@ -25,17 +25,17 @@ MarqueeComponent::MarqueeComponent()
|
|||
{
|
||||
this->mX0 = this->mY0 = 0;
|
||||
this->mX1 = this->mY1 = 0;
|
||||
this->mGammaSlope = 1.0f;
|
||||
//this->mGammaSlope = 1.0f;
|
||||
|
||||
// Default color scheme
|
||||
this->setFgColor(0, 255, 0, 0);
|
||||
this->setBgColor(0, 255, 0, 230);
|
||||
}
|
||||
|
||||
void MarqueeComponent::NotifyGammaChange(float inGammaSlope)
|
||||
{
|
||||
this->mGammaSlope = inGammaSlope;
|
||||
}
|
||||
//void MarqueeComponent::NotifyGammaChange(float inGammaSlope)
|
||||
//{
|
||||
// this->mGammaSlope = inGammaSlope;
|
||||
//}
|
||||
|
||||
void MarqueeComponent::paint()
|
||||
{
|
||||
|
@ -49,8 +49,8 @@ void MarqueeComponent::paint()
|
|||
int theWidth, theHeight;
|
||||
this->getSize(theWidth, theHeight);
|
||||
|
||||
//vguiSimpleBox(0, 0, theWidth, theHeight, r/this->mGammaSlope, g/this->mGammaSlope, b/this->mGammaSlope, a/this->mGammaSlope);
|
||||
vguiSimpleBox(0, 0, theWidth, theHeight, r/this->mGammaSlope, g/this->mGammaSlope, b/this->mGammaSlope, a);
|
||||
//vguiSimpleBox(0, 0, theWidth, theHeight, r/this->mGammaSlope, g/this->mGammaSlope, b/this->mGammaSlope, a);
|
||||
vguiSimpleBox(0, 0, theWidth, theHeight, r, g, b, a);
|
||||
|
||||
// Top
|
||||
// vguiSimpleLine(0, 0, theWidth, 0, r, g, b, a);
|
||||
|
@ -76,8 +76,8 @@ void MarqueeComponent::paintBackground()
|
|||
int theWidth, theHeight;
|
||||
this->getSize(theWidth, theHeight);
|
||||
|
||||
//FillRGBA(0, 0, theWidth, theHeight, r/this->mGammaSlope, g/this->mGammaSlope, b/this->mGammaSlope, a/this->mGammaSlope);
|
||||
FillRGBA(0, 0, theWidth, theHeight, r/this->mGammaSlope, g/this->mGammaSlope, b/this->mGammaSlope, a);
|
||||
//FillRGBA(0, 0, theWidth, theHeight, r/this->mGammaSlope, g/this->mGammaSlope, b/this->mGammaSlope, a);
|
||||
FillRGBA(0, 0, theWidth, theHeight, r, g, b, a);
|
||||
}
|
||||
|
||||
void MarqueeComponent::ResetDimensions()
|
||||
|
|
|
@ -20,13 +20,13 @@
|
|||
#define MARQUEECOMPONENT_H
|
||||
|
||||
#include "VGUI_Panel.h"
|
||||
#include "GammaAwareComponent.h"
|
||||
//#include "GammaAwareComponent.h"
|
||||
|
||||
class MarqueeComponent : public vgui::Panel, public GammaAwareComponent
|
||||
class MarqueeComponent : public vgui::Panel//, public GammaAwareComponent
|
||||
{
|
||||
public:
|
||||
MarqueeComponent();
|
||||
virtual void NotifyGammaChange(float inGammaSlope);
|
||||
//virtual void NotifyGammaChange(float inGammaSlope);
|
||||
void SetStartPos(int inX, int inY);
|
||||
void SetEndPos(int inX, int inY);
|
||||
|
||||
|
@ -39,7 +39,7 @@ private:
|
|||
int mX0, mY0;
|
||||
int mX1, mY1;
|
||||
|
||||
float mGammaSlope;
|
||||
//float mGammaSlope;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -130,11 +130,11 @@ void PieMenu::ResetToDefaults()
|
|||
this->mNodeList->ResetToDefaults();
|
||||
}
|
||||
|
||||
void PieMenu::NotifyGammaChange(float inGammaSlope)
|
||||
{
|
||||
// TODO: Adjust font color?
|
||||
this->mNodeList->GetRoot()->SetColorBias(1.0f/inGammaSlope);
|
||||
}
|
||||
//void PieMenu::NotifyGammaChange(float inGammaSlope)
|
||||
//{
|
||||
// // TODO: Adjust font color?
|
||||
// this->mNodeList->GetRoot()->SetColorBias(1.0f/inGammaSlope);
|
||||
//}
|
||||
|
||||
void PieMenu::SetConnectorName(const string& inConnectorName)
|
||||
{
|
||||
|
|
|
@ -27,13 +27,13 @@
|
|||
#include "cl_dll/chud.h"
|
||||
#include "ui/FadingImageLabel.h"
|
||||
#include "ui/PieNode.h"
|
||||
#include "ui/GammaAwareComponent.h"
|
||||
//#include "ui/GammaAwareComponent.h"
|
||||
#include "ui/ReloadableComponent.h"
|
||||
|
||||
using std::string;
|
||||
using vgui::Font;
|
||||
|
||||
class PieMenu : public vgui::Panel, public ReloadableComponent, public GammaAwareComponent
|
||||
class PieMenu : public vgui::Panel, public ReloadableComponent//, public GammaAwareComponent
|
||||
{
|
||||
public:
|
||||
PieMenu(const string& inRootName, int x, int y, int wide, int tall);
|
||||
|
@ -59,7 +59,7 @@ public:
|
|||
// is how it determines which item was selected.
|
||||
virtual void mouseReleased(MouseCode code, Panel* panel);
|
||||
|
||||
virtual void NotifyGammaChange(float inGammaSlope);
|
||||
//virtual void NotifyGammaChange(float inGammaSlope);
|
||||
|
||||
void RecomputeVisibleSize(void);
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
#define PIENODE_H
|
||||
|
||||
#include "ui/FadingImageLabel.h"
|
||||
#include "ui/GammaAwareComponent.h"
|
||||
//#include "ui/GammaAwareComponent.h"
|
||||
#include "mod/AvHSharedTypes.h"
|
||||
#include "string"
|
||||
using std::string;
|
||||
|
|
|
@ -115,8 +115,10 @@ vgui::Color gammaAdjustColor( vgui::Color& color, const float gamma_slope )
|
|||
{
|
||||
int components[4];
|
||||
color.getColor( components[0], components[1], components[2], components[3] );
|
||||
ASSERT( gamma_slope != 0 );
|
||||
vgui::Color returnVal = vgui::Color( components[0]/gamma_slope, components[1]/gamma_slope, components[2]/gamma_slope, 0 );
|
||||
////2024 - replace gamma ramp with shader
|
||||
//ASSERT( gamma_slope != 0 );
|
||||
//vgui::Color returnVal = vgui::Color( components[0]/gamma_slope, components[1]/gamma_slope, components[2]/gamma_slope, 0 );
|
||||
vgui::Color returnVal = vgui::Color(components[0], components[1], components[2], 0);
|
||||
return returnVal;
|
||||
}
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@ SpritePanel::SpritePanel(const string& inBaseSpriteName, const string& inRenderM
|
|||
|
||||
this->mRenderMode = inRenderMode;
|
||||
this->mSpriteHandle = 0;
|
||||
this->mGammaSlope = 1.0f;
|
||||
//this->mGammaSlope = 1.0f;
|
||||
}
|
||||
|
||||
int SpritePanel::GetNumSpritesAcross()
|
||||
|
@ -48,10 +48,10 @@ int SpritePanel::GetNumSpritesDown()
|
|||
|
||||
}
|
||||
|
||||
void SpritePanel::NotifyGammaChange(float inGammaSlope)
|
||||
{
|
||||
this->mGammaSlope = inGammaSlope;
|
||||
}
|
||||
//void SpritePanel::NotifyGammaChange(float inGammaSlope)
|
||||
//{
|
||||
// this->mGammaSlope = inGammaSlope;
|
||||
//}
|
||||
|
||||
void SpritePanel::paint()
|
||||
{
|
||||
|
@ -118,8 +118,9 @@ void SpritePanel::paint()
|
|||
{
|
||||
if(theCurrentFrame < theNumFrames)
|
||||
{
|
||||
int theGammaAwareColorComponent = (int)(255.0f/this->mGammaSlope);
|
||||
SPR_Set(this->mSpriteHandle, theGammaAwareColorComponent, theGammaAwareColorComponent, theGammaAwareColorComponent);
|
||||
//int theGammaAwareColorComponent = (int)(255.0f/this->mGammaSlope);
|
||||
//SPR_Set(this->mSpriteHandle, theGammaAwareColorComponent, theGammaAwareColorComponent, theGammaAwareColorComponent);
|
||||
SPR_Set(this->mSpriteHandle, 255, 255, 255);
|
||||
int theFinalX = theX*theSpriteWidth;
|
||||
int theFinalY = theY*theSpriteHeight + theAlignBottomOffset;
|
||||
//if(!theAlignmentIsTop)
|
||||
|
|
|
@ -2,18 +2,18 @@
|
|||
#define SPRITEPANEL_H
|
||||
|
||||
#include "VGUI_Panel.h"
|
||||
#include "ui/GammaAwareComponent.h"
|
||||
//#include "ui/GammaAwareComponent.h"
|
||||
#include "ui/ReloadableComponent.h"
|
||||
#include "../types.h"
|
||||
|
||||
typedef int AVHHSPRITE;
|
||||
|
||||
class SpritePanel : public vgui::Panel, public ReloadableComponent, public GammaAwareComponent
|
||||
class SpritePanel : public vgui::Panel, public ReloadableComponent//, public GammaAwareComponent
|
||||
{
|
||||
public:
|
||||
SpritePanel(const string& inBaseSpriteName, const string& inRenderMode);
|
||||
|
||||
virtual void NotifyGammaChange(float inGammaSlope);
|
||||
//virtual void NotifyGammaChange(float inGammaSlope);
|
||||
|
||||
virtual void SetVAlignment(const string& inAlignment);
|
||||
|
||||
|
@ -30,7 +30,7 @@ private:
|
|||
string mRenderMode;
|
||||
string mVAlignment;
|
||||
AVHHSPRITE mSpriteHandle;
|
||||
float mGammaSlope;
|
||||
//float mGammaSlope;
|
||||
|
||||
};
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
#include "VGUI_TextPanel.h"
|
||||
#include "VGUI_Label.h"
|
||||
#include "cl_dll/vgui_TeamFortressViewport.h"
|
||||
#include "ui/GammaAwareComponent.h"
|
||||
//#include "ui/GammaAwareComponent.h"
|
||||
#include "ui/ReloadableComponent.h"
|
||||
|
||||
//using vgui::Label;
|
||||
|
@ -41,7 +41,7 @@ UIManager::UIManager(UIFactory* inFactory)
|
|||
this->mBlankCursor = NULL;
|
||||
|
||||
this->mFactory = inFactory;
|
||||
this->mGammaSlope = 1.0f;
|
||||
//this->mGammaSlope = 1.0f;
|
||||
}
|
||||
|
||||
UIManager::~UIManager(void)
|
||||
|
@ -221,12 +221,12 @@ bool UIManager::Initialize(const TRDescriptionList& inDesc, CSchemeManager* inSc
|
|||
this->TranslateComponent(theCurrentComponent->GetComponentPointer(), true);
|
||||
}
|
||||
|
||||
// If gamma aware, tell it immediately
|
||||
GammaAwareComponent* theGammaAwareComponent = dynamic_cast<GammaAwareComponent*>(theCurrentComponent->GetComponentPointer());
|
||||
if(theGammaAwareComponent)
|
||||
{
|
||||
theGammaAwareComponent->NotifyGammaChange(this->mGammaSlope);
|
||||
}
|
||||
//// If gamma aware, tell it immediately
|
||||
//GammaAwareComponent* theGammaAwareComponent = dynamic_cast<GammaAwareComponent*>(theCurrentComponent->GetComponentPointer());
|
||||
//if(theGammaAwareComponent)
|
||||
//{
|
||||
// theGammaAwareComponent->NotifyGammaChange(this->mGammaSlope);
|
||||
//}
|
||||
|
||||
// Save it. It is now part of the world.
|
||||
this->mComponentList.push_back(theCurrentComponent);
|
||||
|
@ -250,20 +250,20 @@ bool UIManager::InMouseMode(void) const
|
|||
return (g_iVisibleMouse ? true : false);
|
||||
}
|
||||
|
||||
void UIManager::NotifyGammaChange(float inGammaSlope)
|
||||
{
|
||||
UIComponentListType::iterator theCompIter;
|
||||
for(theCompIter = this->mComponentList.begin(); theCompIter != this->mComponentList.end(); theCompIter++)
|
||||
{
|
||||
GammaAwareComponent* theGammaAwareComponent = dynamic_cast<GammaAwareComponent*>((*theCompIter)->GetComponentPointer());
|
||||
if(theGammaAwareComponent)
|
||||
{
|
||||
theGammaAwareComponent->NotifyGammaChange(inGammaSlope);
|
||||
}
|
||||
}
|
||||
|
||||
this->mGammaSlope = inGammaSlope;
|
||||
}
|
||||
//void UIManager::NotifyGammaChange(float inGammaSlope)
|
||||
//{
|
||||
// UIComponentListType::iterator theCompIter;
|
||||
// for(theCompIter = this->mComponentList.begin(); theCompIter != this->mComponentList.end(); theCompIter++)
|
||||
// {
|
||||
// GammaAwareComponent* theGammaAwareComponent = dynamic_cast<GammaAwareComponent*>((*theCompIter)->GetComponentPointer());
|
||||
// if(theGammaAwareComponent)
|
||||
// {
|
||||
// theGammaAwareComponent->NotifyGammaChange(inGammaSlope);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// this->mGammaSlope = inGammaSlope;
|
||||
//}
|
||||
|
||||
bool UIManager::Save(const string& outFilename, const string& outHeader)
|
||||
{
|
||||
|
|
|
@ -75,7 +75,7 @@ public:
|
|||
|
||||
bool InMouseMode(void) const;
|
||||
|
||||
void NotifyGammaChange(float inGammaSlope);
|
||||
//void NotifyGammaChange(float inGammaSlope);
|
||||
|
||||
// Saves the current UI layout back out the file that it was read in from. This is only meaningful after
|
||||
// the layout has been edited by the player. Returns false if the file couldn't be opened, if a write fails.
|
||||
|
@ -145,7 +145,7 @@ private:
|
|||
Cursor* mBlankCursor;
|
||||
|
||||
UIFactory* mFactory;
|
||||
float mGammaSlope;
|
||||
//float mGammaSlope;
|
||||
|
||||
// List of text representations associated with UIComponents.
|
||||
// These are all currently loaded in the game.
|
||||
|
|
|
@ -31,7 +31,7 @@ void UIDrawVariableBarSpriteHoles(AVHHSPRITE inSprite, int inX, int inY, float i
|
|||
int theSpriteWidth = SPR_Width(inSprite, kFullFrame);
|
||||
int theSpriteHeight = SPR_Height(inSprite, kFullFrame);
|
||||
|
||||
int theColorComponent = 255/inGammaSlope;
|
||||
int theColorComponent = 255/*/inGammaSlope*/;
|
||||
|
||||
// Draw empty sprite
|
||||
SPR_Set(inSprite, theColorComponent, theColorComponent, theColorComponent);
|
||||
|
|
152
main/source/util/ShaderUtil.cpp
Normal file
152
main/source/util/ShaderUtil.cpp
Normal file
|
@ -0,0 +1,152 @@
|
|||
//// Bacontsu's Shader utilities - adapted for reading directly from strings.
|
||||
|
||||
#include "hud.h"
|
||||
#include "ShaderUtil.h"
|
||||
//#include "windows.h"
|
||||
#include <GL/glew.h>
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <filesystem>
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <io.h>
|
||||
#define access _access_s
|
||||
#else
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
bool FileExists(const std::string& Filename)
|
||||
{
|
||||
return access(Filename.c_str(), 0) == 0;
|
||||
}
|
||||
|
||||
//unsigned int ShaderUtil::GetCompiledShader(unsigned int shader_type, const std::string& shader_source, const std::string& path)
|
||||
//{
|
||||
// unsigned int shader_id = glCreateShader(shader_type);
|
||||
//
|
||||
// const char* c_source = shader_source.c_str();
|
||||
// glShaderSource(shader_id, 1, &c_source, nullptr);
|
||||
// glCompileShader(shader_id);
|
||||
//
|
||||
// GLint result;
|
||||
// glGetShaderiv(shader_id, GL_COMPILE_STATUS, &result);
|
||||
//
|
||||
// if (result == GL_FALSE)
|
||||
// {
|
||||
// int length;
|
||||
// glGetShaderiv(shader_id, GL_INFO_LOG_LENGTH, &length);
|
||||
//
|
||||
// GLchar* strInfoLog = new GLchar[length + 1];
|
||||
// glGetShaderInfoLog(shader_id, length, &length, strInfoLog);
|
||||
//
|
||||
// //fprintf(stderr, "Compilation error in shader: %s\n", strInfoLog);
|
||||
// gEngfuncs.Con_Printf("[GLEW] Compilation error in shader: %s\n[GLEW] ERROR: %s\n", path.c_str(), strInfoLog);
|
||||
//
|
||||
// delete[] strInfoLog;
|
||||
// }
|
||||
// else
|
||||
// gEngfuncs.Con_Printf("[GLEW] Compiling %s shader success!\n", path.c_str());
|
||||
//
|
||||
// return shader_id;
|
||||
//}
|
||||
|
||||
unsigned int ShaderUtil::GetCompiledShader(unsigned int shader_type, const std::string& shader_source)
|
||||
{
|
||||
unsigned int shader_id = glCreateShader(shader_type);
|
||||
|
||||
const char* c_source = shader_source.c_str();
|
||||
glShaderSource(shader_id, 1, &c_source, nullptr);
|
||||
glCompileShader(shader_id);
|
||||
|
||||
GLint result;
|
||||
glGetShaderiv(shader_id, GL_COMPILE_STATUS, &result);
|
||||
|
||||
if (result == GL_FALSE)
|
||||
{
|
||||
int length;
|
||||
glGetShaderiv(shader_id, GL_INFO_LOG_LENGTH, &length);
|
||||
|
||||
GLchar* strInfoLog = new GLchar[length + 1];
|
||||
glGetShaderInfoLog(shader_id, length, &length, strInfoLog);
|
||||
|
||||
//fprintf(stderr, "Compilation error in shader: %s\n", strInfoLog);
|
||||
gEngfuncs.Con_Printf("[GLEW] Compilation error in shader: %d\n[GLEW] ERROR: %s\n", shader_type, strInfoLog);
|
||||
|
||||
delete[] strInfoLog;
|
||||
}
|
||||
else
|
||||
gEngfuncs.Con_Printf("[GLEW] Compiling %d shader success!\n", shader_type);
|
||||
|
||||
return shader_id;
|
||||
}
|
||||
|
||||
//bool ShaderUtil::LoadFromFile(const std::string& vertexShaderFile, const std::string& fragmentShaderFile)
|
||||
//{
|
||||
// std::ifstream is_vs(vertexShaderFile);
|
||||
// const std::string f_vs((std::istreambuf_iterator<char>(is_vs)), std::istreambuf_iterator<char>());
|
||||
//
|
||||
// std::ifstream is_fs(fragmentShaderFile);
|
||||
// const std::string f_fs((std::istreambuf_iterator<char>(is_fs)), std::istreambuf_iterator<char>());
|
||||
//
|
||||
// bool failToLoad = false;
|
||||
// if (!FileExists(vertexShaderFile))
|
||||
// {
|
||||
// gEngfuncs.Con_Printf("[GLEW] Cannot find %s shader!\n", vertexShaderFile.c_str());
|
||||
// failToLoad = true;
|
||||
// }
|
||||
// if (!FileExists(fragmentShaderFile))
|
||||
// {
|
||||
// gEngfuncs.Con_Printf("[GLEW] Cannot find %s shader!\n", fragmentShaderFile.c_str());
|
||||
// failToLoad = true;
|
||||
// }
|
||||
// if (failToLoad)
|
||||
// {
|
||||
// return false;
|
||||
// }
|
||||
//
|
||||
// mProgramId = glCreateProgram();
|
||||
//
|
||||
// unsigned int vs = GetCompiledShader(GL_VERTEX_SHADER, f_vs, vertexShaderFile);
|
||||
// unsigned int fs = GetCompiledShader(GL_FRAGMENT_SHADER, f_fs, fragmentShaderFile);
|
||||
//
|
||||
// glAttachShader(mProgramId, vs);
|
||||
// glAttachShader(mProgramId, fs);
|
||||
//
|
||||
// glLinkProgram(mProgramId);
|
||||
// glValidateProgram(mProgramId);
|
||||
//
|
||||
// glDeleteShader(vs);
|
||||
// glDeleteShader(fs);
|
||||
//
|
||||
// return true;
|
||||
//}
|
||||
|
||||
bool ShaderUtil::LoadFromString(const std::string& vertexShader, const std::string& fragmentShader)
|
||||
{
|
||||
mProgramId = glCreateProgram();
|
||||
|
||||
unsigned int vs = GetCompiledShader(GL_VERTEX_SHADER, vertexShader);
|
||||
unsigned int fs = GetCompiledShader(GL_FRAGMENT_SHADER, fragmentShader);
|
||||
|
||||
glAttachShader(mProgramId, vs);
|
||||
glAttachShader(mProgramId, fs);
|
||||
|
||||
glLinkProgram(mProgramId);
|
||||
glValidateProgram(mProgramId);
|
||||
|
||||
glDeleteShader(vs);
|
||||
glDeleteShader(fs);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void ShaderUtil::Use()
|
||||
{
|
||||
glUseProgram(mProgramId);
|
||||
}
|
||||
|
||||
void ShaderUtil::Delete()
|
||||
{
|
||||
glDeleteProgram(mProgramId);
|
||||
}
|
||||
|
33
main/source/util/ShaderUtil.h
Normal file
33
main/source/util/ShaderUtil.h
Normal file
|
@ -0,0 +1,33 @@
|
|||
#pragma once
|
||||
|
||||
#include <string>
|
||||
|
||||
// Utitlity class to load, compile and attach a vertex- and fragment shader to a program
|
||||
class ShaderUtil
|
||||
{
|
||||
|
||||
private:
|
||||
unsigned int mProgramId;
|
||||
|
||||
//unsigned int GetCompiledShader(unsigned int shader_type, const std::string& shader_source, const std::string& path);
|
||||
unsigned int GetCompiledShader(unsigned int shader_type, const std::string& shader_source);
|
||||
|
||||
public:
|
||||
ShaderUtil() {}
|
||||
~ShaderUtil() {}
|
||||
|
||||
// Load a vertex and a fragment shader from file
|
||||
//bool LoadFromFile(const std::string& vertexShaderFile, const std::string& fragmentShaderFile);
|
||||
bool LoadFromString(const std::string& vertexShader, const std::string& fragmentShader);
|
||||
|
||||
// Use the program
|
||||
void Use();
|
||||
|
||||
// Delete the program
|
||||
void Delete();
|
||||
|
||||
// Give the programID
|
||||
unsigned int GetProgramID() { return mProgramId; }
|
||||
|
||||
};
|
||||
|
Loading…
Reference in a new issue