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

OpenGL version #1

Open
kaanaksit opened this issue Apr 5, 2020 · 7 comments
Open

OpenGL version #1

kaanaksit opened this issue Apr 5, 2020 · 7 comments

Comments

@kaanaksit
Copy link

kaanaksit commented Apr 5, 2020

Hi, I am on an Ubuntu 19.10 machine and having trouble running simple-3dviz. I installed everything using pip3, and I don't use any special repository on my machine for updating packages:

$ mesh_viewer /mnt/64a69f11-5034-4852-9415-9e04235118a2/cned/code/renderer/objects/cube.obj 
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/dist-packages/simple_3dviz/window/wx.py", line 63, in _on_paint
    self._mgl_context = moderngl.create_context()
  File "/usr/local/lib/python3.7/dist-packages/moderngl/context.py", line 1429, in create_context
    require, ctx.version_code))
ValueError: Requested OpenGL version 330, got version 300
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/dist-packages/simple_3dviz/window/wx.py", line 63, in _on_paint
    self._mgl_context = moderngl.create_context()
  File "/usr/local/lib/python3.7/dist-packages/moderngl/context.py", line 1429, in create_context
    require, ctx.version_code))
ValueError: Requested OpenGL version 330, got version 300
@angeloskath
Copy link
Owner

Hi, hmm that is interesting. Can you create a standalone context with moderngl? Namely, what does the following output?

$ python -m moderngl

Running it on my laptop it outputs the following

moderngl 5.6.0
--------------
vendor: Intel Open Source Technology Center
renderer: Mesa DRI Intel(R) HD Graphics 620 (Kaby Lake GT2) 
version: 4.5 (Core Profile) Mesa 19.2.8
python: 3.7.3 (default, Mar 27 2019, 22:11:17) 
[GCC 7.3.0]
platform: linux
code: 450

As an extra test can you check that wxPython works correctly? The following code should create a black window of size 256x256 with the title "Hello".

import wx
import wx.glcanvas

class Frame(wx.Frame):
    def __init__(self, size, title):
        super(Frame, self).__init__(
            None,
            style=wx.DEFAULT_FRAME_STYLE & ~(wx.RESIZE_BORDER | wx.MAXIMIZE_BOX)
        )
        self.SetTitle(title)
        self.SetClientSize(size)
        self.Center()
        self.view = Canvas(self)
        
class Canvas(wx.glcanvas.GLCanvas):
    def __init__(self, parent):
        super(Canvas, self).__init__(
            parent,
            attribList=[
                wx.glcanvas.WX_GL_CORE_PROFILE,
                wx.glcanvas.WX_GL_RGBA,
                wx.glcanvas.WX_GL_DOUBLEBUFFER,
                wx.glcanvas.WX_GL_DEPTH_SIZE,
                24
            ]
        )
        
app = wx.App(False)
frame = Frame((256, 256), "Hello")
frame.Show()
app.MainLoop()

Let me know the output of the above.

Cheers,
Angelos

@kaanaksit
Copy link
Author

Thank you for your fast reply!

Here is the outcome from running a moderngl instance:

$ python3 -m moderngl
moderngl 5.6.0
--------------
vendor: NVIDIA Corporation
renderer: GeForce RTX 2070/PCIe/SSE2
version: 3.3.0 NVIDIA 435.21
python: 3.7.5 (default, Nov 20 2019, 09:21:52) 
[GCC 9.2.1 20191008]
platform: linux
code: 330

Though I have install wxpython through pip3 by using

sudo pip3 install wxpython

Here is what I get when I run the sample code that you have provided:

$ python3 wx.py 
Traceback (most recent call last):
  File "wx.py", line 1, in <module>
    import wx
  File "/home/X/wx.py", line 2, in <module>
    import wx.glcanvas
ModuleNotFoundError: No module named 'wx.glcanvas'; 'wx' is not a package

@angeloskath
Copy link
Owner

Ok, at least we are progressing towards figuring out the bug. I spent a bit of time yesterday trying to replicate the issue but I can't.

WxPython needs some system libraries to work and thus may be causing this type of issues. We should consider adding PyQt as well, however, Qt has license problems that I don't want to deal with. I know this is really bad advice but anaconda could help with the wxPython building issues.

Let me know if you figured something out.

@AIMads
Copy link

AIMads commented Dec 17, 2021

Im facing the same problem right now, any fix found for this?
I get the following output for python -m moderngl:
moderngl 5.6.4

vendor: NVIDIA Corporation
renderer: NVIDIA GeForce RTX 2070/PCIe/SSE2
version: 3.3.0 NVIDIA 495.29.05
python: 3.8.6 | packaged by conda-forge | (default, Oct 7 2020, 19:08:05)
[GCC 7.5.0]
platform: linux
code: 330

And for the example code, it succeeds with following output tho:
Gtk-Message: 20:51:56.325: Failed to load module "atk-bridge"
Gtk-Message: 20:51:56.327: Failed to load module "canberra-gtk-module"
08:51:56 PM: Debug: Failed to connect to session manager: None of the authentication protocols specified are supported

@hariharan382
Copy link

I am facing same issue please help me out

@paschalidoud
Copy link
Collaborator

Hi @hariharan382,

I am using simple-3dviz without any issues on a linux machine with python 3.9.16. Furthermore, my wxpython version is 4.2.0 and moderngl's version is 5.8.2. Note that I install wxpython through conda, using conda install -c conda-forge wxpython.

Can you please check whether it works with this setup?

Best,
Despoina

@einarf
Copy link

einarf commented May 31, 2023

The root of the problem is definitely the context creation in wx. It's either an old wx install or there's something wrong with the drivers or enviroment locally. The context creation parameters are clearly requesting a core context, meaning it should create an OpenGL 3.3 context or greater (In some casese a 3.2 could also work).

https://github.com/angeloskath/simple-3dviz/blob/master/simple_3dviz/window/wx.py#L40-L43

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants