JNIEXPORT void JNICALL Java_org_lwjgl_opengl_ARBVertexProgram_nglVertexAttrib3dARB(JNIEnv *env, jclass clazz, jint index, jdouble x, jdouble y, jdouble z, jlong function_pointer) {
	glVertexAttrib3dARBPROC glVertexAttrib3dARB = (glVertexAttrib3dARBPROC)((intptr_t)function_pointer);
	glVertexAttrib3dARB(index, x, y, z);
}
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_ARBVertexProgram_glVertexAttrib3dARB(JNIEnv *__env, jclass clazz, jint index, jdouble v0, jdouble v1, jdouble v2) {
    glVertexAttrib3dARBPROC glVertexAttrib3dARB = (glVertexAttrib3dARBPROC)tlsGetFunction(1403);
    UNUSED_PARAM(clazz)
    glVertexAttrib3dARB(index, v0, v1, v2);
}
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_ARBVertexShader_nglVertexAttrib3dARB(JNIEnv *env, jclass clazz, jint index, jdouble v0, jdouble v1, jdouble v2, jlong function_pointer) {
	glVertexAttrib3dARBPROC glVertexAttrib3dARB = (glVertexAttrib3dARBPROC)((intptr_t)function_pointer);
	glVertexAttrib3dARB(index, v0, v1, v2);
}
Exemplo n.º 4
0
//opengl scene, params: input texture (not the output filter->texture)
static void
gst_gl_bumper_callback (gint width, gint height, guint texture, gpointer stuff)
{
  static GLfloat xrot = 0;
  static GLfloat yrot = 0;
  static GLfloat zrot = 0;

  GstGLBumper *bumper = GST_GL_BUMPER (stuff);
  GLint locTangent = 0;

  //choose the lights
  GLfloat light_direction0[] = { 1.0, 0.0, -1.0, 0.0 }; // light goes along -x
  GLfloat light_direction1[] = { -1.0, 0.0, -1.0, 0.0 };        // light goes along x
  GLfloat light_diffuse0[] = { 1.0, 1.0, 1.0, 1.0 };
  GLfloat light_diffuse1[] = { 1.0, 1.0, 1.0, 1.0 };
  GLfloat mat_diffuse[] = { 1.0, 1.0, 1.0, 1.0 };

  //eye point
  glMatrixMode (GL_PROJECTION);
  gluLookAt (0.0, 0.0, -6.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0);
  glMatrixMode (GL_MODELVIEW);

  //scene conf
  glEnable (GL_DEPTH_TEST);
  glDepthFunc (GL_LEQUAL);
  glHint (GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
  glShadeModel (GL_SMOOTH);

  //set the lights
  glLightfv (GL_LIGHT0, GL_POSITION, light_direction0);
  glLightfv (GL_LIGHT0, GL_DIFFUSE, light_diffuse0);
  glLightfv (GL_LIGHT1, GL_POSITION, light_direction1);
  glLightfv (GL_LIGHT1, GL_DIFFUSE, light_diffuse1);
  glMaterialfv (GL_FRONT, GL_DIFFUSE, mat_diffuse);
  glColorMaterial (GL_FRONT_AND_BACK, GL_DIFFUSE);
  glEnable (GL_COLOR_MATERIAL);
  glEnable (GL_LIGHTING);
  glEnable (GL_LIGHT0);
  glEnable (GL_LIGHT1);

  //configure shader
  gst_gl_shader_use (bumper->shader);
  locTangent =
      gst_gl_shader_get_attribute_location (bumper->shader, "aTangent");

  //set the normal map
  glActiveTextureARB (GL_TEXTURE1_ARB);
  gst_gl_shader_set_uniform_1i (bumper->shader, "texture1", 1);
  glBindTexture (GL_TEXTURE_RECTANGLE_ARB, bumper->bumpmap);

  //set the video texture
  glActiveTextureARB (GL_TEXTURE0_ARB);
  gst_gl_shader_set_uniform_1i (bumper->shader, "texture0", 0);
  glBindTexture (GL_TEXTURE_RECTANGLE_ARB, texture);

  //glTranslatef(2.0f, 2.0f, 5.0f);

  glRotatef (xrot, 1.0f, 0.0f, 0.0f);
  glRotatef (yrot, 0.0f, 1.0f, 0.0f);
  glRotatef (zrot, 0.0f, 0.0f, 1.0f);

  //Cube
  glBegin (GL_QUADS);

  // front face
  glNormal3d (0.0, 0.0, -1.0);
  glVertexAttrib3dARB (locTangent, 0.0, 1.0, 0.0);
  glMultiTexCoord2dARB (GL_TEXTURE0_ARB, 0.0, 0.0);
  glMultiTexCoord2dARB (GL_TEXTURE1_ARB, 0.0, 0.0);
  glVertex3d (1.0, 1.0, -1.0);  // B
  glMultiTexCoord2dARB (GL_TEXTURE0_ARB, 0.0, height);
  glMultiTexCoord2dARB (GL_TEXTURE1_ARB, 0.0, bumper->bumpmap_height);
  glVertex3d (1.0, -1.0, -1.0); // A
  glMultiTexCoord2dARB (GL_TEXTURE0_ARB, width, height);
  glMultiTexCoord2dARB (GL_TEXTURE1_ARB, bumper->bumpmap_width,
      bumper->bumpmap_height);
  glVertex3d (-1.0, -1.0, -1.0);        // D
  glMultiTexCoord2dARB (GL_TEXTURE0_ARB, width, 0.0);
  glMultiTexCoord2dARB (GL_TEXTURE1_ARB, bumper->bumpmap_width, 0.0);
  glVertex3d (-1.0, 1.0, -1.0); // C

  // right face
  glNormal3d (-1.0, 0.0, 0.0);
  glVertexAttrib3dARB (locTangent, 0.0, 1.0, 0.0);
  glMultiTexCoord2dARB (GL_TEXTURE0_ARB, 0.0, 0.0);
  glMultiTexCoord2dARB (GL_TEXTURE1_ARB, 0.0, 0.0);
  glVertex3d (-1.0, 1.0, -1.0); // C
  glMultiTexCoord2dARB (GL_TEXTURE0_ARB, 0.0, height);
  glMultiTexCoord2dARB (GL_TEXTURE1_ARB, 0.0, bumper->bumpmap_height);
  glVertex3d (-1.0, -1.0, -1.0);        // D
  glMultiTexCoord2dARB (GL_TEXTURE0_ARB, width, height);
  glMultiTexCoord2dARB (GL_TEXTURE1_ARB, bumper->bumpmap_width,
      bumper->bumpmap_height);
  glVertex3d (-1.0, -1.0, 1.0); // H
  glMultiTexCoord2dARB (GL_TEXTURE0_ARB, width, 0.0);
  glMultiTexCoord2dARB (GL_TEXTURE1_ARB, bumper->bumpmap_width, 0.0);
  glVertex3d (-1.0, 1.0, 1.0);  // G

  // back face
  glNormal3d (0.0, 0.0, 1.0);
  glVertexAttrib3dARB (locTangent, 0.0, 1.0, 0.0);
  glMultiTexCoord2dARB (GL_TEXTURE0_ARB, 0.0, 0.0);
  glMultiTexCoord2dARB (GL_TEXTURE1_ARB, 0.0, 0.0);
  glVertex3d (-1.0, 1.0, 1.0);  // G
  glMultiTexCoord2dARB (GL_TEXTURE0_ARB, 0.0, height);
  glMultiTexCoord2dARB (GL_TEXTURE1_ARB, 0.0, bumper->bumpmap_height);
  glVertex3d (-1.0, -1.0, 1.0); // H
  glMultiTexCoord2dARB (GL_TEXTURE0_ARB, width, height);
  glMultiTexCoord2dARB (GL_TEXTURE1_ARB, bumper->bumpmap_width,
      bumper->bumpmap_height);
  glVertex3d (1.0, -1.0, 1.0);  // E
  glMultiTexCoord2dARB (GL_TEXTURE0_ARB, width, 0.0);
  glMultiTexCoord2dARB (GL_TEXTURE1_ARB, bumper->bumpmap_width, 0.0);
  glVertex3d (1.0, 1.0, 1.0);   // F

  // left face
  glNormal3d (1.0, 0.0, 0.0);
  glVertexAttrib3dARB (locTangent, 0.0, 1.0, 0.0);
  glMultiTexCoord2dARB (GL_TEXTURE0_ARB, 0.0, 0.0);
  glMultiTexCoord2dARB (GL_TEXTURE1_ARB, 0.0, 0.0);
  glVertex3d (1.0, 1.0, 1.0);   // F
  glMultiTexCoord2dARB (GL_TEXTURE0_ARB, 0.0, height);
  glMultiTexCoord2dARB (GL_TEXTURE1_ARB, 0.0, bumper->bumpmap_height);
  glVertex3d (1.0, -1.0, 1.0);  // E
  glMultiTexCoord2dARB (GL_TEXTURE0_ARB, width, height);
  glMultiTexCoord2dARB (GL_TEXTURE1_ARB, bumper->bumpmap_width,
      bumper->bumpmap_height);
  glVertex3d (1.0, -1.0, -1.0); // A
  glMultiTexCoord2dARB (GL_TEXTURE0_ARB, width, 0.0);
  glMultiTexCoord2dARB (GL_TEXTURE1_ARB, bumper->bumpmap_width, 0.0);
  glVertex3d (1.0, 1.0, -1.0);  // B

  // top face
  glNormal3d (0.0, 1.0, 0.0);
  glVertexAttrib3dARB (locTangent, 0.0, 0.0, 1.0);
  glMultiTexCoord2dARB (GL_TEXTURE0_ARB, 0.0, 0.0);
  glMultiTexCoord2dARB (GL_TEXTURE1_ARB, 0.0, 0.0);
  glVertex3d (1.0, 1.0, 1.0);   // F
  glMultiTexCoord2dARB (GL_TEXTURE0_ARB, 0.0, height);
  glMultiTexCoord2dARB (GL_TEXTURE1_ARB, 0.0, bumper->bumpmap_height);
  glVertex3d (1.0, 1.0, -1.0);  // B
  glMultiTexCoord2dARB (GL_TEXTURE0_ARB, width, height);
  glMultiTexCoord2dARB (GL_TEXTURE1_ARB, bumper->bumpmap_width,
      bumper->bumpmap_height);
  glVertex3d (-1.0, 1.0, -1.0); // C
  glMultiTexCoord2dARB (GL_TEXTURE0_ARB, width, 0.0);
  glMultiTexCoord2dARB (GL_TEXTURE1_ARB, bumper->bumpmap_width, 0.0);
  glVertex3d (-1.0, 1.0, 1.0);  // G

  // bottom face
  glNormal3d (0.0, -1.0, 0.0);
  glVertexAttrib3dARB (locTangent, 0.0, 0.0, -1.0);
  glMultiTexCoord2dARB (GL_TEXTURE0_ARB, 0.0, 0.0);
  glMultiTexCoord2dARB (GL_TEXTURE1_ARB, 0.0, 0.0);
  glVertex3d (1.0, -1.0, -1.0); // A
  glMultiTexCoord2dARB (GL_TEXTURE0_ARB, 0.0, height);
  glMultiTexCoord2dARB (GL_TEXTURE1_ARB, 0.0, bumper->bumpmap_height);
  glVertex3d (1.0, -1.0, 1.0);  // E
  glMultiTexCoord2dARB (GL_TEXTURE0_ARB, width, height);
  glMultiTexCoord2dARB (GL_TEXTURE1_ARB, bumper->bumpmap_width,
      bumper->bumpmap_height);
  glVertex3d (-1.0, -1.0, 1.0); // H
  glMultiTexCoord2dARB (GL_TEXTURE0_ARB, width, 0.0);
  glMultiTexCoord2dARB (GL_TEXTURE1_ARB, bumper->bumpmap_width, 0.0);
  glVertex3d (-1.0, -1.0, -1.0);        // D
  glEnd ();

  glUseProgram (0);
  glDisable (GL_LIGHT0);
  glDisable (GL_LIGHT1);
  glDisable (GL_LIGHTING);
  glDisable (GL_COLOR_MATERIAL);

  xrot += 1.0f;
  yrot += 0.9f;
  zrot += 1.1f;
}