mirror of
https://github.com/GRRLIB/GRRLIB.git
synced 2024-12-22 10:29:20 +00:00
commit
3050dba256
26 changed files with 331 additions and 382 deletions
|
@ -7,6 +7,7 @@ All notable changes to this project will be documented in this file.
|
|||
- Fixed compatibility issues with devkitPPC release 39.
|
||||
- Added `GRRLIB_LoadTTFFromFile()` to load a TTF from a file.
|
||||
- Added `GRRLIB_Ellipse()` to draw an ellipse.
|
||||
- Changed function arguments types in a few functions.
|
||||
- Fixed documentation for `GRRLIB_Camera3dSettings()`, `GRRLIB_Screen2Texture()` and `GRRLIB_CompoEnd()`.
|
||||
|
||||
## [4.4.1][] - 2021-03-05
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*------------------------------------------------------------------------------
|
||||
Copyright (c) 2009-2021 The GRRLIB Team
|
||||
Copyright (c) 2009-2022 The GRRLIB Team
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
@ -26,9 +26,9 @@ THE SOFTWARE.
|
|||
|
||||
// User should not directly modify these
|
||||
Mtx _GRR_view; // Should be static as soon as all light functions needing this var will be in this file ;)
|
||||
static guVector _GRR_cam = {0.0F, 0.0F, 0.0F},
|
||||
_GRR_up = {0.0F, 1.0F, 0.0F},
|
||||
_GRR_look = {0.0F, 0.0F, -100.0F};
|
||||
static guVector _GRR_cam = {0.0f, 0.0f, 0.0f},
|
||||
_GRR_up = {0.0f, 1.0f, 0.0f},
|
||||
_GRR_look = {0.0f, 0.0f, -100.0f};
|
||||
static guVector _GRRaxisx = (guVector){1, 0, 0}; // DO NOT MODIFY!!!
|
||||
static guVector _GRRaxisy = (guVector){0, 1, 0}; // Even at runtime
|
||||
static guVector _GRRaxisz = (guVector){0, 0, 1}; // NOT ever!
|
||||
|
@ -134,7 +134,7 @@ void GRRLIB_2dMode() {
|
|||
GX_LoadProjectionMtx(m, GX_ORTHOGRAPHIC);
|
||||
|
||||
guMtxIdentity(view);
|
||||
guMtxTransApply(view, view, 0, 0, -100.0F);
|
||||
guMtxTransApply(view, view, 0, 0, -100.0f);
|
||||
GX_LoadPosMtxImm(view, GX_PNMTX0);
|
||||
|
||||
GX_ClearVtxDesc();
|
||||
|
@ -190,7 +190,8 @@ void GRRLIB_ObjectViewScale(f32 scalx, f32 scaly, f32 scalz) {
|
|||
* @param angz z rotation angle of the object.
|
||||
*/
|
||||
void GRRLIB_ObjectViewRotate(f32 angx, f32 angy, f32 angz) {
|
||||
Mtx m, rx,ry,rz;
|
||||
Mtx m;
|
||||
Mtx rx, ry, rz;
|
||||
|
||||
guMtxIdentity(m);
|
||||
guMtxRotAxisDeg(rx, &_GRRaxisx, angx);
|
||||
|
@ -245,19 +246,20 @@ void GRRLIB_ObjectViewEnd(void) {
|
|||
*/
|
||||
void GRRLIB_ObjectView(f32 posx, f32 posy, f32 posz, f32 angx, f32 angy, f32 angz, f32 scalx, f32 scaly, f32 scalz) {
|
||||
Mtx ObjTransformationMtx;
|
||||
Mtx m, rx,ry,rz;
|
||||
Mtx m;
|
||||
Mtx mv, mvi;
|
||||
|
||||
guMtxIdentity(ObjTransformationMtx);
|
||||
|
||||
if((scalx !=1.0f) || (scaly !=1.0f) || (scalz !=1.0f)) {
|
||||
if((scalx != 1.0f) || (scaly != 1.0f) || (scalz != 1.0f)) {
|
||||
guMtxIdentity(m);
|
||||
guMtxScaleApply(m, m, scalx, scaly, scalz);
|
||||
|
||||
guMtxConcat(m, ObjTransformationMtx, ObjTransformationMtx);
|
||||
}
|
||||
|
||||
if((angx !=0.0f) || (angy !=0.0f) || (angz !=0.0f)) {
|
||||
if((angx != 0.0f) || (angy != 0.0f) || (angz != 0.0f)) {
|
||||
Mtx rx, ry, rz;
|
||||
guMtxIdentity(m);
|
||||
guMtxRotAxisDeg(rx, &_GRRaxisx, angx);
|
||||
guMtxRotAxisDeg(ry, &_GRRaxisy, angy);
|
||||
|
@ -268,7 +270,7 @@ void GRRLIB_ObjectView(f32 posx, f32 posy, f32 posz, f32 angx, f32 angy, f32 ang
|
|||
guMtxConcat(m, ObjTransformationMtx, ObjTransformationMtx);
|
||||
}
|
||||
|
||||
if((posx !=0.0f) || (posy !=0.0f) || (posz !=0.0f)) {
|
||||
if((posx != 0.0f) || (posy != 0.0f) || (posz != 0.0f)) {
|
||||
guMtxIdentity(m);
|
||||
guMtxTransApply(m, m, posx, posy, posz);
|
||||
|
||||
|
@ -297,26 +299,27 @@ void GRRLIB_ObjectView(f32 posx, f32 posy, f32 posz, f32 angx, f32 angy, f32 ang
|
|||
*/
|
||||
void GRRLIB_ObjectViewInv(f32 posx, f32 posy, f32 posz, f32 angx, f32 angy, f32 angz, f32 scalx, f32 scaly, f32 scalz) {
|
||||
Mtx ObjTransformationMtx;
|
||||
Mtx m, rx,ry,rz;
|
||||
Mtx m;
|
||||
Mtx mv, mvi;
|
||||
|
||||
guMtxIdentity(ObjTransformationMtx);
|
||||
|
||||
if((scalx !=1.0f) || (scaly !=1.0f) || (scalz !=1.0f)) {
|
||||
if((scalx != 1.0f) || (scaly != 1.0f) || (scalz != 1.0f)) {
|
||||
guMtxIdentity(m);
|
||||
guMtxScaleApply(m, m, scalx, scaly, scalz);
|
||||
|
||||
guMtxConcat(m, ObjTransformationMtx, ObjTransformationMtx);
|
||||
}
|
||||
|
||||
if((posx !=0.0f) || (posy !=0.0f) || (posz !=0.0f)) {
|
||||
if((posx != 0.0f) || (posy != 0.0f) || (posz != 0.0f)) {
|
||||
guMtxIdentity(m);
|
||||
guMtxTransApply(m, m, posx, posy, posz);
|
||||
|
||||
guMtxConcat(m, ObjTransformationMtx, ObjTransformationMtx);
|
||||
}
|
||||
|
||||
if((angx !=0.0f) || (angy !=0.0f) || (angz !=0.0f)) {
|
||||
if((angx != 0.0f) || (angy != 0.0f) || (angz != 0.0f)) {
|
||||
Mtx rx, ry, rz;
|
||||
guMtxIdentity(m);
|
||||
guMtxRotAxisDeg(rx, &_GRRaxisx, angx);
|
||||
guMtxRotAxisDeg(ry, &_GRRaxisy, angy);
|
||||
|
@ -372,35 +375,28 @@ void GRRLIB_SetTexture(GRRLIB_texImg *tex, bool rep) {
|
|||
* @param col Color of the torus.
|
||||
*/
|
||||
void GRRLIB_DrawTorus(f32 r, f32 R, int nsides, int rings, bool filled, u32 col) {
|
||||
int i, j;
|
||||
f32 theta, phi, theta1;
|
||||
f32 cosTheta, sinTheta;
|
||||
f32 cosTheta1, sinTheta1;
|
||||
f32 ringDelta, sideDelta;
|
||||
f32 cosPhi, sinPhi, dist;
|
||||
const f32 ringDelta = 2.0 * M_PI / rings;
|
||||
const f32 sideDelta = 2.0 * M_PI / nsides;
|
||||
|
||||
ringDelta = 2.0 * M_PI / rings;
|
||||
sideDelta = 2.0 * M_PI / nsides;
|
||||
|
||||
theta = 0.0;
|
||||
cosTheta = 1.0;
|
||||
sinTheta = 0.0;
|
||||
for (i = rings - 1; i >= 0; i--) {
|
||||
theta1 = theta + ringDelta;
|
||||
cosTheta1 = cos(theta1);
|
||||
sinTheta1 = sin(theta1);
|
||||
f32 theta = 0.0;
|
||||
f32 cosTheta = 1.0;
|
||||
f32 sinTheta = 0.0;
|
||||
for (int i = rings - 1; i >= 0; i--) {
|
||||
const f32 theta1 = theta + ringDelta;
|
||||
const f32 cosTheta1 = cosf(theta1);
|
||||
const f32 sinTheta1 = sinf(theta1);
|
||||
if(filled == true) {
|
||||
GX_Begin(GX_TRIANGLESTRIP, GX_VTXFMT0, 2*(nsides+1));
|
||||
GX_Begin(GX_TRIANGLESTRIP, GX_VTXFMT0, 2 * (nsides + 1));
|
||||
}
|
||||
else {
|
||||
GX_Begin(GX_LINESTRIP, GX_VTXFMT0, 2*(nsides+1));
|
||||
GX_Begin(GX_LINESTRIP, GX_VTXFMT0, 2 * (nsides + 1));
|
||||
}
|
||||
phi = 0.0;
|
||||
for (j = nsides; j >= 0; j--) {
|
||||
f32 phi = 0.0;
|
||||
for (int j = nsides; j >= 0; j--) {
|
||||
phi += sideDelta;
|
||||
cosPhi = cos(phi);
|
||||
sinPhi = sin(phi);
|
||||
dist = R + r * cosPhi;
|
||||
const f32 cosPhi = cosf(phi);
|
||||
const f32 sinPhi = sinf(phi);
|
||||
const f32 dist = R + r * cosPhi;
|
||||
|
||||
GX_Position3f32(cosTheta1 * dist, -sinTheta1 * dist, r * sinPhi);
|
||||
GX_Normal3f32(cosTheta1 * cosPhi, -sinTheta1 * cosPhi, sinPhi);
|
||||
|
@ -425,29 +421,25 @@ void GRRLIB_DrawTorus(f32 r, f32 R, int nsides, int rings, bool filled, u32 col)
|
|||
* @param col Color of the sphere.
|
||||
*/
|
||||
void GRRLIB_DrawSphere(f32 r, int lats, int longs, bool filled, u32 col) {
|
||||
int i, j;
|
||||
f32 lat0, z0, zr0,
|
||||
lat1, z1, zr1,
|
||||
lng, x, y;
|
||||
for(int i = 0; i <= lats; i++) {
|
||||
const f32 lat0 = M_PI * (-0.5f + (f32) (i - 1) / lats);
|
||||
const f32 z0 = sinf(lat0);
|
||||
const f32 zr0 = cosf(lat0);
|
||||
|
||||
for(i = 0; i <= lats; i++) {
|
||||
lat0 = M_PI * (-0.5F + (f32) (i - 1) / lats);
|
||||
z0 = sin(lat0);
|
||||
zr0 = cos(lat0);
|
||||
const f32 lat1 = M_PI * (-0.5f + (f32) i / lats);
|
||||
const f32 z1 = sinf(lat1);
|
||||
const f32 zr1 = cosf(lat1);
|
||||
|
||||
lat1 = M_PI * (-0.5F + (f32) i / lats);
|
||||
z1 = sin(lat1);
|
||||
zr1 = cos(lat1);
|
||||
if(filled == true) {
|
||||
GX_Begin(GX_TRIANGLESTRIP, GX_VTXFMT0, 2*(longs+1));
|
||||
GX_Begin(GX_TRIANGLESTRIP, GX_VTXFMT0, 2 * (longs + 1));
|
||||
}
|
||||
else {
|
||||
GX_Begin(GX_LINESTRIP, GX_VTXFMT0, 2*(longs+1));
|
||||
GX_Begin(GX_LINESTRIP, GX_VTXFMT0, 2 * (longs + 1));
|
||||
}
|
||||
for(j = 0; j <= longs; j++) {
|
||||
lng = 2 * M_PI * (f32) (j - 1) / longs;
|
||||
x = cos(lng);
|
||||
y = sin(lng);
|
||||
for(int j = 0; j <= longs; j++) {
|
||||
const f32 lng = 2 * M_PI * (f32) (j - 1) / longs;
|
||||
const f32 x = cosf(lng);
|
||||
const f32 y = sinf(lng);
|
||||
|
||||
GX_Position3f32(x * zr0 * r, y * zr0 * r, z0 * r);
|
||||
GX_Normal3f32(x * zr0 * r, y * zr0 * r, z0 * r);
|
||||
|
@ -467,16 +459,16 @@ void GRRLIB_DrawSphere(f32 r, int lats, int longs, bool filled, u32 col) {
|
|||
* @param col Color of the cube.
|
||||
*/
|
||||
void GRRLIB_DrawCube(f32 size, bool filled, u32 col) {
|
||||
static f32 n[6][3] =
|
||||
static const f32 normal[6][3] =
|
||||
{
|
||||
{-1.0, 0.0, 0.0},
|
||||
{0.0, 1.0, 0.0},
|
||||
{1.0, 0.0, 0.0},
|
||||
{0.0, -1.0, 0.0},
|
||||
{0.0, 0.0, 1.0},
|
||||
{0.0, 0.0, -1.0}
|
||||
{-1.0f, 0.0f, 0.0f},
|
||||
{0.0f, 1.0f, 0.0f},
|
||||
{1.0f, 0.0f, 0.0f},
|
||||
{0.0f, -1.0f, 0.0f},
|
||||
{0.0f, 0.0f, 1.0f},
|
||||
{0.0f, 0.0f, -1.0f}
|
||||
};
|
||||
static int faces[6][4] =
|
||||
static const u8 faces[6][4] =
|
||||
{
|
||||
{0, 1, 2, 3},
|
||||
{3, 2, 6, 7},
|
||||
|
@ -487,14 +479,14 @@ void GRRLIB_DrawCube(f32 size, bool filled, u32 col) {
|
|||
};
|
||||
f32 v[8][3];
|
||||
|
||||
v[0][0] = v[1][0] = v[2][0] = v[3][0] = -size / 2;
|
||||
v[4][0] = v[5][0] = v[6][0] = v[7][0] = size / 2;
|
||||
v[0][1] = v[1][1] = v[4][1] = v[5][1] = -size / 2;
|
||||
v[2][1] = v[3][1] = v[6][1] = v[7][1] = size / 2;
|
||||
v[0][2] = v[3][2] = v[4][2] = v[7][2] = -size / 2;
|
||||
v[1][2] = v[2][2] = v[5][2] = v[6][2] = size / 2;
|
||||
v[0][0] = v[1][0] = v[2][0] = v[3][0] = -size / 2.0f;
|
||||
v[4][0] = v[5][0] = v[6][0] = v[7][0] = size / 2.0f;
|
||||
v[0][1] = v[1][1] = v[4][1] = v[5][1] = -size / 2.0f;
|
||||
v[2][1] = v[3][1] = v[6][1] = v[7][1] = size / 2.0f;
|
||||
v[0][2] = v[3][2] = v[4][2] = v[7][2] = -size / 2.0f;
|
||||
v[1][2] = v[2][2] = v[5][2] = v[6][2] = size / 2.0f;
|
||||
|
||||
for (int i = 5; i >= 0; i--) {
|
||||
for (s8 i = 5; i >= 0; i--) {
|
||||
if(filled == true) {
|
||||
GX_Begin(GX_QUADS, GX_VTXFMT0, 4);
|
||||
}
|
||||
|
@ -502,20 +494,20 @@ void GRRLIB_DrawCube(f32 size, bool filled, u32 col) {
|
|||
GX_Begin(GX_LINESTRIP, GX_VTXFMT0, 5);
|
||||
}
|
||||
GX_Position3f32(v[faces[i][0]][0], v[faces[i][0]][1], v[faces[i][0]][2] );
|
||||
GX_Normal3f32(n[i][0], n[i][1], n[i][2]);
|
||||
GX_Normal3f32(normal[i][0], normal[i][1], normal[i][2]);
|
||||
GX_Color1u32(col);
|
||||
GX_Position3f32(v[faces[i][1]][0], v[faces[i][1]][1], v[faces[i][1]][2]);
|
||||
GX_Normal3f32(n[i][0], n[i][1], n[i][2]);
|
||||
GX_Normal3f32(normal[i][0], normal[i][1], normal[i][2]);
|
||||
GX_Color1u32(col);
|
||||
GX_Position3f32(v[faces[i][2]][0], v[faces[i][2]][1], v[faces[i][2]][2]);
|
||||
GX_Normal3f32(n[i][0], n[i][1], n[i][2]);
|
||||
GX_Normal3f32(normal[i][0], normal[i][1], normal[i][2]);
|
||||
GX_Color1u32(col);
|
||||
GX_Position3f32(v[faces[i][3]][0], v[faces[i][3]][1], v[faces[i][3]][2]);
|
||||
GX_Normal3f32(n[i][0], n[i][1], n[i][2]);
|
||||
GX_Normal3f32(normal[i][0], normal[i][1], normal[i][2]);
|
||||
GX_Color1u32(col);
|
||||
if(filled == false) {
|
||||
GX_Position3f32(v[faces[i][0]][0], v[faces[i][0]][1], v[faces[i][0]][2]);
|
||||
GX_Normal3f32(n[i][0], n[i][1], n[i][2]);
|
||||
GX_Normal3f32(normal[i][0], normal[i][1], normal[i][2]);
|
||||
GX_Color1u32(col);
|
||||
}
|
||||
GX_End();
|
||||
|
@ -530,19 +522,16 @@ void GRRLIB_DrawCube(f32 size, bool filled, u32 col) {
|
|||
* @param filled Wired or not.
|
||||
* @param col Color of the cylinder.
|
||||
*/
|
||||
void GRRLIB_DrawCylinder(f32 r, f32 h, int d, bool filled, u32 col) {
|
||||
int i;
|
||||
f32 dx, dy;
|
||||
|
||||
void GRRLIB_DrawCylinder(f32 r, f32 h, u16 d, bool filled, u32 col) {
|
||||
if(filled == true) {
|
||||
GX_Begin(GX_TRIANGLESTRIP, GX_VTXFMT0, 2 * (d+1));
|
||||
GX_Begin(GX_TRIANGLESTRIP, GX_VTXFMT0, 2 * (d + 1));
|
||||
}
|
||||
else {
|
||||
GX_Begin(GX_LINESTRIP, GX_VTXFMT0, 2 * (d+1));
|
||||
GX_Begin(GX_LINESTRIP, GX_VTXFMT0, 2 * (d + 1));
|
||||
}
|
||||
for(i = 0; i <= d; i++) {
|
||||
dx = cosf( M_PI * 2.0f * i / d );
|
||||
dy = sinf( M_PI * 2.0f * i / d );
|
||||
for(u16 i = 0; i <= d; i++) {
|
||||
const f32 dx = cosf( M_PI * 2.0f * i / d );
|
||||
const f32 dy = sinf( M_PI * 2.0f * i / d );
|
||||
GX_Position3f32( r * dx, -0.5f * h, r * dy );
|
||||
GX_Normal3f32( dx, 0.0f, dy );
|
||||
GX_Color1u32(col);
|
||||
|
@ -553,15 +542,15 @@ void GRRLIB_DrawCylinder(f32 r, f32 h, int d, bool filled, u32 col) {
|
|||
GX_End();
|
||||
|
||||
if(filled == true) {
|
||||
GX_Begin(GX_TRIANGLEFAN, GX_VTXFMT0, d+2);
|
||||
GX_Begin(GX_TRIANGLEFAN, GX_VTXFMT0, d + 2);
|
||||
}
|
||||
else {
|
||||
GX_Begin(GX_LINESTRIP, GX_VTXFMT0, d+2);
|
||||
GX_Begin(GX_LINESTRIP, GX_VTXFMT0, d + 2);
|
||||
}
|
||||
GX_Position3f32(0.0f, -0.5f * h, 0.0f);
|
||||
GX_Normal3f32(0.0f, -1.0f, 0.0f);
|
||||
GX_Color1u32(col);
|
||||
for(i = 0; i <= d; i++) {
|
||||
for(u16 i = 0; i <= d; i++) {
|
||||
GX_Position3f32( r * cosf( M_PI * 2.0f * i / d ), -0.5f * h, r * sinf( M_PI * 2.0f * i / d ) );
|
||||
GX_Normal3f32(0.0f, -1.0f, 0.0f);
|
||||
GX_Color1u32(col);
|
||||
|
@ -569,15 +558,15 @@ void GRRLIB_DrawCylinder(f32 r, f32 h, int d, bool filled, u32 col) {
|
|||
GX_End();
|
||||
|
||||
if(filled == true) {
|
||||
GX_Begin(GX_TRIANGLEFAN, GX_VTXFMT0, d+2);
|
||||
GX_Begin(GX_TRIANGLEFAN, GX_VTXFMT0, d + 2);
|
||||
}
|
||||
else {
|
||||
GX_Begin(GX_LINESTRIP, GX_VTXFMT0, d+2);
|
||||
GX_Begin(GX_LINESTRIP, GX_VTXFMT0, d + 2);
|
||||
}
|
||||
GX_Position3f32(0.0f, 0.5f * h, 0.0f);
|
||||
GX_Normal3f32(0.0f, 1.0f, 0.0f);
|
||||
GX_Color1u32(col);
|
||||
for(i = 0; i <= d; i++) {
|
||||
for(u16 i = 0; i <= d; i++) {
|
||||
GX_Position3f32( r * cosf( M_PI * 2.0f * i / d ), 0.5f * h, r * sinf( M_PI * 2.0f * i / d ) );
|
||||
GX_Normal3f32(0.0f, 1.0f, 0.0f);
|
||||
GX_Color1u32(col);
|
||||
|
@ -593,19 +582,16 @@ void GRRLIB_DrawCylinder(f32 r, f32 h, int d, bool filled, u32 col) {
|
|||
* @param filled Wired or not.
|
||||
* @param col Color of the cone.
|
||||
*/
|
||||
void GRRLIB_DrawCone(f32 r, f32 h, int d, bool filled, u32 col) {
|
||||
int i;
|
||||
f32 dx, dy;
|
||||
|
||||
void GRRLIB_DrawCone(f32 r, f32 h, u16 d, bool filled, u32 col) {
|
||||
if(filled == true) {
|
||||
GX_Begin(GX_TRIANGLESTRIP, GX_VTXFMT0, 2 * (d+1));
|
||||
GX_Begin(GX_TRIANGLESTRIP, GX_VTXFMT0, 2 * (d + 1));
|
||||
}
|
||||
else {
|
||||
GX_Begin(GX_LINESTRIP, GX_VTXFMT0, 2 * (d+1));
|
||||
GX_Begin(GX_LINESTRIP, GX_VTXFMT0, 2 * (d + 1));
|
||||
}
|
||||
for(i = 0; i <= d; i++) {
|
||||
dx = cosf( M_PI * 2.0f * i / d );
|
||||
dy = sinf( M_PI * 2.0f * i / d );
|
||||
for(u16 i = 0; i <= d; i++) {
|
||||
const f32 dx = cosf( M_PI * 2.0f * i / d );
|
||||
const f32 dy = sinf( M_PI * 2.0f * i / d );
|
||||
GX_Position3f32( 0, -0.5f * h,0);
|
||||
GX_Normal3f32( dx, 0.0f, dy );
|
||||
GX_Color1u32(col);
|
||||
|
@ -616,15 +602,15 @@ void GRRLIB_DrawCone(f32 r, f32 h, int d, bool filled, u32 col) {
|
|||
GX_End();
|
||||
|
||||
if(filled == true) {
|
||||
GX_Begin(GX_TRIANGLEFAN, GX_VTXFMT0, d+2);
|
||||
GX_Begin(GX_TRIANGLEFAN, GX_VTXFMT0, d + 2);
|
||||
}
|
||||
else {
|
||||
GX_Begin(GX_LINESTRIP, GX_VTXFMT0, d+2);
|
||||
GX_Begin(GX_LINESTRIP, GX_VTXFMT0, d + 2);
|
||||
}
|
||||
GX_Position3f32(0.0f, 0.5f * h, 0.0f);
|
||||
GX_Normal3f32(0.0f, 1.0f, 0.0f);
|
||||
GX_Color1u32(col);
|
||||
for(i = 0; i <= d; i++) {
|
||||
for(u16 i = 0; i <= d; i++) {
|
||||
GX_Position3f32( r * cosf( M_PI * 2.0f * i / d ), 0.5f * h, r * sinf( M_PI * 2.0f * i / d ) );
|
||||
GX_Normal3f32(0.0f, 1.0f, 0.0f);
|
||||
GX_Color1u32(col);
|
||||
|
@ -642,12 +628,10 @@ void GRRLIB_DrawCone(f32 r, f32 h, int d, bool filled, u32 col) {
|
|||
* @param col Color in RGBA format.
|
||||
*/
|
||||
void GRRLIB_DrawTessPanel(f32 w, f32 wstep, f32 h, f32 hstep, bool filled, u32 col) {
|
||||
f32 x, y;
|
||||
|
||||
f32 tmpy = h/2.0f;
|
||||
f32 tmpx = w/2.0f;
|
||||
int tmp = ((w/wstep)*2)+2;
|
||||
for ( y = -tmpy; y <= tmpy; y += hstep )
|
||||
const f32 tmpy = h / 2.0f;
|
||||
const f32 tmpx = w / 2.0f;
|
||||
const u16 tmp = ((w / wstep) * 2) + 2;
|
||||
for ( f32 y = -tmpy; y <= tmpy; y += hstep )
|
||||
{
|
||||
if(filled == true) {
|
||||
GX_Begin(GX_TRIANGLESTRIP, GX_VTXFMT0, tmp);
|
||||
|
@ -655,12 +639,12 @@ void GRRLIB_DrawTessPanel(f32 w, f32 wstep, f32 h, f32 hstep, bool filled, u32 c
|
|||
else {
|
||||
GX_Begin(GX_LINESTRIP, GX_VTXFMT0, tmp);
|
||||
}
|
||||
for ( x = -tmpx; x <= tmpx; x += wstep )
|
||||
for ( f32 x = -tmpx; x <= tmpx; x += wstep )
|
||||
{
|
||||
GX_Position3f32( x, y, 0.0f );
|
||||
GX_Normal3f32( 0.0f, 0.0f, 1.0f);
|
||||
GX_Color1u32(col);
|
||||
GX_Position3f32( x, y+hstep, 0.0f );
|
||||
GX_Position3f32( x, y + hstep, 0.0f );
|
||||
GX_Normal3f32( 0.0f, 0.0f, 1.0f);
|
||||
GX_Color1u32(col);
|
||||
}
|
||||
|
@ -712,7 +696,7 @@ void GRRLIB_SetLightDiff(u8 num, guVector pos, f32 distattn, f32 brightness, u32
|
|||
* @param speccolor Specular color in RGBA format.
|
||||
*/
|
||||
void GRRLIB_SetLightSpec(u8 num, guVector dir, f32 shininess, u32 lightcolor, u32 speccolor) {
|
||||
Mtx mr,mv;
|
||||
Mtx mr, mv;
|
||||
GXLightObj MyLight;
|
||||
guVector ldir = {dir.x, dir.y, dir.z};
|
||||
|
||||
|
@ -744,7 +728,7 @@ void GRRLIB_SetLightSpec(u8 num, guVector dir, f32 shininess, u32 lightcolor, u3
|
|||
|
||||
/////////////////////// Define Material and Ambient color and draw object /////////////////////////////////////
|
||||
GX_SetChanAmbColor(GX_COLOR1, (GXColor){0x00,0x00,0x00,0xFF}); // specular ambient forced to black
|
||||
GX_SetChanMatColor(GX_COLOR1, (GXColor) { R(speccolor), G(speccolor), B(speccolor), 0xFF }); // couleur du reflet specular
|
||||
GX_SetChanMatColor(GX_COLOR1, (GXColor) { R(speccolor), G(speccolor), B(speccolor), 0xFF }); // specular reflection color
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*------------------------------------------------------------------------------
|
||||
Copyright (c) 2009-2020 The GRRLIB Team
|
||||
Copyright (c) 2009-2022 The GRRLIB Team
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
@ -34,9 +34,9 @@ THE SOFTWARE.
|
|||
*/
|
||||
GRRLIB_bytemapFont* GRRLIB_LoadBMF (const u8 my_bmf[] ) {
|
||||
GRRLIB_bytemapFont *fontArray = (struct GRRLIB_bytemapFont *)malloc(sizeof(GRRLIB_bytemapFont));
|
||||
u32 i, j = 1;
|
||||
|
||||
if (fontArray != NULL && my_bmf[0]==0xE1 && my_bmf[1]==0xE6 && my_bmf[2]==0xD5 && my_bmf[3]==0x1A) {
|
||||
u32 j = 1;
|
||||
fontArray->version = my_bmf[4];
|
||||
//u8 lineheight = my_bmf[5];
|
||||
//short int sizeover = my_bmf[6];
|
||||
|
@ -48,7 +48,7 @@ GRRLIB_bytemapFont* GRRLIB_LoadBMF (const u8 my_bmf[] ) {
|
|||
u8 nbPalette = my_bmf[16];
|
||||
short int numcolpal = 3 * nbPalette;
|
||||
fontArray->palette = (u32 *)calloc(nbPalette + 1, sizeof(u32));
|
||||
for (i=0; i < numcolpal; i+=3) {
|
||||
for (u32 i=0; i < numcolpal; i+=3) {
|
||||
fontArray->palette[j++] = ((((my_bmf[i+17]<<2)+3)<<24) | (((my_bmf[i+18]<<2)+3)<<16) | (((my_bmf[i+19]<<2)+3)<<8) | 0xFF);
|
||||
}
|
||||
j = my_bmf[17 + numcolpal];
|
||||
|
@ -58,7 +58,7 @@ GRRLIB_bytemapFont* GRRLIB_LoadBMF (const u8 my_bmf[] ) {
|
|||
fontArray->nbChar = (my_bmf[j] | my_bmf[j+1]<<8);
|
||||
memset(fontArray->charDef, 0, 256 * sizeof(GRRLIB_bytemapChar));
|
||||
j++;
|
||||
for (i=0; i < fontArray->nbChar; i++) {
|
||||
for (u32 i=0; i < fontArray->nbChar; i++) {
|
||||
const u8 c = my_bmf[++j];
|
||||
fontArray->charDef[c].width = my_bmf[++j];
|
||||
fontArray->charDef[c].height = my_bmf[++j];
|
||||
|
@ -83,16 +83,18 @@ GRRLIB_bytemapFont* GRRLIB_LoadBMF (const u8 my_bmf[] ) {
|
|||
* @param bmf A GRRLIB_bytemapFont structure.
|
||||
*/
|
||||
void GRRLIB_FreeBMF (GRRLIB_bytemapFont *bmf) {
|
||||
if (bmf != NULL) {
|
||||
for (u16 i=0; i<256; i++) {
|
||||
if (bmf->charDef[i].data != NULL) {
|
||||
free(bmf->charDef[i].data);
|
||||
}
|
||||
}
|
||||
free(bmf->palette);
|
||||
free(bmf->name);
|
||||
free(bmf);
|
||||
if (bmf == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (u16 i = 0; i < 256; i++) {
|
||||
if (bmf->charDef[i].data != NULL) {
|
||||
free(bmf->charDef[i].data);
|
||||
}
|
||||
}
|
||||
free(bmf->palette);
|
||||
free(bmf->name);
|
||||
free(bmf);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -115,7 +117,7 @@ void GRRLIB_InitTileSet (GRRLIB_texImg *tex,
|
|||
}
|
||||
tex->tilestart = tilestart;
|
||||
tex->tiledtex = true;
|
||||
tex->ofnormaltexx = 1.0F / tex->nbtilew;
|
||||
tex->ofnormaltexy = 1.0F / tex->nbtileh;
|
||||
tex->ofnormaltexx = 1.0f / tex->nbtilew;
|
||||
tex->ofnormaltexy = 1.0f / tex->nbtileh;
|
||||
GRRLIB_SetHandle( tex, 0, 0 );
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*------------------------------------------------------------------------------
|
||||
Copyright (c) 2009-2017 The GRRLIB Team
|
||||
Copyright (c) 2009-2022 The GRRLIB Team
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
@ -31,10 +31,10 @@ THE SOFTWARE.
|
|||
* @param texdest The texture destination.
|
||||
*/
|
||||
void GRRLIB_BMFX_FlipH (const GRRLIB_texImg *texsrc, GRRLIB_texImg *texdest) {
|
||||
unsigned int x, y, txtWidth = texsrc->w - 1;
|
||||
const u32 txtWidth = texsrc->w - 1;
|
||||
|
||||
for (y = 0; y < texsrc->h; y++) {
|
||||
for (x = 0; x < texsrc->w; x++) {
|
||||
for (u32 y = 0; y < texsrc->h; y++) {
|
||||
for (u32 x = 0; x < texsrc->w; x++) {
|
||||
GRRLIB_SetPixelTotexImg(txtWidth - x, y, texdest,
|
||||
GRRLIB_GetPixelFromtexImg(x, y, texsrc));
|
||||
}
|
||||
|
@ -48,10 +48,10 @@ void GRRLIB_BMFX_FlipH (const GRRLIB_texImg *texsrc, GRRLIB_texImg *texdest) {
|
|||
* @param texdest The texture destination.
|
||||
*/
|
||||
void GRRLIB_BMFX_FlipV (const GRRLIB_texImg *texsrc, GRRLIB_texImg *texdest) {
|
||||
unsigned int x, y, texHeight = texsrc->h - 1;
|
||||
const u32 texHeight = texsrc->h - 1;
|
||||
|
||||
for (y = 0; y < texsrc->h; y++) {
|
||||
for (x = 0; x < texsrc->w; x++) {
|
||||
for (u32 y = 0; y < texsrc->h; y++) {
|
||||
for (u32 x = 0; x < texsrc->w; x++) {
|
||||
GRRLIB_SetPixelTotexImg(x, texHeight - y, texdest,
|
||||
GRRLIB_GetPixelFromtexImg(x, y, texsrc));
|
||||
}
|
||||
|
@ -66,15 +66,13 @@ void GRRLIB_BMFX_FlipV (const GRRLIB_texImg *texsrc, GRRLIB_texImg *texdest) {
|
|||
*/
|
||||
void GRRLIB_BMFX_Grayscale (const GRRLIB_texImg *texsrc,
|
||||
GRRLIB_texImg *texdest) {
|
||||
unsigned int x, y;
|
||||
for (u32 y = 0; y < texsrc->h; y++) {
|
||||
for (u32 x = 0; x < texsrc->w; x++) {
|
||||
const u32 color = GRRLIB_GetPixelFromtexImg(x, y, texsrc);
|
||||
|
||||
for (y = 0; y < texsrc->h; y++) {
|
||||
for (x = 0; x < texsrc->w; x++) {
|
||||
u32 color = GRRLIB_GetPixelFromtexImg(x, y, texsrc);
|
||||
|
||||
u8 gray = ((R(color)* 77 +
|
||||
G(color)*150 +
|
||||
B(color)* 28 ) / 255);
|
||||
const u8 gray = ((R(color) * 77 +
|
||||
G(color) * 150 +
|
||||
B(color) * 28 ) / 255);
|
||||
|
||||
GRRLIB_SetPixelTotexImg(x, y, texdest,
|
||||
(gray << 24) | (gray << 16) | (gray << 8) | (A(color)));
|
||||
|
@ -91,18 +89,16 @@ void GRRLIB_BMFX_Grayscale (const GRRLIB_texImg *texsrc,
|
|||
* @author elisherer
|
||||
*/
|
||||
void GRRLIB_BMFX_Sepia (const GRRLIB_texImg *texsrc, GRRLIB_texImg *texdest) {
|
||||
unsigned int x, y;
|
||||
u16 sr, sg, sb;
|
||||
u32 color;
|
||||
|
||||
for (y = 0; y < texsrc->h; y++) {
|
||||
for (x = 0; x < texsrc->w; x++) {
|
||||
color = GRRLIB_GetPixelFromtexImg(x, y, texsrc);
|
||||
sr = R(color)*0.393 + G(color)*0.769 + B(color)*0.189;
|
||||
sg = R(color)*0.349 + G(color)*0.686 + B(color)*0.168;
|
||||
sb = R(color)*0.272 + G(color)*0.534 + B(color)*0.131;
|
||||
if (sr>255) sr=255;
|
||||
if (sg>255) sg=255;
|
||||
for (u32 y = 0; y < texsrc->h; y++) {
|
||||
for (u32 x = 0; x < texsrc->w; x++) {
|
||||
const u32 color = GRRLIB_GetPixelFromtexImg(x, y, texsrc);
|
||||
u16 sr = R(color)*0.393 + G(color)*0.769 + B(color)*0.189;
|
||||
u16 sg = R(color)*0.349 + G(color)*0.686 + B(color)*0.168;
|
||||
u16 sb = R(color)*0.272 + G(color)*0.534 + B(color)*0.131;
|
||||
if (sr > 255)
|
||||
sr = 255;
|
||||
if (sg > 255)
|
||||
sg = 255;
|
||||
GRRLIB_SetPixelTotexImg(x, y, texdest,
|
||||
RGBA(sr, sg, sb, A(color)));
|
||||
}
|
||||
|
@ -116,12 +112,9 @@ void GRRLIB_BMFX_Sepia (const GRRLIB_texImg *texsrc, GRRLIB_texImg *texdest) {
|
|||
* @param texdest The texture destination.
|
||||
*/
|
||||
void GRRLIB_BMFX_Invert (const GRRLIB_texImg *texsrc, GRRLIB_texImg *texdest) {
|
||||
unsigned int x, y;
|
||||
u32 color;
|
||||
|
||||
for (y = 0; y < texsrc->h; y++) {
|
||||
for (x = 0; x < texsrc->w; x++) {
|
||||
color = GRRLIB_GetPixelFromtexImg(x, y, texsrc);
|
||||
for (u32 y = 0; y < texsrc->h; y++) {
|
||||
for (u32 x = 0; x < texsrc->w; x++) {
|
||||
const u32 color = GRRLIB_GetPixelFromtexImg(x, y, texsrc);
|
||||
GRRLIB_SetPixelTotexImg(x, y, texdest,
|
||||
((0xFFFFFF - (color >> 8 & 0xFFFFFF)) << 8) | (color & 0xFF));
|
||||
}
|
||||
|
@ -137,26 +130,21 @@ void GRRLIB_BMFX_Invert (const GRRLIB_texImg *texsrc, GRRLIB_texImg *texdest) {
|
|||
*/
|
||||
void GRRLIB_BMFX_Blur (const GRRLIB_texImg *texsrc,
|
||||
GRRLIB_texImg *texdest, const u32 factor) {
|
||||
int numba = (1+(factor<<1))*(1+(factor<<1));
|
||||
u32 x, y;
|
||||
s32 k, l;
|
||||
int tmp;
|
||||
int newr, newg, newb, newa;
|
||||
const int numba = (1 + (factor << 1)) * (1 + (factor << 1));
|
||||
u32 colours[numba];
|
||||
u32 thiscol;
|
||||
|
||||
for (x = 0; x < texsrc->w; x++) {
|
||||
for (y = 0; y < texsrc->h; y++) {
|
||||
newr = 0;
|
||||
newg = 0;
|
||||
newb = 0;
|
||||
newa = 0;
|
||||
for (u32 x = 0; x < texsrc->w; x++) {
|
||||
for (u32 y = 0; y < texsrc->h; y++) {
|
||||
int newr = 0;
|
||||
int newg = 0;
|
||||
int newb = 0;
|
||||
int newa = 0;
|
||||
|
||||
tmp = 0;
|
||||
thiscol = GRRLIB_GetPixelFromtexImg(x, y, texsrc);
|
||||
int tmp = 0;
|
||||
const u32 thiscol = GRRLIB_GetPixelFromtexImg(x, y, texsrc);
|
||||
|
||||
for (k = x - factor; k <= x + factor; k++) {
|
||||
for (l = y - factor; l <= y + factor; l++) {
|
||||
for (s32 k = x - factor; k <= x + factor; k++) {
|
||||
for (s32 l = y - factor; l <= y + factor; l++) {
|
||||
if (k < 0 || k >= texsrc->w || l < 0 || l >= texsrc->h) {
|
||||
colours[tmp] = thiscol;
|
||||
}
|
||||
|
@ -193,21 +181,18 @@ void GRRLIB_BMFX_Blur (const GRRLIB_texImg *texsrc,
|
|||
*/
|
||||
void GRRLIB_BMFX_Scatter (const GRRLIB_texImg *texsrc,
|
||||
GRRLIB_texImg *texdest, const u32 factor) {
|
||||
unsigned int x, y;
|
||||
u32 val1, val2;
|
||||
u32 val3, val4;
|
||||
int factorx2 = factor*2;
|
||||
const int factorx2 = factor * 2;
|
||||
|
||||
for (y = 0; y < texsrc->h; y++) {
|
||||
for (x = 0; x < texsrc->w; x++) {
|
||||
val1 = x + (int) (factorx2 * (rand() / (RAND_MAX + 1.0))) - factor;
|
||||
val2 = y + (int) (factorx2 * (rand() / (RAND_MAX + 1.0))) - factor;
|
||||
for (u32 y = 0; y < texsrc->h; y++) {
|
||||
for (u32 x = 0; x < texsrc->w; x++) {
|
||||
const u32 val1 = x + (int) (factorx2 * (rand() / (RAND_MAX + 1.0))) - factor;
|
||||
const u32 val2 = y + (int) (factorx2 * (rand() / (RAND_MAX + 1.0))) - factor;
|
||||
|
||||
if ((val1 >= texsrc->w) || (val2 >= texsrc->h)) {
|
||||
}
|
||||
else {
|
||||
val3 = GRRLIB_GetPixelFromtexImg(x, y, texsrc);
|
||||
val4 = GRRLIB_GetPixelFromtexImg(val1, val2, texsrc);
|
||||
const u32 val3 = GRRLIB_GetPixelFromtexImg(x, y, texsrc);
|
||||
const u32 val4 = GRRLIB_GetPixelFromtexImg(val1, val2, texsrc);
|
||||
GRRLIB_SetPixelTotexImg(x, y, texdest, val4);
|
||||
GRRLIB_SetPixelTotexImg(val1, val2, texdest, val3);
|
||||
}
|
||||
|
@ -224,15 +209,11 @@ void GRRLIB_BMFX_Scatter (const GRRLIB_texImg *texsrc,
|
|||
*/
|
||||
void GRRLIB_BMFX_Pixelate (const GRRLIB_texImg *texsrc,
|
||||
GRRLIB_texImg *texdest, const u32 factor) {
|
||||
unsigned int x, y;
|
||||
unsigned int xx, yy;
|
||||
u32 rgb;
|
||||
|
||||
for (x = 0; x < texsrc->w - 1 - factor; x += factor) {
|
||||
for (y = 0; y < texsrc->h - 1 - factor; y +=factor) {
|
||||
rgb = GRRLIB_GetPixelFromtexImg(x, y, texsrc);
|
||||
for (xx = x; xx < x + factor; xx++) {
|
||||
for (yy = y; yy < y + factor; yy++) {
|
||||
for (u32 x = 0; x < texsrc->w - 1 - factor; x += factor) {
|
||||
for (u32 y = 0; y < texsrc->h - 1 - factor; y +=factor) {
|
||||
const u32 rgb = GRRLIB_GetPixelFromtexImg(x, y, texsrc);
|
||||
for (u32 xx = x; xx < x + factor; xx++) {
|
||||
for (u32 yy = y; yy < y + factor; yy++) {
|
||||
GRRLIB_SetPixelTotexImg(xx, yy, texdest, rgb);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -34,12 +34,12 @@ THE SOFTWARE.
|
|||
|
||||
#define DEFAULT_FIFO_SIZE (256 * 1024) /**< GX fifo buffer size. */
|
||||
|
||||
GRRLIB_drawSettings GRRLIB_Settings;
|
||||
Mtx GXmodelView2D;
|
||||
GRRLIB_drawSettings GRRLIB_Settings;
|
||||
Mtx GXmodelView2D;
|
||||
|
||||
static void *gp_fifo = NULL;
|
||||
static void *gp_fifo = NULL;
|
||||
|
||||
static bool is_setup = false; // To control entry and exit
|
||||
static bool is_setup = false; // To control entry and exit
|
||||
|
||||
/**
|
||||
* Initialize GRRLIB. Call this once at the beginning your code.
|
||||
|
@ -176,7 +176,7 @@ int GRRLIB_Init (void) {
|
|||
GX_SetTexCoordGen(GX_TEXCOORD0, GX_TG_MTX2x4, GX_TG_TEX0, GX_IDENTITY);
|
||||
|
||||
guMtxIdentity(GXmodelView2D);
|
||||
guMtxTransApply(GXmodelView2D, GXmodelView2D, 0.0F, 0.0F, -100.0F);
|
||||
guMtxTransApply(GXmodelView2D, GXmodelView2D, 0.0f, 0.0f, -100.0f);
|
||||
GX_LoadPosMtxImm(GXmodelView2D, GX_PNMTX0);
|
||||
|
||||
guOrtho(perspective, 0.0f, rmode->efbHeight, 0.0f, rmode->fbWidth, 0.0f, 1000.0f);
|
||||
|
@ -219,13 +219,11 @@ int GRRLIB_Init (void) {
|
|||
* and only if the setup function has been called.
|
||||
*/
|
||||
void GRRLIB_Exit (void) {
|
||||
static bool done = false;
|
||||
static bool done = false;
|
||||
if (done == true || is_setup == false) {
|
||||
return;
|
||||
}
|
||||
else {
|
||||
done = true;
|
||||
}
|
||||
done = true;
|
||||
|
||||
// Allow write access to the full screen
|
||||
GX_SetClipMode( GX_CLIP_DISABLE );
|
||||
|
@ -233,8 +231,10 @@ void GRRLIB_Exit (void) {
|
|||
|
||||
// We empty both frame buffers on our way out
|
||||
// otherwise dead frames are sometimes seen when starting the next app
|
||||
GRRLIB_FillScreen( 0x000000FF ); GRRLIB_Render();
|
||||
GRRLIB_FillScreen( 0x000000FF ); GRRLIB_Render();
|
||||
GRRLIB_FillScreen( 0x000000FF );
|
||||
GRRLIB_Render();
|
||||
GRRLIB_FillScreen( 0x000000FF );
|
||||
GRRLIB_Render();
|
||||
|
||||
// Shut down the GX engine
|
||||
GX_DrawDone();
|
||||
|
|
|
@ -29,7 +29,7 @@ THE SOFTWARE.
|
|||
* @param tex A pointer to a texture representing the screen.
|
||||
* @param clear When this flag is set to @c true, the screen is cleared after copy.
|
||||
*/
|
||||
void GRRLIB_Screen2Texture (int posx, int posy, GRRLIB_texImg *tex, bool clear) {
|
||||
void GRRLIB_Screen2Texture (u16 posx, u16 posy, GRRLIB_texImg *tex, bool clear) {
|
||||
if(tex == NULL || tex->data == NULL) {
|
||||
return;
|
||||
}
|
||||
|
@ -60,7 +60,7 @@ void GRRLIB_CompoStart (void) {
|
|||
* @param posy Top left corner of the grabbed part.
|
||||
* @param tex A pointer to a texture representing the screen.
|
||||
*/
|
||||
void GRRLIB_CompoEnd(int posx, int posy, GRRLIB_texImg *tex) {
|
||||
void GRRLIB_CompoEnd(u16 posx, u16 posy, GRRLIB_texImg *tex) {
|
||||
GRRLIB_Screen2Texture(posx, posy, tex, GX_TRUE);
|
||||
|
||||
if (rmode->aa) {
|
||||
|
|
|
@ -364,7 +364,7 @@ GRRLIB_texImg* GRRLIB_LoadTextureJPG (const u8 *my_jpg) {
|
|||
* @param my_size Size of the JPEG buffer to load.
|
||||
* @return A GRRLIB_texImg structure filled with image information.
|
||||
*/
|
||||
GRRLIB_texImg* GRRLIB_LoadTextureJPGEx (const u8 *my_jpg, const int my_size) {
|
||||
GRRLIB_texImg* GRRLIB_LoadTextureJPGEx (const u8 *my_jpg, const u32 my_size) {
|
||||
GRRLIB_texImg *my_texture = calloc(1, sizeof(GRRLIB_texImg));
|
||||
|
||||
if (my_texture == NULL) {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*------------------------------------------------------------------------------
|
||||
Copyright (c) 2009-2017 The GRRLIB Team
|
||||
Copyright (c) 2009-2022 The GRRLIB Team
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
@ -44,8 +44,8 @@ THE SOFTWARE.
|
|||
//------------------------------------------------------------------------------
|
||||
// GRRLIB_clipping.h - Clipping control
|
||||
INLINE void GRRLIB_ClipReset (void);
|
||||
INLINE void GRRLIB_ClipDrawing (const int x, const int y,
|
||||
const int width, const int height);
|
||||
INLINE void GRRLIB_ClipDrawing (const u32 x, const u32 y,
|
||||
const u32 width, const u32 height);
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// GRRLIB_collision.h - Collision detection
|
||||
|
@ -66,16 +66,16 @@ INLINE bool GRRLIB_RectOnRect (const int rect1x, const int rect1y,
|
|||
//------------------------------------------------------------------------------
|
||||
// GRRLIB_fbComplex.h -
|
||||
INLINE void GRRLIB_NPlot (const guVector v[], const u32 color[],
|
||||
const long n);
|
||||
const u16 n);
|
||||
INLINE void GRRLIB_NGone (const guVector v[], const u32 color[],
|
||||
const long n);
|
||||
const u16 n);
|
||||
INLINE void GRRLIB_NGoneFilled (const guVector v[], const u32 color[],
|
||||
const long n);
|
||||
const u16 n);
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// GRRLIB_fbGX.h -
|
||||
INLINE void GRRLIB_GXEngine (const guVector v[], const u32 color[],
|
||||
const long n, const u8 fmt);
|
||||
const u16 n, const u8 fmt);
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// GRRLIB_fbSimple.h -
|
||||
|
|
|
@ -129,9 +129,9 @@ void GRRLIB_Render (void);
|
|||
|
||||
//------------------------------------------------------------------------------
|
||||
// GRRLIB_snapshot.c - Create a texture containing a snapshot of a part of the framebuffer
|
||||
void GRRLIB_Screen2Texture (int posx, int posy, GRRLIB_texImg *tex, bool clear);
|
||||
void GRRLIB_Screen2Texture (u16 posx, u16 posy, GRRLIB_texImg *tex, bool clear);
|
||||
void GRRLIB_CompoStart (void);
|
||||
void GRRLIB_CompoEnd(int posx, int posy, GRRLIB_texImg *tex);
|
||||
void GRRLIB_CompoEnd(u16 posx, u16 posy, GRRLIB_texImg *tex);
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// GRRLIB_texEdit.c - Modifying the content of a texture
|
||||
|
@ -139,7 +139,7 @@ GRRLIB_texImg* GRRLIB_CreateEmptyTexture (const u32 width, const u32 height);
|
|||
GRRLIB_texImg* GRRLIB_LoadTexture (const u8 *my_img);
|
||||
GRRLIB_texImg* GRRLIB_LoadTexturePNG (const u8 *my_png);
|
||||
GRRLIB_texImg* GRRLIB_LoadTextureJPG (const u8 *my_jpg);
|
||||
GRRLIB_texImg* GRRLIB_LoadTextureJPGEx (const u8 *my_jpg, const int my_size);
|
||||
GRRLIB_texImg* GRRLIB_LoadTextureJPGEx (const u8 *my_jpg, const u32 my_size);
|
||||
GRRLIB_texImg* GRRLIB_LoadTextureBMP (const u8 *my_bmp);
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
@ -164,8 +164,8 @@ void GRRLIB_SetTexture(GRRLIB_texImg *tex, bool rep);
|
|||
void GRRLIB_DrawTorus(f32 r, f32 R, int nsides, int rings, bool filled, u32 col);
|
||||
void GRRLIB_DrawSphere(f32 r, int lats, int longs, bool filled, u32 col);
|
||||
void GRRLIB_DrawCube(f32 size, bool filled, u32 col);
|
||||
void GRRLIB_DrawCylinder(f32 r, f32 h, int d, bool filled, u32 col);
|
||||
void GRRLIB_DrawCone(f32 r, f32 h, int d, bool filled, u32 col);
|
||||
void GRRLIB_DrawCylinder(f32 r, f32 h, u16 d, bool filled, u32 col);
|
||||
void GRRLIB_DrawCone(f32 r, f32 h, u16 d, bool filled, u32 col);
|
||||
void GRRLIB_DrawTessPanel(f32 w, f32 wstep, f32 h, f32 hstep, bool filled, u32 col);
|
||||
void GRRLIB_SetLightAmbient(u32 ambientcolor);
|
||||
void GRRLIB_SetLightDiff(u8 num, guVector pos, f32 distattn, f32 brightness, u32 lightcolor);
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*------------------------------------------------------------------------------
|
||||
Copyright (c) 2009-2017 The GRRLIB Team
|
||||
Copyright (c) 2009-2022 The GRRLIB Team
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
@ -42,8 +42,8 @@ void GRRLIB_ClipReset (void) {
|
|||
* @param height The height of the rectangle.
|
||||
*/
|
||||
INLINE
|
||||
void GRRLIB_ClipDrawing (const int x, const int y,
|
||||
const int width, const int height) {
|
||||
void GRRLIB_ClipDrawing (const u32 x, const u32 y,
|
||||
const u32 width, const u32 height) {
|
||||
GX_SetClipMode( GX_CLIP_ENABLE );
|
||||
GX_SetScissor( x, y, width, height );
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*------------------------------------------------------------------------------
|
||||
Copyright (c) 2009-2017 The GRRLIB Team
|
||||
Copyright (c) 2009-2022 The GRRLIB Team
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
@ -29,10 +29,10 @@ THE SOFTWARE.
|
|||
* Draw an array of points.
|
||||
* @param v Array containing the points.
|
||||
* @param color The color of the points in RGBA format.
|
||||
* @param n Number of points in the vector array.
|
||||
* @param n Number of points in the vector array. The maximum is 65536.
|
||||
*/
|
||||
INLINE
|
||||
void GRRLIB_NPlot (const guVector v[], const u32 color[], const long n) {
|
||||
void GRRLIB_NPlot (const guVector v[], const u32 color[], const u16 n) {
|
||||
GRRLIB_GXEngine(v, color, n, GX_POINTS);
|
||||
}
|
||||
|
||||
|
@ -40,10 +40,10 @@ void GRRLIB_NPlot (const guVector v[], const u32 color[], const long n) {
|
|||
* Draw a polygon.
|
||||
* @param v The vector containing the coordinates of the polygon.
|
||||
* @param color The color of the filled polygon in RGBA format.
|
||||
* @param n Number of points in the vector.
|
||||
* @param n Number of points in the vector. The maximum is 65536.
|
||||
*/
|
||||
INLINE
|
||||
void GRRLIB_NGone (const guVector v[], const u32 color[], const long n) {
|
||||
void GRRLIB_NGone (const guVector v[], const u32 color[], const u16 n) {
|
||||
GRRLIB_GXEngine(v, color, n, GX_LINESTRIP);
|
||||
}
|
||||
|
||||
|
@ -51,9 +51,9 @@ void GRRLIB_NGone (const guVector v[], const u32 color[], const long n) {
|
|||
* Draw a filled polygon.
|
||||
* @param v The vector containing the coordinates of the polygon.
|
||||
* @param color The color of the filled polygon in RGBA format.
|
||||
* @param n Number of points in the vector.
|
||||
* @param n Number of points in the vector. The maximum is 65536.
|
||||
*/
|
||||
INLINE
|
||||
void GRRLIB_NGoneFilled (const guVector v[], const u32 color[], const long n) {
|
||||
void GRRLIB_NGoneFilled (const guVector v[], const u32 color[], const u16 n) {
|
||||
GRRLIB_GXEngine(v, color, n, GX_TRIANGLEFAN);
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*------------------------------------------------------------------------------
|
||||
Copyright (c) 2009-2021 The GRRLIB Team
|
||||
Copyright (c) 2009-2022 The GRRLIB Team
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
@ -29,14 +29,14 @@ THE SOFTWARE.
|
|||
* Draws a vector.
|
||||
* @param v The vector to draw.
|
||||
* @param color The color of the vector in RGBA format.
|
||||
* @param n Number of points in the vector.
|
||||
* @param n Number of points in the vector. The maximum is 65536.
|
||||
* @param fmt Type of primitive.
|
||||
*/
|
||||
INLINE
|
||||
void GRRLIB_GXEngine (const guVector v[], const u32 color[], const long n,
|
||||
void GRRLIB_GXEngine (const guVector v[], const u32 color[], const u16 n,
|
||||
const u8 fmt) {
|
||||
GX_Begin(fmt, GX_VTXFMT0, n);
|
||||
for (int i = 0; i < n; i++) {
|
||||
for (u16 i = 0; i < n; i++) {
|
||||
GX_Position3f32(v[i].x, v[i].y, v[i].z);
|
||||
GX_Color1u32(color[i]);
|
||||
}
|
||||
|
|
|
@ -46,12 +46,13 @@ void GRRLIB_FlushTex (GRRLIB_texImg *tex) {
|
|||
*/
|
||||
INLINE
|
||||
void GRRLIB_FreeTexture (GRRLIB_texImg *tex) {
|
||||
if(tex != NULL) {
|
||||
if (tex->data != NULL) {
|
||||
free(tex->data);
|
||||
}
|
||||
free(tex);
|
||||
if(tex == NULL) {
|
||||
return;
|
||||
}
|
||||
if (tex->data != NULL) {
|
||||
free(tex->data);
|
||||
}
|
||||
free(tex);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -144,7 +144,7 @@ int main() {
|
|||
GRRLIB_Init();
|
||||
GRRLIB_Settings.antialias = false;
|
||||
WPAD_Init();
|
||||
GRRLIB_ClipDrawing(0,0,rmode->fbWidth,rmode->efbHeight);
|
||||
GRRLIB_ClipDrawing(0, 0, rmode->fbWidth, rmode->efbHeight);
|
||||
GRRLIB_texImg *tex_tile1 = GRRLIB_LoadTexture(tile1_png);
|
||||
GRRLIB_InitTileSet(tex_tile1, TileMap1Width, TileMap1Height, 0);
|
||||
GRRLIB_texImg *tex_perso = GRRLIB_LoadTexture(perso_png);
|
||||
|
|
|
@ -47,42 +47,42 @@ int main() {
|
|||
GRRLIB_ObjectViewTrans(0.0f,1.3f,0.0f);
|
||||
GRRLIB_ObjectViewRotate(rot,rot*2,rot*3);
|
||||
GRRLIB_ObjectViewEnd();
|
||||
GRRLIB_DrawCone(0.6f, 2.6f, 60,true, 0x502010FF);
|
||||
GRRLIB_DrawCone(0.6f, 2.6f, 60, true, 0x502010FF);
|
||||
|
||||
GRRLIB_ObjectViewBegin();
|
||||
GRRLIB_ObjectViewRotate(0.0f,0.0f,90.0f);
|
||||
GRRLIB_ObjectViewTrans(-1.3f,0.0f,0.0f);
|
||||
GRRLIB_ObjectViewRotate(rot,rot*2,rot*3);
|
||||
GRRLIB_ObjectViewEnd();
|
||||
GRRLIB_DrawCone(0.6f, 2.6f, 60,true, 0x502010FF);
|
||||
GRRLIB_DrawCone(0.6f, 2.6f, 60, true, 0x502010FF);
|
||||
|
||||
GRRLIB_ObjectViewBegin();
|
||||
GRRLIB_ObjectViewRotate(0.0f,0.0f,180.0f);
|
||||
GRRLIB_ObjectViewTrans(0.0f,-1.3f,0.0f);
|
||||
GRRLIB_ObjectViewRotate(rot,rot*2,rot*3);
|
||||
GRRLIB_ObjectViewEnd();
|
||||
GRRLIB_DrawCone(0.6f, 2.6f, 60,true, 0x502010FF);
|
||||
GRRLIB_DrawCone(0.6f, 2.6f, 60, true, 0x502010FF);
|
||||
|
||||
GRRLIB_ObjectViewBegin();
|
||||
GRRLIB_ObjectViewRotate(0.0f,0.0f,-90.0f);
|
||||
GRRLIB_ObjectViewTrans(1.3f,0.0f,0.0f);
|
||||
GRRLIB_ObjectViewRotate(rot,rot*2,rot*3);
|
||||
GRRLIB_ObjectViewEnd();
|
||||
GRRLIB_DrawCone(0.6f, 2.6f, 60,true, 0x502010FF);
|
||||
GRRLIB_DrawCone(0.6f, 2.6f, 60, true, 0x502010FF);
|
||||
|
||||
GRRLIB_ObjectViewBegin();
|
||||
GRRLIB_ObjectViewRotate(-90.0f,0.0f,0.0f);
|
||||
GRRLIB_ObjectViewTrans(0.0f,0.0f,-1.3f);
|
||||
GRRLIB_ObjectViewRotate(rot,rot*2,rot*3);
|
||||
GRRLIB_ObjectViewEnd();
|
||||
GRRLIB_DrawCone(0.6f, 2.6f, 60,true, 0x502010FF);
|
||||
GRRLIB_DrawCone(0.6f, 2.6f, 60, true, 0x502010FF);
|
||||
|
||||
GRRLIB_ObjectViewBegin();
|
||||
GRRLIB_ObjectViewRotate(90.0f,0.0f,0.0f);
|
||||
GRRLIB_ObjectViewTrans(0.0f,0.0f,1.3f);
|
||||
GRRLIB_ObjectViewRotate(rot,rot*2,rot*3);
|
||||
GRRLIB_ObjectViewEnd();
|
||||
GRRLIB_DrawCone(0.6f, 2.6f, 60,true, 0x502010FF);
|
||||
GRRLIB_DrawCone(0.6f, 2.6f, 60, true, 0x502010FF);
|
||||
|
||||
GRRLIB_ObjectViewBegin();
|
||||
GRRLIB_ObjectViewRotate(rot,rot*2,rot*3);
|
||||
|
|
|
@ -36,7 +36,7 @@ int main(int argc, char **argv) {
|
|||
|
||||
GRRLIB_3dMode(0.1,1000,45,0,1);
|
||||
GRRLIB_ObjectView(0,-0.8,0, -90,0,0,1,1,1);
|
||||
GRRLIB_DrawTessPanel(6.2f,0.17f,3.7f,0.1f,0,0xFFFFFFFF);
|
||||
GRRLIB_DrawTessPanel(6.2f, 0.17f, 3.7f, 0.1f, 0, 0xFFFFFFFF);
|
||||
|
||||
lightx+=0.05f;
|
||||
|
||||
|
|
|
@ -12,9 +12,9 @@
|
|||
#include "font_png.h"
|
||||
|
||||
int main() {
|
||||
float a=0;
|
||||
u32 col[3] = {0xFFFFFFFF, 0xAAAAAAFF, 0x666666FF};
|
||||
int cubeZ=0;
|
||||
float a = 0;
|
||||
const u32 col[3] = {0xFFFFFFFF, 0xAAAAAAFF, 0x666666FF};
|
||||
int cubeZ = 0;
|
||||
|
||||
GRRLIB_Init();
|
||||
WPAD_Init();
|
||||
|
|
|
@ -52,9 +52,9 @@ int main() {
|
|||
|
||||
GRRLIB_3dMode(0.1, 1000, 45, false, true);
|
||||
|
||||
if(demo==0) {
|
||||
if(demo == 0) {
|
||||
/////////////////// DEFINE A DIFFUSE LIGHT /////////////////////////////////////////////
|
||||
guVector l0pos={0.0f,20.0f,0.0f};
|
||||
guVector l0pos={0.0f, 20.0f, 0.0f};
|
||||
guVecMultiply(_GRR_view, &l0pos, &l0pos);
|
||||
GX_InitLightPos(&MyLight0, l0pos.x, l0pos.y, l0pos.z);
|
||||
GX_InitLightColor(&MyLight0, (GXColor) { 0xFF, 0x00, 0x00, 0xFF });
|
||||
|
@ -80,9 +80,9 @@ int main() {
|
|||
GRRLIB_2dMode();
|
||||
GRRLIB_Printf(20, 30, tex_font, 0xFFFFFFFF, 1, "Simple Demo 1 Diffuse Light Source");
|
||||
}
|
||||
else if(demo==1) {
|
||||
else if(demo == 1) {
|
||||
/////////////////// DEFINE 2 DIFFUSE LIGHTS /////////////////////////////////////////////
|
||||
guVector l0pos={0.0f,20.0f,0.0f};
|
||||
guVector l0pos={0.0f, 20.0f, 0.0f};
|
||||
guVecMultiply(_GRR_view, &l0pos, &l0pos);
|
||||
GX_InitLightPos(&MyLight0, l0pos.x, l0pos.y, l0pos.z);
|
||||
GX_InitLightColor(&MyLight0, (GXColor) { 0x00, 0xFF, 0x00, 0xFF });
|
||||
|
@ -116,13 +116,13 @@ int main() {
|
|||
GRRLIB_2dMode();
|
||||
GRRLIB_Printf(20, 30, tex_font, 0xFFFFFFFF, 1, "Simple Demo 2 Diffuse Light Sources");
|
||||
}
|
||||
else if(demo==2) {
|
||||
else if(demo == 2) {
|
||||
/////////////////// DEFINE A SPECULAR LIGHT /////////////////////////////////////////////
|
||||
guVector l0dir={0.0f,0.0f,0.0f};
|
||||
guVector l0dir={0.0f, 0.0f, 0.0f};
|
||||
GX_InitSpecularDir(&MyLight0, l0dir.x,l0dir.y,l0dir.z);
|
||||
|
||||
GX_InitLightShininess(&MyLight0, 20); // between 4 and 255 !!!
|
||||
GX_InitLightColor(&MyLight0, (GXColor){0xFF,0xFF,0xFF,0xFF});
|
||||
GX_InitLightColor(&MyLight0, (GXColor){0xFF, 0xFF, 0xFF,0xFF});
|
||||
GX_LoadLightObj(&MyLight0, GX_LIGHT0);
|
||||
|
||||
/////////////////////// Turn light ON ////////////////////////////////////////////////
|
||||
|
@ -143,8 +143,8 @@ int main() {
|
|||
GRRLIB_ObjectView(0,0,0, a,a*2,a*3, 1.0f,1.0f,1.0f);
|
||||
GX_SetChanAmbColor(GX_COLOR0, (GXColor) { 0xFF, 0xFF, 0xFF, 0xFF});
|
||||
GX_SetChanMatColor(GX_COLOR0, (GXColor) { 0x00, 0x00, 0x00, 0xFF});
|
||||
GX_SetChanAmbColor(GX_COLOR1, (GXColor){0x00,0x00,0x00,0x00});
|
||||
GX_SetChanMatColor(GX_COLOR1, (GXColor){0xFF,0xFF,0xFF,0xFF});
|
||||
GX_SetChanAmbColor(GX_COLOR1, (GXColor){0x00, 0x00, 0x00, 0x00});
|
||||
GX_SetChanMatColor(GX_COLOR1, (GXColor){0xFF, 0xFF, 0xFF, 0xFF});
|
||||
GRRLIB_DrawTorus(0.6f, 2.0f, 60, 60, true, 0xFFFFFFFF);
|
||||
a+=0.8f;
|
||||
|
||||
|
@ -155,13 +155,13 @@ int main() {
|
|||
GRRLIB_2dMode();
|
||||
GRRLIB_Printf(20, 30, tex_font, 0xFFFFFFFF, 1, "Simple Demo 1 Specular Source with shininess = 20");
|
||||
}
|
||||
else if(demo==3) {
|
||||
else if(demo == 3) {
|
||||
/////////////////// DEFINE A SPECULAR LIGHT /////////////////////////////////////////////
|
||||
guVector l0dir={0.0f,0.0f,0.0f};
|
||||
guVector l0dir={0.0f, 0.0f, 0.0f};
|
||||
GX_InitSpecularDir(&MyLight0, l0dir.x,l0dir.y,l0dir.z);
|
||||
|
||||
GX_InitLightShininess(&MyLight0, 200); // between 4 and 255 !!!
|
||||
GX_InitLightColor(&MyLight0, (GXColor){0xFF,0xFF,0xFF,0xFF});
|
||||
GX_InitLightColor(&MyLight0, (GXColor){0xFF, 0xFF, 0xFF, 0xFF});
|
||||
GX_LoadLightObj(&MyLight0, GX_LIGHT0);
|
||||
|
||||
/////////////////////// Turn light ON ////////////////////////////////////////////////
|
||||
|
@ -182,9 +182,9 @@ int main() {
|
|||
GRRLIB_ObjectView(0,0,0, a,a*2,a*3, 1.0f,1.0f,1.0f);
|
||||
GX_SetChanAmbColor(GX_COLOR0, (GXColor) { 0xFF, 0xFF, 0xFF, 0xFF});
|
||||
GX_SetChanMatColor(GX_COLOR0, (GXColor) { 0x00, 0x00, 0x00, 0xFF});
|
||||
GX_SetChanAmbColor(GX_COLOR1, (GXColor){0x00,0x00,0x00,0x00});
|
||||
GX_SetChanMatColor(GX_COLOR1, (GXColor){0xFF,0xFF,0xFF,0xFF});
|
||||
GRRLIB_DrawTorus(0.6f, 2.0f, 60, 60,true, 0xFFFFFFFF);
|
||||
GX_SetChanAmbColor(GX_COLOR1, (GXColor){0x00, 0x00, 0x00, 0x00});
|
||||
GX_SetChanMatColor(GX_COLOR1, (GXColor){0xFF, 0xFF, 0xFF, 0xFF});
|
||||
GRRLIB_DrawTorus(0.6f, 2.0f, 60, 60, true, 0xFFFFFFFF);
|
||||
a+=0.8f;
|
||||
|
||||
//////////////////////////// Turn light off and Write demo name
|
||||
|
@ -194,9 +194,9 @@ int main() {
|
|||
GRRLIB_2dMode();
|
||||
GRRLIB_Printf(20, 30, tex_font, 0xFFFFFFFF, 1, "Simple Demo 1 Specular Source with shininess = 200");
|
||||
}
|
||||
else if(demo==4) {
|
||||
else if(demo == 4) {
|
||||
GX_SetTexCoordGen(GX_TEXCOORD0, GX_TG_MTX3x4, GX_TG_NRM, GX_TEXMTX0); // We say we use the Normal coord to map the texture (since there is no textcoord with this torus)
|
||||
guLightFrustum(mv, 1.0F, -1.0F, 1.0F, -1.0F, 1.0F, 0.5F, 0.5F, 0.5F, 0.5F); // we are projecting the texture like a light (ie : videoprojector))
|
||||
guLightFrustum(mv, 1.0f, -1.0f, 1.0f, -1.0f, 1.0f, 0.5f, 0.5f, 0.5f, 0.5f); // we are projecting the texture like a light (ie : videoprojector))
|
||||
|
||||
guMtxScale(mr, -2.8f, -2.8f, 0.0f); //here is a little scaling to fit the torus
|
||||
guMtxConcat(mr, mv, mv);
|
||||
|
@ -216,9 +216,9 @@ int main() {
|
|||
GRRLIB_2dMode();
|
||||
GRRLIB_Printf(20, 30, tex_font, 0xFFFFFFFF, 1, "Simple Demo Mapping Using textgen from normal coord");
|
||||
}
|
||||
else if(demo==5) {
|
||||
else if(demo == 5) {
|
||||
GX_SetTexCoordGen(GX_TEXCOORD0, GX_TG_MTX3x4, GX_TG_NRM, GX_TEXMTX0); // We say we use the Normal coord to map the texture (since there is no textcoord with this torus)
|
||||
guLightFrustum(mv, 1.0F, -1.0F, 1.0F, -1.0F, 1.0F, 0.5F, 0.5F, 0.5F, 0.5F); // we are projecting the texture like a light (ie : videoprojector))
|
||||
guLightFrustum(mv, 1.0f, -1.0f, 1.0f, -1.0f, 1.0f, 0.5f, 0.5f, 0.5f, 0.5f); // we are projecting the texture like a light (ie : videoprojector))
|
||||
guMtxRotDeg(rx, 'X', a); // Here i rotate the texture
|
||||
guMtxRotDeg(ry, 'Y', a*2); // in the inverse way
|
||||
guMtxRotDeg(rz, 'Z', a*3); // of the
|
||||
|
|
|
@ -140,7 +140,7 @@ int main() {
|
|||
GRRLIB_Init();
|
||||
GRRLIB_Settings.antialias = false;
|
||||
WPAD_Init();
|
||||
GRRLIB_ClipDrawing(0,0,rmode->fbWidth,rmode->efbHeight);
|
||||
GRRLIB_ClipDrawing(0, 0, rmode->fbWidth, rmode->efbHeight);
|
||||
GRRLIB_texImg *tex_tile1 = GRRLIB_LoadTexture(tile1_png);
|
||||
GRRLIB_InitTileSet(tex_tile1, TileMap1Width, TileMap1Height, 0);
|
||||
GRRLIB_texImg *tex_perso = GRRLIB_LoadTexture(perso_png);
|
||||
|
|
|
@ -10,71 +10,61 @@
|
|||
|
||||
|
||||
int main() {
|
||||
int offset1, offset2, offset3, offset4;
|
||||
int periode1, periode2, periode3, periode4;
|
||||
int length1, length2, length3, length4;
|
||||
int amp1, amp2, amp3, amp4;
|
||||
int origine1, origine2, origine3, origine4;
|
||||
int adc1, adc2, adc3, adc4;
|
||||
float siny1, siny2, siny3, siny4;
|
||||
int x;
|
||||
float pas1, pas2, pas3, pas4;
|
||||
|
||||
// Initialise the Graphics & Video subsystem
|
||||
GRRLIB_Init();
|
||||
|
||||
// Initialise the Wiimotes
|
||||
// Initialise the Wii Remotes
|
||||
WPAD_Init();
|
||||
|
||||
|
||||
adc1=0;
|
||||
offset1=0;
|
||||
origine1=0;
|
||||
length1=1280;
|
||||
amp1=100;
|
||||
periode1=1;
|
||||
pas1=(periode1*360.0F)/length1;
|
||||
siny1 = offset1*pas1;
|
||||
const int adc1=0;
|
||||
const int offset1=0;
|
||||
const int origin1=0;
|
||||
const int length1=1280;
|
||||
const int amp1=100;
|
||||
const int period1=1;
|
||||
const float pas1=(period1*360.0f)/length1;
|
||||
float siny1 = offset1*pas1;
|
||||
|
||||
adc2=1;
|
||||
offset2=0;
|
||||
origine2=0;
|
||||
length2=1280;
|
||||
amp2=40;
|
||||
periode2=2;
|
||||
pas2=(periode2*360.0F)/length2;
|
||||
siny2 = offset2*pas2;
|
||||
const int adc2=1;
|
||||
const int offset2=0;
|
||||
const int origin2=0;
|
||||
const int length2=1280;
|
||||
const int amp2=40;
|
||||
const int period2=2;
|
||||
const float pas2=(period2*360.0f)/length2;
|
||||
float siny2 = offset2*pas2;
|
||||
|
||||
adc3=-3;
|
||||
offset3=0;
|
||||
origine3=0;
|
||||
length3=1280;
|
||||
amp3=30;
|
||||
periode3=1;
|
||||
pas3=(periode3*360.0F)/length3;
|
||||
siny3 = offset3*pas3;
|
||||
const int adc3=-3;
|
||||
const int offset3=0;
|
||||
const int origin3=0;
|
||||
const int length3=1280;
|
||||
const int amp3=30;
|
||||
const int period3=1;
|
||||
const float pas3=(period3*360.0f)/length3;
|
||||
float siny3 = offset3*pas3;
|
||||
|
||||
adc4=-7;
|
||||
offset4=0;
|
||||
origine4=0;
|
||||
length4=1280;
|
||||
amp4=70;
|
||||
periode4=1;
|
||||
pas4=(periode4*360.0F)/length4;
|
||||
siny4 = offset4*pas4;
|
||||
const int adc4=-7;
|
||||
const int offset4=0;
|
||||
const int origin4=0;
|
||||
const int length4=1280;
|
||||
const int amp4=70;
|
||||
const int period4=1;
|
||||
const float pas4=(period4*360.0f)/length4;
|
||||
float siny4 = offset4*pas4;
|
||||
|
||||
|
||||
while (1) {
|
||||
GRRLIB_FillScreen(0x000000FF);
|
||||
WPAD_ScanPads(); // Scan the Wiimotes
|
||||
WPAD_ScanPads(); // Scan the Wii Remotes
|
||||
if (WPAD_ButtonsDown(0) & WPAD_BUTTON_HOME) break;
|
||||
float old1=siny1;
|
||||
float old2=siny2;
|
||||
float old3=siny3;
|
||||
float old4=siny4;
|
||||
const float old1=siny1;
|
||||
const float old2=siny2;
|
||||
const float old3=siny3;
|
||||
const float old4=siny4;
|
||||
|
||||
|
||||
for (x=0; x<=640; x++) {
|
||||
for (u16 x=0; x<=640; x++) {
|
||||
siny1+=pas1;
|
||||
siny2+=pas2;
|
||||
siny3+=pas3;
|
||||
|
@ -83,11 +73,11 @@ int main() {
|
|||
GX_Begin(GX_LINES, GX_VTXFMT0, 2);
|
||||
GX_Position3f32(x, 0, 0);
|
||||
GX_Color1u32(0x000000FF);
|
||||
GX_Position3f32(x, (sin(DegToRad(siny1))*amp1+origine1)+(sin(DegToRad(siny2))*amp2+origine2)+(sin(DegToRad(siny3))*amp3+origine3)+(sin(DegToRad(siny4))*amp4+origine4)+240, 0);
|
||||
GX_Position3f32(x, (sin(DegToRad(siny1))*amp1+origin1)+(sin(DegToRad(siny2))*amp2+origin2)+(sin(DegToRad(siny3))*amp3+origin3)+(sin(DegToRad(siny4))*amp4+origin4)+240, 0);
|
||||
GX_Color1u32(0xFF00007F);
|
||||
GX_End();
|
||||
GX_Begin(GX_LINES, GX_VTXFMT0, 2);
|
||||
GX_Position3f32(x, (sin(DegToRad(siny1))*amp1+origine1)+(sin(DegToRad(siny2))*amp2+origine2)+(sin(DegToRad(siny3))*amp3+origine3)+(sin(DegToRad(siny4))*amp4+origine4)+240, 0);
|
||||
GX_Position3f32(x, (sin(DegToRad(siny1))*amp1+origin1)+(sin(DegToRad(siny2))*amp2+origin2)+(sin(DegToRad(siny3))*amp3+origin3)+(sin(DegToRad(siny4))*amp4+origin4)+240, 0);
|
||||
GX_Color1u32(0xFF00007F);
|
||||
GX_Position3f32(x, 480, 0);
|
||||
GX_Color1u32(0x000000FF);
|
||||
|
|
|
@ -144,7 +144,7 @@ int main() {
|
|||
GRRLIB_Init();
|
||||
GRRLIB_Settings.antialias = false;
|
||||
PAD_Init();
|
||||
GRRLIB_ClipDrawing(0,0,rmode->fbWidth,rmode->efbHeight);
|
||||
GRRLIB_ClipDrawing(0, 0, rmode->fbWidth, rmode->efbHeight);
|
||||
GRRLIB_texImg *tex_tile1 = GRRLIB_LoadTexture(tile1_png);
|
||||
GRRLIB_InitTileSet(tex_tile1, TileMap1Width, TileMap1Height, 0);
|
||||
GRRLIB_texImg *tex_perso = GRRLIB_LoadTexture(perso_png);
|
||||
|
|
|
@ -47,42 +47,42 @@ int main() {
|
|||
GRRLIB_ObjectViewTrans(0.0f,1.3f,0.0f);
|
||||
GRRLIB_ObjectViewRotate(rot,rot*2,rot*3);
|
||||
GRRLIB_ObjectViewEnd();
|
||||
GRRLIB_DrawCone(0.6f, 2.6f, 60,true, 0x502010FF);
|
||||
GRRLIB_DrawCone(0.6f, 2.6f, 60, true, 0x502010FF);
|
||||
|
||||
GRRLIB_ObjectViewBegin();
|
||||
GRRLIB_ObjectViewRotate(0.0f,0.0f,90.0f);
|
||||
GRRLIB_ObjectViewTrans(-1.3f,0.0f,0.0f);
|
||||
GRRLIB_ObjectViewRotate(rot,rot*2,rot*3);
|
||||
GRRLIB_ObjectViewEnd();
|
||||
GRRLIB_DrawCone(0.6f, 2.6f, 60,true, 0x502010FF);
|
||||
GRRLIB_DrawCone(0.6f, 2.6f, 60, true, 0x502010FF);
|
||||
|
||||
GRRLIB_ObjectViewBegin();
|
||||
GRRLIB_ObjectViewRotate(0.0f,0.0f,180.0f);
|
||||
GRRLIB_ObjectViewTrans(0.0f,-1.3f,0.0f);
|
||||
GRRLIB_ObjectViewRotate(rot,rot*2,rot*3);
|
||||
GRRLIB_ObjectViewEnd();
|
||||
GRRLIB_DrawCone(0.6f, 2.6f, 60,true, 0x502010FF);
|
||||
GRRLIB_DrawCone(0.6f, 2.6f, 60, true, 0x502010FF);
|
||||
|
||||
GRRLIB_ObjectViewBegin();
|
||||
GRRLIB_ObjectViewRotate(0.0f,0.0f,-90.0f);
|
||||
GRRLIB_ObjectViewTrans(1.3f,0.0f,0.0f);
|
||||
GRRLIB_ObjectViewRotate(rot,rot*2,rot*3);
|
||||
GRRLIB_ObjectViewEnd();
|
||||
GRRLIB_DrawCone(0.6f, 2.6f, 60,true, 0x502010FF);
|
||||
GRRLIB_DrawCone(0.6f, 2.6f, 60, true, 0x502010FF);
|
||||
|
||||
GRRLIB_ObjectViewBegin();
|
||||
GRRLIB_ObjectViewRotate(-90.0f,0.0f,0.0f);
|
||||
GRRLIB_ObjectViewTrans(0.0f,0.0f,-1.3f);
|
||||
GRRLIB_ObjectViewRotate(rot,rot*2,rot*3);
|
||||
GRRLIB_ObjectViewEnd();
|
||||
GRRLIB_DrawCone(0.6f, 2.6f, 60,true, 0x502010FF);
|
||||
GRRLIB_DrawCone(0.6f, 2.6f, 60, true, 0x502010FF);
|
||||
|
||||
GRRLIB_ObjectViewBegin();
|
||||
GRRLIB_ObjectViewRotate(90.0f,0.0f,0.0f);
|
||||
GRRLIB_ObjectViewTrans(0.0f,0.0f,1.3f);
|
||||
GRRLIB_ObjectViewRotate(rot,rot*2,rot*3);
|
||||
GRRLIB_ObjectViewEnd();
|
||||
GRRLIB_DrawCone(0.6f, 2.6f, 60,true, 0x502010FF);
|
||||
GRRLIB_DrawCone(0.6f, 2.6f, 60, true, 0x502010FF);
|
||||
|
||||
GRRLIB_ObjectViewBegin();
|
||||
GRRLIB_ObjectViewRotate(rot,rot*2,rot*3);
|
||||
|
|
|
@ -36,7 +36,7 @@ int main(int argc, char **argv) {
|
|||
|
||||
GRRLIB_3dMode(0.1,1000,45,0,1);
|
||||
GRRLIB_ObjectView(0,-0.8,0, -90,0,0,1,1,1);
|
||||
GRRLIB_DrawTessPanel(6.2f,0.17f,3.7f,0.1f,0,0xFFFFFFFF);
|
||||
GRRLIB_DrawTessPanel(6.2f, 0.17f, 3.7f, 0.1f, 0, 0xFFFFFFFF);
|
||||
|
||||
lightx+=0.05f;
|
||||
|
||||
|
|
|
@ -12,9 +12,9 @@
|
|||
#include "font_png.h"
|
||||
|
||||
int main() {
|
||||
float a=0;
|
||||
u32 col[3] = {0xFFFFFFFF, 0xAAAAAAFF, 0x666666FF};
|
||||
int cubeZ=0;
|
||||
float a = 0;
|
||||
const u32 col[3] = {0xFFFFFFFF, 0xAAAAAAFF, 0x666666FF};
|
||||
int cubeZ = 0;
|
||||
|
||||
GRRLIB_Init();
|
||||
PAD_Init();
|
||||
|
|
|
@ -140,7 +140,7 @@ int main() {
|
|||
GRRLIB_Init();
|
||||
GRRLIB_Settings.antialias = false;
|
||||
PAD_Init();
|
||||
GRRLIB_ClipDrawing(0,0,rmode->fbWidth,rmode->efbHeight);
|
||||
GRRLIB_ClipDrawing(0, 0, rmode->fbWidth, rmode->efbHeight);
|
||||
GRRLIB_texImg *tex_tile1 = GRRLIB_LoadTexture(tile1_png);
|
||||
GRRLIB_InitTileSet(tex_tile1, TileMap1Width, TileMap1Height, 0);
|
||||
GRRLIB_texImg *tex_perso = GRRLIB_LoadTexture(perso_png);
|
||||
|
|
|
@ -10,16 +10,6 @@
|
|||
|
||||
|
||||
int main() {
|
||||
int offset1, offset2, offset3, offset4;
|
||||
int periode1, periode2, periode3, periode4;
|
||||
int length1, length2, length3, length4;
|
||||
int amp1, amp2, amp3, amp4;
|
||||
int origine1, origine2, origine3, origine4;
|
||||
int adc1, adc2, adc3, adc4;
|
||||
float siny1, siny2, siny3, siny4;
|
||||
int x;
|
||||
float pas1, pas2, pas3, pas4;
|
||||
|
||||
// Initialise the Graphics & Video subsystem
|
||||
GRRLIB_Init();
|
||||
|
||||
|
@ -27,54 +17,54 @@ int main() {
|
|||
PAD_Init();
|
||||
|
||||
|
||||
adc1=0;
|
||||
offset1=0;
|
||||
origine1=0;
|
||||
length1=1280;
|
||||
amp1=100;
|
||||
periode1=1;
|
||||
pas1=(periode1*360.0F)/length1;
|
||||
siny1 = offset1*pas1;
|
||||
const int adc1=0;
|
||||
const int offset1=0;
|
||||
const int origin1=0;
|
||||
const int length1=1280;
|
||||
const int amp1=100;
|
||||
const int period1=1;
|
||||
const float pas1=(period1*360.0f)/length1;
|
||||
float siny1 = offset1*pas1;
|
||||
|
||||
adc2=1;
|
||||
offset2=0;
|
||||
origine2=0;
|
||||
length2=1280;
|
||||
amp2=40;
|
||||
periode2=2;
|
||||
pas2=(periode2*360.0F)/length2;
|
||||
siny2 = offset2*pas2;
|
||||
const int adc2=1;
|
||||
const int offset2=0;
|
||||
const int origin2=0;
|
||||
const int length2=1280;
|
||||
const int amp2=40;
|
||||
const int period2=2;
|
||||
const float pas2=(period2*360.0f)/length2;
|
||||
float siny2 = offset2*pas2;
|
||||
|
||||
adc3=-3;
|
||||
offset3=0;
|
||||
origine3=0;
|
||||
length3=1280;
|
||||
amp3=30;
|
||||
periode3=1;
|
||||
pas3=(periode3*360.0F)/length3;
|
||||
siny3 = offset3*pas3;
|
||||
const int adc3=-3;
|
||||
const int offset3=0;
|
||||
const int origin3=0;
|
||||
const int length3=1280;
|
||||
const int amp3=30;
|
||||
const int period3=1;
|
||||
const float pas3=(period3*360.0f)/length3;
|
||||
float siny3 = offset3*pas3;
|
||||
|
||||
adc4=-7;
|
||||
offset4=0;
|
||||
origine4=0;
|
||||
length4=1280;
|
||||
amp4=70;
|
||||
periode4=1;
|
||||
pas4=(periode4*360.0F)/length4;
|
||||
siny4 = offset4*pas4;
|
||||
const int adc4=-7;
|
||||
const int offset4=0;
|
||||
const int origin4=0;
|
||||
const int length4=1280;
|
||||
const int amp4=70;
|
||||
const int period4=1;
|
||||
const float pas4=(period4*360.0f)/length4;
|
||||
float siny4 = offset4*pas4;
|
||||
|
||||
|
||||
while (1) {
|
||||
GRRLIB_FillScreen(0x000000FF);
|
||||
PAD_ScanPads(); // Scan the GameCube controllers
|
||||
if (PAD_ButtonsDown(0) & PAD_BUTTON_START) break;
|
||||
float old1=siny1;
|
||||
float old2=siny2;
|
||||
float old3=siny3;
|
||||
float old4=siny4;
|
||||
const float old1=siny1;
|
||||
const float old2=siny2;
|
||||
const float old3=siny3;
|
||||
const float old4=siny4;
|
||||
|
||||
|
||||
for (x=0; x<=640; x++) {
|
||||
for (u16 x=0; x<=640; x++) {
|
||||
siny1+=pas1;
|
||||
siny2+=pas2;
|
||||
siny3+=pas3;
|
||||
|
@ -83,11 +73,11 @@ int main() {
|
|||
GX_Begin(GX_LINES, GX_VTXFMT0, 2);
|
||||
GX_Position3f32(x, 0, 0);
|
||||
GX_Color1u32(0x000000FF);
|
||||
GX_Position3f32(x, (sin(DegToRad(siny1))*amp1+origine1)+(sin(DegToRad(siny2))*amp2+origine2)+(sin(DegToRad(siny3))*amp3+origine3)+(sin(DegToRad(siny4))*amp4+origine4)+240, 0);
|
||||
GX_Position3f32(x, (sin(DegToRad(siny1))*amp1+origin1)+(sin(DegToRad(siny2))*amp2+origin2)+(sin(DegToRad(siny3))*amp3+origin3)+(sin(DegToRad(siny4))*amp4+origin4)+240, 0);
|
||||
GX_Color1u32(0xFF00007F);
|
||||
GX_End();
|
||||
GX_Begin(GX_LINES, GX_VTXFMT0, 2);
|
||||
GX_Position3f32(x, (sin(DegToRad(siny1))*amp1+origine1)+(sin(DegToRad(siny2))*amp2+origine2)+(sin(DegToRad(siny3))*amp3+origine3)+(sin(DegToRad(siny4))*amp4+origine4)+240, 0);
|
||||
GX_Position3f32(x, (sin(DegToRad(siny1))*amp1+origin1)+(sin(DegToRad(siny2))*amp2+origin2)+(sin(DegToRad(siny3))*amp3+origin3)+(sin(DegToRad(siny4))*amp4+origin4)+240, 0);
|
||||
GX_Color1u32(0xFF00007F);
|
||||
GX_Position3f32(x, 480, 0);
|
||||
GX_Color1u32(0x000000FF);
|
||||
|
|
Loading…
Reference in a new issue