[Python.NET] Problem whith DirectX device creation under pythonnet

Laurent Caumont lcaumont at pamdev.com
Mon Jan 12 06:37:42 EST 2004


Hello,

I want to create a Directx 9.0 application with Python and Managed Directx.

Here is the code:

import CLR.System.Windows.Forms as WinForms
from CLR.System.Drawing import Size, Point

import CLR.Microsoft.DirectX
import CLR.Microsoft.DirectX.Direct3D

from CLR.Microsoft.DirectX import Matrix
from CLR.Microsoft.DirectX.Direct3D import Device, PresentParameters,
SwapEffect, DeviceType, CreateFlags

class DirectXWindow(WinForms.Form):
    """A simple hello world app that demonstrates the essentials of
       winforms programming and event-based programming in Python."""

    def CreateDevice(self):
        presentParams = PresentParameters()
        presentParams.Windowed = True
        presentParams.SwapEffect = SwapEffect.Discard
        device = Device(0, DeviceType.Hardware, self,
CreateFlags.SoftwareVertexProcessing, presentParams)

    def __init__(self):
        self.Text = "DirectX Window"
        self.AutoScaleBaseSize = Size(100, 100)
        self.ClientSize = Size(400, 300);
        h = WinForms.SystemInformation.CaptionHeight
        self.MinimumSize = Size(392, (117 + h))
        self.CreateDevice()

    def run(self):
        WinForms.Application.Run(self)


def main():
    DirectXWindow().run()


if __name__ == '__main__':
    main()


I have the error:
> File "Directx.py", line 18, in CreateDevice
> TypeError: no constructor matches given arguments

Form the DirectX documentation, there are 3 constructors available:
public  Device (Int32, DeviceType, IntPtr, CreateFlags, PresentParameters)
public  Device (Int32, DeviceType, Control, CreateFlags, PresentParameters)
public  Device (IntPtr)

The Int32 is the DeviceNum (0).
DeviceType and CreateFlags are 2 enum.
PresentParameters is a Structure.

The 'help(Device)' does'nt work.
How can I display all the signature of all constructors ?

What is the problem ?

Thanks for the help.




More information about the PythonDotNet mailing list