Welcome! Log In Create A New Profile

Advanced

Alpha Pngs and double buffer

Posted by the_marioga 
Alpha Pngs and double buffer
March 11, 2010 07:41PM
Hello, I have two questions, first is how do I load png with alpha with the frontier's library (the function rgba8 but I think it is not using)?, Second is can I use double-buffer without using GX, and if can not, at least you can without screenlib of hermes (not for nothing is that I want a code that depends on many libraries)?

Thank you and sorry for talking bad English, but I'm Spanish XD



Edited 1 time(s). Last edit at 03/11/2010 07:48PM by the_marioga.
Re: Alpha Pngs and double buffer
March 11, 2010 08:51PM
If you need an example of PNGU, you could check this code: [code.google.com]
Re: Alpha Pngs and double buffer
March 11, 2010 10:22PM
Actually, every library uses GX, because that's how we can deal with the hardware, so except you write lots of machine code, you're using GX.
Using double-buffer comes even in the simplest examples, it's part of initialization (you can choose triple buffer, but most times it's double that you want to use).

What do you want to do? maybe if you tell us something more, we can help you better.
Re: Alpha Pngs and double buffer
March 12, 2010 08:36PM
Thanks for the example, also works without grrlib, right?, well, in case you need gx for double buffer gx, what do I dor put it?, that in the examples of DevkitPro not use double buffering, at least in my devkitpro (r19) and the internet examples use the hermes' library and I do not want to depend on external libraries, the proyect is luafwii, you know?

thanks
Re: Alpha Pngs and double buffer
March 12, 2010 09:12PM
Look at this project: C:\devkitPro\examples\wii\graphics\gx\gxSprites\gxsprites.pnproj
With those lines:
	// allocate 2 framebuffers for double buffering
	frameBuffer[0] = MEM_K0_TO_K1(SYS_AllocateFramebuffer(rmode));
	frameBuffer[1] = MEM_K0_TO_K1(SYS_AllocateFramebuffer(rmode));
I did not told you to use GRRLIB, but to look at how GRRLIB is using PNGU.
Re: Alpha Pngs and double buffer
March 12, 2010 11:17PM
I tried already 3 or 4 different ways to double buffer, and the only time I worked a while the screen fills with green stripes, It don't work a simple printf

this is one of the black screen
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 

#define DEFAULT_FIFO_SIZE	(256*1024)

static void *xfb[2] = { NULL, NULL};
static GXRModeObj *rmode;
PNGUPROP imgProp;
IMGCTX ctx;
GXTexObj texObj;
u32	fb;
u32 first_frame;
f32 yscale;
u32 xfbHeight;
Mtx44 perspective;
Mtx GXmodelView2D;
void *gp_fifo = NULL;
GXColor background = {0, 0, 0, 0xff};
int i;


