From 1056788a6a7b40f6bd292ce1a53728e1590def34 Mon Sep 17 00:00:00 2001 From: Matei Date: Mon, 11 Sep 2006 22:35:44 +0000 Subject: [PATCH] - Added support for translating texture coordinates in fancy water, so it can move in some direction like the non-fancy water can. - Removed a debug assertion that could occur in windowed mode if you moved your mouse above or to the left of the window (client x and y >= 0); instead, negative client coordinates are now clipped to 0. (The coordinates can't actually stay negative because we are casting them to uints, so that would give very large values.) This was SVN commit r4323. --- source/lib/sysdep/win/wsdl.cpp | 11 ++++++----- source/renderer/TerrainRenderer.cpp | 10 +++++++--- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/source/lib/sysdep/win/wsdl.cpp b/source/lib/sysdep/win/wsdl.cpp index 2e33f3a0bb..58aee71efa 100644 --- a/source/lib/sysdep/win/wsdl.cpp +++ b/source/lib/sysdep/win/wsdl.cpp @@ -25,6 +25,7 @@ #include #include #include +#include #include "win_internal.h" #include @@ -796,12 +797,12 @@ static void mouse_moved(uint x, uint y) static void screen_to_client(int screen_x, int screen_y, uint& x, uint& y) { POINT pt; - pt.x = (LONG)screen_x; - pt.y = (LONG)screen_y; + pt.x = (LONG) screen_x; + pt.y = (LONG) screen_y; WARN_IF_FALSE(ScreenToClient(hWnd, &pt)); - debug_assert(pt.x >= 0 && pt.y >= 0); - x = (uint)pt.x; - y = (uint)pt.y; + //debug_assert(pt.x >= 0 && pt.y >= 0); + x = (uint) std::max(pt.x, (LONG) 0); + y = (uint) std::max(pt.y, (LONG) 0); } diff --git a/source/renderer/TerrainRenderer.cpp b/source/renderer/TerrainRenderer.cpp index b672d05d21..f1b2d7acbe 100644 --- a/source/renderer/TerrainRenderer.cpp +++ b/source/renderer/TerrainRenderer.cpp @@ -426,13 +426,15 @@ void TerrainRenderer::RenderWater() ogl_tex_bind(WaterMgr->m_WaterTexture[curTex], 0); } + // Shift the texture coordinates by these amounts to make the water "flow" + float tx = -fmod(time, 54.0)/54.0; + float ty = -fmod(time, 23.0)/23.0; + if(!fancy) { - // Shift the texture coordinates to make it "flow" + // Perform the shifting by modifying the texture matrix 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 @@ -482,6 +484,7 @@ void TerrainRenderer::RenderWater() GLint tint = ogl_program_get_uniform_location( m->fancyWaterShader, "tint" ); GLint reflectionTint = ogl_program_get_uniform_location( m->fancyWaterShader, "reflectionTint" ); GLint reflectionTintStrength = ogl_program_get_uniform_location( m->fancyWaterShader, "reflectionTintStrength" ); + GLint translation = ogl_program_get_uniform_location( m->fancyWaterShader, "translation" ); GLint reflectionMatrix = ogl_program_get_uniform_location( m->fancyWaterShader, "reflectionMatrix" ); GLint refractionMatrix = ogl_program_get_uniform_location( m->fancyWaterShader, "refractionMatrix" ); GLint normalMap = ogl_program_get_uniform_location( m->fancyWaterShader, "normalMap" ); @@ -500,6 +503,7 @@ void TerrainRenderer::RenderWater() pglUniform3fvARB( tint, 1, WaterMgr->m_WaterTint.FloatArray() ); pglUniform1fARB( reflectionTintStrength, WaterMgr->m_ReflectionTintStrength ); pglUniform3fvARB( reflectionTint, 1, WaterMgr->m_ReflectionTint.FloatArray() ); + pglUniform4fARB( translation, tx, ty, 0, 0 ); pglUniformMatrix4fvARB( reflectionMatrix, 1, false, &WaterMgr->m_ReflectionMatrix._11 ); pglUniformMatrix4fvARB( refractionMatrix, 1, false, &WaterMgr->m_RefractionMatrix._11 ); pglUniform1iARB( normalMap, 0 ); // texture unit 0