mirror of
https://github.com/ctruLua/ctruLua.git
synced 2025-10-27 16:39:29 +00:00
Updated the sf2dlib and sftdlib; Added the gfx.color.hex() function; Added the New3DS CPU mode control.
As the color order of the sf2dlib changed, you have to change it in your code, or use the color.hex() function. To fix the problems, just change "0xRRGGBBAA" to "0xAABBGGRR". Also, the shader compiler changed to Picasso, so you'll need it in order to compile. https://github.com/fincs/picasso
This commit is contained in:
parent
0105970ab7
commit
b4d025d602
17 changed files with 205 additions and 131 deletions
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
void sf2d_draw_line(int x0, int y0, int x1, int y1, u32 color)
|
||||
{
|
||||
sf2d_vertex_pos_col *vertices = sf2d_pool_malloc(4 * sizeof(sf2d_vertex_pos_col));
|
||||
sf2d_vertex_pos_col *vertices = sf2d_pool_memalign(4 * sizeof(sf2d_vertex_pos_col), 8);
|
||||
if (!vertices) return;
|
||||
|
||||
vertices[0].position = (sf2d_vector_3f){(float)x0+1.0f, (float)y0+1.0f, SF2D_DEFAULT_DEPTH};
|
||||
|
|
@ -12,12 +12,7 @@ void sf2d_draw_line(int x0, int y0, int x1, int y1, u32 color)
|
|||
vertices[2].position = (sf2d_vector_3f){(float)x1+1.0f, (float)y1+1.0f, SF2D_DEFAULT_DEPTH};
|
||||
vertices[3].position = (sf2d_vector_3f){(float)x1-1.0f, (float)y1-1.0f, SF2D_DEFAULT_DEPTH};
|
||||
|
||||
u8 r = (color>>24) & 0xFF;
|
||||
u8 g = (color>>16) & 0xFF;
|
||||
u8 b = (color>>8) & 0xFF;
|
||||
u8 a = color & 0xFF;
|
||||
|
||||
vertices[0].color = (sf2d_vector_4f){r/255.0f, g/255.0f, b/255.0f, a/255.0f};
|
||||
vertices[0].color = color;
|
||||
vertices[1].color = vertices[0].color;
|
||||
vertices[2].color = vertices[0].color;
|
||||
vertices[3].color = vertices[0].color;
|
||||
|
|
@ -35,7 +30,7 @@ void sf2d_draw_line(int x0, int y0, int x1, int y1, u32 color)
|
|||
GPU_SetAttributeBuffers(
|
||||
2, // number of attributes
|
||||
(u32*)osConvertVirtToPhys((u32)vertices),
|
||||
GPU_ATTRIBFMT(0, 3, GPU_FLOAT) | GPU_ATTRIBFMT(1, 4, GPU_FLOAT),
|
||||
GPU_ATTRIBFMT(0, 3, GPU_FLOAT) | GPU_ATTRIBFMT(1, 4, GPU_UNSIGNED_BYTE),
|
||||
0xFFFC, //0b1100
|
||||
0x10,
|
||||
1, //number of buffers
|
||||
|
|
@ -49,7 +44,7 @@ void sf2d_draw_line(int x0, int y0, int x1, int y1, u32 color)
|
|||
|
||||
void sf2d_draw_rectangle(int x, int y, int w, int h, u32 color)
|
||||
{
|
||||
sf2d_vertex_pos_col *vertices = sf2d_pool_malloc(4 * sizeof(sf2d_vertex_pos_col));
|
||||
sf2d_vertex_pos_col *vertices = sf2d_pool_memalign(4 * sizeof(sf2d_vertex_pos_col), 8);
|
||||
if (!vertices) return;
|
||||
|
||||
vertices[0].position = (sf2d_vector_3f){(float)x, (float)y, SF2D_DEFAULT_DEPTH};
|
||||
|
|
@ -57,12 +52,7 @@ void sf2d_draw_rectangle(int x, int y, int w, int h, u32 color)
|
|||
vertices[2].position = (sf2d_vector_3f){(float)x, (float)y+h, SF2D_DEFAULT_DEPTH};
|
||||
vertices[3].position = (sf2d_vector_3f){(float)x+w, (float)y+h, SF2D_DEFAULT_DEPTH};
|
||||
|
||||
u8 r = (color>>24) & 0xFF;
|
||||
u8 g = (color>>16) & 0xFF;
|
||||
u8 b = (color>>8) & 0xFF;
|
||||
u8 a = color & 0xFF;
|
||||
|
||||
vertices[0].color = (sf2d_vector_4f){r/255.0f, g/255.0f, b/255.0f, a/255.0f};
|
||||
vertices[0].color = color;
|
||||
vertices[1].color = vertices[0].color;
|
||||
vertices[2].color = vertices[0].color;
|
||||
vertices[3].color = vertices[0].color;
|
||||
|
|
@ -80,7 +70,7 @@ void sf2d_draw_rectangle(int x, int y, int w, int h, u32 color)
|
|||
GPU_SetAttributeBuffers(
|
||||
2, // number of attributes
|
||||
(u32*)osConvertVirtToPhys((u32)vertices),
|
||||
GPU_ATTRIBFMT(0, 3, GPU_FLOAT) | GPU_ATTRIBFMT(1, 4, GPU_FLOAT),
|
||||
GPU_ATTRIBFMT(0, 3, GPU_FLOAT) | GPU_ATTRIBFMT(1, 4, GPU_UNSIGNED_BYTE),
|
||||
0xFFFC, //0b1100
|
||||
0x10,
|
||||
1, //number of buffers
|
||||
|
|
@ -94,7 +84,7 @@ void sf2d_draw_rectangle(int x, int y, int w, int h, u32 color)
|
|||
|
||||
void sf2d_draw_rectangle_rotate(int x, int y, int w, int h, u32 color, float rad)
|
||||
{
|
||||
sf2d_vertex_pos_col *vertices = sf2d_pool_malloc(4 * sizeof(sf2d_vertex_pos_col));
|
||||
sf2d_vertex_pos_col *vertices = sf2d_pool_memalign(4 * sizeof(sf2d_vertex_pos_col), 8);
|
||||
if (!vertices) return;
|
||||
|
||||
int w2 = w/2.0f;
|
||||
|
|
@ -105,12 +95,7 @@ void sf2d_draw_rectangle_rotate(int x, int y, int w, int h, u32 color, float rad
|
|||
vertices[2].position = (sf2d_vector_3f){(float)-w2, (float) h2, SF2D_DEFAULT_DEPTH};
|
||||
vertices[3].position = (sf2d_vector_3f){(float) w2, (float) h2, SF2D_DEFAULT_DEPTH};
|
||||
|
||||
u8 r = (color>>24) & 0xFF;
|
||||
u8 g = (color>>16) & 0xFF;
|
||||
u8 b = (color>>8) & 0xFF;
|
||||
u8 a = color & 0xFF;
|
||||
|
||||
vertices[0].color = (sf2d_vector_4f){r/255.0f, g/255.0f, b/255.0f, a/255.0f};
|
||||
vertices[0].color = color;
|
||||
vertices[1].color = vertices[0].color;
|
||||
vertices[2].color = vertices[0].color;
|
||||
vertices[3].color = vertices[0].color;
|
||||
|
|
@ -138,7 +123,7 @@ void sf2d_draw_rectangle_rotate(int x, int y, int w, int h, u32 color, float rad
|
|||
GPU_SetAttributeBuffers(
|
||||
2, // number of attributes
|
||||
(u32*)osConvertVirtToPhys((u32)vertices),
|
||||
GPU_ATTRIBFMT(0, 3, GPU_FLOAT) | GPU_ATTRIBFMT(1, 4, GPU_FLOAT),
|
||||
GPU_ATTRIBFMT(0, 3, GPU_FLOAT) | GPU_ATTRIBFMT(1, 4, GPU_UNSIGNED_BYTE),
|
||||
0xFFFC, //0b1100
|
||||
0x10,
|
||||
1, //number of buffers
|
||||
|
|
@ -153,17 +138,11 @@ void sf2d_draw_rectangle_rotate(int x, int y, int w, int h, u32 color, float rad
|
|||
void sf2d_draw_fill_circle(int x, int y, int radius, u32 color)
|
||||
{
|
||||
static const int num_segments = 100;
|
||||
sf2d_vertex_pos_col *vertices = sf2d_pool_malloc((num_segments + 2) * sizeof(sf2d_vertex_pos_col));
|
||||
sf2d_vertex_pos_col *vertices = sf2d_pool_memalign((num_segments + 2) * sizeof(sf2d_vertex_pos_col), 8);
|
||||
if (!vertices) return;
|
||||
|
||||
vertices[0].position = (sf2d_vector_3f){(float)x, (float)y, SF2D_DEFAULT_DEPTH};
|
||||
|
||||
u8 r = (color>>24) & 0xFF;
|
||||
u8 g = (color>>16) & 0xFF;
|
||||
u8 b = (color>>8) & 0xFF;
|
||||
u8 a = color & 0xFF;
|
||||
|
||||
vertices[0].color = (sf2d_vector_4f){r/255.0f, g/255.0f, b/255.0f, a/255.0f};
|
||||
vertices[0].color = color;
|
||||
|
||||
float theta = 2 * M_PI / (float)num_segments;
|
||||
float c = cosf(theta);
|
||||
|
|
@ -199,7 +178,7 @@ void sf2d_draw_fill_circle(int x, int y, int radius, u32 color)
|
|||
GPU_SetAttributeBuffers(
|
||||
2, // number of attributes
|
||||
(u32*)osConvertVirtToPhys((u32)vertices),
|
||||
GPU_ATTRIBFMT(0, 3, GPU_FLOAT) | GPU_ATTRIBFMT(1, 4, GPU_FLOAT),
|
||||
GPU_ATTRIBFMT(0, 3, GPU_FLOAT) | GPU_ATTRIBFMT(1, 4, GPU_UNSIGNED_BYTE),
|
||||
0xFFFC, //0b1100
|
||||
0x10,
|
||||
1, //number of buffers
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue