You are not logged in.
How can i put GRRLIB_texImg in a structure.
typedef struct{ u8* texture; }data GM[3]; Citation GM[0].texture = GM01; GM[1].texture = GM02; GM[2].texture = GM03;
warning: assignment discards qualifiers from pointer target type.
typedef struct{ u8* texture; }data GM[3]; Citation GM[0].texture = GRRLIB_LoadTexture(GM01); GM[1].texture = GRRLIB_LoadTexture(GM02); GM[2].texture = GRRLIB_LoadTexture(GM03);
warning: assignment from incompatible pointer type.
typedef struct{ GRRLIB_texImg * texture; }data GM[3]; Citation GM[0].texture = GRRLIB_LoadTexture(GM01); GM[1].texture = GRRLIB_LoadTexture(GM02); GM[2].texture = GRRLIB_LoadTexture(GM03);
no warning but nothing appears
Offline
There is how I did it, first you create structure:
typedef struct MyStruct { GRRLIB_texImg * texture; } MyStruct;
You create the array and fill each texture:
MyStruct GM[3]; // Create an array of MyStruct GM[0].texture = GRRLIB_LoadTexture(GM01); GM[1].texture = GRRLIB_LoadTexture(GM02); GM[2].texture = GRRLIB_LoadTexture(GM03);
You use it:
GRRLIB_DrawImg(0, 0, GM[0].texture, 0, 1, 1, 0xFFFFFFFF);
Offline
Oups ! i have fortget initilset ^^, good works thanks.
#include <grrlib.h> #include <stdlib.h> #include <wiiuse/wpad.h> #include "gfx/GM01.h" #include "gfx/GM02.h" #include "gfx/GM03.h" #define GRRLIB_BLACK 0x000000FF #define GRRLIB_WHITE 0xFFFFFFFF typedef struct { GRRLIB_texImg * texture; } Img; Img GM[3]; int main(int argc, char **argv) { // Initialise the Graphics & Video subsystem GRRLIB_Init(); GM[0].texture = GRRLIB_LoadTexture(GM01); GRRLIB_InitTileSet(GM[0].texture, 116, 216, 4); GM[1].texture = GRRLIB_LoadTexture(GM02); GRRLIB_InitTileSet(GM[1].texture, 116, 216, 5); GM[2].texture = GRRLIB_LoadTexture(GM03); GRRLIB_InitTileSet(GM[2].texture, 116, 216, 5); // Initialise the Wiimotes WPAD_Init(); // Loop forever while(1) { WPAD_ScanPads(); // Scan the Wiimotes // If [HOME] was pressed on the first Wiimote, break out of the loop if (WPAD_ButtonsDown(0) & WPAD_BUTTON_HOME) break; GRRLIB_FillScreen(GRRLIB_BLACK); // --------------------------------------------------------------------- GRRLIB_DrawTile(29, 106, GM[0].texture, 0, 1, 1, GRRLIB_WHITE, 0); GRRLIB_DrawTile(251, 106, GM[1].texture, 0, 1, 1, GRRLIB_WHITE, 0); GRRLIB_DrawTile(472, 106, GM[2].texture, 0, 1, 1, GRRLIB_WHITE, 0); // --------------------------------------------------------------------- GRRLIB_Render(); // Render the frame buffer to the TV } GRRLIB_Exit(); // Be a good boy, clear the memory allocated by GRRLIB exit(0); // Use exit() to exit a program, do not use 'return' from main() }
Last edited by Cid2mizard (2010-08-01 09:40:35)
Offline