Esempio n. 1
0
int Game::start(void(*buildFunc)(), void(*destructFunc)())
{
	if (game == nullptr)
		return EXIT_FAILURE;

	this->destructFunc = destructFunc;

	if (!InitMainWindow())
	{
		delete game;
		return EXIT_FAILURE;
	}

	if (!InitDirect3D())
	{
		delete game;
		return EXIT_FAILURE;
	}

	deviceContext->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST);
	initEngine();

	buildFunc();

	NetworkManager::networkManager->Initialize(2);
	NetworkManager::networkManager->AssignTask([]() { NetworkManager::networkManager->startClient(); });

	MSG msg = { 0 };

	while (msg.message != WM_QUIT)
	{
		// Peek at the next message (and remove it from the queue)
		if (PeekMessage(&msg, 0, 0, 0, PM_REMOVE))
		{
			// Handle this message
			TranslateMessage(&msg);
			DispatchMessage(&msg);
		}
		else if (!minimized) // No message to handle
		{
			if (Input::wasControlPressed("quit"))
				PostQuitMessage(0);

			// Update the timer for this frame
			UpdateTimer();

			// Standard game loop type stuff
			CalculateFrameStats();
			update(deltaTime, totalTime);

			draw();// (deltaTime, totalTime);
			Input::updateControlStates();
		}
	}

	delete game;
	
	return (int)msg.wParam;
}
/* Handles initialization for each executing instance of the OWL
   application.  Creates and displays the main window. */
void TApplication::InitInstance()
{
  InitMainWindow();
  MainWindow = MakeWindow(MainWindow);
  if ( MainWindow )
    MainWindow->Show(nCmdShow);
  else
    Status = EM_INVALIDMAINWINDOW;
}
Esempio n. 3
0
/**
 * This method is used to launch the animation
 */
