Jump to content
  • Advertisement
Sign in to follow this  
counterrabbit

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

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

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
Advertisement
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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!