Пример #1
0
//--------------------------------------------------------------------------------------
// Initialization
//--------------------------------------------------------------------------------------
int RunDirectX( )
{
	DXUTMainLoop();

	DestroyApp();

	return DXUTGetExitCode();
}
Пример #2
0
void CALLBACK OnD3D11DestroyDevice(void* userContext)
{
    DestroyApp();
    DestroyScene();
    
    gDialogResourceManager.OnD3D11DestroyDevice();
    gD3DSettingsDlg.OnD3D11DestroyDevice();
    DXUTGetGlobalResourceCache().OnDestroyDevice();
    SAFE_DELETE(gTextHelper);
}
Пример #3
0
int main(int argc, char* argv[])
{
	memset(kKeyPool, false, sizeof(kKeyPool));

	//! Create App
	if(!(g_pApp = CreateApp()))
		return 1;

	glutInit(&argc, argv);
	glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE);
	glutInitWindowSize(width, height);
	char title[32];
	sprintf(title, "TestBed2D");
	mainWindow = glutCreateWindow(title);

	//! Init App
	if(!g_pApp->Init(argc, argv))
	{
		DestroyApp();
		return 1;
	}

	glutDisplayFunc(LogicLoop);
	GLUI_Master.set_glutReshapeFunc(Resize);
	GLUI_Master.set_glutKeyboardFunc(Keyboard);
	GLUI_Master.set_glutKeyboardUpFunc(KeyboardUp);
	GLUI_Master.set_glutSpecialFunc(KeyboardSpecial);
	GLUI_Master.set_glutSpecialUpFunc(KeyboardSpecialUp);
	GLUI_Master.set_glutMouseFunc(Mouse);
#ifdef FREEGLUT
	glutMouseWheelFunc(MouseWheel);
#endif
	glutMotionFunc(MouseMotion);

	//! ÃüÁîÐÐstart
	glui = GLUI_Master.create_glui_subwindow( mainWindow, GLUI_SUBWINDOW_BOTTOM );
	pkCmd = new GLUI_CommandLine(glui, "Cmd", NULL, 1, CmdLineCallBack);
	pkCmd->set_w(300);
	//! ÃüÁîÐÐend

	// Use a timer to control the frame rate.
	glutTimerFunc(timerPeriod, Timer, 0);
	lastTime = GetTickCount();

	glutMainLoop();

	return 0;
}
Пример #4
0
void InitApp(ID3D11Device* d3dDevice)
{
	//#MSH if an app exists, destroy it
    DestroyApp();
    
    // Get current UI settings
    unsigned int msaaSamples = PtrToUint(gMSAACombo->GetSelectedData());
    gApp = new App(d3dDevice, 1 << gLightsSlider->GetValue(), msaaSamples);

    // Initialize with the current surface description
    gApp->OnD3D11ResizedSwapChain(d3dDevice, DXUTGetDXGIBackBufferSurfaceDesc());

    // Zero out the elapsed time for the next frame
    gZeroNextFrameTime = true;


}
Пример #5
0
void Keyboard(unsigned char key, int x, int y)
{
	if(!g_pApp)
		return;

	int iKeyVal(0);

	if(key>='0' && key<='9')
		iKeyVal = key-'0'+KV_0;
	else if(key>='a' && key<='z')
		iKeyVal = key-'a'+KV_a;
	else if(key>='A' && key<='Z')
		iKeyVal = key-'A'+KV_A;
	else if(key == 27)//! ESC
		iKeyVal = KV_ESC;
	else
		return;

	bool bRep = kKeyPool[iKeyVal];
	kKeyPool[iKeyVal] = true;

	g_pApp->OnKeyDown(iKeyVal, bRep);

	if(iKeyVal == KV_ESC)
	{
		DestroyApp();
		if(pkCmd)
		{
			delete pkCmd;
			pkCmd = NULL;
		}
		if(glui)
		{
			delete glui;
			glui = NULL;
		}
		exit(0);
		return;
	}
}
Пример #6
0
void CALLBACK OnGUIEvent(UINT eventID, INT controlID, CDXUTControl* control, void* userContext)
{
    switch (controlID) {
        case UI_TOGGLEFULLSCREEN:
            DXUTToggleFullScreen(); break;
        case UI_TOGGLEWARP:
            DXUTToggleWARP(); break;
        case UI_CHANGEDEVICE:
            gD3DSettingsDlg.SetActive(!gD3DSettingsDlg.IsActive()); break;
        case UI_LIGHTINGONLY:
            gUIConstants.lightingOnly = dynamic_cast<CDXUTCheckBox*>(control)->GetChecked(); break;
        case UI_FACENORMALS:
            gUIConstants.faceNormals = dynamic_cast<CDXUTCheckBox*>(control)->GetChecked(); break;        
        case UI_VISUALIZELIGHTCOUNT:
            gUIConstants.visualizeLightCount = dynamic_cast<CDXUTCheckBox*>(control)->GetChecked(); break;            
        case UI_VISUALIZEPERSAMPLESHADING:
            gUIConstants.visualizePerSampleShading = dynamic_cast<CDXUTCheckBox*>(control)->GetChecked(); break;            
        case UI_SELECTEDSCENE:
            DestroyScene(); break;
        case UI_LIGHTS:
            gApp->SetActiveLights(DXUTGetD3D11Device(), 1 << gLightsSlider->GetValue()); break;
        case UI_CULLTECHNIQUE:
            gUIConstants.lightCullTechnique = static_cast<unsigned int>(PtrToUlong(gCullTechniqueCombo->GetSelectedData())); break;

        // These controls all imply changing parameters to the App constructor
        // (i.e. recreating resources and such), so we'll just clean up the app here and let it be
        // lazily recreated next render.
        case UI_MSAA:
            DestroyApp(); break;

        default:
            break;
    }

    UpdateUIState();
}