void Init() {
	VIDEO_Init();
	fatInitDefault();
	rmode = VIDEO_GetPreferredMode(NULL);
	fb = 0;
	first_frame = 1;
	xfb[0] = MEM_K0_TO_K1(SYS_AllocateFramebuffer(rmode));
	xfb[1] = MEM_K0_TO_K1(SYS_AllocateFramebuffer(rmode));
	VIDEO_Configure(rmode);
	VIDEO_SetNextFramebuffer(xfb[fb]);
	VIDEO_SetBlack(FALSE);
	VIDEO_Flush();
	VIDEO_WaitVSync();
	if(rmode->viTVMode&VI_NON_INTERLACE) VIDEO_WaitVSync();
	
	fb ^= 1;
	gp_fifo = memalign(32,DEFAULT_FIFO_SIZE);
	memset(gp_fifo,0,DEFAULT_FIFO_SIZE);
	GX_Init(gp_fifo,DEFAULT_FIFO_SIZE);
	GX_SetCopyClear(background, 0x00ffffff);
	GX_SetViewport(0,0,rmode->fbWidth,rmode->efbHeight,0,1);
	yscale = GX_GetYScaleFactor(rmode->efbHeight,rmode->xfbHeight);
	xfbHeight = GX_SetDispCopyYScale(yscale);
	GX_SetScissor(0,0,rmode->fbWidth,rmode->efbHeight);
	GX_SetDispCopySrc(0,0,rmode->fbWidth,rmode->efbHeight);
	GX_SetDispCopyDst(rmode->fbWidth,xfbHeight);
	GX_SetCopyFilter(rmode->aa,rmode->sample_pattern,GX_TRUE,rmode->vfilter);
	GX_SetFieldMode(rmode->field_rendering,((rmode->viHeight==2*rmode->xfbHeight)?GX_ENABLE:GX_DISABLE));
	if (rmode->aa)
		GX_SetPixelFmt(GX_PF_RGB565_Z16, GX_ZC_LINEAR);
	else
		GX_SetPixelFmt(GX_PF_RGB8_Z24, GX_ZC_LINEAR);
	GX_SetCullMode(GX_CULL_NONE);
	GX_CopyDisp(xfb[fb],GX_TRUE);
	GX_SetDispCopyGamma(GX_GM_1_0);
	GX_SetVtxAttrFmt(GX_VTXFMT0, GX_VA_POS, GX_POS_XY, GX_F32, 0);
	GX_SetVtxAttrFmt(GX_VTXFMT0, GX_VA_TEX0, GX_TEX_ST, GX_F32, 0);
	GX_SetNumChans(1);
	GX_SetNumTexGens(1);
	GX_SetTevOp(GX_TEVSTAGE0, GX_REPLACE);
	GX_SetTevOrder(GX_TEVSTAGE0, GX_TEXCOORD0, GX_TEXMAP0, GX_COLOR0A0);
	GX_SetTexCoordGen(GX_TEXCOORD0, GX_TG_MTX2x4, GX_TG_TEX0, GX_IDENTITY);
	GX_InvalidateTexAll();
}
void InitWhile() {
	WPAD_ScanPads();
	if (WPAD_ButtonsDown(0) & WPAD_BUTTON_HOME) exit(0);
	GX_SetViewport(0,0,rmode->fbWidth,rmode->efbHeight,0,1);
	GX_InvVtxCache();
	GX_InvalidateTexAll();
	GX_ClearVtxDesc();
	GX_SetVtxDesc(GX_VA_POS, GX_DIRECT);
	GX_SetVtxDesc(GX_VA_TEX0, GX_DIRECT);
	guMtxIdentity(GXmodelView2D);
	guMtxTransApply (GXmodelView2D, GXmodelView2D, 0.0F, 0.0F, -5.0F);
	GX_LoadPosMtxImm(GXmodelView2D,GX_PNMTX0);
}
void CloseWhile() {
	GX_DrawDone();
	GX_SetZMode(GX_TRUE, GX_LEQUAL, GX_TRUE);
	GX_SetBlendMode(GX_BM_BLEND, GX_BL_SRCALPHA, GX_BL_INVSRCALPHA, GX_LO_CLEAR);
	GX_SetAlphaUpdate(GX_TRUE);
	GX_SetColorUpdate(GX_TRUE);
	GX_CopyDisp(xfb[fb],GX_TRUE);
	VIDEO_SetNextFramebuffer(xfb[fb]);
	if(first_frame) {
		VIDEO_SetBlack(FALSE);
		first_frame = 0;
	}
	VIDEO_Flush();
	VIDEO_WaitVSync();
	fb ^= 1;
}

int main() {
	Init();
	while(1) {
		InitWhile();
		printf("Probando");
		CloseWhile();
	}
	return 0;
}



Edited 1 time(s). Last edit at 03/12/2010 11:20PM by the_marioga.
Re: Alpha Pngs and double buffer
March 13, 2010 01:03AM
Quote
the_marioga
It don't work a simple printf
I guess this is normal since you did not initialize the console with console_init.

printf will never work at the same time when you are using GX. So you need to choose, graphic or console. Or maybe one after the other, but that's more complicated.
Re: Alpha Pngs and double buffer
March 13, 2010 04:40PM
ok, other question, the PNGU_DecodeTo4x4RGBA8 didn't allow for print in coords



Edited 1 time(s). Last edit at 03/13/2010 05:22PM by the_marioga.
Re: Alpha Pngs and double buffer
March 15, 2010 04:04PM
With PNGU_DecodeTo4x4RGBA8 I cant see the image, and with PNGU_DecodeToRGBA8 I crash my wii, Finally i'm using the screenlib with little modifications
Sorry, only registered users may post in this forum.

Click here to login