You are not logged in.

#1 2009-06-21 19:13:33

tribasic
Member

Wierd lines when using GRRLIB_Plot

Hi,

I was messing around with the GRRLIB_Plot command while I was trying to learn how to make plasma effects, and discovered that I get black lines in my output. In the example that I posted, I believe the output should be a white box, but instead I get a white box with 2 black lines in it. I don't understand what I'm doing wrong.

Thanks,

Tribasic
----------------------------------------------------------------------------

Code:

#include "c:/devkitPro/GRRLIB/GRRLIB/GRRLIB.h"

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

Mtx GXmodelView2D;

int main() {
    u32 wpaddown;
    
    int x;
    int y;
    
    GRRLIB_Init();
    WPAD_Init();

    while(1) {
        WPAD_ScanPads();
        wpaddown = WPAD_ButtonsDown(0);
        for(x=0;x<256;x++){
            for(y=0;y<256;y++){
                GRRLIB_Plot(x,y,0xffffffff);
            }
        }
        GRRLIB_Render();
        if(wpaddown & WPAD_BUTTON_HOME) {
            exit(0);
        }
    }
    GRRLIB_Exit();
    return 0;
}

Offline

 

#2 2009-06-21 22:36:07

Crayon
Bad Mother Fucker

Re: Wierd lines when using GRRLIB_Plot

Hi, to make it easier use those color codes:

Code:

// RGBA Colors
#define GRRLIB_BLACK   0x000000FF
#define GRRLIB_MAROON  0x800000FF
#define GRRLIB_GREEN   0x008000FF
#define GRRLIB_OLIVE   0x808000FF
#define GRRLIB_NAVY    0x000080FF
#define GRRLIB_PURPLE  0x800080FF
#define GRRLIB_TEAL    0x008080FF
#define GRRLIB_GRAY    0x808080FF
#define GRRLIB_SILVER  0xC0C0C0FF
#define GRRLIB_RED     0xFF0000FF
#define GRRLIB_LIME    0x00FF00FF
#define GRRLIB_YELLOW  0xFFFF00FF
#define GRRLIB_BLUE    0x0000FFFF
#define GRRLIB_FUCHSIA 0xFF00FFFF
#define GRRLIB_AQUA    0x00FFFFFF
#define GRRLIB_WHITE   0xFFFFFFFF

To fill the screen in black before drawing the lines use:

Code:

        GRRLIB_FillScreen(GRRLIB_BLACK);    // Clear the screen

Offline

 

#3 2009-06-21 22:44:45

tribasic
Member

Re: Wierd lines when using GRRLIB_Plot

Hi Crayon!

Thanks for the colour codes!

Tribasic

Offline

 

#4 2009-06-24 22:55:42

tribasic
Member

Re: Wierd lines when using GRRLIB_Plot

I managed to get my `plasma`program to work! But I still had a problem if I used the GRRLIB_Plot command. If I use GRRLIB_Plot to fill the entire screen with pixels, I always get 2 black lines in my output. One is a verticle line on the left of my screen and the other is a horizontal line near the top of the screen .

I ended up drawing my pixels with GRRLIB_SetPixelTotexImg and then drawing it to the screen. It fixes the problem, but I find the GRRLIB_Plot command works a bit faster than actually using the GRRLIB_SetPixelTotexImg and GRRLIB_FlushTex commands.

