Jump to content

  • Log In with Google      Sign In   
  • Create Account


#ActualJoyal

Posted 18 March 2013 - 04:39 AM

@DgekGD , i like your approach because i can use the same VS and PS in differents classes biggrin.png!

 

 

@Racoonacoon well right now i don`t have the implementation made of Quad2D on my current "Engine"(DX11), i wanted to ask before i do it because DX10-11 works different,  but i do have my DX9 version , 

 

void RenderManager::DrawQuad2D (CTexture* texture, Vector2 position, int w, int h)
{

	// position = [0] 
	//
	//  [0]------[2]
	//   |        |
	//   |        |
	//   |        |
	//  [1]------[3]
	
	Vector2 coord_text[4];
	coord_text[0].x = 0.f;	coord_text[0].y = 0.f;
	coord_text[1].x = 0.f;	coord_text[1].y = 1.f;
	coord_text[2].x = 1.f;	coord_text[2].y = 0.f;
	coord_text[3].x = 1.f;	coord_text[3].y = 1.f;
			
	unsigned short indices[6]={0,2,1,1,2,3};
	SCREEN_TEXTURE_VERTEX v[4] =
	{
			{ (float)position.x,	(float)position.y,	0.f,1.f, coord_text[0].x,	coord_text[0].y} //(x,y) sup_esq.
		,	{ (float)position.x,	(float)position.y+h,	0.f,1.f, coord_text[1].x,	coord_text[1].y} //(x,y) inf_esq.
		, 	{ (float)position.x+w,	(float)position.y,	0.f,1.f, coord_text[2].x,	coord_text[2].y} //(x,y) sup_dr.
		,	{ (float)position.x+w,	(float)position.y+h,	0.f,1.f, coord_text[3].x,	coord_text[3].y} //(x,y) inf_dr.
	};

	m_pD3DDevice->SetFVF( SCREEN_TEXTURE_VERTEX::getFlags() );
	m_pD3DDevice->SetTexture(0, texture->GetD3DXTexture() );
	m_pD3DDevice->DrawIndexedPrimitiveUP( D3DPT_TRIANGLELIST,0, 4, 2,indices,D3DFMT_INDEX16, v, sizeof( SCREEN_TEXTURE_VERTEX ) );
}

 

 

Well i based in your suggestion , i think i will do some sort of XNA's "SpriteBranch", and that class can be instantiated once, and be passed on the "Render" method,  instead of the "RenderManager", 

 

Thank for your greats advice 


#2Joyal

Posted 18 March 2013 - 04:38 AM

@DgekGD , i like your approach because i can use the same VS and PS in differents classes biggrin.png!

 

 

@Racoonacoon well right now i don`t have the implementation made of Quad2D on my current "Engine"(DX11), i wanted to ask before i do it because DX10-11 works different,  but i do have my DX9 version , 

 

void RenderManager::DrawQuad2D (CTexture* texture, Vector2 position, int w, int h)
{

	// position = [0] 
	//
	//  [0]------[2]
	//   |        |
	//   |        |
	//   |        |
	//  [1]------[3]
	
	Vector2 coord_text[4];
	coord_text[0].x = 0.f;	coord_text[0].y = 0.f;
	coord_text[1].x = 0.f;	coord_text[1].y = 1.f;
	coord_text[2].x = 1.f;	coord_text[2].y = 0.f;
	coord_text[3].x = 1.f;	coord_text[3].y = 1.f;
			
	unsigned short indices[6]={0,2,1,1,2,3};
	SCREEN_TEXTURE_VERTEX v[4] =
	{
			{ (float)position.x,	(float)position.y,		0.f,1.f, coord_text[0].x,	coord_text[0].y} //(x,y) sup_esq.
		,	{ (float)position.x,	(float)position.y+h,	0.f,1.f, coord_text[1].x,	coord_text[1].y} //(x,y) inf_esq.
		, 	{ (float)position.x+w,	(float)position.y,		0.f,1.f, coord_text[2].x,	coord_text[2].y} //(x,y) sup_dr.
		,	{ (float)position.x+w,	(float)position.y+h,	0.f,1.f, coord_text[3].x,	coord_text[3].y} //(x,y) inf_dr.
	};

	m_pD3DDevice->SetFVF( SCREEN_TEXTURE_VERTEX::getFlags() );
	m_pD3DDevice->SetTexture(0, texture->GetD3DXTexture() );
	m_pD3DDevice->DrawIndexedPrimitiveUP( D3DPT_TRIANGLELIST,0, 4, 2,indices,D3DFMT_INDEX16, v, sizeof( SCREEN_TEXTURE_VERTEX ) );
}

 

 

Well i based in your suggestion , i think i will do some sort of XNA's "SpriteBranch", and that class can be instantiated once, and be passed on the "Render" method,  instead of the "RenderManager", 

 

Thank for your greats advice 


#1Joyal

Posted 18 March 2013 - 04:37 AM

@DgekGD , i like your approach because i can use the same VS and PS in differents classes :D!

 

 

@Racoonacoon well right now i don`t have the implementation made of Quad2D on my current "Engine"(DX11), i wanted to ask before i do it because DX10-11 works different,  but i do have my DX9 version , 

 

void RenderManager::DrawQuad2D (CTexture* texture, Vector2 position, int width, int height)
{

	// position = [0] 
	//
	//  [0]------[2]
	//   |        |
	//   |        |
	//   |        |
	//  [1]------[3]
	
	Vector2 coord_text[4];
	coord_text[0].x = 0.f;	coord_text[0].y = 0.f;
	coord_text[1].x = 0.f;	coord_text[1].y = 1.f;
	coord_text[2].x = 1.f;	coord_text[2].y = 0.f;
	coord_text[3].x = 1.f;	coord_text[3].y = 1.f;
			
	unsigned short indices[6]={0,2,1,1,2,3};
	SCREEN_TEXTURE_VERTEX v[4] =
	{
			{ (float)position.x,	(float)position.y,		0.f,1.f, coord_text[0].x,	coord_text[0].y} //(x,y) sup_esq.
		,	{ (float)position.x,	(float)position.y+h,	0.f,1.f, coord_text[1].x,	coord_text[1].y} //(x,y) inf_esq.
		, 	{ (float)position.x+w,	(float)position.y,		0.f,1.f, coord_text[2].x,	coord_text[2].y} //(x,y) sup_dr.
		,	{ (float)position.x+w,	(float)position.y+h,	0.f,1.f, coord_text[3].x,	coord_text[3].y} //(x,y) inf_dr.
	};

	m_pD3DDevice->SetFVF( SCREEN_TEXTURE_VERTEX::getFlags() );
	m_pD3DDevice->SetTexture(0, texture->GetD3DXTexture() );
	m_pD3DDevice->DrawIndexedPrimitiveUP( D3DPT_TRIANGLELIST,0, 4, 2,indices,D3DFMT_INDEX16, v, sizeof( SCREEN_TEXTURE_VERTEX ) );
}

 

 

Well i based in your suggestion , i think i will do some sort of XNA's "SpriteBranch", and that class can be instantiated once, and be passed on the "Render" method,  instead of the "RenderManager", 

 

Thank for your greats advice 


PARTNERS