diff --git a/include/QF/draw.h b/include/QF/draw.h index 1a62533e4..f7bd86416 100644 --- a/include/QF/draw.h +++ b/include/QF/draw.h @@ -183,6 +183,22 @@ qpic_t *Draw_CachePic (const char *path, qboolean alpha); */ 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. \param name name of the was lump to load \return pointer qpic data. diff --git a/libs/video/renderer/gl/gl_draw.c b/libs/video/renderer/gl/gl_draw.c index a7d4ae713..9eda9a59c 100644 --- a/libs/video/renderer/gl/gl_draw.c +++ b/libs/video/renderer/gl/gl_draw.c @@ -150,6 +150,27 @@ Draw_InitText (void) 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 * Draw_PicFromWad (const char *name) { diff --git a/libs/video/renderer/glsl/glsl_draw.c b/libs/video/renderer/glsl/glsl_draw.c index 441554bdc..17a43d9c7 100644 --- a/libs/video/renderer/glsl/glsl_draw.c +++ b/libs/video/renderer/glsl/glsl_draw.c @@ -272,6 +272,18 @@ draw_pic (int x, int y, int w, int h, qpic_t *pic, 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 * Draw_PicFromWad (const char *name) { diff --git a/libs/video/renderer/sw/draw.c b/libs/video/renderer/sw/draw.c index ba08573c7..0d79e223f 100644 --- a/libs/video/renderer/sw/draw.c +++ b/libs/video/renderer/sw/draw.c @@ -28,8 +28,7 @@ # include "config.h" #endif -static __attribute__ ((used)) const char rcsid[] = - "$Id$"; +static __attribute__ ((used)) const char rcsid[] = "$Id$"; #ifdef HAVE_STRING_H # include @@ -38,6 +37,8 @@ static __attribute__ ((used)) const char rcsid[] = # include #endif +#include + #include "QF/cvar.h" #include "QF/draw.h" #include "QF/quakefs.h" @@ -94,6 +95,25 @@ int numcachepics; } 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 * Draw_PicFromWad (const char *name) { diff --git a/libs/video/renderer/sw32/draw.c b/libs/video/renderer/sw32/draw.c index 4325ab5ca..0b71ea9ce 100644 --- a/libs/video/renderer/sw32/draw.c +++ b/libs/video/renderer/sw32/draw.c @@ -28,8 +28,7 @@ # include "config.h" #endif -static __attribute__ ((used)) const char rcsid[] = - "$Id$"; +static __attribute__ ((used)) const char rcsid[] = "$Id$"; #ifdef HAVE_STRING_H # include @@ -38,6 +37,8 @@ static __attribute__ ((used)) const char rcsid[] = # include #endif +#include + #include "QF/cvar.h" #include "QF/draw.h" #include "QF/quakefs.h" @@ -94,6 +95,25 @@ int numcachepics; } 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 * Draw_PicFromWad (const char *name) {