void CD3D9Texture::createDepthStencil(int nWidth, int nHeight) { DXUTGetD3DDevice()->CreateTexture( nWidth, nHeight, 1, D3DUSAGE_DEPTHSTENCIL, D3DFMT_D16, D3DPOOL_DEFAULT, &m_pd3dTexture, NULL); if (m_pd3dTexture) { m_pd3dTexture->GetSurfaceLevel(0 , &m_pD3D9Surface); } else { DXUTGetD3DDevice()->CreateDepthStencilSurface( nWidth,nHeight, D3DFMT_D16, D3DMULTISAMPLE_NONE, 0, TRUE, &m_pD3D9Surface, NULL); } }
void CD3D9Texture::createTextureFromFileInMemory(void* pBuf, int nSize, int nLevels) { D3DXIMAGE_INFO info; if (FAILED (D3DXCreateTextureFromFileInMemoryEx (DXUTGetD3DDevice(), pBuf, nSize, D3DX_DEFAULT, D3DX_DEFAULT, nLevels, 0, D3DFMT_UNKNOWN, D3DPOOL_MANAGED, D3DX_FILTER_LINEAR, D3DX_FILTER_LINEAR, 0, &info, NULL, &m_pd3dTexture))) { //erro return; } m_nWidth = info.Width; m_nHeight = info.Height; //D3DXCreateTextureFromFileInMemory(DXUTGetD3DDevice(), pImageBits, Size, &m_pd3dTexture); //D3DXCreateTextureFromFileInMemoryEx(DXUTGetD3DDevice(),pImageBits,Size,Width,Height, // D3DX_DEFAULT,0, D3DFMT_R8G8B8, D3DPOOL_MANAGED, // D3DX_DEFAULT, D3DX_DEFAULT, 0, // NULL, NULL, &m_pd3dTexture); }
// // Frustum::Render - Chapter 14, page 489 // void Frustum::Render() { COLORED_VERTEX verts[24]; for (int i=0; i<8; ++i) { verts[i].color = g_White; } for (int i=0; i<8; ++i) { verts[i+8].color = g_Red; } for (int i=0; i<8; ++i) { verts[i+16].color = g_Blue; } // Draw the near clip plane verts[0].position = m_NearClip[0]; verts[1].position = m_NearClip[1]; verts[2].position = m_NearClip[1]; verts[3].position = m_NearClip[2]; verts[4].position = m_NearClip[2]; verts[5].position = m_NearClip[3]; verts[6].position = m_NearClip[3]; verts[7].position = m_NearClip[0]; // Draw the far clip plane verts[8].position = m_FarClip[0]; verts[9].position = m_FarClip[1]; verts[10].position = m_FarClip[1]; verts[11].position = m_FarClip[2]; verts[12].position = m_FarClip[2]; verts[13].position = m_FarClip[3]; verts[14].position = m_FarClip[3]; verts[15].position = m_FarClip[0]; // Draw the edges between the near and far clip plane verts[16].position = m_NearClip[0]; verts[17].position = m_FarClip[0]; verts[18].position = m_NearClip[1]; verts[19].position = m_FarClip[1]; verts[20].position = m_NearClip[2]; verts[21].position = m_FarClip[2]; verts[22].position = m_NearClip[3]; verts[23].position = m_FarClip[3]; DWORD oldLightMode; DXUTGetD3DDevice()->GetRenderState( D3DRS_LIGHTING, &oldLightMode ); DXUTGetD3DDevice()->SetRenderState( D3DRS_LIGHTING, FALSE ); DXUTGetD3DDevice()->SetFVF( COLORED_VERTEX::FVF ); DXUTGetD3DDevice()->DrawPrimitiveUP( D3DPT_LINELIST, 12, verts, sizeof(COLORED_VERTEX) ); DXUTGetD3DDevice()->SetRenderState( D3DRS_LIGHTING, oldLightMode ); }
void CALLBACK OnLostDevice( void* pUserContext ) { g_pDepthOfFieldApp->InvalidateDeviceObjects(DXUTGetD3DDevice()); if( g_pFont ) g_pFont->OnLostDevice(); SAFE_RELEASE(g_pTextSprite); }
void CD3D9Texture::createTexture(int nWidth, int nHeight, int nLevels, bool bPoolManaged) { DXUTGetD3DDevice()->CreateTexture( nWidth, nHeight, nLevels, 0, D3DFMT_A8R8G8B8, bPoolManaged?D3DPOOL_MANAGED:D3DPOOL_DEFAULT, &m_pd3dTexture, NULL); }
void CD3D9Texture::createDynamicTexture(int nWidth, int nHeight) { DXUTGetD3DDevice()->CreateTexture( nWidth, nHeight, 0, D3DUSAGE_DYNAMIC, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &m_pd3dTexture, NULL); if (m_pd3dTexture) { m_pd3dTexture->GetSurfaceLevel(0 , &m_pD3D9Surface); } }
void CD3D9Texture::createRenderTarget(int nWidth, int nHeight) { DXUTGetD3DDevice()->CreateTexture( nWidth, nHeight, 1, D3DUSAGE_RENDERTARGET, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &m_pd3dTexture, NULL); //D3D9CheckResRef(m_pd3dTexture); if (m_pd3dTexture) { m_pd3dTexture->GetSurfaceLevel(0 , &m_pD3D9Surface); } //D3D9CheckResRef(m_pd3dTexture); }
void CD3D9Texture::createCubeTexture(int nSize, int nLevels, bool bPoolManaged) { D3DXCreateCubeTexture(DXUTGetD3DDevice(), nSize, nLevels, 0, D3DFMT_A8R8G8B8, bPoolManaged?D3DPOOL_MANAGED:D3DPOOL_DEFAULT, (LPDIRECT3DCUBETEXTURE9*)&m_pd3dTexture); }