JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_EXTVertexShader_nglGenVertexShadersEXT(JNIEnv *env, jclass clazz, jint range, jlong function_pointer) { glGenVertexShadersEXTPROC glGenVertexShadersEXT = (glGenVertexShadersEXTPROC)((intptr_t)function_pointer); GLuint __result = glGenVertexShadersEXT(range); return __result; }
void pnTriangles::bindVertexProgram(const MColor diffuse, const MColor specular, const MColor emission, const MColor ambient) // // Description: // Sample vertex program which sets up a yellow diffuse // shader. // { // See if extension is supported // if (!fExtensionSupported[kVertexShaderEXT]) return; // Enable vertex shaders glEnable(GL_VERTEX_SHADER_EXT); // Generate a new vertex shader id, if none has been created. if (fVertexShaderId != -1) { glBindVertexShaderEXT (fVertexShaderId); return; } fVertexShaderId = glGenVertexShadersEXT (1); //Initialize global parameter bindings GLuint Modelview = glBindParameterEXT (GL_MODELVIEW_MATRIX); GLuint Projection = glBindParameterEXT (GL_PROJECTION_MATRIX); // Q: does this read properly from vertex arrays or // do I need to define a variant pointer via glVariantPointerEXT ? // GLuint Vertex = glBindParameterEXT (GL_CURRENT_VERTEX_EXT); // GL_CURRENT_NORMAL comes from the glGetPointerTarget enums GLuint Normal = glBindParameterEXT (GL_CURRENT_NORMAL); //GLuint lightPos = glBindLightParameterEXT( 0, GL_POSITION ); // Bind a diffuse shader glBindVertexShaderEXT (fVertexShaderId); glBeginVertexShaderEXT (); { float direction[4] = { 0.57735f, 0.57735f, 0.57735f, 0.0f}; //direction vector (1,1,1) normalized GLuint lightDirection; GLuint diffMaterial; GLuint sceneAmbient; GLuint eyeVertex; GLuint clipVertex; GLuint eyeNormal; GLuint intensity; // generate local values eyeVertex = glGenSymbolsEXT (GL_VECTOR_EXT, GL_LOCAL_EXT, GL_FULL_RANGE_EXT, 1); clipVertex = glGenSymbolsEXT (GL_VECTOR_EXT, GL_LOCAL_EXT, GL_FULL_RANGE_EXT, 1); eyeNormal = glGenSymbolsEXT (GL_VECTOR_EXT, GL_LOCAL_EXT, GL_FULL_RANGE_EXT, 1); intensity = glGenSymbolsEXT (GL_VECTOR_EXT, GL_LOCAL_EXT, GL_FULL_RANGE_EXT, 1); // generate constant values lightDirection = glGenSymbolsEXT (GL_VECTOR_EXT, GL_LOCAL_CONSTANT_EXT, GL_FULL_RANGE_EXT, 1); diffMaterial = glGenSymbolsEXT (GL_VECTOR_EXT, GL_LOCAL_CONSTANT_EXT, GL_FULL_RANGE_EXT, 1); sceneAmbient = glGenSymbolsEXT (GL_VECTOR_EXT, GL_LOCAL_CONSTANT_EXT, GL_FULL_RANGE_EXT, 1); glSetLocalConstantEXT (lightDirection, GL_FLOAT, direction); glSetLocalConstantEXT (diffMaterial, GL_FLOAT, (void *)&(diffuse.r)); glSetLocalConstantEXT (sceneAmbient, GL_FLOAT, (void *)&(ambient.r)); glShaderOp2EXT (GL_OP_MULTIPLY_MATRIX_EXT, eyeVertex, Modelview, Vertex); glShaderOp2EXT (GL_OP_MULTIPLY_MATRIX_EXT, GL_OUTPUT_VERTEX_EXT, Projection, eyeVertex); // assumes no scaling/shearing in modelview matrix glShaderOp2EXT (GL_OP_MULTIPLY_MATRIX_EXT, eyeNormal, Modelview, Normal); glShaderOp2EXT (GL_OP_DOT3_EXT, intensity, lightDirection, eyeNormal); glShaderOp2EXT (GL_OP_ADD_EXT, intensity, sceneAmbient, intensity); glShaderOp2EXT (GL_OP_MUL_EXT, GL_OUTPUT_COLOR0_EXT, diffMaterial, intensity); } glEndVertexShaderEXT (); }