You are not logged in.

  • Index
  •  » General Help
  •  » Weird problem, some GRRLIB_DrawImg (same code) does not render

#1 2010-10-23 11:31:50

BlackX
Member

Weird problem, some GRRLIB_DrawImg (same code) does not render

I have the same code in the int main, and some void, like "void splash()".
All inside a "while" loop. But only the screens inside the main() are drawn correctly.

Is almost the same code in both parts of source, but PNG textures (GRRLIB_Printf, GRRLIB_DrawImg) just don't render in void arrays, only "GRRLIB_Rectangle". Why?
I need some help.

BTW, I'm using devkitPro (devkitPPC) and coding for Wii, with GRRLIB 4.3.0.

Tks.

Last edited by BlackX (2010-10-23 11:32:43)

Offline

 

#2 2010-10-23 15:39:16

Crayon
Bad Mother Fucker

Re: Weird problem, some GRRLIB_DrawImg (same code) does not render

Could you give us some details for your image: width and height
What software did you use to convert your PNG to .c/.h files?

Offline

 

#3 2010-10-23 18:48:15

BlackX
Member

Re: Weird problem, some GRRLIB_DrawImg (same code) does not render

Background: 640x480, JPEG.
Cursor: 48x48, PNG.
Font: generated by WiiBuilder, image 960x60, tiles 20x30, PNG.

All conversions made by raw2c.


I must be doing something stupid, but I'm still confused why some screens work and other don't, with basically the same code.




Here a part of the source:

Code:

#define BUILD_DATE "WORKPRINT 23-10-2010"
#define BUILD_VER "V0.01a"

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <malloc.h>
#include <math.h>
#include <ogcsys.h>
#include <gccore.h>
#include <wiiuse/wpad.h>
#include <GRRLIB.h>
#include <pngu.h>

#include "img/title.h"
#include "img/bg.h"
#include "img/button.h"
#include "img/buttoff.h"
#include "img/cursor.h"
#include "img/font2.h"

#define GRRLIB_BLACK   0x000000FF
#define GRRLIB_GRAY    0xE6E6E6FF
#define GRRLIB_WHITE   0xFFFFFFFF

void splash1()                                                                                   // Splash screen not rendering fonts or cursor.
{
    while(1)
    {
        WPAD_ScanPads();
        wpaddown = WPAD_ButtonsDown(0);
        WPAD_IR(0,&ir1);
        if(ir1.valid==0) cursor_on=0;
        else cursor_on=1;
        
        if(wpaddown&WPAD_BUTTON_2)
            GRRLIB_ScrShot("sd:/screen.png");
        
        GRRLIB_FillScreen(GRRLIB_GRAY);                                                                         // -->  These and the Logs screens ( logs() ) not working at all.
        GRRLIB_DrawImg(0,0,tex_bg,0,1,1,GRRLIB_WHITE);
        GRRLIB_Printf(400,15,tex_font,GRRLIB_BLACK,0.8,"%d %d",BUILD_VER,BUILD_DATE);
        GRRLIB_Printf(5,100,tex_font,GRRLIB_BLACK,1,"TO QUIT PRESS THE HOME BUTTON.");
        GRRLIB_Printf(160,400,tex_font,GRRLIB_BLACK,1,"PRESS A TO START");
        if(cursor_on) GRRLIB_DrawImg((int)ir1.x,(int)ir1.y,tex_cursor,0,1,1,GRRLIB_WHITE); // Cursor not working in this screen.
        GRRLIB_Render();
        if (wpaddown & WPAD_BUTTON_HOME) quit(LAUNCHER);
            else 
            if((wpaddown&WPAD_BUTTON_A)||wpaddown&WPAD_BUTTON_B) return;
        if(power==1)
            quit(POWEROFF);
        else if(power==2)
            quit(WIIMENU);
    }
}

