def _initDevice(self): DeviceTypes = [ d3d11c.DRIVER_TYPE_HARDWARE, d3d11c.DRIVER_TYPE_WARP, d3d11c.DRIVER_TYPE_REFERENCE, d3d11c.DRIVER_TYPE_SOFTWARE ] for dt in DeviceTypes: self._device = d3d11.Device(self._window, d3d11c.DRIVER_TYPE_WARP) if self._device: return raise CommonException('Failed to create d3d11 device.')
def __init__(self, parent, id, title, pos, size=(800, 600)): wx.Frame.__init__(self, parent, id, title, pos, size) self.mainpanel = wx.Panel(self, -1, size=(800, 600)) self.mainpanel.SetAutoLayout(True) self.leftwindow = wx.Panel(self.mainpanel, -1, (10, 10), (380, 450)) self.leftwindow.SetBackgroundColour(wx.WHITE) self.leftwindow.SetConstraints( anchors.LayoutAnchors(self.leftwindow, True, True, True, True)) self.rightwindow = wx.Panel(self.mainpanel, -1, (400, 10), (380, 450)) self.rightwindow.SetBackgroundColour(wx.WHITE) self.rightwindow.SetConstraints( anchors.LayoutAnchors(self.rightwindow, False, True, True, True)) playvideo = wx.Button(self.mainpanel, -1, "Play media on this window...", (500, 500)) playvideo.SetConstraints( anchors.LayoutAnchors(playvideo, False, False, True, True)) self.Bind(wx.EVT_BUTTON, self.playVideo, playvideo) #Create a DirectPython window from an existing wxPython window. tempWindow = d3d11.Window(handle=self.leftwindow.GetHandle()) #Create our resources. Note that if the size of the window #changes, you should call self.device.reset(). self.device = d3d11.Device(tempWindow, DRIVER_TYPE_WARP) self.effect = d3d11.Effect( d3d11x.getResourceDir("Effects", "Tutorial2.fx")) self.inputLayout = d3d11.InputLayout(vertexDesc, self.effect, 0, 0) self.vertexBuffer = d3d11.Buffer(vertexDesc, triangle, BIND_VERTEX_BUFFER) #We need to detach() the window. This means that it is up to #us (or wxPython) to mange the window from now on. tempWindow.detach() self.media = None self.Bind(wx.EVT_PAINT, self.onPaint) self.Bind(wx.EVT_TIMER, self.onTimer) self.Bind(wx.EVT_IDLE, self.onIdle) self.leftwindow.Bind(wx.EVT_SIZE, self.onSize) #Use a timer for rendering. It is not a very smooth #solution, you might want to tweak the time interval #or do something else, now it is jerky. self.timer = wx.Timer(self) self.timer.Start(10)
traceback.print_tb(err[2]) self.dp_failures += 1 files = os.listdir(os.getcwd()) tests = [] for f in files: if f.find(".pyc") != -1: continue if f.find("test_") != -1 and f.find("_all") == -1: #if f.find("test_buffer") != -1: name = f.replace(".py", "") m = __import__(name) tests.append(m.Test) device = d3d11.Device(None) suite = unittest.TestSuite() for test in tests: s = unittest.makeSuite(test) suite.addTest(s) os.system("cls") print("Starting testing...") result = Result() suite.run(result) print("\n-----------------------------") print("DirectPython 11 Test Suite:") print(" %i test cases run" % len(tests))
#Import DirectPython modules and constants. import d3d11 import d3d11x from d3d11c import * #First we need a window. If you don't want to do any visible #rendering this could be omitted. window = d3d11.Window() window.setTitle("Tutorial 2 - A colored triangle") window.show(SW_SHOW) #Then create a Device and tell it to use our window for drawing. #Use a software WARP-device, in real applications you might #try hardware first and fall back to software if that fails. device = d3d11.Device(window, DRIVER_TYPE_WARP) #Our vertex layout description: position (x, y, z) and color (r, g, b, a). #See the "Layouts and input layouts" article in the documentation. vertexDesc = [ ("POSITION", 0, FORMAT_R32G32B32_FLOAT, 0, 0, INPUT_PER_VERTEX_DATA, 0), ("COLOR", 0, FORMAT_R32G32B32A32_FLOAT, 0, APPEND_ALIGNED_ELEMENT, INPUT_PER_VERTEX_DATA, 0), #This is functionally same as above, only easier to read. I use the complex one now #so that you don't get confused when you encounter it in samples. #("POSITION", 0, FORMAT_R32G32B32_FLOAT), #("COLOR", 0, FORMAT_R32G32B32A32_FLOAT), ] #Our triangle - three vertices with position and color. The layout must match 'vertexDesc'.