1
0
forked from 0ad/0ad

- 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.
This commit is contained in:
Matei 2006-09-11 22:35:44 +00:00
parent c4607a9c34
commit 1056788a6a
2 changed files with 13 additions and 8 deletions

View File

@ -25,6 +25,7 @@
#include <stdio.h>
#include <math.h>
#include <queue>
#include <algorithm>
#include "win_internal.h"
#include <ddraw.h>
@ -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);
}

View File

@ -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