From c85954a26f6b5f1fa5ede0999140e3c64b126604 Mon Sep 17 00:00:00 2001 From: Lee Salzman Date: Thu, 27 Dec 2007 06:03:47 +0000 Subject: [PATCH] texture bpp info git-svn-id: svn://svn.code.sf.net/p/actiongame/code/trunk/ac@1506 e016b1c5-ed68-44aa-a2f7-31cac88cffde --- source/src/protos.h | 2 +- source/src/texture.cpp | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/source/src/protos.h b/source/src/protos.h index 0d101ae8..15faf12b 100644 --- a/source/src/protos.h +++ b/source/src/protos.h @@ -115,7 +115,7 @@ extern void clearminimap(); struct Texture { char *name; - int xs, ys; + int xs, ys, bpp; GLuint id; }; extern Texture *notexture; diff --git a/source/src/texture.cpp b/source/src/texture.cpp index adf7dc9c..16ef145e 100644 --- a/source/src/texture.cpp +++ b/source/src/texture.cpp @@ -56,7 +56,7 @@ GLenum texformat(int bpp) } } -GLuint loadsurface(const char *texname, int &xs, int &ys, int clamp) +GLuint loadsurface(const char *texname, int &xs, int &ys, int &bpp, int clamp) { SDL_Surface *s = IMG_Load(findfile(texname, "rb")); if(!s) { conoutf("couldn't load texture %s", texname); return 0; } @@ -72,6 +72,7 @@ GLuint loadsurface(const char *texname, int &xs, int &ys, int clamp) createtexture(tnum, s->w, s->h, s->pixels, clamp, true, format); xs = s->w; ys = s->h; + bpp = s->format->BitsPerPixel; SDL_FreeSurface(s); return tnum; } @@ -87,14 +88,15 @@ Texture *textureload(const char *name, int clamp) path(pname); Texture *t = textures.access(pname); if(t) return t; - int xs, ys; - GLuint id = loadsurface(pname, xs, ys, clamp); + int xs, ys, bpp; + GLuint id = loadsurface(pname, xs, ys, bpp, clamp); if(!id) return notexture; char *key = newstring(pname); t = &textures[key]; t->name = key; t->xs = xs; t->ys = ys; + t->bpp = bpp; t->id = id; return t; }