[英]No glcontext for gtkglarea in gtk3 python
I am trying to use a GtkGLArea to create a 3d visualizer using this code: 我正在尝试使用GtkGLArea使用以下代码创建3d可视化器:
import gi
gi.require_version('Gtk', '3.0')
from gi.repository import Gtk, GdkPixbuf, Gdk
import os, sys
UI_FILE = "src/pygtk_gtkglarea.ui"
class GUI:
def __init__(self):
self.builder = Gtk.Builder()
self.builder.add_from_file(UI_FILE)
self.builder.connect_signals(self)
gl_area = Gtk.GLArea()
gl_area.connect('render', self.area_render)
box = self.builder.get_object('box1')
box.pack_end(gl_area, True, True, 0)
window = self.builder.get_object('window')
window.show_all()
def area_render(self, gl_area, gl_context):
print gl_area
print gl_context
return True
def on_window_destroy(self, window):
Gtk.main_quit()
def main():
app = GUI()
Gtk.main()
if __name__ == "__main__":
sys.exit(main())
and the ui file: 和ui文件:
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.18.3 -->
<interface>
<requires lib="gtk+" version="3.0"/>
<object class="GtkWindow" id="window">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="title" translatable="yes">window</property>
<property name="default_width">500</property>
<property name="default_height">400</property>
<signal name="destroy" handler="on_window_destroy" swapped="no"/>
<child>
<object class="GtkBox" id="box1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<child>
<placeholder/>
</child>
</object>
</child>
</object>
</interface>
However, when I run the app it shows a window with the text Unable to create a GL context inside it. 但是,当我运行该应用程序时,它会显示一个窗口,其中包含无法在其中创建GL上下文的文本。 Any suggestions?
有什么建议么?
So I found the answer by Googling Unable to create a GL context . 所以我通过Googling Unable创建GL上下文找到了答案。 It seems most people having this error are running old hardware.
似乎大多数出现此错误的人都在运行旧硬件。 So I tried my newer computer (that I don't like).
因此,我尝试了较新的计算机(我不喜欢)。 Voila!
瞧! Now I get a window that works.
现在,我得到一个工作窗口。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.