mirror of
https://github.com/GRRLIB/GRRLIB.git
synced 2024-11-22 06:52:20 +00:00
Refactoring
This commit is contained in:
parent
44616e89b4
commit
83ed32fad9
8 changed files with 15 additions and 18 deletions
|
@ -421,6 +421,8 @@ void GRRLIB_DrawTorus(f32 r, f32 R, int nsides, int rings, bool filled, u32 col)
|
||||||
* @param col Color of the sphere.
|
* @param col Color of the sphere.
|
||||||
*/
|
*/
|
||||||
void GRRLIB_DrawSphere(f32 r, int lats, int longs, bool filled, u32 col) {
|
void GRRLIB_DrawSphere(f32 r, int lats, int longs, bool filled, u32 col) {
|
||||||
|
const f32 dtheta = 2 * M_PI / longs;
|
||||||
|
|
||||||
for(int i = 0; i <= lats; i++) {
|
for(int i = 0; i <= lats; i++) {
|
||||||
const f32 lat0 = M_PI * (-0.5f + (f32) (i - 1) / lats);
|
const f32 lat0 = M_PI * (-0.5f + (f32) (i - 1) / lats);
|
||||||
const f32 z0 = sinf(lat0);
|
const f32 z0 = sinf(lat0);
|
||||||
|
@ -430,14 +432,11 @@ void GRRLIB_DrawSphere(f32 r, int lats, int longs, bool filled, u32 col) {
|
||||||
const f32 z1 = sinf(lat1);
|
const f32 z1 = sinf(lat1);
|
||||||
const f32 zr1 = cosf(lat1);
|
const f32 zr1 = cosf(lat1);
|
||||||
|
|
||||||
if(filled == true) {
|
GX_Begin((filled == true) ? GX_TRIANGLESTRIP : GX_LINESTRIP,
|
||||||
GX_Begin(GX_TRIANGLESTRIP, GX_VTXFMT0, 2 * (longs + 1));
|
GX_VTXFMT0, 2 * (longs + 1));
|
||||||
}
|
|
||||||
else {
|
|
||||||
GX_Begin(GX_LINESTRIP, GX_VTXFMT0, 2 * (longs + 1));
|
|
||||||
}
|
|
||||||
for(int j = 0; j <= longs; j++) {
|
for(int j = 0; j <= longs; j++) {
|
||||||
const f32 lng = 2 * M_PI * (f32) (j - 1) / longs;
|
const f32 lng = dtheta * (f32) (j - 1);
|
||||||
const f32 x = cosf(lng);
|
const f32 x = cosf(lng);
|
||||||
const f32 y = sinf(lng);
|
const f32 y = sinf(lng);
|
||||||
|
|
||||||
|
|
|
@ -45,7 +45,7 @@ GRRLIB_bytemapFont* GRRLIB_LoadBMF (const u8 my_bmf[] ) {
|
||||||
//short int sizeinner = my_bmf[9];
|
//short int sizeinner = my_bmf[9];
|
||||||
//u8 usedcolors = my_bmf[10];
|
//u8 usedcolors = my_bmf[10];
|
||||||
//u8 highestcolor = my_bmf[11];
|
//u8 highestcolor = my_bmf[11];
|
||||||
u8 nbPalette = my_bmf[16];
|
const u8 nbPalette = my_bmf[16];
|
||||||
const short int numcolpal = 3 * nbPalette;
|
const short int numcolpal = 3 * nbPalette;
|
||||||
fontArray->palette = (u32 *)calloc(nbPalette + 1, sizeof(u32));
|
fontArray->palette = (u32 *)calloc(nbPalette + 1, sizeof(u32));
|
||||||
for (u32 i=0; i < numcolpal; i+=3) {
|
for (u32 i=0; i < numcolpal; i+=3) {
|
||||||
|
|
|
@ -244,7 +244,7 @@ static u8 CalculateFrameRate(void) {
|
||||||
static u8 frameCount = 0;
|
static u8 frameCount = 0;
|
||||||
static u32 lastTime;
|
static u32 lastTime;
|
||||||
static u8 FPS = 0;
|
static u8 FPS = 0;
|
||||||
u32 currentTime = ticks_to_millisecs(gettime());
|
const u32 currentTime = ticks_to_millisecs(gettime());
|
||||||
|
|
||||||
frameCount++;
|
frameCount++;
|
||||||
if(currentTime - lastTime > 1000) {
|
if(currentTime - lastTime > 1000) {
|
||||||
|
|
|
@ -57,7 +57,6 @@ int main() {
|
||||||
u32 wait = TILE_DELAY, direction = TILE_DOWN, direction_new = TILE_DOWN;
|
u32 wait = TILE_DELAY, direction = TILE_DOWN, direction_new = TILE_DOWN;
|
||||||
u8 FPS = 0;
|
u8 FPS = 0;
|
||||||
|
|
||||||
u32 paddown, padheld;
|
|
||||||
guVector triangle[] = {{400,200,0.0f}, {500,400,0.0f}, {300,400,0.0f}};
|
guVector triangle[] = {{400,200,0.0f}, {500,400,0.0f}, {300,400,0.0f}};
|
||||||
u32 trianglecolor[] = {GRRLIB_GREEN, GRRLIB_RED, GRRLIB_BLUE};
|
u32 trianglecolor[] = {GRRLIB_GREEN, GRRLIB_RED, GRRLIB_BLUE};
|
||||||
|
|
||||||
|
@ -91,8 +90,8 @@ int main() {
|
||||||
|
|
||||||
while(1) {
|
while(1) {
|
||||||
PAD_ScanPads();
|
PAD_ScanPads();
|
||||||
paddown = PAD_ButtonsDown(0);
|
const u32 paddown = PAD_ButtonsDown(0);
|
||||||
padheld = PAD_ButtonsHeld(0);
|
const u32 padheld = PAD_ButtonsHeld(0);
|
||||||
|
|
||||||
GRRLIB_FillScreen(GRRLIB_BLACK); // Clear the screen
|
GRRLIB_FillScreen(GRRLIB_BLACK); // Clear the screen
|
||||||
switch(page)
|
switch(page)
|
||||||
|
@ -221,7 +220,7 @@ static u8 CalculateFrameRate(void) {
|
||||||
static u8 frameCount = 0;
|
static u8 frameCount = 0;
|
||||||
static u32 lastTime;
|
static u32 lastTime;
|
||||||
static u8 FPS = 0;
|
static u8 FPS = 0;
|
||||||
u32 currentTime = ticks_to_millisecs(gettime());
|
const u32 currentTime = ticks_to_millisecs(gettime());
|
||||||
|
|
||||||
frameCount++;
|
frameCount++;
|
||||||
if(currentTime - lastTime > 1000) {
|
if(currentTime - lastTime > 1000) {
|
||||||
|
|
|
@ -14,7 +14,6 @@
|
||||||
|
|
||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
u32 paddown;
|
|
||||||
s8 page = 0;
|
s8 page = 0;
|
||||||
|
|
||||||
// Font texture
|
// Font texture
|
||||||
|
@ -115,7 +114,7 @@ int main() {
|
||||||
|
|
||||||
while(1) {
|
while(1) {
|
||||||
PAD_ScanPads();
|
PAD_ScanPads();
|
||||||
paddown = PAD_ButtonsDown(0);
|
const u32 paddown = PAD_ButtonsDown(0);
|
||||||
|
|
||||||
GRRLIB_FillScreen(0xFFFFFFFF);
|
GRRLIB_FillScreen(0xFFFFFFFF);
|
||||||
|
|
||||||
|
|
|
@ -102,7 +102,7 @@ static u8 CalculateFrameRate(void) {
|
||||||
static u8 frameCount = 0;
|
static u8 frameCount = 0;
|
||||||
static u32 lastTime;
|
static u32 lastTime;
|
||||||
static u8 FPS = 0;
|
static u8 FPS = 0;
|
||||||
u32 currentTime = ticks_to_millisecs(gettime());
|
const u32 currentTime = ticks_to_millisecs(gettime());
|
||||||
|
|
||||||
frameCount++;
|
frameCount++;
|
||||||
if(currentTime - lastTime > 1000) {
|
if(currentTime - lastTime > 1000) {
|
||||||
|
|
|
@ -262,7 +262,7 @@ static u8 CalculateFrameRate() {
|
||||||
static u8 frameCount = 0;
|
static u8 frameCount = 0;
|
||||||
static u32 lastTime;
|
static u32 lastTime;
|
||||||
static u8 FPS = 0;
|
static u8 FPS = 0;
|
||||||
u32 currentTime = ticks_to_millisecs(gettime());
|
const u32 currentTime = ticks_to_millisecs(gettime());
|
||||||
|
|
||||||
frameCount++;
|
frameCount++;
|
||||||
if(currentTime - lastTime > 1000) {
|
if(currentTime - lastTime > 1000) {
|
||||||
|
|
|
@ -108,7 +108,7 @@ static u8 CalculateFrameRate(void) {
|
||||||
static u8 frameCount = 0;
|
static u8 frameCount = 0;
|
||||||
static u32 lastTime;
|
static u32 lastTime;
|
||||||
static u8 FPS = 0;
|
static u8 FPS = 0;
|
||||||
u32 currentTime = ticks_to_millisecs(gettime());
|
const u32 currentTime = ticks_to_millisecs(gettime());
|
||||||
|
|
||||||
frameCount++;
|
frameCount++;
|
||||||
if(currentTime - lastTime > 1000) {
|
if(currentTime - lastTime > 1000) {
|
||||||
|
|
Loading…
Reference in a new issue