diff --git a/examples/gpu/source/main.c b/examples/gpu/source/main.c index a045fe3..71a9212 100644 --- a/examples/gpu/source/main.c +++ b/examples/gpu/source/main.c @@ -171,7 +171,8 @@ void renderFrame() 128, //texture width 128, //texture height GPU_TEXTURE_MAG_FILTER(GPU_NEAREST) | GPU_TEXTURE_MIN_FILTER(GPU_NEAREST), //texture params - GPU_RGBA8 //texture pixel format + GPU_RGBA8, //texture pixel format + 0x00000000 // not using GPU_CLAMP_TO_BORDER, so we don't care ); GPU_SetAttributeBuffers( diff --git a/libctru/include/3ds/gpu/gpu.h b/libctru/include/3ds/gpu/gpu.h index a514401..0e43fe5 100644 --- a/libctru/include/3ds/gpu/gpu.h +++ b/libctru/include/3ds/gpu/gpu.h @@ -274,7 +274,11 @@ void GPU_SetBlendingColor(u8 r, u8 g, u8 b, u8 a); void GPU_SetAttributeBuffers(u8 totalAttributes, u32* baseAddress, u64 attributeFormats, u16 attributeMask, u64 attributePermutation, u8 numBuffers, u32 bufferOffsets[], u64 bufferPermutations[], u8 bufferNumAttributes[]); void GPU_SetTextureEnable(GPU_TEXUNIT units); // GPU_TEXUNITx values can be ORed together to enable multiple texture units -void GPU_SetTexture(GPU_TEXUNIT unit, u32* data, u16 width, u16 height, u32 param, GPU_TEXCOLOR colorType); + +/** + * @param borderColor The color used for the border when using the @ref GPU_CLAMP_TO_BORDER wrap mode + */ +void GPU_SetTexture(GPU_TEXUNIT unit, u32* data, u16 width, u16 height, u32 param, GPU_TEXCOLOR colorType, u32 borderColor); void GPU_SetTexEnv(u8 id, u16 rgbSources, u16 alphaSources, u16 rgbOperands, u16 alphaOperands, GPU_COMBINEFUNC rgbCombine, GPU_COMBINEFUNC alphaCombine, u32 constantColor); void GPU_DrawArray(GPU_Primitive_t primitive, u32 n); diff --git a/libctru/include/3ds/gpu/registers.h b/libctru/include/3ds/gpu/registers.h index 89cd378..b08fa2b 100644 --- a/libctru/include/3ds/gpu/registers.h +++ b/libctru/include/3ds/gpu/registers.h @@ -129,7 +129,7 @@ #define GPUREG_007E 0x007E #define GPUREG_007F 0x007F #define GPUREG_TEXUNITS_CONFIG 0x0080 -#define GPUREG_0081 0x0081 +#define GPUREG_TEXUNIT0_BORDER_COLOR 0x0081 #define GPUREG_TEXUNIT0_DIM 0x0082 #define GPUREG_TEXUNIT0_PARAM 0x0083 #define GPUREG_0084 0x0084 @@ -145,7 +145,7 @@ #define GPUREG_TEXUNIT0_TYPE 0x008E #define GPUREG_008F 0x008F #define GPUREG_0090 0x0090 -#define GPUREG_0091 0x0091 +#define GPUREG_TEXUNIT1_BORDER_COLOR 0x0091 #define GPUREG_TEXUNIT1_DIM 0x0092 #define GPUREG_TEXUNIT1_PARAM 0x0093 #define GPUREG_0094 0x0094 @@ -153,7 +153,7 @@ #define GPUREG_TEXUNIT1_TYPE 0x0096 #define GPUREG_0097 0x0097 #define GPUREG_0098 0x0098 -#define GPUREG_0099 0x0099 +#define GPUREG_TEXUNIT2_BORDER_COLOR 0x0099 #define GPUREG_TEXUNIT2_DIM 0x009A #define GPUREG_TEXUNIT2_PARAM 0x009B #define GPUREG_009C 0x009C diff --git a/libctru/source/gpu/gpu.c b/libctru/source/gpu/gpu.c index 455a8bc..869e5bd 100644 --- a/libctru/source/gpu/gpu.c +++ b/libctru/source/gpu/gpu.c @@ -370,11 +370,12 @@ void GPU_SetTextureEnable(GPU_TEXUNIT units) GPUCMD_AddWrite(GPUREG_TEXUNITS_CONFIG, 0x00011000|units); // enables texture units } -void GPU_SetTexture(GPU_TEXUNIT unit, u32* data, u16 width, u16 height, u32 param, GPU_TEXCOLOR colorType) +void GPU_SetTexture(GPU_TEXUNIT unit, u32* data, u16 width, u16 height, u32 param, GPU_TEXCOLOR colorType, u32 borderColor) { switch (unit) { case GPU_TEXUNIT0: + GPUCMD_AddWrite(GPUREG_TEXUNIT0_BORDER_COLOR, borderColor); GPUCMD_AddWrite(GPUREG_TEXUNIT0_TYPE, colorType); GPUCMD_AddWrite(GPUREG_TEXUNIT0_LOC, ((u32)data)>>3); GPUCMD_AddWrite(GPUREG_TEXUNIT0_DIM, (width<<16)|height); @@ -382,6 +383,7 @@ void GPU_SetTexture(GPU_TEXUNIT unit, u32* data, u16 width, u16 height, u32 para break; case GPU_TEXUNIT1: + GPUCMD_AddWrite(GPUREG_TEXUNIT1_BORDER_COLOR, borderColor); GPUCMD_AddWrite(GPUREG_TEXUNIT1_TYPE, colorType); GPUCMD_AddWrite(GPUREG_TEXUNIT1_LOC, ((u32)data)>>3); GPUCMD_AddWrite(GPUREG_TEXUNIT1_DIM, (width<<16)|height); @@ -389,6 +391,7 @@ void GPU_SetTexture(GPU_TEXUNIT unit, u32* data, u16 width, u16 height, u32 para break; case GPU_TEXUNIT2: + GPUCMD_AddWrite(GPUREG_TEXUNIT2_BORDER_COLOR, borderColor); GPUCMD_AddWrite(GPUREG_TEXUNIT2_TYPE, colorType); GPUCMD_AddWrite(GPUREG_TEXUNIT2_LOC, ((u32)data)>>3); GPUCMD_AddWrite(GPUREG_TEXUNIT2_DIM, (width<<16)|height);