////////////////////////////////////////////////////////////////////////////////
// Program main
////////////////////////////////////////////////////////////////////////////////
int main(int argc, char *argv[])
{
    if (!initGlfw(argc, argv))
        return 0;
    if (!initGL(argc, argv))
        return 0;

    LOG_INFO("Starting main loop.");

    running = GL_TRUE;
    //g_timer.reset();
    while (
        running &&
        !glfwWindowShouldClose(g_pWindow) &&
        !glfwWindowShouldClose(g_pWindow2)
        )
    {
        //float dt = (float)g_timer.seconds();
        //timestep(dt);
        //g_timer.reset();
        display();
        //running = running && glfwGetWindowParam(GLFW_OPENED);
        glfwPollEvents();
    }
    
    TwTerminate();
    glfwTerminate();
    return 0;
}
Beispiel #2
0
Window::Window(int width, int height, const char* title)
{
	/* Initialize the GLFW library */
	initGlfw();

	glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 1);
	glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 4);
	//glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE);
	//glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);

	glfwSetErrorCallback(errorCallback);

	/* Create a windowed mode window and its OpenGL context */
	m_window = glfwCreateWindow(width, height, title, NULL, NULL);
	if (!m_window)
	{
		terminateGlfw();
		error::crash("Could not create GLFW window.");
	}

	/* Make the window's context current */
	glfwMakeContextCurrent(m_window);

	/* Initialize GLEW */
	glewExperimental = GL_TRUE;// To get OpenGL 3+ features working on OS X
	GLenum err = glewInit();
	if (err != GLEW_OK)
	{
		std::cout << "Error initializing glew:\n" << glewGetErrorString(err) << std::endl;
	}

	std::cout << "OpenGL " << glGetString(GL_VERSION) << std::endl;
}
Beispiel #3
0
void GFXBoilerplate::
init()
{
  glfwSetErrorCallback(error_callback);
  initGlfw();

  _window = glfwCreateWindow(_width, _height, "SHEXP", NULL, NULL);

  if (!_window)
  {
    glfwTerminate();
    exit(EXIT_FAILURE);
  }

  glewExperimental = GL_TRUE;
  glfwMakeContextCurrent(_window);
  initGlew();

  glfwSetKeyCallback(_window,key_callback);
}
Beispiel #4
0
Window::Window(int width, int height, bool fullscreen, std::string title, int majorVersion, int minorVersion) : width(width), height(height), fullscreen(fullscreen), title(title), majorVersion(majorVersion), minorVersion(minorVersion) {
  initGlfw();
  Window::refCount.insert(std::pair<GLFWwindow*, unsigned>(this->window, 1));
  initGL();
}
 // Public
 GLFW::GLFW(char* title, int x, int y) {
   initGlfw();
   _window = createWindow(title, x, y);
 }