Forum
Contact





DirectX using C#
DirectX using C++
DirectX using Visual Basic



Latest Forum posts

 Texture on a 3d Object
  Posted by: ToastbrotX
  When: 10/09/2010 at 10:23:08

 Unable to Build
  Posted by: Rich_Zap
  When: 09/09/2010 at 15:39:33

 HLSL calculating normals
  Posted by: Rich_Zap
  When: 09/09/2010 at 15:34:56

 Texture on a 3d Object
  Posted by: ToastbrotX
  When: 09/09/2010 at 11:14:19

 DRIVER ERROR XBOX 360
  Posted by: Anonymous
  When: 09/09/2010 at 01:12:47

 Reflection problem in corners ...
  Posted by: Anonymous
  When: 08/09/2010 at 21:03:35

 Texture on a 3d Object
  Posted by: radulph
  When: 08/09/2010 at 17:34:01

 InvalidDataException???
  Posted by: Anonymous
  When: 08/09/2010 at 09:10:36

 Unable to Build
  Posted by: Anonymous
  When: 08/09/2010 at 07:49:36

 Suggestion to change a few lines
  Posted by: Insomnica
  When: 06/09/2010 at 14:37:05

 Collision with series 1
  Posted by: radulph
  When: 05/09/2010 at 13:33:14

 HLSL calculating normals
  Posted by: miroslavign
  When: 04/09/2010 at 17:26:26

 Collision with series 1
  Posted by: ToastbrotX
  When: 04/09/2010 at 16:52:02

 HLSL calculating normals
  Posted by: Rich_Zap
  When: 04/09/2010 at 15:00:20

 Collision with series 1
  Posted by: ToastbrotX
  When: 04/09/2010 at 12:28:41

 HLSL calculating normals
  Posted by: miroslavign
  When: 04/09/2010 at 08:46:31

 Walk along a wall
  Posted by: Anonymous
  When: 03/09/2010 at 10:28:02

 model problems
  Posted by: muffinman
  When: 03/09/2010 at 06:47:32

 Vertices problem
  Posted by: Anonymous
  When: 03/09/2010 at 05:48:35

 OcTree Question
  Posted by: Zorzomezz
  When: 03/09/2010 at 04:07:03




Topic: DrawUserPrimitive Error



  
Goto parent category
  
Create a new user account


   DrawUserPrimitive Error
 Poster : Cronus
 Posts: 6
 Country : USA
 City: Seattle

  
Posted by Cronus on 05/09/2006 at 00:30:23
I have just started going through the DirectX C# tutorials here, and have had a few slight problems with version differences, but when calling DrawUserPrimitive from this example I get the error "error CS1503: Argument '3': cannot convert from 'Microsoft.DirectX.Direct3D.CustomVertex.TransformedColored[]' to 'Microsoft.DirectX.GraphicsBuffer'"

I have not been able to solve this error, nor have I been able to find any documentation anywhere on Microsoft.DirectX.GraphicsBuffer.

Here is my code.  Any help would be greatly appreciated.


        protected override void OnPaint(System.Windows.Forms.PaintEventArgs e)
        {
            Microsoft.DirectX.Direct3D.CustomVertex.TransformedColored[] vertices =
                new Microsoft.DirectX.Direct3D.CustomVertex.TransformedColored[3];
            vertices[0].Position = new Vector4(150f, 100f, 0f, 1f);
            vertices[0].Color = Color.Red;
            vertices[1].Position = new Vector4(this.Width / 2 + 100f, 100f, 0f, 1f);
            vertices[1].Color = Color.Green;
            vertices[2].Position = new Vector4(250f, 300f, 0f, 1f);
            vertices[2].Color = Color.Peru;

            device.Clear(ClearFlags.Target, Color.Blue, 1.0f, 0);
            device.BeginScene();
            device.VertexFormat = Microsoft.DirectX.Direct3D.CustomVertex.TransformedColored.Format;
            device.DrawUserPrimitives(PrimitiveType.TriangleList, 1, vertices);
            device.EndScene();
            device.Present();
        }
 Poster : Cronus
 Posts: 6
 Country : USA
 City: Seattle

  
Posted by Cronus on 05/09/2006 at 01:06:00
Ok, I have an update to my problem.  I deleted my DirectX Reference and rolled back to the 1.0.2902.0 version.  This allows the code to compile, however I get a runtime error of "System.BadImageFormatException.  This is not a valid Win32 application."

With the 1.0.2902.0 I cleared the file and pasted all of the lesson 2 code in, and was given the same runtime error.  I had been able to complete and run Lessons 1 and 2 without any problems with version 2.0.0.0 of DirectX.

Any help is appreciated.  Thanks in advance.
 Poster : riemer
 Posts: 1388
 Country : Belgium
 City: Antwerp

  
