Open LeeMcQueen opened 3 years ago
const char WaterShader::WATER_VERTEX_FILE = "terrainVertexShader.txt"; const char WaterShader::WATER_FRAGMENT_FILE = "terrainFragmentShader.txt";
WaterShader::WaterShader() : ShaderProgram(WATER_VERTEX_FILE, WATER_FRAGMENT_FILE) { //给传入shader的VBO进行命名 bindAttributes();
//加载uniform到顶点shader
getAllUniformLocations();
}
void WaterShader::loadTransformationMatrix(glm::mat4 matrix){
loadMatirx4(Location_transformationMatrix, matrix);
}
void WaterShader::loadProjectionMatrix(glm::mat4 matrix){
loadMatrix4(Location_projectionMatrix, matrix);
}
void WaterShader::loadViewMatrix(glm::mat4 matrix){
loadMatrix4(Location_viewMatrix, matrix);
}
void WaterShader::loadLight(Light light){
loadVector3(Location_lightColor, light.getColor());
loadVector3(Location_lightPosition, light.getPosition());
}
void WaterShader::bindAttributes(){
bindAttribute(0, "position") bindAttribute(1, "textureCoords"); bindAttribute(2, "normal"); }
void WaterShader::getAllUniformLocations(){
Location_transformtonMatrix = getUniformLocation("transformationMatrix");
Location_projectionMatrix = getUniformLocation("projectionMatrix");
Location_viewMatrix = getUniformLocation("viewMatrix");
Location_lightColor = getUniformLocation("lightColor");
Location_lightPosition = getUniformLocation("lightPosition");
}
class WaterTile{
public:
WaterTile(float centerX, float centerZ, float height):
float getX() const {
return _x;
}
float getZ() const {
return _z;
}
float getHeight() const {
return _height;
}
float getTileSize() const {
return TILE_SIZE
}
private:
const flaot TILE_SIZE = 125.0f;
float _x, _z;
gloat _height;
}
pragma once
include "ShaderProgram.h"
include "Light.h"
class WaterShader : public ShaderProgram {
public:
protected:
private:
};