You are not logged in.

#1 2010-07-31 14:26:05

Cid2mizard
Member

[RESOLVED] GRRLIB_texImg in a structure

How can i put GRRLIB_texImg in a structure.

Code:

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.


Code:

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.


Code:

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


www.nintendomax.com - 100% Hack  0% Warez

Offline

 

#2 2010-07-31 17:36:19

Crayon
Bad Mother Fucker

Re: [RESOLVED] GRRLIB_texImg in a structure

There is how I did it, first you create structure:

Code:

typedef  struct MyStruct {
   GRRLIB_texImg * texture;
} MyStruct;

You create the array and fill each texture:

Code:

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:

Code:

GRRLIB_DrawImg(0, 0, GM[0].texture, 0, 1, 1, 0xFFFFFFFF);

Offline

 

#3 2010-08-01 09:13:44

Cid2mizard
Member

Re: [RESOLVED] GRRLIB_texImg in a structure

Oups ! i have fortget initilset ^^, good works thanks.

Code:

#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)


www.nintendomax.com - 100% Hack  0% Warez

Offline

 

Board footer

Powered by FluxBB