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.master
parent
38f368aa80
commit
46feac7f8f
|
@ -965,19 +965,24 @@ void gs_draw_sprite(gs_texture_t *tex, uint32_t flip, uint32_t width,
|
||||||
float fcx, fcy;
|
float fcx, fcy;
|
||||||
struct gs_vb_data *data;
|
struct gs_vb_data *data;
|
||||||
|
|
||||||
if (!gs_valid_p("gs_draw_sprite", tex))
|
if (tex) {
|
||||||
return;
|
|
||||||
|
|
||||||
if (gs_get_texture_type(tex) != GS_TEXTURE_2D) {
|
if (gs_get_texture_type(tex) != GS_TEXTURE_2D) {
|
||||||
blog(LOG_ERROR, "A sprite must be a 2D texture");
|
blog(LOG_ERROR, "A sprite must be a 2D texture");
|
||||||
return;
|
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);
|
fcx = width ? (float)width : (float)gs_texture_get_width(tex);
|
||||||
fcy = height ? (float)height : (float)gs_texture_get_height(tex);
|
fcy = height ? (float)height : (float)gs_texture_get_height(tex);
|
||||||
|
|
||||||
data = gs_vertexbuffer_get_data(graphics->sprite_buffer);
|
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);
|
build_sprite_rect(data, tex, fcx, fcy, flip);
|
||||||
else
|
else
|
||||||
build_sprite_norm(data, fcx, fcy, flip);
|
build_sprite_norm(data, fcx, fcy, flip);
|
||||||
|
|
Loading…
Reference in New Issue