krishauser / Klampt

Kris' Locomotion and Manipulation Planning Toolkit
BSD 3-Clause "New" or "Revised" License
377 stars 96 forks source link

Triangle Mesh Backface Culling #175

Closed j-polden closed 1 year ago

j-polden commented 1 year ago

Hi All,

I am visualizing some TriangleMesh data with the .vis package. I am wondering if it is possible enable back-face culling when i render them (so that a given triangle is visible from one side, but appears invisible when viewed from the opposite side).

Cheers

krishauser commented 1 year ago

Can you try glEnable(GL_CULL_FACE) in your script? (Functions are from PyOpenGL)

j-polden commented 1 year ago

Hi Kris thanks for the message.

I tried that operation (and similar ones yesterday) and got the following 'invalid operation' errors.

OpenGL.error.GLError: GLError(
        err = 1282,
        description = b'invalid operation',
        baseOperation = glEnable,
        cArguments = (GL_CULL_FACE,)
)

I am using python, so i included from OpenGL.GL import * to enable the glEnable() call.

I'll do a bit more digging around, hopefully there is somewhat easy fix

Cheers

krishauser commented 1 year ago

Perhaps this needs to be called after the window is created, maybe also in the graphics thread. Worst comes to worse this could be solved with:

def graphicsSetup(): glEnable(GL_CULL_FACE)

vis.show() vis.threadCall(graphicsSetup)

j-polden commented 1 year ago

Works a treat! Thanks for the help Kris.