From a204c0def7f59486b1a73cbd32674ec2349843da Mon Sep 17 00:00:00 2001 From: Lectem Date: Wed, 8 Jul 2015 00:16:00 +0200 Subject: [PATCH] added texture border color --- examples/gpu/source/main.c | 3 +-- libctru/include/3ds/gpu/gpu.h | 5 ++++- libctru/source/gpu/gpu.c | 23 +++++++++++++++++++---- 3 files changed, 24 insertions(+), 7 deletions(-) diff --git a/examples/gpu/source/main.c b/examples/gpu/source/main.c index 71a9212..a045fe3 100644 --- a/examples/gpu/source/main.c +++ b/examples/gpu/source/main.c @@ -171,8 +171,7 @@ 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 - 0x00000000 // not using GPU_CLAMP_TO_BORDER, so we don't care + GPU_RGBA8 //texture pixel format ); GPU_SetAttributeBuffers( diff --git a/libctru/include/3ds/gpu/gpu.h b/libctru/include/3ds/gpu/gpu.h index 0e43fe5..dc99f54 100644 --- a/libctru/include/3ds/gpu/gpu.h +++ b/libctru/include/3ds/gpu/gpu.h @@ -275,10 +275,13 @@ void GPU_SetAttributeBuffers(u8 totalAttributes, u32* baseAddress, u64 attribute 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_SetTextureBorderColor(GPU_TEXUNIT unit,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/source/gpu/gpu.c b/libctru/source/gpu/gpu.c index 869e5bd..49d5809 100644 --- a/libctru/source/gpu/gpu.c +++ b/libctru/source/gpu/gpu.c @@ -370,12 +370,11 @@ 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, u32 borderColor) +void GPU_SetTexture(GPU_TEXUNIT unit, u32* data, u16 width, u16 height, u32 param, GPU_TEXCOLOR colorType) { 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); @@ -383,7 +382,6 @@ 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); @@ -391,7 +389,6 @@ 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); @@ -400,6 +397,24 @@ void GPU_SetTexture(GPU_TEXUNIT unit, u32* data, u16 width, u16 height, u32 para } } +void GPU_SetTextureBorderColor(GPU_TEXUNIT unit,u32 borderColor) +{ + switch (unit) + { + case GPU_TEXUNIT0: + GPUCMD_AddWrite(GPUREG_TEXUNIT0_BORDER_COLOR, borderColor); + break; + + case GPU_TEXUNIT1: + GPUCMD_AddWrite(GPUREG_TEXUNIT1_BORDER_COLOR, borderColor); + break; + + case GPU_TEXUNIT2: + GPUCMD_AddWrite(GPUREG_TEXUNIT2_BORDER_COLOR, borderColor); + break; + } +} + const u8 GPU_FORMATSIZE[4]={1,1,2,4}; void GPU_SetAttributeBuffers(u8 totalAttributes, u32* baseAddress, u64 attributeFormats, u16 attributeMask, u64 attributePermutation, u8 numBuffers, u32 bufferOffsets[], u64 bufferPermutations[], u8 bufferNumAttributes[])