int launch (ClientData clientData, Tcl_Interp *interp, int argc, CONST84 char **argv){
    if (argc < 2) {
        tprintf("Usage: launch Simbicon3D | mocap");
        return TCL_OK;
    }
	InitMainWindow(argc, argv);

    return TCL_OK;
}
Esempio n. 4
0
bool DemoBase::Init()
{
	if(!InitMainWindow())
		return false;

	if(!InitDirect3D())
		return false;

	return true;
}
Esempio n. 5
0
bool D3DApp::Init()
{
	if(!InitMainWindow())
		return false;

	if(!InitDirect3D())
		return false;

	return true;
}
ULONG Init(VOID)
#endif
{
    /* Add ExitProc to the exit list to handle the exit processing.  If
     * there is an error, then terminate the process since there have
     * not been any resources allocated yet
     */
   if (DosExitList(EXLST_ADD, (PFNEXITLIST)ExitProc))
   {
       MessageBox(HWND_DESKTOP,
                  IDMSG_CANNOTLOADEXITLIST, 0,
                  MB_OK | MB_ERROR,
                  TRUE);
       DosExit(EXIT_PROCESS, RETURN_ERROR);
   }

   /* load application name from resource file */
   if(0==WinLoadString(vhab, (HMODULE)NULL, IDS_APPNAME, CCHAPPNAME, szAppName))
       return IDMSG_CANNOTLOADSTRING;

   /* register the main client window class */
   if (!WinRegisterClass(vhab,
                szAppName,
                (PFNWP)MainWndProc,
                0L,
                0))
       return IDMSG_INITFAILED;

   /*
    * create main application window & detach scrollbars
    */
   if (!InitMainWindow())
       return IDMSG_MAINWINCREATEFAILED;

   /*
    * set up globals used for sizing & system pointers
    */
   if (!InitGlobalVars())
      return IDMSG_INITFAILED;

   /*
    * this function prepares the application for loading images
    */
   InitClientArea(vhwndClient);

   /*
    * initialize help mechanism
    */
#ifdef HELP_MANAGER_ENABLED
   HelpInit();
#endif

   return NO_ERROR;
}  /* End of Init */
Esempio n. 7
0
bool CD3DApplication::Init()
{
	if(!InitMainWindow()) {
		return false;
	}

	if(!InitDirect3D()) {
		return false;
	}

	return true;
}
Esempio n. 8
0
bool D3D11App::Init()
{
	if (!InitMainWindow())
		return false;

	if (!InitDirect3D())
		return false;
	InitResource();
	float AspectHByW = (float)mClientWidth / (float)mClientHeight;
	g_objTrackballCameraController.ProjParams(DirectX::XM_PI*0.25f, AspectHByW, 1.0f, 1000.0f);
	mTimer.Start();
	return true;
}
Esempio n. 9
0
bool D3DApp::Init()
{
	if (!InitMainWindow())
	{
		return FALSE;
	}

	if (!InitDirect3D())
	{
		return FALSE;
	}
	return TRUE;
}
Esempio n. 10
0
// --------------------------------------------------------
// Handles the window and Direct3D initialization
// --------------------------------------------------------
bool DirectXGameCore::Init()
{
	// Create the actual window itself (no DirectX yet)
	if(!InitMainWindow())
		return false;

	// Now that the window is ready, initialize
	// DirectX (specifically Direct3D)
	if(!InitDirect3D())
		return false;

	// Everything was set up properly
	return true;
}
Esempio n. 11
0
bool DX::Initialize(int icon)
{
	ZeroMemory(&viewport, sizeof(D3D11_VIEWPORT));

	if (!InitMainWindow(icon))
		return false;

	if (!InitDirect3D())
		return false;

	ResourceManager::Initialize(device, deviceContext);

	return true;
}
Esempio n. 12
0
D3dApp::D3dApp(HINSTANCE hInstance,const tstring& winCaption, D3DDEVTYPE devType, DWORD requestedVp):m_MainWndCaption(winCaption),
																								m_DevType(devType),
																								m_RequestedVp(requestedVp),
																								m_hAppInst(hInstance),
																								m_hMainWnd(NULL),
																								m_pD3dObject(NULL),
																								m_AppPaused(false),
																								m_pMyD3dDevice(NULL)
{
	ZeroMemory(&m_D3dParams, sizeof(m_D3dParams));

	InitMainWindow();
	InitDirect3D();
}
Esempio n. 13
0
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow),
    strPathQssFile(":/QSS/QSS/StyleSheet.qss"),
    clrBKApp(QColor(205,215,230))
{
    ui->setupUi(this);

    CreateActions();
    CreateMenus();
    ui->mainToolBar->hide();
    InitMainWindow();
    InitStatusBar();

    BeautifyUI();
}
Esempio n. 14
0
LRESULT CALLBACK HookMsgProc(int nCode, WPARAM wParam, LPARAM lParam) {
	const CWPSTRUCT* p = (const CWPSTRUCT*)lParam;
	if ((nCode >= 0) && (nCode == HC_ACTION)) {
		if (g_hWndVDub == 0)
			InitMainWindow(p->hwnd);

		if (g_bInitWindow && !g_hMenuAuo)
			InitMenu();

		if (g_bInitOutput && g_bOutput && g_bStartServer) {
			g_bOutput = false;
			g_hWorkThread = (HANDLE)_beginthreadex(NULL, 0, OutputThread, NULL, 0, NULL);
		}
	}
	return CallNextHookEx(g_hHook, nCode, wParam, lParam);
}
bool D3DApp::Init()
{

	if(!InitMainWindow())
		return false;

	if (!InitGraphicsCard())
	{
		OutputDebugString(L"fAILED TO FIND MONITOR / GRAPHICS CARD"); return false;
		return false;
	}
		

	if(!InitDirect3D())
		return false;

	return true;
}
Esempio n. 16
0
//================================================================
// Initialize application
//================================================================
bool D3D11App::Initialize()
{
	// Have to create Direct3D object before initializing
	// window, basically to initialize d3dDevice to 0
	mDirect3D = new Direct3D();

	if (!mDirect3D)
		return false;

	SettingsData lSettings = *Settings->GetData();
	mcWidth = (int)lSettings.mWidth;
	mcHeight = (int)lSettings.mHeight;
	mIsFullscreen = lSettings.mIsFullscreen;

	//-------------------------------------------
	// Init Win32 window
	//-------------------------------------------
	if (!InitMainWindow())
		return false;

	//-------------------------------------------
	// Init Direct3D
	//-------------------------------------------
	if (!mDirect3D->Initialize(&mhMainWnd))
		return false;

	//-------------------------------------------
	// Init Direct Input
	//-------------------------------------------

	mDirectInput = new DirectInput();
	if(!mDirectInput)
		return false;

	if(!mDirectInput->Initialize(&mhAppInst, &mhMainWnd, &mcWidth, &mcHeight))
		return false;

	return true;
}
Esempio n. 17
0
void D3DApp::Init()
{
	srand((unsigned int)time(0));

	//standard input/ output/ error file pointers
	FILE *fpStdIn, *fpStdOut, *fpStdErr;

	// Enable run-time memory check for debug build
#if defined(DEBUG) | defined(_DEBUG)
	_CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF);

	if (AllocConsole())
	{
		//Assign the stdin/ stdout/ stderr streams to the newly created console
		_tfreopen_s(&fpStdIn, _T("CONIN$"), _T("r"), stdin);
		_tfreopen_s(&fpStdOut, _T("CONOUT$"), _T("w"), stdout);
		_tfreopen_s(&fpStdErr, _T("CONOUT$"), _T("w"), stderr);
	}
#endif

	InitMainWindow();
	InitDirect3D();

	gDInput = new DirectInput(
		mhAppInstance, mhMainWindow,
		DISCL_NONEXCLUSIVE | DISCL_FOREGROUND,
		DISCL_NONEXCLUSIVE | DISCL_FOREGROUND);

	gTimer = new GameTimer();
	gTimer->Reset();

	HR(gD3DDevice->SetRenderState(D3DRS_LIGHTING, false));
	HR(gD3DDevice->SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE));
	//HR(gD3DDevice->SetRenderState(D3DRS_FILLMODE, D3DFILL_WIREFRAME));

}
/****************************************************************\
 *  Main client window procedure
 *--------------------------------------------------------------
 *
 *  Name:   MainWndProc(hwnd, msg, mp1, mp2)
 *
 *  Purpose: Processes the messages sent to the main client
 *              window.  This routine processes the basic
 *              messages all client windows should process
 *              and passes all others onto WinDefWindowProc.
 *
 *  Usage:  Called for each message placed in the main
 *          window's message queue
 *
 *  Method: a switch statement branches to the routines to be
 *          performed for each message processed.
 *
 *  Returns:  Return values are determined by each message
 *
\****************************************************************/
MRESULT EXPENTRY MainWndProc(HWND   hwnd,    /* handle of window */
                             ULONG  msg,     /* id of message */
                             MPARAM mp1,     /* first message parameter */
                             MPARAM mp2)     /* second message parameter */
{
   QDATA   *pqdataQ;

   switch(msg)
   {
      case WM_CREATE:
         return InitMainWindow(hwnd, mp1, mp2);
         break;

      case WM_PAINT:
         MainPaint(hwnd, SvrQMsgs, iIndex, sTotalMsgs);
         break;

      case WM_SIZE:
         MainSize(hwnd, sTotalMsgs, mp1, mp2);
         break;

      case WM_HSCROLL:
         MainHorizScroll(hwnd, mp2);
         break;

      case WM_VSCROLL:
         MainVertScroll(hwnd, mp2);
         break;

      case WM_CHAR:
         switch (SHORT2FROMMP(mp2))
         {
            case VK_LEFT:
            case VK_RIGHT:
               return MainCharHScroll (hwnd, msg, mp1, mp2) ;
            case VK_UP:
            case VK_DOWN:
            case VK_PAGEUP:
            case VK_PAGEDOWN:
               return MainCharVScroll (hwnd, msg, mp1, mp2) ;
         }
         break ;

      case WM_COMMAND:
         MainCommand(mp1, mp2);
         break;

      case HM_QUERY_KEYS_HELP:
         return (MRESULT)PANEL_HELPKEYS;   /* return id of key help panel */
         break ;

      case WM_NEWQMSG:
         /* copy message into circular array, with index being next free spot in array */
         pqdataQ = (QDATA *)PVOIDFROMMP(mp1);
         sprintf(SvrQMsgs[iIndex],
                 "Process ID: %03lu, Priority: %02hu,  Message: %s",
                 pqdataQ->pidProcess,
                 pqdataQ->usPriority,
                 pqdataQ->pszMsg);

         /* increment index, or reset to 0 as appropriate */
         iIndex = (iIndex < MAX_MESSAGES - 1) ? iIndex + 1 : 0;

         /* increment total message count until buffer is filled */
         sTotalMsgs = min(MAX_MESSAGES, sTotalMsgs + 1);

         MainUpdateMsg(hwnd, SvrQMsgs, iIndex, sTotalMsgs);
         break;

      case WM_MSG:
         MessageBox(hwndMain, (ULONG)SHORT1FROMMP(mp1), MB_OK | MB_ICONEXCLAMATION | MB_APPLMODAL, TRUE);
         break;

      case WM_CLOSE:
         DosWriteQueue(hqQ, WM_CLOSE, 0UL, NULL, 15UL);

         /* process the WM_CLOSE */

   /*--------------------------------------------------*\
    *      Any messages not processed are passed on
    *      to WinDefWindowProc.
   \*--------------------------------------------------*/

      default:
         return WinDefWindowProc(hwnd, msg, mp1, mp2);
         break;
   }

   return MRFROMLONG(0L);     /* all window procedures should return 0 as a default */

}   /* MainWndProc() */
Esempio n. 19
0
void D3DApplication::InitApplication()
{
	InitMainWindow();
	InitDirect3D();
}
Esempio n. 20
0
int	main(     int     argc,
		  char    *argv[])
{
	
    MrmInitialize();
	
	appshell = XtAppInitialize(&appContext,"GreatSPN_Motif",NULL,0,&argc,argv,fallback,NULL,0);
#ifdef Linux
   /* Enables the application to talk with editres.
      For debug purposes only */
/*   XmdRegisterEditres(appshell);*/
#endif
	OpenHierarchy();

  	if (MrmRegisterNames (regvec, regnum)
			!= MrmSUCCESS)
			    XtError("can't register names\n");	
	RegisterArcChangeDialog();
	RegisterColorChangeDialog();
	RegisterPlaceChangeDialog();
	RegisterTransChangeDialog();
	RegisterShowDialog();
	RegisterResultDialog();
	RegisterRateDialog();
	RegisterPrintDialog();
	RegisterMDGrammarDialog();
	RegisterMarkDialog();
	RegisterViewLayerDialog();
	RegisterEditLayerDialog();
	RegisterConsoleDialog();
	RegisterCommentDialog();
	RegisterZooomMenuCallbacks();
	RegisterMenuCallbacks();
	RegisterRescale();
	RegisterGrid();
	RegisterMenuValues();
	RegisterOptionsDialog();
	RegisterSimulationDialog();
	RegisterSwnSimOptionsDialog();
	RegisterSwnRGOptionsDialog();
	RegisterSwnUnfoldOptionsDialog();
	
/*    puts(" ...  start FetchWidget"); fflush(stdout);*/
	mainwin = FetchWidget(appshell,"MainWin");
	
/*    puts(" ...  start InitMainWindow"); fflush(stdout);*/
    InitMainWindow();
/*    puts(" ...  start InitWorkWindow"); fflush(stdout);*/
    InitWorkWindow();
/*    puts(" ...  start InitFonts"); fflush(stdout);*/
    InitFonts();
/*    puts(" ...  start InitMenuBar"); fflush(stdout);*/
    InitMenuBar();
/*    puts(" ...  start InitPopups"); fflush(stdout);*/
    InitPopups();
			
/*    puts(" ...  start XtManageChild"); fflush(stdout);*/
	XtManageChild( mainwin );
/*    puts(" ...  start XtRealizeWidget"); fflush(stdout);*/
    XtRealizeWidget( appshell );
/*    puts(" ...  start InitFilesPath"); fflush(stdout);*/
	InitFilesPath();
/*    puts(" ...  start InitGSPNShellErrors"); fflush(stdout);*/
	InitGSPNShellErrors();
/*    puts(" ...  start gdiInitEngine"); fflush(stdout);*/
	gdiInitEngine(appshell);
/*    puts(" ...  start gdiInitDrawingAreaGC"); fflush(stdout);*/
    gdiInitDrawingAreaGC();
/*    puts(" ...  start InitOther"); fflush(stdout);*/
	InitOther();  
/*
    InitMsgDB();
*/
/*    puts(" ...  start XmUpdateDisplay"); fflush(stdout);*/
    XmUpdateDisplay(mainwin);
/*    puts(" ...  start XtAppMainLoop"); fflush(stdout);*/
    XtAppMainLoop(appContext);

    return 0;
}