shimatta-opengl/src/shimatta-opengl-program.c

76 lines
2.0 KiB
C

/*
* 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 <shimatta-opengl-program.h>
#include <epoxy/gl.h>
struct _ShimattaOpenglProgram {
GObject super;
};
typedef struct {
GLint shader_id;
gboolean compiled;
char *fragment_file;
char *vertex_file;
char *geometry_file;
char *fragment_src;
char *vertex_src;
char *geometry_src;
} ShimattaOpenglProgramPrivate;
G_DEFINE_TYPE_WITH_PRIVATE(ShimattaOpenglProgram, shimatta_opengl_program, G_TYPE_OBJECT);
static void shimatta_opengl_program_class_init(ShimattaOpenglProgramClass *klass)
{
(void)klass;
return;
}
static void shimatta_opengl_program_init(ShimattaOpenglProgram *self)
{
ShimattaOpenglProgramPrivate *priv;
priv = shimatta_opengl_program_get_instance_private(self);
priv->shader_id = 0;
priv->vertex_src = NULL;
priv->vertex_file = NULL;
priv->fragment_src = NULL;
priv->geometry_src = NULL;
priv->fragment_file = NULL;
priv->geometry_file = NULL;
priv->compiled = false;
}
ShimattaOpenglProgram *shimatta_opengl_program_new_from_data(const char *vertex_shader, const char *geometry_shader,
const char *fragment_shader)
{
ShimattaOpenglProgram *ret;
ShimattaOpenglProgramPrivate *priv;
ret = g_object_new(SHIMATTA_TYPE_OPENGL_PROGRAM, NULL);
priv = shimatta_opengl_program_get_instance_private(ret);
priv->fragment_src = g_strdup(fragment_shader);
priv->geometry_src = g_strdup(geometry_shader);
priv->vertex_src= g_strdup(vertex_shader);
return ret;
}