Text archives Help
- From: bigler@sci.utah.edu
- To: manta@sci.utah.edu
- Subject: [MANTA] r1112 - in trunk: . Engine/Display SwigInterface
- Date: Fri, 9 Jun 2006 14:28:09 -0600 (MDT)
Author: bigler
Date: Fri Jun 9 14:28:08 2006
New Revision: 1112
Modified:
trunk/Engine/Display/PureOpenGLDisplay.cc
trunk/Engine/Display/PureOpenGLDisplay.h
trunk/SwigInterface/wxManta.py
trunk/commandlines
Log:
Engine/Display/PureOpenGLDisplay.cc
Engine/Display/PureOpenGLDisplay.h
Added setGLViewport function as a helper for SWIG and python. Makes
it so you don't need to use the OpenGL extension from python. All
the needed GL is in PureOpenGLDisplay.
SwigInterface/wxManta.py
Removed dependency on python OpenGL extension.
Moved most of the guts of App into MantaFrame. This is how I think
it should have been.
We can actually shutdown the engine before the window is closed.
commandlines
Scene for the Boeing777 loading from arachne.
Modified: trunk/Engine/Display/PureOpenGLDisplay.cc
==============================================================================
--- trunk/Engine/Display/PureOpenGLDisplay.cc (original)
+++ trunk/Engine/Display/PureOpenGLDisplay.cc Fri Jun 9 14:28:08 2006
@@ -300,6 +300,12 @@
}
void
+PureOpenGLDisplay::setGLViewport(int x, int y, int width, int height)
+{
+ glViewport(x, y, width, height);
+}
+
+void
PureOpenGLDisplay::displayImage(const Image* image)
{
// We will look at the typeid of the image to determine what kind it
Modified: trunk/Engine/Display/PureOpenGLDisplay.h
==============================================================================
--- trunk/Engine/Display/PureOpenGLDisplay.h (original)
+++ trunk/Engine/Display/PureOpenGLDisplay.h Fri Jun 9 14:28:08 2006
@@ -67,7 +67,11 @@
void init();
// Clears the screen with the given color. You still need to swap
// the buffer afterwards.
- void clearScreen(float r, float g, float b, float a = 0);
+ static void clearScreen(float r, float g, float b, float a = 0);
+ // Calls glViewport for you ( helper stuff for swig ;) For
+ // whatever reason, you can't name this glViewport without having
+ // bad things happen on the swig side.
+ static void setGLViewport(int x, int y, int width, int height);
// Renders the image
void displayImage(const Image* image);
Modified: trunk/SwigInterface/wxManta.py
==============================================================================
--- trunk/SwigInterface/wxManta.py (original)
+++ trunk/SwigInterface/wxManta.py Fri Jun 9 14:28:08 2006
@@ -11,8 +11,6 @@
from manta import *
from pycallback import *
-from OpenGL.GL import *
-
import FloatSpin as FS
@@ -119,12 +117,8 @@
def clearScreen(self):
size = self.GetSize()
self.SetCurrent()
- glViewport(0, 0, size.x, size.y)
-# self.printSize("viewport", size)
-# self.printSize("viewport BestFittingSize",
self.GetBestFittingSize())
-# self.printSize("viewport BestSize", self.GetBestSize())
- glClearColor(0.05, 0.1, 0.2, 0.0);
- glClear(GL_COLOR_BUFFER_BIT);
+ PureOpenGLDisplay.setGLViewport(0, 0, size.x, size.y)
+ PureOpenGLDisplay.clearScreen(0.05, 0.1, 0.2, 0.0)
self.SwapBuffers()
def InitGL(self):
@@ -143,9 +137,6 @@
self.prev_time = current_time
-class Frame(wx.Frame):
- pass
-
class LightFrame(wx.Frame):
def __init__(self, parent, engine):
wx.Frame.__init__(self, parent=parent, title="Lights")
@@ -264,45 +255,42 @@
cbArgs = ( Color(rgbColor), )
self.engine.addTransaction("Light Color",
manta_new(PyCallback.static_createMantaCallback(colorButton.light.setColor,
cbArgs)))
-
-
-
-class App(wx.App) :
-
###########################################################################
- ## OnInit
-
###########################################################################
- def OnInit(self) :
- self.frame = Frame(parent=None, title='Manta')
-# size=wx.Size(xres, yres) )
- self.frame.Show()
+class MantaFrame(wx.Frame):
+ def __init__(self, parent=None, title="Manta",
+ renderSize=wx.Size(xres,yres)):
+ wx.Frame.__init__(self, parent=parent, title=title)
+
+ # Setup events
+ self.Bind(wx.EVT_CLOSE, self.OnCloseWindow)
# Create the StatusBar
- self.frame.statusbar = self.frame.CreateStatusBar()
+ self.statusbar = self.CreateStatusBar()
# Create the menu
menuBar = wx.MenuBar()
menu1 = wx.Menu()
- self.frame.Bind(wx.EVT_MENU, self.OnQuit,
+ self.Bind(wx.EVT_MENU, self.OnCloseWindow,
menu1.Append(wx.NewId(), "&Quit"))
menuBar.Append(menu1, "&File")
menu2 = wx.Menu()
- self.frame.Bind(wx.EVT_MENU, self.OnAbout,
+ self.Bind(wx.EVT_MENU, self.OnAbout,
menu2.Append(wx.NewId(), "About Manta"))
menuBar.Append(menu2, "&Help")
- self.frame.SetMenuBar(menuBar)
+ self.SetMenuBar(menuBar)
# Create the Main panel that will hold the renderer
- self.panel = wx.Panel(self.frame)
- self.panel.SetSize(wx.Size(xres, yres))
+ self.panel = wx.Panel(self)
+ self.panel.SetSize(renderSize)
############################################################
# Layout
box = wx.BoxSizer(wx.HORIZONTAL)
box.Add(self.panel, 1, wx.EXPAND)
- self.frame.SetSizerAndFit(box)
+ self.SetSizerAndFit(box)
+
#######################################################################
# Setup manta.
@@ -365,8 +353,6 @@
self.canvas.Bind( wx.EVT_KEY_DOWN, self.OnChar )
# Make canvas the initial focus
wx.CallAfter(self.canvas.SetFocus)
- # Make canvas the initial focus
- wx.CallAfter(self.canvas.SetFocus)
##################################################################
@@ -374,12 +360,18 @@
self.trackball_radius = 0.8
self.mouse_is_down = False
- return True
###########################################################################
- ## OnExit (called under normal shutdown)
+ ## OnCloseWindow
+
###########################################################################
+ def OnCloseWindow(self, event):
+ self.ShutdownEngine()
+ self.Destroy()
+
+
###########################################################################
+ ## ShutdownEngine
###########################################################################
- def OnExit(self):
+ def ShutdownEngine(self):
print "Exiting the engine"
# sync_thread and sync_display only exist for when we use a
# SyncDisplay class. Since this doesn't happen all the time
@@ -394,7 +386,7 @@
except: pass
self.engine.blockUntilFinished()
print "Engine exited"
-
+
###########################################################################
## OnMotion
###########################################################################
@@ -416,10 +408,10 @@
elif key == 'V':
print "Found a 'v'"
elif key == "L":
- LightFrame(self.frame, self.engine).Show()
+ LightFrame(self, self.engine).Show()
elif key == 'Q':
print "Quitting"
- self.frame.Close()
+ self.Close()
else:
print "Unknown key '%s'" % key
else:
@@ -428,17 +420,11 @@
event.Skip()
###########################################################################
- ## OnQuit
-
###########################################################################
- def OnQuit(self, event):
- self.frame.Close()
-
-
###########################################################################
## OnAbout
###########################################################################
def OnAbout(self, event):
wx.MessageBox("This is the Python GUI to the Manta Interactive Ray
Tracer",
- "About Manta", wx.OK | wx.ICON_INFORMATION, self.frame)
+ "About Manta", wx.OK | wx.ICON_INFORMATION, self)
###########################################################################
## FrameReady
@@ -514,9 +500,21 @@
text = "%3.1lf fps" % framerate
else:
text = "%2.2lf fps - %3.1lf spf" % (framerate , 1.0/framerate);
- self.frame.statusbar.SetStatusText(text, 0)
+ self.statusbar.SetStatusText(text, 0)
+
+
+class MantaApp(wx.App) :
+
+
###########################################################################
+ ## OnInit
+
###########################################################################
+ def OnInit(self) :
+ frame = MantaFrame()
+ frame.Show()
+ return True
+
-app = App()
+app = MantaApp()
app.MainLoop()
Modified: trunk/commandlines
==============================================================================
--- trunk/commandlines (original)
+++ trunk/commandlines Fri Jun 9 14:28:08 2006
@@ -4,3 +4,4 @@
bin/manta -np 2 -camera "pinhole( `cat
~/manta/data/iw/conference/conf-xy.view` )" -shadows noshadows -scene
"lib/libscene_iwviewer.so ( -iwfile
/home/sci/bigler/manta/data/iw/conference/conference.iw -reverse -bsp
/home/sci/bigler/manta/data/iw/conference/conference.bsp -flat)"
bin/manta -res 1312x800 -bench 200 10 -imagetraverser null -np 1
-imagedisplay "opengl(-mode image)"
bin/manta -res 1312x800 -bench 200 10 -imagetraverser null -np 1
-imagedisplay "opengl(-mode texture)"
+bin/dm_demo -bookmarks /scratch/bigler/Boeing777/Boeing777.v3c1.txt -np 10
-scene "lib/libscene_boeing777.so ( -file
/scratch/bigler/Boeing777/Boeing777.v3c1 -np 10 )"
- [MANTA] r1112 - in trunk: . Engine/Display SwigInterface, bigler, 06/09/2006
Archive powered by MHonArc 2.6.16.