1
0
mirror of https://github.com/rwengine/openrw.git synced 2024-09-18 16:32:32 +02:00

Changed water rendering

This commit is contained in:
Daniel Evans 2013-08-16 00:06:31 +00:00
parent 2330263c26
commit 9edd196bae
2 changed files with 19 additions and 10 deletions

View File

@ -305,14 +305,20 @@ void GTAData::loadWater(const std::string& path)
std::stringstream ss(line);
std::string a, b, c, d, e;
float fa, fb, fc, fd, fe;
if( std::getline(ss, a, ',') && std::getline(ss, b, ',') && std::getline(ss, c, ',') && std::getline(ss, d, ',') && std::getline(ss, e, ',')) {
fa = atof(a.c_str());
fb = atof(b.c_str());
fc = atof(c.c_str());
fd = atof(d.c_str());
fe = atof(e.c_str());
waterRects.push_back({
atof(a.c_str()),
atof(b.c_str()),
atof(c.c_str()),
atof(d.c_str()),
atof(e.c_str())
fa,
fb,
fc,
fd,
fe
});
}
}

View File

@ -287,12 +287,15 @@ void GTARenderer::renderWorld()
for( size_t w = 0; w < engine->gameData.waterRects.size(); ++w) {
GTATypes::WaterRect& r = engine->gameData.waterRects[w];
glm::vec3 scale( r.xRight - r.xLeft, r.yTop - r.yBottom, 1.f );
glm::vec3 pos( r.xLeft, r.yBottom, r.height );
glm::vec3 vert[4] = {
glm::vec3(r.xRight, r.yTop, r.height),
glm::vec3(r.xLeft, r.yTop, r.height),
glm::vec3(r.xRight, r.yBottom, r.height),
glm::vec3(r.xLeft, r.yBottom, r.height)
};
glBufferSubData(GL_ARRAY_BUFFER, 0, sizeof(glm::vec3) * 4, vert);
glm::mat4 matrixModel;
matrixModel = glm::translate(matrixModel, pos);
matrixModel = glm::scale(matrixModel, scale);
glm::mat4 matrixModel(1.f);
glUniformMatrix4fv(uniModel, 1, GL_FALSE, glm::value_ptr(matrixModel));
glUniform4f(uniCol, 1.f, 1.f, 1.f, 1.f);