Displaying my surface . . is it something to do with copyrects

Started by
0 comments, last by MTclip 18 years, 6 months ago
here is my function . .


bool cSurface::load(LPDIRECT3DDEVICE9 Device)
{
	 m_iImageScale = 100; //set our image scale to 100
     HRESULT hResult;

	  //create the Off Screen Surface
     hResult = Device->CreateOffscreenPlainSurface(m_iWidth, m_iHeight, D3DFMT_A8R8G8B8, //surface format, D3DFMT_A8R8G8B8 is a 32 bit format with      8 alpha bits
     D3DPOOL_DEFAULT,&m_pBitmapSurface, NULL);

     if (FAILED(hResult))
	 {
		MessageBox(NULL, "ERROR IN CREATEOFSCRENPLAIN()", "ERROR", MB_OK);
		return false;
	 }

     //load the surface from the a file
     hResult = D3DXLoadSurfaceFromFile(m_pBitmapSurface, NULL, NULL, "Sprite.jpg", 
										NULL, D3DX_DEFAULT, 0, NULL );
     if (FAILED(hResult))
	 {
		MessageBox(NULL, "ERROR IN D3DXLOADSURFACE()", "ERROR", MB_OK);
		return false;
	 }

	 //copy the stuff to the bak buffer
	 

	 return true;
}


im using directx9 . . is copyrects still available in that? or do you have to do it anew way? the problem is i cant get my image onto the screen and think it could be a problem with drawing to the back buffer . . hmmm
Advertisement
got your answer...

//////////////////////////////////////////// SET UP ///////////////////////////////////////////////////////// varsLPD3DXDEVICE9  Device = NULL; LPDIRECT3DSURFACE9 pSurface = NULL;LPDIRECT3DSURFACE9 pBackBuffer = NULL;RECT DrawDest = {100, 100, 200, 200};//get pointer to backbufferDevice->GetBackBuffer(NULL,NULL, D3DBACKBUFFER_TYPE_MONO, &pBackBuffer);//create a surfaceDevice->CreateOffscreenPlainSurface(640, 480, D3DFMT_X8R8G8B8, D3DPOOL_DEFAULT, &pBackground, NULL);// load a bitmap to the surfaceD3DXLoadSurfaceFromFile(pSurface,NULL,NULL,"surface.bmp",NULL,D3DX_DEFAULT,0,NULL);///////////////////////////////////////////////// DRAWING ////call every frame////////////////////////////////////////////////// clear previous frame Device->Clear(0, 0, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0x00000000, 1.0f, 0);		////////tell direct x you are going to draw///////////////Device->BeginScene();// will draw the surface over the entire screenDevice->StretchRect(pSurface,NULL,pBackBuffer,NULL, D3DTEXF_NONE);// will draw on to the screen coords from DrawDestDevice->StretchRect(pSurface,NULL,pBackBuffer,&DrawDest, D3DTEXF_NONE);//done drawingDevice->EndScene();// show what you just drewDevice->Present(0, 0, 0, 0);///////////////////////////////////////// WHEN ENDING PROGRRAM ///////////////////////////////////////////////pSurface->Release();pBackBuffer->Release();Device->Release();



that is more or less the ins and outs

This topic is closed to new replies.

Advertisement