Jump to content
  • Advertisement
Sign in to follow this  
dan01

Dynamic Vertex Buffer, persisting/wrong texture?

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

my code original came from Microsoft sample, SparseMorphTargets. This function does not seem run in there sample either. I added engine->FormManager()->pStateBlock10->Capture & Restore. The code here doesnt complain about any thing. I'm not doing any occlusion. And this DrawRect10 code all most match the way the Form background are drawn in main render function of the form, which works just fine. The problem is the Rectangle is drawn with a previous Texture, when the texture should not be drawn just the colored rectangle. I just dont under stand why the texture is stay set. Sdk that I'm using is march 2008 (have no real reason yet, to update june version), using directx10, and the language is cpp. HRESULT FormClass::DrawRect10( RECT* pRect, D3DCOLOR color ){ RECT rcScreen = *pRect; OffsetRect( &rcScreen, m_x, m_y ); // If caption is enabled, offset the Y position by its height. if( m_bCaption ) OffsetRect( &rcScreen, 0, m_nCaptionHeight ); color = 0xFF0000FF; D3DCOLORVALUE clr = { ( ( color >> 16 ) & 0xFF ) / 255.0f, ( ( color >> 8 ) & 0xFF ) / 255.0f, ( color & 0xFF ) / 255.0f, ( ( color >> 24 ) & 0xFF ) / 255.0f }; // Convert the rect from screen coordinates to clip space coordinates. float Left, Right, Top, Bottom; Left = rcScreen.left * 2.0f / engine->nBackBufferWidth - 1.0f; Right = rcScreen.right * 2.0f / engine->nBackBufferWidth - 1.0f; Top = 1.0f - rcScreen.top * 2.0f / engine->nBackBufferHeight; Bottom = 1.0f - rcScreen.bottom * 2.0f / engine->nBackBufferHeight; DXUT_SCREEN_VERTEX_10 vertices[4] = { { Left, Top, 0.5f, clr, 0.0f, 0.0f }, { Right, Top, 0.5f, clr, 1.0f, 0.0f }, { Left, Bottom, 0.5f, clr, 0.0f, 1.0f }, { Right, Bottom, 0.5f, clr, 1.0f, 1.0f }, }; DXUT_SCREEN_VERTEX_10 *pVB; if( SUCCEEDED( engine->FormManager()->pVertexBuffer->Map( D3D10_MAP_WRITE_DISCARD, 0, (LPVOID*)&pVB ) ) ) { CopyMemory( pVB, vertices, sizeof( vertices ) ); engine->FormManager()->pVertexBuffer->Unmap( ); } // // Since we're doing our own drawing here we need to flush the sprites engine->FormManager()->pSprite10->Flush(); engine->FormManager()->pStateBlock10->Capture(); UINT stride = sizeof( DXUT_SCREEN_VERTEX_10 ); UINT offset = 0; pd3dDevice->IASetVertexBuffers( 0, 1, &engine->FormManager()->pVertexBuffer, &stride, &offset); pd3dDevice->IASetInputLayout( shader->pVertexLayout ); pd3dDevice->IASetPrimitiveTopology( D3D10_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP ); D3D10_TECHNIQUE_DESC techDesc; shader->m_pTechRenderUI10->GetDesc( &techDesc ); for( UINT p = 0; p < techDesc.Passes; ++p ) { shader->m_pTechRenderUI10->GetPassByIndex( p )->Apply(0); pd3dDevice->Draw( 4, 0 ); } engine->FormManager()->pStateBlock10->Apply(); } Any help would be appreciated. Thanks

Share this post


Link to post
Share on other sites
Advertisement
Sign in to follow this  

  • 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!