summaryrefslogtreecommitdiff
path: root/height-map-display
diff options
context:
space:
mode:
Diffstat (limited to 'height-map-display')
-rwxr-xr-xheight-map-display/height-map-displaybin17512 -> 17512 bytes
-rw-r--r--height-map-display/src/main.c55
2 files changed, 34 insertions, 21 deletions
diff --git a/height-map-display/height-map-display b/height-map-display/height-map-display
index b67544a..df41c3d 100755
--- a/height-map-display/height-map-display
+++ b/height-map-display/height-map-display
Binary files differ
diff --git a/height-map-display/src/main.c b/height-map-display/src/main.c
index 5ad5c78..95e6953 100644
--- a/height-map-display/src/main.c
+++ b/height-map-display/src/main.c
@@ -6,16 +6,29 @@
#define MAP_HEIGHT 10
#define MAP_WIDTH 10
+//int height_map[MAP_WIDTH][MAP_HEIGHT] = {
+// {0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+// {0, 1, 1, 1, 1, 1, 1, 1, 1, 0},
+// {0, 1, 3, 3, 3, 3, 3, 3, 1, 0},
+// {0, 1, 3, 5, 5, 5, 5, 3, 1, 0},
+// {0, 1, 3, 5, 8, 8, 5, 3, 1, 0},
+// {0, 1, 3, 5, 8, 8, 5, 3, 1, 0},
+// {0, 1, 3, 5, 5, 5, 5, 3, 1, 0},
+// {0, 1, 3, 3, 3, 3, 3, 3, 1, 0},
+// {0, 1, 1, 1, 1, 1, 1, 1, 1, 0},
+// {0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+//};
+
int height_map[MAP_WIDTH][MAP_HEIGHT] = {
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
- {0, 1, 1, 1, 1, 1, 1, 1, 1, 0},
- {0, 1, 3, 3, 3, 3, 3, 3, 1, 0},
- {0, 1, 3, 5, 5, 5, 5, 3, 1, 0},
- {0, 1, 3, 5, 8, 8, 5, 3, 1, 0},
- {0, 1, 3, 5, 8, 8, 5, 3, 1, 0},
- {0, 1, 3, 5, 5, 5, 5, 3, 1, 0},
- {0, 1, 3, 3, 3, 3, 3, 3, 1, 0},
- {0, 1, 1, 1, 1, 1, 1, 1, 1, 0},
+ {0, 1, 1, 0, 0, 0, 0, 0, 0, 0},
+ {0, 1, 0, 0, 0, 0, -1, -2, 0, 0},
+ {0, 0, 0, 0, 0, 0, 0, -1, 0, 0},
+ {0, 0, 0, 0, 1, 0, 0, 0, 0, 0},
+ {0, 0, 0, 1, 2, 1, 0, 0, 0, 0},
+ {0, 0, 0, 0, 1, 0, 0, 0, 0, 0},
+ {0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+ {0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
};
@@ -49,9 +62,9 @@ float camera_pitch = 0.0f; // rotation aroudn x-axis
void renderHeightMap() {
float colors[3][3] = {
- {0.0f, 1.0f, 0.0f}, // Green
- {0.5f, 0.5f, 0.5f}, // Gray
- {1.0f, 1.0f, 1.0f} // White
+ {0.0f, 1.0f, 0.0f}, // default green
+ {0.0f, 0.0f, 1.0f}, // blue
+ {0.5f, 1.0f, 0.5f} // light green
};
float scale_factor = 1.0f;
@@ -82,8 +95,8 @@ void renderHeightMap() {
float z1 = y;
float* color = colors[0];
- if (y0 < 1.0f) { color = colors[1]; }
- if (y0 < 0.5f) { color = colors[2]; }
+ if (y0 > 0.5f) { color = colors[2]; }
+ if (y0 < -0.5f) { color = colors[1]; }
glColor3fv(color);
glVertex3f(x0, y0, z0);
@@ -124,14 +137,14 @@ void key_callback(GLFWwindow* window, int key, int scancode, int action, int mod
const float camera_speed = 0.5f;
- if (key == GLFW_KEY_W && action == GLFW_PRESS) { camera_pos_z -= camera_speed; }
- else if (key == GLFW_KEY_S && action == GLFW_PRESS) { camera_pos_z += camera_speed; }
- else if (key == GLFW_KEY_A && action == GLFW_PRESS) { camera_pos_x -= camera_speed; }
- else if (key == GLFW_KEY_D && action == GLFW_PRESS) { camera_pos_x += camera_speed; }
- else if (key == GLFW_KEY_Q && action == GLFW_PRESS) { camera_pitch -= camera_speed; }
- else if (key == GLFW_KEY_E && action == GLFW_PRESS) { camera_pitch += camera_speed; }
- else if (key == GLFW_KEY_Z && action == GLFW_PRESS) { camera_yaw -= camera_speed; }
- else if (key == GLFW_KEY_C && action == GLFW_PRESS) { camera_yaw += camera_speed; }
+ if (key == GLFW_KEY_W && (action == GLFW_PRESS || action == GLFW_REPEAT)) { camera_pos_z -= camera_speed; }
+ else if (key == GLFW_KEY_S && (action == GLFW_PRESS || action == GLFW_REPEAT)) { camera_pos_z += camera_speed; }
+ else if (key == GLFW_KEY_A && (action == GLFW_PRESS || action == GLFW_REPEAT)) { camera_pos_x -= camera_speed; }
+ else if (key == GLFW_KEY_D && (action == GLFW_PRESS || action == GLFW_REPEAT)) { camera_pos_x += camera_speed; }
+ else if (key == GLFW_KEY_Q && (action == GLFW_PRESS || action == GLFW_REPEAT)) { camera_pitch -= camera_speed; }
+ else if (key == GLFW_KEY_E && (action == GLFW_PRESS || action == GLFW_REPEAT)) { camera_pitch += camera_speed; }
+ else if (key == GLFW_KEY_Z && (action == GLFW_PRESS || action == GLFW_REPEAT)) { camera_yaw -= camera_speed; }
+ else if (key == GLFW_KEY_C && (action == GLFW_PRESS || action == GLFW_REPEAT)) { camera_yaw += camera_speed; }
}