From 85c7bc8cb59463e119f8db8d77b0117f18565533 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Steffen=20F=C3=BCndgens?= Date: Fri, 7 Nov 2014 14:06:40 +0100 Subject: [PATCH] changed VertexArrayObject to SharedVertexArrayObject + Bugfixes --- terrain.cc | 24 ++++++++++++------------ terrain.hh | 4 +--- 2 files changed, 13 insertions(+), 15 deletions(-) diff --git a/terrain.cc b/terrain.cc index cf811c4..b9216c1 100644 --- a/terrain.cc +++ b/terrain.cc @@ -1,8 +1,8 @@ #include "terrain.hh" -//Terrain::Terrain(std::string filePath){ -// this->filePath = filePath; -//} +Terrain::Terrain(std::string filePath){ + this->filePath = filePath; +} Terrain::Terrain(){ } @@ -12,17 +12,18 @@ Terrain::~Terrain() { void Terrain::load() { - std::ifstream terrain_png(this->filePath + "/heightmap.png"); //TODO: filepath organization + std::ifstream terrain_png(this->filePath + "/heightmap.png"); //TODO: filepath organization unsigned int rowNum, columnNum, heightmapValue; - terrain_png.seekg(16); //skip part of the header - terrain_png.read((char *)&this->heightmapWidth, 4); //read width - terrain_png.read((char *)&this->heightmapHeight, 4); //read height - this->heightmapWidth = ntohl(this->heightmapWidth); //convert from host to network byte order - this->heightmapHeight = ntohl(this->heightmapHeight); + terrain_png.seekg(16); //skip part of the header + char temp[2]; + terrain_png.read(temp, 4); //read width + this->heightmapWidth = (temp[1]<<0) | (temp[0]<<8); //convert from network to host byte order + terrain_png.read(temp, 4); //read height + this->heightmapHeight = (temp[1]<<0) | (temp[0]<<8); //convert from network to host byte order - heightmap = new float*[this->heightmapHeight]; //initialize the heightmap - for(rowNum = 0; rowNum < this->heightmapHeight; rowNum++){ //read in the heightmap + heightmap = new float*[this->heightmapHeight]; //initialize the heightmap + for(rowNum = 0; rowNum < this->heightmapHeight; rowNum++){ //read in the heightmap heightmap[rowNum] = new float[this->heightmapWidth]; for(columnNum = 0; columnNum < this->heightmapWidth; columnNum++){ terrain_png.read((char *)&heightmapValue, 1); @@ -80,7 +81,6 @@ void Terrain::makeTriangleMesh(){ this->triangleMesh->bind(); this->triangleMesh->setMode(GL_TRIANGLE_STRIP); this->triangleMesh->attachAllAttributes(arrayBuffer); - //TODO unbind? } void Terrain::render() { diff --git a/terrain.hh b/terrain.hh index da831e5..cf91a12 100644 --- a/terrain.hh +++ b/terrain.hh @@ -4,9 +4,7 @@ #include #include "texture.hh" #include -//#include //on Windows -#include //on Unix -#include +#include "extern/bullet/src/BulletDynamics/Dynamics/btRigidBody.h" class Terrain { public: