You are not logged in.

#1 2009-05-28 21:08:24

xtoc
Member

Image flashing

Hi,

My current project has 4 images.
- 2 same backgrounds (for infinity scrolling)
- 1 pointer images (which issen't important at the moment)
- 1 Mario moving image.

The background scrolls to the left, when the background is almost at the end, the image start flickering (like there is no double buffering)...

http://users.telenet.be/ganon/mariogame/IMAGE_244.jpg
http://users.telenet.be/ganon/mariogame/IMAGE_245.jpg


Source:

Code:

#include "../../../GRRLIB/GRRLIB/GRRLIB.h"

#include <stdlib.h>
#include <wiiuse/wpad.h>

#include "gfx/BGLevel1.h"
#include "gfx/starpointer.h"
#include "gfx/mario.h"


Mtx GXmodelView2D;


int main() {
    ir_t ir1; //wiimote pointer
        u32 wpaddown;
    float mariotile=0;
    float backgroundmove=0;
    float backgroundmove2 = 801;

    // Load the image file to a texture structure
    GRRLIB_texImg tex_starpointer = GRRLIB_LoadTexture(starpointer); //wiimote pointer
    GRRLIB_texImg tex_BGLevel1 = GRRLIB_LoadTexture(BGLevel1);
    GRRLIB_texImg tex_mario = GRRLIB_LoadTexture(mario);
    // slice it
    GRRLIB_InitTileSet(&tex_mario, 16, 32, 0);


    GRRLIB_Init();
    WPAD_Init();
    WPAD_SetDataFormat(WPAD_CHAN_0, WPAD_FMT_BTNS_ACC_IR); //wiimote pointer

    while(1) {
        WPAD_SetVRes(0, 800, 600);
        WPAD_ScanPads();
        wpaddown = WPAD_ButtonsDown(0);
        WPAD_IR(WPAD_CHAN_0, &ir1); //wiimote pointer

        //We fill the screen in white(RGBA format)
        GRRLIB_FillScreen(0xFFFFFFFF);

        //Display the image
        GRRLIB_DrawImg(backgroundmove, 0, tex_BGLevel1, 0, 1, 1, 0xFFFFFFFF);
        GRRLIB_DrawImg(backgroundmove2, 0, tex_BGLevel1, 0, 1, 1, 0xFFFFFFFF);
        GRRLIB_DrawImg(ir1.sx, ir1.sy, tex_starpointer, 0, 1, 1, 0xFFFFFFFF); //wiimote pointer
        GRRLIB_DrawTile(50, 370, tex_mario, 0, 2, 2, 0xFFFFFFFF,mariotile);
        
        GRRLIB_Render();
        
        //mario animation        
        mariotile+=0.10;
        if(mariotile>3) mariotile=0;
    
    //scroll background
        backgroundmove-=0.6;
        backgroundmove2-=0.6;
        if(backgroundmove<-800) backgroundmove=801;        
        if(backgroundmove2<-800) backgroundmove2=801;        
    
    //exit when press home
        if(wpaddown & WPAD_BUTTON_HOME) {
            exit(0);
        }
    }

    // Be a good boy, clear the memory allocated by GRRLIB
    GRRLIB_Exit(); 
    free(tex_BGLevel1.data);
    free(tex_starpointer.data); //wiimote pointer
    free(tex_mario.data);
    return 0;
}

Can anyone help me?
Thx!

Last edited by xtoc (2009-05-28 21:21:59)

Offline

 

#2 2009-05-29 00:31:31

NoNameNo
Administrator

Re: Image flashing

hi,

in fact as i already said, clipping is shitty with GX, you cant have more than about 200 pixel out the screen without glitch wink
so, for your BG, slice them in 64 pixel width and display only viewable part wink

2nd idea :
use the SVN grrlib version, this bug seem to be removed wink

Offline

 

#3 2009-05-29 12:52:11

xtoc
Member

Re: Image flashing

Ok Thx,
I have read something about this version, but when i search the internet i can't find this version to download.
Do you know where i can download this version?
Also thx for quick response.

Offline

 

#5 2009-05-31 19:18:36

xtoc
Member

Re: Image flashing

Thx again!,

I'm using the tile methode, but there's a problem with it.

I'm using my background (res 640 x 480) splitted in 64px.
When i draw one, the image looks as 2x times bigger then it should be.


Code:

#include "../../../GRRLIB/GRRLIB/GRRLIB.h"
#include "../../../GRRLIB/GRRLIB/GRRLIB_addon.h"


#include <ogc/lwp_watchdog.h>    // Needed for gettime and ticks_to_millisecs
#include <stdlib.h>
#include <wiiuse/wpad.h>

#include "gfx/background.h"


Mtx GXmodelView2D;


int main() {
    u32 wpaddown;
    short i;

    // Load the image file to a texture structure
    GRRLIB_texImg *tex_background = GRRLIB_LoadTexture(background);

    // slice it
    GRRLIB_InitTileSet(tex_background, 64, 480, 0);


    GRRLIB_Init();
    WPAD_Init();

    while(1) {
        WPAD_SetVRes(0, 640, 480);
        WPAD_ScanPads();
        wpaddown = WPAD_ButtonsDown(0);

        //Display the background
        for(i = 0; i < 10; i++) {
        GRRLIB_DrawTile(64*i, 0, tex_background, 0, 2, 2, 0xFFFFFFFF,i);
        }
        
        GRRLIB_Render();
        
        if(wpaddown & WPAD_BUTTON_HOME) {
            exit(0);
        }
    }

    // Be a good boy, clear the memory allocated by GRRLIB
    GRRLIB_Exit(); 
    GRRLIB_FreeTexture(tex_background);
    return 0;
}

Is there something that i do wrong?

Last edited by xtoc (2009-05-31 23:04:08)

Offline

 

#6 2009-06-01 14:34:10

NoNameNo
Administrator

Re: Image flashing

you use :

"GRRLIB_DrawTile(64*i, 0, tex_background, 0, 2, 2, 0xFFFFFFFF,i);"

parameter are "GRRLIB_DrawTile(Xpos, Ypos, TheTileSet, RotationAngle, ZoomX, ZoomY, Color, TileNum);

So in your code you ask ZoomX and ZoomY (*2)

you should use :

"GRRLIB_DrawTile(64*i, 0, tex_background, 0, 1, 1, 0xFFFFFFFF,i);"

Offline

 

#7 2009-06-05 21:32:57

xtoc
Member

Re: Image flashing

Thx, there is one last question.

I split the background in width  64px height 480px (10 parts)

But my problem is :
The background starts clear...
But when the background starts moving , i get vertical black lines in it.
(i did try both grrlib/ grrlib-gx version° same issue)

Here a screenshot from it :

http://users.telenet.be/ganon/mds/IMAGE_246.jpg

(in the screenshot, you don't see that the blacklines are drawn from the top to the bottom of the screen, that's because the picture is taking from the tv.)

How does this come?


Thx again!

Last edited by xtoc (2009-06-05 21:39:09)

Offline

 

Board footer

Powered by FluxBB