Jump to content
  • Advertisement

Archived

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

mess

D3D Ortho mode

This topic is 5756 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

Where can i find some info on this? im trying to desin a console, and dont know how to go about it. thanks

Share this post


Link to post
Share on other sites
Advertisement
I made two functions in my render class Go3D() and Go2D().

Whenever i call Go2D() my scene disaperas, can somone check if i am going in ortho mode correctly?

thanks

void CRender::Go3D()
{
D3DXMatrixIdentity(&m_matProj);
D3DXMatrixPerspectiveFovLH( &m_matProj, D3DX_PI/4, 1.0f, 1.0f, 1000.0f );
m_pd3dDevice->SetTransform( D3DTS_PROJECTION, &m_matProj );
}

void CRender::Go2D()
{
D3DXMatrixOrthoLH(&m_matProj, m_pWindow->m_Width, m_pWindow->m_Height, 0.0f, 1.0f);
m_pd3dDevice->SetTransform(D3DTS_PROJECTION, &m_matProj);

}

[edited by - mess on September 15, 2002 12:01:11 AM]

Share this post


Link to post
Share on other sites
I haven't checked you parameters, but on a different note, it will be slightly more efficient if you create the matrices on initialization and just call SetTransform() in these functions.

Also, there is no reason to call D3DXMatrixIdentity before D3DXMatrixPerspective...

Author, "Real Time Rendering Tricks and Techniques in DirectX", "Focus on Curves and Surfaces"

[edited by - CrazedGenius on September 15, 2002 12:11:01 AM]

Share this post


Link to post
Share on other sites
http://24.43.48.130/b/Gatigy/CRender.cpp

thats my code if u can take a look gimme some pointers too.

thanks alot

Share this post


Link to post
Share on other sites
I disabled it, and the quad still disapears when i move my camera.


//o-----------------------------------------------------------------------------------o
//| Go into 3d mode
//|
//o-----------------------------------------------------------------------------------o

void CRender::Go3D()
{
m_pd3dDevice->SetRenderState( D3DRS_ZENABLE, TRUE );
m_pd3dDevice->SetRenderState( D3DRS_ZENABLE, D3DZB_TRUE );
m_pd3dDevice->SetRenderState( D3DRS_ZWRITEENABLE, TRUE );
D3DXMatrixIdentity(&m_matProj);
D3DXMatrixPerspectiveFovLH( &m_matProj, D3DX_PI/4, 1.0f, 1.0f, 1000.0f );
m_pd3dDevice->SetTransform( D3DTS_PROJECTION, &m_matProj );
}

//o-----------------------------------------------------------------------------------o
//| Go into ortho mode
//|
//o-----------------------------------------------------------------------------------o

void CRender::Go2D()
{
m_pd3dDevice->SetRenderState( D3DRS_ZENABLE, FALSE );
m_pd3dDevice->SetRenderState( D3DRS_ZENABLE, D3DZB_FALSE );
m_pd3dDevice->SetRenderState( D3DRS_ZWRITEENABLE, FALSE );
D3DXMatrixIdentity(&m_matProj);
D3DXMatrixOrthoLH(&m_matProj, m_pWindow->m_Width, m_pWindow->m_Height, 1.0f, 1.0f);
m_pd3dDevice->SetTransform(D3DTS_PROJECTION, &m_matProj);
}

Share this post


Link to post
Share on other sites
don''t forgett to reset your view/world matrices...

btw. you can also do the 2d-part with transformed vertices, if you don''t need matrix math... -> i.e. D3DFVF_XYRRHW

Share this post


Link to post
Share on other sites
Okay, i changed the code a bit, now im not seeing anything, just a blank screen, please help

thanks

//o-----------------------------------------------------------------------------------o
//| Go into 3d mode
//|
//o-----------------------------------------------------------------------------------o

void CRender::Go3D()
{
D3DXMATRIX Identity;
D3DXMATRIX Matrix3D;
D3DXMatrixIdentity(&Identity);

m_pd3dDevice->SetRenderState( D3DRS_ZENABLE, TRUE );
m_pd3dDevice->SetRenderState( D3DRS_ZENABLE, D3DZB_TRUE );
m_pd3dDevice->SetRenderState( D3DRS_ZWRITEENABLE, TRUE );

D3DXMatrixPerspectiveFovLH( &Matrix3D, D3DX_PI/4, 1.0f, 1.0f, 1000.0f );
m_pd3dDevice->SetTransform( D3DTS_PROJECTION, &Matrix3D );

m_pd3dDevice->SetTransform(D3DTS_WORLD, &Identity);
m_pd3dDevice->SetTransform(D3DTS_VIEW, &Identity);
}

//o-----------------------------------------------------------------------------------o
//| Go into ortho mode
//|
//o-----------------------------------------------------------------------------------o

void CRender::Go2D()
{
D3DXMATRIX Identity;
D3DXMATRIX Matrix2D;
D3DXMatrixIdentity(&Identity);

m_pd3dDevice->SetRenderState( D3DRS_ZENABLE, FALSE );
m_pd3dDevice->SetRenderState( D3DRS_ZENABLE, D3DZB_FALSE );
m_pd3dDevice->SetRenderState( D3DRS_ZWRITEENABLE, FALSE );

D3DXMatrixOrthoLH(&Matrix2D, m_pWindow->m_Width, m_pWindow->m_Height, 5.0f, 1000.0f);
m_pd3dDevice->SetTransform(D3DTS_PROJECTION, &Matrix2D);

m_pd3dDevice->SetTransform(D3DTS_WORLD, &Identity);
m_pd3dDevice->SetTransform(D3DTS_VIEW, &Identity);
}

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!