mirror of
https://github.com/GRRLIB/GRRLIB.git
synced 2024-11-26 08:42:19 +00:00
[CHG] Now checks if the struct is valid / not NULL before drawing it.
This commit is contained in:
parent
6197d0e717
commit
9608deb240
2 changed files with 23 additions and 8 deletions
|
@ -1,9 +1,10 @@
|
|||
/*===========================================
|
||||
GRRLIB (GX version) 4.0.0
|
||||
Code : NoNameNo
|
||||
Additional Code : Crayon
|
||||
Additional Code : Crayon & Xane
|
||||
GX hints : RedShade
|
||||
===========================================*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <malloc.h>
|
||||
|
@ -18,6 +19,7 @@
|
|||
|
||||
#define DEFAULT_FIFO_SIZE (256 * 1024) /**< GX fifo buffer size. */
|
||||
|
||||
|
||||
u32 fb = 0;
|
||||
static void *xfb[2] = {NULL, NULL};
|
||||
GXRModeObj *rmode;
|
||||
|
@ -544,7 +546,9 @@ GRRLIB_texImg *GRRLIB_CreateEmptyTexture(unsigned int w, unsigned int h) {
|
|||
* @param color Color in RGBA format.
|
||||
*/
|
||||
inline void GRRLIB_DrawImg(f32 xpos, f32 ypos, struct GRRLIB_texImg *tex, float degrees, float scaleX, f32 scaleY, u32 color) {
|
||||
if (!tex->data) { return; }
|
||||
if (tex == NULL) { return; }
|
||||
if (tex->data == NULL) { return; }
|
||||
|
||||
GXTexObj texObj;
|
||||
u16 width, height;
|
||||
Mtx m, m1, m2, mv;
|
||||
|
@ -599,6 +603,9 @@ inline void GRRLIB_DrawImg(f32 xpos, f32 ypos, struct GRRLIB_texImg *tex, float
|
|||
* @param color Color in RGBA format.
|
||||
*/
|
||||
inline void GRRLIB_DrawImgQuad(Vector pos[4], struct GRRLIB_texImg *tex, u32 color) {
|
||||
if (tex == NULL) { return; }
|
||||
if (tex->data == NULL) { return; }
|
||||
|
||||
GXTexObj texObj;
|
||||
Mtx m, m1, m2, mv;
|
||||
|
||||
|
@ -655,6 +662,10 @@ inline void GRRLIB_DrawImgQuad(Vector pos[4], struct GRRLIB_texImg *tex, u32 col
|
|||
* @param frame Specifies the frame to draw.
|
||||
*/
|
||||
inline void GRRLIB_DrawTile(f32 xpos, f32 ypos, struct GRRLIB_texImg *tex, float degrees, float scaleX, f32 scaleY, u32 color, int frame) {
|
||||
if (tex == NULL) { return; }
|
||||
if (tex->data == NULL) { return; }
|
||||
if (tex->frame > (tex->nbtilew+tex->nbtileh)) { return; }
|
||||
|
||||
GXTexObj texObj;
|
||||
f32 width, height;
|
||||
Mtx m, m1, m2, mv;
|
||||
|
@ -721,6 +732,9 @@ inline void GRRLIB_DrawTile(f32 xpos, f32 ypos, struct GRRLIB_texImg *tex, float
|
|||
* @param ... Optional arguments.
|
||||
*/
|
||||
void GRRLIB_Printf(f32 xpos, f32 ypos, struct GRRLIB_texImg *tex, u32 color, f32 zoom, const char *text, ...) {
|
||||
if (tex == NULL) { return; }
|
||||
if (tex->data == NULL) { return; }
|
||||
|
||||
int i, size;
|
||||
char tmp[1024];
|
||||
|
||||
|
@ -811,7 +825,7 @@ void GRRLIB_ClipReset() {
|
|||
* @param x The x-coordinate of the handle.
|
||||
* @param y The y-coordinate of the handle.
|
||||
*/
|
||||
void GRRLIB_SetHandle( struct GRRLIB_texImg * tex, int x, int y ) {
|
||||
void GRRLIB_SetHandle( struct GRRLIB_texImg *tex, int x, int y ) {
|
||||
if (tex->tiledtex) {
|
||||
tex->handlex = -(((int)tex->tilew)/2) + x;
|
||||
tex->handley = -(((int)tex->tileh)/2) + y;
|
||||
|
@ -826,7 +840,7 @@ void GRRLIB_SetHandle( struct GRRLIB_texImg * tex, int x, int y ) {
|
|||
* @param tex The texture to center.
|
||||
* @param enabled
|
||||
*/
|
||||
void GRRLIB_SetMidHandle( struct GRRLIB_texImg * tex, bool enabled ) {
|
||||
void GRRLIB_SetMidHandle( struct GRRLIB_texImg *tex, bool enabled ) {
|
||||
if (enabled) {
|
||||
if (tex->tiledtex) {
|
||||
tex->offsetx = (((int)tex->tilew)/2);
|
||||
|
@ -1201,6 +1215,7 @@ void GRRLIB_Render() {
|
|||
GX_SetZMode(GX_TRUE, GX_LEQUAL, GX_TRUE);
|
||||
GX_SetColorUpdate(GX_TRUE);
|
||||
GX_CopyDisp(xfb[fb], GX_TRUE);
|
||||
|
||||
VIDEO_SetNextFramebuffer(xfb[fb]);
|
||||
VIDEO_Flush();
|
||||
VIDEO_WaitVSync();
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*===========================================
|
||||
GRRLIB (GX version) 4.0.0
|
||||
Code : NoNameNo
|
||||
Additional Code : Crayon
|
||||
Additional Code : Crayon & Xane
|
||||
GX hints : RedShade
|
||||
===========================================*/
|
||||
|
||||
|
|
Loading…
Reference in a new issue