Permalink
Browse files

Remove fallback mode. GLSL 1.20 or better is now required.

  • Loading branch information...
1 parent 97ef0ae commit c825e9bf7e299f2bb6cd8b0921bee0df69c38142 @perim perim committed Feb 9, 2013
@@ -135,19 +135,10 @@ static std::vector<SHAPE> shapes;
static void pie_Draw3DButton2(iIMDShape *shape, const PIELIGHT &colour, const PIELIGHT &teamcolour)
{
- const bool shaders = pie_GetShaderUsage();
-
pie_SetAlphaTest(true);
pie_SetFogStatus(false);
pie_SetDepthBufferStatus(DEPTH_CMP_LEQ_WRT_ON);
- if (shaders)
- {
- pie_ActivateShader(SHADER_BUTTON, shape, teamcolour, colour);
- }
- else
- {
- pie_ActivateFallback(SHADER_BUTTON, shape, teamcolour, colour);
- }
+ pie_ActivateShader(SHADER_BUTTON, shape, teamcolour, colour);
pie_SetRendMode(REND_OPAQUE);
glColor4ubv(colour.vector); // Only need to set once for entire model
pie_SetTexturePage(shape->texpage);
@@ -158,39 +149,18 @@ static void pie_Draw3DButton2(iIMDShape *shape, const PIELIGHT &colour, const PI
glBindBuffer(GL_ARRAY_BUFFER, shape->buffers[VBO_NORMAL]); glNormalPointer(GL_FLOAT, 0, NULL);
glBindBuffer(GL_ARRAY_BUFFER, shape->buffers[VBO_TEXCOORD]); glTexCoordPointer(2, GL_FLOAT, 0, NULL);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, shape->buffers[VBO_INDEX]);
- if (!shaders)
- {
- glClientActiveTexture(GL_TEXTURE1);
- glEnableClientState(GL_TEXTURE_COORD_ARRAY);
- glBindBuffer(GL_ARRAY_BUFFER, shape->buffers[VBO_TEXCOORD]); glTexCoordPointer(2, GL_FLOAT, 0, NULL);
- }
glDrawElements(GL_TRIANGLES, shape->npolys * 3, GL_UNSIGNED_SHORT, NULL);
- if (!shaders)
- {
- glDisableClientState(GL_TEXTURE_COORD_ARRAY);
- glClientActiveTexture(GL_TEXTURE0);
- }
glDisableClientState(GL_VERTEX_ARRAY);
glDisableClientState(GL_NORMAL_ARRAY);
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
-
polyCount += shape->npolys;
-
- if (shaders)
- {
- pie_DeactivateShader();
- }
- else
- {
- pie_DeactivateFallback();
- }
+ pie_DeactivateShader();
pie_SetDepthBufferStatus(DEPTH_CMP_ALWAYS_WRT_ON);
}
static void pie_Draw3DShape2(iIMDShape *shape, int frame, PIELIGHT colour, PIELIGHT teamcolour, int pieFlag, int pieFlagData)
{
bool light = true;
- bool shaders = pie_GetShaderUsage();
pie_SetAlphaTest((pieFlag & pie_PREMULTIPLIED) == 0);
@@ -239,25 +209,11 @@ static void pie_Draw3DShape2(iIMDShape *shape, int frame, PIELIGHT colour, PIELI
glMaterialfv(GL_FRONT, GL_SPECULAR, shape->material[LIGHT_SPECULAR]);
glMaterialf(GL_FRONT, GL_SHININESS, shape->shininess);
glMaterialfv(GL_FRONT, GL_EMISSION, shape->material[LIGHT_EMISSIVE]);
- if (shaders)
- {
- pie_ActivateShader(SHADER_COMPONENT, shape, teamcolour, colour);
- }
- else
- {
- pie_ActivateFallback(SHADER_COMPONENT, shape, teamcolour, colour);
- }
+ pie_ActivateShader(SHADER_COMPONENT, shape, teamcolour, colour);
}
else
{
- if (shaders)
- {
- pie_DeactivateShader();
- }
- else
- {
- pie_DeactivateFallback();
- }
+ pie_DeactivateShader();
}
if (pieFlag & pie_HEIGHT_SCALED) // construct
@@ -278,18 +234,7 @@ static void pie_Draw3DShape2(iIMDShape *shape, int frame, PIELIGHT colour, PIELI
glBindBuffer(GL_ARRAY_BUFFER, shape->buffers[VBO_NORMAL]); glNormalPointer(GL_FLOAT, 0, NULL);
glBindBuffer(GL_ARRAY_BUFFER, shape->buffers[VBO_TEXCOORD]); glTexCoordPointer(2, GL_FLOAT, 0, NULL);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, shape->buffers[VBO_INDEX]);
- if (!shaders)
- {
- glClientActiveTexture(GL_TEXTURE1);
- glEnableClientState(GL_TEXTURE_COORD_ARRAY);
- glBindBuffer(GL_ARRAY_BUFFER, shape->buffers[VBO_TEXCOORD]); glTexCoordPointer(2, GL_FLOAT, 0, NULL);
- }
glDrawElements(GL_TRIANGLES, shape->npolys * 3, GL_UNSIGNED_SHORT, BUFFER_OFFSET(frame * shape->npolys * 3 * sizeof(uint16_t)));
- if (!shaders)
- {
- glDisableClientState(GL_TEXTURE_COORD_ARRAY);
- glClientActiveTexture(GL_TEXTURE0);
- }
polyCount += shape->npolys;
@@ -618,14 +563,7 @@ void pie_RemainingPasses(void)
glDisableClientState(GL_VERTEX_ARRAY);
glDisableClientState(GL_NORMAL_ARRAY);
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
- if (pie_GetShaderUsage())
- {
- pie_DeactivateShader();
- }
- else
- {
- pie_DeactivateFallback();
- }
+ pie_DeactivateShader();
glPopMatrix();
tshapes.resize(0);
shapes.resize(0);
@@ -36,9 +36,6 @@
* Global Variables
*/
-static bool shadersAvailable = false;
-static bool shaderUsage = false;
-static bool fallbackAvailable = true;
static GLuint shaderProgram[SHADER_MAX];
static GLfloat shaderStretch = 0;
static GLint locTeam, locStretch, locTCMask, locFog, locNormalMap, locEcm, locTime;
@@ -131,39 +128,6 @@ PIELIGHT pie_GetFogColour(void)
return rendStates.fogColour;
}
-bool pie_GetShaderAvailability(void)
-{
- return shadersAvailable;
-}
-
-void pie_SetShaderAvailability(bool availability)
-{
- shadersAvailable = availability;
-}
-
-bool pie_GetFallbackAvailability(void)
-{
- return fallbackAvailable;
-}
-
-void pie_SetFallbackAvailability(bool availability)
-{
- fallbackAvailable = availability;
-}
-
-bool pie_GetShaderUsage(void)
-{
- return shaderUsage;
-}
-
-void pie_SetShaderUsage(bool usage)
-{
- bool valid = !usage && pie_GetFallbackAvailability();
- valid = valid || (usage && pie_GetShaderAvailability());
- if (valid)
- shaderUsage = usage;
-}
-
// Read shader into text buffer
static char *readShaderBuf(const char *name)
{
@@ -365,78 +329,6 @@ void pie_SetShaderStretchDepth(float stretch)
shaderStretch = stretch;
}
-void pie_ActivateFallback(SHADER_MODE, iIMDShape* shape, PIELIGHT teamcolour, PIELIGHT colour)
-{
- if (shape->tcmaskpage == iV_TEX_INVALID)
- {
- return;
- }
-
- //Set the environment colour with tcmask
- GLfloat tc_env_colour[4];
- pal_PIELIGHTtoRGBA4f(&tc_env_colour[0], teamcolour);
-
- // TU0
- glActiveTexture(GL_TEXTURE0);
- pie_SetTexturePage(shape->texpage);
- glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE);
- glTexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, tc_env_colour);
-
- // TU0 RGB
- glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_ADD_SIGNED);
- glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB, GL_TEXTURE);
- glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB, GL_SRC_COLOR);
- glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB, GL_CONSTANT);
- glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_RGB, GL_SRC_COLOR);
-
- // TU0 Alpha
- glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_ALPHA, GL_REPLACE);
- glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA, GL_TEXTURE);
- glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_ALPHA, GL_SRC_ALPHA);
-
- // TU1
- glActiveTexture(GL_TEXTURE1);
- glEnable(GL_TEXTURE_2D);
- glBindTexture(GL_TEXTURE_2D, pie_Texture(shape->tcmaskpage));
- glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE);
-
- // TU1 RGB
- glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_INTERPOLATE);
- glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB, GL_PREVIOUS);
- glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB, GL_SRC_COLOR);
- glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB, GL_TEXTURE0);
- glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_RGB, GL_SRC_COLOR);
- glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE2_RGB, GL_TEXTURE);
- glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND2_RGB, GL_SRC_ALPHA);
-
- // TU1 Alpha
- glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_ALPHA, GL_REPLACE);
- glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA, GL_PREVIOUS);
- glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_ALPHA, GL_SRC_ALPHA);
-
- if (GLEW_ARB_imaging || GLEW_EXT_blend_color)
- {
- glEnable(GL_BLEND);
- glBlendFunc(GL_CONSTANT_COLOR, GL_ZERO);
- glBlendColor(colour.byte.r / 255.0, colour.byte.g / 255.0, colour.byte.b / 255.0, colour.byte.a / 255.0);
- }
-
- glActiveTexture(GL_TEXTURE0);
-}
-
-void pie_DeactivateFallback()
-{
- glDisable(GL_BLEND);
- rendStates.rendMode = REND_OPAQUE;
-
- glActiveTexture(GL_TEXTURE1);
- glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
- glDisable(GL_TEXTURE_2D);
-
- glActiveTexture(GL_TEXTURE0);
- glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
-}
-
void pie_ActivateShader(SHADER_MODE shaderMode, iIMDShape* shape, PIELIGHT teamcolour, PIELIGHT colour)
{
int maskpage = shape->tcmaskpage;
View
@@ -82,20 +82,11 @@ extern void pie_SetTexturePage(SDWORD num);
extern void pie_SetAlphaTest(bool keyingOn);
extern void pie_SetRendMode(REND_MODE rendMode);
-// Shaders control center
-extern bool pie_GetShaderAvailability(void);
-extern void pie_SetShaderAvailability(bool);
-extern bool pie_GetFallbackAvailability(void);
-extern void pie_SetFallbackAvailability(bool);
-extern bool pie_GetShaderUsage(void);
-extern void pie_SetShaderUsage(bool);
-
-bool pie_LoadShaders(void);
+bool pie_LoadShaders();
+
// Actual shaders (we do not want to export these calls)
-void pie_DeactivateShader(void);
-void pie_DeactivateFallback(void);
void pie_ActivateShader(SHADER_MODE shaderMode, iIMDShape* shape, PIELIGHT teamcolour, PIELIGHT colour);
-void pie_ActivateFallback(SHADER_MODE shaderMode, iIMDShape* shape, PIELIGHT teamcolour, PIELIGHT colour);
+void pie_DeactivateShader();
void pie_SetShaderStretchDepth(float stretch);
void pie_SetShaderTime(uint32_t shaderTime);
void pie_SetShaderEcmEffect(bool value);
View
@@ -168,30 +168,13 @@ bool screenInitialise()
}
bool haveARB_vertex_buffer_object = GLEW_ARB_vertex_buffer_object || GLEW_VERSION_1_5;
- bool haveARB_texture_env_crossbar = GLEW_ARB_texture_env_crossbar || GLEW_NV_texture_env_combine4 || GLEW_VERSION_1_4;
- bool canRunFallback = GLEW_VERSION_1_2 && haveARB_vertex_buffer_object && haveARB_texture_env_crossbar;
bool canRunShaders = GLEW_VERSION_1_2 && haveARB_vertex_buffer_object && glslVersion >= std::make_pair(1, 20); // glGetString(GL_SHADING_LANGUAGE_VERSION) >= "1.20"
- pie_SetFallbackAvailability(canRunFallback);
-
- if (canRunShaders)
- {
- screen_EnableMissingFunctions(); // We need to do this before pie_LoadShaders(), but the effect of this call will be undone later by iV_TextInit(), so we will need to call it again.
- if (pie_LoadShaders())
- {
- pie_SetShaderAvailability(true);
- }
- }
- else if (canRunFallback)
- {
- // corner cases: vbo(core 1.5 or ARB ext), texture crossbar (core 1.4 or ARB ext)
- debug(LOG_POPUP, _("OpenGL GLSL shader version 1.20 is not supported by your system. Some things may look wrong. Please upgrade your graphics driver/hardware, if possible."));
- }
- else
+ screen_EnableMissingFunctions(); // We need to do this before pie_LoadShaders(), but the effect of this call will be undone later by iV_TextInit(), so we will need to call it again.
+ if (!canRunShaders || !pie_LoadShaders())
{
- // We write this file in hopes that people will upload the information in it to us.
writeGameInfo("WZdebuginfo.txt");
- debug(LOG_FATAL, _("OpenGL 1.2 + VBO + TEC is not supported by your system. The game requires this. Please upgrade your graphics drivers/hardware, if possible."));
+ debug(LOG_FATAL, _("OpenGL GLSL shader version 1.20 is not supported by your system. The game requires this. Please upgrade your graphics drivers/hardware, if possible."));
exit(1);
}
View
@@ -232,7 +232,6 @@ typedef enum
CLI_CRASH,
CLI_TEXTURECOMPRESSION,
CLI_NOTEXTURECOMPRESSION,
- CLI_FALLBACKMODE,
} CLI_OPTIONS;
static const struct poptOption* getOptionsTable(void)
@@ -264,7 +263,6 @@ static const struct poptOption* getOptionsTable(void)
{ "host", '\0', POPT_ARG_NONE, NULL, CLI_HOSTLAUNCH, N_("go directly to host screen"), NULL },
{ "texturecompression", '\0', POPT_ARG_NONE, NULL, CLI_TEXTURECOMPRESSION, N_("Enable texture compression"), NULL },
{ "notexturecompression", '\0', POPT_ARG_NONE, NULL, CLI_NOTEXTURECOMPRESSION, N_("Disable texture compression"), NULL },
- { "fallback-mode", '\0', POPT_ARG_NONE, NULL, CLI_FALLBACKMODE, N_("Only use OpenGL 1.5"), NULL },
// Terminating entry
{ NULL, '\0', 0, NULL, 0, NULL, NULL },
};
@@ -597,10 +595,6 @@ bool ParseCommandLine(int argc, const char** argv)
case CLI_NOTEXTURECOMPRESSION:
wz_texture_compression = GL_RGBA;
break;
-
- case CLI_FALLBACKMODE:
- war_SetShaders(SHADERS_OFF);
- break;
};
}
View
@@ -44,7 +44,7 @@
#include "radar.h"
#include "seqdisp.h"
#include "texture.h"
-#include "warzoneconfig.h" // renderMode
+#include "warzoneconfig.h"
// ////////////////////////////////////////////////////////////////////////////
@@ -117,7 +117,6 @@ bool loadConfig()
if (ini.contains("textureSize")) setTextureSize(ini.value("textureSize").toInt());
NetPlay.isUPNP = ini.value("UPnP", true).toBool();
if (ini.contains("FSAA")) war_setFSAA(ini.value("FSAA").toInt());
- if (ini.contains("shaders")) war_SetShaders(ini.value("shaders").toInt());
// Leave this to false, some system will fail and they can't see the system popup dialog!
war_setFullscreen(ini.value("fullscreen", false).toBool());
war_SetTrapCursor(ini.value("trapCursor", false).toBool());
@@ -184,7 +183,6 @@ bool saveConfig()
ini.setValue("radarTerrainMode",(SDWORD)radarDrawMode);
ini.setValue("trapCursor", war_GetTrapCursor());
ini.setValue("vsync", war_GetVsync());
- ini.setValue("shaders", war_GetShaders());
ini.setValue("textureSize", getTextureSize());
ini.setValue("FSAA", war_getFSAA());
ini.setValue("UPnP", (SDWORD)NetPlay.isUPNP);
Oops, something went wrong.

0 comments on commit c825e9b

Please sign in to comment.