Sign in to follow this  
v0dKA

[FIXED] The Player Disappears!!! [cpp && directx]

Recommended Posts

In my ever expanding (but still unfinished) game, I've ran into some trouble. The game worked fine, then I tried to expand it, and (surprise!) that killed it. The player doesn't get displayed anymore. Here's the jist: it's a 2D tile-based game, and also my first game, so it shouldn't be a tough problem (thereotically). The feature I tried to introduce is support for the size of the player to be different from the size of the regular tile. For example, the regular tile size is 32 pixels - I added support for the size of the player to be an even number <= 32, like 30, 28, 26, etc. (and of course, 32 is still valid). What happens now is the player just doesn't get drawn - at all. Now, the oddest aspect of this problem is, even though the code for drawing the player changed (and no longer works), it still works only when the player is 32 pixels. That's odd because the code for handling drawing the player is still the same - it works for 32, and doesn't work for anything else. C'est tres bizarre, n'est-ce pas? A little pre-code explanation: I have a class (CVisual was its name-o) that holds all vital information for my, game such as regular tile size, info about the pic where my tiles are stored, etc, and of course, player tile size. I haven't touched the project in a while now (school [sad]), but thankfully I left an extensive comment to describe my expansion plan (some of this may be a bit jibberish, but bear with me [smile]):
/*************************************************************************
	TODO: SUPPORT FOR MULTIPLE PLAYER TILE SIZES
	--------------------------------------------

  The Procedure:
		-> Extend CVISUAL to include PLAYERTILESIZE, PLAYERDRAWNORMAL.
		-> Extend every CVISUAL copy function to set those values.
		-> Implement a procedure to load the player tile size and store it (perhaps copy the procedure that checks valid image size on tileset).
		-> Error check that the player tile size <= reg. tile size.
		-> Error check that player tile size is an even number and width=height.
		-> PLAYERDRAWNORMAL = TILSIZE / 2 - ( .5 * PLAYERTILESIZE ).
		-> DrawPlayer() or whatever it was called, make it draw where it draws now+PLAYERDRAWNORMAL.
		-> CreateImageSurface(): Instead of dimensioning it by VISUAL.TILESIZE, use the width & height of
			the player tile

  Example:
		If PLAYERTILSIZE = 30, then PLAYERDRAWNORMAL would end up being 1. That means
			start drawing the player from pixel 1, rather than 0 ( 1 pixel on either side of the tile ).
	***************************************************************************/




Here's the code where the player tile is created and stored to a surface:
BOOL CDirect3D::CreatePlayerTile( const char* filename )
{
	HRESULT hResult;

	D3DXIMAGE_INFO Info;
	D3DXGetImageInfoFromFile( filename, &Info );
	int width = static_cast<int>(Info.Width);
	int height = static_cast<int>(Info.Height);
	if( width != height )
	{
		char ErrorBuffer[ 1024 ];
		wsprintf( ErrorBuffer, "Player tile %s \nis not a valid tile - width does not equal height.", filename );
		CloseWindow( m_hWnd );
		MessageBox( m_hWnd, ErrorBuffer, "Error", MB_OK | MB_ICONHAND );
		PostQuitMessage( FailCreatePlayerSurface );
		return FALSE;
	}
	if( width > VISUAL.TILESIZE || height > VISUAL.TILESIZE )
	{
		char ErrorBuffer[ 1024 ];
		wsprintf( ErrorBuffer, "Player tile %s \nexceeds the specified tile size of %d.", filename, VISUAL.TILESIZE );
		CloseWindow( m_hWnd );
		MessageBox( m_hWnd, ErrorBuffer, "Error", MB_OK | MB_ICONHAND );
		PostQuitMessage( FailCreatePlayerSurface );
		return FALSE;
	}
	if( width % 2 || height % 2 )
	{
		char ErrorBuffer[ 1024 ];
		wsprintf( ErrorBuffer, "Error in player tile %s:\nImage dimensions must be even numbers.", filename );
		CloseWindow( m_hWnd );
		MessageBox( m_hWnd, ErrorBuffer, "Error", MB_OK | MB_ICONHAND );
		PostQuitMessage( FailCreatePlayerSurface );
		return FALSE;
	}
	VISUAL.PLAYERTILESIZE = width;

	hResult = m_pD3DDevice->CreateImageSurface( VISUAL.PLAYERTILESIZE, VISUAL.PLAYERTILESIZE,
		D3DFMT_X8R8G8B8, &m_pPlayerTile );
	if( FAILED( hResult ) )
	{
		CloseWindow( m_hWnd );
		MessageBox( m_hWnd,
			"Failed to create player surface.\nPlease contact the program vendor about this problem.",
			"Error",
			MB_OK | MB_ICONHAND );
		PostQuitMessage( FailCreatePlayerSurface );
		return FALSE;
	}

	hResult = D3DXLoadSurfaceFromFile( m_pPlayerTile,
		NULL, NULL, filename,
		NULL, D3DX_FILTER_NONE, 0, NULL );
	if( FAILED( hResult ) )
	{
		char ErrorMessage[ 1024 ];
		wsprintf( ErrorMessage, "Cannot find the default player tile. Please make sure this player tile exists:\n%s", filename );
		CloseWindow( m_hWnd );
		MessageBox( m_hWnd,
			ErrorMessage,
			"Error",
			MB_OK | MB_ICONHAND );
		PostQuitMessage( FailFindDefPlayerSurface );
		return FALSE;
	}
	return TRUE;
}




