Skip to content
Raphael Menges edited this page Jan 15, 2016 · 2 revisions

Vertical sync

I would suggest to use vertical sync to save energy and keep the computer cool. Example below is for GLFW3.

// VSync
glfwSwapInterval(1);
#ifdef _WIN32
	// Turn on vertical screen sync under Windows.
	// (I.e. it uses the WGL_EXT_swap_control extension)
	typedef BOOL(WINAPI *PFNWGLSWAPINTERVALEXTPROC)(int interval);
	FNWGLSWAPINTERVALEXTPROC wglSwapIntervalEXT = NULL;
	wglSwapIntervalEXT = (PFNWGLSWAPINTERVALEXTPROC)wglGetProcAddress("wglSwapIntervalEXT");
	if (wglSwapIntervalEXT)
		wglSwapIntervalEXT(1);
#endif

OpenGL Core profile

To make the library run unter linux with intel graphics one should use the core profile of OpenGL. This can be achieved by special settings for GLFW3 and GLEW.

// Window and OpenGL initialization without any error handling
glfwInit();
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE);
GLFWwindow* window = glfwCreateWindow(1280, 720, "WindowTitle", NULL, NULL);
glfwMakeContextCurrent(window);
glewExperimental = true;
glewInit();

Resizing

When using GLFW3 one can implement its resize callback to make eyeGUI always window filling.

void resizeCallback(GLFWwindow* window, int width, int height)
{
	eyegui::resizeGUI(pGUI, width, height);
}
//...
// Somewhere after glfwInit()
//...
glfwSetFramebufferSizeCallback(window, resizeCallback);
Clone this wiki locally