Ir resolution shifted off screen? March 15, 2009 07:49AM | Registered: 15 years ago Posts: 10 |
#include "GRRLIB.h" #include#include #include "GFX/pointer.h" #include "GFX/background.h" #include "GFX/font3.h" ir_t ir; orient_t orient; static u32 *xfb; static GXRModeObj *rmode; Mtx GXmodelView2D; int main() { u32 pressed; GRRLIB_Init(); WPAD_Init(); rmode = VIDEO_GetPreferredMode(NULL); xfb = MEM_K0_TO_K1(SYS_AllocateFramebuffer(rmode)); WPAD_SetVRes(WPAD_CHAN_ALL, rmode->fbWidth, rmode->xfbHeight); WPAD_SetDataFormat(WPAD_CHAN_ALL, WPAD_FMT_BTNS_ACC_IR); GRRLIB_texImg tex_bg = GRRLIB_LoadTexture(background); GRRLIB_texImg tex_pointer = GRRLIB_LoadTexture(pointer); GRRLIB_texImg tex_font3 = GRRLIB_LoadTexture(font3); GRRLIB_InitTileSet(&tex_font3, 32, 32, 32); int centered = tex_pointer.w/2; int right = rmode->fbWidth-(7*32); while(1) { //Wiimote WPAD_ScanPads(); pressed = WPAD_ButtonsDown(WPAD_CHAN_0); //Background GRRLIB_FillScreen(0x000000FF); GRRLIB_DrawImg(0, 0, tex_bg, 0, 1, 1, 0xFFFFFFFF); //Wiimote IR WPAD_IR(WPAD_CHAN_0, &ir); if(ir.valid){ GRRLIB_Printf(right, 68, tex_font3, 0xFFFFFFFF, 1, "X:%d", (int)ir.x); GRRLIB_Printf(right, 100, tex_font3, 0xFFFFFFFF, 1, "Y:%d", (int)ir.y); } //Wiimote Rotation WPAD_Orientation(WPAD_CHAN_0, &orient); GRRLIB_Printf(right, 34, tex_font3, 0xFFFFFFFF, 1, "R:%d", (int)orient.roll); //Draw Pointer GRRLIB_DrawImg(ir.sx-centered, ir.sy-centered, tex_pointer, orient.roll, 1, 1, 0xFFFFFFFF); //Render GRRLIB_Render(); //Exit to loader if (pressed & WPAD_BUTTON_HOME) { exit(0); } } GRRLIB_Exit(); free(tex_pointer.data); free(tex_bg.data); free(tex_font3.data); return 0; }
Re: Ir resolution shifted off screen? March 15, 2009 10:08AM | Registered: 16 years ago Posts: 68 |
Re: Ir resolution shifted off screen? March 16, 2009 02:48PM | Registered: 16 years ago Posts: 42 |