using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using Microsoft.DirectX;
using Microsoft.DirectX.Direct3D;
namespace DXChpOne
{
/// <summary>
/// Summary description for Form1.
/// </summary>
public class Form1 : System.Windows.Forms.Form
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.Container components = null;
private Device device = null;
//page 9 and 10, DX Kick Start
public void InitializeGraphics()
{
//Set our presentation parameters
PresentParameters presentParams = new PresentParameters();
presentParams.Windowed = true;
presentParams.SwapEffect = SwapEffect.Discard;
//Create our device
device = new Device(0, DeviceType.Hardware, this, CreateFlags.SoftwareVertexProcessing, presentParams);
}
public Form1()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
//
// TODO: Add any constructor code after InitializeComponent call
//
}
/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(292, 266);
this.Name = "Form1";
this.Text = "Form1";
this.Load += new System.EventHandler(this.Form1_Load);
}
#endregion
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
//page 11 DX Kick Start
using (Form1 frm = new Form1())
{
//Show our form and initialize our graphics engine
frm.Show();
frm.InitializeGraphics();
Application.Run(new Form1());
}
}
private void Form1_Load(object sender, System.EventArgs e)
{
}
}
}
Please help debug simple DirectX app
I have the book "Managed Direct X 9 Graphics and Game Programming" Kick Start by Tom Miller.
I am trying to run the sample code for Chapter 1 which does nothing more than initialize the graphics device (does no drawing yet).
I get a runtime error when I try to run the application.
'DefaultDomain': Loaded 'c:\windows\microsoft.net\framework\v1.0.3705\mscorlib.dll', No symbols loaded.
'DXChpOne': Loaded 'C:\Documents and Settings\Syndi\Desktop\DXChpOne\bin\Debug\DXChpOne.exe', Symbols loaded.
'DXChpOne.exe': Loaded 'c:\windows\assembly\gac\system.windows.forms\1.0.3300.0__b77a5c561934e089\system.windows.forms.dll', No symbols loaded.
'DXChpOne.exe': Loaded 'c:\windows\assembly\gac\system\1.0.3300.0__b77a5c561934e089\system.dll', No symbols loaded.
'DXChpOne.exe': Loaded 'c:\windows\assembly\gac\system.drawing\1.0.3300.0__b03f5f7f11d50a3a\system.drawing.dll', No symbols loaded.
'DXChpOne.exe': Loaded 'c:\windows\assembly\gac\microsoft.directx.direct3d\1.0.2902.0__31bf3856ad364e35\microsoft.directx.direct3d.dll', No symbols loaded.
'DXChpOne.exe': Loaded 'c:\windows\assembly\gac\system.drawing\1.0.5000.0__b03f5f7f11d50a3a\system.drawing.dll', No symbols loaded.
'DXChpOne.exe': Loaded 'c:\windows\assembly\gac\accessibility\1.0.3300.0__b03f5f7f11d50a3a\accessibility.dll', No symbols loaded.
'DXChpOne.exe': Loaded 'c:\windows\assembly\gac\system.windows.forms\1.0.5000.0__b77a5c561934e089\system.windows.forms.dll', No symbols loaded.
'DXChpOne.exe': Loaded 'c:\windows\assembly\gac\system\1.0.5000.0__b77a5c561934e089\system.dll', No symbols loaded.
'DXChpOne.exe': Loaded 'c:\windows\assembly\gac\microsoft.directx\1.0.2902.0__31bf3856ad364e35\microsoft.directx.dll', No symbols loaded.
An unhandled exception of type 'Microsoft.DirectX.Direct3D.InvalidCallException' occurred in microsoft.directx.direct3d.dll
Additional information: Error in the application.
Unhandled Exception: Error in the application.
-2005530516 (D3DERR_INVALIDCALL)
at Microsoft.DirectX.Direct3D.Device..ctor(Int32 adapter, DeviceType deviceType, Control renderWindow, CreateFlags behaviorFlags, PresentParameters[] presentationParameters)
at DXChpOne.Form1.InitializeGraphics() in c:\documents and settings\syndi\desktop\dxchpone\form1.cs:line 35
at DXChpOne.Form1.Main() in c:\documents and settings\syndi\desktop\dxchpone\form1.cs:line 94The program '[564] DXChpOne.exe' has exited with code 0 (0x0).
Here is line 35:
//Create our device
device = new Device(0, DeviceType.Hardware, this, CreateFlags.SoftwareVertexProcessing, presentParams);
Here is the code:
Is there some place online I can lookup these kinds of errors, by the way? :
-2005530516 (D3DERR_INVALIDCALL)
To get more information on what this means?
-2005530516 (D3DERR_INVALIDCALL)
To get more information on what this means?
I'm guessing it's failing because you didn't pass what format you want to use to PresentParameters so try adding this line
presentParams.BackBufferFormat = Format.Unknown;
And to look up what the errors mean you can always take a look at msdn
EDIT: gah! typo
presentParams.BackBufferFormat = Format.Unknown;
And to look up what the errors mean you can always take a look at msdn
EDIT: gah! typo
Quote:Original post by setaglib
I'm guessing it's failing because you didn't pass what format you want to use to PresentParameters so try adding this line
presentParams.Format = BackBufferFormat = Format.Unknown;
And to look up what the errors mean you can always take a look at msdn
One thing that helped (I tried this before realizing you had posted) was to compile in RELEASE mode vs DEBUG. This cleaned-up the problem.
Duh, I should have remembered that DirectX is quirky in DEBUG mode.
Quote:Original post by Tom Knowlton
One thing that helped (I tried this before realizing you had posted) was to compile in RELEASE mode vs DEBUG. This cleaned-up the problem.
Duh, I should have remembered that DirectX is quirky in DEBUG mode.
Cool didn't know that it would work without that line.
Anyway, I never had problems in debug mode maybe because I have an older version? [smile]
The debug mode is trying to warn you that you have done something that is considered unsafe/unwise. It may work in relase mode on your machine, and not work on another. It is always best to eliminate those debug warnings/errors so you know you won't run into problems later.
Quote:Original post by Dave Hunt
The debug mode is trying to warn you that you have done something that is considered unsafe/unwise. It may work in relase mode on your machine, and not work on another. It is always best to eliminate those debug warnings/errors so you know you won't run into problems later.
The problem is back. Now, even Release MODE is not making a difference.
The Format line of code would not compile, btw.
What do I do now?
Why doesn't that line compile what error does it give you?
Did you notice I edited the post? Because I had a little copy/paste trouble there earlier [embarrass]
Did you notice I edited the post? Because I had a little copy/paste trouble there earlier [embarrass]
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement