gstglshader.h 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. /*
  2. * GStreamer
  3. * Copyright (C) 2008 Filippo Argiolas <[email protected]>
  4. * Copyright (C) 2014 Julien Isorce <[email protected]>
  5. *
  6. * This library is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU Library General Public
  8. * License as published by the Free Software Foundation; either
  9. * version 2 of the License, or (at your option) any later version.
  10. *
  11. * This library is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * Library General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU Library General Public
  17. * License along with this library; if not, write to the
  18. * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
  19. * Boston, MA 02110-1301, USA.
  20. */
  21. #ifndef __GST_GL_SHADER_H__
  22. #define __GST_GL_SHADER_H__
  23. #include <gst/gl/gstgl_fwd.h>
  24. G_BEGIN_DECLS
  25. #define GST_GL_TYPE_SHADER (gst_gl_shader_get_type())
  26. #define GST_GL_SHADER(o) (G_TYPE_CHECK_INSTANCE_CAST((o), GST_GL_TYPE_SHADER, GstGLShader))
  27. #define GST_GL_SHADER_CLASS(k) (G_TYPE_CHECK_CLASS((k), GST_GL_TYPE_SHADER, GstGLShaderClass))
  28. #define GST_GL_IS_SHADER(o) (G_TYPE_CHECK_INSTANCE_TYPE((o), GST_GL_TYPE_SHADER))
  29. #define GST_GL_IS_SHADER_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE((k), GST_GL_TYPE_SHADER))
  30. #define GST_GL_SHADER_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS((o), GST_GL_TYPE_SHADER, GstGLShaderClass))
  31. #define GST_GL_SHADER_ERROR (gst_gl_shader_error_quark ())
  32. typedef enum {
  33. GST_GL_SHADER_ERROR_COMPILE,
  34. GST_GL_SHADER_ERROR_LINK,
  35. GST_GL_SHADER_ERROR_PROGRAM
  36. } GstGLShaderError;
  37. typedef enum {
  38. GST_GL_SHADER_FRAGMENT_SOURCE,
  39. GST_GL_SHADER_VERTEX_SOURCE
  40. } GstGLShaderSourceType;
  41. struct _GstGLShader {
  42. /*< private >*/
  43. GstObject parent;
  44. GstGLContext *context;
  45. GstGLShaderPrivate *priv;
  46. };
  47. struct _GstGLShaderClass {
  48. /*< private >*/
  49. GstObjectClass parent_class;
  50. };
  51. /* methods */
  52. GQuark gst_gl_shader_error_quark (void);
  53. GType gst_gl_shader_get_type (void);
  54. GstGLShader * gst_gl_shader_new (GstGLContext *context);
  55. void gst_gl_shader_set_vertex_source (GstGLShader *shader, const gchar *src);
  56. void gst_gl_shader_set_fragment_source (GstGLShader *shader, const gchar *src);
  57. const gchar * gst_gl_shader_get_vertex_source (GstGLShader *shader);
  58. const gchar * gst_gl_shader_get_fragment_source (GstGLShader *shader);
  59. void gst_gl_shader_set_active (GstGLShader *shader, gboolean active);
  60. gboolean gst_gl_shader_is_compiled (GstGLShader *shader);
  61. gboolean gst_gl_shader_compile (GstGLShader *shader, GError **error);
  62. gboolean gst_gl_shader_compile_and_check (GstGLShader *shader, const gchar *source, GstGLShaderSourceType type);
  63. gboolean gst_gl_shader_compile_all_with_attribs_and_check (GstGLShader *shader, const gchar *v_src, const gchar *f_src, const gint n_attribs, const gchar *attrib_names[], GLint attrib_locs[]);
  64. #if GST_GL_HAVE_GLES2
  65. gboolean gst_gl_shader_compile_with_default_f_and_check (GstGLShader *shader, const gchar *v_src, const gint n_attribs, const gchar *attrib_names[], GLint attrib_locs[]);
  66. gboolean gst_gl_shader_compile_with_default_v_and_check (GstGLShader *shader, const gchar *f_src, GLint *pos_loc, GLint *tex_loc);
  67. gboolean gst_gl_shader_compile_with_default_vf_and_check (GstGLShader *shader, GLint *pos_loc, GLint *tex_loc);
  68. #endif
  69. void gst_gl_shader_release (GstGLShader *shader);
  70. void gst_gl_shader_use (GstGLShader *shader);
  71. void gst_gl_context_clear_shader (GstGLContext *context);
  72. void gst_gl_shader_set_uniform_1i (GstGLShader *shader, const gchar *name, gint value);
  73. void gst_gl_shader_set_uniform_1iv (GstGLShader *shader, const gchar *name, guint count, gint *value);
  74. void gst_gl_shader_set_uniform_1f (GstGLShader *shader, const gchar *name, gfloat value);
  75. void gst_gl_shader_set_uniform_1fv (GstGLShader *shader, const gchar *name, guint count, gfloat *value);
  76. void gst_gl_shader_set_uniform_2i (GstGLShader *shader, const gchar *name, gint v0, gint v1);
  77. void gst_gl_shader_set_uniform_2iv (GstGLShader *shader, const gchar *name, guint count, gint *value);
  78. void gst_gl_shader_set_uniform_2f (GstGLShader *shader, const gchar *name, gfloat v0, gfloat v1);
  79. void gst_gl_shader_set_uniform_2fv (GstGLShader *shader, const gchar *name, guint count, gfloat *value);
  80. void gst_gl_shader_set_uniform_3i (GstGLShader *shader, const gchar *name, gint v0, gint v1, gint v2);
  81. void gst_gl_shader_set_uniform_3iv (GstGLShader *shader, const gchar *name, guint count, gint * value);
  82. void gst_gl_shader_set_uniform_3f (GstGLShader *shader, const gchar *name, gfloat v0, gfloat v1, gfloat v2);
  83. void gst_gl_shader_set_uniform_3fv (GstGLShader *shader, const gchar *name, guint count, gfloat *value);
  84. void gst_gl_shader_set_uniform_4i (GstGLShader *shader, const gchar *name, gint v0, gint v1, gint v2, gint v3);
  85. void gst_gl_shader_set_uniform_4iv (GstGLShader *shader, const gchar *name, guint count, gint *value);
  86. void gst_gl_shader_set_uniform_4f (GstGLShader *shader, const gchar *name, gfloat v0, gfloat v1, gfloat v2, gfloat v3);
  87. void gst_gl_shader_set_uniform_4fv (GstGLShader *shader, const gchar *name, guint count, gfloat *value);
  88. void gst_gl_shader_set_uniform_matrix_2fv (GstGLShader *shader, const gchar *name, gint count, gboolean transpose, const gfloat* value);
  89. void gst_gl_shader_set_uniform_matrix_3fv (GstGLShader *shader, const gchar *name, gint count, gboolean transpose, const gfloat* value);
  90. void gst_gl_shader_set_uniform_matrix_4fv (GstGLShader *shader, const gchar *name, gint count, gboolean transpose, const gfloat* value);
  91. #if GST_GL_HAVE_OPENGL
  92. void gst_gl_shader_set_uniform_matrix_2x3fv (GstGLShader *shader, const gchar *name, gint count, gboolean transpose, const gfloat* value);
  93. void gst_gl_shader_set_uniform_matrix_2x4fv (GstGLShader *shader, const gchar *name, gint count, gboolean transpose, const gfloat* value);
  94. void gst_gl_shader_set_uniform_matrix_3x2fv (GstGLShader *shader, const gchar *name, gint count, gboolean transpose, const gfloat* value);
  95. void gst_gl_shader_set_uniform_matrix_3x4fv (GstGLShader *shader, const gchar *name, gint count, gboolean transpose, const gfloat* value);
  96. void gst_gl_shader_set_uniform_matrix_4x2fv (GstGLShader *shader, const gchar *name, gint count, gboolean transpose, const gfloat* value);
  97. void gst_gl_shader_set_uniform_matrix_4x3fv (GstGLShader *shader, const gchar *name, gint count, gboolean transpose, const gfloat* value);
  98. #endif
  99. gint gst_gl_shader_get_attribute_location (GstGLShader *shader, const gchar *name);
  100. void gst_gl_shader_bind_attribute_location (GstGLShader * shader, guint index, const gchar * name);
  101. G_END_DECLS
  102. #endif /* __GST_GL_SHADER_H__ */