44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
|
glEnable(GL_CULL_FACE);
char *exts = (char *)glGetString(GL_EXTENSIONS);
if (strstr(exts, "GL_EXT_texture_env_combine"))
hasoverbright = true;
else
conoutf("WARNING: cannot use overbright lighting, using old "
"lighting model!");
glGetIntegerv(GL_MAX_TEXTURE_SIZE, &glmaxtexsize);
purgetextures();
if (!(qsphere = gluNewQuadric()))
fatal("glu sphere");
|
|
|
|
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
|
glEnable(GL_CULL_FACE);
char *exts = (char *)glGetString(GL_EXTENSIONS);
if (strstr(exts, "GL_EXT_texture_env_combine"))
hasoverbright = true;
else
conoutf(@"WARNING: cannot use overbright lighting, using old "
@"lighting model!");
glGetIntegerv(GL_MAX_TEXTURE_SIZE, &glmaxtexsize);
purgetextures();
if (!(qsphere = gluNewQuadric()))
fatal("glu sphere");
|
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
|
};
bool
installtex(int tnum, char *texname, int &xs, int &ys, bool clamp)
{
SDL_Surface *s = IMG_Load(texname);
if (!s) {
conoutf("couldn't load texture %s", texname);
return false;
};
if (s->format->BitsPerPixel != 24) {
conoutf("texture must be 24bpp: %s", texname);
return false;
};
// loopi(s->w*s->h*3) { uchar *p = (uchar *)s->pixels+i; *p = 255-*p; };
glBindTexture(GL_TEXTURE_2D, tnum);
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S,
clamp ? GL_CLAMP_TO_EDGE : GL_REPEAT);
|
|
|
|
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
|
};
bool
installtex(int tnum, char *texname, int &xs, int &ys, bool clamp)
{
SDL_Surface *s = IMG_Load(texname);
if (!s) {
conoutf(@"couldn't load texture %s", texname);
return false;
};
if (s->format->BitsPerPixel != 24) {
conoutf(@"texture must be 24bpp: %s", texname);
return false;
};
// loopi(s->w*s->h*3) { uchar *p = (uchar *)s->pixels+i; *p = 255-*p; };
glBindTexture(GL_TEXTURE_2D, tnum);
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S,
clamp ? GL_CLAMP_TO_EDGE : GL_REPEAT);
|
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
|
ys = s->h;
while (xs > glmaxtexsize || ys > glmaxtexsize) {
xs /= 2;
ys /= 2;
};
void *scaledimg = s->pixels;
if (xs != s->w) {
conoutf("warning: quality loss: scaling %s",
texname); // for voodoo cards under linux
scaledimg = alloc(xs * ys * 3);
gluScaleImage(GL_RGB, s->w, s->h, GL_UNSIGNED_BYTE, s->pixels,
xs, ys, GL_UNSIGNED_BYTE, scaledimg);
};
if (gluBuild2DMipmaps(GL_TEXTURE_2D, GL_RGB, xs, ys, GL_RGB,
GL_UNSIGNED_BYTE, scaledimg))
|
|
|
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
|
ys = s->h;
while (xs > glmaxtexsize || ys > glmaxtexsize) {
xs /= 2;
ys /= 2;
};
void *scaledimg = s->pixels;
if (xs != s->w) {
conoutf(@"warning: quality loss: scaling %s",
texname); // for voodoo cards under linux
scaledimg = alloc(xs * ys * 3);
gluScaleImage(GL_RGB, s->w, s->h, GL_UNSIGNED_BYTE, s->pixels,
xs, ys, GL_UNSIGNED_BYTE, scaledimg);
};
if (gluBuild2DMipmaps(GL_TEXTURE_2D, GL_RGB, xs, ys, GL_RGB,
GL_UNSIGNED_BYTE, scaledimg))
|
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
|
s.num = n;
};
VARFP(gamma, 30, 100, 300, {
float f = gamma / 100.0f;
if (SDL_SetGamma(f, f, f) == -1) {
conoutf(
"Could not set gamma (card/driver doesn't support it?)");
conoutf("sdl: %s", SDL_GetError());
};
});
void
transplayer()
{
glLoadIdentity();
|
|
|
|
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
|
s.num = n;
};
VARFP(gamma, 30, 100, 300, {
float f = gamma / 100.0f;
if (SDL_SetGamma(f, f, f) == -1) {
conoutf(
@"Could not set gamma (card/driver doesn't support it?)");
conoutf(@"sdl: %s", SDL_GetError());
};
});
void
transplayer()
{
glLoadIdentity();
|