Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Running_Wolf

Terragin from TGA Problems

This topic is 6277 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

This is really depressing. I got the TGA to work in my last thread. But now I can''t get the terrain to show. Here is my spot in my main program where I render it: glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glLoadIdentity(); glTranslatef(xmove, ymove, zmove); terrain1.Render(); and here is what terrain1.Render() does: Terrain::Render() { unsigned int loop = 0; glBegin(GL_TRIANGLE_STRIP); for(loop = 0; loop < texture.height; loop++) { glColor3f(array[loop].red, array[loop].green, array[loop].blue); glVertex3f(array[loop].x, array[loop].y, array[loop].z); glColor3f(array[loop+1].red, array[loop+1].green, array[loop+1].blue); glVertex3f(array[loop+1].x, array[loop+1].y, array[loop+1].z); } glEnd(); } What am I doing wrong!!!

Share this post


Link to post
Share on other sites
Advertisement
I suggest you create the terrain from points first and see that all is in order (that is, if the points show up and arrange in the way you''d expect).

Share this post


Link to post
Share on other sites
I tried using points. I still can''t see anything. I know it is doing something because my framerate drops considerably but I don''t see anything on the screen. What do I need to do?

Share this post


Link to post
Share on other sites
I got it to show itself...but there is something else wrong.

http://gen.gserver.com/running_wolf/teragine/screenshots/shot3.jpg

The red points is the terrain. The image in the upper left is the TGA it is based on. I''m mixing something up and as you can see it is twisting and distorting the image.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
1) It looks like you might be outputing degenerate triangles. Try stepping though with your debugger and plotting the first couple of points on graph paper to verify that you are really generating valid strips (Doesn''t look like it to me)

2) Try using a simpler terrain file... like a real simple greyscale gradient.

Share this post


Link to post
Share on other sites
Okay, I got it to place correctly. But now I have another problem. I can only see it when I use GL_POINTS or GL_LINES. GL_TRIANGLES or GL_TRIANGLE_STRIP don''t work.

Here is the rendering function from my Terrain class:
Terrain::Render()
{
unsigned int x = 0, y = 0;

glBindTexture(GL_TEXTURE_2D, texture.ID);
glBegin(GL_TRIANGLE_STRIP);
for (y = 0; y < heightmap.height; y++) {
for (x = 0; x < heightmap.width; x++) {
glTexCoord2f(0.0f, 0.0f);
glColor4f(array[x].red, array[x].green, array[x].blue, 1.0f);
glVertex3f(array[x].x, array[x].y, array[x].z);

glTexCoord2f(1.0f, 1.0f);
glColor4f(array[x+1].red, array[x+1].green, array[x+1].blue, 1.0f);
glVertex3f(array[x+1].x, array[x+1].y, array[x+1].z);
}
}
glEnd();
}

and here is where I call it in my main program...GL_TEXTURE_2D is enabled.

glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity();
glTranslatef(xmove, ymove, zmove);
glRotatef(rotate, 1.0, 0.0, 0.0);

terrain1.Render();

What am I doing wrong now?

Share this post


Link to post
Share on other sites
Everything works now except for the colors. It displays properly textured. But I want to add a colored mask over the texture. To say give it a reddish hue or something.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!