Exemple #1
0
bool Image2D::Render()
{
	Debug ("Image2D::Render called.");
	
	if (!m_active) return true;
	
	// Place texture in buffer (as needed)
	AssetManager::GetSingleton().LoadTexture(m_texture);
	
	// Render the "model" in the correct location
	
	// Determine where to render the image
	int left		= m_x - m_width/2;
	int right		= m_x + m_width/2;
	int top			= m_y - m_height/2;
	int bottom		= m_y + m_height/2;

	// Start DIRECT mode transfer
	VIFDynamicDMA.StartDirect();
									
	// Add the GIFTag
	VIFDynamicDMA.Add128(GS_GIFTAG_BATCH(	1,							// NLOOP
											1,							// EOP
											1,							// PRE
											GS_PRIM(PRIM_SPRITE, 		//PRIM
													PRIM_IIP_FLAT, 
													PRIM_TME_ON,
													PRIM_FGE_OFF, 
													PRIM_ABE_ON, 
													PRIM_AA1_OFF, 
													PRIM_FST_UV, 
													PRIM_CTXT_CONTEXT1, 
													PRIM_FIX_NOFIXDDA),					
											GIF_FLG_PACKED,				//FLG
											GS_BATCH_5(	GIF_REG_RGBAQ, 	//BATCH
														GIF_REG_UV, 
														GIF_REG_XYZ2, 
														GIF_REG_UV, 
														GIF_REG_XYZ2)));				
	// Add Vertex data
	VIFDynamicDMA.Add128(PACKED_RGBA(m_r, m_g, m_b, m_a));
	VIFDynamicDMA.Add128(PACKED_UV(0<<4, 0<<4));
	VIFDynamicDMA.Add128(PACKED_XYZ2(	(left + 2048)<< 4, 
										(top + 2048)<< 4, 
										m_depth, 
										0));						
	VIFDynamicDMA.Add128(PACKED_UV((255<<4), (255<<4)));	
	VIFDynamicDMA.Add128(PACKED_XYZ2(	(right + 2048)<< 4, 
										(bottom + 2048)<< 4, 
										m_depth, 
										0));
			
	
	// End the direct mode
	VIFDynamicDMA.EndDirect();
	
	return true;
}
Exemple #2
0
/*
=============================
Textured Quad Render Function
=============================
*/
void PS2TexQuad::Render( void ) const {
	VIFDynamicDMA.StartDirect();
	/* Add the GIFTag */
	VIFDynamicDMA.Add128( GS_GIFTAG_BATCH(	mNumOfVerts,				    // NLOOP
											1,							    // EOP
											1,							    // PRE
											GS_PRIM( PRIM_TRI_STRIP, 	    // PRIM
												PRIM_IIP_FLAT, 
												PRIM_TME_ON,
												PRIM_FGE_OFF, 
												PRIM_ABE_ON, 
												PRIM_AA1_OFF, 
												PRIM_FST_UV, 
												PRIM_CTXT_CONTEXT1, 
												PRIM_FIX_NOFIXDDA ),
											GIF_FLG_PACKED,				    // FLG
											GS_BATCH_3(	GIF_REG_RGBAQ,
														GIF_REG_UV, 
														GIF_REG_XYZ2 ) ) ); // BATCH	
	for( int i = 0; i < mNumOfVerts; i++ ) {
		/* Add the colour */
		VIFDynamicDMA.Add128( PACKED_RGBA( pVertColours[ i ].mR, pVertColours[ i ].mG, pVertColours[ i ].mB, pVertColours[ i ].mA ) );
		/* Add UV texture coordinates */ 
		VIFDynamicDMA.Add128( PACKED_UV( ( ( ( int )pTexVerts[ i ].x ) << 4 ), ( ( ( int )pTexVerts[ i ] .y ) << 4 ) ) );
		/* Add the position */  
		VIFDynamicDMA.Add128( PACKED_XYZ2( ( int )( ( 2048.0f + mX + pVerts[ i ].x ) * 16.0f ), 
										   ( int )( ( 2048.0f + mY + pVerts[ i ].y ) * 16.0f ),  
										   ( int )mZ, 
										   0 ) );
	}
	VIFDynamicDMA.EndDirect();
}