shimatta-opengl/src/shimatta-opengl-graphics.c

102 lines
2.7 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/>.
*/
#include <shimatta-opengl-graphics.h>
typedef struct {
gpointer dummy[12];
} ShimattaOpenglGraphicsPrivate;
G_DEFINE_TYPE_WITH_PRIVATE(ShimattaOpenglGraphics, shimatta_opengl_graphics, G_TYPE_OBJECT);
static void shimatta_opengl_graphics_dispose(GObject *self)
{
(void)self;
}
static void draw_dummy(ShimattaOpenglGraphics *graphics)
{
(void)graphics;
g_warning("Object does not implement draw function");
}
static void draw_dummy_with_matrix(ShimattaOpenglGraphics *graphics, mat4 model_matrix, mat4 normal_matrix)
{
(void)graphics;
(void)model_matrix;
(void)normal_matrix;
g_warning("Object does not implement draw_with_model_matrix function");
}
static int realize_dummy(ShimattaOpenglGraphics *graphics)
{
(void)graphics;
g_warning("Object does not implement relize function");
return -1;
}
static void shimatta_opengl_graphics_class_init(ShimattaOpenglGraphicsClass *klass)
{
(void)klass;
GObjectClass *oclass;
oclass = G_OBJECT_CLASS(klass);
oclass->dispose = shimatta_opengl_graphics_dispose;
klass->draw = draw_dummy;
klass->draw_with_model_matrix = draw_dummy_with_matrix;
klass->realize = realize_dummy;
return;
}
static void shimatta_opengl_graphics_init(ShimattaOpenglGraphics *self)
{
(void)self;
return;
}
int shimatta_opengl_graphics_realize(ShimattaOpenglGraphics *graphics)
{
ShimattaOpenglGraphicsClass *klass;
g_return_val_if_fail(SHIMATTA_IS_OPENGL_GRAPHICS(graphics), -1001);
klass = SHIMATTA_OPENGL_GRAPHICS_GET_CLASS(graphics);
return klass->realize(graphics);
}
void shimatta_opengl_graphics_draw(ShimattaOpenglGraphics *graphics)
{
ShimattaOpenglGraphicsClass *klass;
g_return_if_fail(SHIMATTA_IS_OPENGL_GRAPHICS(graphics));
klass = SHIMATTA_OPENGL_GRAPHICS_GET_CLASS(graphics);
klass->draw(graphics);
}
void shimatta_opengl_graphics_draw_with_model_matrix(ShimattaOpenglGraphics *graphics, mat4 model_matrix, mat4 normal_matrix)
{
ShimattaOpenglGraphicsClass *klass;
g_return_if_fail(SHIMATTA_IS_OPENGL_GRAPHICS(graphics));
klass = SHIMATTA_OPENGL_GRAPHICS_GET_CLASS(graphics);
klass->draw_with_model_matrix(graphics, model_matrix, normal_matrix);
}