Problems Clearing Portion of Screen

This is a discussion on Problems Clearing Portion of Screen within the Windows Programming forums, part of the Platform Specific Boards category; Hi, I'm trying to make a simple tool to create maps for a game I'm making. The goal is to ...

  1. #1
    Registered User
    Join Date
    Jan 2006
    Location
    Seattle
    Posts
    30

    Problems Clearing Portion of Screen

    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
    Last edited by Peter5897; 05-27-2006 at 07:56 PM.

  2. #2
    Registered User
    Join Date
    Jan 2006
    Location
    Seattle
    Posts
    30
    I think I've figured it out... well actually I haven't figured it out but I just kept on messing with code and currently I have what I want occuring.

  3. #3
    Super Moderator VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,590
    Are you using multiple swap chains? You will probably want to.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. clearing the screen
    By ssharish in forum C Programming
    Replies: 2
    Last Post: 02-01-2005, 08:00 PM
  2. clearing the screen
    By satory in forum C Programming
    Replies: 5
    Last Post: 10-23-2004, 06:51 AM
  3. i am not able to figure ot the starting point of this
    By youngashish in forum C++ Programming
    Replies: 7
    Last Post: 10-07-2004, 02:41 AM
  4. sub routines and clearing the screen
    By Leeman_s in forum C++ Programming
    Replies: 2
    Last Post: 10-01-2001, 08:31 PM
  5. Clearing screen with MS VC++ 6
    By Narciss in forum C Programming
    Replies: 2
    Last Post: 09-23-2001, 07:22 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21