TORCS  1.3.10
The Open Racing Car Simulator
Loading...
Searching...
No Matches
grtexture.h
Go to the documentation of this file.
1/***************************************************************************
2
3 file : grtexture.h
4 created : Wed Jun 1 14:56:31 CET 2005
5 copyright : (C) 2005-2026 by Bernhard Wymann
6
7***************************************************************************/
8
9/***************************************************************************
10 * *
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 ***************************************************************************/
17
18/*
19 This classes/methods are used to handle texture compression and
20 textures which are shared among multiple objects. In the long term
21 they should obsolete parts of grutil.cpp.
22*/
23
24#ifndef _GRTEXTURE_H_
25#define _GRTEXTURE_H_
26
27#include <stdio.h>
28#include <plib/ssg.h>
29#include <glfeatures.h>
30#include "grloadsgi.h"
31
32bool doMipMap(const char *tfname, int mipmap);
33void grRemoveState(char* img);
34void grApplyTextureAnisotropy(ssgTexture *tex);
35
36
37// This state does currently not manage anything!
38// TODO: manage shared textures, obsolete grutil.cpp parts.
39class grManagedState : public ssgSimpleState {
40 public:
41
42 /*static int ms;
43
44 grManagedState() {
45 GfError("Created state: %0xd, #: %d\n", this, ++ms);
46 }
47*/
48 virtual ~grManagedState() {
49 //GfError("delete this: %0xd, #: %d\n", this, --ms);
50 if (this->getTexture() != NULL) {
51 grRemoveState(this->getTexture()->getFilename());
52 }
53 }
54
55 virtual void setTexture(ssgTexture *tex) {
56 //printf("tex: %s\n", tex->getFilename());
57 ssgSimpleState::setTexture(tex);
58 grApplyTextureAnisotropy(this->getTexture());
59 }
60
61 virtual void setTexture(const char *fname, int _wrapu = TRUE, int _wrapv = TRUE, int _mipmap = TRUE) {
62 //printf("texw: %s\n", fname);
63 _mipmap = doMipMap(fname, _mipmap);
64 ssgSimpleState::setTexture(fname, _wrapu, _wrapv, _mipmap);
65 grApplyTextureAnisotropy(this->getTexture());
66 }
67
68 virtual void setTexture(GLuint tex) {
69 printf("Obsolete call: setTexture(GLuint tex)\n");
70 ssgSimpleState::setTexture(tex);
71 grApplyTextureAnisotropy(this->getTexture());
72 }
73};
74
75// Managed state factory.
76inline grManagedState* grStateFactory(void) { return new grManagedState(); }
77
78// Prototype for mipmap generation.
79bool grMakeMipMaps(GLubyte *image, int xsize, int ysize, int zsize, bool mipmap);
80
81// Prototype for SGI texture loading function.
82bool grLoadSGI(const char *fname, ssgTextureInfo* info);
83
84// Register customized loader in plib.
86
87// SGI loader class to call customized ssgMakeMipMaps. This is necessary because
88// of plib architecture which does not allow to customize the mipmap
89// generation.
90class grSGIHeader : public ssgSGIHeader {
91 public:
92 grSGIHeader(const char *fname, ssgTextureInfo* info);
93};
94
95
96
97#endif // _GRTEXTURE_H_
virtual void setTexture(const char *fname, int _wrapu=TRUE, int _wrapv=TRUE, int _mipmap=TRUE)
Definition grtexture.h:61
virtual void setTexture(ssgTexture *tex)
Definition grtexture.h:55
virtual ~grManagedState()
Definition grtexture.h:48
virtual void setTexture(GLuint tex)
Definition grtexture.h:68
grSGIHeader(const char *fname, ssgTextureInfo *info)
bool grMakeMipMaps(GLubyte *image, int xsize, int ysize, int zsize, bool mipmap)
bool doMipMap(const char *tfname, int mipmap)
Definition grtexture.cpp:28
void grApplyTextureAnisotropy(ssgTexture *tex)
Definition grtexture.cpp:67
grManagedState * grStateFactory(void)
Definition grtexture.h:76
bool grLoadSGI(const char *fname, ssgTextureInfo *info)
void grRemoveState(char *img)
Definition grutil.cpp:156
void grRegisterCustomSGILoader(void)