diff --git a/src/video/glalert.c b/src/video/glalert.c index d47620be..2d33dbad 100644 --- a/src/video/glalert.c +++ b/src/video/glalert.c @@ -27,7 +27,7 @@ static GLModel *messageModel = NULL; // ---------------------------------------------------------------------------- static void *_create_alert(void) { - GLModelHUDElement *hudElement = (GLModelHUDElement *)CALLOC(sizeof(GLModelHUDElement), 1); + GLModelHUDElement *hudElement = (GLModelHUDElement *)glhud_createDefault(); if (hudElement) { hudElement->colorScheme = RED_ON_BLACK; hudElement->blackIsTransparent = false; diff --git a/src/video/glhudmodel.c b/src/video/glhudmodel.c index 4cae0b20..092de5e7 100644 --- a/src/video/glhudmodel.c +++ b/src/video/glhudmodel.c @@ -13,7 +13,12 @@ #include "glvideo.h" void *glhud_createDefault(void) { - GLModelHUDElement *hudElement = (GLModelHUDElement *)CALLOC(sizeof(GLModelHUDElement), 1); + return glhud_createCustom(sizeof(GLModelHUDElement)); +} + +void *glhud_createCustom(unsigned int sizeofModel) { + assert(sizeof(GLModelHUDElement) <= sizeofModel); + GLModelHUDElement *hudElement = (GLModelHUDElement *)CALLOC(sizeofModel, 1); if (hudElement) { hudElement->colorScheme = RED_ON_BLACK; } diff --git a/src/video/glhudmodel.h b/src/video/glhudmodel.h index a780d583..9601f3a7 100644 --- a/src/video/glhudmodel.h +++ b/src/video/glhudmodel.h @@ -15,13 +15,15 @@ #include "common.h" #include "video_util/modelUtil.h" +// HUD GLModel is basically just a quad/texture generated from the Apple //e bitmap font + #define HUD_CLASS(CLS, ...) \ MODEL_CLASS(CLS, \ char *tpl; /* ASCII template */ \ unsigned int tplWidth; /* template width */ \ unsigned int tplHeight; /* template height */ \ \ - uint8_t *pixels; /* raw texture/FB data */ \ + uint8_t *pixels; /* raw indexed data */ \ unsigned int pixWidth; /* FB width -- FIXME TODO : this is really the same as GLModel.texWidth */ \ unsigned int pixHeight; /* FB height -- FIXME TODO : this is really the same as GLModel.texHeight */ \ \ @@ -37,6 +39,9 @@ HUD_CLASS(GLModelHUDElement); // default model creation void *glhud_createDefault(void); +// create custom HUD model +void *glhud_createCustom(unsigned int sizeofModel); + // default model setup void glhud_setupDefault(GLModel *parent); diff --git a/src/video/gltouchkbd.c b/src/video/gltouchkbd.c index 54133747..b29b37bb 100644 --- a/src/video/gltouchkbd.c +++ b/src/video/gltouchkbd.c @@ -460,7 +460,7 @@ static void _setup_touchkbd_hud(GLModel *parent) { } static void *_create_touchkbd_hud(void) { - GLModelHUDKeyboard *hudKeyboard = (GLModelHUDKeyboard *)CALLOC(sizeof(GLModelHUDKeyboard), 1); + GLModelHUDKeyboard *hudKeyboard = (GLModelHUDKeyboard *)glhud_createCustom(sizeof(GLModelHUDKeyboard)); if (hudKeyboard) { hudKeyboard->blackIsTransparent = true; hudKeyboard->opaquePixelHalo = true; diff --git a/src/video/gltouchmenu.c b/src/video/gltouchmenu.c index 73654fc9..1870b935 100644 --- a/src/video/gltouchmenu.c +++ b/src/video/gltouchmenu.c @@ -352,7 +352,7 @@ static void _setup_touchmenu(GLModel *parent) { } static void *_create_touchmenu(void) { - GLModelHUDMenu *hudMenu = (GLModelHUDMenu *)CALLOC(sizeof(GLModelHUDMenu), 1); + GLModelHUDMenu *hudMenu = (GLModelHUDMenu *)glhud_createCustom(sizeof(GLModelHUDMenu)); if (hudMenu) { hudMenu->blackIsTransparent = true; hudMenu->opaquePixelHalo = true;