From 46feac7f8fb9d4275e53050edf1209aa3986234c Mon Sep 17 00:00:00 2001 From: jp9000 Date: Sun, 3 Jan 2016 15:50:57 -0800 Subject: [PATCH] libobs/graphics: Allow gs_render_sprite use without texture Allows gs_render_sprite to be used without a texture as long as cx/cy are set. There's no reason why it shouldn't be able to do this. --- libobs/graphics/graphics.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/libobs/graphics/graphics.c b/libobs/graphics/graphics.c index 1a8441013..ffbf89e50 100644 --- a/libobs/graphics/graphics.c +++ b/libobs/graphics/graphics.c @@ -965,19 +965,24 @@ void gs_draw_sprite(gs_texture_t *tex, uint32_t flip, uint32_t width, float fcx, fcy; struct gs_vb_data *data; - if (!gs_valid_p("gs_draw_sprite", tex)) - return; - - if (gs_get_texture_type(tex) != GS_TEXTURE_2D) { - blog(LOG_ERROR, "A sprite must be a 2D texture"); - return; + if (tex) { + if (gs_get_texture_type(tex) != GS_TEXTURE_2D) { + blog(LOG_ERROR, "A sprite must be a 2D texture"); + return; + } + } else { + if (!width || !height) { + blog(LOG_ERROR, "A sprite cannot be drawn without " + "a width/height"); + return; + } } fcx = width ? (float)width : (float)gs_texture_get_width(tex); fcy = height ? (float)height : (float)gs_texture_get_height(tex); data = gs_vertexbuffer_get_data(graphics->sprite_buffer); - if (gs_texture_is_rect(tex)) + if (tex && gs_texture_is_rect(tex)) build_sprite_rect(data, tex, fcx, fcy, flip); else build_sprite_norm(data, fcx, fcy, flip);