diff --git a/libc3/window/sdl2/gl_camera.c b/libc3/window/sdl2/gl_camera.c
index 0021b76..1881b49 100644
--- a/libc3/window/sdl2/gl_camera.c
+++ b/libc3/window/sdl2/gl_camera.c
@@ -16,11 +16,11 @@
#include "gl_matrix_4d.h"
static const s8 * g_gl_camera_vertex_shader_src = "#version 330 core\n"
-"layout (location = 0) in dvec3 aPos;\n"
-"uniform dmat4 matrix;\n"
+"layout (location = 0) in vec3 aPos;\n"
+"uniform mat4 matrix;\n"
"\n"
"void main() {\n"
-" gl_Position = vec4(matrix * dvec4(aPos, 1.0));\n"
+" gl_Position = vec4(matrix * vec4(aPos, 1.0));\n"
"}\n";
void gl_camera_clean (s_gl_camera *camera)
@@ -41,15 +41,15 @@ s_gl_camera * gl_camera_init (s_gl_camera *camera, uw w, uw h)
u32 vertex_shader;
assert(camera);
gl_camera_set_aspect_ratio(camera, w, h);
- camera->clip_z_far = 1000;
- camera->clip_z_near = 0.1;
- camera->fov_y = 90.0;
- camera->position.x = 0.0;
- camera->position.y = 0.0;
- camera->position.z = -10.0;
- camera->rotation.x = 90.0;
- camera->rotation.y = 0.0;
- camera->rotation.z = 0.0;
+ camera->clip_z_far = 1000.0f;
+ camera->clip_z_near = 0.1f;
+ camera->fov_y = 90.0f;
+ camera->position.x = 0.0f;
+ camera->position.y = 0.0f;
+ camera->position.z = -10.0f;
+ camera->rotation.x = 90.0f;
+ camera->rotation.y = 0.0f;
+ camera->rotation.z = 0.0f;
vertex_shader = glCreateShader(GL_VERTEX_SHADER);
glShaderSource(vertex_shader, 1, &g_gl_camera_vertex_shader_src,
NULL);
@@ -101,7 +101,7 @@ void gl_camera_render (s_gl_camera *camera)
gl_matrix_4d_rotate_axis(&camera->matrix, camera->rotation.z,
&(s_gl_point_3d) { 0.0, 0.0, 1.0 });
glUseProgram(camera->gl_shader_program);
- glUniformMatrix4dv(camera->gl_matrix_loc, 1, GL_FALSE,
+ glUniformMatrix4fv(camera->gl_matrix_loc, 1, GL_FALSE,
&camera->matrix.xx);
}
diff --git a/libc3/window/sdl2/gl_matrix_4d.c b/libc3/window/sdl2/gl_matrix_4d.c
index a10f928..c9ead3f 100644
--- a/libc3/window/sdl2/gl_matrix_4d.c
+++ b/libc3/window/sdl2/gl_matrix_4d.c
@@ -22,14 +22,14 @@ sw gl_matrix_4d_buf_inspect (s_buf *buf, const s_gl_matrix_4d *matrix)
sw result = 0;
assert(buf);
assert(matrix);
- const f64 *m;
- if ((r = buf_write_1(buf, "(F64) {")) < 0)
+ const f32 *m;
+ if ((r = buf_write_1(buf, "(F32) {")) < 0)
return r;
result += r;
m = &matrix->xx;
i = 0;
while (i < 16) {
- if ((r = buf_inspect_f64(buf, m)) < 0)
+ if ((r = buf_inspect_f32(buf, m)) < 0)
return r;
result += r;
m++;
@@ -140,13 +140,13 @@ s_gl_matrix_4d * gl_matrix_4d_new_zero (void)
return m;
}
-s_gl_matrix_4d * gl_matrix_4d_ortho (s_gl_matrix_4d *m, f64 x1, f64 x2,
- f64 y1, f64 y2, f64 clip_z_near,
- f64 clip_z_far)
+s_gl_matrix_4d * gl_matrix_4d_ortho (s_gl_matrix_4d *m, f32 x1, f32 x2,
+ f32 y1, f32 y2, f32 clip_z_near,
+ f32 clip_z_far)
{
- f64 dx;
- f64 dy;
- f64 dz;
+ f32 dx;
+ f32 dy;
+ f32 dz;
s_gl_matrix_4d ortho;
assert(m);
dx = x2 - x1;
@@ -164,15 +164,15 @@ s_gl_matrix_4d * gl_matrix_4d_ortho (s_gl_matrix_4d *m, f64 x1, f64 x2,
return m;
}
-s_gl_matrix_4d * gl_matrix_4d_perspective (s_gl_matrix_4d *m, f64 fov_y,
- f64 aspect_ratio,
- f64 z_near,
- f64 z_far)
+s_gl_matrix_4d * gl_matrix_4d_perspective (s_gl_matrix_4d *m, f32 fov_y,
+ f32 aspect_ratio,
+ f32 z_near,
+ f32 z_far)
{
- f64 dz;
+ f32 dz;
s_gl_matrix_4d perspective;
- f64 f;
- f64 fov_y_2;
+ f32 f;
+ f32 fov_y_2;
fov_y_2 = fov_y / 2.0;
f = cos(fov_y_2) / sin(fov_y_2);
dz = z_near - z_far;
@@ -195,8 +195,8 @@ s_gl_matrix_4d * gl_matrix_4d_product (s_gl_matrix_4d *m,
return m;
}
-s_gl_matrix_4d * gl_matrix_4d_scale (s_gl_matrix_4d *m, f64 x, f64 y,
- f64 z)
+s_gl_matrix_4d * gl_matrix_4d_scale (s_gl_matrix_4d *m, f32 x, f32 y,
+ f32 z)
{
s_gl_matrix_4d s = {0};
s.xx = x;
@@ -207,8 +207,8 @@ s_gl_matrix_4d * gl_matrix_4d_scale (s_gl_matrix_4d *m, f64 x, f64 y,
return m;
}
-s_gl_matrix_4d * gl_matrix_4d_translate (s_gl_matrix_4d *m, f64 x,
- f64 y, f64 z)
+s_gl_matrix_4d * gl_matrix_4d_translate (s_gl_matrix_4d *m, f32 x,
+ f32 y, f32 z)
{
m->xt += x;
m->yt += y;
@@ -216,14 +216,14 @@ s_gl_matrix_4d * gl_matrix_4d_translate (s_gl_matrix_4d *m, f64 x,
return m;
}
-s_gl_matrix_4d * gl_matrix_4d_rotate_axis (s_gl_matrix_4d *m, f64 rad,
+s_gl_matrix_4d * gl_matrix_4d_rotate_axis (s_gl_matrix_4d *m, f32 rad,
const s_gl_point_3d *axis)
{
s_gl_point_3d a;
- f64 angle;
- f64 one_minus_x;
- f64 x;
- f64 y;
+ f32 angle;
+ f32 one_minus_x;
+ f32 x;
+ f32 y;
gl_point_3d_init_normalize(&a, axis);
angle = -rad;
x = cos(angle);
diff --git a/libc3/window/sdl2/gl_matrix_4d.h b/libc3/window/sdl2/gl_matrix_4d.h
index 4d4be24..39b0c13 100644
--- a/libc3/window/sdl2/gl_matrix_4d.h
+++ b/libc3/window/sdl2/gl_matrix_4d.h
@@ -33,20 +33,20 @@ s_gl_matrix_4d * gl_matrix_4d_new_matrix_mult (const s_gl_matrix_4d *a,
s_gl_matrix_4d * gl_matrix_4d_new_zero (void);
/* Operators. */
-s_gl_matrix_4d * gl_matrix_4d_ortho (s_gl_matrix_4d *m, f64 x1, f64 x2,
- f64 y1, f64 y2, f64 clip_z_near,
- f64 clip_z_far);
-s_gl_matrix_4d * gl_matrix_4d_perspective (s_gl_matrix_4d *m, f64 fov_y,
- f64 aspect_ratio,
- f64 clip_z_near,
- f64 clip_z_far);
+s_gl_matrix_4d * gl_matrix_4d_ortho (s_gl_matrix_4d *m, f32 x1, f32 x2,
+ f32 y1, f32 y2, f32 clip_z_near,
+ f32 clip_z_far);
+s_gl_matrix_4d * gl_matrix_4d_perspective (s_gl_matrix_4d *m, f32 fov_y,
+ f32 aspect_ratio,
+ f32 clip_z_near,
+ f32 clip_z_far);
s_gl_matrix_4d * gl_matrix_4d_product (s_gl_matrix_4d *m,
const s_gl_matrix_4d *a);
-s_gl_matrix_4d * gl_matrix_4d_rotate_axis (s_gl_matrix_4d *m, f64 rad,
+s_gl_matrix_4d * gl_matrix_4d_rotate_axis (s_gl_matrix_4d *m, f32 rad,
const s_gl_point_3d *axis);
-s_gl_matrix_4d * gl_matrix_4d_scale (s_gl_matrix_4d *m, f64 x, f64 y,
- f64 z);
-s_gl_matrix_4d * gl_matrix_4d_translate (s_gl_matrix_4d *m, f64 x,
- f64 y, f64 z);
+s_gl_matrix_4d * gl_matrix_4d_scale (s_gl_matrix_4d *m, f32 x, f32 y,
+ f32 z);
+s_gl_matrix_4d * gl_matrix_4d_translate (s_gl_matrix_4d *m, f32 x,
+ f32 y, f32 z);
#endif /* GL_MATRIX_4D_H */
diff --git a/libc3/window/sdl2/gl_ortho.c b/libc3/window/sdl2/gl_ortho.c
index 8574398..579e9de 100644
--- a/libc3/window/sdl2/gl_ortho.c
+++ b/libc3/window/sdl2/gl_ortho.c
@@ -16,19 +16,19 @@
#include "gl_matrix_4d.h"
static const s8 * g_gl_ortho_vertex_shader_src = "#version 330 core\n"
- "layout (location = 0) in dvec3 aPos;\n"
- "layout (location = 1) in dvec3 aNorm;\n"
- "layout (location = 2) in dvec2 aTexCoord;\n"
+ "layout (location = 0) in vec3 aPos;\n"
+ "layout (location = 1) in vec3 aNorm;\n"
+ "layout (location = 2) in vec2 aTexCoord;\n"
"out vec3 FragNormal;\n"
"out vec2 TexCoord;\n"
- "uniform dmat4 projection_matrix;\n"
- "uniform dmat4 view_matrix;\n"
- "uniform dmat4 model_matrix;\n"
+ "uniform mat4 projection_matrix;\n"
+ "uniform mat4 view_matrix;\n"
+ "uniform mat4 model_matrix;\n"
"\n"
"void main() {\n"
" gl_Position = vec4(projection_matrix * view_matrix * \n"
- " model_matrix * dvec4(aPos, 1.0));\n"
- " FragNormal = vec3(dmat3(transpose(inverse(model_matrix))) * aNorm);\n"
+ " model_matrix * vec4(aPos, 1.0));\n"
+ " FragNormal = vec3(mat3(transpose(inverse(model_matrix))) * aNorm);\n"
" TexCoord = vec2(aTexCoord);\n"
"}\n";
@@ -112,7 +112,7 @@ void gl_ortho_render (s_gl_ortho *ortho)
assert(glGetError() == GL_NO_ERROR);
glUseProgram(ortho->gl_shader_program);
assert(glGetError() == GL_NO_ERROR);
- glUniformMatrix4dv(ortho->gl_projection_matrix_loc, 1, GL_FALSE,
+ glUniformMatrix4fv(ortho->gl_projection_matrix_loc, 1, GL_FALSE,
&ortho->projection_matrix.xx);
if ((error = glGetError()) != GL_NO_ERROR) {
err_write_1("gl_ortho_render: glUniformMatrix4dv: ");
@@ -120,16 +120,16 @@ void gl_ortho_render (s_gl_ortho *ortho)
assert(! "gl_ortho_render: glUniformMatrix4dv");
}
assert(glGetError() == GL_NO_ERROR);
- glUniformMatrix4dv(ortho->gl_view_matrix_loc, 1, GL_FALSE,
+ glUniformMatrix4fv(ortho->gl_view_matrix_loc, 1, GL_FALSE,
&ortho->view_matrix.xx);
assert(glGetError() == GL_NO_ERROR);
- glUniformMatrix4dv(ortho->gl_model_matrix_loc, 1, GL_FALSE,
+ glUniformMatrix4fv(ortho->gl_model_matrix_loc, 1, GL_FALSE,
&ortho->model_matrix.xx);
assert(glGetError() == GL_NO_ERROR);
}
-void gl_ortho_resize (s_gl_ortho *ortho, f64 x1, f64 x2, f64 y1, f64 y2,
- f64 clip_z_near, f64 clip_z_far)
+void gl_ortho_resize (s_gl_ortho *ortho, f32 x1, f32 x2, f32 y1, f32 y2,
+ f32 clip_z_near, f32 clip_z_far)
{
assert(ortho);
gl_matrix_4d_init_identity(&ortho->projection_matrix);
@@ -150,7 +150,7 @@ void gl_ortho_update_model_matrix (s_gl_ortho *ortho)
{
assert(ortho);
assert(glGetError() == GL_NO_ERROR);
- glUniformMatrix4dv(ortho->gl_model_matrix_loc, 1, GL_FALSE,
+ glUniformMatrix4fv(ortho->gl_model_matrix_loc, 1, GL_FALSE,
&ortho->model_matrix.xx);
assert(glGetError() == GL_NO_ERROR);
}
@@ -168,7 +168,7 @@ void gl_ortho_update_view_matrix (s_gl_ortho *ortho)
&(s_gl_point_3d) { 0.0, 1.0, 0.0 });
gl_matrix_4d_rotate_axis(&ortho->view_matrix, ortho->rotation.z,
&(s_gl_point_3d) { 0.0, 0.0, 1.0 });
- glUniformMatrix4dv(ortho->gl_view_matrix_loc, 1, GL_FALSE,
+ glUniformMatrix4fv(ortho->gl_view_matrix_loc, 1, GL_FALSE,
&ortho->view_matrix.xx);
assert(glGetError() == GL_NO_ERROR);
}
diff --git a/libc3/window/sdl2/gl_ortho.h b/libc3/window/sdl2/gl_ortho.h
index 91f4c5d..a9f6fc5 100644
--- a/libc3/window/sdl2/gl_ortho.h
+++ b/libc3/window/sdl2/gl_ortho.h
@@ -27,8 +27,8 @@ s_gl_ortho * gl_ortho_new (void);
/* Operators. */
void gl_ortho_render (s_gl_ortho *ortho);
void gl_ortho_render_end (s_gl_ortho *ortho);
-void gl_ortho_resize (s_gl_ortho *ortho, f64 x1, f64 x2, f64 y1,
- f64 y2, f64 clip_z_near, f64 clip_z_far);
+void gl_ortho_resize (s_gl_ortho *ortho, f32 x1, f32 x2, f32 y1,
+ f32 y2, f32 clip_z_near, f32 clip_z_far);
void gl_ortho_update_model_matrix (s_gl_ortho *ortho);
void gl_ortho_update_view_matrix (s_gl_ortho *ortho);
diff --git a/libc3/window/sdl2/types.h b/libc3/window/sdl2/types.h
index 0f8e9de..b311db1 100644
--- a/libc3/window/sdl2/types.h
+++ b/libc3/window/sdl2/types.h
@@ -81,8 +81,8 @@ typedef void (*f_window_sdl2_unload) (s_window_sdl2 *window);
/* 1 */
struct gl_font {
FT_Face ft_face;
- f64 point_size;
- f64 pixel_per_point;
+ f32 point_size;
+ f32 pixel_per_point;
s_str path;
s_str real_path;
};
@@ -94,34 +94,34 @@ struct gl_lines {
};
struct gl_matrix_3d {
- f64 xx;
- f64 xy;
- f64 xz;
- f64 yx;
- f64 yy;
- f64 yz;
- f64 zx;
- f64 zy;
- f64 zz;
+ f32 xx;
+ f32 xy;
+ f32 xz;
+ f32 yx;
+ f32 yy;
+ f32 yz;
+ f32 zx;
+ f32 zy;
+ f32 zz;
};
struct gl_matrix_4d {
- f64 xx;
- f64 xy;
- f64 xz;
- f64 xt;
- f64 yx;
- f64 yy;
- f64 yz;
- f64 yt;
- f64 zx;
- f64 zy;
- f64 zz;
- f64 zt;
- f64 tx;
- f64 ty;
- f64 tz;
- f64 tt;
+ f32 xx;
+ f32 xy;
+ f32 xz;
+ f32 xt;
+ f32 yx;
+ f32 yy;
+ f32 yz;
+ f32 yt;
+ f32 zx;
+ f32 zy;
+ f32 zz;
+ f32 zt;
+ f32 tx;
+ f32 ty;
+ f32 tz;
+ f32 tt;
};
struct gl_object {
@@ -134,14 +134,14 @@ struct gl_object {
};
struct gl_point_2d {
- f64 x;
- f64 y;
+ f32 x;
+ f32 y;
};
struct gl_point_3d {
- f64 x;
- f64 y;
- f64 z;
+ f32 x;
+ f32 y;
+ f32 z;
};
struct gl_text {
@@ -160,16 +160,16 @@ struct gl_triangle {
};
struct rgb {
- f64 r;
- f64 g;
- f64 b;
+ f32 r;
+ f32 g;
+ f32 b;
};
struct rgba {
- f64 r;
- f64 g;
- f64 b;
- f64 a;
+ f32 r;
+ f32 g;
+ f32 b;
+ f32 a;
};
/* Subtype of s_window. See libc3/window/types.h */
@@ -202,10 +202,10 @@ struct window_sdl2 {
/* 2 */
struct gl_camera {
- f64 aspect_ratio;
- f64 clip_z_far;
- f64 clip_z_near;
- f64 fov_y;
+ f32 aspect_ratio;
+ f32 clip_z_far;
+ f32 clip_z_near;
+ f32 fov_y;
s_gl_point_3d position;
s_gl_point_3d rotation;
s_gl_matrix_4d matrix;
@@ -220,12 +220,12 @@ struct gl_cylinder {
};
struct gl_ortho {
- f64 x1;
- f64 x2;
- f64 y1;
- f64 y2;
- f64 clip_z_near;
- f64 clip_z_far;
+ f32 x1;
+ f32 x2;
+ f32 y1;
+ f32 y2;
+ f32 clip_z_near;
+ f32 clip_z_far;
s_gl_point_3d position;
s_gl_point_3d rotation;
s_gl_matrix_4d projection_matrix;