Giter Site home page Giter Site logo

Comments (8)

okuma10 avatar okuma10 commented on June 29, 2024 1

yes it works now! Thank you for addressing this so quickly!

from pyglfw.

FlorianRhiem avatar FlorianRhiem commented on June 29, 2024

Hello @okuma10,

currently no specific Vulkan wrapper is supported by pyGLFW, so you will need to cast the wrapper-specific arguments to ctypes.c_void_p, e.g. using ctypes.cast(instance_pointer, ctypes.c_void_p). Depening on the technology used by the Vulkan wrapper you are using, you may need to perform an additional step to retrieve the instance pointer first.

Please let me know if this solved your issue, otherwise please tell me which Vulkan wrapper you are using so I can look into it.

from pyglfw.

okuma10 avatar okuma10 commented on June 29, 2024

hi
I'm using this wrapper
https://github.com/realitix/vulkan

the ctypes.cast suggestion didn't work

from pyglfw.

FlorianRhiem avatar FlorianRhiem commented on June 29, 2024

Thanks, the wrapper is using cffi, so you need to convert the cffi pointer to a ctypes pointer. I'll look into it.

from pyglfw.

FlorianRhiem avatar FlorianRhiem commented on June 29, 2024

Instead of using ctypes.cast(instance_pointer, ctypes.c_void_p) you will need to use ctypes.c_void_p(int(ffi.cast('uintptr_t', instance_pointer))) to convert the cffi pointer to a ctypes pointer. You should be able to import ffi from the vulkan package, otherwise you can create a new one using:

from cffi import FFI

ffi = FFI()

from pyglfw.

okuma10 avatar okuma10 commented on June 29, 2024

I tried your first suggestion but I get an error

  File "C:\Users\Okuma_10\AppData\Roaming\Python\Python37\site-packages\glfw\__init__.py", line 2561, in create_window_surface
    return _glfw.glfwCreateWindowSurface(instance, window, allocator, surface)
OSError: exception: access violation writing 0x0000000000000000
        glfw_VKinstance = ctypes.c_void_p(int(ffi.cast('uintptr_t',self.VKinstance)))

        glfw.create_window_surface(glfw_VKinstance, self.window, None, self.surface)

self.window is the window handle I get from glfw. and self.surface is just set to None at the moment of the function call.

On the tutorial ...since it's in C++ the variable type is pre-defined as VkSurfaceKHR . But up to this point in the tutorial the vulkan wrapper always returns the the correct type.

from pyglfw.

FlorianRhiem avatar FlorianRhiem commented on June 29, 2024

I just checked their repo and they have an example for using pyGLFW: https://github.com/realitix/vulkan/blob/master/example/contribs/example_glfw.py The example has the following code:

        surface = ctypes.c_void_p(0)
        instance = ctypes.cast(int(ffi.cast('uintptr_t', self.__instance)), ctypes.c_void_p)
        glfw.create_window_surface(instance, self.__window, None, ctypes.byref(surface))

Please try and use the code from the example. I'll try to get it set up on my system and maybe I can add some support for this wrapper to pyGLFW.

from pyglfw.

FlorianRhiem avatar FlorianRhiem commented on June 29, 2024

I have just released pyGLFW1.12.0 which contains some utilities for working with CFFI based Vulkan wrappers. You can now do the following:

surface_ptr = ffi.new('VkSurfaceKHR[1]')
glfw.create_window_surface(instance, window, None, surface_ptr)
surface = surface_ptr[0]

and pyGLFW will automatically convert the CFFI pointers to ctypes pointers.

from pyglfw.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.