Actually completely L07

This commit is contained in:
Alex 2017-05-02 16:30:58 -05:00
parent 9768278cf1
commit 60695f80cf
2 changed files with 13 additions and 3 deletions

View file

@ -5,11 +5,16 @@ uniform mat4 MV;
attribute vec4 aPos; // In object space
attribute vec3 aNor; // In object space
varying vec3 color;
uniform float t;
void main()
{
gl_Position = P * MV * aPos;
vec4 temp = aPos;
temp.z = (cos(20*aPos.x + t) + sin(20*aPos.y + t))/20.0;
gl_Position = P * MV * temp;
vec3 l = vec3(0.0, 0.0, 1.0); // In camera space
vec4 n = MV * vec4(aNor, 0.0);
vec3 tempn = aNor;
tempn.z = (cos(20*aPos.x + t) + sin(20*aPos.y + t))/20.0;
vec4 n = MV * vec4(tempn, 0.0);
color = vec3((n.x*l.x + n.y*l.y + n.z*l.z), (n.x*l.x + n.y*l.y + n.z*l.z), (n.x*l.x + n.y*l.y + n.z*l.z));
}

View file

@ -28,6 +28,7 @@ shared_ptr<Camera> camera;
shared_ptr<Program> prog;
map<string,GLuint> bufIDs;
int indCount;
float t = glfwGetTime();
bool keyToggles[256] = {false}; // only for English keyboards!
@ -104,6 +105,7 @@ static void init()
prog->addAttribute("aNor");
prog->addUniform("MV");
prog->addUniform("P");
prog->addUniform("t");
camera = make_shared<Camera>();
camera->setInitDistance(2.0f);
@ -262,6 +264,8 @@ static void render()
MV->pushMatrix();
camera->applyViewMatrix(MV);
t = glfwGetTime();
prog->bind();
glUniformMatrix4fv(prog->getUniform("P"), 1, GL_FALSE, value_ptr(P->topMatrix()));
glEnableVertexAttribArray(prog->getAttribute("aPos"));
@ -277,6 +281,7 @@ static void render()
glBindBuffer(GL_ARRAY_BUFFER, 0);
glDisableVertexAttribArray(prog->getAttribute("aNor"));
glDisableVertexAttribArray(prog->getAttribute("aPos"));
glUniform1f(prog->getUniform("t"), t);
prog->unbind();
MV->popMatrix();