41 static float grWhite[4] = {1.0, 1.0, 1.0, 1.0};
42 static float grRed[4] = {1.0, 0.0, 0.0, 1.0};
43 static float grBlue[4] = {0.0, 0.0, 1.0, 1.0};
44 static float grGreen[4] = {0.0, 1.0, 0.0, 1.0};
45 static float grBlack[4] = {0.0, 0.0, 0.0, 1.0};
72 const int BUFSIZE=1024;
103 const int BUFSIZE=1024;
140 const int BUFSIZE=256;
147 snprintf(buf, BUFSIZE,
"FPS: %.1f", fps);
171 tdble X1, Y1, X2, Y2, xc, yc;
176 yc = (
tdble)(Y1 - 50);
178 X2 = -car->_DynGC.acc.y / 9.81f * 25.0f + X1;
179 Y2 = car->_DynGC.acc.x / 9.81f * 25.0f + Y1;
181 glColor4f(1.0, 1.0, 1.0, 1.0);
182 glVertex2f(X1-50, Y1);
183 glVertex2f(X1+50, Y1);
184 glVertex2f(X1, Y1-50);
185 glVertex2f(X1, Y1+50);
187 glVertex2f(xc, yc+100);
190 const tdble THNSS = 2.0f;
193 glColor4f(0.0, 0.0, 1.0, 1.0);
194 glVertex2f(X1 - THNSS, Y1);
195 glVertex2f(X1 + THNSS, Y1);
196 glVertex2f(X1 + THNSS, Y1 + car->
ctrl.
accelCmd * 50.0f);
197 glVertex2f(X1 - THNSS, Y1 + car->
ctrl.
accelCmd * 50.0f);
199 glVertex2f(X1 - THNSS, Y1);
200 glVertex2f(X1 + THNSS, Y1);
201 glVertex2f(X1 + THNSS, Y1 - car->
ctrl.
brakeCmd * 50.0f);
202 glVertex2f(X1 - THNSS, Y1 - car->
ctrl.
brakeCmd * 50.0f);
204 glVertex2f(X1, Y1 - THNSS);
205 glVertex2f(X1, Y1 + THNSS);
206 glVertex2f(X1 - car->
ctrl.
steer * 50.0f, Y1 + THNSS);
207 glVertex2f(X1 - car->
ctrl.
steer * 50.0f, Y1 - THNSS);
209 glVertex2f(xc - THNSS, yc);
210 glVertex2f(xc + THNSS, yc);
217 glColor4f(1.0, 0.0, 0.0, 1.0);
229 curH =
MIN(val, 1.0);
230 curH =
MAX(curH, 0.0);
243 glVertex2f(X1 -
THNSSFG, Y1 + curH);
244 glVertex2f(X1 +
THNSSFG, Y1 + curH);
245 glVertex2f(X1 +
THNSSFG, Y1 + H);
246 glVertex2f(X1 -
THNSSFG, Y1 + H);
251 glVertex2f(X1 +
THNSSFG, Y1 + curH);
252 glVertex2f(X1 -
THNSSFG, Y1 + curH);
262 if (car->_fuel < 5.0f) {
278 const int BUFSIZE=256;
288 snprintf(buf, BUFSIZE,
"%d/%d - %s", car->_pos, s->_ncars, car->_name);
290 dx =
MAX(dx, (x2-x));
293 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA) ;
295 glColor4f(0.1, 0.1, 0.1, 0.8);
296 glVertex2f(x-5,
y + dy);
297 glVertex2f(x+dx+5,
y + dy);
298 glVertex2f(x+dx+5,
y-5 - dy2 * 9 );
299 glVertex2f(x-5,
y-5 - dy2 * 9 );
309 if (car->_fuel < 5.0) {
314 snprintf(buf, BUFSIZE,
"%.1f l", car->_fuel);
325 snprintf(buf, BUFSIZE,
"%d", car->_dammage);
331 snprintf(buf, BUFSIZE,
"%d / %d", car->_laps, s->_totLaps);
340 if (!car->_commitBestLapTime) {
360 snprintf(buf, BUFSIZE,
"%d", (
int)(car->_topSpeed * 3.6));
368 const int BUFSIZE=256;
382 snprintf(buf, BUFSIZE,
"%d/%d - %s", car->_pos, s->_ncars, car->_name);
384 dx =
MAX(dx, (x3-x));
387 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA) ;
389 glColor4f(0.1, 0.1, 0.1, 0.8);
390 glVertex2f(x-5,
y + dy);
391 glVertex2f(x+dx+5,
y + dy);
392 int y2 =
y-5 - dy2 * 7;
393 glVertex2f(x+dx+5, y2);
399 glVertex2f(x-5, y2 - 2);
400 glVertex2f(x+dx+5, y2 - 2);
401 y2 = y2 - 2 - dy2 * 6;
402 glVertex2f(x+dx+5, y2);
408 glVertex2f(x-5, y2 - 2);
409 glVertex2f(x+dx+5, y2 - 2);
410 y2 = y2 - 2 - dy2 * 4;
411 glVertex2f(x+dx+5, y2);
422 if (car->_fuel < 5.0) {
427 snprintf(buf, BUFSIZE,
"%.1f l", car->_fuel);
434 snprintf(buf, BUFSIZE,
"%d / %d", car->_laps, s->_totLaps);
444 if (!car->_commitBestLapTime) {
455 if (car->_pos != 1) {
456 snprintf(buf, BUFSIZE,
"<- %s", s->
cars[car->_pos - 2]->_name);
458 if (s->
cars[car->_pos - 2]->_laps == car->_laps) {
469 if (car->_pos != s->_ncars) {
470 snprintf(buf, BUFSIZE,
"-> %s", s->
cars[car->_pos]->_name);
472 if (s->
cars[car->_pos]->_laps == car->_laps) {
484 static const char* wheellabel[4] = {
"FR",
"FL",
"RR",
"RL"};
488 static const int tx0 = 45;
489 static const int tdx = 47;
491 for (i = 0; i < 4; i++) {
500 snprintf(buf, BUFSIZE,
"%5.4f", wheel->
currentWear);
509 for (i = 0; i < 4; i++) {
534 static const char *
gearStr[
MAX_GEARS] = {
"R",
"N",
"1",
"2",
"3",
"4",
"5",
"6",
"7",
"8"};
536 #define ALIGN_CENTER 0 538 #define ALIGN_RIGHT 2 545 GLfloat ledcolg[2][3] = {
550 GLfloat ledcolr[2][3] = {
560 int ledRed = (int)((car->_enginerpmRedLine * .9 / car->_enginerpmMax) * (
tdble)ledNb);
561 int ledLit = (int)((car->_enginerpm / car->_enginerpmMax) * (
tdble)ledNb);
565 x =
X - ((ledNb * ledWidth) + (ledNb - 1) * ledSpace) / 2;
571 x =
X - ((ledNb * ledWidth) + (ledNb - 1) * ledSpace);
574 x =
X - ((ledNb * ledWidth) + (ledNb - 1) * ledSpace) / 2;
582 glColor3f(0.1, 0.1, 0.1);
583 glVertex2f(x - ledSpace,
y + ledHeight + ledSpace);
584 glVertex2f(x + ledNb * (ledWidth+ ledSpace),
y + ledHeight + ledSpace);
585 glVertex2f(x + ledNb * (ledWidth+ ledSpace),
Winy);
586 glVertex2f(x - ledSpace,
Winy);
590 glColor3fv(ledcolg[0]);
591 for (i = 0; i < ledRed; i++) {
593 glVertex2f(x + ledWidth,
y);
594 glVertex2f(x + ledWidth,
y + ledHeight);
595 glVertex2f(x,
y + ledHeight);
596 x += ledWidth + ledSpace;
599 glColor3fv(ledcolr[0]);
600 for (i = ledRed; i < ledNb; i++) {
602 glVertex2f(x + ledWidth,
y);
603 glVertex2f(x + ledWidth,
y + ledHeight);
604 glVertex2f(x,
y + ledHeight);
605 x += ledWidth + ledSpace;
609 glColor3fv(ledcolg[1]);
610 for (i = 0; i < ledNb; i++) {
612 glColor3fv(ledcolr[1]);
615 glVertex2f(x +
DD,
y +
DD);
616 glVertex2f(x + ledWidth -
DD,
y +
DD);
617 glVertex2f(x + ledWidth -
DD,
y + ledHeight -
DD);
618 glVertex2f(x +
DD,
y + ledHeight -
DD);
619 x += ledWidth + ledSpace;
631 const int BUFSIZE=256;
638 snprintf(buf, BUFSIZE,
" kph %s",
gearStr[car->_gear+car->_gearOffset]);
642 snprintf(buf, BUFSIZE,
"%3d", abs((
int)(car->_speed_x * 3.6)));
650 const int BUFSIZE=256;
659 for (i = 0; i < s->_ncars; i++) {
660 if (car == s->
cars[i]) {
672 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA) ;
674 glColor4f(0.1, 0.1, 0.1, 0.8);
675 glVertex2f(x,
Winy + 5);
677 glVertex2f(
Winx + 180,
y + dy * (maxi + drawLaps));
678 glVertex2f(x,
y + dy * (maxi + drawLaps));
682 if (current + 1 > maxi) {
688 for (j = maxi; j > 0; j--) {
696 if (i == current + 1) {
703 snprintf(buf, BUFSIZE,
"%3d: %s", i, s->
cars[i-1]->_name);
708 }
else if (s->
cars[i-1]->_timeBehindLeader == 0) {
718 if (s->
cars[i-1]->_lapsBehindLeader == 0) {
721 if (s->
cars[i-1]->_lapsBehindLeader > 1) {
722 snprintf(buf, BUFSIZE,
"+%3d Laps", s->
cars[i-1]->_lapsBehindLeader);
724 snprintf(buf, BUFSIZE,
"+%3d Lap", s->
cars[i-1]->_lapsBehindLeader);
735 snprintf(buf, BUFSIZE,
"%d / %d", s->
cars[0]->_laps, s->_totLaps);
747 const int BUFSIZE=32;
754 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA) ;
755 glEnable(GL_TEXTURE_2D);
756 glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
757 glBindTexture(GL_TEXTURE_2D, curInst->
texture->getTextureHandle());
759 glBindTexture(GL_TEXTURE_2D, 0);
764 }
else if (val < 0.0) {
774 glRotatef(val, 0, 0, 1);
785 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA) ;
786 glEnable(GL_TEXTURE_2D);
787 glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
788 glBindTexture(GL_TEXTURE_2D, curInst->
texture->getTextureHandle());
790 glBindTexture(GL_TEXTURE_2D, 0);
795 }
else if (val < 0.0) {
804 glRotatef(val, 0, 0, 1);
810 snprintf(buf, BUFSIZE,
"%d", abs((
int)(car->_speed_x * 3.6)));
842 const int BUFSIZE=256;
852 snprintf(buf, BUFSIZE,
"%d/%d", car->_pos, s->_ncars);
858 if (!car->_commitBestLapTime) {
871 snprintf(buf, BUFSIZE,
"Lap: %d/%d", car->_laps, s->_totLaps);
876 snprintf(buf, BUFSIZE,
"%s", car->_name);
880 if (car->_fuel < 5.0) {
891 snprintf(buf, BUFSIZE,
"%3d km/h", abs((
int)(car->_speed_x * 3.6)));
894 snprintf(buf, BUFSIZE,
"%s",
gearStr[car->_gear+car->_gearOffset]);
919 const int BUFSIZE=1024;
927 tdble xSz, ySz, xpos, ypos;
928 tdble needlexSz, needleySz;
930 ssgSetCurrentOptions ( &
options ) ;
934 handle = car->_carHandle;
941 snprintf(buf, BUFSIZE,
"drivers/%s/%d;drivers/%s;cars/%s;data/textures", car->_modName, car->_driverIndex, car->_modName, car->_carName);
967 glBegin(GL_TRIANGLE_STRIP);
969 glColor4f(1.0, 1.0, 1.0, 0.0);
970 glTexCoord2f(0.0, 0.0); glVertex2f(xpos, ypos);
971 glTexCoord2f(0.0, 1.0); glVertex2f(xpos, ypos + ySz);
972 glTexCoord2f(1.0, 0.0); glVertex2f(xpos + xSz, ypos);
973 glTexCoord2f(1.0, 1.0); glVertex2f(xpos + xSz, ypos + ySz);
980 glBegin(GL_TRIANGLE_STRIP);
982 glColor4f(1.0, 0.0, 0.0, 1.0);
983 glVertex2f(0, -needleySz);
984 glVertex2f(0, needleySz);
985 glVertex2f(needlexSz, -needleySz / 2.0);
986 glVertex2f(needlexSz, needleySz / 2.0);
997 snprintf(buf, BUFSIZE,
"drivers/%s/%d;drivers/%s;cars/%s;data/textures", car->_modName, car->_driverIndex, car->_modName, car->_carName);
1026 glBegin(GL_TRIANGLE_STRIP);
1028 glColor4f(1.0, 1.0, 1.0, 0.0);
1029 glTexCoord2f(0.0, 0.0); glVertex2f(xpos, ypos);
1030 glTexCoord2f(0.0, 1.0); glVertex2f(xpos, ypos + ySz);
1031 glTexCoord2f(1.0, 0.0); glVertex2f(xpos + xSz, ypos);
1032 glTexCoord2f(1.0, 1.0); glVertex2f(xpos + xSz, ypos + ySz);
1039 glBegin(GL_TRIANGLE_STRIP);
1041 glColor4f(1.0, 0.0, 0.0, 1.0);
1042 glVertex2f(0, -needleySz);
1043 glVertex2f(0, needleySz);
1044 glVertex2f(needlexSz, -needleySz / 2.0);
1045 glVertex2f(needlexSz, needleySz / 2.0);
1056 ssgDeRefDelete(
grCarInfo[i].instrument[0].texture);
1057 ssgDeRefDelete(
grCarInfo[i].instrument[1].texture);
1058 glDeleteLists(
grCarInfo[i].instrument[0].needleList, 1);
1059 glDeleteLists(
grCarInfo[i].instrument[1].needleList, 1);
1060 glDeleteLists(
grCarInfo[i].instrument[0].CounterList, 1);
1061 glDeleteLists(
grCarInfo[i].instrument[1].CounterList, 1);
#define RM_CAR_STATE_DNF
Car did not finish.
#define PRM_SPEEDO_XCENTER
double currentTime
current time in sec since the beginning of the simulation
void grDispCounterBoard2(tCarElt *car)
static ssgLoaderOptionsEx options
void grDispMisc(tCarElt *car)
void loadDefaults(tCarElt *curCar)
cars situation used to inform the GUI and the drivers
tdble brakeCmd
Brake command [0.0, 1.0].
static void grDispEngineLeds(tCarElt *car, int X, int Y, int align, int bg)
#define RM_CAR_STATE_BROKEN
Engine no more working.
tCarElt ** cars
list of cars
tdble clutchCmd
Clutch command [0.0, 1.0].
void grDispCarBoard2(tCarElt *car, tSituation *s)
void refreshBoard(tSituation *s, float Fps, int forceArcade, tCarElt *curr)
char msg[4][32]
4 lines of 31 characters 0-1 from car 2-3 from race engine
#define RPM2RADS(x)
RPM to Radian/s conversion.
int GfParmWriteFile(const char *file, void *parmHandle, const char *name)
Write parameter set into file.
#define GFUI_FONT_SMALL_C
#define PRM_SPEEDO_NDLXSZ
#define PRM_SPEEDO_XDIGITCENTER
void display(tCarElt *currentCar, tSituation *situation, int Winx, int Winy, int Winw, int Winh)
void grDispCounterBoard(tCarElt *car)
const char * GfParmGetStr(void *parmHandle, const char *path, const char *key, const char *deflt)
Get a string parameter from the parameter set handle.
#define GFUI_FONT_LARGE_C
The Gaming Framework API (client part).
void grDispGGraph(tCarElt *car)
void grDispDebug(float fps, tCarElt *car)
#define PRM_SPEEDO_MAXVAL
tdble steer
Steer command [-1.0, 1.0].
void grDrawGauge(tdble X1, tdble Y1, tdble H, float *clr1, float *clr2, tdble val, const char *title)
void selectBoard(int brd)
tgrCarInstrument instrument[2]
float tdble
Floating point type used in TORCS.
int GfuiFontHeight(int font)
void grDispCarBoard1(tCarElt *car, tSituation *s)
#define PRM_SPEEDO_MINANG
void GfuiPrintString(const char *text, float *fgColor, int font, int x, int y, int align)
Dynamic wheel information.
#define PRM_SPEEDO_YDIGITCENTER
#define PRM_SPEEDO_DIGITAL
static float grDefaultClr[4]
void grDispArcade(tCarElt *car, tSituation *s)
void grShutdownBoardCar(void)
void grDispLeaderBoard(tCarElt *car, tSituation *s)
Parameter header structure, a parameter can either carry a numeric or a string value, numeric value is constraint by min and max, string value by options in within.
int GfuiFontWidth(int font, const char *text)
int GfParmSetNum(void *handle, const char *path, const char *key, const char *unit, tdble val)
Set a numerical parameter in the parameter set handle.
#define PRM_TACHO_YDIGITCENTER
#define PRM_SPEEDO_NDLYSZ
tdble accelCmd
Accelerator command [0.0, 1.0].
tdble GfParmGetNum(void *handle, const char *path, const char *key, const char *unit, tdble deflt)
Get a numerical parameter from the parameter set handle.
#define PRM_SPEEDO_MINVAL
#define PRM_TACHO_XCENTER
#define GFUI_FONT_MEDIUM_C
ssgState * grSsgLoadTexState(const char *img)
#define PRM_TACHO_XDIGITCENTER
static const char * gearStr[MAX_GEARS]
void grDispCarBoard(tCarElt *car, tSituation *s)
float msgColor[4]
RGBA of text.
#define PRM_TACHO_YCENTER
int skillLevel
Driver's skill level (0=rookie -> 3=pro)
void grWriteTime(float *color, int font, int x, int y, tdble sec, int sgn)
void grInitBoardCar(tCarElt *car)
#define PRM_SPEEDO_MAXANG
#define PRM_SPEEDO_YCENTER