mirror of
https://github.com/GRRLIB/GRRLIB.git
synced 2024-11-22 15:02:20 +00:00
[BUG] GRRLIB_GetPixelFromtexImg and GRRLIB_SetPixelTotexImg now WORKING
!!
This commit is contained in:
parent
324f4792e8
commit
c8276275ea
5 changed files with 31 additions and 29 deletions
|
@ -52,7 +52,7 @@ ChangeLog :
|
|||
|
||||
* add GRRLIB_PtInRect, GRRLIB_RectInRect and GRRLIB_RectOnRect.
|
||||
|
||||
* GRRLIB_GetPixelFromtexImg and GRRLIB_SetPixelTotexImg ////////////////////////// BUGGED DO NOT USE !!!
|
||||
* GRRLIB_GetPixelFromtexImg and GRRLIB_SetPixelTotexImg
|
||||
|
||||
* add GRRLIB_Exit to free the memory allocated by GRRLIB
|
||||
|
||||
|
|
|
@ -434,7 +434,6 @@ bool GRRLIB_RectOnRect(int rect1x, int rect1y, int rect1w, int rect1h, int rect2
|
|||
|
||||
/**
|
||||
* Return the color value of a pixel from a GRRLIB_texImg
|
||||
* @bug !!!!!!!!!!!!!!!! NOT WORKING NEED HELP !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
* @param x specifies the x-coordinate of the pixel in the texture.
|
||||
* @param y specifies the y-coordinate of the pixel in the texture.
|
||||
* @param tex texture to get the color from.
|
||||
|
@ -447,9 +446,9 @@ u32 GRRLIB_GetPixelFromtexImg(int x, int y, GRRLIB_texImg tex){
|
|||
u32 value;
|
||||
u32 offset;
|
||||
|
||||
x1 = x >> 2; // div by 4
|
||||
y1 = y >> 2; // div by 4
|
||||
offset = (x1*64) + (x-(x1*4))*2+y*8;
|
||||
x1 = x >> 2;
|
||||
y1 = y >> 2;
|
||||
offset = (y1*16*tex.w) + (x1*64) + ((y%4 * 4 + x%4 ) * 2); // Fuckin equation found by NoNameNo ;)
|
||||
|
||||
a=*(truc+offset);
|
||||
r=*(truc+offset+1);
|
||||
|
@ -463,7 +462,6 @@ u32 GRRLIB_GetPixelFromtexImg(int x, int y, GRRLIB_texImg tex){
|
|||
|
||||
/**
|
||||
* Set the color value of a pixel to a GRRLIB_texImg
|
||||
* @bug !!!!!!!!!!!!!!!! NOT WORKING NEED HELP !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
* @param x specifies the x-coordinate of the pixel in the texture.
|
||||
* @param y specifies the y-coordinate of the pixel in the texture.
|
||||
* @param tex texture to set the color to.
|
||||
|
@ -475,19 +473,22 @@ void GRRLIB_SetPixelTotexImg(int x, int y, GRRLIB_texImg tex, u32 color){
|
|||
u8 r, g, b, a;
|
||||
u32 offset;
|
||||
|
||||
x1 = x >> 2; // div by 4
|
||||
y1 = y >> 2; // div by 4
|
||||
offset = (x1*64) + (x-(x1*4))*2+y*8;
|
||||
x1 = x >> 2;
|
||||
y1 = y >> 2;
|
||||
offset = (y1*16*tex.w) + (x1*64) + ((y%4 * 4 + x%4 ) * 2); // Fuckin equation found by NoNameNo ;)
|
||||
|
||||
a=color & 0xFF;
|
||||
r=(color>>8) & 0xFF;
|
||||
b=(color>>8) & 0xFF;
|
||||
g=(color>>16) & 0xFF;
|
||||
b=(color>>24) & 0xFF;
|
||||
r=(color>>24) & 0xFF;
|
||||
|
||||
*(truc+offset)=a;
|
||||
*(truc+offset+1)=r;
|
||||
*(truc+offset+32)=g;
|
||||
*(truc+offset+33)=b;
|
||||
|
||||
DCFlushRange(tex.data, tex.w * tex.h * 4);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -5,16 +5,14 @@ Visit http://www.devkitpro.org
|
|||
|
||||
const unsigned char pixeltest[] = {
|
||||
0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a, 0x00, 0x00, 0x00, 0x0d, 0x49, 0x48, 0x44, 0x52,
|
||||
0x00, 0x00, 0x00, 0x28, 0x00, 0x00, 0x00, 0x28, 0x08, 0x06, 0x00, 0x00, 0x00, 0x8c, 0xfe, 0xb8,
|
||||
0x6d, 0x00, 0x00, 0x00, 0x01, 0x73, 0x52, 0x47, 0x42, 0x00, 0xae, 0xce, 0x1c, 0xe9, 0x00, 0x00,
|
||||
0x00, 0x06, 0x62, 0x4b, 0x47, 0x44, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x43, 0xbb, 0x7f,
|
||||
0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x08, 0x08, 0x06, 0x00, 0x00, 0x00, 0xc4, 0x0f, 0xbe,
|
||||
0x8b, 0x00, 0x00, 0x00, 0x01, 0x73, 0x52, 0x47, 0x42, 0x00, 0xae, 0xce, 0x1c, 0xe9, 0x00, 0x00,
|
||||
0x00, 0x06, 0x62, 0x4b, 0x47, 0x44, 0x00, 0xff, 0x00, 0xff, 0x00, 0xff, 0xa0, 0xbd, 0xa7, 0x93,
|
||||
0x00, 0x00, 0x00, 0x09, 0x70, 0x48, 0x59, 0x73, 0x00, 0x00, 0x0b, 0x13, 0x00, 0x00, 0x0b, 0x13,
|
||||
0x01, 0x00, 0x9a, 0x9c, 0x18, 0x00, 0x00, 0x00, 0x07, 0x74, 0x49, 0x4d, 0x45, 0x07, 0xd9, 0x02,
|
||||
0x04, 0x14, 0x1e, 0x12, 0x30, 0x90, 0x66, 0x4b, 0x00, 0x00, 0x00, 0x37, 0x49, 0x44, 0x41, 0x54,
|
||||
0x58, 0xc3, 0xed, 0xce, 0x01, 0x0d, 0x00, 0x00, 0x08, 0x03, 0x20, 0xb5, 0x7f, 0xe7, 0x5b, 0x43,
|
||||
0x37, 0x48, 0x40, 0x27, 0x49, 0x1d, 0x36, 0x75, 0x9c, 0xa0, 0xa0, 0xa0, 0xa0, 0xa0, 0xa0, 0xa0,
|
||||
0xa0, 0xa0, 0xa0, 0xa0, 0xa0, 0xa0, 0xa0, 0xa0, 0xa0, 0xa0, 0xa0, 0xa0, 0xa0, 0xa0, 0xa0, 0xe0,
|
||||
0xd7, 0xe0, 0x02, 0x3e, 0xea, 0x04, 0x4c, 0xc6, 0x8c, 0xdb, 0x8d, 0x00, 0x00, 0x00, 0x00, 0x49,
|
||||
0x45, 0x4e, 0x44, 0xae, 0x42, 0x60, 0x82
|
||||
0x05, 0x12, 0x1b, 0x0e, 0xe5, 0xd7, 0xd5, 0x96, 0x00, 0x00, 0x00, 0x16, 0x49, 0x44, 0x41, 0x54,
|
||||
0x18, 0xd3, 0x63, 0xfc, 0xff, 0xff, 0xff, 0x7f, 0x06, 0x3c, 0x80, 0x89, 0x81, 0x00, 0x18, 0x1e,
|
||||
0x0a, 0x00, 0x1b, 0x6e, 0x04, 0x0c, 0x19, 0x49, 0x52, 0xd1, 0x00, 0x00, 0x00, 0x00, 0x49, 0x45,
|
||||
0x4e, 0x44, 0xae, 0x42, 0x60, 0x82
|
||||
};
|
||||
const int pixeltest_size = sizeof(pixeltest);
|
||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 183 B After Width: | Height: | Size: 150 B |
|
@ -56,7 +56,8 @@ Mtx GXmodelView2D;
|
|||
int main() {
|
||||
int left = 0, top = 0, page = 0, frame = TILE_DOWN + 1;
|
||||
unsigned int wait = TILE_DELAY, direction = TILE_DOWN, direction_new = TILE_DOWN;
|
||||
int x, y, val;
|
||||
int x, y;
|
||||
u32 val;
|
||||
ir_t ir1;
|
||||
u32 wpaddown, wpadheld;
|
||||
Vector triangle[] = {{400,200,0.0f}, {500,400,0.0f}, {300,400,0.0f}};
|
||||
|
@ -69,7 +70,7 @@ int main() {
|
|||
|
||||
GRRLIB_texImg tex_test_jpg = GRRLIB_LoadTextureJPG(test_jpg);
|
||||
|
||||
GRRLIB_texImg tex_pixeltest = GRRLIB_LoadTexturePNG(pixeltest);
|
||||
GRRLIB_texImg tex_pixeltest = GRRLIB_LoadTexturePNG(pixeltest); // a 8x8 only white test png
|
||||
|
||||
GRRLIB_texImg tex_sprite_png = GRRLIB_LoadTexturePNG(sprite);
|
||||
GRRLIB_InitTileSet(&tex_sprite_png, 24, 32, 0);
|
||||
|
@ -89,6 +90,13 @@ int main() {
|
|||
GRRLIB_texImg tex_BMfont5 = GRRLIB_LoadTexturePNG(BMfont5);
|
||||
GRRLIB_InitTileSet(&tex_BMfont5, 8, 16, 0);
|
||||
|
||||
for(y=0;y<8;y++){
|
||||
for(x=0;x<8;x++){
|
||||
val = GRRLIB_GetPixelFromtexImg(x+8,y+8,tex_sprite_png);
|
||||
GRRLIB_SetPixelTotexImg(x, y, tex_pixeltest, val);
|
||||
}
|
||||
}
|
||||
|
||||
while(1) {
|
||||
WPAD_SetVRes(0, 640, 480);
|
||||
WPAD_ScanPads();
|
||||
|
@ -105,14 +113,9 @@ int main() {
|
|||
GRRLIB_Printf(5, 25, tex_BMfont2, GRRLIB_WHITE, 1, "IMAGES DEMO");
|
||||
|
||||
GRRLIB_DrawImg(10, 50, tex_test_jpg, 0, 1, 1, GRRLIB_WHITE);
|
||||
GRRLIB_DrawImg(400, 150, tex_pixeltest, 0, 1, 1, GRRLIB_WHITE);
|
||||
GRRLIB_DrawImg(400, 150, tex_pixeltest, 0, 20, 20, GRRLIB_WHITE);
|
||||
|
||||
|
||||
for(y=0; y<tex_pixeltest.h; y++) { //------------ <just a test>
|
||||
for(x=0; x<(tex_pixeltest.w*20); x++) {
|
||||
val = 1 + (int) (16777215.0 * (rand() / (RAND_MAX + 1.0)));
|
||||
GRRLIB_SetPixelTotexImg(x, y, tex_pixeltest, (val<<8)|0xFF);
|
||||
}
|
||||
} //------------ </just a test>
|
||||
|
||||
// Draw a sprite
|
||||
GRRLIB_DrawTile(600, 400, tex_sprite_png, 0, 2, 2, GRRLIB_WHITE, 12*4); // Rupee
|
||||
|
|
Loading…
Reference in a new issue