0

This systems works fine with pygame, glut and glfw using openGL 2.1, however as soon as I try to force openGL 3.2, openGL immediately fails. Here is my glfw implementation, I also have a GLUT program in similar sytle which fails with the same error.

 class GlfwDisplayController(object):
    def __init__(self,resolution):
        glfw.init()
        self._resolution = resolution
        w,h = self._resolution
        glfw.window_hint(glfw.CONTEXT_VERSION_MAJOR, 3)
        glfw.window_hint(glfw.CONTEXT_VERSION_MINOR, 2)
        glfw.window_hint(glfw.OPENGL_FORWARD_COMPAT, GL_TRUE)
        glfw.window_hint(glfw.OPENGL_PROFILE, glfw.OPENGL_CORE_PROFILE);
        self._window = glfw.create_window(w,h,"GLFW openGL render",None,None)
        glfw.make_context_current(self._window)

    def kill(self):
        glfw.terminate()

    def display(self):
        glfw.swap_buffers(self._window)
        glfw.poll_events()

if __name__ == "__main__":
    from OpenGL.GL import *
    import glfw
    testContext = GlfwDisplayController( (500,500) )
    #testing to make sure the context was created
    glMatrixMode(GL_MODELVIEW)

Here is the error output. This works fine with openGL 2.1 if I comment out all of the glfw.window_hint() calls

Traceback (most recent call last):


 File "src/rendering/Display_controller.py", line 134, in <module>
    glMatrixMode(GL_MODELVIEW)
      File "/usr/local/lib/python2.7/site-packages/OpenGL/platform/baseplatform.py", line 402, in __call__
        return self( *args, **named )
      File "errorchecker.pyx", line 53, in OpenGL_accelerate.errorchecker._ErrorChecker.glCheckError (src/errorchecker.c:1218)
    OpenGL.error.GLError: GLError(
        err = 1282,
        description = 'invalid operation',
        baseOperation = glMatrixMode,
        cArguments = (GL_MODELVIEW,)
    )

TO my knowledge, OSX is fully updated, including graphics drivers. Is there anything special I have to do in the system to access openGL 3.2+? I'm thoroughly sick of working with glsl 1.2 :(

glxinfo output:

$ glxinfo | grep openGL

OpenGL vendor string: Intel Inc.
OpenGL renderer string: Intel(R) Iris(TM) Graphics 6100
OpenGL version string: 2.1 INTEL-10.25.17
OpenGL shading language version string: 1.20
OpenGL extensions:
Frozenglass
  • 145
  • 1
  • 9

2 Answers2

1

I think you are creating core profile by glfw.OPENGL_CORE_PROFILE. Change this to glfw.OPENGL_COMPATIBILITY_PROFILE ( Please see exact flag). You are creating core profile by that you are telling driver that I will not use any fixed functionality feature in my program. But aparently there is call to glMatrixMode(GL_MODELVIEW) which is not in modern OpenGL.

  • Pretty much this! I would suggest to take a look [here](http://www.glfw.org/docs/latest/window_guide.html). The exact flag is `OPENGL_COMPAT_PROFILE`. Also, if you are going to mix in deprecated functionality like `glMatrixMode(GL_MODELVIEW)`, then forcing `glfw.window_hint(glfw.OPENGL_FORWARD_COMPAT, GL_TRUE)` makes little since, since using `GL_TRUE` there would remove functions like `glMatrixMode`... – CodeSurgeon Oct 13 '17 at 20:06
  • I actually wasnt aware that glMatrixMode wasnt in modern openGL? (I'm a GL noobie), how do i specify which matrix i want to modify in modern? – Frozenglass Oct 13 '17 at 21:09
  • You just pass all matrices to shader. I think follow some good tutorial on modern opengl. – Paritosh Kulkarni Oct 13 '17 at 21:13
  • I'll try that! however, for now I changed the flag to GL_COMPAT_PROFILE and recieved: `glfw.GLFWError: (65543) NSGL: The targeted version of OS X only supports core profile contexts for OpenGL 3.2 and above` any way around this? – Frozenglass Oct 13 '17 at 21:19
  • Try changing version to below 3.2 – Paritosh Kulkarni Oct 13 '17 at 21:37
  • Try to give version 2.1 . After that if dint work try removing forward compatibility flag but keep version 2.1 and compatibility profile – Paritosh Kulkarni Oct 13 '17 at 22:01
  • looks like OSX really doesn't like OPENGL_COMPAT_PROFILE -- no luck at all. Thanks for your help, I'm going to try to write a modern openGL implementation of my code and try my luck. OPENGL_CORE_PROFILE allows the object to be created – Frozenglass Oct 13 '17 at 22:22
  • Ok best of luck – Paritosh Kulkarni Oct 13 '17 at 22:24
0

OSX OpenGL profiles are tightly constrained compared to PC profiles. Most PCs support compatibility profiles in modern OpenGL, which means you can mix and match programmable pipelines with code that uses the legacy functionality like glMatrixMode.

You either need to re-write your software to use only Core profile code (modern OpenGL) or you need to re-write it to use legacy OpenGL, and the creation of the GL context needs to match the code. Right now you're creating a Core profile context and using forbidden functionality from legacy OpenGL.

#testing to make sure the context was created
glMatrixMode(GL_MODELVIEW)

This is bad code to use to test the context creation, since it's tied to the legacy pipeline. Try something like

glClearColor(1.0f, 0.0f, 0.0f, 1.0f);
glClear(GL_COLOR_BUFFER_BIT);

That will work on either a core profile or a legacy profile.

Jherico
  • 28,584
  • 8
  • 61
  • 87