diff --git a/libc3/window/sdl2/demo/window_sdl2_demo.c b/libc3/window/sdl2/demo/window_sdl2_demo.c
index 7cc1c93..d0a5a03 100644
--- a/libc3/window/sdl2/demo/window_sdl2_demo.c
+++ b/libc3/window/sdl2/demo/window_sdl2_demo.c
@@ -281,6 +281,7 @@ bool window_sdl2_demo_render (s_window_sdl2 *window)
render_text(&g_text_seq_title, 20.0f, 30.0f);
*/
/* progress bar */
+ /*
glDisable(GL_BLEND);
assert(glGetError() == GL_NO_ERROR);
assert(glGetError() == GL_NO_ERROR);
@@ -294,11 +295,13 @@ bool window_sdl2_demo_render (s_window_sdl2 *window)
4.0, 0);
gl_ortho_update_model_matrix(&g_ortho);
gl_square_render(&g_square);
+ */
/*
glRectd(19, 11,
19 + (window->w - 40.0) * seq->t / seq->duration + 2,
11 + 4);
*/
+ /*
glBlendColor(0.0f, 0.0f, 0.0f, 1.0f);
gl_matrix_4f_init_identity(&g_ortho.model_matrix);
gl_matrix_4f_translate(&g_ortho.model_matrix, 20.0, 12.0, 0);
@@ -307,6 +310,7 @@ bool window_sdl2_demo_render (s_window_sdl2 *window)
2.0, 0);
gl_ortho_update_model_matrix(&g_ortho);
gl_square_render(&g_square);
+ */
/*
glRectd(20, 12,
20 + (window->w - 40.0) * seq->t / seq->duration,
diff --git a/libc3/window/sdl2/gl_matrix_4f.c b/libc3/window/sdl2/gl_matrix_4f.c
index 7236514..dfca8d9 100644
--- a/libc3/window/sdl2/gl_matrix_4f.c
+++ b/libc3/window/sdl2/gl_matrix_4f.c
@@ -175,9 +175,9 @@ s_gl_matrix_4f * gl_matrix_4f_ortho (s_gl_matrix_4f *m, f32 x1, f32 x2,
ortho.xx = 2.0 / dx;
ortho.yy = 2.0 / dy;
ortho.zz = -2.0 / dz;
- ortho.tx = - (x1 + x2) / dx;
- ortho.ty = - (y1 + y2) / dy;
- ortho.tz = - (clip_z_near + clip_z_far) / dz;
+ ortho.xt = - (x1 + x2) / dx;
+ ortho.yt = - (y1 + y2) / dy;
+ ortho.zt = - (clip_z_near + clip_z_far) / dz;
ortho.tt = 1.0;
gl_matrix_4f_product(m, &ortho);
return m;
@@ -230,9 +230,9 @@ s_gl_matrix_4f * gl_matrix_4f_scale (s_gl_matrix_4f *m, f32 x, f32 y,
s_gl_matrix_4f * gl_matrix_4f_translate (s_gl_matrix_4f *m, f32 x,
f32 y, f32 z)
{
- m->tx += x;
- m->ty += y;
- m->tz += z;
+ m->xt += x;
+ m->yt += y;
+ m->zt += z;
return m;
}
diff --git a/libc3/window/sdl2/gl_ortho.c b/libc3/window/sdl2/gl_ortho.c
index 1e80bbf..434ecaf 100644
--- a/libc3/window/sdl2/gl_ortho.c
+++ b/libc3/window/sdl2/gl_ortho.c
@@ -131,6 +131,13 @@ void gl_ortho_render (s_gl_ortho *ortho)
&ortho->model_matrix.xx);
glDepthRange(ortho->clip_z_near, ortho->clip_z_far);
assert(glGetError() == GL_NO_ERROR);
+ err_puts("gl_ortho_render projection matrix");
+ gl_matrix_4f_buf_inspect(&g_c3_env.err, &ortho->projection_matrix);
+ err_puts("view matrix");
+ gl_matrix_4f_buf_inspect(&g_c3_env.err, &ortho->view_matrix);
+ err_puts("model matrix");
+ gl_matrix_4f_buf_inspect(&g_c3_env.err, &ortho->model_matrix);
+ buf_flush(&g_c3_env.err);
}
void gl_ortho_render_end (s_gl_ortho *ortho)
@@ -149,9 +156,6 @@ void gl_ortho_resize (s_gl_ortho *ortho, f32 x1, f32 x2, f32 y1, f32 y2,
gl_matrix_4f_init_identity(&ortho->projection_matrix);
gl_matrix_4f_ortho(&ortho->projection_matrix, x1, x2, y1, y2,
clip_z_near, clip_z_far);
- err_puts("gl_ortho_resize");
- gl_matrix_4f_buf_inspect(&g_c3_env.err, &ortho->projection_matrix);
- buf_flush(&g_c3_env.err);
}
void gl_ortho_update_model_matrix (s_gl_ortho *ortho)
@@ -161,7 +165,11 @@ void gl_ortho_update_model_matrix (s_gl_ortho *ortho)
glUniformMatrix4fv(ortho->gl_model_matrix_loc, 1, GL_FALSE,
&ortho->model_matrix.xx);
assert(glGetError() == GL_NO_ERROR);
- err_puts("gl_ortho_update_model_matrix");
+ err_puts("gl_ortho_update_model_matrix projection matrix");
+ gl_matrix_4f_buf_inspect(&g_c3_env.err, &ortho->projection_matrix);
+ err_puts("view matrix");
+ gl_matrix_4f_buf_inspect(&g_c3_env.err, &ortho->view_matrix);
+ err_puts("model matrix");
gl_matrix_4f_buf_inspect(&g_c3_env.err, &ortho->model_matrix);
buf_flush(&g_c3_env.err);
}
diff --git a/libc3/window/sdl2/gl_point_3f.c b/libc3/window/sdl2/gl_point_3f.c
index 1cf88c6..03ed4f4 100644
--- a/libc3/window/sdl2/gl_point_3f.c
+++ b/libc3/window/sdl2/gl_point_3f.c
@@ -56,9 +56,9 @@ s_gl_point_3f * gl_point_3f_init_product (s_gl_point_3f *p,
assert(p);
assert(m);
assert(s);
- p->x = m->xx * s->x + m->yx * s->y + m->zx * s->z + m->tx;
- p->y = m->yx * s->x + m->yy * s->y + m->zy * s->z + m->ty;
- p->z = m->zx * s->x + m->yz * s->y + m->zz * s->z + m->tz;
+ p->x = m->xx * s->x + m->xy * s->y + m->xz * s->z + m->xt;
+ p->y = m->xy * s->x + m->yy * s->y + m->yz * s->z + m->yt;
+ p->z = m->xz * s->x + m->zy * s->y + m->zz * s->z + m->zt;
return p;
}
diff --git a/libc3/window/sdl2/types.h b/libc3/window/sdl2/types.h
index ebb592e..58039b3 100644
--- a/libc3/window/sdl2/types.h
+++ b/libc3/window/sdl2/types.h
@@ -109,7 +109,6 @@ struct gl_matrix_3d {
f64 zz;
};
-#pragma pack(push, 1)
struct gl_matrix_3f {
f32 xx;
f32 yx;
@@ -121,7 +120,6 @@ struct gl_matrix_3f {
f32 yz;
f32 zz;
};
-#pragma pack(pop)
struct gl_matrix_4d {
f64 xx;
@@ -142,7 +140,6 @@ struct gl_matrix_4d {
f64 tt;
};
-#pragma pack(push, 1)
struct gl_matrix_4f {
f32 xx;
f32 yx;
@@ -161,7 +158,6 @@ struct gl_matrix_4f {
f32 zt;
f32 tt;
};
-#pragma pack(pop)
struct gl_object {
s_array vertex;
@@ -316,11 +312,13 @@ struct gl_square {
uw segments_v;
};
+#pragma pack(push, 1)
struct gl_vertex {
s_gl_point_3f position;
s_gl_point_3f normal;
s_gl_point_2f tex_coord;
};
+#pragma pack(pop)
struct sdl2_sprite {
s_gl_object object;
diff --git a/libc3/window/sdl2/window_sdl2.c b/libc3/window/sdl2/window_sdl2.c
index 11eb091..3a85157 100644
--- a/libc3/window/sdl2/window_sdl2.c
+++ b/libc3/window/sdl2/window_sdl2.c
@@ -154,8 +154,8 @@ bool window_sdl2_run (s_window_sdl2 *window)
SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 8);
SDL_GL_SetAttribute(SDL_GL_ALPHA_SIZE, 8);
SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 24);
- SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3);
- SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 3);
+ SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 4);
+ SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 1);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK,
SDL_GL_CONTEXT_PROFILE_CORE);
sdl_window = SDL_CreateWindow(window->title,