121 float curseglen = 0.0;
128 while (curseglen < seg->
length) {
129 float cs = cos(phi), ss = sin(phi);
131 float lx, ly, rx, ry;
154 }
while (seg != first);
160 while (texturesize <= maxtexturesize) {
166 int maxOpenGLtexturesize;
167 glGetIntegerv(GL_MAX_TEXTURE_SIZE, &maxOpenGLtexturesize);
168 if (texturesize > maxOpenGLtexturesize) {
169 texturesize = maxOpenGLtexturesize;
178 linewidth = linewidth*(texturesize/512.0);
208 glClearColor(0.0, 0.0, 0.0, 0.0);
209 glClear(GL_COLOR_BUFFER_BIT);
213 glMatrixMode(GL_MODELVIEW);
217 glMatrixMode(GL_PROJECTION);
220 glMatrixMode(GL_MODELVIEW);
225 float halflinewidth = linewidth/2.0;
226 bool firstvert =
true;
227 float xf1, yf1 , xf2, yf2;
228 xf1 = yf1 = xf2 = yf2 = 0.0;
229 glBegin(GL_QUAD_STRIP);
243 float length = sqrt(xn*xn+yn*yn);
248 float x1 = (xm - xn*halflinewidth);
249 float y1 = (ym - yn*halflinewidth);
250 float x2 = (xm + xn*halflinewidth);
251 float y2 = (ym + yn*halflinewidth);
264 float curseglen = 0.0;
273 while (curseglen < seg->
length) {
274 float cs = cos(phi), ss = sin(phi);
275 float x = mx * cs - my * ss - xc * cs + yc * ss + xc;
276 float y = mx * ss + my * cs - xc * ss - yc * cs + yc;
280 float length = sqrt(xn*xn+yn*yn);
287 float x1 = (x + xn*halflinewidth);
288 float y1 = (
y + yn*halflinewidth);
289 float x2 = (x - xn*halflinewidth);
290 float y2 = (
y - yn*halflinewidth);
319 }
while (seg != first);
322 glVertex2f(xf1, yf1);
323 glVertex2f(xf2, yf2);
332 GLuint *trackImage = (GLuint*) malloc(texturesize*texturesize*
sizeof(GLuint));
333 glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
334 glPixelStorei(GL_PACK_ALIGNMENT, 1);
335 glReadBuffer(GL_BACK);
336 glReadPixels(0, 0, texturesize, texturesize, GL_RGBA, GL_BYTE, trackImage);
341 if (glutGet(GLUT_WINDOW_ALPHA_SIZE) == 0) {
345 GLuint clearcolor = trackImage[0];
347 for (i = 0; i < texturesize*texturesize; i++) {
348 if (trackImage[i] == clearcolor) {
358 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
359 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
360 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
361 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
370 glHint(GL_TEXTURE_COMPRESSION_HINT_ARB, GL_NICEST);
371 gluBuild2DMipmaps(GL_TEXTURE_2D, GL_COMPRESSED_RGBA_ARB, texturesize, texturesize, GL_RGBA, GL_BYTE, trackImage);
383 gluBuild2DMipmaps(GL_TEXTURE_2D, GL_RGBA, texturesize, texturesize, GL_RGBA, GL_BYTE, trackImage);
400 glNewList(
cardot, GL_COMPILE);
401 glBegin(GL_TRIANGLE_FAN);
403 glVertex2f(0.0, 0.0);
406 const int borderpoints = 8;
407 halflinewidth = halflinewidth*float(
map_size)/float(texturesize);
408 for (i = 0; i < borderpoints + 1; i++) {
409 float phi = 2.0*
PI*float(i)/float(borderpoints);
410 glVertex2f(halflinewidth*cos(phi), halflinewidth*sin(phi));
417 glClear(GL_COLOR_BUFFER_BIT);
466 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
467 glEnable(GL_TEXTURE_2D);
468 glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
495 glTexCoord2f(0.0, 0.0); glVertex2f(x,
y);
496 glTexCoord2f(1.0, 0.0); glVertex2f(x +
map_size,
y);
498 glTexCoord2f(0.0, 1.0); glVertex2f(x,
y +
map_size);
513 float x1, y1, x2, y2;
515 float radius =
MIN(500.0, tracksize/2.0);
516 x1 = (currentCar->_pos_X - radius -
track_min_x)/tracksize;
517 y1 = (currentCar->_pos_Y - radius -
track_min_y)/tracksize;
518 x2 = (currentCar->_pos_X + radius -
track_min_x)/tracksize;
519 y2 = (currentCar->_pos_Y + radius -
track_min_y)/tracksize;
525 glTexCoord2f(x1, y1); glVertex2f(x,
y);
526 glTexCoord2f(x2, y1); glVertex2f(x +
map_size,
y);
528 glTexCoord2f(x1, y2); glVertex2f(x,
y +
map_size);
533 glDisable(GL_TEXTURE_2D);
537 for (i = 0; i < s->_ncars; i++) {
538 if ((s->
cars[i] != currentCar) &&
539 !(s->
cars[i]->_state &
547 float xc = s->
cars[i]->_pos_X - currentCar->_pos_X;
548 float yc = s->
cars[i]->_pos_Y - currentCar->_pos_Y;
549 if (fabs(xc) < radius && fabs(yc) < radius) {
555 float factor = tracksize/(2.0*radius);
556 glScalef(factor, factor, 1.0);
566 glMatrixMode(GL_MODELVIEW);
569 float factor = tracksize/(2.0*radius);
570 glScalef(factor, factor, 1.0);
588 float radius =
MIN(500.0, tracksize/2.0);
592 glMatrixMode(GL_TEXTURE);
600 glRotatef(currentCar->_yaw*360.0/(2.0*
PI) - 90.0, 0.0, 0.0, 1.0);
601 float factor = (2.0*radius)/tracksize;
602 glScalef(factor, factor, 1.0);
603 glTranslatef(-0.5, -0.5, 0.0);
606 glTexCoord2f(0.0, 0.0); glVertex2f(x,
y);
607 glTexCoord2f(1.0, 0.0); glVertex2f(x +
map_size,
y);
609 glTexCoord2f(0.0, 1.0); glVertex2f(x,
y +
map_size);
613 glMatrixMode(GL_MODELVIEW);
617 glDisable(GL_TEXTURE_2D);
621 for (i = 0; i < s->_ncars; i++) {
628 float xc = (s->
cars[i]->_pos_X - currentCar->_pos_X)/(radius*2.0)*
map_size;
629 float yc = (s->
cars[i]->_pos_Y - currentCar->_pos_Y)/(radius*2.0)*
map_size;
630 float ss = sin(-currentCar->_yaw +
PI/2.0);
631 float cs = cos(-currentCar->_yaw +
PI/2.0);
632 float xrc = xc * cs - yc * ss;
633 float yrc = xc * ss + yc * cs;
638 float factor = tracksize/(2.0*radius);
639 glScalef(factor, factor, 1.0);
649 glMatrixMode(GL_MODELVIEW);
652 glScalef(1.0/factor, 1.0/factor, 1.0);
667 glDisable(GL_TEXTURE_2D);
671 glMatrixMode(GL_MODELVIEW);
673 glTranslatef(car_x, car_y, 0.0);
684 for (i = 0; i < s->_ncars; i++) {
685 if ((s->
cars[i] != currentCar) &&
686 !(s->
cars[i]->_state &
702 if (value < currentmin) {
712 if (value > currentmax) {
#define RM_CAR_STATE_DNF
Car did not finish.
static float track_x_ratio
#define TR_SR
Start-Right corner.
static const float RESOLUTION
int type
Geometrical type:
t3Dd center
Center of the curve.
cars situation used to inform the GUI and the drivers
tCarElt ** cars
list of cars
static GLfloat aheadCarColor[4]
#define TR_SL
Start-Left corner.
#define TRACK_MAP_PAN_ALIGNED
#define RM_CAR_STATE_PULLSIDE
Car pulled out in the air.
void checkAndSetMaximum(float ¤tmax, float &value)
void drawTrackPanningAligned(int Winx, int Winy, int Winw, int Winh, tCarElt *currentCar, tSituation *s)
void display(tCarElt *currentCar, tSituation *situation, int Winx, int Winy, int Winw, int Winh)
The Gaming Framework API (client part).
bool isCompressARBAvailable(void)
#define RM_CAR_STATE_PULLDN
Car pulled out in the air.
void drawTrackPanning(int Winx, int Winy, int Winw, int Winh, tCarElt *currentCar, tSituation *situation)
static GLfloat currentCarColor[4]
#define TRACK_MAP_NORMAL_WITH_OPPONENTS
static const float MINLINEWIDTH
static float track_y_ratio
#define TR_LFT
Left curve.
Scalar length(const Quaternion &q)
static GLfloat behindCarColor[4]
tdble radius
Radius in meters of the middle of the track (>0)
t3Dd vertex[4]
Coordinates of the 4 corners of the segment.
#define TRACK_MAP_PAN_WITH_OPPONENTS
Track segment (tTrackSeg) The segments can be straights (type TR_STR): (the track goes from the right...
int track(tModInfo *modInfo)
void drawCars(tCarElt *currentCar, tSituation *s, int x, int y)
struct trackSeg * next
Next segment.
void checkAndSetMinimum(float ¤tmin, float &value)
void drawCar(tCarElt *currentCar, GLfloat *color, int x, int y)
void drawTrackNormal(int x, int y)
#define TRACK_MAP_PAN_ALIGNED_WITH_OPPONENTS
#define RM_CAR_STATE_PULLUP
Car pulled out in the air.
static float track_height
static const float MAXLINEWIDTH