how to use GLFW with openGL?

I'm trying to compile a short openGl and GLFW code but I'm failing in.. I've included all the .h like this :

#include <stdio.h>
#include <stdlib.h>
#include <GL/glew.h>
#include <GL/glfw2.h>

I'm on linux so I've made a :

sudo zypper install libglfw2

When I'm compiling like this :

 g++ main.cpp -lGLU

I have :

main.cpp:14:22: fatal error: GL/glfw2.h:Any file or directory
 #include <GL/glfw2.h>
                      ^
compilation terminated.

I've also tried to include #include <GL/glfw3.h> but without success.

This is my complet code :

#include <stdio.h>
#include <stdlib.h>
#include <GL/glew.h>
#include <GL/glfw2.h>

int main()
{
      if (glfwInit() == false)
        {
          fprintf(stderr, "GLFW failed to initialise.\n");
          return (-1);
        }
      glfwWindowHint(GLFW_FSAA_SAMPLES, 4);
      glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
      glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
      glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
      GLFWwindow* window;
      window = glfwCreateWindow(640, 480, "OPENGL", NULL, NULL);
      if (!window)
        {
          fprintf(stderr, "Window failed to create\n");
          glfwTerminate();
          return (-1);
        }
      glfwMakeContextCurrent(window);
      glewExperimental = true;
      if (glewInit() != GLEW_OK)
        {
          fprintf(stderr, "Failed to initialize GLEW\n");
          return (-1);
        }
    return (0);
}

Could someone know what I have to do to compile my code ?

Thanks

Answers


There is no GL/glfw2.h and never has been, and the code above uses the GLFW 3 API. See Renamed library and header file for more information about header paths.

There is no reason to use GLFW 2 for new projects, so I would avoid the libglfw2 package. Instead see if there is a GLFW 3 package.


Need Your Help

Windows batch script to find largest PDF file in subfolders and print with path in footer using Ghostscript and `pdftk`

windows batch-file path ghostscript pdftk

I have a large number of directories, and there are a lot of PDF files in them. I have to print the largest PDF file in each subdirectories with the path in the footer. I have searched a lot on the

how to shift single value of a pandas dataframe column

python pandas dataframe

Using pandas first_valid_index() to get index of first non-null value of a column, how can I shifta single value of column rather than the whole column. i.e.