//-------------------------------------------------------------------------- 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"); }
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_GL41_nglProgramUniform2i(JNIEnv *env, jclass clazz, jint program, jint location, jint v0, jint v1, jlong function_pointer) { glProgramUniform2iPROC glProgramUniform2i = (glProgramUniform2iPROC)((intptr_t)function_pointer); glProgramUniform2i(program, location, v0, v1); }
static bool test_int(const char *version_string) { GLint loc; bool pass = true; int values[4]; int got[ARRAY_SIZE(values)]; GLuint prog; static const char subtest_name[] = "integer scalar and vectors"; const char *const shader_strings[] = { version_string, int_code, common_body }; BUILD_SHADER(version_string == NULL); /* Try int */ random_ints(values, ARRAY_SIZE(values)); loc = glGetUniformLocation(prog, "v1"); glProgramUniform1i(prog, loc, values[0]); pass = piglit_check_gl_error(0) && pass; glGetUniformiv(prog, loc, got); pass = piglit_check_gl_error(0) && pass; pass = check_int_values(values, got, 1) && pass; random_ints(values, ARRAY_SIZE(values)); glProgramUniform1iv(prog, loc, 1, values); pass = piglit_check_gl_error(0) && pass; glGetUniformiv(prog, loc, got); pass = piglit_check_gl_error(0) && pass; pass = check_int_values(values, got, 1) && pass; /* Try ivec2 */ random_ints(values, ARRAY_SIZE(values)); loc = glGetUniformLocation(prog, "v2"); glProgramUniform2i(prog, loc, values[0], values[1]); pass = piglit_check_gl_error(0) && pass; glGetUniformiv(prog, loc, got); pass = piglit_check_gl_error(0) && pass; pass = check_int_values(values, got, 2) && pass; random_ints(values, ARRAY_SIZE(values)); glProgramUniform2iv(prog, loc, 1, values); pass = piglit_check_gl_error(0) && pass; glGetUniformiv(prog, loc, got); pass = piglit_check_gl_error(0) && pass; pass = check_int_values(values, got, 2) && pass; /* Try ivec3 */ random_ints(values, ARRAY_SIZE(values)); loc = glGetUniformLocation(prog, "v3"); glProgramUniform3i(prog, loc, values[0], values[1], values[2]); pass = piglit_check_gl_error(0) && pass; glGetUniformiv(prog, loc, got); pass = piglit_check_gl_error(0) && pass; pass = check_int_values(values, got, 3) && pass; random_ints(values, ARRAY_SIZE(values)); glProgramUniform3iv(prog, loc, 1, values); pass = piglit_check_gl_error(0) && pass; glGetUniformiv(prog, loc, got); pass = piglit_check_gl_error(0) && pass; pass = check_int_values(values, got, 3) && pass; /* Try ivec4 */ random_ints(values, ARRAY_SIZE(values)); loc = glGetUniformLocation(prog, "v4"); glProgramUniform4i(prog, loc, values[0], values[1], values[2], values[3]); pass = piglit_check_gl_error(0) && pass; glGetUniformiv(prog, loc, got); pass = piglit_check_gl_error(0) && pass; pass = check_int_values(values, got, 4) && pass; random_ints(values, ARRAY_SIZE(values)); glProgramUniform4iv(prog, loc, 1, values); pass = piglit_check_gl_error(0) && pass; glGetUniformiv(prog, loc, got); pass = piglit_check_gl_error(0) && pass; pass = check_int_values(values, got, 4) && pass; piglit_report_subtest_result(pass ? PIGLIT_PASS : PIGLIT_FAIL, subtest_name); glDeleteProgram(prog); return pass; }