void piglit_init(int argc, char **argv) { GLint loc; piglit_require_gl_version(20); piglit_require_extension("GL_EXT_separate_shader_objects"); glClearColor(0.3, 0.3, 0.3, 0.0); piglit_ortho_projection(piglit_width, piglit_height, GL_FALSE); prog[0] = glCreateShaderProgramEXT(GL_VERTEX_SHADER, vs_text); prog[1] = glCreateShaderProgramEXT(GL_FRAGMENT_SHADER, fs_text); loc = glGetUniformLocation(prog[0], "color"); if (loc < 0) { printf("Unable to get uniform location in separate vertex " "shader"); piglit_report_result(PIGLIT_FAIL); } glActiveProgramEXT(prog[0]); glUniform4f(loc, 0.0, 0.5, 0.0, 0.5); loc = glGetUniformLocation(prog[1], "color"); if (loc < 0) { printf("Unable to get uniform location in separate fragment " "shader"); piglit_report_result(PIGLIT_FAIL); } glActiveProgramEXT(prog[1]); glUniform1i(loc, 2); }
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_EXTSeparateShaderObjects_nglActiveProgramEXT(JNIEnv *env, jclass clazz, jint program, jlong function_pointer) { glActiveProgramEXTPROC glActiveProgramEXT = (glActiveProgramEXTPROC)((intptr_t)function_pointer); glActiveProgramEXT(program); }
void piglit_init(int argc, char **argv) { enum piglit_result result = PIGLIT_PASS; GLenum err; GLint ok; GLuint prog; GLuint vs; if (piglit_get_gl_version() < 20) { printf("Requires OpenGL 2.0\n"); piglit_report_result(PIGLIT_SKIP); } piglit_require_extension("GL_EXT_separate_shader_objects"); printf("Trying shader with unresolved external symbol...\n"); vs = piglit_compile_shader_text(GL_VERTEX_SHADER, bad_vs_text); prog = glCreateProgram(); glAttachShader(prog, vs); glLinkProgram(prog); glDeleteShader(vs); ok = piglit_link_check_status_quiet(prog); if (ok) { fprintf(stderr, "Linking with unresolved symbol succeeded when it " "should have failed.\n"); piglit_report_result(PIGLIT_FAIL); } /* There shouldn't be any GL errors, but clear them all just to be * sure. */ while (glGetError() != 0) /* empty */ ; /* The specified program is not linked. This should generate * the error GL_INVALID_OPERATION. */ glActiveProgramEXT(prog); err = glGetError(); if (err != GL_INVALID_OPERATION) { printf("Unexpected OpenGL error state 0x%04x for " "glActiveProgramEXT called with\n" "an unlinked shader program (expected 0x%04x).\n", err, GL_INVALID_OPERATION); result = PIGLIT_FAIL; } glDeleteProgram(prog); glUseProgram(0); /* Try again with a shader program that could be linked but wasn't. */ printf("Trying unlinked, valid shader...\n"); vs = piglit_compile_shader_text(GL_VERTEX_SHADER, good_vs_text); prog = glCreateProgram(); glAttachShader(prog, vs); glDeleteShader(vs); /* There shouldn't be any GL errors, but clear them all just to be * sure. */ while (glGetError() != 0) /* empty */ ; /* The specified program is not linked. This should generate * the error GL_INVALID_OPERATION. */ glActiveProgramEXT(prog); err = glGetError(); if (err != GL_INVALID_OPERATION) { printf("Unexpected OpenGL error state 0x%04x for " "glActiveProgramEXT called with\n" "an unlinked shader program (expected 0x%04x).\n", err, GL_INVALID_OPERATION); result = PIGLIT_FAIL; } glDeleteProgram(prog); glUseProgram(0); piglit_report_result(result); }