Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Project 5 submission #4

Open
wants to merge 17 commits into
base: master
Choose a base branch
from
Prev Previous commit
Next Next commit
temp
  • Loading branch information
foxking0416 committed Oct 31, 2014
commit 7509295f6b0b7daa2c18ca382ac78ff57d5ade52
53 changes: 24 additions & 29 deletions vert_wave.html
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,14 @@
<script id="fs" type="x-shader/x-fragment">
precision mediump float;

uniform vec4 u_color;
uniform vec4 u_color1;
uniform vec4 u_color2;
varying vec4 color;
uniform vec4 u_colorHigh;
uniform vec4 u_colorLow;


void main(void)
{
// NOTE : gl_FragColor is always a vec4
gl_FragColor = u_color;
gl_FragColor = u_colorHigh;
}
</script>

Expand Down Expand Up @@ -78,25 +77,23 @@

// Function called when the window is loaded
window.onload = function() {
// Add GUI component

var guiMinHeightColor = new dat.GUI();
//var colorObjectMin = new ColorObject();
guiMinHeightColor.addColor(ColorObject, 'color');
guiMinHeightColor.addColor(ColorObject, 'color2');
guiMinHeightColor.add(ColorObject, 'speed', 0.01, 0.1);

// Add GUI component
var gui = new dat.GUI();
gui.addColor(ColorObject, 'colorHigh');
gui.addColor(ColorObject, 'colorLow');
gui.add(ColorObject, 'speed', 0.01, 0.1);


init();

animate();
};

var ColorObject = {
color: [45, 133, 150], // RGB with alpha
color2: [45, 133, 150],
speed: 0.05
};
var ColorObject = new function(){
this.colorHigh = [ 0, 128, 255, 0.3 ]; // RGB with alpha
this.colorLow = [ 0, 128, 255, 0.3 ];
this.speed = 0.05;
}


function init() {
Expand Down Expand Up @@ -132,9 +129,6 @@
var mvp = mat4.create();
mat4.multiply(persp, mv, mvp);

var test = [ 1.0, 1.0, 0.0, 1.0 ];
var test2 = ColorObject.color;
//delta += 0.01;
delta += ColorObject.speed;
// Render
context.clear(context.COLOR_BUFFER_BIT | context.DEPTH_BUFFER_BIT);
Expand All @@ -143,11 +137,10 @@
context.drawElements(context.LINES, numberOfIndices, context.UNSIGNED_SHORT,0);
context.uniform1f(u_timeLocation, delta);

var testColor = "#827b48";
//vec4 lowestPtColor= vec4(0.0, 1.0, 0.0, 1.0);
context.uniform4f(u_colorLocation, 0.0, 1.0, 0.0 , 1.0);

//context.uniform4f(u_colorLocation, ColorObject.color);

context.uniform4f(u_colorLocationHigh, ColorObject.colorHigh[0]/255.0, ColorObject.colorHigh[1]/255.0, ColorObject.colorHigh[2]/255.0 , 1.0);
context.uniform4f(u_colorLocationLow, ColorObject.colorLow[0]/255.0, ColorObject.colorLow[1]/255.0, ColorObject.colorLow[2]/255.0 , 1.0);

window.requestAnimFrame(animate);
}

Expand All @@ -160,10 +153,12 @@
var program = createProgram(context, vs, fs, message);//combine a vs and fs to a program
context.bindAttribLocation(program, positionLocation, "position");
u_modelViewPerspectiveLocation = context.getUniformLocation(program,"u_modelViewPerspective");
u_colorLocation = context.getUniformLocation(program, "u_color");

u_timeLocation = context.getUniformLocation(program, "u_time")
u_colorLocation1 = context.getUniformLocation(program, "u_color1")
u_colorLocation2 = context.getUniformLocation(program, "u_color2")

u_colorLocationHigh = context.getUniformLocation(program, "u_colorHigh");
u_colorLocationLow = context.getUniformLocation(program, "u_colorLow")

context.useProgram(program);
}

Expand Down