Add opengl shader program class
This commit is contained in:
@@ -0,0 +1,75 @@
|
||||
/*
|
||||
* This file is part of Shimatta OpenGL.
|
||||
*
|
||||
* Foobar is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* Shimatta OpenGL is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with GtkGraphView. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <glib.h>
|
||||
#include <glib-object.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define SHIMATTA_TYPE_OPENGL_PROGRAM (shimatta_opengl_program_get_type())
|
||||
|
||||
G_DECLARE_FINAL_TYPE(ShimattaOpenglProgram, shimatta_opengl_program, SHIMATTA, OPENGL_PROGRAM, GObject);
|
||||
|
||||
/**
|
||||
* @brief generate a new shader program using the source code for the shaders
|
||||
* @param vertex_shader Vertex shader source code
|
||||
* @param geometry_shader Geometry shader source code
|
||||
* @param fragment_shader Fragement shader source code
|
||||
* @return New shader program
|
||||
*/
|
||||
ShimattaOpenglProgram *shimatta_opengl_program_new_from_data(const char *vertex_shader,
|
||||
const char *geometry_shader,
|
||||
const char *fragment_shader);
|
||||
|
||||
/**
|
||||
* @brief shimatta_opengl_program_new_from_file
|
||||
* @param vertex_shader Source file for the vertex shader
|
||||
* @param geometry_shader Source file for the geometry shader
|
||||
* @param fragment_shader source file for the fragment shader
|
||||
* @return New shader program
|
||||
* @note The files have tobe accessible when calling @ref shimatta_opengl_program_compile
|
||||
*/
|
||||
ShimattaOpenglProgram *shimatta_opengl_program_new_from_file(const char *vertex_shader,
|
||||
const char *geometry_shader,
|
||||
const char *fragment_shader);
|
||||
|
||||
/**
|
||||
* @brief Compile the OpenGL Program
|
||||
* @param program Shader Program
|
||||
* @param error_text Error message from compilation. May be NULL.
|
||||
* @param error_text_size Size in bytes of the error_text buffer. May be 0.
|
||||
* @return 0 if successful. If Error error text will hold the error
|
||||
*/
|
||||
int shimatta_opengl_program_compile(ShimattaOpenglProgram *program, char *error_text, size_t error_text_size);
|
||||
|
||||
/**
|
||||
* @brief Active shader program.
|
||||
*
|
||||
* The activation only works, if the program is compiled successfully
|
||||
*
|
||||
* @param program Shader program
|
||||
* @return 0 if successful
|
||||
*/
|
||||
int shimatta_opengl_program_use(ShimattaOpenglProgram *program);
|
||||
|
||||
/**
|
||||
* @brief Check if shader program is compiled
|
||||
* @param program Shader program
|
||||
* @return true if successfully built
|
||||
*/
|
||||
gboolean shimatta_opengl_program_is_compiled(ShimattaOpenglProgram *program);
|
||||
|
||||
G_END_DECLS
|
||||
|
Reference in New Issue
Block a user