commit 2f22b32f05071778a734e97087590d555546bb40
parent 21508f95652d60b0647d707007a28f05f4b93905
Author: William Casarin <jb55@jb55.com>
Date: Wed, 3 Nov 2021 20:49:19 -0700
grid ortho aspect
Diffstat:
2 files changed, 11 insertions(+), 7 deletions(-)
diff --git a/etc/shaders/rogue/main.f.glsl b/etc/shaders/rogue/main.f.glsl
@@ -10,10 +10,8 @@ in shader_data {
void main() {
- vec4 v4_pos = vec4(vertex.position, 1.0);
+ //vec4 v4_pos = vec4(vertex.position, 1.0);
- vec3 color = v4_pos.xyz;
-
- frag_color = vec4(color, 1.0);
+ frag_color = gl_FragCoord / 1024.0;
}
diff --git a/rogue/rogue.c b/rogue/rogue.c
@@ -55,7 +55,7 @@ static int compile_shaders(struct gpu *gpu)
static int init_grid(struct grid *grid)
{
- make_grid_geom(&grid->geom, 32, 32, 1.0);
+ make_grid_geom(&grid->geom, 32.0, 32.0, 1.0);
return 1;
}
@@ -97,7 +97,7 @@ static void render(struct engine *engine, struct rogue_game *game, struct render
glEnable(GL_DEPTH_TEST);
- glClearColor( 0.25, 0.25, 0.25, 1.0 ); //clear background screen to black
+ glClearColor( 40.0/255.0, 44.0/255.0, 52.0/255.0, 1.0 ); //clear background screen to black
/* glClearColor( 0.5294f * adjust, 0.8078f * adjust, 0.9216f * adjust, 1.0f ); //clear background screen to black */
glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
@@ -125,9 +125,15 @@ static void render(struct engine *engine, struct rogue_game *game, struct render
mat4_copy(projection, cvars->mvp);
+ float aspect = (float)engine->width / (float)engine->height;
+
+ float h = 0.03124; // 32.0 / 1024.0
+ float w = h / aspect;
+
mat4_translate(cvars->mvp, V3(-0.5, -0.5, 0.0), cvars->mvp);
- mat4_scale(cvars->mvp, V3(32.0/1024.0, 32.0/1024.0, 0.0), cvars->mvp);
+ mat4_scale(cvars->mvp, V3(w, h, 1.0), cvars->mvp);
+ glLineWidth(1.0);
glPolygonMode( GL_FRONT_AND_BACK, GL_LINE );
render_grid(&game->grid, &engine->gpu, cvars);