I’m trying to implement F3D Viewer with wxpython, but I don’t seem to understand the steps.
I think my understanding on GLCanvas is somewhat beginner level. I can’t seem to find GLCanvas supported events, but at least I know that one of them is EVT_PAINT.
Any support is appreciated.
#!/usr/bin/env python
import f3d
import wx
from wx.glcanvas import GLCanvas
class Canvas(GLCanvas):
def __init__(self, parent):
GLCanvas.__init__(self, parent)
self.mEngine = None
self.GL_Initialized = False
self.Bind(wx.EVT_PAINT, self.OnPaint)
# Initialize F3D
def OnInitGL(self):
self.mEngine = f3d.Engine(f3d.Window.EXTERNAL)
self.mEngine.loader.load_geometry(f3d.Mesh(
points=[0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 1.0, 0.0, 0.0],
face_sides=[3],
face_indices=[0, 1, 2],
)
)
def OnPaint(self):
if not self.GL_Initialized:
self.OnInitGL()
self.GL_Initialized = True
self.OnDraw()
def OnDraw(self):
self.mEngine.window.render()
self.SwapBuffers()
# Define window size
size_x = 1024
size_y = 768
# Initialize wxPython
app = wx.App(False)
# Define frame
frame = wx.Frame(None, id=wx.ID_ANY, title="Split Frame", size=(size_x, size_y))
splitter = wx.SplitterWindow(parent=frame, id=wx.ID_ANY, style=wx.SP_3D)
splitter.SetMinimumPaneSize(800)
leftP = wx.Panel(splitter, style=wx.BORDER_SUNKEN) # Create left panel
rightP = wx.Panel(splitter, style=wx.BORDER_SUNKEN) # Create right panel
splitter.SplitVertically(leftP, rightP, 100)
_3d = Canvas(leftP)
# Show Frame
frame.Show(True)
# Run mainloop
app.MainLoop()