moderngl / moderngl-window Goto Github PK
View Code? Open in Web Editor NEWA cross platform utility library for ModernGL making window creation and resource loading simple
License: MIT License
A cross platform utility library for ModernGL making window creation and resource loading simple
License: MIT License
We should support mouse exclusivity consitently between all the windows and properly separate between a hidden cursor and mouse exclusivity. This ensures mouse movements are not clipped to the window borders both in fullscreen and windowed mode.
This also means we need to handle the mouse dx/dy instead of position.
A suggestion so far is only supporting it for pyglet, glfw and sdl2. Still we need to figure out how this affects other functions dealing with the mouse.
https://pyglet.readthedocs.io/en/stable/programming_guide/mouse.html#mouse-exclusivity
We already use mouse exclusivity in glfw.
# Hide cursor
glfwSetInputMode(m_window, GLFW_CURSOR, GLFW_CURSOR_DISABLED)
# Mouse exclusivity
glfwSetInputMode(m_window, GLFW_CURSOR, GLFW_CURSOR_HIDDEN)
Possible by constraining the mouse course to the middle of the screen. There are some challenges on how different platforms handle this.
SDL has a SDL_SetRelativeMouseMode
function. This forces SDL to only report motion events, so the mouse position doesn't change.
No idea ... might be platform dependent.
We need to get some docs out very soon. This is pri 1 currently.
Going for standard sphinx + rtd.
The current examples are a bit random and need cleanup. A proper README.md
in the example directory is also needed.
We should probably use this one for tracking key pressed in pyglet window:
https://github.com/pyglet/pyglet/blob/893b7a113f8d2d562faab6c18146485ce9b47d0e/pyglet/window/key.py#L71-L96
I think a good addition to this package would be a ressources
module with basic functions for loading textures and programs. This should probably have optional dependencies in the package (mainly Pillow for now).
Maybe something like (On the top of my head right now)
load_program
load_texture_1d
load_texture_2d
load_texture_3d
load_texture_cube
load_texture_cube_map
This is an alternative to PyQt5 with a less restrictive license (LGPLv3/GPLv2). The bindings are more or less the same.
I suggest aligning the version of this package with the ModernGL version. At least the major version. I'm not entirely sure where to go from there, but would that will be sufficient?
Backend: glfw
Context OpenGL version: 450 core
Operation system: Windows 10
Python interpreter: Python 3.8.0 [MSC v.1916 64 bit (AMD64)] on win32
I want to change ctx.line_width
but nothing happened.
Code:
from moderngl-window import *
from moderngl import *
from OpenGL.GL import *
import ctypes
import logging
class Config(WindowConfig):
gl_version = (4, 5)
def __init__(self, **kwargs):
super().__init__(**kwargs)
ctx = self.ctx
ctx.line_width = 50
print(ctx.error)
print(ctx.line_width)
run_window_config(Config)
Log:
python main.py --window glfw
2019-11-16 14:15:40,698 - moderngl_window - INFO - Attempting to load window class: moderngl_window.context.glfw.Window
2019-11-16 14:15:40,995 - moderngl_window.context.base.window - INFO - Context Version:
2019-11-16 14:15:40,995 - moderngl_window.context.base.window - INFO - ModernGL: 5.5.4
2019-11-16 14:15:40,996 - moderngl_window.context.base.window - INFO - vendor: NVIDIA Corporation
2019-11-16 14:15:40,996 - moderngl_window.context.base.window - INFO - renderer: GeForce GTX 1050 Ti/PCIe/SSE2
2019-11-16 14:15:40,996 - moderngl_window.context.base.window - INFO - version: 4.5.0 NVIDIA 431.23
2019-11-16 14:15:40,996 - moderngl_window.context.base.window - INFO - python: 3.8.0 (tags/v3.8.0:fa919fd, Oct 14 2019, 19:37:50) [MSC v.1916 64 bit (AMD64)]
2019-11-16 14:15:40,996 - moderngl_window.context.base.window - INFO - platform: win32
2019-11-16 14:15:40,996 - moderngl_window.context.base.window - INFO - code: 450
GL_INVALID_VALUE
1.0
But according to the document, GL_INVALID_VALUE
should be raised if param is less or equal to 0.
Use the native glLineWidth
call has the same effect.
Code:
class Config(WindowConfig):
gl_version = (4, 5)
def __init__(self, **kwargs):
super().__init__(**kwargs)
try:
glLineWidth(50)
except GLError as error:
print(ctypes.cast(error.description, ctypes.c_char_p).value)
raise error
run_window_config(Config)
Log:
python main.py --window glfw
2019-11-16 14:22:41,288 - moderngl_window - INFO - Attempting to load window class: moderngl_window.context.glfw.Window
None
2019-11-16 14:22:41,796 - moderngl_window.context.base.window - INFO - Context Version:
2019-11-16 14:22:41,796 - moderngl_window.context.base.window - INFO - ModernGL: 5.5.4
2019-11-16 14:22:41,796 - moderngl_window.context.base.window - INFO - vendor: NVIDIA Corporation
2019-11-16 14:22:41,796 - moderngl_window.context.base.window - INFO - renderer: GeForce GTX 1050 Ti/PCIe/SSE2
2019-11-16 14:22:41,796 - moderngl_window.context.base.window - INFO - version: 4.5.0 NVIDIA 431.23
2019-11-16 14:22:41,796 - moderngl_window.context.base.window - INFO - python: 3.8.0 (tags/v3.8.0:fa919fd, Oct 14 2019, 19:37:50) [MSC v.1916 64 bit (AMD64)]
2019-11-16 14:22:41,796 - moderngl_window.context.base.window - INFO - platform: win32
2019-11-16 14:22:41,796 - moderngl_window.context.base.window - INFO - code: 450
Traceback (most recent call last):
File "C:/WorkPlace/Python/glumpy_demo/main.py", line 151, in <module>
run_window_config(Config, args=['--window', 'glfw'])
File "c:\users\mafumafu\downloads\moderngl-window\moderngl_window\__init__.py", line 190, in run_window_config
window.config = config_cls(ctx=window.ctx, wnd=window, timer=timer)
File "C:/WorkPlace/Python/glumpy_demo/main.py", line 54, in __init__
raise error
File "C:/WorkPlace/Python/glumpy_demo/main.py", line 51, in __init__
glLineWidth(50)
File "C:\Users\mafumafu\AppData\Local\Programs\Python\Python38\lib\site-packages\OpenGL\platform\baseplatform.py", line 402, in __call__
return self( *args, **named )
File "C:\Users\mafumafu\AppData\Local\Programs\Python\Python38\lib\site-packages\OpenGL\error.py", line 228, in glCheckError
raise GLError(
OpenGL.error.GLError: GLError(
err = 1281,
description = b'\xce\xde\xd0\xa7\xd6\xb5',
baseOperation = glLineWidth,
cArguments = (50,)
)
But everything goes well if I create a standalone context.
λ python
Python 3.8.0 (tags/v3.8.0:fa919fd, Oct 14 2019, 19:37:50) [MSC v.1916 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> from moderngl import *
>>> ctx = create_standalone_context()
>>> from OpenGL.GL import *
>>> glLineWidth(50)
>>> glGetFloat(GL_LINE_WIDTH)
50.0
>>> ctx.line_width
50.0
What should I do to solve it?
PS:
ctx.point_size
goes well.
Code:
class Config(WindowConfig):
gl_version = (4, 5)
window_size = (640, 360)
aspect_ratio = 16 / 9
log_level = logging.DEBUG
def __init__(self, **kwargs):
super().__init__(**kwargs)
ctx = self.ctx
glPolygonMode(GL_FRONT_AND_BACK, GL_POINT)
print(ctx.error)
print(ctx.point_size)
# Useless details
run_window_config(Config)
Log:
python main.py --window glfw
2019-11-16 14:33:45,808 - moderngl_window - INFO - Attempting to load window class: moderngl_window.context.glfw.Window
2019-11-16 14:33:46,303 - moderngl_window.context.base.window - INFO - Context Version:
2019-11-16 14:33:46,303 - moderngl_window.context.base.window - INFO - ModernGL: 5.5.4
2019-11-16 14:33:46,305 - moderngl_window.context.base.window - INFO - vendor: NVIDIA Corporation
2019-11-16 14:33:46,305 - moderngl_window.context.base.window - INFO - renderer: GeForce GTX 1050 Ti/PCIe/SSE2
2019-11-16 14:33:46,305 - moderngl_window.context.base.window - INFO - version: 4.5.0 NVIDIA 431.23
2019-11-16 14:33:46,305 - moderngl_window.context.base.window - INFO - python: 3.8.0 (tags/v3.8.0:fa919fd, Oct 14 2019, 19:37:50) [MSC v.1916 64 bit (AMD64)]
2019-11-16 14:33:46,305 - moderngl_window.context.base.window - INFO - platform: win32
2019-11-16 14:33:46,305 - moderngl_window.context.base.window - INFO - code: 450
GL_NO_ERROR
50.0
model = WindowConfig.load_scene("/input/uv.obj")
Traceback (most recent call last):
File "", line 1, in
File "/usr/local/lib/python3.6/dist-packages/moderngl_window/context/base/window.py", line 673, in load_scene
**kwargs,
File "/usr/local/lib/python3.6/dist-packages/moderngl_window/resources/scenes.py", line 18, in load
return super().load(meta)
File "/usr/local/lib/python3.6/dist-packages/moderngl_window/resources/base.py", line 46, in load
self.resolve_loader(meta)
File "/usr/local/lib/python3.6/dist-packages/moderngl_window/resources/base.py", line 97, in resolve_loader
if loader_cls.supports_file(meta):
File "/usr/local/lib/python3.6/dist-packages/moderngl_window/loaders/base.py", line 34, in supports_file
path = Path(meta.path)
File "/usr/lib/python3.6/pathlib.py", line 1001, in new
self = cls._from_parts(args, init=False)
File "/usr/lib/python3.6/pathlib.py", line 656, in _from_parts
drv, root, parts = self._parse_args(args)
File "/usr/lib/python3.6/pathlib.py", line 640, in _parse_args
a = os.fspath(a)
TypeError: expected str, bytes or os.PathLike object, not type
Now that we have a proper unified event system we should document it properly in the programming guide section.
Test with python 3.8 when moderngl wheels are created. Add classifiers and release new version.
Loaders using external libraries should ideally check the library version for a sane minmimum version.
I have some (rough) code at https://github.com/jonwright/pyopengltk which makes an OpenGL context for tkinter. You can summarise it as creating empty Tk.frame, and then using the window information (winfo_id/winfo_screen) for some ctypes calls.
Would you be interested to try to get a Tk backend working here?
I just realized we parse out divisors, but we only forward /i
divisors. I think just blindly using the specified divisor is the way to go.
Some window types can trigger glerrors on creation. This is often related to deprecated GL calls under the hood. Consume these if possible to avoid confusing users.
We should support this event for all window types.
Method description from pyglet:
The mouse was moved with one or more mouse buttons pressed. This event will continue to be fired even if the mouse leaves the window, so long as the drag buttons are continuously held down.
We need to explore how this event is handled in all window libraries and if the on_mouse_motion
function is also triggered during mouse drag. We could simplify this by checking mouse button states during mouse motion and simply send the event to a generic mouse drag method.
Project: : https://github.com/swistakm/pyimgui
We could potentially gain a lot from this as users can easily create UI with a lot of different widgets. We could also add some debug windows showing useful information.
When running the loading_obj_files.py
example in Python 3.5 I get the following error:
moderngl/examples$ python loading_obj_files.py
...
scene = Scene(self.meta.resolved_path)
File "../env/lib/python3.5/site-packages/moderngl_window/scene/scene.py", line 46, in __init__
ProgramDescription(path='scene_default/bbox.glsl'),
File "../env/lib/python3.5/site-packages/moderngl_window/resources/programs.py", line 22, in load
return super().load(meta)
File "../env/lib/python3.5/site-packages/moderngl_window/resources/base.py", line 47, in load
return meta.loader_cls(meta).load()
File "../env/lib/python3.5/site-packages/moderngl_window/loaders/program/single.py", line 21, in load
with open(self.meta.resolved_path, 'r') as fd:
TypeError: invalid file: PosixPath('../env/lib/python3.5/site-packages/moderngl_window/scene/programs/scene_default/bbox.glsl')
Changing line 21 from
with open(self.meta.resolved_path, 'r') as fd:
to
with open(str(self.meta.resolved_path), 'r') as fd:
makes the example work.
I suggest a very simple geometry
module were users can generate the most basic meshes (as VAOs) like cubes, plane, sphere. For a lot of people this is probably one of the most frustrating aspects of playing around with rendering if they don't have capabilities of loading scenes.
I do have a very ugly module for this in demosys-py
I could strip down and improve.
In the VAO wrapper we check for special build in attribute names such as gl_InstanceID
and gl_VertexID
. We don't need to do this. Instead we check if the location is less than 0.
Currently the load_
shortcuts are hard to use because they do not expose important optional parameters passed into the resource description instances.
This should be fairly easy to add and will not break compatibility.
I noticed that when trying to set vsync to false in the following example, vsync is still enabled.
class Window(mglw.WindowConfig):
gl_version = (3, 3)
title = 'Test'
vsync = False
Passing --vsync false via the command line successfully disables vsync for the same context using the default of pyglet.
I also tried both methods with --window glfw and it ignored both and kept vsync enabled.
So far the following seems to be realistic.
Will only support moderngl 5.5.x
Will support both moderngl 5 and 6 using moderngl 5.6.
Only supports moderngl 6.x
.. currently produces random noise.
Might be something to address in moderngl itself. No idea to even start on this one, but I'll let this hang around because it's a real issue.
Not entirely sure what formats would be useful here. Look into it.
I haven't used this library yet, but wanted to say thanks.
A few years ago tried a whole bunch of GL tutorials in C, C++, Python, JS on desktop, android and the web.
More X-library libs are a really good thing.
In the same way as the buffer protocol made it easy for various libraries to pass around memory areas, maybe at some point in the future there will be low level interface(s) that python graphics libraries will support + interoperate with other effortlessly.
In the meantime, this is a great step forward :)
python3 water.py ~/coding/gpu/moderngl-window/examples/advanced(master)@Lolarch
2019-11-09 18:51:51,458 - moderngl_window - INFO - Attempting to load window class: moderngl_window.context.pyglet.Window
2019-11-09 18:51:53,908 - moderngl_window.context.base.window - INFO - Context Version:
2019-11-09 18:51:53,909 - moderngl_window.context.base.window - INFO - ModernGL: 5.5.3
2019-11-09 18:51:53,915 - moderngl_window.context.base.window - INFO - vendor: Intel Open Source Technology Center
2019-11-09 18:51:53,915 - moderngl_window.context.base.window - INFO - renderer: Mesa DRI Intel(R) Sandybridge Mobile
2019-11-09 18:51:53,915 - moderngl_window.context.base.window - INFO - version: 3.3 (Core Profile) Mesa 19.2.3
2019-11-09 18:51:53,915 - moderngl_window.context.base.window - INFO - python: 3.7.4 (default, Oct 4 2019, 06:57:26)
[GCC 9.2.0]
2019-11-09 18:51:53,915 - moderngl_window.context.base.window - INFO - platform: linux
2019-11-09 18:51:53,915 - moderngl_window.context.base.window - INFO - code: 330
2019-11-09 18:51:53,928 - moderngl_window.loaders.program.single - INFO - Loading: programs/water/drop.glsl
2019-11-09 18:51:53,930 - moderngl_window.loaders.program.single - INFO - Loading: programs/water/wave.glsl
2019-11-09 18:51:53,930 - moderngl_window.loaders.program.single - INFO - Loading: programs/water/texture.glsl
Traceback (most recent call last):
File "water.py", line 120, in
moderngl_window.run_window_config(Water)
File "/home/lolart/.local/lib/python3.7/site-packages/moderngl_window/init.py", line 198, in run_window_config
window.swap_buffers()
File "/home/lolart/.local/lib/python3.7/site-packages/moderngl_window/context/pyglet/window.py", line 102, in swap_buffers
self._window.dispatch_events()
File "/home/lolart/.local/lib/python3.7/site-packages/pyglet/window/xlib/init.py", line 837, in dispatch_events
self.dispatch_pending_events()
File "/home/lolart/.local/lib/python3.7/site-packages/pyglet/window/xlib/init.py", line 874, in dispatch_pending_events
EventDispatcher.dispatch_event(self, *self._event_queue.pop(0))
File "/home/lolart/.local/lib/python3.7/site-packages/pyglet/event.py", line 416, in dispatch_event
self._raise_dispatch_exception(event_type, args, handler, exception)
File "/home/lolart/.local/lib/python3.7/site-packages/pyglet/event.py", line 479, in _raise_dispatch_exception
raise exception
File "/home/lolart/.local/lib/python3.7/site-packages/pyglet/event.py", line 413, in dispatch_event
if handler(*args):
File "/home/lolart/.local/lib/python3.7/site-packages/moderngl_window/context/pyglet/window.py", line 159, in on_mouse_motion
self._mouse_position_event_func(x, self._buffer_height - y)
TypeError: mouse_position_event() missing 2 required positional arguments: 'dx' and 'dy'
Pyglet 2.x might be a good candidate for the default window. Some short exchanges with one of the pyglet devs in reddit indicates they are aiming for 3.3 as a minimum and I urged them to use forward compatible core contexts just in case.
EDIT: They are indeed doing context creation right: https://bitbucket.org/pyglet/pyglet/src/ea6080cbb3c0370124b30543757da8349f8ed3a3/pyglet/gl/cocoa.py?at=default&fileviewer=file-view-default#cocoa.py-196:204
The advantage of using Pyglet as the standard window is:
The following...
ProgramDescription(
'program.glsl',
defines=[('NUM_ENTRIES' '256')],
)
.. will add the macro/define
#define NUM_ENTRIES 100
It should probably also replace an existing #define
in the source.
Should look into adding a windiw using Kivy. I'm not sure if this will work perfectly cross platform considering OS X only allows 3.3 core. Worth a shot,
Hello,
I'm trying to render to a texture and render to screen again (hopefully just once). However I tried 2 versions and at both I failed:
A) RTT, copy to screen
B) RTT, render to screen
min code:
self.vao = self.ctx.vertex_array(self.prog2, self.vao_content, self.ibo)
size = (1024, 1024)
self.texture = self.ctx.texture(size, components=3, dtype='f1')
depth_attachment = self.ctx.depth_renderbuffer(size)
self.fbo1 = self.ctx.framebuffer(self.texture, depth_attachment)
#render method A
self.fbo1.use()
self.vao.render()
self.ctx.detect_framebuffer().use()
self.vao.render()
self.ctx.finish()
#render method B
self.fbo1.use()
self.vao.render()
#self.ctx.detect_framebuffer().use()
self.ctx.copy_framebuffer(self.ctx.screen, self.fbo1)
self.ctx.finish()
Is there something obvious I do miss?
This is very confusing when using INFO
log level.
#line
must have, after macro substitution, one of the following two forms:
#line line
#line line source-string-number
where line
and source-string-number
are constant integer expressions. After processing this directive (including its new-line), the implementation will behave as if the following line has line number line
and starts with source string number source-string-number
. Subsequent source strings will be numbered sequentially, until another #line
directive overrides that numbering.
If during macro expansion a preprocessor directive is encountered, the results are undefined. The compiler may or may not report an error in such cases
We should support loading texture cubes:
4 x 3 single cubemap texture.
| | top | | |
| left | front | right | back |
| | bottom | | |
We should make an initial PyPI release asap.
Remaining:
WindowConfig
SceneLoader
s should use the configurable AttributeNames
I'm using this library myself for fairly lage amount of data and noticing that load times can start to become a burden after a certain point.
This was solved in pywavefront by adding a cache system that stores the parsed file in a binary format with vertex data that more or less can be dumped directly into the buffers. This reduced load times 10-100x depending on the file size. I'm wondering if we can use the same technique to reduce loading times in general.
I suspect this can be improved by suporting a file caching system for all loaders. A new settings value CACHE_DIR
can be added to settings. This would be an absolute path to a directory were cache files are stored.
<hash>.json
and <hash>.bin
{
"sha256": "XXXXXXXXXXXXX",
"parameters": {
"flip": true,
}
}
A good test case is to support file cache for textures. If we can reduce the load time by 50% I would call it a success. The cache file will simply contain the raw texture data loaded by Pillow after modifiers (horisontal flip etc). This way we can dump this directly into a texture using GzipFile.
The question is if the sha256 checks alone will negate the benefits of the cache system.
It would be nice to support basic text rendering. I already have a very simple version in demosys-py that could be ported over and possibly improved: https://github.com/Contraz/demosys-py/tree/master/demosys/effects/text
Right now it's just using a texture generated with freetype-py
loaded as a TextureArray
.
This part is pretty interesting:
From PyPI, recommended: pip install freetype-py. This will install the library with a bundled FreeType binary, so you’re ready to go on Windows, macOS and Linux (all with 32 and 64 bit x86 architecture support).
This means we could provide cross platform support for generating text on the fly in moderngl_window. Still it should probably be an optional dependency.
We need to support the standard callback when a unicode character is pressed. These are only characters that can appear in text fields and such. No control characters.
pyglet and glfw are good references. I think we can support this simply by using unicodedata.category(char)
in the keypress callback. The event must be set after the actual key press event.
This one is a bit more work because we need to actually implement this specifically for each window type.
Texture loader should not generate mipmaps by default. It should rely on the mipmap
parameter and the user should also be able to specify start/end levels.
Currently the Scene
instance returned by scene loaders are fairly generic. It contains both the scene structure and is responsible for rendering. This is a problem when handling scenes from different formats, but at least does a decent job at rendering any scene using generic shaders.
Scene
class should ideally ONLY contain the scene tree with nodes, meshes, materials.Scene
class to not break compatibility.SceneRenderer
classes. Have a basic scene renderer what will render any scene and expand to specific ones for wavefront and PBR rendeing for GLTF2. These could take a scene as input and generate a list of scopes ready for rendering. Stick to UBOs and drop as many single uniform setters as possible.Currently the flip
parameter is True
by default. This makes sense for 2d textures, but it doesn't make sense for texture arrays. Instead each loader type should have a default behavior when flip
is None
.
True
False
We currently only provide a window with a single widget covering the entire window. If we could also provide a ModernglWidget
that can easily be used together with other Qt widgets it would make the use of moderngl a lot easier for those kind of use cases.
A lot of information is already collected here:
moderngl/moderngl#348
We just need to add these as valid types and specify a byte size.
Backend: glfw
Context OpenGL version: 450 core
Operation system: Windows 10
Python interpreter: Python 3.8.0 [MSC v.1916 64 bit (AMD64)] on win32
I want to call glPolygonMode
via PyOpenGL
, but a GLError
is raised.
Code:
from moderngl-window import *
from moderngl import *
from PyOpenGL.GL import *
import ctypes
import logging
class Config(WindowConfig)
# Useless details....
def render(self, time: float, frame_time: float):
try:
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE)
except GLError as error:
logging.error(ctypes.cast(error.description, ctypes.c_char_p).value)
raise error
run_window_config(Config)
Error log:
python main.py --window glfw
2019-11-16 03:26:36,106 - moderngl_window - INFO - Attempting to load window class: moderngl_window.context.glfw.Window
2019-11-16 03:26:36,487 - moderngl_window.context.base.window - INFO - Context Version:
2019-11-16 03:26:36,487 - moderngl_window.context.base.window - INFO - ModernGL: 5.5.4
2019-11-16 03:26:36,487 - moderngl_window.context.base.window - INFO - vendor: NVIDIA Corporation
2019-11-16 03:26:36,487 - moderngl_window.context.base.window - INFO - renderer: GeForce GTX 1050 Ti/PCIe/SSE2
2019-11-16 03:26:36,487 - moderngl_window.context.base.window - INFO - version: 4.5.0 NVIDIA 431.23
2019-11-16 03:26:36,487 - moderngl_window.context.base.window - INFO - python: 3.8.0 (tags/v3.8.0:fa919fd, Oct 14 2019, 19:37:50) [MSC v.1916 64 bit (AMD64)]
2019-11-16 03:26:36,488 - moderngl_window.context.base.window - INFO - platform: win32
2019-11-16 03:26:36,488 - moderngl_window.context.base.window - INFO - code: 450
ERROR:root:None
Traceback (most recent call last):
File "main.py", line 142, in <module>
run_window_config(Config)
File "C:\Users\mafumafu\AppData\Local\Programs\Python\Python38\lib\site-packages\moderngl_window\__init__.py", line 198, in run_window_config
window.render(current_time, delta)
File "C:\Users\mafumafu\AppData\Local\Programs\Python\Python38\lib\site-packages\moderngl_window\context\base\window.py", line 588, in render
self.render_func(time, frame_time)
File "C:/WorkPlace/Python/glumpy_demo/main.py", line 127, in render
raise error
File "C:/WorkPlace/Python/glumpy_demo/main.py", line 124, in render
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE)
File "C:\Users\mafumafu\AppData\Local\Programs\Python\Python38\lib\site-packages\OpenGL\platform\baseplatform.py", line 402, in __call__
return self( *args, **named )
File "C:\Users\mafumafu\AppData\Local\Programs\Python\Python38\lib\site-packages\OpenGL\error.py", line 228, in glCheckError
raise GLError(
OpenGL.error.GLError: GLError(
err = 1280,
description = b'\xce\xde\xd0\xa7\xc1\xd0\xbe\xd9',
baseOperation = glPolygonMode,
cArguments = (GL_FRONT_AND_BACK, GL_LINE)
)
It seems that the lack of a OpenGL
context.
I put a breakpoint at moderngl_window/context/glfw/__init__.py: line 61
61| glfw.make_context_current(self._window)
after that line is executed, I could call native OpenGL functions via PyOpenGL
But I'm confused why I can't do the same thing in render
function, is there a solution?
Thanks a lot.
Support making a 2D sphere. This seems to be a common type of geometry.
Maybe we can "borrow" from moderngl example : https://github.com/moderngl/moderngl/blob/0a15b92dc8b695f4dd6272dd13856ad811deedaa/examples/mug_mockup.py#L36-L54
This is a test
I was trying to implement shadow mapping in ModernGL by following tutorials in other languages but it seems like ModernGL has its unique style that isn't very similar to other APIs.
This is one of the tutorials
I have searched everywhere for something implemented in ModernGL, with no result.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.