Jump to content

Recommended Posts

Hello,

stuck with proper UV maps caluclation.... (yeah, rectangle too complicated figure)

So, all in all i've got something like this: 6be4f50e11a230f67080651162c7d653.png

with that:


	float fWidth = m_width;
	float fHeight = m_height;

	float texReverseWidth = 1.0f / (fWidth); // TextureWidth
	float texReverseHeight = 1.0f / (fHeight); // TextureHeight
	float su = m_renderRect.left * texReverseWidth;
	float sv = m_renderRect.top * texReverseHeight;
	float eu = texReverseWidth * (m_renderRect.left + (m_renderRect.right - m_renderRect.left));
	float ev = texReverseHeight * (m_renderRect.top + (m_renderRect.bottom - m_renderRect.top));

	SAFE_RELEASE(m_lpd3dOriginalRenderTarget);
	SAFE_RELEASE(m_lpd3dOldDepthBufferSurface);

	TPDTVertex pVertices[4];

	pVertices[0].position = TPosition(m_renderRect.left - 0.5f, m_renderRect.top - 0.5f, 0.0f);
	pVertices[0].texCoord = TTextureCoordinate(su, sv);
	pVertices[0].diffuse = 0xffffffff;

	pVertices[1].position = TPosition(m_renderRect.left + fWidth - 0.5f, m_renderRect.top - 0.5f, 0.0f);
	pVertices[1].texCoord = TTextureCoordinate(eu, sv);
	pVertices[1].diffuse = 0xffffffff;

	pVertices[2].position = TPosition(m_renderRect.left - 0.5f, m_renderRect.top + fHeight - 0.5f, 0.0f);
	pVertices[2].texCoord = TTextureCoordinate(su, ev);
	pVertices[2].diffuse = 0xffffffff;

	pVertices[3].position = TPosition(m_renderRect.left + fWidth - 0.5f,
		m_renderRect.top + fHeight - 0.5f, 0.0f);
	pVertices[3].texCoord = TTextureCoordinate(eu, ev);
	pVertices[3].diffuse = 0xffffffff;

	if (CGraphicBase::SetPDTStream(pVertices, 4))
	{
		CGraphicBase::SetDefaultIndexBuffer(CGraphicBase::DEFAULT_IB_FILL_RECT);

		STATEMANAGER.SetTexture(0, GetRenderTargetTexture());
		STATEMANAGER.SetTexture(1, NULL);
		STATEMANAGER.SetVertexShader(D3DFVF_XYZ | D3DFVF_TEX1 | D3DFVF_DIFFUSE);
		STATEMANAGER.DrawIndexedPrimitive(D3DPT_TRIANGLELIST, 0, 4, 0, 2);
	}

 

On the other hand, i've got this: b338ac253bcb5efea64ba3209e380fbd.png

with that:


	float fWidth = m_width;
	float fHeight = m_height;

	float texReverseWidth = 1.0f / (desc.Width); // ScreenWidth
	float texReverseHeight = 1.0f / (desc.Height); // ScreenHeight
	float su = m_renderRect.left * texReverseWidth;
	float sv = m_renderRect.top * texReverseHeight;
	float eu = texReverseWidth * (m_renderRect.left + (m_renderRect.right - m_renderRect.left));
	float ev = texReverseHeight * (m_renderRect.top + (m_renderRect.bottom - m_renderRect.top));

	SAFE_RELEASE(m_lpd3dOriginalRenderTarget);
	SAFE_RELEASE(m_lpd3dOldDepthBufferSurface);

	TPDTVertex pVertices[4];

	pVertices[0].position = TPosition(m_renderRect.left - 0.5f, m_renderRect.top - 0.5f, 0.0f);
	pVertices[0].texCoord = TTextureCoordinate(su, sv);
	pVertices[0].diffuse = 0xffffffff;

	pVertices[1].position = TPosition(m_renderRect.left + fWidth - 0.5f, m_renderRect.top - 0.5f, 0.0f);
	pVertices[1].texCoord = TTextureCoordinate(eu, sv);
	pVertices[1].diffuse = 0xffffffff;

	pVertices[2].position = TPosition(m_renderRect.left - 0.5f, m_renderRect.top + fHeight - 0.5f, 0.0f);
	pVertices[2].texCoord = TTextureCoordinate(su, ev);
	pVertices[2].diffuse = 0xffffffff;

	pVertices[3].position = TPosition(m_renderRect.left + fWidth - 0.5f,
		m_renderRect.top + fHeight - 0.5f, 0.0f);
	pVertices[3].texCoord = TTextureCoordinate(eu, ev);
	pVertices[3].diffuse = 0xffffffff;

	if (CGraphicBase::SetPDTStream(pVertices, 4))
	{
		CGraphicBase::SetDefaultIndexBuffer(CGraphicBase::DEFAULT_IB_FILL_RECT);

		STATEMANAGER.SetTexture(0, GetRenderTargetTexture());
		STATEMANAGER.SetTexture(1, NULL);
		STATEMANAGER.SetVertexShader(D3DFVF_XYZ | D3DFVF_TEX1 | D3DFVF_DIFFUSE);
		STATEMANAGER.DrawIndexedPrimitive(D3DPT_TRIANGLELIST, 0, 4, 0, 2);
	}

I'm missing something, but this direct api makes me crazy.

All help gladly appreciated.

Regards!

Edited by Metin2 Dev
Core X - External 2 Internal
Link to comment
Share on other sites

  • Replies 0
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

Popular Days

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

Announcements



×
×
  • Create New...

Important Information

Terms of Use / Privacy Policy / Guidelines / We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.