mirror of https://github.com/mgba-emu/mgba.git
3DS: Use an actual texture format
This commit is contained in:
parent
5a1ec94b02
commit
a263d4718f
|
@ -7,6 +7,7 @@ find_program(BANNERTOOL bannertool)
|
|||
find_program(MAKEROM makerom)
|
||||
find_program(PICASSO picasso)
|
||||
find_program(RAW2C raw2c)
|
||||
find_program(TEX3DS tex3ds)
|
||||
set(STRIP "${cross_prefix_path}strip" CACHE INTERNAL "symbol stripper")
|
||||
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-format" PARENT_SCOPE)
|
||||
|
@ -65,9 +66,15 @@ add_custom_command(OUTPUT ${BINARY_NAME}.bnr
|
|||
COMMAND ${BANNERTOOL} makebanner -ci ${CMAKE_CURRENT_SOURCE_DIR}/banner.cgfx -a ${CMAKE_CURRENT_SOURCE_DIR}/bios.wav -o ${BINARY_NAME}.bnr
|
||||
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/banner.cgfx ${CMAKE_CURRENT_SOURCE_DIR}/bios.wav)
|
||||
|
||||
# tex3ds binaries as of 2.0.1-3 crash if you try to do this
|
||||
#add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/icons.t3x
|
||||
# COMMAND ${TEX3DS} -f rgb5551 -o icons.t3x ${CMAKE_SOURCE_DIR}/res/icons.png
|
||||
# MAIN_DEPENDENCY ${CMAKE_SOURCE_DIR}/res/icons.png
|
||||
# WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
|
||||
|
||||
add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/icons.c
|
||||
COMMAND ${RAW2C} ${CMAKE_SOURCE_DIR}/src/platform/3ds/icons.raw
|
||||
DEPENDS ${CMAKE_SOURCE_DIR}/src/platform/3ds/icons.raw)
|
||||
COMMAND ${RAW2C} ${CMAKE_CURRENT_SOURCE_DIR}/icons.t3x
|
||||
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/icons.t3x)
|
||||
|
||||
add_custom_command(
|
||||
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/uishader.shbin ${CMAKE_CURRENT_BINARY_DIR}/uishader.shbin.h
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
#include <mgba-util/vfs.h>
|
||||
#include "icons.h"
|
||||
|
||||
#include <tex3ds.h>
|
||||
#include "ctr-gpu.h"
|
||||
|
||||
#define FONT_SIZE 15.6f
|
||||
|
@ -44,12 +45,8 @@ struct GUIFont* GUIFontCreate(void) {
|
|||
tex->param = GPU_TEXTURE_MAG_FILTER(GPU_LINEAR) | GPU_TEXTURE_MIN_FILTER(GPU_LINEAR) | GPU_TEXTURE_WRAP_S(GPU_CLAMP_TO_EDGE) | GPU_TEXTURE_WRAP_T(GPU_CLAMP_TO_EDGE);
|
||||
}
|
||||
|
||||
tex = &guiFont->icons;
|
||||
C3D_TexInitVRAM(tex, 256, 64, GPU_RGBA5551);
|
||||
|
||||
GSPGPU_FlushDataCache(icons, icons_size);
|
||||
GX_RequestDma((u32*) icons, tex->data, icons_size);
|
||||
gspWaitForDMA();
|
||||
Tex3DS_Texture t3x = Tex3DS_TextureImport(icons, icons_size, &guiFont->icons, NULL, true);
|
||||
Tex3DS_TextureFree(t3x);
|
||||
|
||||
return guiFont;
|
||||
}
|
||||
|
@ -136,23 +133,28 @@ void GUIFontDrawIcon(const struct GUIFont* font, int x, int y, enum GUIAlignment
|
|||
y -= metric.height;
|
||||
break;
|
||||
}
|
||||
s16 origin = font->icons.height - metric.y - metric.height;
|
||||
|
||||
switch (orient) {
|
||||
case GUI_ORIENT_HMIRROR:
|
||||
ctrAddRectEx(color, x + metric.width, y,
|
||||
-metric.width, metric.height,
|
||||
metric.x, metric.y,
|
||||
ctrAddRectEx(color, x + metric.width, y + metric.height,
|
||||
-metric.width, -metric.height,
|
||||
metric.x, origin,
|
||||
metric.width, metric.height, 0);
|
||||
break;
|
||||
case GUI_ORIENT_VMIRROR:
|
||||
ctrAddRectEx(color, x, y + metric.height,
|
||||
metric.width, -metric.height,
|
||||
metric.x, metric.y,
|
||||
ctrAddRectEx(color, x, y,
|
||||
metric.width, metric.height,
|
||||
metric.x, origin,
|
||||
metric.width, metric.height, 0);
|
||||
break;
|
||||
case GUI_ORIENT_0:
|
||||
default:
|
||||
// TODO: Rotation
|
||||
ctrAddRect(color, x, y, metric.x, metric.y, metric.width, metric.height);
|
||||
ctrAddRectEx(color, x, y + metric.height,
|
||||
metric.width, -metric.height,
|
||||
metric.x, origin,
|
||||
metric.width, metric.height, 0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -163,11 +165,10 @@ void GUIFontDrawIconSize(const struct GUIFont* font, int x, int y, int w, int h,
|
|||
if (icon >= GUI_ICON_MAX) {
|
||||
return;
|
||||
}
|
||||
|
||||
struct GUIIconMetric metric = defaultIconMetrics[icon];
|
||||
ctrAddRectEx(color, x, y,
|
||||
ctrAddRectEx(color, x, y + (h ? h : metric.height),
|
||||
w ? w : metric.width,
|
||||
h ? h : metric.height,
|
||||
metric.x, metric.y,
|
||||
h ? -h : -metric.height,
|
||||
metric.x, font->icons.height - metric.y - metric.height,
|
||||
metric.width, metric.height, 0);
|
||||
}
|
||||
|
|
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue