22 #include <sys/types.h> 46 int grGetFilename(
const char *filename,
char *filepath,
char *buf,
const int BUFSIZE)
51 int flen = strlen(filename);
56 while ((!found) && (c2 != NULL)) {
59 snprintf(buf, BUFSIZE,
"%s/%s", c1, filename);
62 if (lg + flen + 2 < BUFSIZE) {
65 strcpy(buf + lg + 1, filename);
70 if (ulFileExists(buf)) {
76 strncpy(buf, filename, BUFSIZE);
77 if (ulFileExists(buf)) {
82 GfOut(
"File %s not found\n", filename);
83 GfOut(
"File Path was %s\n", filepath);
97 TRACE_GL(
"Load: grLoadPngTexture start");
108 info -> alpha =
true;
111 TRACE_GL(
"Load: grLoadPngTexture stop");
119 GLubyte* tex2 =
new GLubyte[w*h*4];
120 memcpy(tex2, tex, w*h*4);
146 while (curr != NULL) {
147 if (strcmp(curr->
name, img) == 0) {
161 while (curr != NULL) {
162 if (strcmp(curr->
name, img) == 0) {
163 if (curr->
prev != 0) {
166 if (curr->
next != 0) {
188 while (curr != NULL) {
190 printf(
"Still in list : %s\n", curr->
name);
201 st->enable(GL_LIGHTING);
202 st->enable(GL_TEXTURE_2D);
203 st->enable(GL_BLEND);
204 st->setColourMaterial(GL_AMBIENT_AND_DIFFUSE);
213 curr->
name = strdup(buf);
215 GfOut(
"Loading %s\n", buf);
221 const int BUFSIZE = 1024;
227 s = strrchr(img,
'/');
235 GfOut(
"grSsgLoadTexState: File %s not found\n", s);
241 return (ssgState*)st;
248 return (ssgState*)st;
253 const int BUFSIZE = 1024;
259 s = strrchr(img,
'/');
267 GfOut(
"grSsgLoadTexState: File %s not found\n", s);
280 return (ssgState*)st;
286 const int BUFSIZE = 1024;
292 s = strrchr(img,
'/');
300 GfOut(
"File %s not found\n", s);
306 return (ssgState*)st;
313 return (ssgState*)st;
319 const int BUFSIZE = 256;
334 int h = (int)(sec / 3600.0);
336 int m = (int)(sec / 60.0);
340 int c = (int)floor((sec) * 100.0);
342 (void)snprintf(buf, BUFSIZE,
"%s%2.2d:%2.2d:%2.2d:%2.2d",
sign,h,m,s,c);
344 (void)snprintf(buf, BUFSIZE,
" %s%2.2d:%2.2d:%2.2d",
sign,m,s,c);
346 (void)snprintf(buf, BUFSIZE,
" %s%2.2d:%2.2d",
sign,s,c);
358 sgMakeIdentMat4(invmat);
362 invmat[3][2] = 0.0f ;
366 test_vec [2] = 100000.0f;
369 int num_hits = ssgHOT (
TheScene, test_vec, invmat, &results);
370 float hot = -1000000.0f;
372 for (
int i = 0; i < num_hits; i++) {
373 ssgHit *h = &results[i];
375 float hgt = (h->plane[2] == 0.0 ? 0.0 : - h->plane[3] / h->plane[2]);
bool grLoadPngTexture(const char *fname, ssgTextureInfo *info)
static grManagedState * grGetState(char *img)
ssgState * grSsgEnvTexState(const char *img)
void grRemoveState(char *img)
static void grSetupState(grManagedState *st, char *buf)
bool doMipMap(const char *tfname, int mipmap)
static stlist * stateList
The Gaming Framework API (client part).
float tdble
Floating point type used in TORCS.
unsigned char * GfImgReadPng(const char *filename, int *widthp, int *heightp, float screen_gamma)
Load an image from disk to a buffer in RGBA mode.
grManagedState * grStateFactory(void)
void GfuiPrintString(const char *text, float *fgColor, int font, int x, int y, int align)
float grGetHOT(float x, float y)
void grShutdownState(void)
ssgState * grSsgLoadTexState(const char *img)
virtual void setTexture(ssgTexture *tex)
ssgState * grSsgLoadTexStateEx(const char *img, char *filepath, int wrap, int mipmap)
int grGetFilename(const char *filename, char *filepath, char *buf, const int BUFSIZE)
void grWriteTime(float *color, int font, int x, int y, tdble sec, int sgn)
bool grMakeMipMaps(GLubyte *image, int xsize, int ysize, int zsize, bool mipmap)