examples: Refactor compressed texture example

Add PNG files that get converted to the binary data used by the NDS ROM.
This commit is contained in:
Antonio Niño Díaz 2024-01-22 02:27:57 +00:00
parent a57af044f4
commit 5fbe47c7fc
17 changed files with 85 additions and 38 deletions

View File

@ -1,14 +1,16 @@
#!/bin/sh
NITRO_ENGINE=$DEVKITPRO/nitro-engine
ASSETS=$NITRO_ENGINE/examples/assets
TOOLS=$NITRO_ENGINE/tools
IMG2DS=$TOOLS/img2ds/img2ds.py
rm -rf data
mkdir -p data
python3 $IMG2DS \
--input $ASSETS/a5pal8.png \
--name a5pal8 \
--output data \
--format A5PAL8
# ptexconv can be obtained here: https://github.com/Garhoogin/ptexconv/
/opt/blocksds/external/ptexconv/ptexconv \
-gt -ob -k FF00FF -v -f tex4x4 \
-o data/grill \
assets/grill.png
/opt/blocksds/external/ptexconv/ptexconv \
-gt -ob -k FF00FF -v -f tex4x4 \
-o data/landscape \
assets/landscape.jpg

Binary file not shown.

After

Width:  |  Height:  |  Size: 27 KiB

View File

@ -0,0 +1,24 @@
Information about the test photo
================================
Unmodified image: T_Grate03_d.tga
https://opengameart.org/content/free-materials-pack-74
License
-------
Copyright (c) 2023 Yughues (https://opengameart.org/users/yughues)
CC-BY-4.0
Creative Commons Attribution 4.0 International
https://creativecommons.org/licenses/by/4.0/legalcode
CC-BY-3.0
Creative Commons Attribution 3.0 Unported
https://creativecommons.org/licenses/by/3.0/legalcode

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

View File

@ -0,0 +1,18 @@
Information about the test photo
================================
Location: Rovinj, Croatia
Date: June 2023
License
-------
Copyright (c) 2023 Antonio Niño Díaz
CC-BY-NC-SA-4.0
Creative Commons Attribution Non Commercial Share Alike 4.0 International
https://creativecommons.org/licenses/by-nc-sa/4.0/legalcode

View File

@ -1 +0,0 @@
ÝË¿Â!Ý  I<fd

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -6,32 +6,36 @@
#include <NEMain.h>
#include "a5pal8_tex_bin.h"
#include "a5pal8_pal_bin.h"
// This has been taken from a libnds example:
//
// https://github.com/devkitPro/nds-examples/tree/6afa09b2054c9f47685514c32873b3905721c9ee/Graphics/3D/Paletted_Cube/data
//
// When img2ds supports compressed textures it will be replaced by a PNG file.
#include "texture10_COMP_pal_bin.h"
#include "texture10_COMP_tex_bin.h"
#include "texture10_COMP_texExt_bin.h"
#include "grill_idx_bin.h"
#include "grill_pal_bin.h"
#include "grill_tex_bin.h"
#include "landscape_idx_bin.h"
#include "landscape_pal_bin.h"
#include "landscape_tex_bin.h"
NE_Material *Material1, *Material2;
NE_Palette *Palette1, *Palette2;
void Draw3DScene(void)
void Draw3DScene1(void)
{
NE_ClearColorSet(RGB15(5, 5, 10), 31, 63);
NE_2DViewInit();
NE_2DDrawTexturedQuad(0, 0,
64, 64,
0, Material2);
NE_2DDrawTexturedQuad(32, 32,
32 + 128, 32 + 128,
0, Material1);
}
void Draw3DScene2(void)
{
NE_ClearColorSet(RGB15(10, 5, 0), 31, 63);
NE_2DViewInit();
NE_2DDrawTexturedQuad(64, 0,
64 + 128, 0 + 128,
0, Material1);
0, Material2);
}
int main(void)
@ -40,8 +44,7 @@ int main(void)
irqSet(IRQ_VBLANK, NE_VBLFunc);
irqSet(IRQ_HBLANK, NE_HBLFunc);
// Init 3D mode
NE_Init3D();
NE_InitDual3D();
// Allocate objects
Material1 = NE_MaterialCreate();
@ -50,23 +53,24 @@ int main(void)
Palette2 = NE_PaletteCreate();
NE_MaterialTex4x4Load(Material1, 128, 128, NE_TEXGEN_TEXCOORD,
(u8 *)texture10_COMP_tex_bin,
(u8 *)texture10_COMP_texExt_bin);
NE_PaletteLoadSize(Palette1, (u16 *)texture10_COMP_pal_bin,
texture10_COMP_pal_bin_size, NE_TEX4X4);
(u8 *)grill_tex_bin,
(u8 *)grill_idx_bin);
NE_PaletteLoadSize(Palette1, (u16 *)grill_pal_bin, grill_pal_bin_size,
NE_TEX4X4);
NE_MaterialSetPalette(Material1, Palette1);
NE_MaterialTexLoad(Material2, NE_A5PAL8, 256, 256, NE_TEXGEN_TEXCOORD,
(u8 *)a5pal8_tex_bin);
NE_PaletteLoadSize(Palette2, (u16 *)a5pal8_pal_bin, a5pal8_pal_bin_size,
NE_A5PAL8);
NE_MaterialTex4x4Load(Material2, 128, 128, NE_TEXGEN_TEXCOORD,
(u8 *)landscape_tex_bin,
(u8 *)landscape_idx_bin);
NE_PaletteLoadSize(Palette2, (u16 *)landscape_pal_bin,
landscape_pal_bin_size, NE_TEX4X4);
NE_MaterialSetPalette(Material2, Palette2);
while (1)
{
NE_WaitForVBL(0);
NE_Process(Draw3DScene);
NE_ProcessDual(Draw3DScene1, Draw3DScene2);
}
return 0;