aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/mgl/gl.h13
-rw-r--r--include/mgl/graphics/color.h8
-rw-r--r--include/mgl/graphics/rectangle.h17
-rw-r--r--include/mgl/graphics/sprite.h21
-rw-r--r--include/mgl/graphics/texture.h6
-rw-r--r--include/mgl/graphics/vec.h8
-rw-r--r--include/mgl/mgl.h5
-rw-r--r--include/mgl/window.h2
8 files changed, 76 insertions, 4 deletions
diff --git a/include/mgl/gl.h b/include/mgl/gl.h
index 7d9900c..823e6af 100644
--- a/include/mgl/gl.h
+++ b/include/mgl/gl.h
@@ -47,6 +47,10 @@
#define GL_CLAMP_TO_EDGE 0x812F
#define GL_LINEAR 0x2601
+#define GL_QUADS 0x0007
+
+#define GL_PROJECTION 0x1701
+
typedef struct _XVisualInfo _XVisualInfo;
typedef struct _XDisplay Display;
typedef struct __GLXcontextRec *GLXContext;
@@ -73,6 +77,15 @@ typedef struct {
void (*glBindTexture)(unsigned int target, unsigned int texture);
void (*glTexParameteri)(unsigned int target, unsigned int pname, int param);
void (*glHint)(unsigned int target, unsigned int mode);
+ void (*glBegin)(unsigned int mode);
+ void (*glEnd)(void);
+ void (*glColor3f)(float red, float green, float blue);
+ void (*glVertex3f)(float x, float y, float z);
+ void (*glColor4f)(float red, float green, float blue, float alpha);
+ void (*glTexCoord2f)(float s, float t);
+ void (*glOrtho)(double left, double right, double bottom, double top, double near_val, double far_val);
+ void (*glMatrixMode)(unsigned int mode);
+ void (*glLoadIdentity)(void);
/* Optional*/
void (*glXSwapIntervalEXT)(Display * dpy, GLXDrawable drawable, int interval);
diff --git a/include/mgl/graphics/color.h b/include/mgl/graphics/color.h
new file mode 100644
index 0000000..62ded72
--- /dev/null
+++ b/include/mgl/graphics/color.h
@@ -0,0 +1,8 @@
+#ifndef MGL_COLOR_H
+#define MGL_COLOR_H
+
+typedef struct {
+ float r, g, b, a;
+} mgl_color;
+
+#endif /* MGL_COLOR_H */
diff --git a/include/mgl/graphics/rectangle.h b/include/mgl/graphics/rectangle.h
new file mode 100644
index 0000000..7c2403b
--- /dev/null
+++ b/include/mgl/graphics/rectangle.h
@@ -0,0 +1,17 @@
+#ifndef MGL_RECTANGLE_H
+#define MGL_RECTANGLE_H
+
+#include "color.h"
+#include "vec.h"
+
+typedef struct mgl_context mgl_context;
+
+typedef struct {
+ mgl_color color;
+ mgl_vec2f position;
+ mgl_vec2f size;
+} mgl_rectangle;
+
+void mgl_rectangle_draw(mgl_context *context, mgl_rectangle *rect);
+
+#endif /* MGL_RECTANGLE_H */
diff --git a/include/mgl/graphics/sprite.h b/include/mgl/graphics/sprite.h
new file mode 100644
index 0000000..045da19
--- /dev/null
+++ b/include/mgl/graphics/sprite.h
@@ -0,0 +1,21 @@
+#ifndef MGL_SPRITE_H
+#define MGL_SPRITE_H
+
+#include "color.h"
+#include "vec.h"
+
+typedef struct mgl_context mgl_context;
+typedef struct mgl_texture mgl_texture;
+
+typedef struct {
+ mgl_texture *texture;
+ mgl_color color;
+ mgl_vec2f position;
+ mgl_vec2f scale;
+} mgl_sprite;
+
+void mgl_sprite_init(mgl_sprite *self, mgl_texture *texture, float x, float y);
+void mgl_sprite_draw(mgl_context *context, mgl_sprite *sprite);
+void mgl_sprite_set_color(mgl_sprite *self, float r, float g, float b, float a);
+
+#endif /* MGL_SPRITE_H */
diff --git a/include/mgl/graphics/texture.h b/include/mgl/graphics/texture.h
index 669be1e..7048c20 100644
--- a/include/mgl/graphics/texture.h
+++ b/include/mgl/graphics/texture.h
@@ -1,6 +1,8 @@
#ifndef MGL_TEXTURE_H
#define MGL_TEXTURE_H
+typedef struct mgl_texture mgl_texture;
+
typedef enum {
MGL_TEXTURE_GRAY = 1,
MGL_TEXTURE_GRAY_ALPHA = 2,
@@ -8,12 +10,12 @@ typedef enum {
MGL_TEXTURE_RGB_ALPHA = 4
} mgl_texture_format;
-typedef struct {
+struct mgl_texture {
unsigned int id;
int width;
int height;
mgl_texture_format format;
-} mgl_texture;
+};
int mgl_texture_load_from_file(mgl_texture *self, const char *filepath);
void mgl_texture_unload(mgl_texture *self);
diff --git a/include/mgl/graphics/vec.h b/include/mgl/graphics/vec.h
new file mode 100644
index 0000000..562f560
--- /dev/null
+++ b/include/mgl/graphics/vec.h
@@ -0,0 +1,8 @@
+#ifndef MGL_VEC_H
+#define MGL_VEC_H
+
+typedef struct {
+ float x, y;
+} mgl_vec2f;
+
+#endif /* MGL_VEC_H */
diff --git a/include/mgl/mgl.h b/include/mgl/mgl.h
index e906bc1..15020e9 100644
--- a/include/mgl/mgl.h
+++ b/include/mgl/mgl.h
@@ -5,13 +5,14 @@
/* Display* on x11 */
typedef void* mgl_connection;
+typedef struct mgl_context mgl_context;
-typedef struct {
+struct mgl_context {
mgl_connection connection;
GLXContext glx_context;
_XVisualInfo *visual_info;
mgl_gl gl;
-} mgl_context;
+};
/*
Safe to call multiple times, but will only be initialized the first time called.
diff --git a/include/mgl/window.h b/include/mgl/window.h
index 1cee698..34920a8 100644
--- a/include/mgl/window.h
+++ b/include/mgl/window.h
@@ -11,6 +11,8 @@ typedef struct {
struct mgl_window {
unsigned long window;
mgl_window_callback callback;
+ int width;
+ int height;
};
int mgl_window_create(mgl_window *self, const char *title, int width, int height, mgl_window_callback *callback);