Original Post
I am setting up view ports for a split-screen multi-player game. What I am trying to do is, after splitting the screen and drawing in each viewport, I want to again draw on the full screen several things. My problem is that for some reason when I set the viewport back to full screen, I can''t draw anything new. Meaning I can''t seem to see what I draw after setting the view back to full screen.
This is how I am setting everything:
g_d3d_device->EndScene(); D3DVIEWPORT8 bottomViewPort; bottomViewPort.X = 0; bottomViewPort.Y = window_height/2; bottomViewPort.Width = window_width; bottomViewPort.Height = window_height/2; bottomViewPort.MinZ = 0.0f; // ? bottomViewPort.MaxZ = 1.0f; // ? g_d3d_device->SetViewport( &bottomViewPort ); g_d3d_device->Clear( 0, NULL, D3DCLEAR_TARGET|D3DCLEAR_ZBUFFER|D3DCLEAR_STENCIL , 0xff000000, 1.0f, 0 ); g_d3d_device->BeginScene(); D3DXMatrixIdentity(&d3d_view_matrix); D3DXMatrixLookAtLH(&d3d_view_matrix,&D3DXVECTOR3( 0.0f, 0.0f, 1.0f ), &D3DXVECTOR3( 0.0f, 0.0f, 0.0f ), &D3DXVECTOR3( 0.0f, 1.0f, 0.0f )); // set the transformation, need to update when camera moves g_d3d_device->SetTransform(D3DTS_VIEW,&d3d_view_matrix); D3DXMatrixIdentity(&d3d_world_matrix); g_d3d_device->SetTransform(D3DTS_WORLD, &d3d_world_matrix); D3DXMatrixPerspectiveFovLH( &matProj, //Result Matrix D3DX_PI/6, //Field of View, in radians. (PI/4) is typical -((float)window_width / (float)window_height)*2, //Aspect ratio 0.2f, //Near view plane 2001.0f ); // Far view plane // set the projection matrix g_d3d_device->SetTransform( D3DTS_PROJECTION, &matProj ); // DRAW BOTTOM VIEW g_d3d_device->EndScene(); D3DVIEWPORT8 topViewPort; topViewPort.X = 0; topViewPort.Y = 0; topViewPort.Width = window_width; topViewPort.Height = window_height/2; topViewPort.MinZ = 0.0f; // ? topViewPort.MaxZ = 1.0f; // ? g_d3d_device->SetViewport( &topViewPort ); g_d3d_device->Clear( 0, NULL, D3DCLEAR_TARGET|D3DCLEAR_ZBUFFER|D3DCLEAR_STENCIL , 0xff000000, 1.0f, 0 ); g_d3d_device->BeginScene(); D3DXMatrixIdentity(&d3d_view_matrix); D3DXMatrixLookAtLH(&d3d_view_matrix,&D3DXVECTOR3( 0.0f, 0.0f, 1.0f ), &D3DXVECTOR3( 0.0f, 0.0f, 0.0f ), &D3DXVECTOR3( 0.0f, 1.0f, 0.0f )); // set the transformation, need to update when camera moves g_d3d_device->SetTransform(D3DTS_VIEW,&d3d_view_matrix); D3DXMatrixIdentity(&d3d_world_matrix); g_d3d_device->SetTransform(D3DTS_WORLD, &d3d_world_matrix); D3DXMatrixPerspectiveFovLH( &matProj, //Result Matrix D3DX_PI/6, //Field of View, in radians. (PI/4) is typical -((float)window_width / (float)window_height)*2, //Aspect ratio 0.2f, //Near view plane 2001.0f ); // Far view plane // set the projection matrix g_d3d_device->SetTransform( D3DTS_PROJECTION, &matProj ); // DRAW TOP VIEW D3DVIEWPORT8 fullViewPort; fullViewPort.X = 0; fullViewPort.Y = 0; fullViewPort.Width = window_width; fullViewPort.Height = window_height; fullViewPort.MinZ = 0.0f; // ? fullViewPort.MaxZ = 1.0f; // ? g_d3d_device->SetViewport( &fullViewPort ); // set to 2dview D3DXMATRIX matOrtho; D3DXMATRIX matIdentity; //Setup the orthogonal projection matrix and the default world/view matrix D3DXMatrixOrthoLH(&matOrtho, (float)window_width, (float)window_height, 0.0f, 2000.0f); D3DXMatrixIdentity(&matIdentity); D3DXMatrixIdentity(&d3d_world_matrix); g_d3d_device->SetTransform(D3DTS_PROJECTION, &matOrtho); g_d3d_device->SetTransform(D3DTS_WORLD, &d3d_world_matrix); g_d3d_device->SetTransform(D3DTS_VIEW, &matIdentity); //Make sure that the z-buffer and lighting are disabled g_d3d_device->SetRenderState(D3DRS_ZENABLE, D3DZB_FALSE); g_d3d_device->SetRenderState(D3DRS_LIGHTING, FALSE); // DRAW SOME 2D STUFF OVER EVERYTHINGDoes anyone have any ideas ? Thanks, Nitzan