ShaderFP(final String vpShaderFile, final String fpShaderFile) { // Initialize the vertex program. vpFile = vpShaderFile; vpSource = getShaderText(vpShaderFile); vpID = glGenProgramsARB(); glBindProgramARB(ARBVertexProgram.GL_VERTEX_PROGRAM_ARB, vpID); glProgramStringARB(ARBVertexProgram.GL_VERTEX_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB, vpSource); checkProgramError(vpFile, vpSource); // Initialize the fragment program. fpFile = fpShaderFile; fpSource = getShaderText(fpShaderFile); fpID = glGenProgramsARB(); glBindProgramARB(ARBFragmentProgram.GL_FRAGMENT_PROGRAM_ARB, fpID); glProgramStringARB(ARBFragmentProgram.GL_FRAGMENT_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB, fpSource); checkProgramError(fpFile, fpSource); }
void render() { glEnable(ARBVertexProgram.GL_VERTEX_PROGRAM_ARB); glBindProgramARB(ARBVertexProgram.GL_VERTEX_PROGRAM_ARB, vpID); glEnable(ARBFragmentProgram.GL_FRAGMENT_PROGRAM_ARB); glBindProgramARB(ARBFragmentProgram.GL_FRAGMENT_PROGRAM_ARB, fpID); glProgramLocalParameter4fARB(ARBVertexProgram.GL_VERTEX_PROGRAM_ARB, 0, ShadersTest.getSin(), ShadersTest.getSpecularity() * 8.0f, 0.0f, 0.0f); glProgramLocalParameter4fARB(ARBFragmentProgram.GL_FRAGMENT_PROGRAM_ARB, 0, ShadersTest.getSin(), ShadersTest.getSpecularity() * 8.0f, -ShadersTest.getDisplayWidth() * 0.5f, -ShadersTest.getDisplayHeight() * 0.5f); ShadersTest.renderObject(); glDisable(ARBVertexProgram.GL_VERTEX_PROGRAM_ARB); glDisable(ARBFragmentProgram.GL_FRAGMENT_PROGRAM_ARB); }