dimanche 27 novembre 2016

OpenGL crashes at glCreateShader();

sorry for my English. I installed these libraries according to the instructions on the Internet GLEW and GLFW, but i can't to compile this code:

#include "GL\glew.h"
#include "glfw3.h"
#include <iostream>

int main(int argc, char** argv) {

if (!glfwInit()) {
    std::cerr << "Can't initialize glfw" << std::endl;
    return -1;
}

GLFWwindow *window;

glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 4);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE);
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_COMPAT_PROFILE );

window = glfwCreateWindow(640, 480, "GLFW", 0, 0);

if (!window) {
    glfwTerminate();
    std::cout << "Can't create window with glfwCreateWindow" << std::endl;
    return -1;
}

glewExperimental = true;
if (glewInit() != GLEW_OK) {
    std::cout << "Can't initialize GLEW\n";
}

//glCreateShader(GL_VERTEX_SHADER);

while (!glfwWindowShouldClose(window)) {
    glClear(GL_COLOR_BUFFER_BIT);

    glfwSwapBuffers(window);
    glfwPollEvents();
}

glfwTerminate();

}

this code does not work if there is this function glCreateShader(GL_VERTEX_SHADER), runtime crash(proggram has been stopped). i use Visual Studio 2015. My project settings: additional library Directories C:\C C++ librares\GLFW\lib-vc2015 C:\C C++ librares\glew-2.0.0\lib\Release\Win32 additional Dependencies opengl32.lib glew32.lib glfw3.lib additional Include Directories C:\C C++ librares\GLFW C:\C C++ librares\glew-2.0.0\include

p.s. output is std::cout << "Can't initialize GLEW\n";

Aucun commentaire:

Enregistrer un commentaire