//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; GstGLFuncs *gl; GstGLBumper *bumper = GST_GL_BUMPER (stuff); GstGLContext *context = GST_GL_FILTER (bumper)->context; 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 }; /* *INDENT-OFF* */ MeshData mesh[] = { /* | Vertex | Normal |TexCoord0|TexCoord1| VertexAttrib | */ /*F*/ { 1.0, 1.0, -1.0, 0.0, 0.0, -1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0}, /*r*/ { 1.0, -1.0, -1.0, 0.0, 0.0, -1.0, 1.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.0}, /*o*/ {-1.0, -1.0, -1.0, 0.0, 0.0, -1.0, 1.0, 1.0, 1.0, 1.0, 0.0, 1.0, 0.0}, {-1.0, 1.0, -1.0, 0.0, 0.0, -1.0, 0.0, 1.0, 0.0, 1.0, 0.0, 1.0, 0.0}, /*R*/ {-1.0, 1.0, -1.0, -1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0}, /*i*/ {-1.0, -1.0, -1.0, -1.0, 0.0, 0.0, 1.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.0}, /*g*/ {-1.0, -1.0, 1.0, -1.0, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0, 0.0, 1.0, 0.0}, {-1.0, 1.0, 1.0, -1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 1.0, 0.0, 1.0, 0.0}, /*B*/ {-1.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0, 0.0, 1.0, 1.0, 1.0, 1.0, 0.0, 0.0, -1.0}, {-1.0, -1.0, -1.0, 0.0, -1.0, 0.0, 0.0, 1.0, 0.0, 1.0, 0.0, 0.0, -1.0}, }; GLushort indices[] = { 0, 1, 2, 0, 2, 3, 4, 5, 6, 4, 6, 7, 8, 9, 10, 8, 10, 11, 12, 13, 14, 12, 14, 15, 16, 17, 18, 16, 18, 19, 20, 21, 22, 20, 22, 23 }; /* *INDENT-ON* */ gl = GST_GL_FILTER (bumper)->context->gl_vtable; //eye point gl->MatrixMode (GL_PROJECTION); gluLookAt (0.0, 0.0, -6.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0); gl->MatrixMode (GL_MODELVIEW); //scene conf gl->Enable (GL_DEPTH_TEST); gl->DepthFunc (GL_LEQUAL); gl->Hint (GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST); gl->ShadeModel (GL_SMOOTH); //set the lights gl->Lightfv (GL_LIGHT0, GL_POSITION, light_direction0); gl->Lightfv (GL_LIGHT0, GL_DIFFUSE, light_diffuse0); gl->Lightfv (GL_LIGHT1, GL_POSITION, light_direction1); gl->Lightfv (GL_LIGHT1, GL_DIFFUSE, light_diffuse1); gl->Materialfv (GL_FRONT, GL_DIFFUSE, mat_diffuse); gl->ColorMaterial (GL_FRONT_AND_BACK, GL_DIFFUSE); gl->Enable (GL_COLOR_MATERIAL); gl->Enable (GL_LIGHTING); gl->Enable (GL_LIGHT0); gl->Enable (GL_LIGHT1); //configure shader gst_gl_shader_use (bumper->shader); locTangent = gst_gl_shader_get_attribute_location (bumper->shader, "aTangent"); //set the normal map gl->ActiveTexture (GL_TEXTURE1); gst_gl_shader_set_uniform_1i (bumper->shader, "texture1", 1); gl->BindTexture (GL_TEXTURE_2D, bumper->bumpmap); //set the video texture gl->ActiveTexture (GL_TEXTURE0); gst_gl_shader_set_uniform_1i (bumper->shader, "texture0", 0); gl->BindTexture (GL_TEXTURE_2D, texture); gl->Rotatef (xrot, 1.0f, 0.0f, 0.0f); gl->Rotatef (yrot, 0.0f, 1.0f, 0.0f); gl->Rotatef (zrot, 0.0f, 0.0f, 1.0f); gl->EnableVertexAttribArray (locTangent); gl->ClientActiveTexture (GL_TEXTURE0); gl->EnableClientState (GL_TEXTURE_COORD_ARRAY); gl->EnableClientState (GL_VERTEX_ARRAY); gl->EnableClientState (GL_NORMAL_ARRAY); gl->VertexAttribPointer (locTangent, 3, GL_FLOAT, 0, sizeof (MeshData), &mesh[0].va0); gl->VertexPointer (3, GL_FLOAT, sizeof (MeshData), &mesh[0].x); gl->NormalPointer (GL_FLOAT, sizeof (MeshData), &mesh[0].nx); gl->TexCoordPointer (2, GL_FLOAT, sizeof (MeshData), &mesh[0].s0); gl->ClientActiveTexture (GL_TEXTURE1); gl->EnableClientState (GL_TEXTURE_COORD_ARRAY); gl->TexCoordPointer (2, GL_FLOAT, sizeof (MeshData), &mesh[0].s1); gl->DrawElements (GL_TRIANGLES, 36, GL_UNSIGNED_SHORT, indices); gl->DisableClientState (GL_VERTEX_ARRAY); gl->DisableClientState (GL_TEXTURE_COORD_ARRAY); gl->DisableClientState (GL_NORMAL_ARRAY); gl->ClientActiveTexture (GL_TEXTURE0); gl->DisableClientState (GL_TEXTURE_COORD_ARRAY); gl->DisableVertexAttribArray (locTangent); gst_gl_context_clear_shader (context); gl->Disable (GL_LIGHT0); gl->Disable (GL_LIGHT1); gl->Disable (GL_LIGHTING); gl->Disable (GL_COLOR_MATERIAL); xrot += 1.0f; yrot += 0.9f; zrot += 0.6f; }