Code:
float width=50;
float height=60;
float length=3000;
float termvel=100;
main.Texture2D(true);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
if(main.keys['1'])
main.Mode(GL_FRONT,GL_FILL);
if(main.keys['2'])
main.Mode(GL_FRONT,GL_LINE);
if(main.keys['3'])
main.Mode(GL_FRONT,GL_POINT);
glLoadIdentity();
Camera();
if(up)
hover+=0.01f;
else
hover-=0.01f;
if(hover>1)
up=false;
if(hover<-1)
up=true;
glTranslatef(xpos,25.0f+hover,zpos);
glRotatef(180,0.0f,1.0f,0.0f);
if(main.keys[VK_LEFT])
{
crot=-20.0f;
xvel-=0.03f;
}
else if(main.keys[VK_RIGHT])
{
crot=20.0f;
xvel+=0.03f;
}
else
{
crot=0.0f;
if(xvel<0.02f && xvel>-0.02f)
xvel=0.0f;
}
if(main.keys[VK_UP])
{
speed+=0.02f;
cxrot=-10.0f;
}
else if(main.keys[VK_DOWN])
{
speed-=0.02f;
cxrot=10.0f;
}
else
{
cxrot=0.0f;
if(speed<0.2f && speed>-0.2f)
speed=0.0f;
}
if(crot>rot)
rot+=0.5f;
if(crot<rot)
rot-=0.5f;
if(cxrot>xrot)
xrot+=0.5f;
if(cxrot<xrot)
xrot-=0.5f;
if(xvel>3)
xvel=3;
if(xvel<-3)
xvel=-3;
if(speed>termvel)
speed=termvel;
if(speed<-termvel)
speed=-termvel;
if(speed>0)
speed-=0.01f;
if(speed<0)
speed+=0.01f;
if(xvel>0)
xvel-=0.005f;
if(xvel<0)
xvel+=0.005f;
if(xpos>width/2*10-30)
{
xpos=width/2*10-30;
xvel=-xvel/3;
}
if(xpos<-width/2*10+30)
{
xpos=-width/2*10+30;
xvel=-xvel/3;
}
if(main.keys['C'] && !main.lkeys['C'])
view++;
if(view>=NUMCAM)
view=0;
zpos-=speed;
xpos+=xvel;
glRotatef(-xrot,1.0f,0.0f,0.0f);
glRotatef(rot,0.0f,0.0f,1.0f);
ship->draw();
main.glPrint(0,32,0,"Speed %f",speed);
glLoadIdentity();
Camera();
glTranslatef(-10*width/2,0.0f,-40.0f);
glBindTexture(GL_TEXTURE_2D, main.texture[0]);
float zposf=0.0f;
for(int b=0;b<length;b++)
{
zposf-=height;
if(zposf<zpos+230 && zposf>zpos-3000)
{
glBegin(GL_QUADS);
glTexCoord2d(0,1);glVertex3f(0.0f, 30.0f,height);
glTexCoord2d(1,1);glVertex3f(0.0f, 0.0f,height);
glTexCoord2d(1,0);glVertex3f(0.0f, 0.0f,0.0f);
glTexCoord2d(0,0);glVertex3f(0.0f, 30.0f,0.0f);
for(int a=0;a<10;a++)
{
glTexCoord2d(0,1);glVertex3f(a*width,0.0f,height);
glTexCoord2d(1,1);glVertex3f((a+1)*width,0.0f,height);
glTexCoord2d(1,0);glVertex3f((a+1)*width,0.0f,0.0f);
glTexCoord2d(0,0);glVertex3f(a*width,0.0f,0.0f);
}
glTexCoord2d(0,1);glVertex3f(10*width, 30.0f,0.0f);
glTexCoord2d(1,1);glVertex3f(10*width, 0.0f,0.0f);
glTexCoord2d(1,0);glVertex3f(10*width, 0.0f,height);
glTexCoord2d(0,0);glVertex3f(10*width, 30.0f,height);
glEnd();
}
glTranslatef(0.0f,0.0f,-height);
}
main.glPrint(0,16,0,"%f::%f",zposf,zpos);
main.UpdateKeys();
now, I'm pretty sure nobody here's gonna be able to rip that code off, lmao....
ok, about the main.* stuff, that's for an opengl header file i made that can do a lot of stuff......but anyways
thing is, this is the code i'm using for my racing game, and well, it looks perfectly fine to me......the problem is, as I'm driving on the course, once i reach about -40000, the track starts dissapearing, and the car starts sinking below it for some odd reason.....
i know it's not anything in my header file, because all the header file is used for is creating windows, drawing text, etc etc....i think there might be something wrong with just the way that i'm using opengl,,,,,but i have no idea....
hopin' someone here has had this happen to them before, and they can help (AND NO STUPID POSTS SAYING, "oooh, just look at google, google is the god, we must all follow google, praise google", I'm looking for someone here who actually KNOWS, cuz i've already looked on Google ) You guys are my last resort......
-edit oh yeah, here's the camera code-
Code:
void Camera()
{
switch(view)
{
case 0:
gluLookAt(xpos,60.0f,zpos+200, //back view raised
xpos,25.0f,zpos,
0,1,0);
break;
case 1:
gluLookAt(xpos,25.0f+hover,zpos+1, //cockpit
xpos,25.0f+hover+sin(xrot*PI180),zpos,
sin(rot*PI180),cos(rot*PI180),0);
break;
case 2:
glTranslatef(-xpos,-35.0f,-zpos-95); //back view
break;
case 3:
gluLookAt(xpos,60.0f,zpos+400,
xpos,25.0f,zpos,
0,1,0);
break;
}
}