More heightmaps

This commit is contained in:
2016-05-24 09:58:28 +02:00
parent 28d5c06c7f
commit 8c9b39983b
5 changed files with 12 additions and 6 deletions
+6 -2
View File
@@ -6,13 +6,12 @@
#include <string>
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)
{
}
+1
View File
@@ -12,6 +12,7 @@ public:
~HeightMap();
void Draw();
void GetHeigth(float x, float z);
struct Vertex {
float x;
+5 -4
View File
@@ -34,7 +34,7 @@ struct Vertex
};
std::vector<Vertex> 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 });
Binary file not shown.

After

Width:  |  Height:  |  Size: 227 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 202 KiB