static void build_disp_list(void) { DCInvalidateRange(display_list, sizeof(display_list)); GX_BeginDispList(display_list, sizeof(display_list)); GX_Begin(GX_QUADS, GX_VTXFMT0, 4); for (unsigned i = 0; i < 4; i++) { GX_Position1x8(i); GX_TexCoord1x8(i); } GX_End(); display_list_size = GX_EndDispList(); }
void skybox_render (skybox_info *skybox) { const u32 vtxfmt = GX_VTXFMT0; int face; GX_ClearVtxDesc (); GX_SetVtxDesc (GX_VA_POS, GX_INDEX8); GX_SetVtxDesc (GX_VA_TEX0, GX_DIRECT); GX_SetArray (GX_VA_POS, vertices, 3 * sizeof (f32)); GX_SetVtxAttrFmt (vtxfmt, GX_VA_POS, GX_POS_XYZ, GX_F32, 0); GX_SetVtxAttrFmt (vtxfmt, GX_VA_TEX0, GX_TEX_ST, GX_F32, 0); GX_SetCullMode (GX_CULL_BACK); for (face = 0; face < 6; face++) { shader_load (skybox->face_shader[face]); GX_Begin (GX_TRIANGLESTRIP, vtxfmt, 4); GX_Position1x8 (faces[face][0]); GX_TexCoord2f32 (0, 1); GX_Position1x8 (faces[face][1]); GX_TexCoord2f32 (0, 0); GX_Position1x8 (faces[face][2]); GX_TexCoord2f32 (1, 1); GX_Position1x8 (faces[face][3]); GX_TexCoord2f32 (1, 0); GX_End (); } }
void BoxCover::Draw() { u8 BoxAlpha = (int) (alpha+alphaDyn) & 0xFF; GX_LoadProjectionMtx(projection, GX_PERSPECTIVE); GX_ClearVtxDesc(); GX_InvVtxCache(); GX_SetVtxDesc(GX_VA_POS, GX_INDEX8); GX_SetVtxDesc(GX_VA_CLR0, GX_DIRECT); GX_SetVtxDesc(GX_VA_TEX0, GX_INDEX8); //! don't draw inside of the box GX_SetCullMode(GX_CULL_FRONT); Mtx modelView; Mtx modelView2; Mtx modelView3; guVector cubeAxis = {0,0,1}; guVector cubeAxis2 = {0,1,0}; guVector cubeAxis3 = {1,0,0}; guMtxIdentity(modelView); guMtxRotAxisDeg(modelView3, &cubeAxis3, RotX-Animation2); guMtxRotAxisDeg(modelView2, &cubeAxis2, RotY+Animation2+xoffsetDyn/2.0f); guMtxRotAxisDeg(modelView, &cubeAxis, RotZ-Animation); guMtxConcat(modelView3, modelView2, modelView2); guMtxConcat(modelView2, modelView, modelView); if(Settings.widescreen) guMtxScaleApply(modelView, modelView, Settings.WSFactor, 1.0f, 1.0f); guMtxTransApply(modelView, modelView, PosX+xoffsetDyn/680.0f+movePosX, PosY+yoffsetDyn/680.0f+movePosY, PosZ); guMtxConcat(view,modelView,modelView); GX_LoadPosMtxImm(modelView, GX_PNMTX0); //! Border quads GX_LoadTexObj(&boxBorderTex, GX_TEXMAP0); GX_InvalidateTexAll(); GX_SetArray(GX_VA_POS, (void *) &g_boxMeshQ[0].pos, sizeof(g_boxMeshQ[0])); GX_SetArray(GX_VA_TEX0, (void *) &g_boxMeshQ[0].texCoord, sizeof(g_boxMeshQ[0])); GX_Begin(GX_QUADS, GX_VTXFMT0, g_boxMeshQSize); for (u32 j = 0; j < g_boxMeshQSize; ++j) { GX_Position1x8(j); GX_Color4u8(boxColor.r, boxColor.g, boxColor.b, BoxAlpha); GX_TexCoord1x8(j); } GX_End(); //! Border triangles GX_SetArray(GX_VA_POS, (void *) &g_boxMeshT[0].pos, sizeof(g_boxMeshT[0])); GX_SetArray(GX_VA_TEX0, (void *) &g_boxMeshT[0].texCoord, sizeof(g_boxMeshT[0])); GX_Begin(GX_TRIANGLES, GX_VTXFMT0, g_boxMeshTSize); for (u32 j = 0; j < g_boxMeshTSize; ++j) { GX_Position1x8(j); GX_Color4u8(boxColor.r, boxColor.g, boxColor.b, BoxAlpha); GX_TexCoord1x8(j); } GX_End(); //! Back Cover (Might be flat) GX_LoadTexObj(flatCover ? &defaultBoxTex : &coverTex, GX_TEXMAP0); GX_InvalidateTexAll(); GX_SetArray(GX_VA_POS, (void *) &g_boxBackCoverMesh[0].pos, sizeof(g_boxBackCoverMesh[0])); GX_SetArray(GX_VA_TEX0, (void *) &g_boxBackCoverMesh[0].texCoord, sizeof(g_boxBackCoverMesh[0])); GX_Begin(GX_QUADS, GX_VTXFMT0, g_boxBackCoverMeshSize); for (u32 j = 0; j < g_boxBackCoverMeshSize; ++j) { GX_Position1x8(j); if(flatCover) GX_Color4u8(boxColor.r, boxColor.g, boxColor.b, BoxAlpha); else GX_Color4u8(0xff, 0xff, 0xff, BoxAlpha); GX_TexCoord1x8(j); } GX_End(); if(flatCover) { //! Front Flat Cover GX_LoadTexObj(&coverTex, GX_TEXMAP0); GX_InvalidateTexAll(); GX_SetArray(GX_VA_POS, (void *) &g_flatCoverMesh[0].pos, sizeof(g_flatCoverMesh[0])); GX_SetArray(GX_VA_TEX0, (void *) &g_flatCoverMesh[0].texCoord, sizeof(g_flatCoverMesh[0])); GX_Begin(GX_QUADS, GX_VTXFMT0, g_flatCoverMeshSize); for (u32 j = 0; j < g_flatCoverMeshSize; ++j) { GX_Position1x8(j); GX_Color4u8(0xff, 0xff, 0xff, 0xff); GX_TexCoord1x8(j); } GX_End(); } else { //! Front Cover GX_SetArray(GX_VA_POS, (void *) &g_boxCoverMesh[0].pos, sizeof(g_boxCoverMesh[0])); GX_SetArray(GX_VA_TEX0, (void *) &g_boxCoverMesh[0].texCoord, sizeof(g_boxCoverMesh[0])); GX_Begin(GX_QUADS, GX_VTXFMT0, g_boxCoverMeshSize); for (u32 j = 0; j < g_boxCoverMeshSize; ++j) { GX_Position1x8(j); GX_Color4u8(0xff, 0xff, 0xff, BoxAlpha); GX_TexCoord1x8(j); } GX_End(); } //! stop cull GX_SetCullMode(GX_CULL_NONE); UpdateEffects(); }
void gdl::FFont::DrawText(const char *text, short x, short y, float scale, u32 col) { // Draws text using the current font set by gdl_SetCurrentFont() float tx; int c,tc; Mtx TempMatrix; GXColor TempCol; if (vList == NULL) return; if ((x == gdl::Centered) || (x == gdl::PCentered)) { tx = gdl::ScreenCenterX - ((((cw+1)*strlen(text))*scale)/2)+(scale/2); } else { tx = x; } TempCol.r = RED(col); TempCol.g = GREEN(col); TempCol.b = BLUE(col); TempCol.a = ALPHA(col); GX_LoadTexObj(charTexObj, GX_TEXMAP0); GX_SetTevOp(GX_TEVSTAGE0, GX_MODULATE); GX_ClearVtxDesc(); GX_SetVtxDesc(GX_VA_POS, GX_INDEX8); GX_SetVtxDesc(GX_VA_TEX0, GX_INDEX16); GX_SetArray(GX_VA_POS, vList, 2*sizeof(s16)); GX_SetArray(GX_VA_TEX0, tList, 2*sizeof(f32)); guMtxCopy(gdl::wii::ModelMtx, TempMatrix); guMtxApplyTrans(TempMatrix, TempMatrix, tx, y, 0); guMtxApplyScale(TempMatrix, TempMatrix, scale, scale, 0); GX_LoadPosMtxImm(TempMatrix, GX_PNMTX0); GX_SetChanCtrl(GX_COLOR0A0, GX_DISABLE, GX_SRC_VTX, GX_SRC_REG, 0, GX_DF_NONE, GX_AF_NONE); GX_SetChanMatColor(GX_COLOR0A0, TempCol); for(c=0; text[c] != 0x00; c++) { tc = 4*((u_char*)text)[c]; GX_Begin(GX_QUADS, GX_VTXFMT0, 4); GX_Position1x8(0); GX_TexCoord1x16(tc); GX_Position1x8(1); GX_TexCoord1x16(tc+1); GX_Position1x8(2); GX_TexCoord1x16(tc+2); GX_Position1x8(3); GX_TexCoord1x16(tc+3); GX_End(); guMtxApplyTrans(TempMatrix, TempMatrix, cw+1, 0, 0); GX_LoadPosMtxImm(TempMatrix, GX_PNMTX0); } GX_LoadPosMtxImm(gdl::wii::ModelMtx, GX_PNMTX0); GX_SetChanCtrl(GX_COLOR0A0, GX_DISABLE, GX_SRC_VTX, GX_SRC_VTX, 0, GX_DF_NONE, GX_AF_NONE); }