using System.Windows.Forms;
using System.Drawing.Color;
using Microsoft.DirectX;
using Microsoft.DirectX.Direct3D;
public class D3DForm : Form
{
private device : Device;
public this(title : string)
{
base();
Text = title;
def presentParams = PresentParameters();
presentParams.Windowed = false;
presentParams.SwapEffect = SwapEffect.Discard;
/*
presentParams.BackBufferHeight = Height;
presentParams.BackBufferWidth = Width;
presentParams.BackBufferCount = 1;
presentParams.BackBufferFormat = Format.A8R8G8B8;
presentParams.PresentationInterval = PresentInterval.Immediate;
presentParams.EnableAutoDepthStencil = true;
presentParams.AutoDepthStencilFormat = DepthFormat.D32;
*/
try
{
device = Device(0,
DeviceType.Hardware,
this : Control,
CreateFlags.SoftwareVertexProcessing,
presentParams)
}
catch
{
e is DirectXException =>
ignore( MessageBox.Show("Error initializing Direct3D!\n"
+ e.ToString()
+ "\n"
+ e.ErrorString
)
)
}
finally
{
}
}
static Main() : void
{
def win = D3DForm("Direct 3D window!");
win.Height = 600;
win.Width = 800;
win.BackColor = Blue;
Application.Run(win)
}
}
If I uncomment the presentParams I get D3DERR_NOTAVAILABLE instead.
Is there something wrong with this initialisation?
Quick help initalising D3D
Hey. I'm trying to write a D3D app in the .Net language Nemerle.
Anyway, it gives me D3DERR_INVALDCALL when I try to use the following init:
(it should be prettys traightforward even if you don't know Nemerle).
I would imagine that your D3DERR_INVALIDCALL is simply because you're creating your Device without fulling qualifying the presentParams struct.
So, you put it back in, and it's happy - because the function is getting a fully filled out param list. Problem is, the underlying hardware/driver is NOT capable of doing something you want - hence D3DERR_NOTSUPPORTED.
You really should be enumerating all of the functionality you're specifying!
You haven't specified what hardware you're running on, but DepthFormat.D32 might be your problem. 32Bit depth buffering is more common these days, but they're far from being universal. Conversely, a 16Bit depth buffer has been standard in pretty much all hardware you're likely to encounter. Try changing the respective line to use DepthFormat.D16 and see what happens [smile]
hth
Jack
So, you put it back in, and it's happy - because the function is getting a fully filled out param list. Problem is, the underlying hardware/driver is NOT capable of doing something you want - hence D3DERR_NOTSUPPORTED.
You really should be enumerating all of the functionality you're specifying!
You haven't specified what hardware you're running on, but DepthFormat.D32 might be your problem. 32Bit depth buffering is more common these days, but they're far from being universal. Conversely, a 16Bit depth buffer has been standard in pretty much all hardware you're likely to encounter. Try changing the respective line to use DepthFormat.D16 and see what happens [smile]
hth
Jack
Hmm.. I have an ATI Radeon 9800 pro and I thought D32 was supported...
Anyway, you got any hints on how to write a general enumerating function.. Basically a function where I pass it "I want this, get me the closest possible thing to this".
Anyway, you got any hints on how to write a general enumerating function.. Basically a function where I pass it "I want this, get me the closest possible thing to this".
Quote:Original post by sebastiansylvan
Hmm.. I have an ATI Radeon 9800 pro and I thought D32 was supported...
I've got a 9800 pro, and it only supports 4 modes: D3DFMT_D16_LOCKABLE, D3DFMT_D24S8, D3DFMT_D24X8, D3DFMT_D16. Whilst the middle two are, strictly speaking, 32bits wide they don't give you 32bits of depth precision [smile]
Quote:Original post by sebastiansylvan
you got any hints on how to write a general enumerating function.. Basically a function where I pass it "I want this, get me the closest possible thing to this".
The enumeration functions are quite well documented in the SDK, I'm in a hurry now (Grand Prix starts in 2mins[attention]) so I can't look up the exact names.
It can be difficult to have a general purpose function like you request as the things you'd enumerate are often some of the most important parts that have big impacts on the way your program works [smile] seleting a fallback isn't always easy...
Cheers,
Jack
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement