Jump to content
  • Advertisement
Sign in to follow this  
giuseppeCT

MFC splitters and DirectX

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

Hola there, hope'n someone who may help me, enigma: I'm trying to use mfc classes to create a 3d editor, i've encountered a little problem when tryin to split two time a main window, practically direct 3d doesn't initialize, because it can't create a device, with this situation all works great:
___________
|    |    |
|    |    |
|dx  | dlg|
|    |    |
|    |    |
|____|____|
left CView derived class, direct3d create the device right a main dialog !! if i try to split da dx side again to get this:
___________
|    |    |
|    |    |
|dx  | dlg|
|    |    |
|____|    |
|_tl_|____|
a time line dialog, with that situation d3d can't create a device, here's my code:
	//create splittered window 1 row and 2 cols
	if ( !m_mainSplitter.CreateStatic( this, 1, 2 ) )
	{
		MessageBox( "Error setting up splitter frames!", "Init Error!",
			MB_OK | MB_ICONERROR );
		return FALSE;
	}

	//setup statusbar
	if (!m_wndStatusBar.Create(this) ||
		!m_wndStatusBar.SetIndicators(indicators,
		  sizeof(indicators)/sizeof(UINT)))
	{
		TRACE0("Failed to create status bar\n");
		return -1;      // fail to create
	}

	//one view for the main tool panel
	if ( !m_mainSplitter.CreateView( 0, 1, RUNTIME_CLASS(CMainToolDialog),
		CSize( xsize, ysize ), pContext ) )
	{
		MessageBox( "Error setting up splitter frames!", "Init Error!",
			MB_OK | MB_ICONERROR );
		return FALSE;
	}


	//again split first column in 2 rows and 1 col
	if ( !m_tlSplitter.CreateStatic( &m_mainSplitter, 2, 1, WS_CHILD | WS_VISIBLE, m_mainSplitter.IdFromRowCol( 0, 0 ) ) )
	{
		MessageBox( "Error setting up splitter frames!", "Init Error!",
			MB_OK | MB_ICONERROR );
		return FALSE;
	}


	//view fo d3d
	if ( !m_tlSplitter.CreateView( 0, 0, RUNTIME_CLASS(CViewer),
		CSize(xsize,ysize ), pContext ) )
	{
		MessageBox( "Error setting up splitter frames!", "Init Error!",
			MB_OK | MB_ICONERROR );
		return FALSE;
	}

	//and da tl panel
	if ( !m_tlSplitter.CreateView( 1, 0, RUNTIME_CLASS(CTimeLineDialog),
		CSize(0,0 ), pContext ) )
	{
		MessageBox( "Error setting up splitter frames!", "Init Error!",
			MB_OK | MB_ICONERROR );
		return FALSE;
	}


	MessageBox("Splittered windows Created!");
	m_initSplitters = TRUE;
	return TRUE;

any idea why this occour?? any help are appreciated !!!! [Edit: Formatting assist - Oluseyi.]

Share this post


Link to post
Share on other sites
Advertisement
Sorry for the bad formatting now ''ve read the faq ;) thanx Oluseyi :) and her's the code


HRESULT Graphics::create(
HWND hWnd,
int width,
int height,
bool windowed) {

if( NULL == ( g_pD3D = Direct3DCreate9( D3D_SDK_VERSION ) ) )
return E_FAIL;

D3DPRESENT_PARAMETERS d3dpp;
ZeroMemory( &d3dpp, sizeof(d3dpp) );
d3dpp.Windowed = TRUE;
d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
d3dpp.BackBufferFormat = D3DFMT_UNKNOWN;
d3dpp.BackBufferCount = 2;

if( FAILED( g_pD3D->CreateDevice( D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hWnd,
D3DCREATE_HARDWARE_VERTEXPROCESSING,
&d3dpp, &g_pd3dDevice ) ) )
{

MessageBox(NULL,"Error creating device!","",MB_OK);
return E_FAIL;
}



return S_OK;

};






createdevice will fails miserably !!! thanx in advance dude !!!

Share this post


Link to post
Share on other sites
Oh guys, i've discovered why it doesn't works, i've to specify the window x and y size while creating the device !!!


D3DPRESENT_PARAMETERS d3dpp;
ZeroMemory( &d3dpp, sizeof(d3dpp) );
d3dpp.Windowed = TRUE;
d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
d3dpp.BackBufferFormat = D3DFMT_UNKNOWN;
d3dpp.BackBufferCount = 2;
d3dpp.BackBufferWidth = 640; // :)
d3dpp.BackBufferHeight = 480; // :)



thanx anyway !!

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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!