示例#1
0
int WINAPI WinMain(HINSTANCE instance, HINSTANCE prevInstance, LPSTR commandLine, int showCommand)
{
    WNDCLASS wndClass = {0};
    MSG msg;

    /* Register window class */
    wndClass.hInstance = instance;
    wndClass.hbrBackground = CreateSolidBrush(RGB(0, 0, 0));
    wndClass.lpszClassName = ClassName;
    wndClass.lpfnWndProc = WndProc;
    if (!RegisterClass(&wndClass))
        exit(1);

    /* Create window */
    g_hwnd = CreateWindow(ClassName, Title, WS_POPUP, 0, 0, 160 * ViewScale, 100 * ViewScale, 0, 0, instance, 0);
    if (!g_hwnd)
        exit(2);

    ShowWindow(g_hwnd, showCommand);
    UpdateWindow(g_hwnd);

    /* Initialize Graphics */
    InitializeGraphics(g_hwnd);
    InitializeGame();

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

            TranslateMessage(&msg);
            DispatchMessage(&msg);
        }
        else
        {
            TickGame();
            Present();
        }
    }

    DestroyGraphics();

    return 0;
}
示例#2
0
	void GameMode::Initialize(const std::shared_ptr<FG::Window>& window)
	{
		Mode::Initialize(window);

		mMap.reset(new Map);
		mMap->Initialize();
		currentTime = std::chrono::system_clock::now();
		mSelectedUnit = nullptr;

		mKeyboard.reset(new FG::KeyboardInput);
		mMouse.reset(new FG::MouseInput);

		window->RegisterInput(mKeyboard.get());
		window->RegisterInput(mMouse.get());
		mMouse->SetScreenSize(window->GetScreenWidth(), window->GetScreenHeight());

		InitializeGraphics();
	}
