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
This commit is contained in:
Bill Currie 2001-11-22 05:31:44 +00:00
parent 84bb78abe4
commit bd0ac4a38a
4 changed files with 48 additions and 85 deletions

View File

@ -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);

View File

@ -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);
}

View File

@ -30,6 +30,12 @@ static const char rcsid[] =
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#ifdef HAVE_STRING_H
# include <string.h>
#endif
#ifdef HAVE_STRINGS_H
# include <strings.h>
#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;

View File

@ -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 <string.h>
#endif
#ifdef HAVE_STRINGS_H
# include <strings.h>
#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);
}