Hi,
I'm trying to make a simple tool to create maps for a game I'm making. The goal is to be able to create the maps visually in this program and then save them to a binary or text file which I can then load in to the game and decode. The problem now is that I'm having trouble with what I'm assuming should be some pretty simple display code.
Code:
HRESULT UpdateToolBar(HWND &hWnd, DisplayInfo& DisplayInfo, IDirect3DDevice9* &pDevice,
ID3DXSprite* &pSprite, IDirect3DTexture9* &pTexture, unsigned int posX,
unsigned int posY)
{
HRESULT hr = S_OK;
// setting position of tile to draw
D3DXVECTOR3 position( float(posX), float(posY), 0 );
D3DRECT clearRect[1];
// rectangular coordinates of tile
clearRect[0].x1 = posX;
clearRect[0].x2 = posX + 64;
clearRect[0].y1 = posY;
clearRect[0].y2 = posY + 64;
// clearing area where tile will be drawn
hr = pDevice->Clear( 1, clearRect, D3DCLEAR_TARGET, 0x00000000, 0.f, 0L );
if( SUCCEEDED(hr) )
hr = pDevice->BeginScene();
if( SUCCEEDED(hr) )
hr = pSprite->Begin( D3DXSPRITE_ALPHABLEND );
if( SUCCEEDED(hr) )
hr = pSprite->Draw(
pTexture, // texture to draw
NULL, // source rect -- NULL to draw the whole thing
NULL, // sprite center--NULL for default
&position, // draw position--NULL for default
0xffffffff ); // color modulator--0xffffffff is no change in color
if( SUCCEEDED(hr) )
hr = pSprite->End();
if( SUCCEEDED(hr) )
hr = pDevice->EndScene();
if( SUCCEEDED(hr) )
hr = pDevice->Present( NULL, NULL, hWnd, NULL );
ShowWindow( hWnd, SW_SHOW );
return hr;
}
I have a 64x64 "tile" on the left side of my screen in a child window that has a vertical scrollbar. As a simple test I'm trying to draw one tile and have it be displayed leaving the rest of the window in it's original state. Currently I am able to display the tile but everything else is cleared and set to black, including the vertical scrollbar of my child window.
I've been looking at the IDirect3DDevice9::Clear() and IDirect3DDevice9::Present() functions and I'm thinking my problem probably lies with my use of one of them.
Any help would be greatly appreciated.
-Peter
*EDIT* I'm using Visual Studios 2003