Hi, this is killing me i just wanted to start learning OpenGL and now on my first program i get core dumped right after made window !
this is my code:
#include <iostream>
using namespace std;
// GLEW
#define GLEW_STATIC
#include <GL/glew.h>
// GLFW
#include <GLFW/glfw3.h>
// Function prototypes
void key_callback(GLFWwindow* window, int key, int scancode, int action, int mode);
// The MAIN function, from here we start our application and run our Program/Game loop
int main()
{
// Init GLFW
cout << "Starting to Init GLFW
";
glfwInit();
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
glfwWindowHint(GLFW_RESIZABLE, GL_FALSE);
cout << "Done initglfw
";
GLFWwindow* window = glfwCreateWindow(800, 600, "LearnOpenGL", nullptr, nullptr); // Windowed
glfwMakeContextCurrent(window);
cout << "Made Window
";
// Set the required callback functions
glfwSetKeyCallback(window, key_callback);
cout << "seted the reqyured callbackfunctions
";
// Initialize GLEW to setup the OpenGL Function pointers
glewExperimental = GL_TRUE;
glewInit();
cout << "did glewInit
";
// Define the viewport dimensions
glViewport(0, 0, 800, 600);
cout << "Going in to the game loop
";
// Program loop
while(!glfwWindowShouldClose(window))
{
cout <<"doing glwfollevents();
";
// Check and call events
glfwPollEvents();
// Render
// Clear the colorbuffer
//glClearColor(0.2f, 0.3f, 0.3f, 1.0f);
//glClear(GL_COLOR_BUFFER_BIT);
// Swap the buffers
glfwSwapBuffers(window);
}
glfwTerminate();
return 0;
}
// Is called whenever a key is pressed/released via GLFW
void key_callback(GLFWwindow* window, int key, int scancode, int action, int mode)
{
cout << key << endl;
if(key == GLFW_KEY_ESCAPE && action == GLFW_PRESS)
glfwSetWindowShouldClose(window, GL_TRUE);
}
i tried exmples included in glfw-3.0.4 and all worked fine, i don’t know if they come precompiled but i ran cmake . and found them here !
please help me start opengl faster and using the same command without -lGLEW i compiled some example from glfw and it workeds, its a spining triangle!