Open.GL icon indicating copy to clipboard operation
Open.GL copied to clipboard

c2_triangle_elements.txt don't compile

Open gheaeckkseqrz opened this issue 10 years ago • 5 comments

On line 33, you pass settings as 4th argument of window, this variable doesn't exist. I'm pretty sure the variable to use is context, I changed it, the code compile without errors, but it still displays nothing on my Macbook Air.

gheaeckkseqrz avatar Sep 29 '14 13:09 gheaeckkseqrz

Hi,

The typo has been corrected. I've just built the code on Windows and it appears to run without issues:

Are you running Mavericks?

Overv avatar Sep 29 '14 19:09 Overv

Yes, I'm running Mavericks (10.9.5), with an Intel HD Graphics 5000 1536 MB graphics. I just added a few checks, it seems that compiling the shaders fails.

    // Create and compile the vertex shader
    GLuint vertexShader = glCreateShader(GL_VERTEX_SHADER);
    glShaderSource(vertexShader, 1, &vertexSource, NULL);
    glCompileShader(vertexShader);

    GLint compileResult = GL_TRUE;
    glGetShaderiv(vertexShader, GL_COMPILE_STATUS, &compileResult);
    if (compileResult != GL_TRUE)
      {
        std::cerr << "Failled to compile vertexShader" << std::endl;
        return -1;
      }

I'll keep looking for the solution, I'll update this thread if I find something.

EDIT: Getting the compile error :

[23:47, ] rm -f a.out && make && ./a.out
g++ c2_triangle_elements.cpp -framework OpenGL -lGlew -lsfml-system -lsfml-window
Failled to compile vertexShader
ERROR: 0:1: '' :  version '150' is not supported
ERROR: 0:1: '' : syntax error #version

gheaeckkseqrz avatar Sep 30 '14 09:09 gheaeckkseqrz

Try adding:

settings.majorVersion = 3;
settings.minorVersion = 2;

Or context.* if you renamed them to that.

Overv avatar Sep 30 '14 10:09 Overv

Tried this, it doesn't fix the problem.

From http://stackoverflow.com/questions/20931528/shader-cant-be-compiled

MacOS uses Legacy Profile as default for all created OpenGL context. Therefor by default only OpenGL up to 2.1 and GLSL up to 1.20 is supported.

To use OpenGL 3.2+ you need to switch to the Core Profile.

The page give example of how to do this with Glut, but I can't find anything equivalent in the (non-existing) glew documentation.

gheaeckkseqrz avatar Sep 30 '14 10:09 gheaeckkseqrz

In that case you should use SDL or GLFW to create the context. Both of these are modern libraries (unlike Glut) and have support for creating a core profile context, as described in the context chapter. I'll see if I can add a disclaimer for Mac users.

Edit: It appears that SFML should be creating a core profile context when passing 3 as major version:

https://github.com/LaurentGomila/SFML/blob/master/src/SFML/Window/OSX/SFContext.mm#L199

I'm not sure why it's not working. You could try filing a bug with SFML.

Overv avatar Sep 30 '14 22:09 Overv