Giter VIP home page Giter VIP logo

Comments (15)

einarf avatar einarf commented on May 29, 2024 1

Works on Ubuntu Eoan Ermine (AMD Vega) ⭐

GLX version: 1.4
Screen is  0
Number of FBconfigs 336
Got a matching visual: index 144 33 xid 0x21
Is Direct?:  1
Done making a first context
base.window - INFO - Context Version:
base.window - INFO - ModernGL: 5.5.3
base.window - INFO - vendor: X.Org
base.window - INFO - renderer: AMD RAVEN (DRM 3.32.0, 5.2.0-15-generic, LLVM 9.0.0)
base.window - INFO - version: 4.5 (Compatibility Profile) Mesa 19.2.1
base.window - INFO - python: 3.7.4 (default, Sep 11 2019, 16:12:59) 
[GCC 9.2.1 20190909]
base.window - INFO - platform: linux
base.window - INFO - code: 450

Screenshot from 2019-10-14 14-56-00

Missing darwin support. Currently working on that. (Half way done)

from moderngl-window.

einarf avatar einarf commented on May 29, 2024 1

Most of this is now resolved. We are still missing OS X support in pyopengltk.

More info here : jonwright/pyopengltk#4

from moderngl-window.

einarf avatar einarf commented on May 29, 2024

Definitely want to give that a try at least. I'm not entirely sure how to cover mouse, keyboard and window events, but I'm guessing tkinter should be able to provide most of those? Worst case missing events can be emulated somehow.

I guess starting with a simple Tk window with a frame covering the entire window is a good idea. Then later make a widget that can be mixed with other UI elements (making one for PyQt5 and PySide2 as well).

It would probably require a bit of investment in your pyopengltk project. I see darwin is missing and I'm sure there will be other things to tweak as well to make this work. If it can benefit both pyopengl and moderngl users.. even better. I'm not sure if you had other things in mind?

One very important thing to resolve is setting a package license on github and in setup.py (making license visible on PyPI). I'm not sure what that would be, considering this is derived work from projects using CPOL (pytkogl), zlib (opengl-tcltk) and BSD (pyopengl).

There is a 1000% percent chance we will get questions about this if not resolved 😄
Worst case contact the maintainers of pytkogl + opengl-tcltk to be sure. All these licenses are fairly permissive and similar, so I'm sure it's not too complicated to resolve.

from moderngl-window.

einarf avatar einarf commented on May 29, 2024

I manage to get moderngl context and basic rendering working on windows at least. There's of course a lot more work needed to make this into a proper window, but a good sign this idea is doable.

Capture

moderngl_window.context.base.window - INFO - Context Version:
moderngl_window.context.base.window - INFO - ModernGL: 5.5.3
moderngl_window.context.base.window - INFO - vendor: NVIDIA Corporation
moderngl_window.context.base.window - INFO - renderer: GeForce GTX 1070/PCIe/SSE2
moderngl_window.context.base.window - INFO - version: 4.6.0 NVIDIA 436.48
moderngl_window.context.base.window - INFO - python: 3.7.2 (tags/v3.7.2:9a3ffc0492, Dec 23 2018, 23:09:28) [MSC v.1916 64 bit (AMD64)] 
moderngl_window.context.base.window - INFO - platform: win32
moderngl_window.context.base.window - INFO - code: 460

from moderngl-window.

jonwright avatar jonwright commented on May 29, 2024

That was fast! I had been thinking to eliminate all the ctypes code and just use the winfo_id and winfo_screen to hook up the window with one of your contexts. It sounds like you already got it working, so I am happy I asked. I don't have access to mac but would be happy to do some testing on windows and linux (although it might take me some time to get up to speed).

from moderngl-window.

einarf avatar einarf commented on May 29, 2024

The tkinter window is located here:
https://github.com/moderngl/moderngl_window/tree/master/moderngl_window/context/tk

You can test the window by running:

python.exe .\examples\moderngl_logo.py --window tk

.. or any other of the examples.