int main() {

    GRRLIB_Init();
    GRRLIB_texImg *tex_font = GRRLIB_LoadTexture(font2);
    GRRLIB_InitTileSet(tex_font,20,30,32);
    GRRLIB_texImg *tex_title = GRRLIB_LoadTexture(title);
    GRRLIB_texImg *tex_bg = GRRLIB_LoadTexture(bg);
    GRRLIB_texImg *tex_buttoff = GRRLIB_LoadTexture(buttoff);
    GRRLIB_texImg *tex_button = GRRLIB_LoadTexture(button);
    GRRLIB_texImg *tex_cursor = GRRLIB_LoadTexture(cursor);

        WPAD_Init();

splash1(); 
    while(1)
    {
        WPAD_ScanPads();
        wpaddown = WPAD_ButtonsDown(0);
        WPAD_IR(0,&ir1);
                if(ir1.valid==0) cursor_on=0;
                else cursor_on=1;
                if((int)ir1.x>=375&&(int)ir1.x<444&&(int)ir1.y>=312&&(int)ir1.y<352)
                    highlighted=1;
                else if((int)ir1.x>=375&&(int)ir1.x<585&&(int)ir1.y>=372&&(int)ir1.y<412)
                    highlighted=2;
                else
                    highlighted=0;
                if((wpaddown&WPAD_BUTTON_A)&&cursor_on)
                        {
            if((int)ir1.x>=20&&(int)ir1.x<52&&(int)ir1.y>=120&&(int)ir1.y<312&&((int)(int)ir1.y%40)<32)
                sortby=(char)(((int)ir1.y-120)/40)+1;
            else if((int)ir1.x>=360&&(int)ir1.x<392&&(int)ir1.y>=120&&(int)ir1.y<192&&((int)(int)ir1.y%40)<32)       // All the highlighting code works.
                order=(char)(((int)ir1.y-120)/40);
            else if(highlighted==1)
                showlist(sortby,order);
            else if(highlighted==2)
                showtotal();
                }

        if(wpaddown&WPAD_BUTTON_2)
            GRRLIB_ScrShot("sd:/screenshot.png");

        GRRLIB_FillScreen(GRRLIB_GRAY);
        GRRLIB_DrawImg(0,0,tex_bg,0,1,1,GRRLIB_WHITE);
        for(i=1;i<6;i++)
            GRRLIB_DrawImg(20,i*40+80,sortby==i?tex_button:tex_buttoff,0,0.7,0.7,GRRLIB_GRAY);                         // This screen works!!!
        for(i=0;i<2;i++)
            GRRLIB_DrawImg(360,i*40+120,order==i?tex_button:tex_buttoff,0,0.7,0.7,GRRLIB_GRAY);
        GRRLIB_Printf(20,95,tex_font,GRRLIB_BLACK,1,"List1:");
        GRRLIB_Printf(55,125,tex_font,GRRLIB_BLACK,0.8,"Opt1");
        GRRLIB_Printf(55,165,tex_font,GRRLIB_BLACK,0.8,"Opt2");
        GRRLIB_Printf(55,205,tex_font,GRRLIB_BLACK,0.8,"Opt3");
        GRRLIB_Printf(55,245,tex_font,GRRLIB_BLACK,0.8,"Opt4");
        GRRLIB_Printf(55,285,tex_font,GRRLIB_BLACK,0.8,"Opt5");
        GRRLIB_Printf(360,95,tex_font,GRRLIB_BLACK,1,"List2:");
        GRRLIB_Printf(395,125,tex_font,GRRLIB_BLACK,0.8,"Opt1-2");
        GRRLIB_Printf(395,165,tex_font,GRRLIB_BLACK,0.8,"Opt2-2");
        GRRLIB_Rectangle(375,312,69,40,GRRLIB_BLACK,0);
        GRRLIB_Rectangle(376,313,67,38,GRRLIB_BLACK,0);
        if(highlighted==1)
            GRRLIB_Rectangle(377,314,65,36,GRRLIB_WHITE,1);
        GRRLIB_Printf(382,314,tex_font,GRRLIB_BLACK,1,"Show me!");
        GRRLIB_Rectangle(375,372,210,40,GRRLIB_BLACK,0);
        GRRLIB_Rectangle(376,373,208,38,GRRLIB_BLACK,0);
        if(highlighted==2)
            GRRLIB_Rectangle(377,374,206,36,GRRLIB_WHITE,1);
        GRRLIB_Printf(382,374,tex_font,GRRLIB_BLACK,1,"TOTALS");
        if(cursor_on) GRRLIB_DrawImg((int)ir1.x,(int)ir1.y,tex_cursor,0,1,1,GRRLIB_WHITE);                 // Cursor Works!
        GRRLIB_Render();

        if (wpaddown & WPAD_BUTTON_HOME) quit(LAUNCHER);
        if(power==1)
            quit(POWEROFF);
        else if(power==2)
            quit(WIIMENU);
    }
    return 0;
}

Last edited by BlackX (2010-10-23 18:53:33)

Offline

 

#4 2010-10-24 20:22:09

Crayon
Bad Mother Fucker

Re: Weird problem, some GRRLIB_DrawImg (same code) does not render

I don't understand, does your code compiles? Because it looks like you declared all your textures in main() and you use them in splash1()??? The scope for all your GRRLIB_texImg * is limited to main!

Offline

 

#5 2010-10-24 21:08:49

BlackX
Member

Re: Weird problem, some GRRLIB_DrawImg (same code) does not render

Yes, it compiles.
What do you mean by "The scope is all your GRRLIB_texImg * is limited to main"?


I am newbie in this, using this as a learning task.



EDITED: I said: I'm a newbie and the problem was stupid... GRRLIB_texImg inside void splash() and others... and the problem SOLVED.
Thanks!

Last edited by BlackX (2010-10-24 21:38:35)

Offline

 
  • Index
  •  » General Help
  •  » Weird problem, some GRRLIB_DrawImg (same code) does not render

Board footer

Powered by FluxBB