- GLint HeightMap::mapWidth,HeightMap::mapHeight;
- GLubyte *HeightMap::yValueBuffer;
- GLfloat *HeightMap::hmVertexBuffer;
- unsigned int *HeightMap::hmIndices;
- void HeightMap::getRedFromMipMap(int mipMapLevel)
- {
- GLint textureWidth, textureHeight;
- glBindTexture(GL_TEXTURE_2D,textureName[0]);
- glGetTexLevelParameteriv(GL_TEXTURE_2D, mipMapLevel, GL_TEXTURE_WIDTH, &textureWidth);
- glGetTexLevelParameteriv(GL_TEXTURE_2D, mipMapLevel, GL_TEXTURE_HEIGHT, &textureHeight);
- mapWidth=textureWidth;
- mapHeight=textureHeight;
- yValueBuffer= (GLubyte *)malloc(textureWidth*textureHeight*4);
- glGetTexImage(GL_TEXTURE_2D, mipMapLevel, GL_BGRA, GL_UNSIGNED_BYTE, yValueBuffer);
- }
- void HeightMap::doHeightMapStuff()
- {
- glBindTexture(GL_TEXTURE_2D,textureName[0]);
- getRedFromMipMap(0);
- hmVertexBuffer=(GLfloat *)malloc(mapWidth*mapHeight*3);
- for(int y = 0; y < mapHeight; y++)
- for(int x = 0; x < mapWidth; x++)
- {
- GLint startAdressOfVertex=((y*mapWidth) + x);
- // hmVertexBuffer[startAdressOfVertex]=(float)x;
- // hmVertexBuffer[startAdressOfVertex+1]=(float)yValueBuffer[((y*mapWidth) + x)*4];
- // hmVertexBuffer[startAdressOfVertex+2]=(float)y;
- }
- }