Anyway, here is a compiled .DOL of the code from my original post which illustrates the line problem that I`m talking about. The output should be a white box, but for some reason I have 2 black lines on my box. I`m just curious about why it happens, because it doesn`t make sense to me.

http://www.mediafire.com/file/dzifezwjnke/box.dol

And in case anyone is interested, here is my `plasma` program. It`s really basic, but I`m going to play around with the sine equations and make a cooler colour pallete for a neater plasma effect.

http://www.mediafire.com/file/zc5j5z3zr … ma_004.rar

Thanks,

Tribasic

Offline

 

#5 2009-06-25 17:53:17

Crayon
Bad Mother Fucker

Re: Wierd lines when using GRRLIB_Plot

Hi, be careful in your code you put shift++; in your while loop. It's declare as an int. I don't know what's the limit of an int on a Wii but when it's reach I don't how it's going to react. One thing for sure it wont go to zero.

Instead of this code:

Code:

        if(wpaddown & WPAD_BUTTON_HOME) {
            exit(0);
        }

Use:

Code:

        if(wpaddown & WPAD_BUTTON_HOME) {
            break; // Get out of the while
        }

With this you will reach GRRLIB_Exit(); before exiting.

Offline

 

#6 2009-06-25 19:48:39

tribasic
Member

Re: Wierd lines when using GRRLIB_Plot

Hi Crayon!

Thanks for pointing that out to me. I totally missed it. Mostly because I'm still learning. But partly because I was really excited that my program was actually working!

One problem that I came across was initializing my 'plasma' array. I wasn't able to make the array very big because it would crash my Wii, but when I declared it by sayin, "static int plasma[640][480]", I was able to increase the size without any problems. I don't really understand why it was happening, but I read on the internet that I was probibly overflowing my stack or something.

Anyway, I'm happy it works! Thanks for your help.

Tribasic

Offline

 

#7 2009-06-25 20:24:56

Crayon
Bad Mother Fucker

Re: Wierd lines when using GRRLIB_Plot

I just want to add a comment about your code, after those lines gradient wont be useful, so it's best to free the memory:

Code:

    //read palette info
    for(x=0;x<256;x++){
        colour = GRRLIB_GetPixelFromtexImg(x,1,gradient);
        palette[x]=colour;
    }

Just add:

Code:

    GRRLIB_FreeTexture(gradient);

You don't need to use a temporary variable (colour), just use:

Code:

        palette[x] = GRRLIB_GetPixelFromtexImg(x,1,gradient);

To make your project smaller, change the height of line.png to 1 pixel instead of 4 wink

Offline

 

#8 2009-06-25 21:01:51

tribasic
Member

Re: Wierd lines when using GRRLIB_Plot

Thanks for taking a look at my code Crayon. smile

I'm going to make those changes.


Tribasic

Offline

 

#9 2009-06-25 21:54:42

Crayon
Bad Mother Fucker

Re: Wierd lines when using GRRLIB_Plot

Just for fun instead of using the gradient texture try using this to initialize your array:

Code:

    int palette[256] = {0xF9F7D4FF,0xF9F6C5FF,0xF9F6B7FF,0xF9F6A8FF,0xF8F59AFF,0xF9F48BFF,0xF8F37CFF,0xF8F26EFF,0xF9F25EFF,0xF8F24EFF,0xF9F13FFF,0xF8F02FFF,0xF8F020FF,0xF8ED14FF,0xF9E516FF,0xFADD18FF,0xF9D51BFF,0xFACC1DFF,0xFBC320FF,0xFCBB23FF,0xFCB225FF,0xFDA928FF,0xFEA12BFF,0xFE972EFF,0xFF8F31FF,0xFE8931FF,0xFB8430FF,0xFA802EFF,0xF87C2CFF,0xF5782BFF,0xF3742AFF,0xF26F29FF,0xEF6C26FF,0xED6825FF,0xEB6424FF,0xE95F22FF,0xE75B21FF,0xE5571FFF,0xE4531EFF,0xE14F1CFF,0xDF4B1BFF,0xDD4719FF,0xDA4017FF,0xD73A15FF,0xD43412FF,0xD12D10FF,0xCD260EFF,0xCA200CFF,0xC71909FF,0xC41307FF,0xC00D04FF,0xBD0602FF,0xBA0000FF,0xB40000FF,0xAF0000FF,0xA90000FF,0xA50000FF,0x9F0000FF,0x9A0000FF,0x940000FF,0x8E0000FF,0x8A0000FF,0x840000FF,0x7E0000FF,0x790000FF,0x730000FF,0x6F0000FF,0x690000FF,0x640000FF,0x5E0000FF,0x5C0000FF,0x5A0000FF,0x590000FF,0x570000FF,0x550000FF,0x540000FF,0x520000FF,0x510000FF,0x4F0000FF,0x4E0000FF,0x4C0000FF,0x4A0000FF,0x490000FF,0x470000FF,0x460000FF,0x440000FF,0x420000FF,0x410000FF,0x400000FF,0x3E0000FF,0x3C0000FF,0x3B0000FF,0x390000FF,0x380000FF,0x360000FF,0x340000FF,0x330000FF,0x310000FF,0x300000FF,0x2E0000FF,0x2C0000FF,0x2B0000FF,0x290000FF,0x270000FF,0x260000FF,0x250000FF,0x230000FF,0x210000FF,0x1F0000FF,0x1E0000FF,0x1C0000FF,0x1B0000FF,0x190000FF,0x180000FF,0x170000FF,0x150000FF,0x130000FF,0x110000FF,0x0F0000FF,0x0E0000FF,0x0C0000FF,0x0B0000FF,0x090000FF,0x080000FF,0x060000FF,0x040000FF,0x040000FF,0x020000FF,0x000000FF,0x020000FF,0x030000FF,0x050000FF,0x060000FF,0x080000FF,0x090000FF,0x0C0000FF,0x0C0000FF,0x0F0000FF,0x100000FF,0x120000FF,0x130000FF,0x140000FF,0x170000FF,0x180000FF,0x190000FF,0x1B0000FF,0x1C0000FF,0x1E0000FF,0x200000FF,0x220000FF,0x230000FF,0x240000FF,0x260000FF,0x270000FF,0x2A0000FF,0x2B0000FF,0x2C0000FF,0x2E0000FF,0x300000FF,0x310000FF,0x330000FF,0x340000FF,0x360000FF,0x370000FF,0x390000FF,0x3A0000FF,0x3C0000FF,0x3D0000FF,0x400000FF,0x410000FF,0x420000FF,0x440000FF,0x450000FF,0x470000FF,0x490000FF,0x4A0000FF,0x4C0000FF,0x4E0000FF,0x500000FF,0x500000FF,0x530000FF,0x530000FF,0x550000FF,0x570000FF,0x590000FF,0x5A0000FF,0x5C0000FF,0x5E0000FF,0x630000FF,0x690000FF,0x6E0000FF,0x740000FF,0x7A0000FF,0x7F0000FF,0x830000FF,0x8A0000FF,0x8E0000FF,0x940000FF,0x9A0000FF,0x9F0000FF,0xA40000FF,0xA90000FF,0xAF0000FF,0xB40000FF,0xBA0000FF,0xBD0602FF,0xC10D05FF,0xC31307FF,0xC61909FF,0xCA210BFF,0xCD260EFF,0xD02D10FF,0xD43312FF,0xD73A15FF,0xDA4117FF,0xDD4619FF,0xDF4B1BFF,0xE14E1CFF,0xE3531EFF,0xE6571FFF,0xE75B21FF,0xE95F22FF,0xEB6323FF,0xED6725FF,0xEF6B27FF,0xF17028FF,0xF47429FF,0xF6782BFF,0xF87C2CFF,0xF9802EFF,0xFB842FFF,0xFE8831FF,0xFF8E31FF,0xFE982EFF,0xFEA02BFF,0xFDA928FF,0xFDB226FF,0xFBBB23FF,0xFBC421FF,0xFACC1EFF,0xF9D41CFF,0xF9DD19FF,0xF9E616FF,0xF8EE13FF,0xF8F020FF,0xF8F02FFF,0xF8F13FFF,0xF8F24FFF,0xF9F25EFF,0xF9F36DFF,0xF9F37DFF,0xF9F48BFF,0xF9F49AFF,0xF9F5A9FF,0xF8F5B7FF,0xF9F7C6FF};

Offline

 

#10 2009-06-26 00:02:37

tribasic
Member

Re: Wierd lines when using GRRLIB_Plot

Wow!! I'm impressed!

I'm fairly certain you will guess my next question.

How were you able to convert my colour palette .PNG into hex codes? That's awesome!!!!

By the way, my compiled .DOL file is now only 249kb!! With my old code it was 458kb!!! Huge difference big_smile Thanks!

Last edited by tribasic (2009-06-26 02:19:55)

Offline

 

#11 2009-06-26 16:28:01

Crayon
Bad Mother Fucker

Re: Wierd lines when using GRRLIB_Plot

I just did a small change to my software called WiiBuilder. The code for converting an image file to GRRLIB 2.0 or less was very similar.

Offline

 

Board footer

Powered by FluxBB