// actually draw the shape to the screen void Shape::Draw(float x, float y, float xScale, float yScale) { // Send offset and scale factor to the appropriate uniform variable glProgramUniform2f(shaderProgramIndex, shapeOffset, x, y); glProgramUniform2f(shaderProgramIndex, shapeScaleFactor, xScale, yScale); // Draw the currently bound data glBindVertexArray(shapeVAO); glDrawArrays(GL_TRIANGLES, 0, totalVertices); }
void renderVis(double peak) { double transition = 0.0; time++; totaltime++; if(time > SHADER_TIME){ active++; if(active == SHADER_AMOUNT){ active = 0; } time = 0; } if(time <= TRANSITION_TIME){ transition = 1.0 - time / TRANSITION_TIME; int prev = active > 0 ? active - 1 : SHADER_AMOUNT - 1; glUseProgram(progs[prev].program); glClearColor(0, 0, 0, 1); glClear(GL_COLOR_BUFFER_BIT); glProgramUniform1f(progs[prev].program, progs[prev].peak, peak); glProgramUniform1f(progs[prev].program, progs[prev].transition, 0); glProgramUniform1f(progs[prev].program, progs[prev].time, totaltime); glProgramUniform2f(progs[prev].program, progs[prev].size, width, height); glProgramUniform1i(progs[prev].program, progs[prev].texture, 0); glBindVertexArray(vao); glDrawArrays(GL_TRIANGLES, 0, 6); glBindVertexArray(0); glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 0, 0, width, height, 0); glUseProgram(progs[active].program); glProgramUniform1i(progs[active].program, progs[active].texture, 0); } glClearColor(0, 0, 0, 1); glClear(GL_COLOR_BUFFER_BIT); glProgramUniform1f(progs[active].program, progs[active].peak, peak); glProgramUniform1f(progs[active].program, progs[active].transition, transition); glProgramUniform1f(progs[active].program, progs[active].time, totaltime); glProgramUniform2f(progs[active].program, progs[active].size, width, height); glBindVertexArray(vao); glDrawArrays(GL_TRIANGLES, 0, 6); glBindVertexArray(0); }
void Material::Bind() { glUseProgram(program); for (std::unordered_map<std::string, Texture2D*>::iterator it = textures.begin(); it != textures.end(); ++it) { it->second->Bind(); } for (std::unordered_map<std::string, ShaderVariable>::iterator it = uniforms.begin(); it != uniforms.end(); ++it) { ShaderVariable v = it->second; switch (v.size) { case 1: glProgramUniform1f(program, v.index, data[v.offset]); break; case 2: glProgramUniform2f(program, v.index, data[v.offset], data[v.offset + 1]); break; case 3: glProgramUniform3f(program, v.index, data[v.offset], data[v.offset + 1], data[v.offset + 2]); break; case 4: glProgramUniform4f(program, v.index, data[v.offset], data[v.offset + 1], data[v.offset + 2], data[v.offset + 3]); break; case 16: glProgramUniformMatrix4fv(program, v.index, 1, GL_TRUE, &data[v.offset]); break; } } }
void Material::SetFloat2(std::string name, Vector2& value) { int location = glGetUniformLocation(program, name.c_str()); if (location == -1) { //std::cout << "Attempt made to set invalid uniform variable: " << name << std::endl; } glProgramUniform2f(program, location, value.x, value.y); }
void program::set_uniform2f(char const* varname, GLfloat v0, GLfloat v1) const { GLint location = get_uniform_location(varname); if (location >= 0) { #if GPUCAST_GL_DIRECT_STATE_ACCESS glProgramUniform2f(id_, location, v0, v1); #else glUniform2f(location, v0, v1); #endif } }
GLUniform::GLUniform(const char* name, GLuint program, int size, const char* type) : GLNode(name) { this->location = glGetUniformLocation(program, name); if(size == 1 && std::string(type) == std::string("i") ) glProgramUniform1i(program, this->location, 0); else if(size == 1 && std::string(type) == std::string("f") ) glProgramUniform1f(program, this->location, 0); else if(size == 2 && std::string(type) == std::string("f") ) glProgramUniform2f(program, this->location, 0, 0); else if(size == 3 && std::string(type) == std::string("f") ) glProgramUniform3f(program, this->location, 0, 0, 0); else if(size == 3 && std::string(type) == std::string("f") ) glProgramUniform3f(program, this->location, 0, 0, 0); else if(size == 4 && std::string(type) == std::string("f") ) glProgramUniform4f(program, this->location, 0, 0, 0, 0); this->id = UINT_MAX; }
void TransitionTriangulation::configurePrograms() { glProgramUniform3f (Parameters::getInstance()->g_programs[PROGRAM_TRANSITION_DRAW], Parameters::getInstance()->g_uniform_locations[LOCATION_TRANSITION_SCENE_SIZE], Parameters::getInstance()->g_geometry.scale[0], Parameters::getInstance()->g_geometry.scale[1], Parameters::getInstance()->g_geometry.scale[2]); glProgramUniform2f (Parameters::getInstance()->g_programs[PROGRAM_TRANSITION_DRAW], Parameters::getInstance()->g_uniform_locations[LOCATION_TRANSITION_VIEWPORT], Parameters::getInstance()->g_window.width, Parameters::getInstance()->g_window.height); glProgramUniform1f (Parameters::getInstance()->g_programs[PROGRAM_TRANSITION_DRAW], Parameters::getInstance()->g_uniform_locations[LOCATION_TRANSITION_TAN_FOVY], tanf (Parameters::getInstance()->g_camera.fovy / 360.f * 3.14159f)); glProgramUniform1f(Parameters::getInstance()->g_programs[PROGRAM_TRANSITION_DRAW], Parameters::getInstance()->g_uniform_locations[LOCATION_TRANSITION_SCALE], Parameters::getInstance()->g_scale); glProgramUniform1i (Parameters::getInstance()->g_programs[PROGRAM_TRANSITION_DRAW], Parameters::getInstance()->g_uniform_locations[LOCATION_TRANSITION_DENSITY], TEXTURE_DENSITY); glProgramUniform1i (Parameters::getInstance()->g_programs[PROGRAM_TRANSITION_DRAW], Parameters::getInstance()->g_uniform_locations[LOCATION_TRANSITION_CODE_CLASS_TR], TEXTURE_CODE_CLASS_TR); glProgramUniform1i (Parameters::getInstance()->g_programs[PROGRAM_TRANSITION_DRAW], Parameters::getInstance()->g_uniform_locations[LOCATION_TRANSITION_CODE_VERTICES_TR], TEXTURE_CODE_VERTICES_TR); glProgramUniform1i (Parameters::getInstance()->g_programs[PROGRAM_TRANSITION_DRAW], Parameters::getInstance()->g_uniform_locations[LOCATION_TRANSITION_CLASS_TRIANGLES_TR], TEXTURE_CLASS_TRIANGLES_TR); glProgramUniform1i (Parameters::getInstance()->g_programs[PROGRAM_TRANSITION_DRAW], Parameters::getInstance()->g_uniform_locations[LOCATION_TRANSITION_TESSEL], (int)Parameters::getInstance()->g_tessel); glProgramUniform1f(Parameters::getInstance()->g_programs[PROGRAM_TRANSITION_DRAW], Parameters::getInstance()->g_uniform_locations[LOCATION_TRANSITION_ISOSURFACE], 0);//Parameters::getInstance()->g_isosurface); glProgramUniform1i (Parameters::getInstance()->g_programs[PROGRAM_TRANSITION_DRAW], Parameters::getInstance()->g_uniform_locations[LOCATION_TRANSITION_FROMTEXTURE], 1);//Parameters::getInstance()->g_fromtexture); glProgramUniform1i (Parameters::getInstance()->g_programs[PROGRAM_TRANSITION_DRAW], Parameters::getInstance()->g_uniform_locations[LOCATION_TRANSITION_METRIC], 0);//Parameters::getInstance()->g_radial_length); glProgramUniform1f(Parameters::getInstance()->g_programs[PROGRAM_TRANSITION_DRAW], Parameters::getInstance()->g_uniform_locations[LOCATION_TRANSITION_TIME], Parameters::getInstance()->g_time_elapsed); }
void ShaderProgram::setUniform(const std::string& name, float first, float second) { if(!ext::separateShaderObjects()) //If we can't do uniforms without binding { //Get the currently-bound program and bind this program auto previous = getBound(); bind(); //Set the uniform glCheck(glUniform2f(uniformLocation(name), first, second)); //Set the previous program back glCheck(glUseProgram(previous)); } else //If we can do uniforms without binding { //Set the uniform with this program glCheck(glProgramUniform2f(program_, uniformLocation(name), first, second)); } }
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_GL41_nglProgramUniform2f(JNIEnv *env, jclass clazz, jint program, jint location, jfloat v0, jfloat v1, jlong function_pointer) { glProgramUniform2fPROC glProgramUniform2f = (glProgramUniform2fPROC)((intptr_t)function_pointer); glProgramUniform2f(program, location, v0, v1); }
void SurfaceReconstruction::Render (const GLuint &positionbuffer, const GLuint &numparticles, const GLuint &width, const GLuint &height) { // get fullscreen quad singleton const FullscreenQuad &fullscreenquad = FullscreenQuad::Get (); // pass particle buffer to point sprite class pointsprite.SetPositionBuffer (positionbuffer, 4 * sizeof (float), 0); // render point sprites, storing depth glBindFramebuffer (GL_FRAMEBUFFER, depthfb); glViewport (0, 0, offscreen_width, offscreen_height); glClear (GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT); particledepthprogram.Use (); pointsprite.Render (numparticles); glBindBufferBase (GL_SHADER_STORAGE_BUFFER, 0, depthblurweights); // blur depth depthblurprog.Use (); for (int i = 0; i < 3; i++) { depthtexture.Bind (GL_TEXTURE_2D); glBindFramebuffer (GL_FRAMEBUFFER, depthhblurfb); glClear (GL_DEPTH_BUFFER_BIT); glProgramUniform2f (depthblurprog.get (), depthbluroffsetscale, 1.0f / offscreen_width, 0.0f); fullscreenquad.Render (); glBindFramebuffer (GL_FRAMEBUFFER, depthvblurfb); blurtexture.Bind (GL_TEXTURE_2D); glClear (GL_DEPTH_BUFFER_BIT); glProgramUniform2f (depthblurprog.get (), depthbluroffsetscale, 0.0f, 1.0f / offscreen_height); fullscreenquad.Render (); } // render point sprites storing thickness glBindFramebuffer (GL_FRAMEBUFFER, thicknessfb); if (usenoise) { GLuint buffers[] = { GL_COLOR_ATTACHMENT0, GL_COLOR_ATTACHMENT1 }; glDrawBuffers (2, buffers); float c[] = { 0, 0, 0, 0 }; glClearBufferfv (GL_COLOR, 0, c); glClearBufferfv (GL_COLOR, 1, c); } else { GLuint buffers[] = { GL_COLOR_ATTACHMENT0 }; glDrawBuffers (1, buffers); float c[] = { 0, 0, 0, 0 }; glClearBufferfv (GL_COLOR, 0, c); } // enable additive blending glEnable (GL_BLEND); glBlendFunc (GL_ONE, GL_ONE); glDisable (GL_DEPTH_TEST); // use depth texture as input depthtexture.Bind (GL_TEXTURE_2D); thicknessprog.Use (); glViewport (0, 0, 512, 512); pointsprite.Render (numparticles); // blur thickness texture glDisable (GL_BLEND); glBindFramebuffer (GL_FRAMEBUFFER, thicknessblurfb); thicknesstexture.Bind (GL_TEXTURE_2D); thicknessblur.Apply (glm::vec2 (1.0f / 512.0f, 0), thicknessblurweights); glBindFramebuffer (GL_FRAMEBUFFER, thicknessfb); { GLuint buffers[] = { GL_COLOR_ATTACHMENT0 }; glDrawBuffers (1, buffers); } thicknessblurtexture.Bind (GL_TEXTURE_2D); thicknessblur.Apply (glm::vec2 (0, 1.0f / 512.0f), thicknessblurweights); // use depth texture as input depthtexture.Bind (GL_TEXTURE_2D); glEnable (GL_BLEND); glEnable (GL_DEPTH_TEST); glBindFramebuffer (GL_FRAMEBUFFER, 0); // use thickness texture as input glActiveTexture (GL_TEXTURE1); thicknesstexture.Bind (GL_TEXTURE_2D); glGenerateMipmap (GL_TEXTURE_2D); // use environment map as input if (envmap) { glActiveTexture (GL_TEXTURE2); envmap->Bind (GL_TEXTURE_CUBE_MAP); } // use noise texture as input if (usenoise) { glActiveTexture (GL_TEXTURE3); noisetexture.Bind (GL_TEXTURE_2D); glGenerateMipmap (GL_TEXTURE_2D); } glActiveTexture (GL_TEXTURE0); // enable alpha blending glBlendFunc (GL_ONE_MINUS_SRC_ALPHA, GL_SRC_ALPHA); // render a fullscreen quad glViewport (0, 0, width, height); fsquadprog.Use (); fullscreenquad.Render (); }
//-------------------------------------------------------------------------- void GBuffer::Draw( const glm::mat4& _projection, const glm::mat4& _view, const SceneManager& _scene) { glBindFramebuffer(GL_FRAMEBUFFER,framebuffer); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); glm::mat4 transform = _projection * _view; int nMeshes = int(_scene.regularMeshes.size()); if(nMeshes>0) { // Render at the same resolution than the original window // Draw all objects glUseProgram(regularRenderer.program.id); glProgramUniformMatrix4fv(regularRenderer.program.id, regularRenderer.transformVar, 1, GL_FALSE, &transform[0][0]); for(int i=0;i<nMeshes;++i) { const RegularMesh& mesh = _scene.regularMeshes[i]; glProgramUniformMatrix4fv(regularRenderer.program.id, regularRenderer.modelVar, 1, GL_FALSE, &_scene.transformations[i][0][0]); glProgramUniform1f(regularRenderer.program.id, regularRenderer.roughnessVar, mesh.roughness); glProgramUniform1f(regularRenderer.program.id, regularRenderer.specularityVar, mesh.specularity); mesh.diffuseTex->Bind(regularRenderer.diffuseTexUnit); mesh.normalTex->Bind(regularRenderer.normalTexUnit); mesh.Draw(); } glf::CheckError("GBuffer::Draw::Regulars"); } int nTerrains = int(_scene.terrainMeshes.size()); if(nTerrains>0) { // Render at the same resolution than the original window // Draw all objects glUseProgram(terrainRenderer.program.id); glProgramUniformMatrix4fv(terrainRenderer.program.id, terrainRenderer.transformVar, 1, GL_FALSE, &transform[0][0]); for(int i=0;i<nTerrains;++i) { const TerrainMesh& mesh = _scene.terrainMeshes[i]; glProgramUniform3f(terrainRenderer.program.id, terrainRenderer.tileOffsetVar, mesh.tileOffset.x, mesh.tileOffset.y, mesh.tileOffset.z); glProgramUniform2i(terrainRenderer.program.id, terrainRenderer.tileCountVar, mesh.tileCount.x, mesh.tileCount.y); glProgramUniform2f(terrainRenderer.program.id, terrainRenderer.tileSizeVar, mesh.tileSize.x, mesh.tileSize.y); glProgramUniform1f(terrainRenderer.program.id, terrainRenderer.tessFactorVar, mesh.tessFactor); glProgramUniform1f(terrainRenderer.program.id, terrainRenderer.heightFactorVar, mesh.heightFactor); glProgramUniform1f(terrainRenderer.program.id, terrainRenderer.projFactorVar, mesh.projFactor); glProgramUniform1f(terrainRenderer.program.id, terrainRenderer.roughnessVar, mesh.roughness); glProgramUniform1f(terrainRenderer.program.id, terrainRenderer.specularityVar, mesh.specularity); glProgramUniform1f(terrainRenderer.program.id, terrainRenderer.tileFactorVar, mesh.tileFactor); mesh.diffuseTex->Bind(terrainRenderer.diffuseTexUnit); mesh.normalTex->Bind(terrainRenderer.normalTexUnit); mesh.heightTex->Bind(terrainRenderer.heightTexUnit); mesh.Draw(); } glf::CheckError("GBuffer::Draw::Terrains"); } glBindFramebuffer(GL_FRAMEBUFFER,0); glf::CheckError("GBuffer::Draw"); }
void Shadow2D::render() { static ShaderProgram fp("first_pass.vs.glsl", "first_pass.fs.glsl"); static ShaderProgram sp("second_pass.vs.glsl", "second_pass.fs.glsl"); static bool init = false; static GLuint fbo; static GLuint colour_tex; static GLuint depth_tex; static GLuint colour_texture_loc; static GLuint depth_texture_loc; static GLuint light_pos_loc = glGetUniformLocation(sp, "light_pos"); static GLuint screen_dim_loc = glGetUniformLocation(sp, "screen_dimensions"); glProgramUniform2f(sp, screen_dim_loc, (float)getWidth(), (float)getHeight()); if (glfwGetMouseButton(_window, 0)) { double x, y; glfwGetCursorPos(_window, &x, &y); x /= (double)getWidth(); y /= (double)getHeight(); x *= 2.0f; y *= 2.0f; x = 1.0f - x; y -= 1.0f; glProgramUniform2f(sp, light_pos_loc, x, y); } if (!init) { init = true; int width, height; glfwGetWindowSize(_window, &width, &height); colour_texture_loc = glGetUniformLocation(sp, "colour"); depth_texture_loc = glGetUniformLocation(sp, "depth"); glGenTextures(1, &colour_tex); glBindTexture(GL_TEXTURE_2D, colour_tex); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_FLOAT, 0); glGenTextures(1, &depth_tex); glBindTexture(GL_TEXTURE_2D, depth_tex); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT32, width, height, 0, GL_DEPTH_COMPONENT, GL_FLOAT, 0); glGenFramebuffers(1, &fbo); glBindFramebuffer(GL_FRAMEBUFFER, fbo); glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, colour_tex, 0); glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, depth_tex, 0); checkGlError(); } glBindFramebuffer(GL_FRAMEBUFFER, 0); //glEnable(GL_BLEND); //glBlendFunc(GL_ONE, GL_ONE); glEnable(GL_DEPTH_TEST); glBindFramebuffer(GL_DRAW_FRAMEBUFFER, fbo); glBindFramebuffer(GL_READ_FRAMEBUFFER, 0); glClearColor(0, 0, 0, 0); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); fp.bind(); glMatrixMode(GL_MODELVIEW); glPushMatrix(); glLoadIdentity(); //glRotatef(glfwGetTime() * 15.0f, 0, 0, 1.0f); //glBegin(GL_TRIANGLES); //glVertex2f(-1.0f, -1.0f); //glVertex2f(0.0f, -1.0f); //glVertex2f(0.0f, 0.0f); //glEnd(); for (int i = 0; i < CIRCLE_COUNT; ++i) { glPushMatrix(); glLoadIdentity(); glTranslatef(circle_positions[i].x, circle_positions[i].y, 0.0f); glScalef(circle_sizes[i], circle_sizes[i], 1.0f); glEnableClientState(GL_VERTEX_ARRAY); glVertexPointer(2, GL_FLOAT, 0, _circleVertexArray); glDrawArrays(GL_TRIANGLE_FAN, 0, CIRCLE_DIVISIONS); glDisableClientState(GL_VERTEX_ARRAY); glPopMatrix(); } glPopMatrix(); glDisable(GL_DEPTH_TEST); glBindFramebuffer(GL_FRAMEBUFFER, 0); glClearColor(0, 0, 0, 0); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); //glBlitFramebuffer(0, 0, getWidth(), getHeight(), 0, 0, getWidth(), getHeight(), GL_COLOR_BUFFER_BIT, GL_LINEAR); sp.bind(); glEnable(GL_TEXTURE_2D); //glActiveTexture(GL_TEXTURE0); //glBindTexture(GL_TEXTURE_2D, colour_tex); //glProgramUniform1i(sp, colour_texture_loc, 0); glActiveTexture(GL_TEXTURE1); glBindTexture(GL_TEXTURE_2D, depth_tex); glProgramUniform1i(sp, depth_texture_loc, 1); glBegin(GL_QUADS); glColor3f(1.0f, 1.0f, 1.0f); glTexCoord2f(0.0f, 0.0f); glVertex2f(-1.0f, -1.0f); glTexCoord2f(1.0f, 0.0f); glVertex2f(1.0f, -1.0f); glTexCoord2f(1.0f, 1.0f); glVertex2f(1.0f, 1.0f); glTexCoord2f(0.0f, 1.0f); glVertex2f(-1.0f, 1.0f); glEnd(); }
void Material::SetFloat2(std::string name, Vector2& value) { uint location = glGetUniformLocation(program, name.c_str()); glProgramUniform2f(program, location, value.x, value.y); }
static bool test_float(const char *version_string) { GLint loc; bool pass = true; float values[4]; float got[ARRAY_SIZE(values)]; GLuint prog; static const char subtest_name[] = "float scalar and vectors"; const char *const shader_strings[] = { version_string, float_code, common_body }; BUILD_SHADER(true); /* Try float */ loc = glGetUniformLocation(prog, "v1"); random_floats(values, ARRAY_SIZE(values)); glProgramUniform1f(prog, loc, values[0]); pass = piglit_check_gl_error(0) && pass; glGetUniformfv(prog, loc, got); pass = piglit_check_gl_error(0) && pass; pass = check_float_values(values, got, 1) && pass; random_floats(values, ARRAY_SIZE(values)); glProgramUniform1fv(prog, loc, 1, values); pass = piglit_check_gl_error(0) && pass; glGetUniformfv(prog, loc, got); pass = piglit_check_gl_error(0) && pass; pass = check_float_values(values, got, 1) && pass; /* Try vec2 */ loc = glGetUniformLocation(prog, "v2"); random_floats(values, ARRAY_SIZE(values)); glProgramUniform2f(prog, loc, values[0], values[1]); pass = piglit_check_gl_error(0) && pass; glGetUniformfv(prog, loc, got); pass = piglit_check_gl_error(0) && pass; pass = check_float_values(values, got, 2) && pass; random_floats(values, ARRAY_SIZE(values)); glProgramUniform2fv(prog, loc, 1, values); pass = piglit_check_gl_error(0) && pass; glGetUniformfv(prog, loc, got); pass = piglit_check_gl_error(0) && pass; pass = check_float_values(values, got, 2) && pass; /* Try vec3 */ loc = glGetUniformLocation(prog, "v3"); random_floats(values, ARRAY_SIZE(values)); glProgramUniform3f(prog, loc, values[0], values[1], values[2]); pass = piglit_check_gl_error(0) && pass; glGetUniformfv(prog, loc, got); pass = piglit_check_gl_error(0) && pass; pass = check_float_values(values, got, 3) && pass; random_floats(values, ARRAY_SIZE(values)); glProgramUniform3fv(prog, loc, 1, values); pass = piglit_check_gl_error(0) && pass; glGetUniformfv(prog, loc, got); pass = piglit_check_gl_error(0) && pass; pass = check_float_values(values, got, 3) && pass; /* Try vec4 */ loc = glGetUniformLocation(prog, "v4"); random_floats(values, ARRAY_SIZE(values)); glProgramUniform4f(prog, loc, values[0], values[1], values[2], values[3]); pass = piglit_check_gl_error(0) && pass; glGetUniformfv(prog, loc, got); pass = piglit_check_gl_error(0) && pass; pass = check_float_values(values, got, 4) && pass; random_floats(values, ARRAY_SIZE(values)); glProgramUniform4fv(prog, loc, 1, values); pass = piglit_check_gl_error(0) && pass; glGetUniformfv(prog, loc, got); pass = piglit_check_gl_error(0) && pass; pass = check_float_values(values, got, 4) && pass; piglit_report_subtest_result(pass ? PIGLIT_PASS : PIGLIT_FAIL, subtest_name); glDeleteProgram(prog); return pass; }
void configure_curv(GLuint program, GLuint first_loc) { glProgramUniform3f (program, Parameters::getInstance()->g_uniform_locations[first_loc], Parameters::getInstance()->g_geometry.scale[0], Parameters::getInstance()->g_geometry.scale[1], Parameters::getInstance()->g_geometry.scale[2]); glProgramUniform1i (program, Parameters::getInstance()->g_uniform_locations[first_loc+1], TEXTURE_DENSITY); glProgramUniform2f (program, Parameters::getInstance()->g_uniform_locations[first_loc+2], Parameters::getInstance()->g_window.width, Parameters::getInstance()->g_window.height); glProgramUniform1i (program, Parameters::getInstance()->g_uniform_locations[first_loc+3], Parameters::getInstance()->g_solid_wireframe); glProgramUniform1f (program, Parameters::getInstance()->g_uniform_locations[first_loc+4], Parameters::getInstance()->g_curvradius); glProgramUniform1f (program, Parameters::getInstance()->g_uniform_locations[first_loc+5], Parameters::getInstance()->g_curvmin); glProgramUniform1f (program, Parameters::getInstance()->g_uniform_locations[first_loc+6], Parameters::getInstance()->g_curvmax); glProgramUniform1f(program, Parameters::getInstance()->g_uniform_locations[first_loc+7], Parameters::getInstance()->g_sizetex); glProgramUniform1i (program, Parameters::getInstance()->g_uniform_locations[first_loc+8], (int)Parameters::getInstance()->g_curv_dir); glProgramUniform1i (program, Parameters::getInstance()->g_uniform_locations[first_loc+9], (int)Parameters::getInstance()->g_curv_val); glProgramUniform1f (program, Parameters::getInstance()->g_uniform_locations[first_loc+10], Parameters::getInstance()->g_lvl); glProgramUniform1i (program, Parameters::getInstance()->g_uniform_locations[first_loc+11], (int)Parameters::getInstance()->g_triangle_normals); glProgramUniform1f (program, Parameters::getInstance()->g_uniform_locations[first_loc+12], Parameters::getInstance()->g_time_elapsed); glProgramUniform1i (program, Parameters::getInstance()->g_uniform_locations[first_loc+13], TEXTURE_SUBDIV_SPHERE); /*glProgramUniform1i (program, Parameters::getInstance()->g_uniform_locations[first_loc+7], (int)Parameters::getInstance()->g_ground_truth);*/ /*glProgramUniform1i (program, Parameters::getInstance()->g_uniform_locations[first_loc+15], 1);//Parameters::getInstance()->g_fromtexture );*/ /* glProgramUniform1i (program, Parameters::getInstance()->g_uniform_locations[first_loc+12], TEXTURE_X2Y2Z2); glProgramUniform1i (program, Parameters::getInstance()->g_uniform_locations[first_loc+13], TEXTURE_XY_YZ_XZ); glProgramUniform1i (program, Parameters::getInstance()->g_uniform_locations[first_loc+14], TEXTURE_XYZ); */ /*glProgramUniform1f (program, Parameters::getInstance()->g_uniform_locations[first_loc+3], tanf (Parameters::getInstance()->g_camera.fovy / 360.f * 3.14159f)); glProgramUniform1f(program, Parameters::getInstance()->g_uniform_locations[first_loc+4], Parameters::getInstance()->g_scale); */ /* glProgramUniform3f (program, Parameters::getInstance()->g_uniform_locations[first_loc+6], Parameters::getInstance()->g_camera.pos[0], Parameters::getInstance()->g_camera.pos[1], Parameters::getInstance()->g_camera.pos[2] ); */ }