Example #1
0
int WINAPI
WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine,
        int nShowCmd)
{
    MSG msg;

    /* Force XORMOVE window redraw algorithm, required
     * for this version of alpha blend painting
     */
    mwERASEMOVE = FALSE;

    RegisterAppClass();

    /* set background wallpaper*/
    MwSetDesktopWallpaper(&image_car8);

    /* must update root window until alpha blend blitting
     * uses off screen memory for hidden windows, rather than
     * screen memory*/
    UpdateWindow(GetDesktopWindow());

    CreateAppWindow();
    CreateAppWindow();

    /* type ESC to quit...*/
    while( GetMessage(&msg, NULL, 0, 0)) {
        TranslateMessage(&msg);
        DispatchMessage(&msg);
    }
    return 0;
}
void TextWindow::Initialise (HWND hWnd, unsigned int uID)
{	
	// Make the ID global
	m_ID = uID;
	m_parenthwnd = hWnd;
	//m_hwnd = hWnd;

	// Temporary string value for uID
	char szID[SIZE_STRING];
	ZeroMemory (szID, SIZE_STRING);

	SetParentHWND (hWnd);
	SetBgColor (GetSysColor (COLOR_BTNFACE));
	SetCaption (TEXT ("Decrypted Text"));
	SetWindowStyle (FS_STYLESTANDARD);

	// Create the class name
	strcat_s (m_szClassname, SIZE_STRING, "TextWindowClass");
	sprintf_s (szID, SIZE_STRING, "%d", uID);
	strcat_s (m_szClassname, SIZE_STRING, szID);

	if (m_binitialised == false) {
		CreateAppWindow (m_szClassname, 70, 0, 400, 550, true);
		m_uihandler.SetWindowProperties (0, 0, 300, 0, RGB (230, 230, 240));
		SetWindowPosition (FS_CENTER);
		m_binitialised = true;
	}

	Show ();
}
Example #3
0
int _tmain(int argc, _TCHAR* argv[])
{		
	if (CreateAppWindow())
	{
		if (RegisterForRawInputs()) 
		{
			//Run the message loop for the window.
			MSG msg;
			BOOL ret;
			while (ret = GetMessage(&msg, hWnd, 0, 0))
			{	
				if (ret == -1)
				{
					//printf("Failed to retrieve message.\n");
				}
				else
				{
					TranslateMessage(&msg); 
					DispatchMessage(&msg); 
				}
			}
			UnregisterForRawInputs();
		}
		DeleteAppWindow();
	}	
	return 0;
}
Example #4
0
//-----------------------------------------------------------------------------
// Init, shutdown
//-----------------------------------------------------------------------------
bool CVMTEditApp::PreInit( IAppSystemGroup *pAppSystemGroup )
{	
	// initialize interfaces
	CreateInterfaceFn appFactory = pAppSystemGroup->GetFactory(); 
	if (!vgui::VGui_InitInterfacesList( "VMTEDIT", &appFactory, 1 ))
		return false;

	g_pMatSystemSurface = (IMatSystemSurface *)pAppSystemGroup->FindSystem(MAT_SYSTEM_SURFACE_INTERFACE_VERSION);

	char *pArg;
	int iWidth = 1024;
	int iHeight = 768;
	bool bWindowed = (CommandLine()->CheckParm( "-fullscreen" ) == NULL);
	if (CommandLine()->CheckParm( "-width", &pArg ))
	{
		iWidth = atoi( pArg );
	}
	if (CommandLine()->CheckParm( "-height", &pArg ))
	{
		iHeight = atoi( pArg );
	}

	if (!CreateAppWindow( "VMTEdit", bWindowed, iWidth, iHeight ))
		return false;

	g_pMatSystemSurface->AttachToWindow( m_HWnd );

	// NOTE: If we specifically wanted to use a particular shader DLL, we set it here...
	//g_pMaterialSystem->SetShader( "shaderapidx8" );
	
	return true; 
}
void AboutWindow::Initialise (HWND hWnd, unsigned int uID)
{	
	// Make the ID global
	m_ID = uID;
	m_parenthwnd = hWnd;
	//m_hwnd = hWnd;

	// Temporary string value for uID
	char szID[SIZE_STRING];
	ZeroMemory (szID, SIZE_STRING);

	SetParentHWND (hWnd);
	SetBgColor (GetSysColor (COLOR_BTNFACE));
	SetCaption (TEXT ("About"));
	SetWindowStyle (FS_STYLESTANDARD);

	// Create the class name
	strcat_s (m_szClassname, SIZE_STRING, "ABOUTWindowClass");
	sprintf_s (szID, SIZE_STRING, "%d", uID);
	strcat_s (m_szClassname, SIZE_STRING, szID);


	CreateAppWindow (m_szClassname, 70, 0, 397, 200, true);
	m_uihandler.SetWindowProperties (0, 0, 299, 0, GetSysColor (COLOR_BTNFACE));
	SetWindowPosition (FS_CENTER);
	Show ();
}
//-----------------------------------------------------------------------------
// PreInit, PostShutdown
//-----------------------------------------------------------------------------
bool CInputTestApp::PreInit( )
{
	if ( !BaseClass::PreInit() )
		return false;

	if (!g_pFullFileSystem || !g_pInputSystem )
		return false;

	// Add paths...
	if ( !SetupSearchPaths() )
		return false;

	const char *pArg;
	int iWidth = 1024;
	int iHeight = 768;
	bool bWindowed = (CommandLine()->CheckParm( "-fullscreen" ) == NULL);
	if (CommandLine()->CheckParm( "-width", &pArg ))
	{
		iWidth = atoi( pArg );
	}
	if (CommandLine()->CheckParm( "-height", &pArg ))
	{
		iHeight = atoi( pArg );
	}

	if (!CreateAppWindow( "InputTest", bWindowed, iWidth, iHeight ))
		return false;

	g_pInputSystem->AttachToWindow( m_HWnd );
	return true;
}
Example #7
0
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd)
{
#if defined _DEBUG
    _CrtSetDbgFlag(_CRTDBG_LEAK_CHECK_DF | _CRTDBG_ALLOC_MEM_DF);
    _CrtSetReportMode(_CRT_ASSERT, _CRTDBG_MODE_FILE);
    _CrtSetReportFile(_CRT_ASSERT, _CRTDBG_FILE_STDERR);
#endif

    MSG msg = {0};
    WNDCLASSEX wcl = {0};

    wcl.cbSize = sizeof(wcl);
    wcl.style = CS_OWNDC | CS_HREDRAW | CS_VREDRAW;
    wcl.lpfnWndProc = WindowProc;
    wcl.cbClsExtra = 0;
    wcl.cbWndExtra = 0;
    wcl.hInstance = g_hInstance = hInstance;
    wcl.hIcon = LoadIcon(0, IDI_APPLICATION);
    wcl.hCursor = LoadCursor(0, IDC_ARROW);
    wcl.hbrBackground = 0;
    wcl.lpszMenuName = 0;
    wcl.lpszClassName = "GL3WindowClass";
    wcl.hIconSm = 0;
    if (!RegisterClassEx(&wcl))
        return 0;

    g_hWnd = CreateAppWindow(wcl, "CastleLib Test App");
	if (g_hWnd==NULL)
		return 0;

	if (!Init())	// Init OpenGL context and our library
		return 0;
	
    ShowWindow(g_hWnd, nShowCmd);
    UpdateWindow(g_hWnd);

    while (true)
    {
        while (PeekMessage(&msg, 0, 0, 0, PM_REMOVE))
        {
            if (msg.message == WM_QUIT)
                break;

            TranslateMessage(&msg);
            DispatchMessage(&msg);
        }

        if (msg.message == WM_QUIT)
            break;

        if (g_hasFocus)
            OnIdle();
        else
            WaitMessage();
    }
    return msg.wParam;
}
Example #8
0
Bool GApp::Init()
{
	//	can only get the module handle after main() 
	//GApp::g_HInstance = GetModuleHandle(NULL);
	if ( !CreateAppWindow() )
	{
		return FALSE;
	}

	Window()->SetOwnerApp( this );
	m_Display.m_pWindow = (GOpenglWindow*)Window();

	//	init inputs
	g_Keyboard.Init();
	g_Mouse.Init();
	g_Pad.Init();


	//	game initialisation
	if ( !GameInit() )
	{
		return FALSE;
	}

	//	window needs to already have been allocated
	if ( !Window() )
	{
		GDebug_Break("Window needs to already have been created\n");
		return FALSE;
	}

	//	create new window
	if ( ! Window()->Init( NULL, Window()->DefaultFlags(), 0, (char*)GameName() ) )
	{
		return FALSE;
	}

	//	create display, window etc
	if ( !m_Display.Init() )
	{
		return FALSE;
	}

	//	game post-display init
	if ( !GameDisplayInit() )
	{
		return FALSE;
	}

	Window()->Show();
	
	//	make sure everything is sized up
	OnResize();

	return TRUE;
}
Example #9
0
///=====================================================
/// 
///=====================================================
int __stdcall WinMain(HINSTANCE thisAppInstance, HINSTANCE /*hPrevInstance*/, LPSTR /*lpCmdLine*/, int nShowCmd){
	HWND myWindowHandle = CreateAppWindow(thisAppInstance, nShowCmd);

	s_theApp = new TheApp();
	s_theApp->Startup((void*)myWindowHandle);
	s_theApp->Run();
	s_theApp->Shutdown();

	delete s_theApp;
}
Example #10
0
ApplicationNDS::ApplicationNDS()
{
	NDSApplication	= this;

	_active		= TRUE;					// Window Active Flag Set To TRUE By Default
	_done		= FALSE;

	memset(_keys, 0, sizeof(_keys));

	// Create Our OpenGL Window
	_ready		= CreateAppWindow(256,192, 16);
}
Example #11
0
int WINAPI 
WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine,
	int nShowCmd)
{
	MSG 	msg;
	HWND	hwnd;
	RECT	rc;

	RegisterAppClass();
	GetWindowRect(GetDesktopWindow(), &rc);
#if !(ELKS | MSDOS)
	/* create penguin window*/
	CreateWindowEx(0L, APPCHILD, "", WS_BORDER | WS_VISIBLE,
		rc.right-130-1, rc.bottom-153-1, 130, 153,
		GetDesktopWindow(), (HMENU)1000, NULL, NULL);
#endif
	CreateAppWindow();
	CreateAppWindow();
	CreateAppWindow();
#if !(ELKS | MSDOS)
	CreateAppWindow();
	CreateAppWindow();
	CreateAppWindow();
	CreateAppWindow();
	CreateAppWindow();
	hwnd = CreateAppWindow();
	GetWindowRect(hwnd, &rc);
	OffsetRect(&rc, 50, 50);
	MoveWindow(hwnd, rc.left, rc.top, rc.bottom-rc.top,
		rc.right-rc.left, TRUE);
#endif
#if !(ELKS | MSDOS)
	/* set background wallpaper*/
	MwSetDesktopWallpaper(&image_microwin);
	/*MwSetDesktopWallpaper(&image_under4);*/
	/*MwSetDesktopWallpaper(&image_car8);*/
#endif

	/* type ESC to quit...*/
	while( GetMessage(&msg, NULL, 0, 0)) {
		TranslateMessage(&msg);
		DispatchMessage(&msg);
	}
	return 0;
}
void Diagnostics::Initialise (HWND hWnd, LPSTR lpCmdLine)
{	
	SetParentHWND (hWnd);
	SetBgColor (RGB (200, 200, 200));
	SetParentHWND (hWnd);
	SetCaption (TEXT ("CedeCrypt Diagnostics"));
	SetWindowStyle (FS_STYLESTANDARD);
	CreateAppWindow ("COMMDiagnosticsClass", 30, 30, 1000, 350, true);
	//m_uihandler.SetWindowProperties (0, 70, 40, 443, RGB (200, 200, 200));		
	//SetWindowPosition (FS_CENTER);
	ParseCommandLine (lpCmdLine);
	//Show ();
}
bool FullscreenToggle()
{
    keys[VK_F1]=FALSE;					// If So Make Key FALSE
    CloseWindow();						// Kill Our Current Window
    gFullscreen=!gFullscreen;			// Toggle Fullscreen / Windowed Mode

    if (!CreateAppWindow(windowName,windowWidth,windowHeight,32,gFullscreen))
    {
        MessageBox(0,"Unable to toggle to full screen","Error", MB_OK);
        return 1;
    }

    return true;
}
Example #14
0
static void
ptysignaled(int signo)
{
	switch(signo) {
	case SIGINT:	/* interrupt*/
#if !ELKS
		/* this doesn't work, can anyone fix it?*/
		killpg(pid, SIGINT);
#endif
		return;
	case SIGCHLD:	/* child status change - child exit*/
		DestroyWindow(GetActiveWindow());
		CreateAppWindow();
		return;
	}
	fprintf(stderr, "Uncaught signal %d\n", signo);
}
//-----------------------------------------------------------------------------
// PreInit, PostShutdown
//-----------------------------------------------------------------------------
bool CMaterialSystemTestApp::PreInit( )
{
	if ( !BaseClass::PreInit() )
		return false;

	if ( !g_pFullFileSystem || !g_pMaterialSystem )
		return false;

	// Add paths...
	if ( !SetupSearchPaths() )
		return false;

	const char *pArg;
	int iWidth = 1024;
	int iHeight = 768;
	bool bWindowed = (CommandLine()->CheckParm( "-fullscreen" ) == NULL);
	if (CommandLine()->CheckParm( "-width", &pArg ))
	{
		iWidth = atoi( pArg );
	}
	if (CommandLine()->CheckParm( "-height", &pArg ))
	{
		iHeight = atoi( pArg );
	}

	if (!CreateAppWindow( "Press a Key To Continue", bWindowed, iWidth, iHeight ))
		return false;

	// Get the adapter from the command line....
	const char *pAdapterString;
	int nAdapter = 0;
	if ( CommandLine()->CheckParm( "-adapter", &pAdapterString ) )
	{
		nAdapter = atoi( pAdapterString );
	}

	int nAdapterFlags = 0;
	if ( AppUsesReadPixels() )
	{
		nAdapterFlags |= MATERIAL_INIT_ALLOCATE_FULLSCREEN_TEXTURE;
	}

	g_pMaterialSystem->SetAdapter( nAdapter, nAdapterFlags );

	return true;
}
Example #16
0
int WINAPI 
WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine,
	int nShowCmd)
{
	MSG 	msg;
	extern MWIMAGEHDR image_car8;

	RegisterAppClass();
	MwSetDesktopWallpaper(&image_car8);

	CreateAppWindow();

	/* type ESC to quit...*/
	while(GetMessage(&msg, NULL, 0, 0)) {
		TranslateMessage(&msg);
		DispatchMessage(&msg);
	}
	return 0;
}
Example #17
0
///=====================================================
/// 
///=====================================================
int __stdcall WinMain(HINSTANCE thisAppInstance, HINSTANCE /*hPrevInstance*/, LPSTR lpCmdLine, int nShowCmd){
	FATAL_ASSERT(s_theMemoryManager != nullptr);

	JobManager* jobManager = new JobManager();
	RECOVERABLE_ASSERT(jobManager != nullptr);
	if (jobManager != nullptr){
		jobManager->Startup(6); //main thread + cricket audio thread + 6 = 8
	}

	CommandList commands = ParseCommands(lpCmdLine);
	bool forceQuit = ProcessCommands(commands);
	if (forceQuit){
		if (jobManager != nullptr){
			jobManager->Shutdown();
			delete jobManager;
		}

		return 0;
	}


	HWND myWindowHandle = CreateAppWindow(thisAppInstance, nShowCmd);

	s_theApp = new TheApp();
	s_theApp->Startup((void*)myWindowHandle);
	s_theApp->Run();
	s_theApp->Shutdown();

	delete s_theApp;


	if (jobManager != nullptr){
		jobManager->Shutdown();
		delete jobManager;
	}

	s_theMemoryManager->PrintMemoryLeaks();

	return 0;
}
Example #18
0
int main(int argc, char** argv)
{

	int dw = GetScreenWidth();
	int dh = GetScreenHeight();

	vec3 icp = {0.0F, 4.0F, 8.0F};
	vec3 icl = {0.0F, 0.0F, 0.0F};
	vec3 icu = {0.0F, 1.0F, 0.0F};
	g_globalCam.SetCamera(icp, icl, icu);
	g_globalCam.SetPerspective(65.0F, dw / (float)dh, 0.1F, 1000.0F);



	// Query extension base //
	CreateAppWindow("Mooball", dw, dh, 32, false);
	initExtensions();
	InitKeys();

	srand(time(NULL));

	// Query Device capabilities //
	if(!ValidateDevice())
	{
		DestroyAppWindow();
		return 0;
	}
	g_pTexInterface = new CTextureInterface;
	g_pShaderInterface = new CShaderInterface;
	g_lightManager = new CLightManager;
	g_bMSAA = (quickINI::Instance()->getValueAsInt("msaa") > 0) && (g_pTexInterface->GetMaxMSAA() > 0);
	g_bVSYNC = quickINI::Instance()->getValueAsInt("vsync") > 0;

//	g_model.Load( "Media/Models/Pokeball.3ds" );
	CModelObject* pMdl = new COBJModel;
	std::string err = pMdl->LoadModel("sponza.obj", "Media/Models/");

	// Initialize CG Runtime and shaders //
	init_cg();

	// Turn vsync on //
	if( EXT_VSYNC && g_bVSYNC )
	{
        #ifdef WIN32
            wglSwapIntervalEXT(1);
        #else
            glXSwapIntervalSGI(1);
        #endif
	}

	// Create offscreen targets and depth configurations //
	init_render_targets();

	// Added 8/4/10 - Keeps Mooball from hogging
	// the input focus while it's minimized.
//	HWND windowHandle = GetFocus();

	while(running)
	{
		if(QueryQuitMsg())
			running = false;

		else
		{
			if(!g_bDebugMode)
			{
				UpdateScene();
				PollKeys();
				PollMouse();
			}
			RenderScene();
			FlipBuffers();
		}

	}

	// Fall through to destruction //
	DestroyAppWindow();

	delete g_lightManager;
	delete g_pTexInterface;
	delete g_pShaderInterface;

	return 0;
}
Example #19
0
HRESULT ID3DApplication::Create(    int iWidth,
                                    int iHeight,
                                    int iBPP,
                                    BOOL bWindowed,
                                    LPCTSTR strTitle,
                                    DWORD dwFlags)
{
    if (!CreateAppWindow(    iWidth,
                            iHeight,
                            bWindowed,
                            strTitle))
    {
        return E_FAIL;
    }

    // create the Direct3D
    m_pD3D = ::Direct3DCreate9(D3D_SDK_VERSION);
    if (!m_pD3D)
    {
        return E_FAIL;
    }

    bool aa = Config::getInstance()->getValueAsBool("antialias", false);
    D3DMULTISAMPLE_TYPE samples = D3DMULTISAMPLE_NONE;
    if (aa) {
        if( FAILED(m_pD3D->CheckDeviceMultiSampleType( D3DADAPTER_DEFAULT, 
					        D3DDEVTYPE_HAL , D3DFMT_R8G8B8, FALSE, 
                            samples, NULL ) ) )
                            return E_FAIL;

        switch (Config::getInstance()->getValueAsInt("antialias samples", 2))
        {
        case 2: samples = D3DMULTISAMPLE_2_SAMPLES; break;
        case 3: samples = D3DMULTISAMPLE_3_SAMPLES; break;
        case 4: samples = D3DMULTISAMPLE_4_SAMPLES; break;
        case 5: samples = D3DMULTISAMPLE_5_SAMPLES; break;
        case 6: samples = D3DMULTISAMPLE_6_SAMPLES; break;
        case 7: samples = D3DMULTISAMPLE_7_SAMPLES; break;
        case 8: samples = D3DMULTISAMPLE_8_SAMPLES; break;
        case 9: samples = D3DMULTISAMPLE_9_SAMPLES; break;
        case 10: samples = D3DMULTISAMPLE_10_SAMPLES; break;
        case 11: samples = D3DMULTISAMPLE_11_SAMPLES; break;
        case 12: samples = D3DMULTISAMPLE_12_SAMPLES; break;
        case 13: samples = D3DMULTISAMPLE_13_SAMPLES; break;
        case 14: samples = D3DMULTISAMPLE_14_SAMPLES; break;
        case 15: samples = D3DMULTISAMPLE_15_SAMPLES; break;
        case 16: samples = D3DMULTISAMPLE_16_SAMPLES; break;
        default:
            return E_FAIL;
        }
    }

    // initialise the present parameters
    HRESULT hres;
    m_Present.hDeviceWindow = GetWindow();

    // initialise automatic z-buffering
    m_Present.EnableAutoDepthStencil = TRUE;

    if (IsWindowed())
    {
        // init windowed mode present parameters
        m_Present.BackBufferWidth = GetWindowRect().right;
        m_Present.BackBufferHeight = GetWindowRect().bottom;
        m_Present.Windowed = TRUE;
        m_Present.BackBufferCount = 1;

        // antialias
        if (aa)
        {
            m_Present.SwapEffect      = D3DSWAPEFFECT_DISCARD;
            m_Present.MultiSampleType = samples;
        }
        else
        {
            m_Present.SwapEffect = D3DSWAPEFFECT_COPY;
        }

        // force z-buffer to 16 bit format, without stencil bits
        m_Present.AutoDepthStencilFormat = D3DFMT_D16;

        // get the desktop display mode
        D3DDISPLAYMODE dm;
        m_pD3D->GetAdapterDisplayMode(D3DADAPTER_DEFAULT, &dm);
        m_Present.BackBufferFormat = dm.Format;
    }
    else
    {
        // init fullscreen mode present parameters
        m_Present.BackBufferWidth = iWidth;
        m_Present.BackBufferHeight = iHeight;
//        m_Present.SwapEffect = D3DSWAPEFFECT_FLIP;
        m_Present.FullScreen_RefreshRateInHz = 0;

        // vsync
        if (Config::getInstance()->getValueAsBool("vsync", false))
        {
            m_Present.PresentationInterval = D3DPRESENT_INTERVAL_ONE;
        }
        else
        {
            m_Present.PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE;
        }

        // antialias
        if (aa)
        {
            m_Present.SwapEffect      = D3DSWAPEFFECT_DISCARD;
            m_Present.MultiSampleType = samples;
        }
        else
        {
            m_Present.SwapEffect = D3DSWAPEFFECT_FLIP;
        }

        switch (iBPP)
        {
        case 8:
            // forgetaboutit... not supported anymore
            return E_FAIL;
            break;

        case 16:
            m_Present.BackBufferFormat = D3DFMT_R5G6B5;
            m_Present.AutoDepthStencilFormat = D3DFMT_D16;
            break;

        case 24:
            // forgetaboutit... not supported anymore
            return E_FAIL;
            break;

        case 32:
            m_Present.BackBufferFormat = D3DFMT_X8R8G8B8;
            m_Present.AutoDepthStencilFormat = D3DFMT_D16;
            break;

        default:
            // unknown bits per pixel value
            return E_FAIL;
        }
    }


    // Create Direct3D device
    // use the fallback mechanism to select best possible
    // 3d device type
    hres = m_pD3D->CreateDevice(    D3DADAPTER_DEFAULT,
                                    D3DDEVTYPE_HAL,
                                    GetWindow(),
                                    D3DCREATE_HARDWARE_VERTEXPROCESSING,
                                    &m_Present,
                                    &m_pDevice);
    if (FAILED(hres))
    {
        hres = m_pD3D->CreateDevice(    D3DADAPTER_DEFAULT,
                                        D3DDEVTYPE_HAL,
                                        GetWindow(),
                                        D3DCREATE_SOFTWARE_VERTEXPROCESSING,
                                        &m_Present,
                                        &m_pDevice);
    }
    if (FAILED(hres))
    {
        hres = m_pD3D->CreateDevice(    D3DADAPTER_DEFAULT,
                                        D3DDEVTYPE_REF,
                                        GetWindow(),
                                        D3DCREATE_SOFTWARE_VERTEXPROCESSING,
                                        &m_Present,
                                        &m_pDevice);
    }
    if (FAILED(hres))
    {
        // failed to create any meaningful 3d device...
        Release();
        return hres;
    }



    SetDeviceDefaults();


    // init the text drawing system
    hres = D3DXCreateSprite(m_pDevice, &m_pSprite);
    if (FAILED(hres))
    {
        Release();
        return hres;
    }

    // init the font
    hres = SetTextFont(NULL);
    if (FAILED(hres))
    {
        Release();
        return hres;
    }



    // init the timer
    GetTimer().Create();

    // call the pure virtual OnCreate
    hres = OnCreate();
    if (FAILED(hres))
    {
        Release();
        return hres;
    }

    SetActive(TRUE);
    return S_OK;
}
//-----------------------------------------------------------------------------
// PreInit
//-----------------------------------------------------------------------------
bool CIHVTestApp::PreInit( void )
{
	CreateInterfaceFn factory = GetFactory();
	ConnectTier1Libraries( &factory, 1 );

	// Add paths...
	if ( !SetupSearchPaths( NULL, false, true ) )
	{
		Error( "Failed to setup search paths\n" );
		return false;
	}

	const char *pArgVal;
	if ( CommandLine()->CheckParm( "-bench" ) )
	{
		g_BenchMode = true;
	}
	
	if( !g_BenchMode && !CommandLine()->CheckParm( "-i" ) )
	{
		// Set some default parameters for running as a unittest
		g_BenchMode = true;
		g_WindowMode = IsPC() ? true : false;
	}

	if( g_BenchMode )
	{
		if ( CommandLine()->CheckParm( "-i", &pArgVal ) )
		{
			g_BenchRuns[0].pModelName[0] = pArgVal;
		}
	}
	
	if( CommandLine()->CheckParm( "-softwaretl" ) )
	{
		g_SoftwareTL = true;
	}

	// Explicitly in window/fullscreen mode?
	if ( CommandLine()->CheckParm( "-window") )
	{
		g_WindowMode = true;
	}
	else if ( CommandLine()->CheckParm( "-fullscreen" ) )
	{
		g_WindowMode = false;
	}

	/* figure out g_Renderwidth and g_RenderHeight */
	g_RenderWidth = -1;
	g_RenderHeight = -1;

	if( CommandLine()->CheckParm( "-width", &pArgVal ) )
	{
		g_RenderWidth = atoi( pArgVal );
	}
	if( CommandLine()->CheckParm( "-height", &pArgVal ) )
	{
		g_RenderHeight = atoi( pArgVal );
	}

	if( g_RenderWidth == -1 && g_RenderHeight == -1 )
	{
		g_RenderWidth = 640;
		g_RenderHeight = 480;
	}
	else if( g_RenderWidth != -1 && g_RenderHeight == -1 )
	{
		switch( g_RenderWidth )
		{
		case 320:
			g_RenderHeight = 240;
			break;
		case 512:
			g_RenderHeight = 384;
			break;
		case 640:
			g_RenderHeight = 480;
			break;
		case 800:
			g_RenderHeight = 600;
			break;
		case 1024:
			g_RenderHeight = 768;
			break;
		case 1280:
			g_RenderHeight = 1024;
			break;
		case 1600:
			g_RenderHeight = 1200;
			break;
		default:
			DisplayError( "Can't figure out window dimensions!!" );
			exit( -1 );
			break;
		}
	}

	if( g_RenderWidth == -1 || g_RenderHeight == -1 )
	{
		DisplayError( "Can't figure out window dimensions!!" );
		exit( -1 );
	}
	
	int windowWidth, windowHeight;
	CalcWindowSize( g_RenderWidth, g_RenderHeight, &windowWidth, &windowHeight );

	if( !CreateAppWindow( "ihvtest1", windowWidth, windowHeight ) )
	{
		return false;
	}
	return true;
}
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd)
{
#if defined _DEBUG
    _CrtSetDbgFlag(_CRTDBG_LEAK_CHECK_DF | _CRTDBG_ALLOC_MEM_DF);
    _CrtSetReportMode(_CRT_ASSERT, _CRTDBG_MODE_FILE);
    _CrtSetReportFile(_CRT_ASSERT, _CRTDBG_FILE_STDERR);
#endif

    MSG msg = {0};
    WNDCLASSEX wcl = {0};

    wcl.cbSize = sizeof(wcl);
    wcl.style = CS_OWNDC | CS_HREDRAW | CS_VREDRAW;
    wcl.lpfnWndProc = WindowProc;
    wcl.cbClsExtra = 0;
    wcl.cbWndExtra = 0;
    wcl.hInstance = g_hInstance = hInstance;
    wcl.hIcon = LoadIcon(0, IDI_APPLICATION);
    wcl.hCursor = LoadCursor(0, IDC_ARROW);
    wcl.hbrBackground = 0;
    wcl.lpszMenuName = 0;
    wcl.lpszClassName = "GL2WindowClass";
    wcl.hIconSm = 0;

    if (!RegisterClassEx(&wcl))
        return 0;

    g_hWnd = CreateAppWindow(wcl, APP_TITLE);

    if (g_hWnd)
    {
        SetProcessorAffinity();

        if (Init())
        {
            ShowWindow(g_hWnd, nShowCmd);
            UpdateWindow(g_hWnd);

            while (true)
            {
                while (PeekMessage(&msg, 0, 0, 0, PM_REMOVE))
                {
                    if (msg.message == WM_QUIT)
                        break;

                    TranslateMessage(&msg);
                    DispatchMessage(&msg);
                }

                if (msg.message == WM_QUIT)
                    break;

                if (g_hasFocus)
                {
                    UpdateFrame(GetElapsedTimeInSeconds());
                    RenderFrame();
                    SwapBuffers(g_hDC);
                }
                else
                {
                    WaitMessage();
                }
            }
        }

        Cleanup();
        UnregisterClass(wcl.lpszClassName, hInstance);
    }

    return static_cast<int>(msg.wParam);
}
Example #22
0
//---------------------------------------------------------------------------------------------------------------------
void 
CApplication::Initialize()
{
	CreateAppWindow(800, 600);
}