예제 #1
0
Screen::Screen(const uint32_t width, const uint32_t height, const char *title) :
	w(width),
	h(height),
	fps(0.0),
	frameCount(0),
	vsyncOn(false)
{
	pixels = new uint32_t[width * height];
	memset(&wc, 0, sizeof(wc));
	wc.lpfnWndProc = DefWindowProc;
	wc.style = CS_CLASSDC;
	wc.cbSize = sizeof(WNDCLASSEX);
	wc.hInstance = GetModuleHandle(NULL);
	wc.lpszClassName = TEXT("wincls");
	RegisterClassEx(&wc);
	hwnd = CreateWindow(TEXT("wincls"), TEXT(title?title:"Generic window"), WS_VISIBLE, CW_USEDEFAULT, CW_USEDEFAULT, w, h, NULL, NULL, wc.hInstance, NULL);
	pfd = { 0 }; pfd.dwFlags = PFD_DOUBLEBUFFER;
	SetPixelFormat(GetDC(hwnd), ChoosePixelFormat(GetDC(hwnd), &pfd), &pfd);
	ctx = wglCreateContext(GetDC(hwnd)); wglMakeCurrent(GetDC(hwnd), ctx);
	BOOL(__stdcall* SwapInterval) (int) = (BOOL(__stdcall*)(int)) wglGetProcAddress("wglSwapIntervalEXT");
	if (SwapInterval) {
		SwapInterval(1);
	}

	glGenTextures(1, &backbuffer);
	glEnable(GL_TEXTURE_2D);
	glBindTexture(GL_TEXTURE_2D, backbuffer);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);

	toggleVSync(vsyncOn);

	QueryPerformanceFrequency(&perfFrequency);
	QueryPerformanceCounter(&previousTime);
}
void TINS12Game::onLogic()
{
	if (Input::isPressed(Button_ToggleFullscreen))
	{
		toggleFullscreen();
	}

	if (Input::isPressed(Button_ToggleSlowMotion))
	{
		toggleSlowMotion();
	}

	if (Input::isPressed(Button_ToggleVSync))
	{
		toggleVSync();
	}

	if (Input::isPressed(Button_ToggleWideScreen))
	{
		toggleWideScreen();
	}

	if (Input::isPressed(Button_ForceQuit) || ScreenManager::isEmpty())
	{
		halt();
	}
}