aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/mgl/gl.h48
-rw-r--r--include/mgl/graphics/texture.h21
-rw-r--r--include/mgl/window.h3
3 files changed, 70 insertions, 2 deletions
diff --git a/include/mgl/gl.h b/include/mgl/gl.h
index 745e69d..e715ec2 100644
--- a/include/mgl/gl.h
+++ b/include/mgl/gl.h
@@ -1,6 +1,47 @@
#ifndef MGL_GL_H
#define MGL_GL_H
+/* Copied from GL/glx.h */
+#define GLX_USE_GL 1
+#define GLX_BUFFER_SIZE 2
+#define GLX_LEVEL 3
+#define GLX_RGBA 4
+#define GLX_DOUBLEBUFFER 5
+#define GLX_STEREO 6
+#define GLX_AUX_BUFFERS 7
+#define GLX_RED_SIZE 8
+#define GLX_GREEN_SIZE 9
+#define GLX_BLUE_SIZE 10
+#define GLX_ALPHA_SIZE 11
+#define GLX_DEPTH_SIZE 12
+#define GLX_STENCIL_SIZE 13
+#define GLX_ACCUM_RED_SIZE 14
+#define GLX_ACCUM_GREEN_SIZE 15
+#define GLX_ACCUM_BLUE_SIZE 16
+#define GLX_ACCUM_ALPHA_SIZE 17
+
+/* Copied from GL/gl.h */
+#define GL_COLOR_BUFFER_BIT 0x00004000
+#define GL_BLEND 0x0BE2
+#define GL_SRC_ALPHA 0x0302
+#define GL_ONE_MINUS_SRC_ALPHA 0x0303
+#define GL_TEXTURE_2D 0x0DE1
+#define GL_TEXTURE_WRAP_S 0x2802
+#define GL_TEXTURE_WRAP_T 0x2803
+#define GL_TEXTURE_MAG_FILTER 0x2800
+#define GL_TEXTURE_MIN_FILTER 0x2801
+#define GL_UNSIGNED_BYTE 0x1401
+
+#define GL_RGB 0x1907
+#define GL_RGBA 0x1908
+
+#define GL_LUMINANCE8 0x8040
+#define GL_LUMINANCE8_ALPHA8 0x8045
+#define GL_RGB8 0x8051
+#define GL_RGBA8 0x8058
+#define GL_CLAMP_TO_EDGE 0x812F
+#define GL_LINEAR 0x2601
+
typedef struct _XVisualInfo _XVisualInfo;
typedef struct _XDisplay Display;
typedef struct __GLXcontextRec *GLXContext;
@@ -20,6 +61,13 @@ typedef struct {
void (*glClear)(unsigned int mask);
void (*glEnable)(unsigned int cap);
void (*glBlendFunc)(unsigned int sfactor, unsigned int dfactor);
+ void (*glGenTextures)(int n, unsigned int *textures);
+ void (*glDeleteTextures)(int n, const unsigned int *textures);
+ void (*glTexImage2D)(unsigned int target, int level, int internalFormat, int width, int height, int border, unsigned int format, unsigned int type, const void *pixels);
+ void (*glCompressedTexImage2D)(unsigned int target, int level, unsigned int internalformat, int width, int height, int border, int imageSize, const void *data);
+ 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);
/* Optional*/
void (*glXSwapIntervalEXT)(Display * dpy, GLXDrawable drawable, int interval);
diff --git a/include/mgl/graphics/texture.h b/include/mgl/graphics/texture.h
new file mode 100644
index 0000000..669be1e
--- /dev/null
+++ b/include/mgl/graphics/texture.h
@@ -0,0 +1,21 @@
+#ifndef MGL_TEXTURE_H
+#define MGL_TEXTURE_H
+
+typedef enum {
+ MGL_TEXTURE_GRAY = 1,
+ MGL_TEXTURE_GRAY_ALPHA = 2,
+ MGL_TEXTURE_RGB = 3,
+ MGL_TEXTURE_RGB_ALPHA = 4
+} mgl_texture_format;
+
+typedef struct {
+ 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);
+
+#endif /* MGL_TEXTURE_H */
diff --git a/include/mgl/window.h b/include/mgl/window.h
index 57e3072..7db4ecb 100644
--- a/include/mgl/window.h
+++ b/include/mgl/window.h
@@ -17,8 +17,7 @@ int mgl_window_create(mgl_window *self, const char *title, int width, int height
int mgl_window_create_with_params(mgl_window *self, const char *title, int width, int height, unsigned long parent_window, mgl_window_callback *callback, void *userdata);
void mgl_window_deinit(mgl_window *self);
-void mgl_window_show(mgl_window *self);
-void mgl_window_event_poll(mgl_window *self);
+void mgl_window_events_poll(mgl_window *self);
void mgl_window_draw(mgl_window *self);
#endif /* MGL_WINDOW_H */