114 lines
4.5 KiB
C
114 lines
4.5 KiB
C
/*
|
|
* This file is part of Shimatta OpenGL.
|
|
*
|
|
* Shimatta OpenGL 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/>.
|
|
*/
|
|
|
|
#ifndef _SHIMATTA_OPENGL_PROGRAM_H_
|
|
#define _SHIMATTA_OPENGL_PROGRAM_H_
|
|
|
|
#include <glib.h>
|
|
#include <glib-object.h>
|
|
#include <cglm/cglm.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. 1 is returned if program is already compiled
|
|
*/
|
|
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);
|
|
|
|
/**
|
|
* @brief Get the location of a uniform of a given shader program
|
|
* @param program Shader program
|
|
* @param uniform_name Name of the uniform parameter
|
|
* @return Location. -1 if error.
|
|
*/
|
|
int shimatta_opengl_program_get_uniform_location(ShimattaOpenglProgram *program, const char *uniform_name);
|
|
|
|
/**
|
|
* @brief Get the location of an Attribute of a given shader program
|
|
* @param program Shader program
|
|
* @param attrib_name Name of the attribute
|
|
* @return Location of attribute. -1 if error.
|
|
*/
|
|
int shimatta_opengl_program_get_attrib_location(ShimattaOpenglProgram *program, const char *attrib_name);
|
|
|
|
void shimatta_opengl_program_set_uniform_float(ShimattaOpenglProgram *program, const char *uniform, float value);
|
|
|
|
void shimatta_opengl_program_set_uniform_int(ShimattaOpenglProgram *program, const char *uniform, int value);
|
|
|
|
void shimatta_opengl_program_set_uniform_vec2(ShimattaOpenglProgram *program, const char *uniform, vec2 value);
|
|
|
|
void shimatta_opengl_program_set_uniform_vec3(ShimattaOpenglProgram *program, const char *uniform, vec3 value);
|
|
|
|
void shimatta_opengl_program_set_uniform_vec4(ShimattaOpenglProgram *program, const char *uniform, vec4 value);
|
|
|
|
void shimatta_opengl_program_set_uniform_mat2(ShimattaOpenglProgram *program, const char *uniform, mat2 value);
|
|
|
|
void shimatta_opengl_program_set_uniform_mat3(ShimattaOpenglProgram *program, const char *uniform, mat3 value);
|
|
|
|
void shimatta_opengl_program_set_uniform_mat4(ShimattaOpenglProgram *program, const char *uniform, mat4 value);
|
|
|
|
G_END_DECLS
|
|
|
|
#endif /* _SHIMATTA_OPENGL_PROGRAM_H_ */
|