Commit 114c4120 authored by Sabrina Templeton's avatar Sabrina Templeton
Browse files

colormap functional

parent a260fb5d
......@@ -14,13 +14,16 @@ uniform float u_umax;
uniform samplerBuffer colormap;
#define DEBUG 0
void
get_color( float u , out vec3 color ) {
float umin = 0.;//u_umin;
float umax = 7.;//u_umax;
int indx = int(ncolor*(u - umin)/(umax - umin));
// int indx = int(ncolor*(u - umin)/(umax - umin));
int indx = int(ncolor*(u - umin)/(umax - umin));
if (indx < 0) indx = 0;
if (indx > 255) indx = 255;
......@@ -30,27 +33,33 @@ get_color( float u , out vec3 color ) {
float b0 = texelFetch( colormap , 3*(indx) + 2 ).x;
color = vec3(r0,g0,b0);
//if (indx == 36) color = vec3(1,0,1);
}
void main() {
vec3 color = vec3(1.0, 1.0,1.0);//vec3(0.8,0.8,0.2);
vec3 color = vec3(.8, .8, .8);//vec3(0.8,0.8,0.2);
int idx = gl_PrimitiveID;
float f = idx;
#if DEBUG
if (idx == 0) color = vec3(1,0,0);
if (idx == 1) color = vec3(0,1,0);
if (idx == 2) color = vec3(0,0,1);
if (idx == 3) color = vec3(1,1,0);
if (idx == 4) color = vec3(0,1,1);
if (idx == 5) color = vec3(1,0,1);
if (idx == 6) color = vec3(0,0,0);
if (idx == 6) color = vec3(.5,.5,.5);
//get_color(f, color);
#else
get_color(idx, color);
#endif
fragColor = vec4(color, 1);
}
\ No newline at end of file
// the version should be specified by a macro at compile time
// e.g. #version 410 or #version 330
#version 410
layout (points) in;
// uniform mat4 u_ModelViewProjectionMatrix;
......@@ -44,7 +45,7 @@ layout (triangle_strip, max_vertices = 16) out;
//uniform usamplerBuffer connectivity;
uniform samplerBuffer seeds;
// render full tetrahedron
// render full square
void render_square(vec3 pt) {
//define all four points of the square
vec3 bl = pt + vec3(-.02, -.02, 0);
......@@ -61,10 +62,10 @@ void render_square(vec3 pt) {
EmitVertex();
gl_Position = u_ModelViewProjectionMatrix*vec4(tr, 1.0);
EmitVertex();
//EmitVertex();
gl_PrimitiveID = 3;
gl_PrimitiveID = gl_PrimitiveIDIn;
EmitVertex();
EndPrimitive();
......@@ -78,7 +79,7 @@ void render_square(vec3 pt) {
gl_Position = u_ModelViewProjectionMatrix*vec4(br, 1.0);
EmitVertex();
//EmitVertex();
gl_PrimitiveID = gl_PrimitiveIDIn;
......
......@@ -73,11 +73,13 @@ UT_TEST_CASE( test1 )
GL_CALL( glBindVertexArray(vertex_array) );
//generate random seeds desired times 3
int size = 7* 3;
int size = 7*3;
std::vector<graphics::gl_float> seeds;
srand (time(NULL));
for (int i = 0; i < size; i ++){
seeds.push_back(rand() % 10 * 0.01);
//printf("loop ran, %d point added", i);
};
......@@ -151,6 +153,11 @@ UT_TEST_CASE( test1 )
glUniform1i(seeds_location, 0);
// enable the colormap texture
glActiveTexture(GL_TEXTURE0 + 1);
GLint colormap_location = glGetUniformLocation(shader.handle() , "colormap");
glUniform1i(colormap_location, 1);
// draw
GL_CALL( glBindBuffer(GL_ARRAY_BUFFER, points_buffer ) ); // it doesn't really matter which buffer we bind here since it isn't used
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment