gl: remove the use of glu

This commit is contained in:
Matthew Waters 2014-11-27 16:17:50 +11:00 committed by Tim-Philipp Müller
parent 6bb113f685
commit 892d056a44
18 changed files with 14 additions and 307 deletions

View file

@ -17,8 +17,6 @@ OPENGL_SOURCES = \
gstglfilterglass.h \
gstglfilterapp.c \
gstglfilterapp.h \
gstglfilterreflectedscreen.c \
gstglfilterreflectedscreen.h \
gstgldeinterlace.c \
gstgldeinterlace.h \
gltestsrc.c \
@ -43,8 +41,6 @@ OPENGL_SOURCES = \
if HAVE_PNG
OPENGL_SOURCES += \
gstglbumper.c \
gstglbumper.h \
gstgldifferencematte.c \
gstgldifferencematte.h
endif

View file

@ -78,12 +78,7 @@ static gboolean gst_gl_filter_cube_set_caps (GstGLFilter * filter,
static void gst_gl_filter_cube_reset (GstGLFilter * filter);
static void gst_gl_filter_cube_reset_gl (GstGLFilter * filter);
static gboolean gst_gl_filter_cube_init_shader (GstGLFilter * filter);
static void _callback_gles2 (gint width, gint height, guint texture,
gpointer stuff);
#if GST_GL_HAVE_OPENGL
static void _callback_opengl (gint width, gint height, guint texture,
gpointer stuff);
#endif
static void _callback (gpointer stuff);
static gboolean gst_gl_filter_cube_filter_texture (GstGLFilter * filter,
guint in_tex, guint out_tex);
@ -324,29 +319,14 @@ gst_gl_filter_cube_filter_texture (GstGLFilter * filter, guint in_tex,
guint out_tex)
{
GstGLFilterCube *cube_filter = GST_GL_FILTER_CUBE (filter);
GLCB cb = NULL;
GstGLAPI api;
api = gst_gl_context_get_gl_api (GST_GL_FILTER (cube_filter)->context);
#if GST_GL_HAVE_OPENGL
if (api & GST_GL_API_OPENGL)
cb = _callback_opengl;
#endif
if (api & (GST_GL_API_GLES2 | GST_GL_API_OPENGL3))
cb = _callback_gles2;
cube_filter->in_tex = in_tex;
/* blocking call, use a FBO */
gst_gl_context_use_fbo (filter->context,
gst_gl_context_use_fbo_v2 (filter->context,
GST_VIDEO_INFO_WIDTH (&filter->out_info),
GST_VIDEO_INFO_HEIGHT (&filter->out_info),
filter->fbo, filter->depthbuffer, out_tex,
cb,
GST_VIDEO_INFO_WIDTH (&filter->in_info),
GST_VIDEO_INFO_HEIGHT (&filter->in_info),
in_tex, cube_filter->fovy, cube_filter->aspect,
cube_filter->znear, cube_filter->zfar,
GST_GL_DISPLAY_PROJECTION_PERSPECTIVE, (gpointer) cube_filter);
GST_VIDEO_INFO_HEIGHT (&filter->out_info), filter->fbo,
filter->depthbuffer, out_tex, _callback, (gpointer) cube_filter);
return TRUE;
}
@ -387,73 +367,6 @@ static const GLfloat vertices[] = {
};
/* *INDENT-ON* */
/* opengl scene, params: input texture (not the output filter->texture) */
#if GST_GL_HAVE_OPENGL
static void
_callback_opengl (gint width, gint height, guint texture, gpointer stuff)
{
GstGLFilterCube *cube_filter = GST_GL_FILTER_CUBE (stuff);
GstGLFilter *filter = GST_GL_FILTER (stuff);
GstGLFuncs *gl = filter->context->gl_vtable;
static GLfloat xrot = 0;
static GLfloat yrot = 0;
static GLfloat zrot = 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
};
gl->Enable (GL_DEPTH_TEST);
gl->Enable (GL_TEXTURE_2D);
gl->BindTexture (GL_TEXTURE_2D, texture);
gl->ClearColor (cube_filter->red, cube_filter->green, cube_filter->blue, 0.0);
gl->Clear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
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);
gl->LoadIdentity ();
// gl->Translatef (0.0f, 0.0f, -5.0f);
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->ClientActiveTexture (GL_TEXTURE0);
gl->EnableClientState (GL_TEXTURE_COORD_ARRAY);
gl->EnableClientState (GL_VERTEX_ARRAY);
gl->VertexPointer (3, GL_FLOAT, 5 * sizeof (float), vertices);
gl->TexCoordPointer (2, GL_FLOAT, 5 * sizeof (float), &vertices[3]);
gl->DrawElements (GL_TRIANGLES, 36, GL_UNSIGNED_SHORT, indices);
gl->DisableClientState (GL_TEXTURE_COORD_ARRAY);
gl->DisableClientState (GL_VERTEX_ARRAY);
gl->Disable (GL_DEPTH_TEST);
xrot += 0.3f;
yrot += 0.2f;
zrot += 0.4f;
}
#endif
static void
_bind_buffer (GstGLFilterCube * cube_filter)
{
@ -491,7 +404,7 @@ _unbind_buffer (GstGLFilterCube * cube_filter)
}
static void
_callback_gles2 (gint width, gint height, guint texture, gpointer stuff)
_callback (gpointer stuff)
{
GstGLFilter *filter = GST_GL_FILTER (stuff);
GstGLFilterCube *cube_filter = GST_GL_FILTER_CUBE (filter);
@ -531,7 +444,7 @@ _callback_gles2 (gint width, gint height, guint texture, gpointer stuff)
gst_gl_shader_use (cube_filter->shader);
gl->ActiveTexture (GL_TEXTURE0);
gl->BindTexture (GL_TEXTURE_2D, texture);
gl->BindTexture (GL_TEXTURE_2D, cube_filter->in_tex);
gst_gl_shader_set_uniform_1i (cube_filter->shader, "s_texture", 0);
gst_gl_shader_set_uniform_1f (cube_filter->shader, "xrot_degree", xrot);
gst_gl_shader_set_uniform_1f (cube_filter->shader, "yrot_degree", yrot);

View file

@ -52,6 +52,7 @@ struct _GstGLFilterCube
gdouble znear;
gdouble zfar;
guint in_tex;
GLuint vao;
GLuint vertex_buffer;
GLint attr_position;

View file

@ -1246,14 +1246,6 @@ gst_glimage_sink_on_resize (GstGLImageSink * gl_sink, gint width, gint height)
} else {
gl->Viewport (0, 0, width, height);
}
#if GST_GL_HAVE_OPENGL
if (USING_OPENGL (gl_sink->context)) {
gl->MatrixMode (GL_PROJECTION);
gl->LoadIdentity ();
gluOrtho2D (0, width, 0, height);
gl->MatrixMode (GL_MODELVIEW);
}
#endif
}
}

View file

@ -65,13 +65,13 @@
#include "gstglfilterlaplacian.h"
#include "gstglfilterglass.h"
#include "gstglfilterblur.h"
#include "gstglfilterreflectedscreen.h"
/* #include "gstglfilterreflectedscreen.h" */
#include "gstglfiltersobel.h"
#include "gstgldeinterlace.h"
#include "gstglmosaic.h"
#if HAVE_PNG
#include "gstgldifferencematte.h"
#include "gstglbumper.h"
/* #include "gstglbumper.h" */
#endif /* HAVE_PNG */
#endif /* GST_GL_HAVE_OPENGL */
@ -174,12 +174,12 @@ plugin_init (GstPlugin * plugin)
GST_RANK_NONE, GST_TYPE_GL_FILTER_GLASS)) {
return FALSE;
}
#if 0
if (!gst_element_register (plugin, "glfilterreflectedscreen",
GST_RANK_NONE, GST_TYPE_GL_FILTER_REFLECTED_SCREEN)) {
return FALSE;
}
#endif
if (!gst_element_register (plugin, "gldeinterlace",
GST_RANK_NONE, GST_TYPE_GL_DEINTERLACE)) {
return FALSE;
@ -194,11 +194,12 @@ plugin_init (GstPlugin * plugin)
GST_RANK_NONE, gst_gl_differencematte_get_type ())) {
return FALSE;
}
#if 0
if (!gst_element_register (plugin, "glbumper",
GST_RANK_NONE, gst_gl_bumper_get_type ())) {
return FALSE;
}
#endif
#endif /* HAVE_PNG */
#endif /* GST_GL_HAVE_OPENGL */

View file

@ -74,10 +74,8 @@
# define GL_DO_NOT_WARN_IF_MULTI_GL_VERSION_HEADERS_INCLUDED
# include <OpenGL/gl3.h>
# endif
# include <OpenGL/glu.h>
# else
# include <GL/gl.h>
# include <GL/glu.h>
# if __WIN32__ || _WIN32
# include <GL/glext.h>
# endif

View file

@ -165,110 +165,6 @@ gst_gl_framebuffer_generate (GstGLFramebuffer * frame, gint width, gint height,
return TRUE;
}
gboolean
gst_gl_framebuffer_use (GstGLFramebuffer * frame, gint texture_fbo_width,
gint texture_fbo_height, GLuint fbo, GLuint depth_buffer,
GLuint texture_fbo, GLCB cb, gint input_tex_width,
gint input_tex_height, GLuint input_tex, gdouble proj_param1,
gdouble proj_param2, gdouble proj_param3, gdouble proj_param4,
GstGLDisplayProjection projection, gpointer stuff)
{
const GstGLFuncs *gl;
#if GST_GL_HAVE_GLES2
GLint viewport_dim[4];
#endif
g_return_val_if_fail (GST_IS_GL_FRAMEBUFFER (frame), FALSE);
g_return_val_if_fail (input_tex_width > 0 && input_tex_height > 0, FALSE);
g_return_val_if_fail (texture_fbo_width > 0 && texture_fbo_height > 0, FALSE);
g_return_val_if_fail (input_tex != 0, FALSE);
g_return_val_if_fail (fbo != 0, FALSE);
g_return_val_if_fail (texture_fbo != 0, FALSE);
g_return_val_if_fail (cb != NULL, FALSE);
gl = frame->context->gl_vtable;
GST_TRACE ("Binding v1 FBO %u dimensions:%ux%u with texture:%u "
"dimensions:%ux%u", fbo, texture_fbo_width,
texture_fbo_height, texture_fbo, input_tex_width, input_tex_height);
gl->BindFramebuffer (GL_FRAMEBUFFER, fbo);
/*setup a texture to render to */
gl->BindTexture (GL_TEXTURE_2D, texture_fbo);
/* attach the texture to the FBO to renderer to */
gl->FramebufferTexture2D (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
GL_TEXTURE_2D, texture_fbo, 0);
gst_gl_context_clear_shader (frame->context);
#if GST_GL_HAVE_OPENGL
if (gst_gl_context_get_gl_api (frame->context) & GST_GL_API_OPENGL) {
gl->PushAttrib (GL_VIEWPORT_BIT);
gl->MatrixMode (GL_PROJECTION);
gl->PushMatrix ();
gl->LoadIdentity ();
switch (projection) {
case GST_GL_DISPLAY_PROJECTION_ORTHO2D:
gluOrtho2D (proj_param1, proj_param2, proj_param3, proj_param4);
break;
case GST_GL_DISPLAY_PROJECTION_PERSPECTIVE:
gluPerspective (proj_param1, proj_param2, proj_param3, proj_param4);
break;
default:
gst_gl_context_set_error (frame->context, "Unknow fbo projection %d",
projection);
}
gl->MatrixMode (GL_MODELVIEW);
gl->PushMatrix ();
gl->LoadIdentity ();
}
#endif
#if GST_GL_HAVE_GLES2
if (gst_gl_context_get_gl_api (frame->context) & GST_GL_API_GLES2)
gl->GetIntegerv (GL_VIEWPORT, viewport_dim);
#endif
gl->Viewport (0, 0, texture_fbo_width, texture_fbo_height);
#if GST_GL_HAVE_OPENGL
if (gst_gl_context_get_gl_api (frame->context) & GST_GL_API_OPENGL) {
const GLenum rt[] = { GL_COLOR_ATTACHMENT0 };
gl->DrawBuffers (1, rt);
}
#endif
gl->ClearColor (0.0, 0.0, 0.0, 0.0);
gl->Clear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
cb (input_tex_width, input_tex_height, input_tex, stuff);
#if GST_GL_HAVE_OPENGL
if (gst_gl_context_get_gl_api (frame->context) & GST_GL_API_OPENGL) {
const GLenum rt[] = { GL_NONE };
gl->DrawBuffers (1, rt);
gl->MatrixMode (GL_PROJECTION);
gl->PopMatrix ();
gl->MatrixMode (GL_MODELVIEW);
gl->PopMatrix ();
gl->PopAttrib ();
}
#endif
#if GST_GL_HAVE_GLES2
if (gst_gl_context_get_gl_api (frame->context) & GST_GL_API_GLES2) {
gl->Viewport (viewport_dim[0], viewport_dim[1], viewport_dim[2],
viewport_dim[3]);
}
#endif
gl->BindFramebuffer (GL_FRAMEBUFFER, 0);
return TRUE;
}
gboolean
gst_gl_framebuffer_use_v2 (GstGLFramebuffer * frame, gint texture_fbo_width,
gint texture_fbo_height, GLuint fbo, GLuint depth_buffer,

View file

@ -58,13 +58,6 @@ GstGLFramebuffer *gst_gl_framebuffer_new (GstGLContext *context);
gboolean gst_gl_framebuffer_generate (GstGLFramebuffer *frame, gint width, gint height,
guint * fbo, guint * depthbuffer);
gboolean gst_gl_framebuffer_use (GstGLFramebuffer * frame, gint texture_fbo_width,
gint texture_fbo_height, GLuint fbo, GLuint depth_buffer,
GLuint texture_fbo, GLCB cb, gint input_tex_width,
gint input_tex_height, GLuint input_tex, gdouble proj_param1,
gdouble proj_param2, gdouble proj_param3, gdouble proj_param4,
GstGLDisplayProjection projection, gpointer stuff);
gboolean gst_gl_framebuffer_use_v2 (GstGLFramebuffer * frame, gint texture_fbo_width,
gint texture_fbo_height, GLuint fbo, GLuint depth_buffer,
GLuint texture_fbo, GLCB_V2 cb, gpointer stuff);

View file

@ -341,68 +341,6 @@ gst_gl_context_gen_fbo (GstGLContext * context, gint width, gint height,
return TRUE;
}
typedef struct _UseFBO
{
GstGLFramebuffer *frame;
gint texture_fbo_width;
gint texture_fbo_height;
GLuint fbo;
GLuint depth_buffer;
GLuint texture_fbo;
GLCB cb;
gint input_tex_width;
gint input_tex_height;
GLuint input_tex;
gdouble proj_param1;
gdouble proj_param2;
gdouble proj_param3;
gdouble proj_param4;
GstGLDisplayProjection projection;
gpointer stuff;
} UseFBO;
static void
_use_fbo (GstGLContext * context, UseFBO * data)
{
gst_gl_framebuffer_use (data->frame, data->texture_fbo_width,
data->texture_fbo_height, data->fbo, data->depth_buffer,
data->texture_fbo, data->cb, data->input_tex_width,
data->input_tex_height, data->input_tex, data->proj_param1,
data->proj_param2, data->proj_param3, data->proj_param4, data->projection,
data->stuff);
}
/* Called by glfilter */
/* this function really has to be simplified... do we really need to
set projection this way? Wouldn't be better a set_projection
separate call? or just make glut functions available out of
gst-libs and call it if needed on drawcallback? -- Filippo */
/* GLCB too.. I think that only needed parameters should be
* GstGLDisplay *display and gpointer data, or just gpointer data */
/* ..everything here has to be simplified! */
gboolean
gst_gl_context_use_fbo (GstGLContext * context, gint texture_fbo_width,
gint texture_fbo_height, GLuint fbo, GLuint depth_buffer,
GLuint texture_fbo, GLCB cb, gint input_tex_width,
gint input_tex_height, GLuint input_tex, gdouble proj_param1,
gdouble proj_param2, gdouble proj_param3, gdouble proj_param4,
GstGLDisplayProjection projection, gpointer stuff)
{
GstGLFramebuffer *frame = gst_gl_framebuffer_new (context);
UseFBO data =
{ frame, texture_fbo_width, texture_fbo_height, fbo, depth_buffer,
texture_fbo, cb, input_tex_width, input_tex_height, input_tex,
proj_param1, proj_param2, proj_param3, proj_param4, projection, stuff
};
gst_gl_context_thread_add (context, (GstGLContextThreadFunc) _use_fbo, &data);
gst_object_unref (frame);
return TRUE;
}
typedef struct _UseFBO2
{
GstGLFramebuffer *frame;

View file

@ -76,12 +76,6 @@ void gst_gl_generate_texture_full (GstGLContext * context, const GstVideoInfo *
gboolean gst_gl_context_gen_fbo (GstGLContext * context, gint width, gint height,
GLuint * fbo, GLuint * depthbuffer);
gboolean gst_gl_context_use_fbo (GstGLContext * context, gint texture_fbo_width,
gint texture_fbo_height, GLuint fbo, GLuint depth_buffer,
GLuint texture_fbo, GLCB cb, gint input_texture_width,
gint input_texture_height, GLuint input_texture, gdouble proj_param1,
gdouble proj_param2, gdouble proj_param3, gdouble proj_param4,
GstGLDisplayProjection projection, gpointer stuff);
gboolean gst_gl_context_use_fbo_v2 (GstGLContext * context, gint texture_fbo_width,
gint texture_fbo_height, GLuint fbo, GLuint depth_buffer,
GLuint texture_fbo, GLCB_V2 cb, gpointer stuff);

View file

@ -19,7 +19,6 @@
*/
#include <GL/gl.h>
#include <GL/glu.h>
#if __WIN32__ || _WIN32
# include <GL/glext.h>
#endif
@ -70,7 +69,6 @@ static gboolean reshapeCallback (void *gl_sink, void *context, GLuint width, GLu
glViewport(0, 0, width, height);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(45, (gfloat)width/(gfloat)height, 0.1, 100);
glMatrixMode(GL_MODELVIEW);
return TRUE;

View file

@ -19,7 +19,6 @@
*/
#include <GL/gl.h>
#include <GL/glu.h>
#if __WIN32__ || _WIN32
# include <GL/glext.h>
#endif
@ -92,7 +91,6 @@ static gboolean reshapeCallback (void * gl_sink, void *context, GLuint width, GL
glViewport(0, 0, width, height);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(45, (gfloat)width/(gfloat)height, 0.1, 100);
glMatrixMode(GL_MODELVIEW);
return TRUE;

View file

@ -19,7 +19,6 @@
*/
#include <GL/gl.h>
#include <GL/glu.h>
#if __WIN32__ || _WIN32
# include <GL/glext.h>
#endif
@ -94,7 +93,6 @@ static gboolean reshapeCallback (void *gl_sink, void *context, GLuint width, GLu
glViewport(0, 0, width, height);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(45, (gfloat)width/(gfloat)height, 0.1, 100);
glMatrixMode(GL_MODELVIEW);
return TRUE;

View file

@ -19,7 +19,6 @@
*/
#include <GL/gl.h>
#include <GL/glu.h>
#if __WIN32__ || _WIN32
# include <GL/glext.h>
#endif

View file

@ -20,7 +20,6 @@
#include <gst/video/videooverlay.h>
#include <GL/gl.h>
#include <GL/glu.h>
#include "pipeline.h"
Pipeline::Pipeline(const WId id, const QString videoLocation):
@ -165,7 +164,6 @@ gboolean Pipeline::reshapeCallback (void *sink, void *context, guint width, guin
glViewport(0, 0, width, height);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(45, (gfloat)width/(gfloat)height, 0.1, 100);
glMatrixMode(GL_MODELVIEW);
return TRUE;

View file

@ -20,7 +20,6 @@
#include <gst/video/videooverlay.h>
#include <GL/gl.h>
#include <GL/glu.h>
#include "pipeline.h"
Pipeline::Pipeline(const WId id, const QString videoLocation):
@ -162,7 +161,6 @@ gboolean Pipeline::reshapeCallback (void *sink, void *context, guint width, guin
glViewport(0, 0, width, height);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(45, (gfloat)width/(gfloat)height, 0.1, 100);
glMatrixMode(GL_MODELVIEW);
return TRUE;

View file

@ -122,7 +122,6 @@ QGLRenderer::resizeGL (int width, int height)
glMatrixMode (GL_PROJECTION);
glLoadIdentity ();
gluPerspective (45.0f, (GLfloat) width / (GLfloat) height, 0.1f, 100.0f);
glMatrixMode (GL_MODELVIEW);
}

View file

@ -26,7 +26,6 @@
#endif
#include <GL/gl.h>
#include <GL/glu.h>
#include "SDL/SDL.h"
#include "SDL/SDL_opengl.h"
@ -62,8 +61,6 @@ InitGL (int Width, int Height) // We call this right after our OpenGL window is
glMatrixMode (GL_PROJECTION);
glLoadIdentity (); // Reset The Projection Matrix
gluPerspective (45.0f, (GLfloat) Width / (GLfloat) Height, 0.1f, 100.0f); // Calculate The Aspect Ratio Of The Window
glMatrixMode (GL_MODELVIEW);
}