From 8e543b264d0f11f90cefd58ba407ca1ec041d413 Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Wed, 28 Mar 2001 07:37:14 +0000 Subject: [PATCH] compat.h: add defines for offsetof and varsizeof (could do with a better name. one possibility is varcalcsize). mdl_sprite.h: initial stab at the shared sprite model loader. The gl texture is NOT created but everything should be in a sane state to do so. --- include/compat.h | 6 ++++ include/mdl_sprite.h | 66 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 72 insertions(+) create mode 100644 include/mdl_sprite.h diff --git a/include/compat.h b/include/compat.h index 71b9353ff..65f7158ef 100644 --- a/include/compat.h +++ b/include/compat.h @@ -88,4 +88,10 @@ extern int vsnprintf(char *s, size_t maxlen, const char *format, va_list arg); # define strncaseequal(a,b,c) (strncasecmp (a, b, c) == 0) #endif +#if !defined(offsetof) +# define offsetof(t,f) ((size_t)&((t *)0)->f) +#endif + +#define varsizeof(t,f,c) ((size_t)offsetof(t,f[c])) + #endif // __compat_h diff --git a/include/mdl_sprite.h b/include/mdl_sprite.h new file mode 100644 index 000000000..96607dc7f --- /dev/null +++ b/include/mdl_sprite.h @@ -0,0 +1,66 @@ +/* + mdl_sprit.h + + sprite model structures + + Copyright (C) 1996-1997 Id Software, Inc. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + + See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to: + + Free Software Foundation, Inc. + 59 Temple Place - Suite 330 + Boston, MA 02111-1307, USA + + $Id$ +*/ + +#ifndef __mdl_sprite_h +#define __mdl_sprite_h + +#include "qtypes.h" +#include "spritegn.h" + +// FIXME: shorten these? +typedef struct mspriteframe_s +{ + float up, down, left, right; + int gl_texturenum; + struct tex_s *texture; +} mspriteframe_t; + +typedef struct +{ + int numframes; + float *intervals; + mspriteframe_t *frames[1]; +} mspritegroup_t; + +typedef struct +{ + spriteframetype_t type; + mspriteframe_t *frameptr; +} mspriteframedesc_t; + +typedef struct +{ + int type; + int maxwidth; + int maxheight; + int numframes; + float beamlength; + mspriteframedesc_t frames[1]; +} msprite_t; + +#endif // __mdl_sprite_h