Sign in to follow this  
counterrabbit

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

Recommended Posts

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

Share this post


Link to post
Share on other sites
got your answer...


///////////////////////////////
///////////// SET UP //////////////////////
/////////////////////////////////
// vars
LPD3DXDEVICE9 Device = NULL;
LPDIRECT3DSURFACE9 pSurface = NULL;
LPDIRECT3DSURFACE9 pBackBuffer = NULL;
RECT DrawDest = {100, 100, 200, 200};

//get pointer to backbuffer
Device->GetBackBuffer(NULL,NULL, D3DBACKBUFFER_TYPE_MONO, &pBackBuffer);
//create a surface
Device->CreateOffscreenPlainSurface(640, 480, D3DFMT_X8R8G8B8, D3DPOOL_DEFAULT, &pBackground, NULL);

// load a bitmap to the surface
D3DXLoadSurfaceFromFile(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 screen
Device->StretchRect(pSurface,NULL,pBackBuffer,NULL, D3DTEXF_NONE);
// will draw on to the screen coords from DrawDest
Device->StretchRect(pSurface,NULL,pBackBuffer,&DrawDest, D3DTEXF_NONE);
//done drawing
Device->EndScene();
// show what you just drew
Device->Present(0, 0, 0, 0);

//////////////////////////
/////////////// WHEN ENDING PROGRRAM /////////////////
//////////////////////////////
pSurface->Release();
pBackBuffer->Release();
Device->Release();




that is more or less the ins and outs

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this