Jump to content
  • Advertisement
Sign in to follow this  

my current terrain work (need a little help)

This topic is 4196 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

Hey, I'm working on some terrain and am having trouble. I have some stuff that looks like terrain but will constantly redraw as different terrain. It's hard to explain so here's some code: ints:
bool	keys[256];								// Array Used For The Keyboard Routine
bool	active=TRUE;								// Window Active Flag Set To TRUE By Default
bool	fullscreen=TRUE;							// Fullscreen Flag Set To Fullscreen Mode By Default
double   az = 0.25;
double   ax = 0.0;
float   ay = rand()%5;
double   bz = .25;
double   bx = 2.0;
float   by = rand()%5;
double   cz = 0.0;
double   cx = 2.0;
float   cy = rand()%5;
double   dz = 0.0;
double   dx = 0.0;
float   dy = rand()%5;
double xwidth = 2.0;
double zwidth = 2.0;
int    xdrawn = 0;
bool goon = false;
GLfloat	xrot;				// X Rotation
GLfloat	yrot;				// Y Rotation
GLfloat xspeed;				// X Rotation Speed
GLfloat yspeed;				// Y Rotation Speed

I used the double int because i got warnings saying converting from int to double so I figured it's best to fix warnings. rendering:
int DrawGLScene(GLvoid)							
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);				glLoadIdentity();							// Reset The Current Modelview Matrix
    glTranslatef(0.0f,0.0f,-8.0f);					glRotatef(yrot,0.0f,1.0f,0.0f);
    glVertex3f(ax, ay, az);
    glVertex3f(bx, by, bz);
    glVertex3f(cx, cy, cz);
    glVertex3f(dx, dy, dz);
    ay = by;
    dy = cy;
    by = rand()%5;
    cy = rand()%5;	
	return TRUE;							// Keep Going

and input handling:
					SwapBuffers(hDC);			// Swap Buffers (Double Buffering)
				if (keys[VK_UP])
				if (keys[VK_DOWN])
				if (keys[VK_RIGHT])
				if (keys[VK_LEFT])

I came up with the idea for it one night as I started falling asleep and wrote it down. It just makes some random starting values for 4 points, than draws it, translates over, makes the new left points the same as the old rights, and makes the rights random and does that until the max width is the same as the amount drawn. please help me out. If you want some more description, I'll get out the notepad I wrote it on. Thanks in advance. [Edited by - brandonman on May 20, 2007 1:13:40 PM]

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • 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!