Skip to content

Commit

Permalink
fix #5082
Browse files Browse the repository at this point in the history
fix infotex being bound by FeatureDrawer for no reason (WTF--)
  • Loading branch information
rtri committed Feb 11, 2016
1 parent 788c804 commit 7172dc9
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 38 deletions.
23 changes: 0 additions & 23 deletions rts/Rendering/FeatureDrawer.cpp
Expand Up @@ -16,7 +16,6 @@
#include "Rendering/GL/glExtra.h"
#include "Rendering/GL/myGL.h"
#include "Rendering/GL/VertexArray.h"
#include "Rendering/Map/InfoTexture/IInfoTextureHandler.h"
#include "Rendering/LuaObjectDrawer.h"
#include "Rendering/ShadowHandler.h"
#include "Rendering/Shaders/Shader.h"
Expand Down Expand Up @@ -270,19 +269,6 @@ void CFeatureDrawer::Draw()
{
sky->SetupFog();

if (infoTextureHandler->IsEnabled()) {
glActiveTextureARB(GL_TEXTURE2_ARB);
glEnable(GL_TEXTURE_2D);
glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_ARB, GL_ADD_SIGNED_ARB);
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_ARB);

glMultiTexCoord4f(GL_TEXTURE2_ARB, 1.0f,1.0f,1.0f,1.0f); // workaround a nvidia bug with TexGen
SetTexGen(1.0f / (mapDims.pwr2mapx * SQUARE_SIZE), 1.0f / (mapDims.pwr2mapy * SQUARE_SIZE), 0.0f, 0.0f);

glBindTexture(GL_TEXTURE_2D, infoTextureHandler->GetCurrentInfoTexture());
glActiveTextureARB(GL_TEXTURE0_ARB);
}

// mark all features (in the quads we can see) with a FD_*_FLAG value
// the passes below will ignore any features whose marker is not valid
GetVisibleFeatures(CCamera::GetActiveCamera(), 0, true);
Expand All @@ -300,15 +286,6 @@ void CFeatureDrawer::Draw()

farTextureHandler->Draw();

if (infoTextureHandler->IsEnabled()) {
glActiveTextureARB(GL_TEXTURE2_ARB);
glDisable(GL_TEXTURE_2D);
glDisable(GL_TEXTURE_GEN_S);
glDisable(GL_TEXTURE_GEN_T);
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
glActiveTextureARB(GL_TEXTURE0_ARB);
}

glDisable(GL_TEXTURE_2D);
glDisable(GL_FOG);
}
Expand Down
4 changes: 4 additions & 0 deletions rts/Rendering/UnitDrawerState.cpp
Expand Up @@ -177,7 +177,11 @@ bool UnitDrawerStateFFP::CanEnable(const CUnitDrawer* ud) const {

void UnitDrawerStateFFP::Enable(const CUnitDrawer* ud, bool deferredPass, bool alphaPass) {
glEnable(GL_LIGHTING);
// only for the advshading=0 case
glLightfv(GL_LIGHT1, GL_POSITION, sky->GetLight()->GetLightDir());
glLightfv(GL_LIGHT1, GL_AMBIENT, sunLighting->unitAmbientColor);
glLightfv(GL_LIGHT1, GL_DIFFUSE, sunLighting->unitDiffuseColor);
glLightfv(GL_LIGHT1, GL_SPECULAR, sunLighting->unitAmbientColor);
glEnable(GL_LIGHT1);

CUnitDrawer::SetupBasicS3OTexture1();
Expand Down
13 changes: 0 additions & 13 deletions rts/Rendering/WorldDrawer.cpp
Expand Up @@ -41,18 +41,6 @@
#include "System/TimeProfiler.h"
#include "System/Util.h"

// not used by shaders, only for the advshading=0 case!
static void SetupUnitLightFFP()
{
glLightfv(GL_LIGHT1, GL_AMBIENT, sunLighting->unitAmbientColor);
glLightfv(GL_LIGHT1, GL_DIFFUSE, sunLighting->unitDiffuseColor);
glLightfv(GL_LIGHT1, GL_SPECULAR, sunLighting->unitAmbientColor);
glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, 0);
glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, 0);
}



CWorldDrawer::CWorldDrawer(): numUpdates(0)
{
CShaderHandler::GetInstance(0);
Expand Down Expand Up @@ -137,7 +125,6 @@ void CWorldDrawer::LoadPost() const
loadscreen->SetLoadMessage("Creating Water");
water = IWater::GetWater(NULL, -1);

SetupUnitLightFFP();
sky->SetupFog();
}

Expand Down
7 changes: 5 additions & 2 deletions rts/System/SpringApp.cpp
Expand Up @@ -577,6 +577,10 @@ void SpringApp::InitOpenGL()
glEnable(GL_DEPTH_TEST);
glDepthFunc(GL_LEQUAL);

// FFP model lighting
glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, 0.0f);
glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, 0);

// Clear Window
glClearColor(0.0f,0.0f,0.0f,0.0f);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
Expand Down Expand Up @@ -728,8 +732,7 @@ void SpringApp::ParseCmdLine(const std::string& binaryName)
// Runtime Tests
if (cmdline->IsSet("test-creg")) {
#ifdef USING_CREG
const int res = creg::RuntimeTest() ? EXIT_SUCCESS : EXIT_FAILURE;
exit(res);
exit(creg::RuntimeTest() ? EXIT_SUCCESS : EXIT_FAILURE);
#else
LOG_L(L_ERROR, "Creg is not enabled!\n");
exit(EXIT_FAILURE); //Do not fail tests
Expand Down

0 comments on commit 7172dc9

Please sign in to comment.