RenderKit / ospray

An Open, Scalable, Portable, Ray Tracing Based Rendering Engine for High-Fidelity Visualization
http://ospray.org
Apache License 2.0
1.01k stars 182 forks source link

Is the API still working? #516

Closed gdonval closed 2 years ago

gdonval commented 2 years ago

I am trying to generate limited bindings with Cython (I know there is a pybind11 binding already).

I can get the device to start, instantiate a camera and a simple mesh geometry but when trying to embed the geometry in a geometry model (ospNewGeometricModel(mesh)), I get a

'python test.py' terminated by signal SIGSEGV (Address boundary error)

I get the same error whatever I do with OSPData. The guy doing the pybind11 bindings is not using the API so I was wondering if it was simply broken.


I don't know how to make things simpler than this (minimum wrapping with cython). It fails when committing the model.

# distutils: language = c++
# cython: language_level = 3

cdef extern from "ospray/OSPEnums.h":
    ctypedef enum ErrorCode_t "OSPErrorCode":
        pass

cdef extern from "ospray/ospray.h" namespace "osp":
    cdef cppclass Device:
        pass
    cdef cppclass ManagedObject:
        pass
    cdef cppclass Geometry(ManagedObject):
        pass
    cdef cppclass GeometricModel(ManagedObject):
        pass

cdef extern from "ospray/ospray.h":
    cdef ErrorCode_t ospInit(int argc, char* argv)
    cdef void ospShutdown()
    cdef void ospRelease(ManagedObject* obj)
    cdef void ospCommit(ManagedObject* obj)

    cdef Geometry* ospNewGeometry(const char* geometry_type)
    cdef GeometricModel* ospNewGeometricModel(Geometry* geometry)

cpdef make_mesh_in_model():
    cdef:
        Geometry* geo
        GeometricModel* geom
    ospInit(0, NULL)
    geo = ospNewGeometry(b'mesh')
    ospCommit(geo)
    geom = ospNewGeometricModel(geo)
    ospCommit(geom)  # <-- This is where it fails.
    ospRelease(geo)
    ospShutdown()