TORCS
1.3.9
The Open Racing Car Simulator
main.cpp
Go to the documentation of this file.
1
/***************************************************************************
2
3
file : main.cpp
4
created : Sat Mar 18 23:54:30 CET 2000
5
copyright : (C) 2000 by Eric Espie
6
email : torcs@free.fr
7
version : $Id$
8
9
***************************************************************************/
10
11
/***************************************************************************
12
* *
13
* This program is free software; you can redistribute it and/or modify *
14
* it under the terms of the GNU General Public License as published by *
15
* the Free Software Foundation; either version 2 of the License, or *
16
* (at your option) any later version. *
17
* *
18
***************************************************************************/
19
20
#include <stdlib.h>
21
22
#include <GL/glut.h>
23
24
#include <
tgfclient.h
>
25
#include <
client.h
>
26
27
#include "linuxspec.h"
28
#include <
raceinit.h
>
29
30
extern
bool
bKeepModules
;
31
32
static
void
33
init_args
(
int
argc,
char
**argv,
const
char
**raceconfig)
34
{
35
int
i;
36
char
*buf;
37
38
i = 1;
39
40
while
(i < argc) {
41
if
(strncmp(argv[i],
"-l"
, 2) == 0) {
42
i++;
43
44
if
(i < argc) {
45
buf = (
char
*)malloc(strlen(argv[i]) + 2);
46
sprintf(buf,
"%s/"
, argv[i]);
47
SetLocalDir
(buf);
48
free(buf);
49
i++;
50
}
51
}
else
if
(strncmp(argv[i],
"-L"
, 2) == 0) {
52
i++;
53
54
if
(i < argc) {
55
buf = (
char
*)malloc(strlen(argv[i]) + 2);
56
sprintf(buf,
"%s/"
, argv[i]);
57
SetLibDir
(buf);
58
free(buf);
59
i++;
60
}
61
}
else
if
(strncmp(argv[i],
"-D"
, 2) == 0) {
62
i++;
63
64
if
(i < argc) {
65
buf = (
char
*)malloc(strlen(argv[i]) + 2);
66
sprintf(buf,
"%s/"
, argv[i]);
67
SetDataDir
(buf);
68
free(buf);
69
i++;
70
}
71
}
else
if
(strncmp(argv[i],
"-s"
, 2) == 0) {
72
i++;
73
SetSingleTextureMode
();
74
}
else
if
(strncmp(argv[i],
"-k"
, 2) == 0) {
75
i++;
76
// Keep modules in memory (for valgrind)
77
printf(
"Unloading modules disabled, just intended for valgrind runs.\n"
);
78
bKeepModules
=
true
;
79
#ifndef FREEGLUT
80
}
else
if
(strncmp(argv[i],
"-m"
, 2) == 0) {
81
i++;
82
GfuiMouseSetHWPresent
();
/* allow the hardware cursor */
83
#endif
84
}
else
if
(strncmp(argv[i],
"-r"
, 2) == 0) {
85
i++;
86
*raceconfig =
""
;
87
88
if
(i < argc) {
89
*raceconfig = argv[i];
90
i++;
91
}
92
93
if
((strlen(*raceconfig) == 0) || (strstr(*raceconfig,
".xml"
) == 0)) {
94
printf(
"Please specify a race configuration xml when using -r\n"
);
95
exit(1);
96
}
97
}
else
{
98
i++;
/* ignore bad args */
99
}
100
}
101
102
#ifdef FREEGLUT
103
GfuiMouseSetHWPresent
();
/* allow the hardware cursor (freeglut pb ?) */
104
#endif
105
}
106
107
/*
108
* Function
109
* main
110
*
111
* Description
112
* LINUX entry point of TORCS
113
*
114
* Parameters
115
*
116
*
117
* Return
118
*
119
*
120
* Remarks
121
*
122
*/
123
int
124
main
(
int
argc,
char
*argv[])
125
{
126
const
char
*raceconfig =
""
;
127
128
init_args
(argc, argv, &raceconfig);
129
LinuxSpecInit();
/* init specific linux functions */
130
131
if
(strlen(raceconfig) == 0) {
132
GfScrInit
(argc, argv);
/* init screen */
133
TorcsEntry
();
/* launch TORCS */
134
glutMainLoop();
/* event loop of glut */
135
}
else
{
136
// Run race from console, no Window, no OpenGL/OpenAL etc.
137
// Thought for blind scripted AI training
138
ReRunRaceOnConsole
(raceconfig);
139
}
140
141
return
0;
/* just for the compiler, never reached */
142
}
143
ReRunRaceOnConsole
void ReRunRaceOnConsole(const char *raceconfig)
Definition:
raceinit.cpp:159
tgfclient.h
The Gaming Framework API (client part).
GfuiMouseSetHWPresent
void GfuiMouseSetHWPresent(void)
Force the hardware mouse pointer.
Definition:
gui.cpp:241
main
int main(int argc, char *argv[])
Definition:
main.cpp:124
SetSingleTextureMode
void SetSingleTextureMode(void)
Definition:
tgf.cpp:279
SetLibDir
void SetLibDir(char *buf)
Definition:
tgf.cpp:250
GfScrInit
void GfScrInit(int argc, char *argv[])
Definition:
screen.cpp:261
raceinit.h
bKeepModules
bool bKeepModules
SetDataDir
void SetDataDir(char *buf)
Definition:
tgf.cpp:263
client.h
SetLocalDir
void SetLocalDir(char *buf)
Definition:
tgf.cpp:237
TorcsEntry
void TorcsEntry(void)
Definition:
entry.cpp:46
init_args
static void init_args(int argc, char **argv, const char **raceconfig)
Definition:
main.cpp:33
src
linux
main.cpp
Generated by
1.8.14