Currently window resizing, minimize and maximize works. The only way to close the window currently is clicking the window close button. I'll probably see if I can add some more event support later today.

I have access to win10, linux and OS X.

from moderngl-window.

einarf avatar einarf commented on May 29, 2024

@jonwright This might be done pretty fast as an experimental window. See if you can fix the license issue because I don't want to deal with emails about this 😄

from moderngl-window.

einarf avatar einarf commented on May 29, 2024

The way moderngl works in 5.x : create_context() relies on an existing opengl context and a default framebuffer. The alternative is create_standalone_context() for headless rendering. This is why pyopengltk still would be better off doing the window creation and default framebuffer creation.

We do have an experimental glcontext package : https://github.com/moderngl/glcontext

.. but I'm not sure if the plan is to support context creation and default framebuffer creation (that is not headless) in that one. It's a very odd use case.

from moderngl-window.

einarf avatar einarf commented on May 29, 2024

I think the first version of the tk window is actually done now. Currently only tested on windows. I'll test it out tomorrow in linux.

What has been implemented:

  • A working tk.Window backend (in windows) properly detecting the context and default framebuffer. We also bypass tkinter's event loop.
  • Support for hiding mouse cursor
  • Support for fullscreen mode
  • Support for enable/disable window resize
  • Window resize event automatically calculating new viewport
  • Key press events
  • Key release events
  • Key pressed state map
  • Unicode character pressed event
  • Mouse position events
  • Mouse button events
  • Mouse button state map
  • Mouse drag events (when mouse is moving and any button is pressed)
  • Mouse wheel events (positive/negative y)
  • .. probably more

Missing features:

  • vsync control (Depends on pyopengltk)
  • Multisample anti-aliasing support for the default framebuffer (Depends on pyopengltk)

I created these issues in : https://github.com/jonwright/pyopengltk

from moderngl-window.

einarf avatar einarf commented on May 29, 2024

Just a more complex test rendering the sponza scene. Ran this for about 15 minutes and the cpu is stable around 5%, gpu also around 5%. Memory also stable at 88.5MB. ~480 fps without vsync judging from the redering time. Looking good!

Capture

from moderngl-window.

einarf avatar einarf commented on May 29, 2024

moderngl-window 1.5.0 is now on PyPI with the new experimental tkinter window.

For the optional dependencies for tk window:

pip install moderngl-window[tk]

.. and you can run examples using the tk window like this (pyglet window will be the default if --window is not specified)

# The basic animated logo example
python examples/moderngl_logo.py --window tk
# Other parameters ..
python examples/moderngl_logo.py --window tk --cursor no --resizable no
# more fun .. (mouse + AWSD / QE)
python examples/cube_model.py --window tk --fullscreen

We'll see how that works out on linux... and possibly OS X in the future. Don't think it should be that hard to do some minor tweaks in pyopengltk to conver the missing stuff. The pyglet code base can also be a great reference for this. They do everything with ctypes.

https://github.com/pyglet/pyglet

I can look into darwin support some time in the near future.

from moderngl-window.

einarf avatar einarf commented on May 29, 2024

Released moderngl-window 1.5.1 using pyopengltk==0.0.2 (from 0.0.1)

I'm not sure what the difference between these versions are, but at least it works. I assume some bug was fixed.

from moderngl-window.

jonwright avatar jonwright commented on May 29, 2024

Looks good to me. I managed to see some moderngl test windows. Eventually there may be enhancements needed for the context types etc, but those issues are in pyopengltk, I think. You could close this issue I guess?

from moderngl-window.

einarf avatar einarf commented on May 29, 2024

Yup. I guess we can close this. moderngl-window provides a single interface to multiple window libraries so user can just switch the window type when on OS X. (Configuration option or enviroment variable).

from moderngl-window.

einarf avatar einarf commented on May 29, 2024

@jonwright Also, thanks a lot for suggesting a window for tikinter. I think a lot of people will be happy.

Adding separate widgets is the next step (existing task #42 ) so users can easily combine these with UI elements.

from moderngl-window.

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.