Welcome to collectivesolver - Programming & Software Q&A. A website you can trust. All programs tested and works. Contact: aviboots(AT)netvision.net.il
Liquid Web Managed Dedicated Server: RAID 1 SSD with 16GB of RAM minimum! 24/7 On-Site Heroic Support! Industry-Leading SLA!

BlueHost Web Hosting

Ecommerce Software - Best Ecommerce Platform Made for You - Free Trial

Ecommerce Software - Best Ecommerce Platform Made for You - Free Trial

getflywheel wordpress hosting


Liquid Web Cloud VPS Hosting

8,361 questions

11,615 answers

573 users

How to Create Window in OpenGL with GLFW 3.1 in C/C++

informit.com | the trusted technology learning source - 6,633 eBook | InformIT eBook Store


44 views
asked Jan 30, 2015 by avibootz
edited Feb 1, 2015 by avibootz

1 Answer

0 votes

// 1.  Download glew from glew.sourceforge.net
// 2.  Download glfw from glfw.org/download.html
// 3a. Copy glfw-3.1.bin.WIN32 and glew-1.11.0 libraries to your project directory
// 3b. You can copy glfw-3.1-bin libraries to your project directory add the src files and compile
// 4.  Configure project property for the include and lib files
// 6.  Build and run

#include <GL/glew.h>
#include <GLFW/glfw3.h>
#include <string>
#include <iostream>
#include <fstream>
#include <vector>
#include <ctime>
#include <cstdlib>

// you don't need all the includes now, but you'll need them in OpenGL program

int main( int argc, char* argv[] )
{
  if (!glfwInit ()) 
  {
    fprintf (stderr, "ERROR: could not start GLFW3\n");
    return 1;
  } 

  GLFWwindow* window = glfwCreateWindow (640, 480, "OpenGL", NULL, NULL);
  if (!window) 
  {
    fprintf (stderr, "ERROR: could not open window with GLFW3\n");
    glfwTerminate();
    return 1;
  }

  glfwMakeContextCurrent (window);

  GLenum err = glewInit();
  if (err!= GLEW_OK)
  {
    fprintf(stderr, "Error: %s\n", glewGetErrorString(err));
  }
  
  glClearColor (0.6f, 0.6f, 0.8f, 1.0f);

  while (!glfwWindowShouldClose (window)) 
  {
    glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    glfwPollEvents ();
    glfwSwapBuffers (window);
  }
  
  glfwTerminate();

  return 0;
}





answered Jan 30, 2015 by avibootz
edited Jan 30, 2015 by avibootz
...