Beispiel #1
0
int WINAPI WinMain(HINSTANCE hInstance,
	HINSTANCE hPrevInstance,
	LPSTR lpCmdLine,
	int nCmdShow)
{
	MSG msg;
	bool done = false;

	fullscreen = MessageBox(nullptr,
		L"Do you want run application in fullscreen mode?",
		L"Is fullscreen mode", MB_YESNO | MB_ICONQUESTION) == IDNO ? false : true;

	if (!create_gl_window(L"OpenGL window", 1024, 768, 32, fullscreen))
		return 0;

	while (!done)
	{
		if (PeekMessage(&msg, nullptr, 0, 0, PM_REMOVE))
		{
			if (msg.message == WM_QUIT)
				done = true;
			else
			{
				TranslateMessage(&msg);
				DispatchMessage(&msg);
			}
		}
		else
		{
			if (active)
			{
				if (keys[VK_ESCAPE])
					done = true;
				else
				{
					draw_gl_scene();
					SwapBuffers(hDC);
				}
			}

			if (keys[VK_F1])
			{
				keys[VK_F1] = false;
				kill_gl_window();
				fullscreen = !fullscreen;
				if (!create_gl_window(L"OpenGL window", 1024, 768, 32, fullscreen))
					return 0;
			}
		}
	}

	kill_gl_window();
	return (msg.wParam);
}
Beispiel #2
0
int WINAPI WinMain(HINSTANCE hInstance,
	HINSTANCE hPrevInstance,
	LPSTR lpCmdLine,
	int nCmdShow)
{
	MSG msg;
	bool done = false;


#if PROMPT_FULLSCREEN
	fullscreen = MessageBox(nullptr,
		L"Do you want run application in fullscreen mode?",
		L"Is fullscreen mode", MB_YESNO | MB_ICONQUESTION) == IDNO ? false : true;
#endif

	if (!create_gl_window(WND_TITLE, WND_WIDTH, WND_HEIGHT, COLOR_BITS, fullscreen))
		return 0;

	while (!done)
	{
		if (PeekMessage(&msg, nullptr, 0, 0, PM_REMOVE))
		{
			if (msg.message == WM_QUIT)
				done = true;
			else
			{
				TranslateMessage(&msg);
				DispatchMessage(&msg);
			}
		}
		else
		{
			if ((active && !draw_gl_scene()) || keys[VK_ESCAPE])
				done = true;
			else
				SwapBuffers(hDC);

			if (keys[VK_F1])
			{
				keys[VK_F1] = false;
				kill_gl_window();
				fullscreen = !fullscreen;
				if (!create_gl_window(WND_TITLE, WND_WIDTH, WND_HEIGHT, COLOR_BITS, fullscreen))
					return 0;
			}
		}
	}

	kill_gl_window();
	return (msg.wParam);
}
Beispiel #3
0
Window::Window(int width, int height, int bpp) {
	if(SDL_Init(SDL_INIT_VIDEO) < 0) {
		throw std::runtime_error("Unable to initialize SDL");
	}

	create_gl_window(width, height, bpp);
}
Beispiel #4
0
int WINAPI WinMain(HINSTANCE hInstance,
	HINSTANCE hPrevInstance,
	LPSTR lpCmdLine,
	int nCmdShow)
{
	MSG msg;
	bool done = false;


#if PROMPT_FULLSCREEN
	fullscreen = MessageBox(nullptr,
		L"Do you want run application in fullscreen mode?",
		L"Is fullscreen mode", MB_YESNO | MB_ICONQUESTION) == IDNO ? false : true;
#endif

	int width = WND_WIDTH;
	int	height = WND_HEIGHT;

	get_window_size(&width, &height);

	if (!create_gl_window(WND_TITLE, width, height, COLOR_BITS, fullscreen))
		return 0;

	while (!done)
	{
		if (PeekMessage(&msg, nullptr, 0, 0, PM_REMOVE))
		{
			if (msg.message == WM_QUIT)
				done = true;
			else
			{
				TranslateMessage(&msg);
				DispatchMessage(&msg);
			}
		}
		else
		{
			if ((active && !draw_gl_scene()) || keys[VK_ESCAPE])
			{
#ifdef _DEBUG
				OutputDebugString(L"[INFO] ESC typed. Program will be closed\n");
#endif
				done = true;
			}
			else
				SwapBuffers(hDC);

			if (keys['T'] && !t_press)
			{
				t_press = true;
				twinkle = !twinkle;
			}

			if (!keys['T']) t_press = false;

			//if (keys[VK_UP]) tilt -= 0.5f;		// Up
			//if (keys[VK_DOWN]) tilt += 0.5f;	// Down
			if (keys[VK_PRIOR]) zoom -= 0.2f;	// PgUp
			if (keys[VK_NEXT]) zoom += 0.2f;	// PgDown

			glBlendFunc(GL_SRC_ALPHA, GL_ONE);
			glEnable(GL_BLEND);

			if (keys[VK_F1])
			{
				keys[VK_F1] = false;
				kill_gl_window();
				fullscreen = !fullscreen;
				get_window_size(&width, &height);
				if (!create_gl_window(WND_TITLE, width, height, COLOR_BITS, fullscreen))
					return 0;
			}
		}
	}

	kill_gl_window();
	return (msg.wParam);
}