Comments (22)
Which version of pyglet
verifiably works? I've tried Pyglet 1.2.4, and I still have this exact issue.
enricozb@enricozb-mbp ~> pip3 show pyglet
Name: pyglet
Version: 1.2.4
Summary: Cross-platform windowing and multimedia library
Home-page: http://pyglet.readthedocs.org/en/pyglet-1.2-maintenance/
Author: Alex Holkner
Author-email: [email protected]
License: BSD
Location: /usr/local/lib/python3.6/site-packages
Requires:
p5 version: 0.3.0a1
Python version: 3.6
Operating System: Mac OS
from p5.
Ahhh.. okay. This is interesting. We haven't been able to consistently reproduce this issue (as I use a linux machine for development and only have access to a Windows for testing). I'll see if I can write some debugging code that you can run.
from p5.
Were you ever able to test on a mac before the 0.3.0a1 release? I'm having a hard time finding a commit which supports even the simplest sketch on a mac. Trying to see if the bug appeared in a specific commit.
from p5.
fwiw, i can recreate this issue. same version of python, macOS, p5py, and pyglet.
from p5.
Same issue on OS X; the window updates jerkily a few times, then stops responding. I doubt that it matters, but I'm running the script from within a virtualenv.
Test script:
from p5 import *
def setup():
size(640, 360)
no_stroke()
background(204)
def draw():
if mouse_is_pressed:
fill(random_uniform(255), random_uniform(127), random_uniform(51), 127)
else:
fill(255, 15)
circle_size = random_uniform(low=10, high=80)
circle((mouse_x, mouse_y), circle_size)
def key_pressed(event):
background(204)
run()
Expected behavior:
Same as original poster.
Actual behavior
Same as original poster.
Errors produced (if any):
None.
p5 version:
numpy==1.13.2
p5==0.3.0a2
pyglet==1.2.4
PyOpenGL==3.1.0
Python version:
Python 3.6.1
Operating System:
OS X El Capitan
v10.11.6 (15G1611)
MacBook Pro (Retina, 13-inch, Late 2012)
Processor: 2.9 GHz Intel Core i7
Memory: 8 GB 1600 MHz DDR3
Graphics: Intel HD Graphics 4000 1536 MB
from p5.
Were you ever able to test on a mac before the 0.3.0a1 release? I'm having a hard time finding a commit which supports even the simplest sketch on a mac. Trying to see if the bug appeared in a specific commit.
We were facing issues on the Mac even before. I can't remember this exactly, but the v0.1.0dev3 release would be a good place to start. I'll do some digging myself and give you more specific commits to test this weekend.
from p5.
I now run my testscript on MacOS X 10.10.5 (Yosemite). I got it running (see screenshot) but when I tried to run the examples I got the same behaviour as described above: After a few steps the animation stops and freezes the window. I run on both machines Anaconda Python 3.5.2 with an actual pyglet (1.2.4).
from p5.
A few things I can confirm:
- All of the refresh/draw functions are running properly. They are being called at the right time (ie, they are not stuttering like the window).
- You are using the correct timing method to call the refresh (time.time vs time.clock)
And a few discoveries:
- I was messing around with some of the gl configs and found that you are using a depreciated method of getting the display config. But after correcting it, it didn't solve the problem.
- In
sketch/base
if you change the template totemplate = pyglet.gl.Config(samples_buffers=1, samples=2, double_buffer=True)
you get a ton of flickering (which makes sense after reading about this option), but, you are actually able to see the animation rendering. (NOTE: This is not the actual solution... it introduces some other issues like the buffer not clearing properly)
I have a sneaking suspicion that this is a pyglet issue. I wonder if making the switch to QT would solve this... If that is the end goal, transitioning to QT might kill two birds with one stone.
from p5.
I have a sneaking suspicion that this is a pyglet issue.
Yep. Have been thinking about that as well. I've been hanging out on the Pyglet Google group and they are working really hard on upgrading Pyglet's OpenGL integration (esp. adding support for the core profile: https://groups.google.com/forum/#!topic/pyglet-users/oihWLIDH1S4)
I wonder if making the switch to QT would solve this... If that is the end goal, transitioning to QT might kill two birds with one stone.
I've been playing around with the idea of moving to PyQT for a while, but if we get it working with Pyglet it would be amazing. I'll get to properly work on this in a week or two, and will experiment with the pyglet version that people are working on right now.
from p5.
Nice! I’ll keep an eye out for any commits.
from p5.
I would like to add that I'm getting the same issue on (Fedora) Linux.
My system has 2 OpenGL stacks: when using mesa, the problem arises, but it does not when using nvidia drivers (via optirun). Python stack is the same.
$ pip3 freeze
future==0.16.0
numpy==1.14.0
opencv-python==3.4.0.12
p5==0.3.0a2
pyglet==1.3.0
PyOpenGL==3.1.0
I tried using the double buffering solution reported above, but nothing changes. @marcrleonard I would be interested in seeing the config changes you made.
I am currently investigating as well.
from p5.
I'm not entirely sure, but this could be connected to the OpenGL version that p5 gets access to. What version of OpenGL do you get for your mesa and nvidia stacks respectively? (glxinfo | grep OpenGL
should find the correct information for you).
from p5.
mesa:
OpenGL core profile version string: 4.5 (Core Profile) Mesa 17.2.4
OpenGL core profile shading language version string: 4.50
OpenGL core profile context flags: (none)
OpenGL core profile profile mask: core profile
OpenGL core profile extensions:
OpenGL version string: 3.0 Mesa 17.2.4
OpenGL shading language version string: 1.30
Nvidia:
OpenGL core profile version string: 4.6.0 NVIDIA 387.34
OpenGL core profile shading language version string: 4.60 NVIDIA
OpenGL core profile context flags: (none)
OpenGL core profile profile mask: core profile
OpenGL core profile extensions:
OpenGL version string: 4.6.0 NVIDIA 387.34
OpenGL shading language version string: 4.60 NVIDIA
EDIT
I am not aware of how processing.org (v3) is rendering, but I have no issues with it. If your shaders are the same, I guess there should be no differences... I tried to explore a little the opengl calls, but apparently the only bugs I get are related to glX (I can post a trace obtained with https://github.com/apitrace/apitrace if it's helpful).
from p5.
I think the problem lies in the config
passed in this line. When I remove this, the sketch works as correctly. I have posted an issue on stack-overflow and others suggested that it is better to define config
from pyglet.window.Window()
's config
: https://stackoverflow.com/questions/48983828/pyglet-not-running-as-expected-in-macos/48984962#48984962
from p5.
Just to confirm that I can reproduce the issue on High Sierra (10.13.3) with pyglet-1.3.1 and PyOpenGL-3.1.0 and the current HEAD (e78c4a8). Using the interactive sample sketch by @falquaddoomi above I actually found out that the window doesn't freeze or stop rendering completely, it is just not redrawn as long as it is in the foreground. With the sketch code above, moving the mouse in front of the sketch nothing happens, but when backgrounding and then foregrounding the window again, the drawings triggered by the mouse hovering over the inactive sketch earlier are all there. It is also possible to only cause a redraw of parts of the sketch by partially obscuring the sketch window with another window.
@parsoyaarihant what would the working order of config/template/window initialisation be? Just removing line 62 gives me a flickering sketch, same with the version from PR #35
from p5.
I've been playing around with how to best generate a config that works across all platforms (see also #24) but I haven't been able to keep the sketch from stopping to redraw automatically on MacOS. @abhikpal what's the motivation for the two hard-coded config settings? I found out that the samples_buffers
config option in
Line 48 in e78c4a8
sample_buffers
(https://pythonhosted.org/pyglet/api/pyglet.gl.Config-class.html), so I don't think it is actually doing anything? The double_buffer
option that fixes things on Raspberry (see #24) also causes the sketch to break (i.e. flicker) on OSX.from p5.
@kevinstadler , I have tried running the code in virtual environment and still the sketch is running as expected. Here is the configuration:
High Sierra 10.13.3
Python 3.6
pyglet 1.4.0a1
PyOpenGL 3.1.1a1
numpy 1.14.0
from p5.
Which code, the one from the repository or your pull request?
from p5.
My pull request
from p5.
Ok cool I finally got it to work! Simply using screen.get_best_config()
did not work for me, I had to provide the following two arguments to the template:
template = pyglet.gl.Config(double_buffer=1, sample_buffers=1)
config = screen.get_best_config(template=template)
For any value greater than 0 for sample_buffers
in the template, get_best_config()
returns a config with sample_buffers=1
on my machine. Also, explicitly passing samples
like in the original code does not seem to be necessary as it is automatically set to whatever sample_buffers
is. Can you test if this also works for you and add it to the PR if so?
from p5.
Okay, this new configuration works for me too. I have added this change in my PR #35
from p5.
Hey @Manindra29 (and everyone on this thread), thanks to #49, do we consider this issue and #9 fixed?
from p5.
Related Issues (20)
- Weird jittery behavior when `background()` is not called in `draw()` while using the skia renderer. HOT 12
- Exclude building test files into distribution builds HOT 2
- extend CI tests for windows and mac-os platform HOT 2
- Too many open files error when loading many images HOT 3
- Migrate to poetry HOT 4
- save() throws an error HOT 2
- Errors using "CORNERS" mode HOT 5
- Error installing p5 package: Failed building wheel for PyOpenGL-accelerate HOT 20
- Inconsistency between mouse_is_pressed boolean and mouse_clicked function HOT 1
- Improve installation instructions to account for unuspported Python versions HOT 6
- Setup pre-commit HOT 3
- Optimize skia rendering loop
- KeyError: 'SQAURE' when using stroke_cap(SQUARE) HOT 5
- Fix Code Formatting to Resolve Flake8 Errors in Pre-commit Hook HOT 4
- ModuleNotFoundError: No module named 'npy_tempita' when installing P5. HOT 3
- Not compatible with Python >=3.11 HOT 6
- Unable to install p5 and ml5 in python HOT 2
- pip cant install p5 HOT 3
- Cannot install p5 package with Python 3.12 HOT 6
- Unable to run custom setup and draw HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from p5.