1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
|
void HeightMap::loadHeightMap(void)
{
unsigned int x;
unsigned int z;
unsigned int k;
x = 0;
k = 0;
this->_vertexArray = new float[static_cast<unsigned int>((this->_lenX * this->_lenY * this->getAccuracy()) * 6)];
this->_glList = glGenLists(1);
glNewList(this->_glList, GL_COMPILE);
{
glEnable(GL_CULL_FACE);
glCullFace(GL_BACK);
glBegin(GL_TRIANGLES);
while (x < (this->_lenX - this->getAccuracy()))
{
z = 0;
while (z < (this->_lenY - this->getAccuracy()))
{
Vector3f vertex1(x, this->getPixel(x, z), z);
Vector3f vertex2(x + this->getAccuracy(), this->getPixel(x + this->getAccuracy(), z), z);
Vector3f vertex3(x + this->getAccuracy(), this->getPixel(x + this->getAccuracy(), z + this->getAccuracy()), z + this->getAccuracy());
Vector3f vertex4(x, this->getPixel(x, z + this->getAccuracy()), z + this->getAccuracy());
vertex3.sendWithText();
vertex2.sendWithText();
vertex1.sendWithText();
vertex4.sendWithText();
vertex3.sendWithText();
vertex1.sendWithText();
k += 18;
z += this->getAccuracy();
}
x += this->getAccuracy();
}
glEnd();
glDisable(GL_CULL_FACE);
}
glEndList();
} |
Partager