Hi,
I'm trying to use correclty OpenGL on two different pc.
The first is a Laptop and it works perfectly:
-Intel(R) HD Graphics 4000
-Drivers updated
-Windows 10
But on my second pc (more powerful
), I have an error:
-NVIDIA GeForce GTX770 4Go
-Drivers updated
-Windows 7
Here is the error message:
https://gyazo.com/7aae9d9c6f14e3dcac6b9f4899f212ccI use the same code and it is recompiled before use it.
Code:
#include <iostream>
#include <string>
#include "GL\glew.h"
#include "SFML\OpenGL.hpp"
#include "SFML\Graphics.hpp"
#include "SFML\Window.hpp"
#include "glm\gtx\transform.hpp"
#include "Camera.h"
using namespace std;
int main(int argc, char *args[])
{
sf::Context context;
sf::ContextSettings settings;
settings.depthBits = 24;
settings.stencilBits = 8;
settings.majorVersion = 4;
settings.minorVersion = 0;
settings.antialiasingLevel = 8;
sf::RenderWindow window(sf::VideoMode(1280, 800), "OpenGL",sf::Style::Close, settings);
glewExperimental = GL_TRUE;
glewInit();
sf::Event event;
Camera camera(glm::vec3(4,4,3),1280.f / 800.f, glm::radians(90.f), 0.0001f, 1000.0f);
bool IsRunning = true;
//OPENGL//
float points[] = {
0.0f, 0.5f, 0.0f,
0.5f, -0.5f, 0.0f,
-0.5f, -0.5f, 0.0f
};
GLuint vbo = 0;
glGenBuffers(1, &vbo);
glBindBuffer(GL_ARRAY_BUFFER, vbo);
glBufferData(GL_ARRAY_BUFFER, sizeof(points), points, GL_STATIC_DRAW);
GLuint vao = 0;
glGenVertexArrays(1, &vao);
glBindVertexArray(vao);
glEnableVertexAttribArray(0);
glBindBuffer(GL_ARRAY_BUFFER, vbo);
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, NULL);
const char* vertex_shader =
"#version 400\n"
"in vec3 vp;"
"uniform mat4 MVP;"
"void main () {"
" gl_Position = MVP * vec4 (vp, 1.0);"
"}";
const char* fragment_shader =
"#version 400\n"
"out vec4 frag_colour;"
"void main () {"
" frag_colour = vec4 (1.0, 0.0, 0.0, 1.0);"
"}";
GLuint vs = glCreateShader(GL_VERTEX_SHADER);
glShaderSource(vs, 1, &vertex_shader, NULL);
glCompileShader(vs);
GLuint fs = glCreateShader(GL_FRAGMENT_SHADER);
glShaderSource(fs, 1, &fragment_shader, NULL);
glCompileShader(fs);
GLuint shader_programme = glCreateProgram();
glAttachShader(shader_programme, fs);
glAttachShader(shader_programme, vs);
glLinkProgram(shader_programme);
while (IsRunning)
{
while (window.pollEvent(event))
{
if (event.type == sf::Event::Closed) IsRunning = false;
}
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glUseProgram(shader_programme);
GLuint MVPID = glGetUniformLocation(shader_programme, "MVP");
glUniformMatrix4fv(MVPID, 1, GL_FALSE, &camera.MVPMatrix()[0][0]);
glBindVertexArray(vao);
glDrawArrays(GL_TRIANGLES, 0, 3);
window.display();
}
window.close();
return 0;
}
Thanks for your help !