2006-01-07 02:04:26 +01:00
|
|
|
/**
|
|
|
|
* =========================================================================
|
|
|
|
* File : TerrainRenderer.cpp
|
|
|
|
* Project : Pyrogenesis
|
|
|
|
* Description : Terrain rendering (everything related to patches and
|
|
|
|
* : water) is encapsulated in TerrainRenderer
|
|
|
|
*
|
2006-07-26 16:04:52 +02:00
|
|
|
* @author Nicolai Haehnle <nicolai@wildfiregames.com>
|
2006-01-07 02:04:26 +01:00
|
|
|
* =========================================================================
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "precompiled.h"
|
|
|
|
|
|
|
|
#include "graphics/Camera.h"
|
2006-02-13 15:18:20 +01:00
|
|
|
#include "graphics/LightEnv.h"
|
2006-01-07 02:04:26 +01:00
|
|
|
#include "graphics/Patch.h"
|
|
|
|
#include "graphics/Terrain.h"
|
2006-03-21 21:55:45 +01:00
|
|
|
#include "graphics/GameView.h"
|
2006-01-07 02:04:26 +01:00
|
|
|
|
|
|
|
#include "maths/MathUtil.h"
|
|
|
|
|
|
|
|
#include "ps/Game.h"
|
|
|
|
#include "ps/Profile.h"
|
2006-06-02 05:56:24 +02:00
|
|
|
#include "ps/Pyrogenesis.h" // MICROLOG
|
2006-01-07 02:04:26 +01:00
|
|
|
|
|
|
|
#include "simulation/LOSManager.h"
|
|
|
|
|
|
|
|
#include "renderer/PatchRData.h"
|
|
|
|
#include "renderer/Renderer.h"
|
2006-02-11 19:04:32 +01:00
|
|
|
#include "renderer/ShadowMap.h"
|
2006-01-07 02:04:26 +01:00
|
|
|
#include "renderer/TerrainRenderer.h"
|
|
|
|
#include "renderer/WaterManager.h"
|
|
|
|
|
2006-05-25 07:46:17 +02:00
|
|
|
#include "lib/res/graphics/ogl_shader.h"
|
|
|
|
|
2006-01-07 02:04:26 +01:00
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// TerrainRenderer implementation
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* TerrainRenderer keeps track of which phase it is in, to detect
|
|
|
|
* when Submit, PrepareForRendering etc. are called in the wrong order.
|
|
|
|
*/
|
|
|
|
enum Phase {
|
|
|
|
Phase_Submit,
|
|
|
|
Phase_Render
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Struct TerrainRendererInternals: Internal variables used by the TerrainRenderer class.
|
|
|
|
*/
|
|
|
|
struct TerrainRendererInternals
|
|
|
|
{
|
|
|
|
/// Which phase (submitting or rendering patches) are we in right now?
|
|
|
|
Phase phase;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* VisiblePatches: Patches that were submitted for this frame
|
|
|
|
*
|
|
|
|
* @todo Merge this list with CPatchRData list
|
|
|
|
*/
|
|
|
|
std::vector<CPatch*> visiblePatches;
|
2006-05-25 07:46:17 +02:00
|
|
|
|
|
|
|
/// Fancy water shader
|
|
|
|
Handle fancyWaterShader;
|
2006-01-07 02:04:26 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////
|
|
|
|
// Construction/Destruction
|
|
|
|
TerrainRenderer::TerrainRenderer()
|
|
|
|
{
|
|
|
|
m = new TerrainRendererInternals();
|
|
|
|
m->phase = Phase_Submit;
|
2006-05-25 07:46:17 +02:00
|
|
|
m->fancyWaterShader = 0;
|
2006-01-07 02:04:26 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
TerrainRenderer::~TerrainRenderer()
|
|
|
|
{
|
2006-05-25 07:46:17 +02:00
|
|
|
if( m->fancyWaterShader )
|
|
|
|
{
|
|
|
|
ogl_program_free( m->fancyWaterShader );
|
|
|
|
}
|
2006-01-07 02:04:26 +01:00
|
|
|
delete m;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////
|
|
|
|
// Submit a patch for rendering
|
|
|
|
void TerrainRenderer::Submit(CPatch* patch)
|
|
|
|
{
|
|
|
|
debug_assert(m->phase == Phase_Submit);
|
|
|
|
|
|
|
|
CPatchRData* data=(CPatchRData*) patch->GetRenderData();
|
|
|
|
if (data == 0)
|
|
|
|
{
|
|
|
|
// no renderdata for patch, create it now
|
|
|
|
data = new CPatchRData(patch);
|
|
|
|
patch->SetRenderData(data);
|
|
|
|
}
|
|
|
|
data->Update();
|
|
|
|
|
|
|
|
m->visiblePatches.push_back(patch);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////
|
|
|
|
// Prepare for rendering
|
|
|
|
void TerrainRenderer::PrepareForRendering()
|
|
|
|
{
|
|
|
|
debug_assert(m->phase == Phase_Submit);
|
|
|
|
|
|
|
|
m->phase = Phase_Render;
|
|
|
|
}
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////
|
|
|
|
// Clear submissions lists
|
|
|
|
void TerrainRenderer::EndFrame()
|
|
|
|
{
|
|
|
|
debug_assert(m->phase == Phase_Render);
|
|
|
|
|
|
|
|
m->visiblePatches.clear();
|
|
|
|
|
|
|
|
m->phase = Phase_Submit;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////
|
|
|
|
// Query if patches have been submitted this frame
|
|
|
|
bool TerrainRenderer::HaveSubmissions()
|
|
|
|
{
|
# Added tool for viewing models and animations outside the game.
Atlas: Added ActorViewer. Moved GL canvas into separate class for shared
use. Disabled message-handling callback while blocked on the game, and
stopped creating dialog boxes inside the game thread in order to avoid
deadlocks (hopefully). Support multiple Views (for independent sets of
camera/update/render code). Recalculate territory boundaries when
necessary. Changed default list of animations to match those currently
used by actors.
# Tidied up more code.
Moved some more #includes out of .h files, to minimise unnecessary
compilation.
MathUtil: Deleted unused/unuseful macros (M_PI (use PI instead), M_PI_2
(use PI/2), MAX3, ABS (use abs)).
ObjectManager: Removed some ScEd-specific things.
Unit: Moved creation out of UnitManager, so units can be created without
adding to the manager. Changed CStr8 to the more conventional CStr.
app_hooks: Removed warning for setting multiple times.
win: Restored SEH catcher.
GameSetup, GameView: Removed RenderNoCull, because it doesn't seem to do
what it says it does ("force renderer to load everything") since we're
loading-on-demand most stuff and it doesn't seem especially useful since
we'd prefer to minimise loading times (but feel free to correct me if
I'm wrong). (And because it crashes when things need to be initialised
in a different order, so it's easier to remove than to understand and
fix it.)
PatchRData, Renderer: Work sensibly when there's no game (hence no LOS
manager, water, etc).
LOSManager: Use entity position instead of actor position when possible.
TerritoryManager: Allow delayed recalculations (so Atlas can issue lots
of move+recalculate commands per frame).
Cinematic: Non-pointer wxTimer, so it doesn't leak and doesn't have to
be deleted manually.
This was SVN commit r4261.
2006-08-28 19:36:42 +02:00
|
|
|
return !m->visiblePatches.empty();
|
2006-01-07 02:04:26 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////
|
|
|
|
// Full-featured terrain rendering with blending and everything
|
2006-02-13 15:18:20 +01:00
|
|
|
void TerrainRenderer::RenderTerrain(ShadowMap* shadow)
|
2006-01-07 02:04:26 +01:00
|
|
|
{
|
|
|
|
debug_assert(m->phase == Phase_Render);
|
|
|
|
|
|
|
|
// switch on required client states
|
|
|
|
glEnableClientState(GL_VERTEX_ARRAY);
|
|
|
|
glEnableClientState(GL_COLOR_ARRAY);
|
|
|
|
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
|
2006-03-31 05:30:34 +02:00
|
|
|
|
2006-02-13 15:18:20 +01:00
|
|
|
// render everything fullbright
|
2006-01-07 02:04:26 +01:00
|
|
|
// set up texture environment for base pass
|
|
|
|
MICROLOG(L"base splat textures");
|
|
|
|
pglActiveTextureARB(GL_TEXTURE0);
|
|
|
|
pglClientActiveTextureARB(GL_TEXTURE0);
|
|
|
|
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE);
|
|
|
|
glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_ARB, GL_MODULATE);
|
|
|
|
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB_ARB, GL_TEXTURE);
|
|
|
|
glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB_ARB, GL_SRC_COLOR);
|
|
|
|
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB_ARB, GL_PRIMARY_COLOR);
|
|
|
|
glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_RGB_ARB, GL_SRC_COLOR);
|
|
|
|
|
|
|
|
// Set alpha to 1.0
|
|
|
|
glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_ALPHA_ARB, GL_REPLACE);
|
|
|
|
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA_ARB, GL_CONSTANT);
|
|
|
|
glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_ALPHA_ARB, GL_SRC_ALPHA);
|
2006-02-15 01:45:16 +01:00
|
|
|
static const float one[4] = { 1.f, 1.f, 1.f, 1.f };
|
2006-01-07 02:04:26 +01:00
|
|
|
glTexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, one);
|
2006-03-31 05:30:34 +02:00
|
|
|
|
2006-01-07 02:04:26 +01:00
|
|
|
for(uint i = 0; i < m->visiblePatches.size(); ++i)
|
|
|
|
{
|
|
|
|
CPatchRData* patchdata = (CPatchRData*)m->visiblePatches[i]->GetRenderData();
|
2006-02-13 15:18:20 +01:00
|
|
|
patchdata->RenderBase(true); // with LOS color
|
2006-01-07 02:04:26 +01:00
|
|
|
}
|
2006-03-31 05:30:34 +02:00
|
|
|
|
2006-01-07 02:04:26 +01:00
|
|
|
// render blends
|
|
|
|
// switch on the composite alpha map texture
|
|
|
|
(void)ogl_tex_bind(g_Renderer.m_hCompositeAlphaMap, 1);
|
|
|
|
|
|
|
|
// switch on second uv set
|
|
|
|
pglClientActiveTextureARB(GL_TEXTURE1);
|
|
|
|
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
|
|
|
|
|
|
|
|
// setup additional texenv required by blend pass
|
|
|
|
pglActiveTextureARB(GL_TEXTURE1);
|
|
|
|
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE);
|
|
|
|
glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_ARB, GL_REPLACE);
|
|
|
|
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB_ARB, GL_PREVIOUS);
|
|
|
|
glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB_ARB, GL_SRC_COLOR);
|
|
|
|
glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_ALPHA_ARB, GL_REPLACE);
|
|
|
|
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA_ARB, GL_TEXTURE);
|
|
|
|
glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_ALPHA_ARB, GL_ONE_MINUS_SRC_ALPHA);
|
|
|
|
|
|
|
|
// switch on blending
|
|
|
|
glEnable(GL_BLEND);
|
|
|
|
glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
|
|
|
|
|
|
|
|
// no need to write to the depth buffer a second time
|
|
|
|
glDepthMask(0);
|
2006-03-31 05:30:34 +02:00
|
|
|
|
2006-01-07 02:04:26 +01:00
|
|
|
// render blend passes for each patch
|
|
|
|
for(uint i = 0; i < m->visiblePatches.size(); ++i)
|
|
|
|
{
|
|
|
|
CPatchRData* patchdata = (CPatchRData*)m->visiblePatches[i]->GetRenderData();
|
|
|
|
patchdata->RenderBlends();
|
|
|
|
}
|
2006-03-31 05:30:34 +02:00
|
|
|
|
2006-02-13 15:18:20 +01:00
|
|
|
// Disable second texcoord array
|
2006-01-07 02:04:26 +01:00
|
|
|
pglClientActiveTextureARB(GL_TEXTURE1);
|
|
|
|
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
|
2006-02-13 15:18:20 +01:00
|
|
|
|
|
|
|
// Now apply lighting
|
|
|
|
const CLightEnv& lightEnv = g_Renderer.GetLightEnv();
|
|
|
|
|
2006-02-15 01:45:16 +01:00
|
|
|
glBlendFunc(GL_DST_COLOR, GL_ZERO);
|
2006-03-31 05:30:34 +02:00
|
|
|
|
2006-02-15 01:45:16 +01:00
|
|
|
if (!shadow)
|
|
|
|
{
|
|
|
|
pglActiveTextureARB(GL_TEXTURE0);
|
|
|
|
glBindTexture(GL_TEXTURE_2D, 0);
|
|
|
|
|
|
|
|
// Shadow rendering disabled: Ambient + Diffuse
|
|
|
|
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE);
|
|
|
|
glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_ARB, GL_ADD);
|
|
|
|
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB_ARB, GL_PREVIOUS);
|
|
|
|
glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB_ARB, GL_SRC_COLOR);
|
|
|
|
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB_ARB, GL_CONSTANT);
|
|
|
|
glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_RGB_ARB, GL_SRC_COLOR);
|
|
|
|
glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_ALPHA_ARB, GL_REPLACE);
|
|
|
|
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA_ARB, GL_PREVIOUS);
|
|
|
|
glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_ALPHA_ARB, GL_SRC_ALPHA);
|
|
|
|
|
|
|
|
glTexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, &lightEnv.m_TerrainAmbientColor.X);
|
2006-03-31 05:30:34 +02:00
|
|
|
|
2006-02-15 01:45:16 +01:00
|
|
|
}
|
|
|
|
else
|
2006-02-13 15:18:20 +01:00
|
|
|
{
|
|
|
|
const CMatrix3D& texturematrix = shadow->GetTextureMatrix();
|
|
|
|
|
2006-02-15 01:45:16 +01:00
|
|
|
pglActiveTextureARB(GL_TEXTURE0);
|
2006-02-13 15:18:20 +01:00
|
|
|
glMatrixMode(GL_TEXTURE);
|
|
|
|
glLoadMatrixf(&texturematrix._11);
|
|
|
|
glMatrixMode(GL_MODELVIEW);
|
2006-02-15 01:45:16 +01:00
|
|
|
|
|
|
|
glBindTexture(GL_TEXTURE_2D, shadow->GetTexture());
|
|
|
|
|
|
|
|
if (shadow->GetUseDepthTexture())
|
|
|
|
{
|
|
|
|
// Ambient + ShTranslucency * Diffuse * (1 - Shadow) + Diffuse * Shadow
|
|
|
|
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE);
|
|
|
|
glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_ARB, GL_MODULATE);
|
|
|
|
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB_ARB, GL_PRIMARY_COLOR);
|
|
|
|
glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB_ARB, GL_SRC_COLOR);
|
|
|
|
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB_ARB, GL_CONSTANT);
|
|
|
|
glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_RGB_ARB, GL_SRC_COLOR);
|
|
|
|
glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_ALPHA_ARB, GL_REPLACE);
|
|
|
|
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA_ARB, GL_PREVIOUS);
|
|
|
|
glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_ALPHA_ARB, GL_SRC_ALPHA);
|
|
|
|
|
|
|
|
float shadowTransp = g_Renderer.GetLightEnv().GetTerrainShadowTransparency();
|
|
|
|
float color[4] = { shadowTransp, shadowTransp, shadowTransp, 1.0 };
|
|
|
|
glTexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, color);
|
|
|
|
|
|
|
|
pglActiveTextureARB(GL_TEXTURE1);
|
|
|
|
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE);
|
|
|
|
glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_ARB, GL_INTERPOLATE);
|
|
|
|
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB_ARB, GL_PRIMARY_COLOR);
|
|
|
|
glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB_ARB, GL_SRC_COLOR);
|
|
|
|
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB_ARB, GL_PREVIOUS);
|
|
|
|
glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_RGB_ARB, GL_SRC_COLOR);
|
|
|
|
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE2_RGB_ARB, GL_TEXTURE0);
|
|
|
|
glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND2_RGB_ARB, GL_SRC_COLOR);
|
|
|
|
glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_ALPHA_ARB, GL_REPLACE);
|
|
|
|
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA_ARB, GL_PREVIOUS);
|
|
|
|
glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_ALPHA_ARB, GL_SRC_ALPHA);
|
|
|
|
|
|
|
|
pglActiveTextureARB(GL_TEXTURE2);
|
|
|
|
glEnable(GL_TEXTURE_2D);
|
|
|
|
glBindTexture(GL_TEXTURE_2D, shadow->GetTexture()); // Need a valid texture or the unit will be disabled
|
|
|
|
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE);
|
|
|
|
glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_ARB, GL_ADD);
|
|
|
|
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB_ARB, GL_PREVIOUS);
|
|
|
|
glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB_ARB, GL_SRC_COLOR);
|
|
|
|
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB_ARB, GL_CONSTANT);
|
|
|
|
glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_RGB_ARB, GL_SRC_COLOR);
|
|
|
|
glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_ALPHA_ARB, GL_REPLACE);
|
|
|
|
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA_ARB, GL_PREVIOUS);
|
|
|
|
glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_ALPHA_ARB, GL_SRC_ALPHA);
|
|
|
|
|
|
|
|
glTexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, &lightEnv.m_TerrainAmbientColor.X);
|
2006-03-31 05:30:34 +02:00
|
|
|
|
2006-02-15 01:45:16 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Ambient + Diffuse * Shadow
|
|
|
|
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE);
|
|
|
|
glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_ARB, GL_MODULATE);
|
|
|
|
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB_ARB, GL_PREVIOUS);
|
|
|
|
glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB_ARB, GL_SRC_COLOR);
|
|
|
|
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB_ARB, GL_TEXTURE);
|
|
|
|
glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_RGB_ARB, GL_SRC_COLOR);
|
|
|
|
glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_ALPHA_ARB, GL_REPLACE);
|
|
|
|
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA_ARB, GL_PREVIOUS);
|
|
|
|
glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_ALPHA_ARB, GL_SRC_ALPHA);
|
|
|
|
|
|
|
|
pglActiveTextureARB(GL_TEXTURE1); // + Ambient
|
|
|
|
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE);
|
|
|
|
glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_ARB, GL_ADD);
|
|
|
|
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB_ARB, GL_PREVIOUS);
|
|
|
|
glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB_ARB, GL_SRC_COLOR);
|
|
|
|
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB_ARB, GL_CONSTANT);
|
|
|
|
glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_RGB_ARB, GL_SRC_COLOR);
|
|
|
|
glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_ALPHA_ARB, GL_REPLACE);
|
|
|
|
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA_ARB, GL_PREVIOUS);
|
|
|
|
glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_ALPHA_ARB, GL_SRC_ALPHA);
|
|
|
|
|
|
|
|
glTexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, &lightEnv.m_TerrainAmbientColor.X);
|
2006-03-31 05:30:34 +02:00
|
|
|
|
2006-02-15 01:45:16 +01:00
|
|
|
}
|
2006-02-13 15:18:20 +01:00
|
|
|
}
|
|
|
|
|
2006-02-15 01:45:16 +01:00
|
|
|
pglActiveTextureARB(GL_TEXTURE0);
|
2006-02-13 15:18:20 +01:00
|
|
|
pglClientActiveTextureARB(GL_TEXTURE0);
|
2006-03-31 05:30:34 +02:00
|
|
|
|
2006-02-13 15:18:20 +01:00
|
|
|
for (uint i = 0; i < m->visiblePatches.size(); ++i)
|
|
|
|
{
|
|
|
|
CPatchRData* patchdata = (CPatchRData*)m->visiblePatches[i]->GetRenderData();
|
|
|
|
patchdata->RenderStreams(STREAM_POS|STREAM_COLOR|STREAM_POSTOUV0, false);
|
|
|
|
}
|
2006-03-31 05:30:34 +02:00
|
|
|
|
2006-02-13 15:18:20 +01:00
|
|
|
glMatrixMode(GL_TEXTURE);
|
|
|
|
glLoadIdentity();
|
|
|
|
glMatrixMode(GL_MODELVIEW);
|
|
|
|
|
|
|
|
// restore OpenGL state
|
# Added tool for viewing models and animations outside the game.
Atlas: Added ActorViewer. Moved GL canvas into separate class for shared
use. Disabled message-handling callback while blocked on the game, and
stopped creating dialog boxes inside the game thread in order to avoid
deadlocks (hopefully). Support multiple Views (for independent sets of
camera/update/render code). Recalculate territory boundaries when
necessary. Changed default list of animations to match those currently
used by actors.
# Tidied up more code.
Moved some more #includes out of .h files, to minimise unnecessary
compilation.
MathUtil: Deleted unused/unuseful macros (M_PI (use PI instead), M_PI_2
(use PI/2), MAX3, ABS (use abs)).
ObjectManager: Removed some ScEd-specific things.
Unit: Moved creation out of UnitManager, so units can be created without
adding to the manager. Changed CStr8 to the more conventional CStr.
app_hooks: Removed warning for setting multiple times.
win: Restored SEH catcher.
GameSetup, GameView: Removed RenderNoCull, because it doesn't seem to do
what it says it does ("force renderer to load everything") since we're
loading-on-demand most stuff and it doesn't seem especially useful since
we'd prefer to minimise loading times (but feel free to correct me if
I'm wrong). (And because it crashes when things need to be initialised
in a different order, so it's easier to remove than to understand and
fix it.)
PatchRData, Renderer: Work sensibly when there's no game (hence no LOS
manager, water, etc).
LOSManager: Use entity position instead of actor position when possible.
TerritoryManager: Allow delayed recalculations (so Atlas can issue lots
of move+recalculate commands per frame).
Cinematic: Non-pointer wxTimer, so it doesn't leak and doesn't have to
be deleted manually.
This was SVN commit r4261.
2006-08-28 19:36:42 +02:00
|
|
|
if (shadow)
|
2006-03-31 05:30:34 +02:00
|
|
|
{
|
# Added tool for viewing models and animations outside the game.
Atlas: Added ActorViewer. Moved GL canvas into separate class for shared
use. Disabled message-handling callback while blocked on the game, and
stopped creating dialog boxes inside the game thread in order to avoid
deadlocks (hopefully). Support multiple Views (for independent sets of
camera/update/render code). Recalculate territory boundaries when
necessary. Changed default list of animations to match those currently
used by actors.
# Tidied up more code.
Moved some more #includes out of .h files, to minimise unnecessary
compilation.
MathUtil: Deleted unused/unuseful macros (M_PI (use PI instead), M_PI_2
(use PI/2), MAX3, ABS (use abs)).
ObjectManager: Removed some ScEd-specific things.
Unit: Moved creation out of UnitManager, so units can be created without
adding to the manager. Changed CStr8 to the more conventional CStr.
app_hooks: Removed warning for setting multiple times.
win: Restored SEH catcher.
GameSetup, GameView: Removed RenderNoCull, because it doesn't seem to do
what it says it does ("force renderer to load everything") since we're
loading-on-demand most stuff and it doesn't seem especially useful since
we'd prefer to minimise loading times (but feel free to correct me if
I'm wrong). (And because it crashes when things need to be initialised
in a different order, so it's easier to remove than to understand and
fix it.)
PatchRData, Renderer: Work sensibly when there's no game (hence no LOS
manager, water, etc).
LOSManager: Use entity position instead of actor position when possible.
TerritoryManager: Allow delayed recalculations (so Atlas can issue lots
of move+recalculate commands per frame).
Cinematic: Non-pointer wxTimer, so it doesn't leak and doesn't have to
be deleted manually.
This was SVN commit r4261.
2006-08-28 19:36:42 +02:00
|
|
|
if (shadow->GetUseDepthTexture())
|
|
|
|
g_Renderer.BindTexture(2,0);
|
2006-03-31 05:30:34 +02:00
|
|
|
}
|
2006-01-07 02:04:26 +01:00
|
|
|
g_Renderer.BindTexture(1,0);
|
2006-02-11 19:04:32 +01:00
|
|
|
|
2006-01-07 02:04:26 +01:00
|
|
|
pglClientActiveTextureARB(GL_TEXTURE0);
|
|
|
|
pglActiveTextureARB(GL_TEXTURE0);
|
2006-02-13 15:18:20 +01:00
|
|
|
glDepthMask(1);
|
|
|
|
glDisable(GL_BLEND);
|
2006-01-07 02:04:26 +01:00
|
|
|
glDisableClientState(GL_COLOR_ARRAY);
|
|
|
|
glDisableClientState(GL_VERTEX_ARRAY);
|
2006-02-13 15:18:20 +01:00
|
|
|
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
|
2006-03-31 05:30:34 +02:00
|
|
|
|
2006-01-07 02:04:26 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////
|
|
|
|
// Render un-textured patches as polygons
|
|
|
|
void TerrainRenderer::RenderPatches()
|
|
|
|
{
|
|
|
|
debug_assert(m->phase == Phase_Render);
|
|
|
|
|
|
|
|
glEnableClientState(GL_VERTEX_ARRAY);
|
|
|
|
for(uint i = 0; i < m->visiblePatches.size(); ++i)
|
|
|
|
{
|
|
|
|
CPatchRData* patchdata = (CPatchRData*)m->visiblePatches[i]->GetRenderData();
|
2006-02-13 15:18:20 +01:00
|
|
|
patchdata->RenderStreams(STREAM_POS, true);
|
2006-01-07 02:04:26 +01:00
|
|
|
}
|
|
|
|
glDisableClientState(GL_VERTEX_ARRAY);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////
|
|
|
|
// Render outlines of submitted patches as lines
|
|
|
|
void TerrainRenderer::RenderOutlines()
|
|
|
|
{
|
|
|
|
glEnableClientState(GL_VERTEX_ARRAY);
|
|
|
|
for(uint i = 0; i < m->visiblePatches.size(); ++i)
|
|
|
|
{
|
|
|
|
CPatchRData* patchdata = (CPatchRData*)m->visiblePatches[i]->GetRenderData();
|
|
|
|
patchdata->RenderOutline();
|
|
|
|
}
|
|
|
|
glDisableClientState(GL_VERTEX_ARRAY);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////
|
|
|
|
// Render water that is part of the terrain
|
|
|
|
void TerrainRenderer::RenderWater()
|
|
|
|
{
|
2006-04-19 02:56:24 +02:00
|
|
|
PROFILE( "render water" );
|
2006-01-07 02:04:26 +01:00
|
|
|
|
2006-05-25 07:46:17 +02:00
|
|
|
bool fancy = g_Renderer.m_Options.m_FancyWater;
|
|
|
|
|
|
|
|
// If we're using fancy water, make sure its shader is loaded
|
|
|
|
if(fancy && !m->fancyWaterShader)
|
|
|
|
{
|
|
|
|
m->fancyWaterShader = ogl_program_load( "shaders/water_high.xml" );
|
|
|
|
}
|
2006-03-31 05:30:34 +02:00
|
|
|
|
|
|
|
//(Crappy) fresnel effect
|
2006-01-07 02:04:26 +01:00
|
|
|
CCamera* Camera=g_Game->GetView()->GetCamera();
|
|
|
|
CVector3D CamFace=Camera->m_Orientation.GetIn();
|
|
|
|
CamFace.Normalize();
|
|
|
|
float FresnelScalar = CamFace.Dot( CVector3D(0.0f, -1.0f, 0.0f) );
|
|
|
|
//Invert and set boundaries
|
|
|
|
FresnelScalar = (1 - FresnelScalar) * 0.4f + 0.6f;
|
|
|
|
|
|
|
|
CTerrain* terrain = g_Game->GetWorld()->GetTerrain();
|
|
|
|
int mapSize = terrain->GetVerticesPerSide();
|
|
|
|
CLOSManager* losMgr = g_Game->GetWorld()->GetLOSManager();
|
|
|
|
WaterManager* WaterMgr = g_Renderer.GetWaterManager();
|
2006-03-31 05:30:34 +02:00
|
|
|
|
2006-01-07 02:04:26 +01:00
|
|
|
glEnable(GL_BLEND);
|
|
|
|
glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
|
2006-05-29 02:49:09 +02:00
|
|
|
glEnable(GL_DEPTH_TEST);
|
|
|
|
glDepthFunc(GL_LEQUAL);
|
2006-01-07 02:04:26 +01:00
|
|
|
|
2006-01-22 00:27:42 +01:00
|
|
|
double time = WaterMgr->m_WaterTexTimer;
|
2006-01-07 02:04:26 +01:00
|
|
|
|
|
|
|
double period = 1.6;
|
|
|
|
int curTex = (int)(time*60/period) % 60;
|
|
|
|
|
2006-05-25 07:46:17 +02:00
|
|
|
if(fancy)
|
|
|
|
{
|
|
|
|
ogl_tex_bind(WaterMgr->m_NormalMap[curTex], 0);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ogl_tex_bind(WaterMgr->m_WaterTexture[curTex], 0);
|
|
|
|
}
|
2006-01-07 02:04:26 +01:00
|
|
|
|
2006-05-25 07:46:17 +02:00
|
|
|
if(!fancy)
|
|
|
|
{
|
|
|
|
// Shift the texture coordinates to make it "flow"
|
|
|
|
glMatrixMode(GL_TEXTURE);
|
|
|
|
glLoadIdentity();
|
|
|
|
float tx = -fmod(time, 20.0)/20.0;
|
|
|
|
float ty = fmod(time, 35.0)/35.0;
|
|
|
|
glTranslatef(tx, ty, 0);
|
|
|
|
|
|
|
|
// Set up texture environment to multiply vertex RGB by texture RGB and use vertex alpha
|
|
|
|
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE);
|
|
|
|
glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_ARB, GL_MODULATE);
|
|
|
|
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB_ARB, GL_TEXTURE);
|
|
|
|
glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB_ARB, GL_SRC_COLOR);
|
|
|
|
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB_ARB, GL_PRIMARY_COLOR_ARB);
|
|
|
|
glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_RGB_ARB, GL_SRC_COLOR);
|
|
|
|
glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_ALPHA_ARB, GL_REPLACE);
|
|
|
|
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA_ARB, GL_PRIMARY_COLOR_ARB);
|
|
|
|
glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_ALPHA_ARB, GL_SRC_ALPHA);
|
|
|
|
}
|
2006-01-07 02:04:26 +01:00
|
|
|
|
|
|
|
// Set the proper LOD bias
|
|
|
|
glTexEnvf(GL_TEXTURE_FILTER_CONTROL, GL_TEXTURE_LOD_BIAS, g_Renderer.m_Options.m_LodBias);
|
2006-03-31 05:30:34 +02:00
|
|
|
|
2006-05-25 07:46:17 +02:00
|
|
|
// Some offsets used to go around counterclockwise while keeping code concise
|
|
|
|
const int DX[] = {1,1,0,0};
|
|
|
|
const int DZ[] = {0,1,1,0};
|
|
|
|
|
|
|
|
GLint vertexDepth = 0; // water depth attribute, if using fancy water
|
2006-09-01 01:56:12 +02:00
|
|
|
GLint losMultiplier = 0; // LOS multiplier, if using fancy water
|
2006-05-25 07:46:17 +02:00
|
|
|
|
|
|
|
if(fancy)
|
|
|
|
{
|
2006-05-28 04:13:32 +02:00
|
|
|
// Bind reflection and refraction textures on texture units 1 and 2
|
|
|
|
pglActiveTextureARB( GL_TEXTURE1_ARB );
|
|
|
|
glEnable( GL_TEXTURE_2D );
|
|
|
|
glBindTexture( GL_TEXTURE_2D, WaterMgr->m_ReflectionTexture );
|
|
|
|
pglActiveTextureARB( GL_TEXTURE2_ARB );
|
|
|
|
glEnable( GL_TEXTURE_2D );
|
|
|
|
glBindTexture( GL_TEXTURE_2D, WaterMgr->m_RefractionTexture );
|
|
|
|
|
|
|
|
// Bind water shader and set arguments
|
2006-05-25 07:46:17 +02:00
|
|
|
ogl_program_use( m->fancyWaterShader );
|
|
|
|
|
|
|
|
GLint ambient = ogl_program_get_uniform_location( m->fancyWaterShader, "ambient" );
|
|
|
|
GLint sunDir = ogl_program_get_uniform_location( m->fancyWaterShader, "sunDir" );
|
|
|
|
GLint sunColor = ogl_program_get_uniform_location( m->fancyWaterShader, "sunColor" );
|
|
|
|
GLint shininess = ogl_program_get_uniform_location( m->fancyWaterShader, "shininess" );
|
2006-05-28 23:58:56 +02:00
|
|
|
GLint waviness = ogl_program_get_uniform_location( m->fancyWaterShader, "waviness" );
|
2006-06-22 23:11:18 +02:00
|
|
|
GLint murkiness = ogl_program_get_uniform_location( m->fancyWaterShader, "murkiness" );
|
|
|
|
GLint fullDepth = ogl_program_get_uniform_location( m->fancyWaterShader, "fullDepth" );
|
|
|
|
GLint tint = ogl_program_get_uniform_location( m->fancyWaterShader, "tint" );
|
2006-05-25 07:46:17 +02:00
|
|
|
GLint cameraPos = ogl_program_get_uniform_location( m->fancyWaterShader, "cameraPos" );
|
2006-05-28 04:13:32 +02:00
|
|
|
GLint reflectionMatrix = ogl_program_get_uniform_location( m->fancyWaterShader, "reflectionMatrix" );
|
|
|
|
GLint refractionMatrix = ogl_program_get_uniform_location( m->fancyWaterShader, "refractionMatrix" );
|
2006-05-25 07:46:17 +02:00
|
|
|
GLint normalMap = ogl_program_get_uniform_location( m->fancyWaterShader, "normalMap" );
|
2006-05-28 04:13:32 +02:00
|
|
|
GLint reflectionMap = ogl_program_get_uniform_location( m->fancyWaterShader, "reflectionMap" );
|
|
|
|
GLint refractionMap = ogl_program_get_uniform_location( m->fancyWaterShader, "refractionMap" );
|
2006-05-25 07:46:17 +02:00
|
|
|
|
2006-05-28 04:13:32 +02:00
|
|
|
const CLightEnv& lightEnv = g_Renderer.GetLightEnv();
|
2006-05-25 07:46:17 +02:00
|
|
|
pglUniform3fvARB( ambient, 1, &lightEnv.m_TerrainAmbientColor.X );
|
|
|
|
pglUniform3fvARB( sunDir, 1, &lightEnv.GetSunDir().X );
|
|
|
|
pglUniform3fvARB( sunColor, 1, &lightEnv.m_SunColor.X );
|
2006-05-28 23:58:56 +02:00
|
|
|
pglUniform1fARB( shininess, WaterMgr->m_Shininess );
|
|
|
|
pglUniform1fARB( waviness, WaterMgr->m_Waviness );
|
2006-06-22 23:11:18 +02:00
|
|
|
pglUniform1fARB( murkiness, WaterMgr->m_Murkiness );
|
|
|
|
pglUniform1fARB( fullDepth, WaterMgr->m_WaterFullDepth );
|
|
|
|
pglUniform3fvARB( tint, 1, WaterMgr->m_WaterTint.FloatArray() );
|
2006-05-28 04:13:32 +02:00
|
|
|
pglUniformMatrix4fvARB( reflectionMatrix, 1, false, &WaterMgr->m_ReflectionMatrix._11 );
|
|
|
|
pglUniformMatrix4fvARB( refractionMatrix, 1, false, &WaterMgr->m_RefractionMatrix._11 );
|
2006-05-28 23:58:56 +02:00
|
|
|
pglUniform1iARB( normalMap, 0 ); // texture unit 0
|
2006-05-28 04:13:32 +02:00
|
|
|
pglUniform1iARB( reflectionMap, 1 ); // texture unit 1
|
|
|
|
pglUniform1iARB( refractionMap, 2 ); // texture unit 2
|
2006-05-25 07:46:17 +02:00
|
|
|
|
|
|
|
const CCamera& camera = g_Renderer.GetViewCamera();
|
|
|
|
CVector3D camPos = camera.m_Orientation.GetTranslation();
|
|
|
|
pglUniform3fvARB( cameraPos, 1, &camPos.X );
|
|
|
|
|
|
|
|
vertexDepth = ogl_program_get_attrib_location( m->fancyWaterShader, "vertexDepth" );
|
2006-09-01 01:56:12 +02:00
|
|
|
losMultiplier = ogl_program_get_attrib_location( m->fancyWaterShader, "losMultiplier" );
|
2006-05-25 07:46:17 +02:00
|
|
|
}
|
|
|
|
|
2006-05-28 23:58:56 +02:00
|
|
|
float repeatPeriod = (fancy ? WaterMgr->m_RepeatPeriod : 16.0f);
|
2006-05-25 07:46:17 +02:00
|
|
|
|
2006-01-07 02:04:26 +01:00
|
|
|
glBegin(GL_QUADS);
|
|
|
|
|
|
|
|
for(size_t i=0; i<m->visiblePatches.size(); i++)
|
|
|
|
{
|
|
|
|
CPatch* patch = m->visiblePatches[i];
|
|
|
|
|
|
|
|
for(int dx=0; dx<PATCH_SIZE; dx++)
|
|
|
|
{
|
|
|
|
for(int dz=0; dz<PATCH_SIZE; dz++)
|
|
|
|
{
|
|
|
|
int x = (patch->m_X*PATCH_SIZE + dx);
|
|
|
|
int z = (patch->m_Z*PATCH_SIZE + dz);
|
|
|
|
|
|
|
|
// is any corner of the tile below the water height? if not, no point rendering it
|
|
|
|
bool shouldRender = false;
|
|
|
|
for(int j=0; j<4; j++)
|
|
|
|
{
|
|
|
|
float terrainHeight = terrain->getVertexGroundLevel(x + DX[j], z + DZ[j]);
|
2006-03-31 05:30:34 +02:00
|
|
|
if( terrainHeight < WaterMgr->m_WaterHeight )
|
2006-01-07 02:04:26 +01:00
|
|
|
{
|
|
|
|
shouldRender = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(!shouldRender)
|
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
for(int j=0; j<4; j++)
|
|
|
|
{
|
|
|
|
int ix = x + DX[j];
|
|
|
|
int iz = z + DZ[j];
|
|
|
|
|
|
|
|
float vertX = ix * CELL_SIZE;
|
|
|
|
float vertZ = iz * CELL_SIZE;
|
|
|
|
|
|
|
|
float terrainHeight = terrain->getVertexGroundLevel(ix, iz);
|
|
|
|
|
|
|
|
float alpha = clamp(
|
|
|
|
(WaterMgr->m_WaterHeight - terrainHeight) / WaterMgr->m_WaterFullDepth + WaterMgr->m_WaterAlphaOffset,
|
|
|
|
-100.0f, WaterMgr->m_WaterMaxAlpha);
|
|
|
|
|
|
|
|
float losMod = 1.0f;
|
|
|
|
for(int k=0; k<4; k++)
|
|
|
|
{
|
|
|
|
int tx = ix - DX[k];
|
|
|
|
int tz = iz - DZ[k];
|
|
|
|
|
|
|
|
if(tx >= 0 && tz >= 0 && tx <= mapSize-2 && tz <= mapSize-2)
|
|
|
|
{
|
|
|
|
ELOSStatus s = losMgr->GetStatus(tx, tz, g_Game->GetLocalPlayer());
|
|
|
|
if(s == LOS_EXPLORED && losMod > 0.7f)
|
|
|
|
losMod = 0.7f;
|
|
|
|
else if(s==LOS_UNEXPLORED && losMod > 0.0f)
|
|
|
|
losMod = 0.0f;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-05-25 07:46:17 +02:00
|
|
|
if(fancy)
|
|
|
|
{
|
|
|
|
pglVertexAttrib1fARB( vertexDepth, WaterMgr->m_WaterHeight - terrainHeight );
|
2006-09-01 01:56:12 +02:00
|
|
|
pglVertexAttrib1fARB( losMultiplier, losMod );
|
2006-05-25 07:46:17 +02:00
|
|
|
}
|
2006-06-22 23:11:18 +02:00
|
|
|
else
|
|
|
|
{
|
|
|
|
glColor4f(WaterMgr->m_WaterColor.r*losMod, WaterMgr->m_WaterColor.g*losMod,
|
|
|
|
WaterMgr->m_WaterColor.b*losMod, alpha * FresnelScalar);
|
|
|
|
}
|
2006-05-28 23:58:56 +02:00
|
|
|
pglMultiTexCoord2fARB(GL_TEXTURE0, vertX/repeatPeriod, vertZ/repeatPeriod);
|
2006-01-07 02:04:26 +01:00
|
|
|
glVertex3f(vertX, WaterMgr->m_WaterHeight, vertZ);
|
|
|
|
}
|
|
|
|
} //end of x loop
|
|
|
|
} //end of z loop
|
|
|
|
}
|
|
|
|
glEnd();
|
|
|
|
|
2006-05-25 07:46:17 +02:00
|
|
|
if(fancy)
|
|
|
|
{
|
2006-05-28 04:13:32 +02:00
|
|
|
// Unbind the refraction/reflection textures and the shader
|
|
|
|
|
|
|
|
pglActiveTextureARB( GL_TEXTURE1_ARB );
|
|
|
|
glBindTexture( GL_TEXTURE_2D, 0 );
|
|
|
|
glDisable( GL_TEXTURE_2D );
|
|
|
|
|
|
|
|
pglActiveTextureARB( GL_TEXTURE2_ARB );
|
|
|
|
glBindTexture( GL_TEXTURE_2D, 0 );
|
|
|
|
glDisable( GL_TEXTURE_2D );
|
|
|
|
|
|
|
|
pglActiveTextureARB( GL_TEXTURE0_ARB );
|
|
|
|
|
2006-05-25 07:46:17 +02:00
|
|
|
ogl_program_use( 0 );
|
|
|
|
}
|
|
|
|
|
2006-05-28 23:58:56 +02:00
|
|
|
if(!fancy)
|
|
|
|
{
|
|
|
|
// Clean up the texture matrix and blend mode
|
|
|
|
glLoadIdentity();
|
|
|
|
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
|
|
|
|
}
|
|
|
|
|
2006-01-07 02:04:26 +01:00
|
|
|
glMatrixMode(GL_MODELVIEW);
|
|
|
|
glDisable(GL_BLEND);
|
|
|
|
glDisable(GL_TEXTURE_2D);
|
|
|
|
}
|
|
|
|
|