Skip to content

Commit

Permalink
fix #5850
Browse files Browse the repository at this point in the history
  • Loading branch information
rt committed Dec 5, 2017
1 parent b4cd4a1 commit b55d2f9
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
19 changes: 10 additions & 9 deletions rts/Rendering/Env/BumpWater.cpp
Expand Up @@ -147,7 +147,7 @@ CBumpWater::CBumpWater()

// LOAD TEXTURES
foamTexture = LoadTexture(waterRendering->foamTexture);
normalTexture = LoadTexture(waterRendering->normalTexture , anisotropy , &normalTextureX, &normalTextureY);
normalTexture = LoadTexture(waterRendering->normalTexture, anisotropy, &normalTextureX, &normalTextureY);

// caustic textures
if (waterRendering->causticTextures.empty())
Expand Down Expand Up @@ -229,20 +229,18 @@ CBumpWater::CBumpWater()
coastFBO.Bind();
coastFBO.AttachTexture(coastTexture, GL_TEXTURE_2D, GL_COLOR_ATTACHMENT0);

if (coastFBO.CheckStatus("BUMPWATER(Coastmap)")) {
if ((shoreWaves = coastFBO.CheckStatus("BUMPWATER(Coastmap)"))) {
// initialize texture
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
glClear(GL_COLOR_BUFFER_BIT);

// fill with current heightmap/coastmap
UnsyncedHeightMapUpdate(SRectangle(0, 0, mapDims.mapx, mapDims.mapy));
UploadCoastline(true);
UpdateCoastmap();
} else
shoreWaves = false;
UpdateCoastmap(true);

if (shoreWaves)
eventHandler.InsertEvent(this, "UnsyncedHeightMapUpdate");
}

//coastFBO.Unbind(); // gets done below
}
Expand Down Expand Up @@ -335,6 +333,7 @@ CBumpWater::CBumpWater()
if (dynWavesFBO.CheckStatus("BUMPWATER(DynWaves)"))
UpdateDynWaves(true); // initialize
}

FBO::Unbind();
}

Expand Down Expand Up @@ -842,7 +841,7 @@ void CBumpWater::UploadCoastline(const bool forceFull)
}


void CBumpWater::UpdateCoastmap()
void CBumpWater::UpdateCoastmap(const bool initialize)
{
coastFBO.Bind();
glPushAttrib(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT | GL_ENABLE_BIT);
Expand Down Expand Up @@ -935,7 +934,9 @@ void CBumpWater::UpdateCoastmap()
blurShader->Disable();
coastFBO.Detach(GL_COLOR_ATTACHMENT1);
glPopAttrib();
//coastFBO.Unbind();

// NB: not needed during init, but no reason to leave bound after ::Update
coastFBO.Unbind();

// generate mipmaps
//glActiveTexture(GL_TEXTURE0);
Expand All @@ -950,7 +951,7 @@ void CBumpWater::UpdateCoastmap()
glDeleteTextures(1, &coastUpdateTexture);
coastmapAtlasRects.clear();

//glViewport(globalRendering->viewPosX, 0, globalRendering->viewSizeX, globalRendering->viewSizeY);
glViewport(globalRendering->viewPosX, 0, globalRendering->viewSizeX, globalRendering->viewSizeY);
glActiveTexture(GL_TEXTURE0);
}

Expand Down
2 changes: 1 addition & 1 deletion rts/Rendering/Env/BumpWater.h
Expand Up @@ -67,7 +67,7 @@ class CBumpWater : public IWater, public CEventClient
CRectangleOptimizer heightmapUpdates;

void UploadCoastline(const bool forceFull = false);
void UpdateCoastmap();
void UpdateCoastmap(const bool initialize = false);
void UpdateDynWaves(const bool initialize = false);
void UnsyncedHeightMapUpdate(const SRectangle& rect);

Expand Down

0 comments on commit b55d2f9

Please sign in to comment.