mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-10 15:22:04 +00:00
Add functions to create/destroy qpics.
The creation uses raw 8-bit data (and the system palette). Destroying a qpic loaded via other means will probably produce nasal demons.
This commit is contained in:
parent
2b6adaa2d4
commit
bc2aca53c3
5 changed files with 93 additions and 4 deletions
|
@ -183,6 +183,22 @@ qpic_t *Draw_CachePic (const char *path, qboolean alpha);
|
||||||
*/
|
*/
|
||||||
void Draw_UncachePic (const char *path);
|
void Draw_UncachePic (const char *path);
|
||||||
|
|
||||||
|
/** Create a qpic from raw data.
|
||||||
|
|
||||||
|
\param width The width of the pic.
|
||||||
|
\param height The height of the pic.
|
||||||
|
\param data The raw data bytes. The system palette will be used for
|
||||||
|
colors.
|
||||||
|
\return pointer qpic data.
|
||||||
|
*/
|
||||||
|
qpic_t *Draw_MakePic (int width, int height, const byte *data);
|
||||||
|
|
||||||
|
/** Destroy a qpic created by Draw_MakePic.
|
||||||
|
|
||||||
|
\param pic The qpic to destory.
|
||||||
|
*/
|
||||||
|
void Draw_DestroyPic (qpic_t *pic);
|
||||||
|
|
||||||
/** Load a qpic from gfx.wad.
|
/** Load a qpic from gfx.wad.
|
||||||
\param name name of the was lump to load
|
\param name name of the was lump to load
|
||||||
\return pointer qpic data.
|
\return pointer qpic data.
|
||||||
|
|
|
@ -150,6 +150,27 @@ Draw_InitText (void)
|
||||||
tVAindices[i] = i;
|
tVAindices[i] = i;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
VISIBLE qpic_t *
|
||||||
|
Draw_MakePic (int width, int height, const byte *data)
|
||||||
|
{
|
||||||
|
glpic_t *gl;
|
||||||
|
qpic_t *pic;
|
||||||
|
|
||||||
|
pic = malloc (field_offset (qpic_t, data[sizeof (glpic_t)]));
|
||||||
|
pic->width = width;
|
||||||
|
pic->height = height;
|
||||||
|
gl = (glpic_t *) pic->data;
|
||||||
|
gl->texnum = GL_LoadTexture ("", width, height, data, false, true, 1);
|
||||||
|
return pic;
|
||||||
|
}
|
||||||
|
|
||||||
|
VISIBLE void
|
||||||
|
Draw_DestroyPic (qpic_t *pic)
|
||||||
|
{
|
||||||
|
//FIXME gl texture management sucks
|
||||||
|
free (pic);
|
||||||
|
}
|
||||||
|
|
||||||
VISIBLE qpic_t *
|
VISIBLE qpic_t *
|
||||||
Draw_PicFromWad (const char *name)
|
Draw_PicFromWad (const char *name)
|
||||||
{
|
{
|
||||||
|
|
|
@ -272,6 +272,18 @@ draw_pic (int x, int y, int w, int h, qpic_t *pic,
|
||||||
qfglDisableVertexAttribArray (quake_icon.vertex.location);
|
qfglDisableVertexAttribArray (quake_icon.vertex.location);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
VISIBLE qpic_t *
|
||||||
|
Draw_MakePic (int width, int height, const byte *data)
|
||||||
|
{
|
||||||
|
return pic_data (0, width, height, data);
|
||||||
|
}
|
||||||
|
|
||||||
|
VISIBLE void
|
||||||
|
Draw_DestroyPic (qpic_t *pic)
|
||||||
|
{
|
||||||
|
pic_free (pic);
|
||||||
|
}
|
||||||
|
|
||||||
VISIBLE qpic_t *
|
VISIBLE qpic_t *
|
||||||
Draw_PicFromWad (const char *name)
|
Draw_PicFromWad (const char *name)
|
||||||
{
|
{
|
||||||
|
|
|
@ -28,8 +28,7 @@
|
||||||
# include "config.h"
|
# include "config.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static __attribute__ ((used)) const char rcsid[] =
|
static __attribute__ ((used)) const char rcsid[] = "$Id$";
|
||||||
"$Id$";
|
|
||||||
|
|
||||||
#ifdef HAVE_STRING_H
|
#ifdef HAVE_STRING_H
|
||||||
# include <string.h>
|
# include <string.h>
|
||||||
|
@ -38,6 +37,8 @@ static __attribute__ ((used)) const char rcsid[] =
|
||||||
# include <strings.h>
|
# include <strings.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
#include "QF/cvar.h"
|
#include "QF/cvar.h"
|
||||||
#include "QF/draw.h"
|
#include "QF/draw.h"
|
||||||
#include "QF/quakefs.h"
|
#include "QF/quakefs.h"
|
||||||
|
@ -94,6 +95,25 @@ int numcachepics;
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
|
|
||||||
|
VISIBLE qpic_t *
|
||||||
|
Draw_MakePic (int width, int height, const byte *data)
|
||||||
|
{
|
||||||
|
qpic_t *pic;
|
||||||
|
int size = width * height;
|
||||||
|
|
||||||
|
pic = malloc (field_offset (qpic_t, data[size]));
|
||||||
|
pic->width = width;
|
||||||
|
pic->height = height;
|
||||||
|
memcpy (pic->data, data, size);
|
||||||
|
return pic;
|
||||||
|
}
|
||||||
|
|
||||||
|
VISIBLE void
|
||||||
|
Draw_DestroyPic (qpic_t *pic)
|
||||||
|
{
|
||||||
|
free (pic);
|
||||||
|
}
|
||||||
|
|
||||||
VISIBLE qpic_t *
|
VISIBLE qpic_t *
|
||||||
Draw_PicFromWad (const char *name)
|
Draw_PicFromWad (const char *name)
|
||||||
{
|
{
|
||||||
|
|
|
@ -28,8 +28,7 @@
|
||||||
# include "config.h"
|
# include "config.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static __attribute__ ((used)) const char rcsid[] =
|
static __attribute__ ((used)) const char rcsid[] = "$Id$";
|
||||||
"$Id$";
|
|
||||||
|
|
||||||
#ifdef HAVE_STRING_H
|
#ifdef HAVE_STRING_H
|
||||||
# include <string.h>
|
# include <string.h>
|
||||||
|
@ -38,6 +37,8 @@ static __attribute__ ((used)) const char rcsid[] =
|
||||||
# include <strings.h>
|
# include <strings.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
#include "QF/cvar.h"
|
#include "QF/cvar.h"
|
||||||
#include "QF/draw.h"
|
#include "QF/draw.h"
|
||||||
#include "QF/quakefs.h"
|
#include "QF/quakefs.h"
|
||||||
|
@ -94,6 +95,25 @@ int numcachepics;
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
|
|
||||||
|
VISIBLE qpic_t *
|
||||||
|
Draw_MakePic (int width, int height, const byte *data)
|
||||||
|
{
|
||||||
|
qpic_t *pic;
|
||||||
|
int size = width * height;
|
||||||
|
|
||||||
|
pic = malloc (field_offset (qpic_t, data[size]));
|
||||||
|
pic->width = width;
|
||||||
|
pic->height = height;
|
||||||
|
memcpy (pic->data, data, size);
|
||||||
|
return pic;
|
||||||
|
}
|
||||||
|
|
||||||
|
VISIBLE void
|
||||||
|
Draw_DestroyPic (qpic_t *pic)
|
||||||
|
{
|
||||||
|
free (pic);
|
||||||
|
}
|
||||||
|
|
||||||
VISIBLE qpic_t *
|
VISIBLE qpic_t *
|
||||||
Draw_PicFromWad (const char *name)
|
Draw_PicFromWad (const char *name)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue