Sign in to follow this  
Toonkides

Window Resizing : can't figure out what I'm doing wrong

Recommended Posts

Toonkides    122
Within my Renderscene function I have this code.
switch(g_pd3dDevice->TestCooperativeLevel())
	{
	case D3DERR_DEVICELOST :
		Cleanup() ;
		return ;

	case D3DERR_DEVICENOTRESET :
		// release the objects
		if(g_pVB != NULL)
			g_pVB->Release() ;

		if(g_pTexture[0] != NULL)
			g_pTexture[0]->Release() ;
	
		if(g_pTexture[1] != NULL)
			g_pTexture[1]->Release() ;

		// reset the device
		g_pd3dDevice->Reset(&d3dpp) ;

		// recreate and initialize the objects
		ZeroMemory(&d3dpp, sizeof(d3dpp)) ;
		d3dpp.Windowed					= TRUE ;
		d3dpp.SwapEffect				= D3DSWAPEFFECT_DISCARD ;
		d3dpp.BackBufferWidth			= g_width ;
		d3dpp.BackBufferHeight			= g_height ;
		d3dpp.BackBufferFormat			= D3DFMT_UNKNOWN ;
		d3dpp.EnableAutoDepthStencil	= TRUE ;
		d3dpp.AutoDepthStencilFormat	= D3DFMT_D16 ;

		// create the D3DDevice
		if(FAILED(g_pD3D->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, g_hWnd,
			D3DCREATE_HARDWARE_VERTEXPROCESSING, &d3dpp, &g_pd3dDevice)))
			return ;

		// turn of culling
		g_pd3dDevice->SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE) ;
		// turn off D3D lighting
		g_pd3dDevice->SetRenderState(D3DRS_LIGHTING, FALSE) ;
		// turn on the zbuffer
		g_pd3dDevice->SetRenderState(D3DRS_ZENABLE, TRUE) ;
		g_pd3dDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE) ;
		InitGeometry() ;
		break ;
	}

In my Message Proc I have this code :
case WM_SIZE :
		GetClientRect(hWnd, &rc) ;
		g_width = rc.right - rc.left ;		// reset the width
		g_height = rc.bottom - rc.top ;		// reset the height
		return 0 ;

I have tried releasing->reseting->recreating/initializing the objects within the WM_SIZE message but then the application doesn't even load. Any suggestions? TIA

Share this post


Link to post
Share on other sites
Toonkides    122
never learned the thing :(, but the program actually runs, it's just not showing anything on the screen.

In the WM_SIZE message I "SAFERELEASE()" all the objects
then I test the coop levels in the render function which resets the device then I recreate my objects.

What could be wrong?

Share this post


Link to post
Share on other sites
jaxson    127
I once had a similar sounding problem and it was because I was using the D3DXFont class and I was forgetting to reset it as well. So, if you are using any of those D3DX helper classes, make sure you call their reset methods.

Share this post


Link to post
Share on other sites
Toonkides    122
My program is very basic actually it just loads a few points into the VB and applies a texture to them as well.

No fonts.

I didn't know about the WM_SIZE on startup, how do I get around this ?

TIA

Share this post


Link to post
Share on other sites
Toonkides    122
After trying that I also noticed that when i put a messagebox call within my render scene :


switch(g_pd3dDevice->TestCooperativeLevel())
{
case D3DERR_DEVICELOST :
Cleanup() ;
return ;

case D3DERR_DEVICENOTRESET :
MessageBox(NULL, TEXT("TEST"), TEXT("TESTING"), MB_OK) ;
// reset the device
g_pd3dDevice->Reset(&d3dpp) ;

// turn of culling
g_pd3dDevice->SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE) ;
// turn off D3D lighting
g_pd3dDevice->SetRenderState(D3DRS_LIGHTING, FALSE) ;
// turn on the zbuffer
g_pd3dDevice->SetRenderState(D3DRS_ZENABLE, TRUE) ;
g_pd3dDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE) ;

// recreate and initialize the objects
d3dpp.BackBufferWidth = g_width ;
d3dpp.BackBufferHeight = g_height ;

// create the D3DDevice
if(FAILED(g_pD3D->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, g_hWnd,
D3DCREATE_HARDWARE_VERTEXPROCESSING, &d3dpp, &g_pd3dDevice)))
return ;

InitGeometry() ;
break ;
}



And it's not even executing. I thought that when you release all the objects the testcoop will automatically be setup for the device not reset. Am I missing something obvious?

Share this post


Link to post
Share on other sites
Toonkides    122
I figured it out :

It turns out that if I went to my original configuration this would have worked. My problem was exactly what Endurion & Oluseyi were saying.

Thx guys, sorry to spam the boards; it was a journey!

<3

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