mirror of
https://github.com/coop-deluxe/sm64coopdx.git
synced 2024-11-25 13:35:12 +00:00
Fixed crash in djui_gfx_render_texture_tile()
This commit is contained in:
parent
07324c5396
commit
5113e9e99c
1 changed files with 16 additions and 0 deletions
|
@ -7,6 +7,7 @@
|
|||
#include "src/pc/gfx/gfx_window_manager_api.h"
|
||||
#include "gfx_dimensions.h"
|
||||
#include "djui_gfx.h"
|
||||
#include "pc/debuglog.h"
|
||||
|
||||
const Gfx dl_djui_display_list_begin[] = {
|
||||
gsSPTextureAddrDjui(1),
|
||||
|
@ -102,7 +103,22 @@ void djui_gfx_render_texture(const u8* texture, u32 w, u32 h, u32 bitSize) {
|
|||
}
|
||||
|
||||
void djui_gfx_render_texture_tile(const u8* texture, u32 w, u32 h, u32 bitSize, u32 tileX, u32 tileY, u32 tileW, u32 tileH) {
|
||||
if (!gDisplayListHead) {
|
||||
LOG_ERROR("Retrieved a null displaylist head");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!texture) {
|
||||
LOG_ERROR("Attempted to render null texture");
|
||||
return;
|
||||
}
|
||||
|
||||
Vtx *vtx = alloc_display_list(sizeof(Vtx) * 4);
|
||||
if (!vtx) {
|
||||
LOG_ERROR("Failed to allocate vertices");
|
||||
return;
|
||||
}
|
||||
|
||||
f32 aspect = tileH ? ((f32)tileW / (f32)tileH) : 1;
|
||||
// I don't know why adding 1 to all of the UVs seems to fix rendering, but it does...
|
||||
vtx[0] = (Vtx) {{{ 0, -1, 0 }, 0, { ( tileX * 512) / w + 1, ((tileY + tileH) * 512) / h }, { 0xff, 0xff, 0xff, 0xff }}};
|
||||
|
|
Loading…
Reference in a new issue