summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gl.c14
-rw-r--r--main.c1
-rw-r--r--math.c123
3 files changed, 14 insertions, 124 deletions
diff --git a/gl.c b/gl.c
index 9873bfa..5ef3360 100644
--- a/gl.c
+++ b/gl.c
@@ -2,6 +2,20 @@
// macro trickery to avoid having to write everything twice
#define gl_for_each_proc(do)\
+ do(DRAWARRAYS, DrawArrays)\
+ do(GENTEXTURES, GenTextures)\
+ do(DELETETEXTURES, DeleteTextures)\
+ do(TEXIMAGE2D, TexImage2D)\
+ do(BINDTEXTURE, BindTexture)\
+ do(TEXPARAMETERI, TexParameteri)\
+ do(GETERROR, GetError)\
+ do(GETINTEGERV, GetIntegerv)\
+ do(ENABLE, Enable)\
+ do(DISABLE, Disable)\
+ do(BLENDFUNC, BlendFunc)\
+ do(VIEWPORT, Viewport)\
+ do(CLEARCOLOR, ClearColor)\
+ do(CLEAR, Clear)\
do(CREATESHADER, CreateShader)\
do(DELETESHADER, DeleteShader)\
do(CREATEPROGRAM, CreateProgram)\
diff --git a/main.c b/main.c
index 5d3d37a..bba3b6b 100644
--- a/main.c
+++ b/main.c
@@ -13,7 +13,6 @@ no_warn_start
#include <SDL2/SDL.h>
#endif
no_warn_end
-#include <GL/gl.h>
#include <locale.h>
#include <wctype.h>
#if _WIN32
diff --git a/math.c b/math.c
index 2b01730..b833872 100644
--- a/math.c
+++ b/math.c
@@ -276,29 +276,11 @@ static void v2_print(v2 v) {
printf("(%f, %f)\n", v.x, v.y);
}
-#if MATH_GL
-static void v2_gl_vertex(v2 v) {
- glVertex2f(v.x, v.y);
-}
-#endif
-
static v2 v2_rand_unit(void) {
float theta = rand_uniform(0, TAUf);
return V2(cosf(theta), sinf(theta));
}
-#if MATH_GL
-static void v2_rand_unit_test(void) {
- int i;
- glColor3f(1.0f, 0.0f, 0.0f);
- glBegin(GL_POINTS);
- for (i = 0; i < 100000; ++i) {
- v2_gl_vertex(v2_rand_unit());
- }
- glEnd();
-}
-#endif
-
static v2 v2_polar(float r, float theta) {
return V2(r * cosf(theta), r * sinf(theta));
}
@@ -321,20 +303,6 @@ static v3 v3_from_v2(v2 v) {
return V3(v.x, v.y, 0);
}
-#if MATH_GL
-static void v3_gl_vertex(v3 v) {
- glVertex3f(v.x, v.y, v.z);
-}
-
-static void v3_gl_color(v3 v) {
- glColor3f(v.x, v.y, v.z);
-}
-
-static void v3_gl_color_alpha(v3 v, float alpha) {
- glColor4f(v.x, v.y, v.z, alpha);
-}
-#endif
-
static v3 v3_add(v3 a, v3 b) {
return V3(a.x + b.x, a.y + b.y, a.z + b.z);
}
@@ -413,18 +381,6 @@ static v3 v3_rand_unit(void) {
return V3(0, 0, 0);
}
-#if MATH_GL
-static void v3_rand_unit_test(void) {
- int i;
- glColor3f(1.0f, 0.0f, 0.0f);
- glBegin(GL_POINTS);
- for (i = 0; i < 100000; ++i) {
- v3_gl_vertex(v3_rand_unit());
- }
- glEnd();
-}
-#endif
-
typedef struct {
float x, y, z, w;
} v4;
@@ -440,12 +396,6 @@ static v4 V4(float x, float y, float z, float w) {
return v;
}
-#if MATH_GL
-static void v4_gl_color(v4 v) {
- glColor4f(v.x, v.y, v.z, v.w);
-}
-#endif
-
static v4 v4_add(v4 a, v4 b) {
return V4(a.x + b.x, a.y + b.y, a.z + b.z, a.w + b.w);
}
@@ -719,60 +669,6 @@ static void rect_print(Rect r) {
printf("Position: (%f, %f), Size: (%f, %f)\n", r.pos.x, r.pos.y, r.size.x, r.size.y);
}
-#if MATH_GL
-
-#if 0
-// must be rendering GL_QUADS to use these functions!
-
-static void rect_render(Rect r) {
- float x1 = r.pos.x, y1 = r.pos.y, x2 = x1 + r.size.x, y2 = y1 + r.size.y;
- glVertex2f(x1, y1);
- glVertex2f(x2, y1);
- glVertex2f(x2, y2);
- glVertex2f(x1, y2);
-}
-
-static void rect_render_border(Rect r, float border_thickness) {
- float border_radius = border_thickness * 0.5f;
- float x1 = r.pos.x, y1 = r.pos.y, x2 = x1 + r.size.x, y2 = y1 + r.size.y;
-
- glVertex2f(x1+border_radius, y1-border_radius);
- glVertex2f(x1+border_radius, y1+border_radius);
- glVertex2f(x2+border_radius, y1+border_radius);
- glVertex2f(x2+border_radius, y1-border_radius);
-
- glVertex2f(x1-border_radius, y2-border_radius);
- glVertex2f(x1-border_radius, y2+border_radius);
- glVertex2f(x2-border_radius, y2+border_radius);
- glVertex2f(x2-border_radius, y2-border_radius);
-
- glVertex2f(x1-border_radius, y1-border_radius);
- glVertex2f(x1+border_radius, y1-border_radius);
- glVertex2f(x1+border_radius, y2-border_radius);
- glVertex2f(x1-border_radius, y2-border_radius);
-
- glVertex2f(x2-border_radius, y1+border_radius);
- glVertex2f(x2+border_radius, y1+border_radius);
- glVertex2f(x2+border_radius, y2+border_radius);
- glVertex2f(x2-border_radius, y2+border_radius);
-}
-#endif
-
-/*
- gl grayscale color
- i am tired of not having this
-*/
-static void gl_color1f(float v) {
- glColor3f(v,v,v);
-}
-
-/*
- gl grayscale+alpha color
-*/
-static void gl_color2f(float v, float a) {
- glColor4f(v,v,v,a);
-}
-
static void rgba_u32_to_floats(u32 rgba, float floats[4]) {
floats[0] = (float)((rgba >> 24) & 0xFF) / 255.f;
floats[1] = (float)((rgba >> 16) & 0xFF) / 255.f;
@@ -786,23 +682,6 @@ static v4 rgba_u32_to_v4(u32 rgba) {
return V4(c[0], c[1], c[2], c[3]);
}
-// color is 0xRRGGBBAA
-static void gl_color_rgba(u32 color) {
- glColor4ub((u8)(color >> 24), (u8)(color >> 16), (u8)(color >> 8), (u8)color);
-}
-
-// color is 0xRRGGBB
-static void gl_color_rgb(u32 color) {
- gl_color_rgba((color << 8) | 0xff);
-}
-
-static void gl_quad(float x1, float y1, float x2, float y2) {
- glVertex2f(x1, y1);
- glVertex2f(x2, y1);
- glVertex2f(x2, y2);
- glVertex2f(x1, y2);
-}
-
// returns average of red green and blue components of color
static float rgba_brightness(u32 color) {
u8 r = (u8)(color >> 24), g = (u8)(color >> 16), b = (u8)(color >> 8);
@@ -828,5 +707,3 @@ static bool rect_clip_to_rect(Rect *clipped, Rect clipper) {
clipped->size.y = clampf(clipped->size.y, 0, clipper.pos.y + clipper.size.y - clipped->pos.y);
return clipped->size.x > 0 && clipped->size.y > 0;
}
-#endif
-