-1

I am trying to port hackathon-slicer to python3 with the OpenGL library. The hackathon slicer is programmed in node/javascript and runs fine on my older laptop.

However when I port it to python using the OpenGL library, I get an error on 'glGenFramebuffers' because glGenFramebuffers is not available. I checked and the OpenGL library has the function available. Also since it runs fine in node/javascript my laptops graphics card also has FrameBuffer available.

So what is the real problem and how to solve this? Any help greatly appreciated!

Nard
  • 119
  • 8
  • Some code here, as the [help docs](https://stackoverflow.com/help) recomend, will help anybody to find the solution. Some questions: What OpenGL library do you link to? What OpenGL version and *profile* you ask for? – Ripi2 Nov 23 '18 at 16:29

1 Answers1

0

Found the problem. You apparently only have glGenFramebuffers after creating an OpenGL context. The context is now created in the class init.

class Viewport:
def display(self):
    # Clear the color and depth buffers
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)

    # ... render stuff in here ...
    # It will go to an off-screen frame buffer.

    # Copy the off-screen buffer to the screen.
    glutSwapBuffers()

def __init__(self):
    glutInit(sys.argv)

    # Create a double-buffer RGBA window.   (Single-buffering is possible.
    # So is creating an index-mode window.)
    glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE | GLUT_DEPTH)

    # Create a window, setting its title
    glutCreateWindow('interactive')

    # Set the display callback.  You can set other callbacks for keyboard and
    # mouse events.
    glutDisplayFunc(self.display)

After this the following code does work:

    def renderSlice(self):
    glDisable(GL_DEPTH_TEST)
    glEnable(GL_STENCIL_TEST)
    glViewport(0, 0, 2560,1440)#printer.resolution.x, printer.resolution.y)

    # Bind the target framebuffer
    sliceFbo = glGenFramebuffers(1)
Nard
  • 119
  • 8