From bd0ac4a38a1eff64678acaac5596b1f58c3d4cf7 Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Thu, 22 Nov 2001 05:31:44 +0000 Subject: [PATCH] merge Mod_LoadSpriteFrame from gl and sw back into the common sprite loader pulling the gl specific code (the loading of the texture into GL) into a separate function (Mod_SpriteLoadTexture), which is just a stub in sw --- include/QF/model.h | 1 + libs/models/sprite/gl_model_sprite.c | 40 +++-------------------- libs/models/sprite/model_sprite.c | 44 +++++++++++++++++++++++-- libs/models/sprite/sw_model_sprite.c | 48 ++-------------------------- 4 files changed, 48 insertions(+), 85 deletions(-) diff --git a/include/QF/model.h b/include/QF/model.h index 29a0e425c..960c435c6 100644 --- a/include/QF/model.h +++ b/include/QF/model.h @@ -469,6 +469,7 @@ void *Mod_LoadSkin (byte *skin, int skinsize, int snum, int gnum, void Mod_MakeAliasModelDisplayLists (model_t *m, aliashdr_t *hdr, void *_m, int _s); void Mod_FinalizeAliasModel (model_t *m, aliashdr_t *hdr); +void Mod_SpriteLoadTexture (mspriteframe_t *pspriteframe, int framenum); diff --git a/libs/models/sprite/gl_model_sprite.c b/libs/models/sprite/gl_model_sprite.c index a5629906b..f1ff380d4 100644 --- a/libs/models/sprite/gl_model_sprite.c +++ b/libs/models/sprite/gl_model_sprite.c @@ -27,9 +27,6 @@ static const char rcsid[] = "$Id$"; -// models are the only shared resource between a client and server running -// on the same machine. - #ifdef HAVE_CONFIG_H # include "config.h" #endif @@ -41,46 +38,17 @@ static const char rcsid[] = #endif #include "QF/model.h" -#include "QF/qendian.h" #include "QF/GL/qf_textures.h" #include "compat.h" - -void * -Mod_LoadSpriteFrame (void *pin, mspriteframe_t **ppframe, int framenum) +void +Mod_SpriteLoadTexture (mspriteframe_t *pspriteframe, int framenum) { - dspriteframe_t *pinframe; - mspriteframe_t *pspriteframe; - int width, height, size, origin[2]; char name[64]; - pinframe = (dspriteframe_t *) pin; - - width = LittleLong (pinframe->width); - height = LittleLong (pinframe->height); - size = width * height; - - pspriteframe = Hunk_AllocName (sizeof (mspriteframe_t), loadname); - - memset (pspriteframe, 0, sizeof (mspriteframe_t)); - - *ppframe = pspriteframe; - - pspriteframe->width = width; - pspriteframe->height = height; - origin[0] = LittleLong (pinframe->origin[0]); - origin[1] = LittleLong (pinframe->origin[1]); - - pspriteframe->up = origin[1]; - pspriteframe->down = origin[1] - height; - pspriteframe->left = origin[0]; - pspriteframe->right = width + origin[0]; - snprintf (name, sizeof (name), "%s_%i", loadmodel->name, framenum); pspriteframe->gl_texturenum = - GL_LoadTexture (name, width, height, (byte *) (pinframe + 1), true, - true, 1); - - return (void *) ((byte *) pinframe + sizeof (dspriteframe_t) + size); + GL_LoadTexture (name, pspriteframe->width, pspriteframe->height, + pspriteframe->pixels, true, true, 1); } diff --git a/libs/models/sprite/model_sprite.c b/libs/models/sprite/model_sprite.c index 1e045b592..4e8f5fdd0 100644 --- a/libs/models/sprite/model_sprite.c +++ b/libs/models/sprite/model_sprite.c @@ -30,6 +30,12 @@ static const char rcsid[] = #ifdef HAVE_CONFIG_H # include "config.h" #endif +#ifdef HAVE_STRING_H +# include +#endif +#ifdef HAVE_STRINGS_H +# include +#endif #include "QF/model.h" #include "QF/qendian.h" @@ -37,11 +43,43 @@ static const char rcsid[] = #include "compat.h" +void * +Mod_LoadSpriteFrame (void *pin, mspriteframe_t **ppframe, int framenum) +{ + dspriteframe_t *pinframe; + mspriteframe_t *pspriteframe; + int width, height, size, origin[2]; -void *Mod_LoadSpriteFrame (void *pin, mspriteframe_t **ppframe, - int framenum); + pinframe = (dspriteframe_t *) pin; -void * + width = LittleLong (pinframe->width); + height = LittleLong (pinframe->height); + size = width * height; + + pspriteframe = Hunk_AllocName (sizeof (mspriteframe_t) + size, loadname); + + memset (pspriteframe, 0, sizeof (mspriteframe_t) + size); + + *ppframe = pspriteframe; + + pspriteframe->width = width; + pspriteframe->height = height; + origin[0] = LittleLong (pinframe->origin[0]); + origin[1] = LittleLong (pinframe->origin[1]); + + pspriteframe->up = origin[1]; + pspriteframe->down = origin[1] - height; + pspriteframe->left = origin[0]; + pspriteframe->right = width + origin[0]; + + memcpy (pspriteframe->pixels, (byte *) (pinframe + 1), size); + + Mod_SpriteLoadTexture (pspriteframe, framenum); + + return (void *) ((byte *) pinframe + sizeof (dspriteframe_t) + size); +} + +void * Mod_LoadSpriteGroup (void *pin, mspriteframe_t **ppframe, int framenum) { dspritegroup_t *pingroup; diff --git a/libs/models/sprite/sw_model_sprite.c b/libs/models/sprite/sw_model_sprite.c index d8cc73746..877dd4bed 100644 --- a/libs/models/sprite/sw_model_sprite.c +++ b/libs/models/sprite/sw_model_sprite.c @@ -27,57 +27,13 @@ static const char rcsid[] = "$Id$"; -// models are the only shared resource between a client and server running -// on the same machine. - #ifdef HAVE_CONFIG_H # include "config.h" #endif -#ifdef HAVE_STRING_H -# include -#endif -#ifdef HAVE_STRINGS_H -# include -#endif #include "QF/model.h" -#include "QF/qendian.h" -#include "QF/sys.h" -#include "d_iface.h" - - - -void * -Mod_LoadSpriteFrame (void *pin, mspriteframe_t **ppframe, int framenum) +void +Mod_SpriteLoadTexture (mspriteframe_t *pspriteframe, int framenum) { - dspriteframe_t *pinframe; - mspriteframe_t *pspriteframe; - int width, height, size, origin[2]; - - pinframe = (dspriteframe_t *) pin; - - width = LittleLong (pinframe->width); - height = LittleLong (pinframe->height); - size = width * height; - - pspriteframe = Hunk_AllocName (sizeof (mspriteframe_t) + size, loadname); - - memset (pspriteframe, 0, sizeof (mspriteframe_t) + size); - - *ppframe = pspriteframe; - - pspriteframe->width = width; - pspriteframe->height = height; - origin[0] = LittleLong (pinframe->origin[0]); - origin[1] = LittleLong (pinframe->origin[1]); - - pspriteframe->up = origin[1]; - pspriteframe->down = origin[1] - height; - pspriteframe->left = origin[0]; - pspriteframe->right = width + origin[0]; - - memcpy (&pspriteframe->pixels[0], (byte *) (pinframe + 1), size); - - return (void *) ((byte *) pinframe + sizeof (dspriteframe_t) + size); }