Skip to main content
gamedev.net
🔒 Locked

Another Managed DX9 problem

Started by Inkog 2 replies 450+ views
Original Post
Inkog
Inkog
I''m getting a compile error from the following code: . . using (VertexBuffer vb = mesh.VertexBuffer) { . . Compile error: Cannot implicitly convert type Microsoft.DirectX.Direct3D.Indexbuffer'' to ''System IDisposable'' Anyone have any idea why this is not compiling? I starting to wonder if my DX9 libaries are jacked. I have 2 of each DAC refrences for: Microsoft.DirectX Microsoft.DirectX.Direct3D Microsoft.DirectX.Direct3DX + the other DX items one is version 1.0.1901.0, the other 1.0.900.0 I use version 1.0.900.0 Are these correct? I''m assuminig this is from the summer DX SDK update. Is having both possibly causing issues? Due to lack of response from my last question, its becomming apparent that I''m one of the few using C# and managed DX9. Hopefully someone out there might have at least some suggestions, as their is really no other sources for information.
Arrummzen
Arrummzen
I haven''t learned to use meshes yet. I use both mangaged C++ and managed C# for my application.


using (VertexBuffer vb = mesh.VertexBuffer)
{


That is strange code, what are you trying to do. It looks legal, but its not logical.

Did you try to explicitly cast it? Use RTTI to make sure they are the same type at runtime...

Thank you for your time,
Arrummzen
Inkog
Inkog
Here is the code in context... And honestly I''m not sure why the author did it this way. This is from Tom Miller''s Managed DX9 book. I would assume it was correct concidering he wrote the API, but then again I''m having so much trouble with his code I begining to wonder .

.
.
_device.Transform.View = View;
_device.Transform.Projection = Project;

using (VertexBuffer vb = mesh.VertexBuffer)
{
using (IndexBuffer ib = mesh.IndexBuffer)
{
// Set the stream source
_device.SetStreamSource(0, vb, 0,
VertexInformation.GetFormatSize(mesh.VertexFormat));

// And the vertex format and indices
_device.VertexFormat = mesh.VertexFormat;
_device.Indices = ib;

_device.SetTexture(0, environment);
_device.SamplerState[0].MinFilter = TextureFilter.Linear;
_device.SamplerState[0].MagFilter = TextureFilter.Linear;
.
.

I was able to get it to work by nixing the using statements and replacing the ''vb'' with ''mesh.VertexBuffer'' etc. I would really love to know the reason behind that use.
roastedamoeba
roastedamoeba
Hi,

The problem is that you're using the original Managed DirectX dll's (1.0.900.0), whereas Tom Miller's code was designed to work with the Summer Update (1.0.1901.0).

In the original version, the VertexBuffer did not implement IDisposable, whereas in the Summer Update version it does.

Whenever you use that construct:


using (VertexBuffer vb = mesh.VertexBuffer)
{
...
}


it expands out into


VertexBuffer vb = mesh.VertexBuffer;
...
vb.Dispose();


... so you can see why the class must implement IDisposable.

Hope this helps.

Tim

[edited by - roastedamoeba on April 25, 2004 5:52:53 AM]

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.