Release is not a method of Sprite. The reference for Sprite says that OnLostDevice performs the following:
Quote:Use this method to release all references to video memory resources and delete all stateblocks. This method should be called whenever a device is lost or before resetting a device.
Here is my code during the Render call:
void _Direct3D::Render(){ //------------------- D3DCOLOR vertexColour = 0xFFFFFFFF; //------------------- d3d9Device->Clear( 0, // Number of Rectangles in Array - Set to 0 since Rects is NULL NULL, // Pointer to an Array of D3DRect to Clear - NULL indicates entire viewport D3DCLEAR_TARGET, // Surface to Clear D3DCOLOR_XRGB( 0, 0, 0 ), // Clear to this Color 1.0f, // Depth Buffer to Clear to 0 // Stencil Buffer to Clear to ); //------------------- if ( SUCCEEDED( hr = d3d9Device->BeginScene() ) ) { //------------------- // Scene Rendering takes place Here //------------------- // Draw the triangles in the vertex buffer. This is broken into a few // steps. We are passing the vertices down a "stream", so first we need // to specify the source of that stream, which is our vertex buffer. Then // we need to let D3D know what vertex shader to use. Full, custom vertex // shaders are an advanced topic, but in most cases the vertex shader is // just the FVF, so that D3D knows what type of vertices we are dealing // with. Finally, we call DrawPrimitive() which does the actual rendering // of our geometry (in this case, just one triangle). //------------------- Begin Sprite Drawing d3d9Sprite->Begin(D3DXSPRITE_ALPHABLEND ); //------------------- Draw the Map Tiles DXTexture dxt = DXTexture(this); dxt.DrawSprites(); //------------------- Draw the Navigation Control hr = d3d9Sprite->Draw( navTexture, NULL, new D3DXVECTOR3(0.0f, 0.0f, 0.0f), new D3DXVECTOR3(0.0f, 0.0f, 0.0f), D3DCOLOR_ARGB(255, 255, 255, 255) ); if (FAILED(hr)) return; //------------------- End Sprite Drawing d3d9Sprite->End(); //------------------- End the Scene d3d9Device->EndScene(); } //------------------- Present the Backbuffer contents to the display d3d9Device->Present( NULL, NULL, NULL, NULL); //-------------------}//-------------------
And my function that is called for the dxt.DrawSprites(); is as follows:
HRESULT DXTexture::DrawSprites(){ //------------------- std::list<LOADEDTEXTURE*>::iterator it; //------------------- Go through loaded texture list for (it = loadedTextures.begin(); it != loadedTextures.end (); it++) { hr = DXDirect3D->d3d9Sprite->Draw( (*it)->texture, NULL, new D3DXVECTOR3(0.0f, 0.0f, 0.0f), new D3DXVECTOR3((*it)->xpos, (*it)->ypos, 0.0f), D3DCOLOR_ARGB(255, 255, 255, 255) ); if (FAILED(hr)) return hr; } //------------------- return hr; //-------------------}