Hi, I have a program that loads in a heightmap data from a text file. The problem i have is i don't really have a clue what do do with it.

I have to call glTexImage2D to set up the text, how would i use that? Oh and the data from the heightmap text file is stored in a floating point array.

Any tutorials or help os very welcome and much appreciate.

My OpenGL isn't very good to be honest.

Thanks in advanced.

Recommended Answers

All 10 Replies

Well what do you intend to use the heightmap for? One use for them is to create a terrain based on the heightmap. For example, you would use the heightmap values to map the height of the plane at a given point.

Well its not really being used for anything. I need to just display the heightmap. Nothing special, just to use it really.

What do you mean you want to display the heightmap? I am assuming your "heightmap" is a file with bunch of numbers? How would you display that? Do you mean to print it?

Yeah its a text file with a bunch of numbers in it. See this is the problem i have, is i that my understand isn't to good.

The overall this i have to do is render a 3D surface using a heightmap. Is that a little better?

Thanks for the interest!

So first you need to be able to render a flat 3D surface, and for each point in the surface, you will use the heightmap as the heightvalue for that point.

Yeah thats the one. any ideas?

But to change the points to work with the heightmap i have to write a shader. But for no if i can get it working without the shader i'll be happy!

Thanks.

You don't need shaders. All you need to do is something like this :

for( int x = 0; x < MAP_WIDTH; ++x){
  for(int z = 0; z < MAX_HEIGHT; ++z){
    surface[x][y].setHeight( heightMap.getHeight(x,z) );
 }
}

Thats the problem, i just done the render function, but now i have to use a vertex shader to change the positions according to the heightmap.

you shouldn't have to use shaders for this. Setting height is just a numerical thing. Rendering it is different. You can render it with or without shaders

If you have to use a shader to manipulate the vertex data from a flat plane, the easiest way would be to load the height map into a texture, and extract the height value in the vertex shader using a call the texture2D.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.