diff --git a/OpenGL4/HeightMap.cpp b/OpenGL4/HeightMap.cpp index 6d56dfe..f5b0606 100644 --- a/OpenGL4/HeightMap.cpp +++ b/OpenGL4/HeightMap.cpp @@ -6,13 +6,12 @@ #include GLuint imageIndex; +int scale = 50; 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++) { @@ -72,4 +71,9 @@ void HeightMap::Draw() glDisableClientState(GL_TEXTURE_COORD_ARRAY); //glDisableClientState(GL_COLOR_ARRAY); //glDisableClientState(GL_NORMAL_ARRAY); +} + +void HeightMap::GetHeigth(float x, float z) +{ + } \ No newline at end of file diff --git a/OpenGL4/HeightMap.h b/OpenGL4/HeightMap.h index 9b04fb3..f59f378 100644 --- a/OpenGL4/HeightMap.h +++ b/OpenGL4/HeightMap.h @@ -12,6 +12,7 @@ public: ~HeightMap(); void Draw(); + void GetHeigth(float x, float z); struct Vertex { float x; diff --git a/OpenGL4/Main.cpp b/OpenGL4/Main.cpp index fa53e1e..cc14694 100644 --- a/OpenGL4/Main.cpp +++ b/OpenGL4/Main.cpp @@ -34,7 +34,7 @@ struct Vertex }; std::vector cubeVertices; - +float speed = 1000; void drawCube() { @@ -63,7 +63,7 @@ void display() glMatrixMode(GL_PROJECTION); glLoadIdentity(); - gluPerspective(60.0f, (float)width/height, 0.1, 15000); + gluPerspective(60.0f, (float)width/height, 0.1, 100000); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); @@ -123,13 +123,14 @@ void idle() float deltaTime = frameTime - lastFrameTime; lastFrameTime = frameTime; - 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); if (keys['s']) move(270, deltaTime*speed); if (keys['q']) moveVert(1, deltaTime*speed); if (keys['e']) moveVert(-1, deltaTime*speed); + if (keys['+']) speed += 100; + if (keys['-']) speed -= speed <= 100 ? 0 : 100; glutPostRedisplay(); } @@ -186,7 +187,7 @@ int main(int argc, char* argv[]) glutKeyboardUpFunc(keyboardUp); glutPassiveMotionFunc(mousePassiveMotion); - heightmap = new HeightMap("worlds/HMCSHeightmap.gif"); + heightmap = new HeightMap("worlds/alps.png"); 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 }); diff --git a/OpenGL4/worlds/alps.png b/OpenGL4/worlds/alps.png new file mode 100644 index 0000000..bc8e990 Binary files /dev/null and b/OpenGL4/worlds/alps.png differ diff --git a/OpenGL4/worlds/awesome.png b/OpenGL4/worlds/awesome.png new file mode 100644 index 0000000..7dd3c74 Binary files /dev/null and b/OpenGL4/worlds/awesome.png differ