示例#3
0
bool GameController::Initialize(ISystemUtils *systemUtils)
{
	Log::StartLog(true, false, false);

	m_systemUtils = systemUtils;

	srand(time(NULL));

	Player *player = new Player(TaxiGame::Environment::GetInstance()->GetWritePath() + "player.xml");
	player->Load();

	std::string basePath = TaxiGame::Environment::GetInstance()->GetBasePath();

	SoundManager::GetInstance()->Initialize(basePath + "data/audio/");
	SoundManager::GetInstance()->PlayMusic();

	if (!InitializeGraphics(basePath))
	{
		assert(false);
		return false;
	}

	m_gameScreen = new GameScreen(this);
	if (!m_gameScreen->Initialize())
		return false;

	m_splashScreen = new SplashScreen(this);
	if (!m_splashScreen->InitResources())
		return false;

	m_mainMenuScreen = new MainMenuScreen(this);
	if (!m_mainMenuScreen->InitResources())
		return false;

	m_summaryScreen = new SummaryScreen(this);
	if (!m_summaryScreen->InitResources())
		return false;

	m_activeScreen = m_splashScreen;

	return true;
}
示例#4
0
//FSX has finished drawing to given device... add any overlays on that device 
void CFSXGUI::OnFSXPresent(IDirect3DDevice9 *pI)
{
	
	if (!m_bRunning)
		return;
		
	if (!m_bGraphicsInitialized)
		InitializeGraphics(pI);

	//See if we've switched from windowed to full-screen, or back
	if (!m_bCheckForNewDevices)
	{
		if (m_bInWindowedMode)
		{
			if (pI != m_WindowedDeviceDesc.pDevice)
			{
				m_bCheckForNewDevices = true;
				m_CheckNewDevicesEndTime = GetTickCount64() + CHECK_NEW_DEVICES_INTERVAL_MS;
			}
		}
		//Fullscreen mode, check if one of the known fullscreen devices 
		else
		{
			bool bFound = false;
			for (size_t i = 0; !bFound && i < m_aFullscreenDevices.size(); i++)
				if (m_aFullscreenDevices[i].pDevice == pI)
					bFound = true;
			if (!bFound)
			{
				m_bCheckForNewDevices = true;
				m_CheckNewDevicesEndTime = GetTickCount64() + CHECK_NEW_DEVICES_INTERVAL_MS;
			}
		}
	}
	
	//Continue scan for new devices
	if (m_bCheckForNewDevices)
	{
		if (GetTickCount64() < m_CheckNewDevicesEndTime)
			CheckIfNewDevice(pI);
		else
			m_bCheckForNewDevices = false;
	}



	if (pI != m_WindowedDeviceDesc.pDevice && pI != m_pFullscreenPrimaryDevice)
		CheckIfNewDevice(pI);



	//If windowed, or fullscreen primary device, tell each open dialog to draw
	if ((m_bInWindowedMode && pI == m_WindowedDeviceDesc.pDevice) ||
		(!m_bInWindowedMode && pI == m_pFullscreenPrimaryDevice))
	{
		for (size_t i = 0; i < m_apOpenDialogs.size(); i++)
			m_apDialogs[i]->Draw(pI);
	}

	return;
}
示例#5
0
文件: qplot.c 项目: WndSks/msys
int
main(int argc, char **argv)
{
    char           *file = NULL;
    int             Do_Start = 1, tmp;
    int             m, p, i, j, n, nchars, theight, twidth, xclick, yclick;
    int             downx = 1000, downy = 1000, upx, upy;
    long            id, winclick;
    Real            xmax, xmin, ymax, ymin, xdiff, ydiff, xgrid_spacing,
		    ygrid_spacing;
    Real           *x, *y, *nls;
    LineFunction    linetype = StartLine;
    char            axis[100], line[256];
    FILE           *fd;

    x = (Real *)malloc(1000000 * sizeof(Real));
    y = (Real *)malloc(1000000 * sizeof(Real));
    nls = (Real *)malloc(1000 * sizeof(Real));
    if (x == NULL || y == NULL || nls == NULL) {
	fprintf(stderr, "Can't allocate initial memory\n");
	exit(1);
    }

    ymax = xmax = -HUGE_VAL;
    ymin = xmin = HUGE_VAL;

    for (i = 1; i < argc; i++) {
	if (*argv[i] == '-') {
	    if (!strcmp(argv[i], "-nl"))
		linetype = StartPoint;
	    else if (argv[i][1] == '\0')	/* use stdin */
		file = argv[i];
	    else {

		fprintf(stderr, "Usage:\n\t %s [options] [file]\n\n", argv[0]);
		fprintf(stderr,
			"where options include:\n"
			"  -pt                   plot with points instead of lines\n\n");

		fprintf(stderr,
			"file name `-' specifies stdin\n"
			"if no file name is specified, "
			"the default is \"%s\"\n\n", DEFAULT_DATA_FILE);

		return EXIT_FAILURE;
	    }
	} else
	    file = argv[i];
    }

    if (file && !strcmp(file, "-")) {
	fd = stdin;
	file = "stdin";
    } else {
	if (file == NULL)
	    file = DEFAULT_DATA_FILE;

	if ((fd = fopen(file, "r")) == NULL) {
	    fprintf(stderr, "%s: can't open file \"%s\"\n", argv[0], file);
	    return EXIT_FAILURE;
	}
    }
    m = 0;
    p = 0;
    while (fgets(line, sizeof(line), fd) != NULL) {
	if (sscanf(line, "%f %f", &x[m], &y[m]) == 2) {
	    if (x[m] > xmax)
		xmax = x[m];
	    else if (x[m] < xmin)
		xmin = x[m];
	    if (y[m] > ymax)
		ymax = y[m];
	    else if (y[m] < ymin)
		ymin = y[m];
	    m++;
	} else {
	    nls[p] = m;
	    p++;
	}
    }
    nls[p++] = m;

    if (m == 0)
	return;

    signal(SIGTERM, nice_end);
    signal(SIGSTOP, nice_end);
    signal(SIGTSTP, nice_end);
    signal(SIGINT, nice_end);
    signal(SIGQUIT, nice_end);
    if (!InitializeGraphics(1))
	return EXIT_FAILURE;

    n = 1;
    do {
	axis_round(&xmin, &xmax, &xgrid_spacing);
	axis_round(&ymin, &ymax, &ygrid_spacing);

	id = CreateWin(0, 0, GRX_SCALE, GRX_SCALE);
	if (id == 0) {
	    fprintf(stderr, "Help id = 0\n");
	    return EXIT_FAILURE;
	}
	/* Fill the window in black for real eye-catching graphics! */
	ForeColor(0);
	StartFill(id);
	FillArea(0, 0, GRX_SCALE, GRX_SCALE);
	Done();

	/* draw outline box in white */
	ForeColor(7);

	/* Draw outline box */
	StartLine(id);
	Extend(1000, 1000);
	Extend(1000, 9000);
	Extend(9000, 9000);
	Extend(9000, 1000);
	Extend(1000, 1000);
	Done();

	/* Draw the data - either lines or dots */
	xdiff = 8000 / (xmax - xmin);
	ydiff = 8000 / (ymax - ymin);

	for (i = j = 0; j < p; j++) {
	    int             n = 0;

	    ForeColor(j % 6 + 1);
	    while (((x[i] < xmin) || (x[i] > xmax) ||
		    (y[i] < ymin) || (y[i] > ymax)) && (i < nls[j]))
		i++;

	    while (i < nls[j]) {
		if (n == 0)
		    linetype(id);
		Extend(1000 + (x[i] - xmin) * xdiff,
		       9000 - (y[i] - ymin) * ydiff);
		n++;
		if (n > 450) {
		    Done();
		    n = 0;
		    continue;
		}
		i++;
		while ((i < nls[j]) &&
		       ((x[i] < xmin) || (x[i] > xmax) ||
			(y[i] < ymin) || (y[i] > ymax)))
		    i++;
	    }
	    if (n > 0)
		Done();
	}

	/* Do axis labels in black */
	ForeColor(7);
	QueryWin(id, &twidth, &theight);
	PlaceText(id, GRX_SCALE / 2, 0, HCENTER_TEXT | TOP_TEXT, file);
	PlaceText(id, GRX_SCALE / 2, GRX_SCALE, HCENTER_TEXT | BOTTOM_TEXT,
		  "X");
	PlaceText(id, 0, GRX_SCALE / 2, LEFT_TEXT | VCENTER_TEXT, "Y");
	sprintf(axis, "%f", ymax);
	nchars = 1000 / twidth;
	axis[nchars] = 0;
	PlaceText(id, GRX_SCALE / 10, GRX_SCALE / 10,
		  RIGHT_TEXT | TOP_TEXT, axis);
	sprintf(axis, "%f", ymin);
	axis[nchars] = 0;
	PlaceText(id, GRX_SCALE / 10, 9 * GRX_SCALE / 10,
		  RIGHT_TEXT | BOTTOM_TEXT, axis);
	sprintf(axis, "%f", xmax);
	PlaceText(id, 9 * GRX_SCALE / 10, 9 * GRX_SCALE / 10,
		  HCENTER_TEXT | TOP_TEXT, axis);
	sprintf(axis, "%f", xmin);
	PlaceText(id, GRX_SCALE / 10, 9 * GRX_SCALE / 10,
		  HCENTER_TEXT | TOP_TEXT, axis);
	fflush(stdout);

	do {
	    n = WaitForCarriageReturn(&winclick, &xclick, &yclick);
	    switch (n) {
	    case 1:
		downx = xclick;
		downy = yclick;
		break;
	    case 2:
		upx = xclick;
		upy = yclick;
		if (upx < downx) {
		    tmp = downx;
		    downx = upx;
		    upx = tmp;
		}
		if (upy < downy) {
		    tmp = downy;
		    downy = upy;
		    upy = tmp;
		}
		xmin = (xmax - xmin) * (downx - 1000) / (8000) + xmin;
		xmax = (xmax - xmin) * (upx - 1000) / (8000) + xmin;
		ymax = ymax - (ymax - ymin) * (downy - 1000) / (8000);
		ymin = ymax - (ymax - ymin) * (upy - 1000) / (8000);
		break;
	    }
	} while (n && (n != 2));
    } while (n);
    nice_end(EXIT_SUCCESS);
    return EXIT_SUCCESS;
}
示例#6
0
文件: bounce.c 项目: klutt/hpc_ass2
int main(int argc, char *argv[]) 
{
	int i, N=2500;
	const float L=1,W=1,dt=1e-6;
	G=2.0/N;
	double *x,*y,*mass,*forceX,*forceY,*u,*v,ax,ay;
	const int frameskip=100;
	int frame=frameskip-1;
	const double initSpeedLimit=0.001;
	const float theta = 0.8;
	x = (double *)malloc(N*sizeof(double));
	y = (double *)malloc(N*sizeof(double));
	u = (double *)malloc(N*sizeof(double));
	v = (double *)malloc(N*sizeof(double));
	mass = (double *)malloc(N*sizeof(double));
	forceX = (double *)malloc(N*sizeof(double));
	forceY = (double *)malloc(N*sizeof(double));
	#ifndef DISTRIBUTION_AS_IN_ASSIGNMENT
  	for(i=0;i<N;i++) 
  	{
		x[i]=frand(0,1);
		y[i]=frand(.25,.75);
		relativePosition(&u[i], &v[i], 0, 0, x[i], y[i]);
		u[i]*=frand(-initSpeedLimit,initSpeedLimit);
		v[i]*=frand(-initSpeedLimit,initSpeedLimit);
		mass[i]=frand(1, 100);
		forceX[i]=0;
		forceY[i]=0;
  	}
  
	  x[0]=x[1]=0.5;
	  y[0]=0.45; y[1]=0.55;
	  v[0]=v[1]=0;
	  u[0]=-0.007;
	  u[1]=0.007;
	  mass[0]=mass[1]=1000;
	  #endif
	 #ifdef DISTRIBUTION_AS_IN_ASSIGNMENT

	const double alpha=0.25;
	const double V=20.0;
	for(i = 0; i<N; i++)
	  {
	    mass[i]=1;
	    double R=frand(0, L/4.0);
	    double fi=frand(0, 2*3.1415);
	    x[i]=L/2.0+R*cos(fi);
	    y[i]=W/2.0+alpha*R*sin(fi);
	    double Rprim = sqrt((x[i]-L/2.0)*(x[i]-L/2.0) + (y[i]-W/2.0)*(y[i]-W/2.0));
	    u[i] = -V*Rprim*sin(fi);
	    v[i] = V*Rprim*cos(fi);
	    forceX[i]=0;
	    forceY[i]=0;
	  }
	#endif
	
	  InitializeGraphics(argv[0],windowWidth,windowWidth);
	  SetCAxes(0,1);
	  Node *root;
	  printf("Hit q to quit.\n");
	  int iterations=0;
  	while(!CheckForQuit()) 
  	{
	  iterations++;
  		#ifndef BARNESHUT
  		for(i=0;i<N;i++) {
  		#endif
  		
  	
  		#ifdef BARNESHUT
		  //  		Bounce(&x[0],&y[0],&u[0],&v[0],L,W); 
  		root = createNode(0,x,y,mass);
		for(i=1;i<N;i++) {
		#endif
			if (x[i] > 2*L || x[i]< -1 || y[i] > 2*W || y[i] < -1)
			{
				printf("Things are going out of bounds");
				exit(-1);
			}
			//			Bounce(&x[i],&y[i],&u[i],&v[i],L,W); 
			#ifndef BARNESHUT
				calculateForce(&forceX[i], &forceY[i], i, x, y, mass, N);
			#endif
			#ifdef BARNESHUT
				insertParticle(root, x, y, mass, i);	
			#endif
		}
		#ifdef BARNESHUT
	  		for(i=0; i<N; i++)
				BarnesHut(root, x, y, mass, theta, i, &forceX[i], &forceY[i]);
		#endif
  		update(x,y,u,v,mass,forceX, forceY,dt, N);
		frame++;
		frame=frame%frameskip;
		if(frame==0) {
		  ClearScreen();  
		  for(i=0;i<N;i++)
		    DrawCircle(x[i],y[i],L,W,(1+log10(mass[i]))*circleRadius,circleColor);
		  Refresh();
		}
		freeNodes(root);
	}
	XFlush(display);
	XCloseDisplay(display);
	printf("Iterations: %d\n", iterations);
	return 0;
}

/*
 * Function: Bounce
 * Usage: Bounce(&x[i],&y[i],&u[i],&v[i],L,W);
 * -------------------------------------------
 * If a particle moves beyond any of the boundaries then set
 * it on the other side of the boundary back in the domain and
 * reverse the velocities.
 *
 */
void Bounce(double *x, double *y, double *u, double *v, double L, double W) {
  if(*x>L ) {
    *x=2*L-*x;
    *u=-*u;
  }

  if(*x<0 ) {
    *x=-*x;
    *u=-*u;
  }

  if(*y>W ) {
    *y=2*W-*y;
    *v=-*v;
  }

  if(*y<0 ) {
    *y=-*y;
    *v=-*v;
  }
}
示例#7
0
文件: Main.cpp 项目: m1h4/Xetrix
bool InitializeWindow(ULONG width,ULONG height)
{
	PIXELFORMATDESCRIPTOR pfd =
	{
		sizeof(PIXELFORMATDESCRIPTOR),
		1,
		PFD_DRAW_TO_WINDOW|PFD_SUPPORT_OPENGL|PFD_DOUBLEBUFFER,
		PFD_TYPE_RGBA,
		32,	// Color Buffer Size
		0,0,0,0,0,0,
		0,
		0,
		0,
		0,0,0,0,
		24,	// Depth Buffer Size
		0,
		0,
		PFD_MAIN_PLANE,
		0,
		0,0,0
	};

	UINT		pixelFormat;
	WNDCLASS	wc = {0};
	DWORD		dwExStyle = 0;
	DWORD		dwStyle = WS_POPUP|WS_CAPTION|WS_SYSMENU|WS_MINIMIZEBOX|WS_SIZEBOX|WS_MAXIMIZEBOX;
	RECT		windowRect = {0,0,width,height};

	wc.style			= CS_CLASSDC;
	wc.lpfnWndProc		= WinProcedure;
	wc.hInstance		= GetModuleHandle(NULL);
	wc.hIcon			= LoadIcon(NULL,IDI_WINLOGO);
	wc.hCursor			= LoadCursor(NULL,IDC_ARROW);
	wc.lpszClassName	= mainClassName;

	if(!RegisterClass(&wc))
	{
		MessageBox(NULL,TEXT("Could not register the window class."),TEXT("Error"),MB_OK|MB_ICONEXCLAMATION);

		return false;
	}

	AdjustWindowRectEx(&windowRect,dwStyle,FALSE,dwExStyle);

	mainWnd = CreateWindowEx(dwExStyle,
								mainClassName,
								mainWindowName,
								dwStyle,
								CW_USEDEFAULT,CW_USEDEFAULT,
								windowRect.right-windowRect.left,
								windowRect.bottom-windowRect.top,
								NULL,
								NULL,
								GetModuleHandle(NULL),
								NULL);
	if(!mainWnd)
	{
		KillWindow();
		MessageBox(NULL,TEXT("Window creation error."),TEXT("Error"),MB_OK|MB_ICONEXCLAMATION);
		return false;
	}
	
	mainDC = GetDC(mainWnd);
	if(!mainDC)
	{
		KillWindow();
		MessageBox(NULL,TEXT("Could not create a device context."),TEXT("Error"),MB_OK|MB_ICONEXCLAMATION);
		return false;
	}

	pixelFormat = ChoosePixelFormat(mainDC,&pfd);
	if(!pixelFormat)
	{
		KillWindow();
		MessageBox(NULL,TEXT("Could not find a suitable pixel format."),TEXT("Error"),MB_OK|MB_ICONEXCLAMATION);
		return false;
	}

	if(!SetPixelFormat(mainDC,pixelFormat,&pfd))
	{
		KillWindow();
		MessageBox(NULL,TEXT("Could not set the pixel format."),TEXT("Error"),MB_OK|MB_ICONEXCLAMATION);
		return false;
	}

	mainRC = wglCreateContext(mainDC);
	if(!mainRC)
	{
		KillWindow();
		MessageBox(NULL,TEXT("Could not create a rendering context."),TEXT("Error"),MB_OK|MB_ICONEXCLAMATION);
		return false;
	}

	if(!wglMakeCurrent(mainDC,mainRC))
	{
		KillWindow();
		MessageBox(NULL,TEXT("Could not activate the rendering context."),TEXT("Error"),MB_OK|MB_ICONEXCLAMATION);
		return false;
	}

	ShowWindow(mainWnd,SW_SHOW);
	SetForegroundWindow(mainWnd);
	SetFocus(mainWnd);
	ReSizeScene(width,height);

	if(!InitializeGraphics())
	{
		KillWindow();
		MessageBox(NULL,TEXT("Graphics initialization failed."),TEXT("Error"),MB_OK|MB_ICONEXCLAMATION);
		return false;
	}

	if(!InitializeGame())
	{
		KillWindow();
		MessageBox(NULL,TEXT("Game initialization failed."),TEXT("Error"),MB_OK|MB_ICONEXCLAMATION);
		return false;
	}

	if(!InitializeTimer())
	{
		KillWindow();
		MessageBox(NULL,TEXT("Timer initialization failed."),TEXT("Error"),MB_OK|MB_ICONEXCLAMATION);
		return false;
	}

	TRACE(TEXT("OpenGL %S\n"), glGetString(GL_VERSION));

	return true;
}
示例#8
0
文件: Main.cpp 项目: sadiem/JUVADA
//+++++++++++++++++++++++++++++++++++++++++++++++++
//メイン関数
//-------------------------------------------------
//初期化及びメインループ
//--in---------------------------------------------
//
//--out---------------------------------------------
//
//+++++++++++++++++++++++++++++++++++++++++++++++++
int WINAPI _tWinMain(HINSTANCE hInst, HINSTANCE hPrevInst, LPTSTR lpCmdLine, int iCmdShow)
{
	HWND	hWnd;
	MSG		msg;
	DWORD	dwFPSLastTime, dwCurrentTime, dwFrameCount;

	//ウィンドウ クラスを登録
	WNDCLASS wndClass = {
		CS_HREDRAW | CS_VREDRAW,
		WndProc,
		0,
		0,
		hInst,
		LoadIcon(hInst, MAKEINTRESOURCE(IDI_ICON1)),
		LoadCursor(NULL, IDC_ARROW),
		(HBRUSH)GetStockObject(WHITE_BRUSH),
		MAKEINTRESOURCE(IDR_MENU1),
		CLASS_NAME
	};
	if (RegisterClass(&wndClass) == 0) return false;

	//ウィンドウ サイズを取得
	RECT rc = {0, 0, SCREEN_WIDTH, SCREEN_HEIGHT};
	DWORD dwStyle = WS_OVERLAPPED | WS_SYSMENU | WS_MINIMIZEBOX | WS_VISIBLE;
	DWORD dwExStyle = 0;
	AdjustWindowRectEx(&rc, dwStyle, FALSE, dwExStyle);

	//ウィンドウを作成
	hWnd = CreateWindowEx(
		dwExStyle,
		CLASS_NAME,
		CAPTION_NAME,
		dwStyle,
		WINDOW_X,
		WINDOW_Y,
		rc.right - rc.left,
		rc.bottom - rc.top,
		NULL,
		NULL,
		hInst,
		NULL);
	if (hWnd == NULL) return false;

	g_bWindow = true;
	
	if(FAILED(InitializeGraphics(hWnd, g_bWindow))) 
		return 0;	//OpenGL の初期化

	//変数初期化
	timeBeginPeriod(1);									//タイマの分解能を最小にセット
	dwFPSLastTime = dwExecLastTime = timeGetTime();		//現在のシステム タイマを取得
	dwExecLastTime -= FRAME_RATE;
	dwFrameCount = 0;
	g_fFPS = 0.0f;

	//マウスカーソル位置を固定する
	//SetCursorPos( WINDOW_X + SCREEN_WIDTH / 2, WINDOW_Y + SCREEN_HEIGHT / 2 );	//ウィンドウの中心位置に固定
	ShowCursor(false);

	//メイン ウインドウ ループ
	msg.message = WM_NULL;

	//乱数設定
	InitRandom();

	while (WM_QUIT != msg.message && !g_bEnd)	//WM_QUIT がくるか、終了フラグがたつまでループ
	{
		if (PeekMessage(&msg,NULL, 0, 0, PM_REMOVE)) {
			TranslateMessage(&msg);
			DispatchMessage(&msg);
		} else {
			dwCurrentTime = timeGetTime();					//現在のタイマ値を取得
			if (dwCurrentTime - dwFPSLastTime >= 500)		//0.5 秒ごとに計測
			{
				//フレーム数を計算
				g_fFPS = dwFrameCount * 1000.0f / (dwCurrentTime - dwFPSLastTime);
				dwFPSLastTime = dwCurrentTime;	//タイマ値を更新
				dwFrameCount = 0;				//フレーム カウンタをリセット
			}
			//この辺で時間管理
			while (dwCurrentTime - dwExecLastTime >= FRAME_RATE)	//一定時間が経過したら・・・
			{
				dwExecLastTime += FRAME_RATE;						//タイマ値を更新
			
				GameMain(hWnd);										//ゲーム メイン処理
			}
			RenderGraphics();								//レンダリング処理を実行
			dwFrameCount++;									//フレーム カウントを+1
			Sleep(1);										//いったん Windows に制御を戻す
		}

		//終了確認
		if(g_bEnd)
		{
			//if (IDNO == MessageBox(hWnd, _T("ゲームを終了しますか?"), _T("終了確認"), MB_YESNO))
			//	g_bEnd = false;

		}

	}
	timeEndPeriod(1);						//システム タイマの分解能を元に戻す
	return (int)msg.wParam;
}
//*****************************************************************************
//
// The following is the Main Application Thread.  It will Initialize the
// Bluetooth Stack and all used profiles.
//
//*****************************************************************************
static void
MainApp(void *pThreadParameter)
{
    int iPressCount;
    int iTick;
    int iVolume;
    int iRetVal;
    tDeviceInfo sDeviceInfo;
    BTPS_Initialization_t sBTPSInitialization;

    //
    // Set the callback function the stack can use for printing to the
    // console.
    //
#ifdef DEBUG_ENABLED
    sBTPSInitialization.MessageOutputCallback = MessageOutputCallback;
#else
    sBTPSInitialization.MessageOutputCallback = NULL;
#endif

    //
    // Initialize the Bluetooth stack, using no callback parameters (NULL).
    //
    iRetVal = InitializeBluetooth(BluetoothCallbackFunction, NULL,
                                  &sBTPSInitialization);

    //
    // Initialize the Graphics Module.
    //
    InitializeGraphics(ButtonPressCallback);

    //
    // Proceed with application if there was no Bluetooth init error.
    //
    if(!iRetVal)
    {
        //
        // Make the device Connectable and Discoverable and enabled Secured
        // Simple Pairing.
        //
        SetLocalDeviceMode(CONNECTABLE_MODE  | DISCOVERABLE_MODE |
                           PAIRABLE_SSP_MODE);

        //
        // Get information about our local device.
        //
        iRetVal = GetLocalDeviceInformation(&sDeviceInfo);
        if(!iRetVal)
        {
            //
            // Format the board address into a string, and display it on
            // the console.
            //
            BD_ADDRToStr(sDeviceInfo.ucBDAddr, g_cBoardAddress);
            Display(("Local BD_ADDR: %s\r\n", g_cBoardAddress));

            //
            // Display additional info about the device to the console
            //
            Display(("HCI Version  : %s\r\n",
                      g_pcHCIVersionStrings[sDeviceInfo.ucHCIVersion]));
            Display(("Connectable  : %s\r\n",
                    ((sDeviceInfo.sMode & CONNECTABLE_MODE) ? "Yes" : "No")));
            Display(("Discoverable : %s\r\n",
                    ((sDeviceInfo.sMode & DISCOVERABLE_MODE) ? "Yes" : "No")));
            if(sDeviceInfo.sMode & (PAIRABLE_NON_SSP_MODE | PAIRABLE_SSP_MODE))
            {
                Display(("Pairable     : Yes\r\n"));
                Display(("SSP Enabled  : %s\r\n",
                       ((sDeviceInfo.sMode & PAIRABLE_SSP_MODE) ?
                        "Yes" : "No")));
            }
            else
            {
                Display(("Pairable     : No\r\n"));
            }

            //
            // Show message to user on the screen
            //
            UpdateStatusBox("Waiting for Connection...");

            //
            // Bluetooth should be running now.  Enter a forever loop to run
            // the user interface on the board screen display and process
            // button presses.
            //
            iTick = ONE_SEC_COUNT;
            iVolume = DEFAULT_POWERUP_VOLUME;
            iPressCount = 0;
            while(1)
            {
                //
                // Update the screen.
                //
                ProcessGraphics();

                //
                // Wait 1/10 second.
                //
                BTPS_Delay(TENTH_SEC_COUNT);

                //
                // If one second has elapsed, toggle the LED
                //
                if(!(--iTick))
                {
                   iTick = ONE_SEC_COUNT;
                   ToggleLED(LED_PIN);
                }

                //
                // Check to see if the User Switch was pressed.
                //
                if(UserSwitchPressed())
                {
                   //
                   // Count the amount of time that the button has been
                   // pressed.
                   //
                   iPressCount++;
                }

                //
                // Else the user switch is not pressed
                //
                else
                {
                    //
                    // If the button was just released, then adjust the volume.
                    // Decrease the volume by 10% for each button press.  At
                    // zero, then reset it to 100%.
                    //
                    if(iPressCount)
                    {
                        iVolume = (iVolume == 0) ? 100 : iVolume - 10;

                        //
                        // Set the new volume, and display a message on the
                        // console
                        //
                        SoundVolumeSet(iVolume);
                        Display(("Press Count %d Volume %d\r\n", iPressCount,
                                iVolume));
                        iPressCount = 0;
                   }
                }
            }
        }
    }

    //
    // There was an error initializing Bluetooth
    //
    else
    {
        //
        // Print an error message to the console and show a message on
        // the screen
        //
        Display(("Bluetooth Failed to initialize:  Error %d\r\n", iRetVal));
        UpdateStatusBox("Failed to Initialize Bluetooth.");

        //
        // Enter a forever loop.  Continue to update the screen, and rapidly
        // blink the LED as an indication of the error state.
        //
        while(1)
        {
            ProcessGraphics();
            BTPS_Delay(500);
            ToggleLED(LED_PIN);
        }
    }
}