Changed the name of the test.py file to better indicate what kind of test file it is.

This commit is contained in:
Joey Payne 2014-02-13 19:10:40 -07:00
commit e800d37c00

View file

@ -11,7 +11,7 @@ from pandac.PandaModules import *
from testclasses import *
class Test(ShowBase):
def __init__(self, width=800, height=600):
def __init__(self, width=1000, height=1000):
ShowBase.__init__(self)
self._render = True
self.width = width
@ -28,11 +28,12 @@ class Test(ShowBase):
screen = render2d.attachNewNode(c.generate())
screen.setTransparency(TransparencyAttrib.MAlpha)
screen.setPos(0,0,0)
base.buttonThrowers[0].node().setMoveEvent('mouse_move')
self.surf = TestSurface([width, height])
cairoTexture = Texture()
cairoTexture.setMagfilter(Texture.FTNearest)
cairoTexture.setMinfilter(Texture.FTNearest)
cairoTexture.setXSize(width)
cairoTexture.setYSize(height)
cairoTexture.setFormat(cairoTexture.FRgba8)
@ -40,21 +41,25 @@ class Test(ShowBase):
self.cairoTexture = cairoTexture
screen.setTexture(cairoTexture)
self.screen = screen
#screen.reparentTo(render2d)
self.accept('mouse1', self.click)
self.accept('mouse1-up', self.up)
taskMgr.add(self.mousemove, 'mousemove')
taskMgr.add(self.drawall, 'draw')
self.accept('mouse1', self.click, ['mouse-left'])
self.accept('mouse1-up', self.up, ['mouse-left'])
self.accept('mouse2', self.click, ['mouse-middle'])
self.accept('mouse2-up', self.up, ['mouse-middle'])
self.accept('mouse3', self.click, ['mouse-right'])
self.accept('mouse3-up', self.up, ['mouse-right'])
self.accept('window-event', self.windowEvent)
def click(self):
self.surf.inject_mouse_down('mouse-left')
#taskMgr.setupTaskChain('move_chain', numThreads=1, threadPriority=TPLow, frameBudget=0.00001)
#taskMgr.setupTaskChain('draw_chain', numThreads=2, threadPriority=TPHigh, frameSync=True)
taskMgr.add(self.mousemove, 'mousemove')
taskMgr.add(self.drawall, 'draw')
def up(self):
self.surf.inject_mouse_up('mouse-left')
def click(self, button):
self.surf.inject_mouse_down(button)
def up(self, button):
self.surf.inject_mouse_up(button)
def windowEvent(self, window):
ShowBase.windowEvent(self, window) #call the super method to handle all other cases
@ -63,6 +68,11 @@ class Test(ShowBase):
return
width, height = window.getXSize(), window.getYSize()
if width != self.width or height != self.height:
#self._render = False
#while self.surf.drawing:
# pass
#taskMgr.remove('mousemove')
#taskMgr.remove('draw')
self.width, self.height = width, height
cairoTexture = Texture()
cairoTexture.setMagfilter(Texture.FTNearest)
@ -74,6 +84,9 @@ class Test(ShowBase):
self.cairoTexture = cairoTexture
self.screen.setTexture(cairoTexture)
self.surf.notify_window_resize(window.getXSize(), window.getYSize())
#self._render = True
#taskMgr.add(self.mousemove, 'mousemove', taskChain='move_chain')
#taskMgr.add(self.drawall, 'draw', taskChain='move_chain')
def drawall(self, task):
if self._render: