• Advertisement


This topic is now archived and is closed to further replies.

Orthogonal projection problems

This topic is 5078 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

[I use DirectX 7!] I'm trying to setup a orthogonal projection matrix, so I can render faces as if they were 2D. The problem that I have is that nothing shows up on my screen. I do the following: Once at startup:
// create orthogonal projection matrix for this window

D3DXMatrixOrtho(&m_orthogonal_projection_matrix, (float)m_videowindow_width, (float)m_videowindow_height, -1, 1);
When I want to render '2D faces', I setup the world and projection matrix once like this:
m_d3ddevice->SetTransform(D3DTRANSFORMSTATE_PROJECTION, (D3DMATRIX *)&m_orthogonal_projection_matrix);
m_d3ddevice->SetTransform(D3DTRANSFORMSTATE_WORLD, (D3DMATRIX *)&m_orthogonal_world_matrix);
Then the function that renders a 2D quad looks like this:
void RendererEngine_Direct3D::Draw2DTexturedRectangle(int x1, int y1, int x2, int y2)
	float x1f = (float)x1, y1f = (float)y1, x2f = (float)x2, y2f = (float)y2;
	float vertices[5*4] = 
		/*pos*/x1f, y1f, 0, /*texcoord*/ 0, 0,
		/*pos*/x2f, y1f, 0, /*texcoord*/ 1, 0,
		/*pos*/x2f, y2f, 0, /*texcoord*/ 1, 1,
		/*pos*/x1f, y2f, 0, /*texcoord*/ 0, 1,
	m_d3ddevice->DrawPrimitive(D3DPT_TRIANGLEFAN, D3DFVF_XYZ | D3DFVF_TEX1, vertices, 4, 0);
Can anyone point out to me the mistake I must be making? Thanks in advance! Marc [edited by - Marc aka Foddex on April 23, 2004 5:01:36 AM]

Share this post

Link to post
Share on other sites
Damn, I figured it out myself... Isn''t it always so that when you answer the question on the net, that a few seconds later you see the light?

Anyway, I had locked the device context for other 2D stuff (like drawing fonts and such), and that kinda got in the way of all the Direct3D action! A simple ReleaseDC and GetDC did the trick

Share this post

Link to post
Share on other sites

  • Advertisement