Add graphics class and add example triangle
This commit is contained in:
33
include/shimatta-opengl-colored-triangle.h
Normal file
33
include/shimatta-opengl-colored-triangle.h
Normal file
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
* 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_COLORED_TRIANGLE_H_
|
||||
#define _SHIMATTA_OPENGL_COLORED_TRIANGLE_H_
|
||||
|
||||
#include <shimatta-opengl-graphics.h>
|
||||
#include <shimatta-opengl-program.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define SHIMATTA_TYPE_OPENGL_COLORED_TRIANGLE (shimatta_opengl_colored_triangle_get_type())
|
||||
|
||||
G_DECLARE_FINAL_TYPE(ShimattaOpenglColoredTriangle, shimatta_opengl_colored_triangle, SHIMATTA, OPENGL_COLORED_TRIANGLE, ShimattaOpenglGraphics);
|
||||
|
||||
ShimattaOpenglGraphics *shimatta_opengl_colored_triangle_new(ShimattaOpenglProgram *prog, const vec3 color, const vec3* vertecies);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* _SHIMATTA_OPENGL_COLORED_TRIANGLE_H_ */
|
46
include/shimatta-opengl-graphics.h
Normal file
46
include/shimatta-opengl-graphics.h
Normal file
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
* 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_GRAPHICS_H_
|
||||
#define _SHIMATTA_OPENGL_GRAPHICS_H_
|
||||
|
||||
#include <glib.h>
|
||||
#include <glib-object.h>
|
||||
#include <cglm/cglm.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define SHIMATTA_TYPE_OPENGL_GRAPHICS (shimatta_opengl_graphics_get_type())
|
||||
|
||||
G_DECLARE_DERIVABLE_TYPE(ShimattaOpenglGraphics, shimatta_opengl_graphics, SHIMATTA, OPENGL_GRAPHICS, GObject);
|
||||
|
||||
struct _ShimattaOpenglGraphicsClass {
|
||||
GObjectClass super_class;
|
||||
|
||||
int (*realize)(ShimattaOpenglGraphics *graphics);
|
||||
void (*draw)(ShimattaOpenglGraphics *graphics);
|
||||
void (*draw_with_model_matrix)(ShimattaOpenglGraphics *graphics, mat4 model_matrix, mat4 normal_matrix);
|
||||
};
|
||||
|
||||
int shimatta_opengl_graphics_realize(ShimattaOpenglGraphics *graphics);
|
||||
|
||||
void shimatta_opengl_graphics_draw(ShimattaOpenglGraphics *graphics);
|
||||
|
||||
void shimatta_opengl_graphics_draw_with_model_matrix(ShimattaOpenglGraphics *graphics, mat4 model_matrix, mat4 normal_matrix);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* _SHIMATTA_OPENGL_GRAPHICS_H_ */
|
@@ -14,6 +14,9 @@
|
||||
* 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>
|
||||
@@ -106,3 +109,5 @@ void shimatta_opengl_program_set_uniform_mat3(ShimattaOpenglProgram *program, co
|
||||
void shimatta_opengl_program_set_uniform_mat4(ShimattaOpenglProgram *program, const char *uniform, mat4 value);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* _SHIMATTA_OPENGL_PROGRAM_H_ */
|
||||
|
Reference in New Issue
Block a user