예제 #1
0
void	Scene::Load( U16 _SceneResourceID ) {
	U32			SceneSize = 0;
	const U8*	pData = LoadResourceBinary( _SceneResourceID, "SCENE", &SceneSize );

	U32		Version = ReadU32( pData );	// Should be "GCX1"
	ASSERT( Version == 0x31584347L, "Unsupported scene version!" );

	// ==== Read Materials ====
	//
	m_MaterialsCount = ReadU16( pData );
	m_ppMaterials = new Material*[m_MaterialsCount];
	for ( int MaterialIndex=0; MaterialIndex < m_MaterialsCount; MaterialIndex++ ) {
		Material*	pMaterial = new Material( *this );
		m_ppMaterials[MaterialIndex] = pMaterial;

		pMaterial->Init( pData );
	}

	// ==== Read Node Hierarchy ====
	//
	m_NodesCount = 0;
	m_MeshesCount = 0;
	m_LightsCount = 0;
	m_CamerasCount = 0;
	m_ProbesCount = 0;

	m_pROOT = CreateNode( NULL, pData );
}
예제 #2
0
// Return 0 for no error
int	WindowInit()
{
	gs_WindowInfos.hInstance = GetModuleHandle( NULL );

	#ifndef _WIN64
		//////////////////////////////////////////////////////////////////////////
		// Initialize rounding mode once since we disabled f*****g _ftol2 link error by adding a deprecated compile flag named /QIfist
		// (always following the advice from http://www.benshoof.org/blog/minicrt/)
		static U16	CW;
		__asm
		{
			fstcw	CW							// store fpu control word  
			mov		dx, word ptr [CW]  
			or		dx, 0x0C00                  // rounding: truncate (default)
			mov		CW, dx 
			fldcw	CW							// load modfied control word  
		}  
	#endif

	//////////////////////////////////////////////////////////////////////////
	// Register the new window class
	WNDCLASSA	wc;
	memset( &wc, 0, sizeof(WNDCLASSA) );
	wc.style		 = CS_OWNDC;
	wc.lpfnWndProc   = WndProc;
	wc.hInstance	 = gs_WindowInfos.hInstance;
	wc.lpszClassName = pWindowClass;

	if( !RegisterClass( (WNDCLASSA*) &wc ) )
		return ERR_REGISTER_CLASS;

	//////////////////////////////////////////////////////////////////////////
	// Create the window
	U32	dwExStyle, dwStyle;
	if ( gs_WindowInfos.bFullscreen )
	{
		if ( ChangeDisplaySettings( &ScreenSettings, CDS_FULLSCREEN ) != DISP_CHANGE_SUCCESSFUL )
			return ERR_CHANGE_DISPLAY_SETTINGS;

		dwExStyle = WS_EX_APPWINDOW;
		dwStyle   = WS_VISIBLE | WS_POPUP | WS_CLIPSIBLINGS | WS_CLIPCHILDREN;
		ShowCursor( 0 );
	}
	else
	{
		dwExStyle = WS_EX_APPWINDOW;// | WS_EX_WINDOWEDGE;
		dwStyle   = WS_VISIBLE | WS_CAPTION | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_SYSMENU;
	}

	RECT	WindowRect;
	WindowRect.left		= 0;
	WindowRect.top		= 0;
	WindowRect.right	= RESX;
	WindowRect.bottom	= RESY;

#ifdef ALLOW_WINDOWED
	AdjustWindowRect( &WindowRect, dwStyle, false );
	gs_WindowInfos.hWnd = CreateWindowEx( dwExStyle, wc.lpszClassName, wc.lpszClassName, dwStyle,
							   (GetSystemMetrics(SM_CXSCREEN)-WindowRect.right+WindowRect.left)>>1,
							   (GetSystemMetrics(SM_CYSCREEN)-WindowRect.bottom+WindowRect.top)>>1,
							   WindowRect.right-WindowRect.left, WindowRect.bottom-WindowRect.top, 0, 0, gs_WindowInfos.hInstance, 0 );
#else
	gs_WindowInfos.hWnd = CreateWindowEx( dwExStyle, wc.lpszClassName, wc.lpszClassName, dwStyle, 0, 0, 
								 WindowRect.right-WindowRect.left, WindowRect.bottom-WindowRect.top, 0, 0, gs_WindowInfos.hInstance, 0 );
#endif
	if( gs_WindowInfos.hWnd == NULL )
		return ERR_CREATE_WINDOW;

	if( (gs_WindowInfos.hDC = GetDC( gs_WindowInfos.hWnd )) == NULL )
		return ERR_RETRIEVE_DC;
	
	SetForegroundWindow( gs_WindowInfos.hWnd );
	SetFocus( gs_WindowInfos.hWnd );


	//////////////////////////////////////////////////////////////////////////
	// Initialize DirectX Device
// 
// 	Video	Test( *((Device*) NULL), gs_WindowInfos.hWnd );
// 
	gs_Device.Init( RESX, RESY, gs_WindowInfos.hWnd, gs_WindowInfos.bFullscreen, true );
	if ( !gs_Device.IsInitialized() )
		return ERR_DX_INIT_DEVICE;	// Oopsy daisy shit f**k hell !


	//////////////////////////////////////////////////////////////////////////
	// Initialize sound player
#ifdef MUSIC
	gs_Music.Init();

	int	WorkMemSize = synthGetSize();
	gs_pMusicPlayerWorkMem = new U8[WorkMemSize];

	U32			TuneSize = 0;
	const U8*	pTheTune = LoadResourceBinary( IDR_MUSIC, "MUSIC", &TuneSize );
	if ( pTheTune == NULL )
		return ERR_MUSIC_RESOURCE_NOT_FOUND;
	if ( !gs_Music.Open( pTheTune ) )
		return ERR_MUSIC_INIT;

	dsInit( gs_Music.RenderProxy, &gs_Music, gs_WindowInfos.hWnd );

// Readback positions
// sS32*	pPositions = NULL;
// U32		PositionsCount = gs_Music.CalcPositions( &pPositions );
// delete[] pPositions;

#endif

	//////////////////////////////////////////////////////////////////////////
	// Initialize other static fields

	return 0;
}