Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for Viewer and headless rendering on windows #83

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 38 additions & 5 deletions genesis/ext/pyrender/numba_gl_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,25 @@
)
from numba.core import cgutils
from contextlib import ExitStack

import platform
if platform.platform().lower().startswith("windows"):
import glfw
glfw.init()
glfw.window_hint(glfw.CONTEXT_VERSION_MAJOR, 2)
glfw.window_hint(glfw.CONTEXT_VERSION_MINOR, 0)
glfw.window_hint(glfw.VISIBLE, glfw.FALSE)
window = glfw.create_window(1, 1, "OpenGL Window", None, None)
if not window:
glfw.terminate()
raise Exception("Failed to create GLFW window")

glfw.make_context_current(window) # This is necessary for Windows OpenGL to work

import OpenGL.GL as GL
from OpenGL.GL import GLint, GLuint, GLvoidp, GLvoid, GLfloat, GLsizei, GLboolean, GLenum, GLsizeiptr, GLintptr
from OpenGL.raw.GL.VERSION.GL_2_0 import _EXTENSION_NAME
from OpenGL import platform as GLplatform


class GLWrapper:
Expand Down Expand Up @@ -49,11 +66,27 @@ def __init__(self):

def load_func(self, func_name, *signature):
dll = GL.platform.PLATFORM.GL
func_ptr = GL.platform.ctypesloader.buildFunction(
GL.platform.PLATFORM.functionTypeFor(dll)(*signature),
func_name,
dll,
)
func_type = GL.platform.PLATFORM.functionTypeFor(dll)(*signature)
try:
func_ptr = GL.platform.ctypesloader.buildFunction(
func_type,
func_name,
dll,
)
except:
func_type = func_type()
func_ptr = glplatform.createExtensionFunction(
DearVa marked this conversation as resolved.
Show resolved Hide resolved
func_name,
dll,
resultType=func_type.restype,
argTypes=func_type.argtypes,
doc='',
argNames=tuple(map(lambda x: str(x), func_type.argtypes)),
extension=_EXTENSION_NAME,
)
func_ptr.argtypes = func_type.argtypes
func_ptr.restype = func_type.restype

self.gl_funcs[func_name] = func_ptr

def build_wrapper(self):
Expand Down
2 changes: 1 addition & 1 deletion genesis/vis/viewer.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def build(self, scene):
elif gs.platform == "Windows":
run_in_thread = False
auto_start = False
gs.raise_exception("Viewer has some issues on Windows. Can anyone help?")
# gs.raise_exception("Viewer has some issues on Windows. Can anyone help?")

self._pyrender_viewer = pyrender.Viewer(
context=self.context,
Expand Down
4 changes: 2 additions & 2 deletions genesis/vis/visualizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ def __init__(self, scene, show_viewer, vis_options, viewer_options, renderer):
self._cameras = gs.List()

def add_camera(self, res, pos, lookat, up, model, fov, aperture, focus_dist, GUI, spp, denoise):
if gs.platform == "Windows":
gs.raise_exception("Camera not yet supported on Windows but is supposed to. Can anyone help?")
# if gs.platform == "Windows":
# gs.raise_exception("Camera not yet supported on Windows but is supposed to. Can anyone help?")

# if self._viewer is None and gs.platform == 'macOS':
# gs.raise_exception(f'Headless rendering not yet supported on {gs.platform}.')
Expand Down