Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: OpenGL: Version 0.0  (Read 7980 times)

0 Members and 5 Guests are viewing this topic.

herotom99

  • Newbie
  • *
  • Posts: 23
    • View Profile
OpenGL: Version 0.0
« on: March 23, 2016, 11:29:29 am »
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/7aae9d9c6f14e3dcac6b9f4899f212cc

I 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 !
« Last Edit: March 23, 2016, 11:31:54 am by herotom99 »

ka0s420

  • Jr. Member
  • **
  • Posts: 56
    • View Profile
    • Email
Re: OpenGL: Version 0.0
« Reply #1 on: March 23, 2016, 07:12:18 pm »
Sounds more like some sort of driver error to me, try updating your graphics card drivers perhaps.

herotom99

  • Newbie
  • *
  • Posts: 23
    • View Profile
Re: OpenGL: Version 0.0
« Reply #2 on: March 23, 2016, 07:34:15 pm »
I've already updated my drivers :/
My friend has also tried the program and it works (GTX 950m).

herotom99

  • Newbie
  • *
  • Posts: 23
    • View Profile
Re: OpenGL: Version 0.0
« Reply #3 on: March 23, 2016, 08:00:06 pm »
I have reroll my drivers but it doesn't works then re-updated and nothing ...

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11034
    • View Profile
    • development blog
    • Email
AW: OpenGL: Version 0.0
« Reply #4 on: March 23, 2016, 08:45:15 pm »
The only thing I can think of is GLEW screwing something up. Maybe binary1248 will know.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

binary1248

  • SFML Team
  • Hero Member
  • *****
  • Posts: 1405
  • I am awesome.
    • View Profile
    • The server that really shouldn't be running
Re: OpenGL: Version 0.0
« Reply #5 on: March 23, 2016, 09:11:28 pm »
What does the string returned when calling glGetString(GL_VERSION) contain?
SFGUI # SFNUL # GLS # Wyrm <- Why do I waste my time on such a useless project? Because I am awesome (first meaning).

herotom99

  • Newbie
  • *
  • Posts: 23
    • View Profile
Re: OpenGL: Version 0.0
« Reply #6 on: March 23, 2016, 10:10:57 pm »
It just crash on this line (with debug mode) so I have nothing.

By the way, I have made a total clean up of my card drivers and the problem still here.
So, I think drivers are not the problem or the installation is always corrupted.

binary1248

  • SFML Team
  • Hero Member
  • *****
  • Posts: 1405
  • I am awesome.
    • View Profile
    • The server that really shouldn't be running
Re: OpenGL: Version 0.0
« Reply #7 on: March 23, 2016, 10:14:15 pm »
Call it without GLEW around... just with an SFML window. GLEW causes it to crash if it can't load functions.
SFGUI # SFNUL # GLS # Wyrm <- Why do I waste my time on such a useless project? Because I am awesome (first meaning).

herotom99

  • Newbie
  • *
  • Posts: 23
    • View Profile
Re: OpenGL: Version 0.0
« Reply #8 on: March 23, 2016, 10:24:13 pm »
Hum... I don't understand I can't call this function without glew:

Error   1   error LNK2019: unresolved external symbol __imp__glGetString@4 referenced in function _main   


I can't call this function because I need an OpenGL Context and it is the problem.
And I use a char*, it return NULL :/
« Last Edit: March 23, 2016, 10:59:22 pm by herotom99 »

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11034
    • View Profile
    • development blog
    • Email
AW: OpenGL: Version 0.0
« Reply #9 on: March 24, 2016, 08:00:04 am »
Do you link OpenGL?
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

herotom99

  • Newbie
  • *
  • Posts: 23
    • View Profile
Re: OpenGL: Version 0.0
« Reply #10 on: March 24, 2016, 03:35:26 pm »
I think this is what you want:
https://gyazo.com/def7cb3534693548320471bb2e6483ad

and I am using the opengl32.dll


#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"
« Last Edit: March 24, 2016, 03:40:20 pm by herotom99 »

binary1248

  • SFML Team
  • Hero Member
  • *****
  • Posts: 1405
  • I am awesome.
    • View Profile
    • The server that really shouldn't be running
Re: OpenGL: Version 0.0
« Reply #11 on: March 24, 2016, 07:55:55 pm »
You shouldn't include both SFML/OpenGL.hpp and GL/GLEW.h at the same time. You include either one or the other, and your choice will also determine what libraries you have to link against. In fact, if you had included GL/GLEW.h after SFML/OpenGL.hpp, it would have detected multiple OpenGL includes and not allowed you to compile.

Remove all traces of GLEW and show us the output of glGetString(GL_VERSION). If it doesn't link properly, then fix the problem and get it to link. It isn't that complicated. Trying to do too many things at the same time makes it harder to find out what went wrong when something does.
SFGUI # SFNUL # GLS # Wyrm <- Why do I waste my time on such a useless project? Because I am awesome (first meaning).

herotom99

  • Newbie
  • *
  • Posts: 23
    • View Profile
Re: OpenGL: Version 0.0
« Reply #12 on: March 24, 2016, 08:14:34 pm »
Hum... Really I don't understand.
I have remove everything about glew.

And it still to return a null pointer ...

#include <iostream>
#include <string>

#include "SFML\OpenGL.hpp"
#include "SFML\Graphics.hpp"
#include "SFML\Window.hpp"

using namespace std;

int main(int argc, char *args[])
{
        sf::RenderWindow(sf::VideoMode(100, 100), "Opengl");

        const char* gl_version = (const char*)(glGetString(GL_VERSION));
        printf("GLVersion: %s\n", gl_version);

        system("pause");

        return 0;
}

Same thing without creating a window.

The result:
https://gyazo.com/37cad4f7696610d7e53712b67a530970

And when I use:
std::cout << glGetString(GL_VERSION) << std::endl;
It just crash :/

binary1248

  • SFML Team
  • Hero Member
  • *****
  • Posts: 1405
  • I am awesome.
    • View Profile
    • The server that really shouldn't be running
Re: OpenGL: Version 0.0
« Reply #13 on: March 24, 2016, 08:28:44 pm »
This means that OpenGL simply isn't available in the required form on this specific machine. What is the exact version of the Nvidia driver you installed? Is this a desktop or laptop?
SFGUI # SFNUL # GLS # Wyrm <- Why do I waste my time on such a useless project? Because I am awesome (first meaning).

herotom99

  • Newbie
  • *
  • Posts: 23
    • View Profile
Re: OpenGL: Version 0.0
« Reply #14 on: March 24, 2016, 08:31:56 pm »
It is a Desktop and I have the last nvidia driver: 364.51

 

anything