From 28d5c06c7f4c3f2c0c6fc2790560681be5a39ca0 Mon Sep 17 00:00:00 2001 From: Kenneth van Ewijk Date: Mon, 23 May 2016 20:50:30 +0200 Subject: [PATCH] Increase scale to massive --- OpenGL4/HeightMap.cpp | 4 +++- OpenGL4/Main.cpp | 6 +++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/OpenGL4/HeightMap.cpp b/OpenGL4/HeightMap.cpp index d2bcb7c..6d56dfe 100644 --- a/OpenGL4/HeightMap.cpp +++ b/OpenGL4/HeightMap.cpp @@ -12,6 +12,8 @@ HeightMap::HeightMap(const std::string &file) int bpp; unsigned char* imgData = stbi_load(file.c_str(), &width, &height, &bpp, 4); + int scale = 50; + for (int h = 0; h < height; h++) { for (int w = 0; w < width; w++) @@ -22,7 +24,7 @@ HeightMap::HeightMap(const std::string &file) float y = ((float)imgData[((h + offsets[i][0]) + (w + offsets[i][1]) * width) * 4]); y = (y / 256.0f) * 100.0f; - vertices.push_back(Vertex{ (float)(h + offsets[i][0]), y, (float)(w + offsets[i][1]), + vertices.push_back(Vertex{ (float)(h + offsets[i][0])*scale, y*scale, (float)(w + offsets[i][1])*scale, 0, 1, 0, (h + offsets[i][0]) / (float)height, (w + offsets[i][1]) / (float)width } ); } diff --git a/OpenGL4/Main.cpp b/OpenGL4/Main.cpp index 33881c8..fa53e1e 100644 --- a/OpenGL4/Main.cpp +++ b/OpenGL4/Main.cpp @@ -63,7 +63,7 @@ void display() glMatrixMode(GL_PROJECTION); glLoadIdentity(); - gluPerspective(60.0f, (float)width/height, 0.1, 5000); + gluPerspective(60.0f, (float)width/height, 0.1, 15000); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); @@ -123,7 +123,7 @@ void idle() float deltaTime = frameTime - lastFrameTime; lastFrameTime = frameTime; - const float speed = 50; + const float speed = 500; if (keys['a']) move(0, deltaTime*speed); if (keys['d']) move(180, deltaTime*speed); if (keys['w']) move(90, deltaTime*speed); @@ -186,7 +186,7 @@ int main(int argc, char* argv[]) glutKeyboardUpFunc(keyboardUp); glutPassiveMotionFunc(mousePassiveMotion); - heightmap = new HeightMap("worlds/hell.png"); + heightmap = new HeightMap("worlds/HMCSHeightmap.gif"); cubeVertices.push_back(Vertex{ -1, -1, -1, 0,0,1, 1,1,1,1 }); cubeVertices.push_back(Vertex{ -1, 1, -1, 0,0,1, 1,1,1,1 });