Posted by riemer on 05/09/2006 at 02:36:16
MDX 2.0 will never be officially completed, so the reference is there only to confuse people ;)
 Poster : Cronus
 Posts: 6
 Country : USA
 City: Seattle

  
Posted by Cronus on 05/09/2006 at 11:53:19
Do you have any idea why I would be getting the runtime errors, when compiling your code on the older version of MDX then?

Thanks,
Cronus
 Poster : riemer
 Posts: 1388
 Country : Belgium
 City: Antwerp

  
Posted by riemer on 05/09/2006 at 13:41:47
Sometimes when going from the April to the June version or so of the SDK, MS decides to change the interface to some methods, to make the whole more coherent. So you shouldn't be surprised to see a few major changes in the new 2.0 version.

It's a new wrapper. It's pretty difficult (or even useless) to change the inner clockwork of a wrapper without changing its interface.
 Poster : Anonymous
 Posts:
 Country :
 City:

  
Posted by Anonymous on 05/09/2006 at 14:23:52
I understand that, but I don't understand how I am supposed to pass in an array of vertices as a System.Object.  I have it as an array of CustomVertex.TransformedColored objects as described in your tutorial, but I can't figure out how to turn that data into a System.Object type, as per the new parameters of DrawUserPrimitive().  I don't know if I am missing some simple way to convert, or if it is supposed to be passed similiar to a void pointer?  It has me quite confused.

Thanks for the quick response.
-Cronus
 Poster : riemer
 Posts: 1388
 Country : Belgium
 City: Antwerp

  
Posted by riemer on 05/09/2006 at 15:34:18
Can't help you with that, I have almost no experience with MDX2.0, and I suggest you to revert to MDX1.0, as the 2.0 development has been abandoned.
 Poster : Cronus
 Posts: 6
 Country : USA
 City: Seattle

  
Posted by Cronus on 06/09/2006 at 00:08:49
I deleted my DirectX References and rolled back to the 1.0.2902.0 version.  This allows the code to compile, however I get a runtime error of "System.BadImageFormatException.  This is not a valid Win32 application."

I've tried opening some older DirectX tutorials with  references to 1.0.2902.0 and I get the same runtime error.  Do you know what I would have to do to get rid of this error?

Any help is appreciated.  Thanks in advance.
 Poster : Cronus
 Posts: 6
 Country : USA
 City: Seattle

  
Posted by Cronus on 06/09/2006 at 01:48:28
Ok, I have uninstalled my DirectX SDK and installed the April version, and when trying to compile your tutorial or any DirectX app I get a System.BadImageFormat Exception.  Do you have any idea how I can get rid of these?
 Poster : riemer
 Posts: 1388
 Country : Belgium
 City: Antwerp

  
Posted by riemer on 06/09/2006 at 02:49:26
You didn't have to uninstall you SDK ;)

the original MDX1.0 references are still included in the latest SDK release

Regarding your error, I think it's best to uninstall the SDK again and reinstall the newest one .. sorry for confusing you ;)
 Poster : Cronus
 Posts: 6
 Country : USA
 City: Seattle

  
Posted by Cronus on 07/09/2006 at 17:35:56
I had tried the older references in the newest SDK, which is what prompted me to try the older SDK's.  I did however get the code to compile, by using the older references, but I had to set the project to sepcifically compile to an x86 architecture.
    I am still not sure how to get the DrawUserPrimitive error to work with version 2.0 of the SDK, but I will simply continue my use of the older references with the projects set to the x86 architecture for the time being.
 Poster : Anonymous
 Posts:
 Country :
 City:

  
Posted by Anonymous on 12/01/2009 at 07:24:52
You can fix that by going into your CPU settings on the IDE. For some reason my error went away when I specified the x86 (instead of Any CPU as per the default)

  
Post a new reply
 





Google
 
Web www.riemers.net
If you appreciate the amount of time I spend creating and updating
these pages, feel free to donate -- any amount is welcome !
- Website design & DirectX code : Riemer Grootjans -
©2006 Riemer Grootjans


News
Home
Forum
XNA 2.0 Recipes Book (8)
XNA 3.0 Recipes Book (8)
Downloads
Extra Reading (3)
Matrices: geometrical
Matrix Mathematics
Homogenous matrices
Community Projects (1)
Tutorials (160)
XNA 3.0 using C# (89)
DirectX using C# (54)
Series 1:Terrain (14)
Opening a window
Linking to the Device
Drawing a triangle
Camera
Rotation - Translation
Indices
Terrain creation
Terrain from file
DirectInput
Importing bmp files
Colored vertices
DirectX Light basics
Mesh creation
Mesh lighting
Series 2: Flightsim (19)
Series 3: HLSL (19)
Short Tuts (2)
Resizing problem
Checking Device caps
DirectX using C++ (15)
DirectX using VB (2)