commit 6559cff442f3750fc20990d9f5bfe6003a926baa
parent 47be43a13b1bfbb5bfb25fe77ea34b9f77ad210a
Author: William Casarin <jb55@jb55.com>
Date: Tue, 24 Apr 2018 09:24:01 -0700
WIP
Diffstat:
6 files changed, 15 insertions(+), 8 deletions(-)
diff --git a/src/game.c b/src/game.c
@@ -3,10 +3,10 @@
#include "game.h"
mat4 *cam_init = (float[16]){
- 1.000000, 0.000000, 0.000000, 0.000000,
- 0.000000, 0.674875, -0.737931, 0.000000,
- 0.000000, 0.737931, 0.674875, 0.000000,
- -0.100000,-0.131862, -6.496247, 1.000000
+ 1, 0, 0, 0,
+ 0, 0.67, -0.74, 0,
+ 0, 0.74, 0.66, 0,
+ -0.1, -0.6, -3.0, 1
};
void game_init(struct game *game) {
diff --git a/src/main.c b/src/main.c
@@ -22,12 +22,12 @@ int main(void)
struct terrain terrain;
size_t length;
- void *slab_buffer;
SDL_Window *window = SDL_CreateWindow(
"SDL2/OpenGL Demo", 0, 0, 640, 480,
SDL_WINDOW_OPENGL|SDL_WINDOW_RESIZABLE);
+ srand(42);
SDL_GL_CreateContext(window);
init_gl(&game.test_resources);
diff --git a/src/render.c b/src/render.c
@@ -98,7 +98,7 @@ init_gl(struct resources *resources) {
assert(resources->fragment_shader != 0);
// camera
- mat4_perspective(50 /* fov */, 1080 / 720, 1, 1000, resources->camera_persp);
+ mat4_perspective(90 /* fov */, 1080 / 720, 1, 1000, resources->camera_persp);
// Shader program
resources->program = make_program(resources->vertex_shader,
diff --git a/src/terrain.c b/src/terrain.c
@@ -1,6 +1,5 @@
#include "terrain.h"
-
#include "util.h"
static const float plane_verts[] = {
@@ -40,3 +39,7 @@ terrain_detroy(struct terrain *terrain) {
free(terrain->geom.normals);
}
+
+float old_noisy_boi(float x, float y) {
+ return sinf(x) * cosf(y);
+}
diff --git a/src/util.c b/src/util.c
@@ -1,5 +1,6 @@
#include "util.h"
+#include <stdlib.h>
void check_gl() {
unsigned int e = glGetError();
@@ -10,6 +11,9 @@ void check_gl() {
}
+float rand_0to1() {
+ return (float) rand() / RAND_MAX;
+}
/* void glhLookAtf2( float *matrix, float *eyePosition3D, */
/* float *center3D, float *upVector3D ) */
diff --git a/src/util.h b/src/util.h
@@ -9,6 +9,6 @@
void check_gl(void);
-
+float rand_0to1();
#endif /* PA_UTIL_H */