Here's a line from a function that finishes off the initializing: VISUAL.PLAYERDRAWNORMAL = ( VISUAL.TILESIZE / 2 ) - ( .5 * VISUAL.PLAYERTILESIZE ); Still with me? Here's the drawing preparation code, and most likely the culprit (btw, some lines have a /////TEMP DEBUG around them somewhere - that's something that isn't going to stay in the final game, things like outputting variables. Ignore them):
void CEngine::PrepareDraw( int& LowVisibleCol, int& HiVisibleCol,
								 int& LowVisibleRow, int& HiVisibleRow,
								 POINT& DstPoint, char buf[] )
{


	int PlayerMapCol = Map.Player.GetPosition()->y;
	int PlayerMapRow = Map.Player.GetPosition()->x;
	LowVisibleCol = PlayerMapCol - VISUAL.NORMALVISIBLEPLAYERCOL;
	HiVisibleCol = PlayerMapCol + VISUAL.NORMALVISIBLEPLAYERCOL;
	LowVisibleRow = PlayerMapRow - VISUAL.NORMALVISIBLEPLAYERROW;
	HiVisibleRow = PlayerMapRow + VISUAL.NORMALVISIBLEPLAYERROW;

	DstPoint.x = VISUAL.NORMALVISIBLEPLAYERCOL * VISUAL.TILESIZE + VISUAL.XOFFSET + VISUAL.PLAYERDRAWNORMAL;
	DstPoint.y = VISUAL.NORMALVISIBLEPLAYERROW * VISUAL.TILESIZE + VISUAL.YOFFSET + VISUAL.PLAYERDRAWNORMAL;

	////////////// TEMP DEBUG
	//wsprintf( buf, "NormalVisiblePlayerRow: %d", VISUAL.NORMALVISIBLEPLAYERROW );
	/////////////////////////

	if( PlayerMapCol < VISUAL.NORMALVISIBLEPLAYERCOL )
	{

		LowVisibleCol = 0;
		HiVisibleCol = VISUAL.VISIBLECOLUMNCOUNT - 1;

		DstPoint.x = Column2X( PlayerMapCol, VISUAL.TILESIZE, VISUAL.MAPCOLUMNCOUNT ) + VISUAL.XOFFSET;
		//DstPoint.y = Row2Y( PlayerMapRow, VISUAL.TILESIZE ) + VISUAL.YOFFSET;
	}
	else if( PlayerMapCol > VISUAL.MAPCOLUMNCOUNT - VISUAL.NORMALVISIBLEPLAYERCOL )
	{

		HiVisibleCol = VISUAL.MAPCOLUMNCOUNT;
		LowVisibleCol = VISUAL.MAPCOLUMNCOUNT - VISUAL.VISIBLECOLUMNCOUNT + 1;

		DstPoint.x = Column2X( 2*VISUAL.NORMALVISIBLEPLAYERCOL - VISUAL.MAPCOLUMNCOUNT + PlayerMapCol, VISUAL.TILESIZE, VISUAL.MAPCOLUMNCOUNT ) + VISUAL.XOFFSET;
	}
	
	if( PlayerMapRow < VISUAL.NORMALVISIBLEPLAYERROW )
	{

		LowVisibleRow = 0;
		HiVisibleRow = VISUAL.VISIBLEROWCOUNT - 1;

		DstPoint.y = Row2Y( PlayerMapRow, VISUAL.TILESIZE ) + VISUAL.YOFFSET;
	}
	else if( PlayerMapRow > VISUAL.MAPROWCOUNT - VISUAL.NORMALVISIBLEPLAYERROW )
	{

		HiVisibleRow = VISUAL.MAPROWCOUNT;
		LowVisibleRow = VISUAL.MAPROWCOUNT - VISUAL.VISIBLEROWCOUNT + 1;

		DstPoint.y = Row2Y( 2*VISUAL.NORMALVISIBLEPLAYERROW - VISUAL.MAPROWCOUNT + PlayerMapRow, VISUAL.TILESIZE ) + VISUAL.YOFFSET;
	}




	if( VISUAL.NORMALVISIBLEPLAYERCOL > VISUAL.MAPCOLUMNCOUNT )
		HiVisibleCol = VISUAL.MAPCOLUMNCOUNT;
	if( VISUAL.NORMALVISIBLEPLAYERROW > VISUAL.MAPROWCOUNT )
		HiVisibleRow = VISUAL.MAPROWCOUNT;

		///////// TEMP DEBUG
	wsprintf( buf, "LowVisibleCol=%d HiVisibleCol=%d", LowVisibleCol, HiVisibleRow );
	////////////////////

}




The drawing code is a matter of getting that DstPoint from the above function, and using it to draw the player in the correct spot:
RECT SrcTileRect;
	SrcTileRect.left = 0;
	SrcTileRect.right = VISUAL.PLAYERTILESIZE;
	SrcTileRect.top = 0;
	SrcTileRect.bottom = VISUAL.PLAYERTILESIZE;

	m_Direct3D.GetDevice()->CopyRects( m_Direct3D.GetPlayerTile(),
		&SrcTileRect, 1, m_Direct3D.GetBackBuffer(), &DstPoint );




I'm sorry, it's a lot of code. If anyone has any ideas, please help! If something needs more clarifying, notify me. I may have not explained everything (it's quite late), so tell if there are any probs. Any insight on this is appreciated in advance! EDIT: Real sorry about the unfortunate turnout of the spacing too! [Edited by - v0dKA on December 10, 2004 5:59:47 PM]

Share this post


Link to post
Share on other sites
What the...

I never used the debug runtimes, so I tried to set it up. Well, something screwed up, bad. Here's exactly what I did:

I went Start->Settings->Control Panel, then under DirectX. I went under Direct3D tab, put the Debug Output level dead in the center, clicked "Use Debug Version of Direct3D" (instead of retail), and checked "Enable multi-mon debugging" (since I have 2 monitors).

Well, now my game doesn't run as before. The debugging text I outputted in my game is gone - that code never gets to be executed now, or what? The escape key still works, but I'm not sure if that's from the game or just a safety feature of DirectX debugger. I have no way of knowing whether or not my game is responding since the player doesn't get drawn, and that's about as much interaction as I've programmed into my game thus far.

Anyways, at least some useful looking junk gets spit out into the debug pane now:

Direct3D8: (ERROR) :*** Exception in d:\builds\nt32_chk\multimedia\directx\dxg\d3d8\fe\d3dbase.cpp Line: 3443

Direct3D8: (ERROR) :Need to call BeginScene before rendering.

Direct3D8: (ERROR) :*** Exception in d:\builds\nt32_chk\multimedia\directx\dxg\d3d8\fe\d3dbase.cpp Line: 3443

Direct3D8: (ERROR) :Need to call BeginScene before rendering.

Direct3D8: (ERROR) :*** Exception in d:\builds\nt32_chk\multimedia\directx\dxg\d3d8\fe\d3dbase.cpp Line: 3443

Direct3D8: (ERROR) :Need to call BeginScene before rendering.

Direct3D8: (ERROR) :*** Exception in d:\builds\nt32_chk\multimedia\directx\dxg\d3d8\fe\d3dbase.cpp Line: 3443

Direct3D8: (ERROR) :Need to call BeginScene before rendering.

Direct3D8: (ERROR) :*** Exception in d:\builds\nt32_chk\multimedia\directx\dxg\d3d8\fe\d3dbase.cpp Line: 3443

Direct3D8: (ERROR) :Need to call BeginScene before rendering.

First-chance exception in GTM1.exe (KERNEL32.DLL): 0xE06D7363: Microsoft C++ Exception.
Direct3D8: (ERROR) :*** Exception in d:\builds\nt32_chk\multimedia\directx\dxg\d3d8\fe\d3dbase.cpp Line: 3443

Direct3D8: (ERROR) :Need to call BeginScene before rendering.
First-chance exception in GTM1.exe (KERNEL32.DLL): 0xE06D7363: Microsoft C++ Exception.
First-chance exception in GTM1.exe (KERNEL32.DLL): 0xE06D7363: Microsoft C++ Exception.

First-chance exception in GTM1.exe (KERNEL32.DLL): 0xE06D7363: Microsoft C++ Exception.
Direct3D8: (ERROR) :*** Exception in d:\builds\nt32_chk\multimedia\directx\dxg\d3d8\fe\d3dbase.cpp Line: 3443
First-chance exception in GTM1.exe (KERNEL32.DLL): 0xE06D7363: Microsoft C++ Exception.
First-chance exception in GTM1.exe (KERNEL32.DLL): 0xE06D7363: Microsoft C++ Exception.

Direct3D8: (ERROR) :Need to call BeginScene before rendering.
First-chance exception in GTM1.exe (KERNEL32.DLL): 0xE06D7363: Microsoft C++ Exception.

Direct3D8: (ERROR) :*** Exception in d:\builds\nt32_chk\multimedia\directx\dxg\d3d8\fe\d3dbase.cpp Line: 3443
First-chance exception in GTM1.exe (KERNEL32.DLL): 0xE06D7363: Microsoft C++ Exception.
First-chance exception in GTM1.exe (KERNEL32.DLL): 0xE06D7363: Microsoft C++ Exception.

First-chance exception in GTM1.exe (KERNEL32.DLL): 0xE06D7363: Microsoft C++ Exception.
First-chance exception in GTM1.exe (KERNEL32.DLL): 0xE06D7363: Microsoft C++ Exception.
Direct3D8: (ERROR) :Need to call BeginScene before rendering.

First-chance exception in GTM1.exe (KERNEL32.DLL): 0xE06D7363: Microsoft C++ Exception.
First-chance exception in GTM1.exe (KERNEL32.DLL): 0xE06D7363: Microsoft C++ Exception.
First-chance exception in GTM1.exe (KERNEL32.DLL): 0xE06D7363: Microsoft C++ Exception.
Direct3D8: (ERROR) :*** Exception in d:\builds\nt32_chk\multimedia\directx\dxg\d3d8\fe\d3dbase.cpp Line: 3443

Direct3D8: (ERROR) :Need to call BeginScene before rendering.

Direct3D8: (ERROR) :*** Exception in d:\builds\nt32_chk\multimedia\directx\dxg\d3d8\fe\d3dbase.cpp Line: 3443

Direct3D8: (ERROR) :Need to call BeginScene before rendering.

Direct3D8: (ERROR) :*** Exception in d:\builds\nt32_chk\multimedia\directx\dxg\d3d8\fe\d3dbase.cpp Line: 3443

Direct3D8: (ERROR) :Need to call BeginScene before rendering.

Direct3D8: (ERROR) :*** Exception in d:\builds\nt32_chk\multimedia\directx\dxg\d3d8\fe\d3dbase.cpp Line: 3443

Direct3D8: (ERROR) :Need to call BeginScene before rendering.

Direct3D8: (ERROR) :*** Exception in d:\builds\nt32_chk\multimedia\directx\dxg\d3d8\fe\d3dbase.cpp Line: 3443

Direct3D8: (ERROR) :Need to call BeginScene before rendering.

Direct3D8: (ERROR) :*** Exception in d:\builds\nt32_chk\multimedia\directx\dxg\d3d8\fe\d3dbase.cpp Line: 3443

Direct3D8: (ERROR) :Need to call BeginScene before rendering.

Direct3D8: (ERROR) :Invalid Rect: zero-area.
Direct3D8: (ERROR) :CopyRects failed
Direct3D8: (ERROR) :*** Exception in d:\builds\nt32_chk\multimedia\directx\dxg\d3d8\fe\d3dbase.cpp Line: 3443

Direct3D8: (ERROR) :Need to call BeginScene before rendering.
First-chance exception in GTM1.exe (KERNEL32.DLL): 0xE06D7363: Microsoft C++ Exception.

First-chance exception in GTM1.exe (KERNEL32.DLL): 0xE06D7363: Microsoft C++ Exception.
Direct3D8: (ERROR) :*** Exception in d:\builds\nt32_chk\multimedia\directx\dxg\d3d8\fe\d3dbase.cpp Line: 3443
First-chance exception in GTM1.exe (KERNEL32.DLL): 0xE06D7363: Microsoft C++ Exception.
First-chance exception in GTM1.exe (KERNEL32.DLL): 0xE06D7363: Microsoft C++ Exception.

Direct3D8: (ERROR) :Need to call BeginScene before rendering.
First-chance exception in GTM1.exe (KERNEL32.DLL): 0xE06D7363: Microsoft C++ Exception.

Direct3D8: (ERROR) :*** Exception in d:\builds\nt32_chk\multimedia\directx\dxg\d3d8\fe\d3dbase.cpp Line: 3443
First-chance exception in GTM1.exe (KERNEL32.DLL): 0xE06D7363: Microsoft C++ Exception.
First-chance exception in GTM1.exe (KERNEL32.DLL): 0xE06D7363: Microsoft C++ Exception.

First-chance exception in GTM1.exe (KERNEL32.DLL): 0xE06D7363: Microsoft C++ Exception.
First-chance exception in GTM1.exe (KERNEL32.DLL): 0xE06D7363: Microsoft C++ Exception.
Direct3D8: (ERROR) :Need to call BeginScene before rendering.
First-chance exception in GTM1.exe (KERNEL32.DLL): 0xE06D7363: Microsoft C++ Exception.

Direct3D8: (ERROR) :*** Exception in d:\builds\nt32_chk\multimedia\directx\dxg\d3d8\fe\d3dbase.cpp Line: 3443
First-chance exception in GTM1.exe (KERNEL32.DLL): 0xE06D7363: Microsoft C++ Exception.
First-chance exception in GTM1.exe (KERNEL32.DLL): 0xE06D7363: Microsoft C++ Exception.

First-chance exception in GTM1.exe (KERNEL32.DLL): 0xE06D7363: Microsoft C++ Exception.
First-chance exception in GTM1.exe (KERNEL32.DLL): 0xE06D7363: Microsoft C++ Exception.
Direct3D8: (ERROR) :Need to call BeginScene before rendering.

Direct3D8: (ERROR) :*** Exception in d:\builds\nt32_chk\multimedia\directx\dxg\d3d8\fe\d3dbase.cpp Line: 3443

Direct3D8: (ERROR) :Need to call BeginScene before rendering.

Direct3D8: (ERROR) :*** Exception in d:\builds\nt32_chk\multimedia\directx\dxg\d3d8\fe\d3dbase.cpp Line: 3443

Direct3D8: (ERROR) :Need to call BeginScene before rendering.

Direct3D8: (ERROR) :*** Exception in d:\builds\nt32_chk\multimedia\directx\dxg\d3d8\fe\d3dbase.cpp Line: 3443

Direct3D8: (ERROR) :Need to call BeginScene before rendering.

Direct3D8: (ERROR) :*** Exception in d:\builds\nt32_chk\multimedia\directx\dxg\d3d8\fe\d3dbase.cpp Line: 3443

Direct3D8: (ERROR) :Need to call BeginScene before rendering.

Direct3D8: (ERROR) :*** Exception in d:\builds\nt32_chk\multimedia\directx\dxg\d3d8\fe\d3dbase.cpp Line: 3443

Direct3D8: (ERROR) :Need to call BeginScene before rendering.

Direct3D8: (ERROR) :*** Exception in d:\builds\nt32_chk\multimedia\directx\dxg\d3d8\fe\d3dbase.cpp Line: 3443

Direct3D8: (ERROR) :Need to call BeginScene before rendering.

Direct3D8: (ERROR) :*** Exception in d:\builds\nt32_chk\multimedia\directx\dxg\d3d8\fe\d3dbase.cpp Line: 3443

Direct3D8: (ERROR) :Need to call BeginScene before rendering.

Direct3D8: (ERROR) :*** Exception in d:\builds\nt32_chk\multimedia\directx\dxg\d3d8\fe\d3dbase.cpp Line: 3443

Direct3D8: (ERROR) :Need to call BeginScene before rendering.
First-chance exception in GTM1.exe (KERNEL32.DLL): 0xE06D7363: Microsoft C++ Exception.
First-chance exception in GTM1.exe (KERNEL32.DLL): 0xE06D7363: Microsoft C++ Exception.

First-chance exception in GTM1.exe (KERNEL32.DLL): 0xE06D7363: Microsoft C++ Exception.
Direct3D8: (ERROR) :*** Exception in d:\builds\nt32_chk\multimedia\directx\dxg\d3d8\fe\d3dbase.cpp Line: 3443
First-chance exception in GTM1.exe (KERNEL32.DLL): 0xE06D7363: Microsoft C++ Exception.
First-chance exception in GTM1.exe (KERNEL32.DLL): 0xE06D7363: Microsoft C++ Exception.

Direct3D8: (ERROR) :Need to call BeginScene before rendering.

First-chance exception in GTM1.exe (KERNEL32.DLL): 0xE06D7363: Microsoft C++ Exception.
First-chance exception in GTM1.exe (KERNEL32.DLL): 0xE06D7363: Microsoft C++ Exception.
First-chance exception in GTM1.exe (KERNEL32.DLL): 0xE06D7363: Microsoft C++ Exception.
First-chance exception in GTM1.exe (KERNEL32.DLL): 0xE06D7363: Microsoft C++ Exception.
Direct3D8: (ERROR) :*** Exception in d:\builds\nt32_chk\multimedia\directx\dxg\d3d8\fe\d3dbase.cpp Line: 3443

First-chance exception in GTM1.exe (KERNEL32.DLL): 0xE06D7363: Microsoft C++ Exception.
First-chance exception in GTM1.exe (KERNEL32.DLL): 0xE06D7363: Microsoft C++ Exception.
Direct3D8: (ERROR) :Need to call BeginScene before rendering.
First-chance exception in GTM1.exe (KERNEL32.DLL): 0xE06D7363: Microsoft C++ Exception.
First-chance exception in GTM1.exe (KERNEL32.DLL): 0xE06D7363: Microsoft C++ Exception.

First-chance exception in GTM1.exe (KERNEL32.DLL): 0xE06D7363: Microsoft C++ Exception.
First-chance exception in GTM1.exe (KERNEL32.DLL): 0xE06D7363: Microsoft C++ Exception.
Direct3D8: (ERROR) :*** Exception in d:\builds\nt32_chk\multimedia\directx\dxg\d3d8\fe\d3dbase.cpp Line: 3443

First-chance exception in GTM1.exe (KERNEL32.DLL): 0xE06D7363: Microsoft C++ Exception.
First-chance exception in GTM1.exe (KERNEL32.DLL): 0xE06D7363: Microsoft C++ Exception.
Direct3D8: (ERROR) :Need to call BeginScene before rendering.
First-chance exception in GTM1.exe (KERNEL32.DLL): 0xE06D7363: Microsoft C++ Exception.

Direct3D8: (ERROR) :*** Exception in d:\builds\nt32_chk\multimedia\directx\dxg\d3d8\fe\d3dbase.cpp Line: 3443

Direct3D8: (ERROR) :Need to call BeginScene before rendering.

Direct3D8: (ERROR) :*** Exception in d:\builds\nt32_chk\multimedia\directx\dxg\d3d8\fe\d3dbase.cpp Line: 3443

Direct3D8: (ERROR) :Need to call BeginScene before rendering.

Direct3D8: (ERROR) :*** Exception in d:\builds\nt32_chk\multimedia\directx\dxg\d3d8\fe\d3dbase.cpp Line: 3443

Direct3D8: (ERROR) :Need to call BeginScene before rendering.

Direct3D8: (ERROR) :Invalid Rect: zero-area.
Direct3D8: (ERROR) :CopyRects failed
Direct3D8: (ERROR) :*** Exception in d:\builds\nt32_chk\multimedia\directx\dxg\d3d8\fe\d3dbase.cpp Line: 3443

Direct3D8: (ERROR) :Need to call BeginScene before rendering.

Direct3D8: (ERROR) :*** Exception in d:\builds\nt32_chk\multimedia\directx\dxg\d3d8\fe\d3dbase.cpp Line: 3443

Direct3D8: (ERROR) :Need to call BeginScene before rendering.

Direct3D8: (ERROR) :*** Exception in d:\builds\nt32_chk\multimedia\directx\dxg\d3d8\fe\d3dbase.cpp Line: 3443


it goes on, I only copied about a tenth of it.

Now, the main thing that worries me is my text doesn't get displayed anymore, and that was the only way of knowing my program was responding.

Anyone happens to know what's wrong now?

btw, here's the text that outputs the text:

char buf[ 1024 ];
wsprintf( buf, "Drawing player at x:%d y:%d", DstPoint.x, DstPoint.y );
LOGFONT lf;
ZeroMemory( &lf, sizeof( LOGFONT ) );
lf.lfHeight = 12;
lf.lfWidth = 7;
lf.lfItalic = false;
lf.lfUnderline = false;
lf.lfStrikeOut = false;
lf.lfCharSet = DEFAULT_CHARSET;
strcpy( lf.lfFaceName, "Times New Roman" );
ID3DXFont* font = 0;
D3DXCreateFontIndirect( m_Direct3D.GetDevice(), &lf, &font );
RECT destRect;
destRect.left = 0;
destRect.right = 800;
destRect.top = 54;
destRect.bottom = 500;
font->DrawText( buf, -1, &destRect,
DT_TOP | DT_RIGHT, 0xffffffff );

Share this post


Link to post
Share on other sites
Are you calling BeginScene()/EndScene() anywhere in your main render loop at all?

You'll need to be doing that for ID3DXFont to work. I'm also persuaded that you might need to do it for CopyRects to work, though I don't have the D3D8 docs around to check with.

You're seeing the message lots of times because it's generating it each time the relevant function is called - that is, once per frame.

Try setting a breakpoint on the call and stepping over it. The D3D runtime should spit out debug messages as and when you make the calls, so you'll see pretty quickly which ones are complaining.

Share this post


Link to post
Share on other sites
Problem fixed!

I didn't call Begin/EndScene() at all, and it worked fine under the retail dll's. Changed it and it works fine now.

Anyways, as to the main problem, it was just a matter of updating a variable. I updated it in one function but forgot to copy it so it can be used in the other function.

Still more problems, though, but they belong in another thread (memory leaks).

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