i can´t load a 3d model with sharpdx 2.6.2
this is my code
static void Main()
{
if (!SharpDevice.IsDirectX11Supported())
{
System.Windows.Forms.MessageBox.Show("DirectX11 Not Supported");
return;
}
//render form
RenderForm form = new RenderForm();
form.Text = "Tutorial 17: Query";
//frame rate counter
SharpFPS fpsCounter = new SharpFPS();
using (SharpDevice device = new SharpDevice(form))
{
//load font
SharpBatch font = new SharpBatch(device, "textfont.dds");
//load model from wavefront obj file
SharpMesh earth = SharpMesh.CreateFromObj(device, "../../../Models/planets/earth.obj");
SharpMesh moon = SharpMesh.CreateFromObj(device, "../../../Models/planets/moon.obj");
//init shader
SharpShader shader = new SharpShader(device, "../../HLSL.txt",
new SharpShaderDescription() { VertexShaderFunction = "VS", PixelShaderFunction = "PS" },
new InputElement[] {
new InputElement("POSITION", 0, Format.R32G32B32_Float, 0, 0),
new InputElement("NORMAL", 0, Format.R32G32B32_Float, 12, 0),
new InputElement("TEXCOORD", 0, Format.R32G32_Float, 24, 0)
});
//init constant buffer
Buffer11 buffer = shader.CreateBuffer<Data>();
Query pipelineQuery = new Query(device.Device, new QueryDescription() { Flags = QueryFlags.None, Type = QueryType.PipelineStatistics });
QueryDataPipelineStatistics stats = new QueryDataPipelineStatistics();
//init frame counter
fpsCounter.Reset();
int lastX = 0;
float currentAngle = 200;
form.MouseMove += (sender, e) =>
{
if (e.Button == System.Windows.Forms.MouseButtons.Left)
{
currentAngle += (lastX - e.X);
}
lastX = e.X;
};
//main loop
RenderLoop.Run(form, () =>
{
//Resizing
if (device.MustResize)
{
device.Resize();
font.Resize();
}
//apply states
device.UpdateAllStates();
//clear color
device.Clear(Color.CornflowerBlue);
//apply shader
shader.Apply();
//apply constant buffer to shader
device.DeviceContext.VertexShader.SetConstantBuffer(0, buffer);
device.DeviceContext.PixelShader.SetConstantBuffer(0, buffer);
//set transformation matrix
float ratio = (float)form.ClientRectangle.Width / (float)form.ClientRectangle.Height;
Matrix projection = Matrix.PerspectiveFovLH(3.14F / 3.0F, ratio, 1F, 1000.0F);
Matrix view = Matrix.LookAtLH(new Vector3(0, 0, -250), new Vector3(), Vector3.UnitY);
Matrix world = Matrix.Translation(0, 0, 200) * Matrix.RotationY(MathUtil.DegreesToRadians(currentAngle));
//light direction
Vector3 lightDirection = new Vector3(0.5f, 0, -1);
lightDirection.Normalize();
Data sceneInformation = new Data()
{
world = world,
worldViewProjection = world * view * projection,
lightDirection = new Vector4(lightDirection, 1)
};
//write data inside constant buffer
device.UpdateData<Data>(buffer, sceneInformation);
//draw mesh
moon.Begin();
for (int i = 0; i < moon.SubSets.Count; i++)
{
device.DeviceContext.PixelShader.SetShaderResource(0, moon.SubSets[i].DiffuseMap);
moon.Draw(i);
}
//begin analizing
device.DeviceContext.Begin(pipelineQuery);
world = Matrix.RotationY(Environment.TickCount / 2000.0F);
sceneInformation = new Data()
{
world = world,
worldViewProjection = world * view * projection,
lightDirection = new Vector4(lightDirection, 1)
};
//write data inside constant buffer
device.UpdateData<Data>(buffer, sceneInformation);
//draw mesh
earth.Begin();
for (int i = 0; i < earth.SubSets.Count; i++)
{
device.DeviceContext.PixelShader.SetShaderResource(0, earth.SubSets[i].DiffuseMap);
earth.Draw(i);
}
//end analizing
device.DeviceContext.End(pipelineQuery);
//get result
while (!device.DeviceContext.GetData<QueryDataPipelineStatistics>(pipelineQuery, AsynchronousFlags.None, out stats))
{
}
//begin drawing text
font.Begin();
//draw string
fpsCounter.Update();
font.DrawString("Earth Stats : FPS: " + fpsCounter.FPS, 0, 0, Color.White);
//print earth stats
font.DrawString("Earth Stats : Rotate Moon To Cover Earth ", 0, 30, Color.White);
font.DrawString(string.Format("Primitive Count: {0}", stats.IAPrimitiveCount), 0, 60, Color.White);
font.DrawString(string.Format("Vertex Count Count: {0}", stats.IAVerticeCount), 0, 90, Color.White);
font.DrawString(string.Format("Vertex Shader Execution: {0}", stats.VSInvocationCount), 0, 120, Color.White);
font.DrawString(string.Format("Pixel Shader Execution: {0}", stats.PSInvocationCount), 0, 150, Color.White);
//flush text to view
font.End();
//present
device.Present();
});
//release resource
font.Dispose();
earth.Dispose();
moon.Dispose();
buffer.Dispose();
pipelineQuery.Dispose();
}
}
Error 1 The type 'SharpDX.Windows.RenderForm' is defined in an assembly that is not referenced. You must add a reference to assembly 'SharpDX, Version=2.6.0.0, Culture=neutral, PublicKeyToken=null'. C:\Users\Pedro\Dropbox\GAMES\NeoforceControls-SharpDX-master\Central\Code\Layout.cs 526 9 Central
Error 2 The best overloaded method match for 'SharpHelper.SharpDevice.SharpDevice(SharpDX.Windows.RenderForm, bool)' has some invalid arguments C:\Users\Pedro\Dropbox\GAMES\NeoforceControls-SharpDX-master\Central\Code\Layout.cs 526 37 Central
Error 3 Argument 1: cannot convert from 'SharpDX.Windows.RenderForm [c:\Users\Pedro\Dropbox\GAMES\NeoforceControls-SharpDX-master\packages\SharpDX.2.6.2\Bin\DirectX11-Signed-net40\SharpDX.dll]' to 'SharpDX.Windows.RenderForm' C:\Users\Pedro\Dropbox\GAMES\NeoforceControls-SharpDX-master\Central\Code\Layout.cs 526 53 Central
Error 4 The type 'SharpDX.Direct3D11.InputElement' is defined in an assembly that is not referenced. You must add a reference to assembly 'SharpDX.Direct3D11, Version=2.6.0.0, Culture=neutral, PublicKeyToken=null'. C:\Users\Pedro\Dropbox\GAMES\NeoforceControls-SharpDX-master\Central\Code\Layout.cs 536 13 Central
Error 5 The best overloaded method match for 'SharpHelper.SharpShader.SharpShader(SharpHelper.SharpDevice, string, SharpHelper.SharpShaderDescription, SharpDX.Direct3D11.InputElement[])' has some invalid arguments C:\Users\Pedro\Dropbox\GAMES\NeoforceControls-SharpDX-master\Central\Code\Layout.cs 536 34 Central
Error 6 Argument 4: cannot convert from 'SharpDX.Direct3D11.InputElement[] [c:\Users\Pedro\Dropbox\GAMES\NeoforceControls-SharpDX-master\packages\SharpDX.2.6.2\Bin\DirectX11-Signed-net40\SharpDX.Direct3D11.dll]' to 'SharpDX.Direct3D11.InputElement[]' C:\Users\Pedro\Dropbox\GAMES\NeoforceControls-SharpDX-master\Central\Code\Layout.cs 538 17 Central
Error 7 The type or namespace name 'Data' could not be found (are you missing a using directive or an assembly reference?) C:\Users\Pedro\Dropbox\GAMES\NeoforceControls-SharpDX-master\Central\Code\Layout.cs 545 51 Central
Error 8 The type 'SharpDX.Direct3D11.Device' is defined in an assembly that is not referenced. You must add a reference to assembly 'SharpDX.Direct3D11, Version=2.6.0.0, Culture=neutral, PublicKeyToken=null'. C:\Users\Pedro\Dropbox\GAMES\NeoforceControls-SharpDX-master\Central\Code\Layout.cs 547 13 Central
Error 9 The best overloaded method match for 'SharpDX.Direct3D11.Query.Query(SharpDX.Direct3D11.Device, SharpDX.Direct3D11.QueryDescription)' has some invalid arguments C:\Users\Pedro\Dropbox\GAMES\NeoforceControls-SharpDX-master\Central\Code\Layout.cs 547 35 Central
Error 10 Argument 1: cannot convert from 'SharpDX.Direct3D11.Device' to 'SharpDX.Direct3D11.Device [c:\Users\Pedro\Dropbox\GAMES\NeoforceControls-SharpDX-master\packages\SharpDX.2.6.2\Bin\DirectX11-Signed-net40\SharpDX.Direct3D11.dll]' C:\Users\Pedro\Dropbox\GAMES\NeoforceControls-SharpDX-master\Central\Code\Layout.cs 547 45 Central
Error 11 The best overloaded method match for 'SharpHelper.SharpDevice.Clear(SharpDX.Color4)' has some invalid arguments C:\Users\Pedro\Dropbox\GAMES\NeoforceControls-SharpDX-master\Central\Code\Layout.cs 580 17 Central
Error 12 The type 'SharpDX.Color4' is defined in an assembly that is not referenced. You must add a reference to assembly 'SharpDX, Version=2.6.0.0, Culture=neutral, PublicKeyToken=null'. C:\Users\Pedro\Dropbox\GAMES\NeoforceControls-SharpDX-master\Central\Code\Layout.cs 580 17 Central
Error 13 Argument 1: cannot convert from 'SharpDX.Color' to 'SharpDX.Color4' C:\Users\Pedro\Dropbox\GAMES\NeoforceControls-SharpDX-master\Central\Code\Layout.cs 580 30 Central
Error 14 The type 'SharpDX.Direct3D11.DeviceContext' is defined in an assembly that is not referenced. You must add a reference to assembly 'SharpDX.Direct3D11, Version=2.6.0.0, Culture=neutral, PublicKeyToken=null'. C:\Users\Pedro\Dropbox\GAMES\NeoforceControls-SharpDX-master\Central\Code\Layout.cs 587 17 Central
Error 15 'SharpDX.Direct3D11.DeviceContext' does not contain a definition for 'VertexShader' and no extension method 'VertexShader' accepting a first argument of type 'SharpDX.Direct3D11.DeviceContext' could be found (are you missing a using directive or an assembly reference?) C:\Users\Pedro\Dropbox\GAMES\NeoforceControls-SharpDX-master\Central\Code\Layout.cs 587 38 Central
Error 16 'SharpDX.Direct3D11.DeviceContext' does not contain a definition for 'PixelShader' and no extension method 'PixelShader' accepting a first argument of type 'SharpDX.Direct3D11.DeviceContext' could be found (are you missing a using directive or an assembly reference?) C:\Users\Pedro\Dropbox\GAMES\NeoforceControls-SharpDX-master\Central\Code\Layout.cs 588 38 Central
Error 17 The type or namespace name 'Data' could not be found (are you missing a using directive or an assembly reference?) C:\Users\Pedro\Dropbox\GAMES\NeoforceControls-SharpDX-master\Central\Code\Layout.cs 601 17 Central
Error 18 The type or namespace name 'Data' could not be found (are you missing a using directive or an assembly reference?) C:\Users\Pedro\Dropbox\GAMES\NeoforceControls-SharpDX-master\Central\Code\Layout.cs 601 45 Central
Error 19 The type or namespace name 'Data' could not be found (are you missing a using directive or an assembly reference?) C:\Users\Pedro\Dropbox\GAMES\NeoforceControls-SharpDX-master\Central\Code\Layout.cs 609 35 Central
Error 20 The type 'SharpDX.Direct3D11.ShaderResourceView' is defined in an assembly that is not referenced. You must add a reference to assembly 'SharpDX.Direct3D11, Version=2.6.0.0, Culture=neutral, PublicKeyToken=null'. C:\Users\Pedro\Dropbox\GAMES\NeoforceControls-SharpDX-master\Central\Code\Layout.cs 615 21 Central
Error 21 'SharpDX.Direct3D11.DeviceContext' does not contain a definition for 'PixelShader' and no extension method 'PixelShader' accepting a first argument of type 'SharpDX.Direct3D11.DeviceContext' could be found (are you missing a using directive or an assembly reference?) C:\Users\Pedro\Dropbox\GAMES\NeoforceControls-SharpDX-master\Central\Code\Layout.cs 615 42 Central
Error 22 'SharpDX.Direct3D11.DeviceContext' does not contain a definition for 'Begin' and no extension method 'Begin' accepting a first argument of type 'SharpDX.Direct3D11.DeviceContext' could be found (are you missing a using directive or an assembly reference?) C:\Users\Pedro\Dropbox\GAMES\NeoforceControls-SharpDX-master\Central\Code\Layout.cs 620 38 Central
Error 23 The type or namespace name 'Data' could not be found (are you missing a using directive or an assembly reference?) C:\Users\Pedro\Dropbox\GAMES\NeoforceControls-SharpDX-master\Central\Code\Layout.cs 623 40 Central
Error 24 The type or namespace name 'Data' could not be found (are you missing a using directive or an assembly reference?) C:\Users\Pedro\Dropbox\GAMES\NeoforceControls-SharpDX-master\Central\Code\Layout.cs 631 35 Central
Error 25 'SharpDX.Direct3D11.DeviceContext' does not contain a definition for 'PixelShader' and no extension method 'PixelShader' accepting a first argument of type 'SharpDX.Direct3D11.DeviceContext' could be found (are you missing a using directive or an assembly reference?) C:\Users\Pedro\Dropbox\GAMES\NeoforceControls-SharpDX-master\Central\Code\Layout.cs 637 42 Central
Error 26 'SharpDX.Direct3D11.DeviceContext' does not contain a definition for 'End' and no extension method 'End' accepting a first argument of type 'SharpDX.Direct3D11.DeviceContext' could be found (are you missing a using directive or an assembly reference?) C:\Users\Pedro\Dropbox\GAMES\NeoforceControls-SharpDX-master\Central\Code\Layout.cs 641 38 Central
Error 27 'SharpDX.Direct3D11.DeviceContext' does not contain a definition for 'GetData' and no extension method 'GetData' accepting a first argument of type 'SharpDX.Direct3D11.DeviceContext' could be found (are you missing a using directive or an assembly reference?) C:\Users\Pedro\Dropbox\GAMES\NeoforceControls-SharpDX-master\Central\Code\Layout.cs 644 46 Central
Error 28 The best overloaded method match for 'SharpHelper.SharpBatch.DrawString(string, int, int, SharpDX.Color)' has some invalid arguments C:\Users\Pedro\Dropbox\GAMES\NeoforceControls-SharpDX-master\Central\Code\Layout.cs 653 17 Central
Error 29 The type 'SharpDX.Color' is defined in an assembly that is not referenced. You must add a reference to assembly 'SharpDX, Version=2.6.0.0, Culture=neutral, PublicKeyToken=null'. C:\Users\Pedro\Dropbox\GAMES\NeoforceControls-SharpDX-master\Central\Code\Layout.cs 653 17 Central
Error 30 Argument 4: cannot convert from 'SharpDX.Color [c:\Users\Pedro\Dropbox\GAMES\NeoforceControls-SharpDX-master\packages\SharpDX.2.6.2\Bin\DirectX11-Signed-net40\SharpDX.dll]' to 'SharpDX.Color' C:\Users\Pedro\Dropbox\GAMES\NeoforceControls-SharpDX-master\Central\Code\Layout.cs 653 79 Central
Error 31 The best overloaded method match for 'SharpHelper.SharpBatch.DrawString(string, int, int, SharpDX.Color)' has some invalid arguments C:\Users\Pedro\Dropbox\GAMES\NeoforceControls-SharpDX-master\Central\Code\Layout.cs 656 17 Central
Error 32 Argument 4: cannot convert from 'SharpDX.Color [c:\Users\Pedro\Dropbox\GAMES\NeoforceControls-SharpDX-master\packages\SharpDX.2.6.2\Bin\DirectX11-Signed-net40\SharpDX.dll]' to 'SharpDX.Color' C:\Users\Pedro\Dropbox\GAMES\NeoforceControls-SharpDX-master\Central\Code\Layout.cs 656 85 Central
Error 33 The best overloaded method match for 'SharpHelper.SharpBatch.DrawString(string, int, int, SharpDX.Color)' has some invalid arguments C:\Users\Pedro\Dropbox\GAMES\NeoforceControls-SharpDX-master\Central\Code\Layout.cs 657 17 Central
Error 34 Argument 4: cannot convert from 'SharpDX.Color [c:\Users\Pedro\Dropbox\GAMES\NeoforceControls-SharpDX-master\packages\SharpDX.2.6.2\Bin\DirectX11-Signed-net40\SharpDX.dll]' to 'SharpDX.Color' C:\Users\Pedro\Dropbox\GAMES\NeoforceControls-SharpDX-master\Central\Code\Layout.cs 657 103 Central
Error 35 The best overloaded method match for 'SharpHelper.SharpBatch.DrawString(string, int, int, SharpDX.Color)' has some invalid arguments C:\Users\Pedro\Dropbox\GAMES\NeoforceControls-SharpDX-master\Central\Code\Layout.cs 658 17 Central
Error 36 Argument 4: cannot convert from 'SharpDX.Color [c:\Users\Pedro\Dropbox\GAMES\NeoforceControls-SharpDX-master\packages\SharpDX.2.6.2\Bin\DirectX11-Signed-net40\SharpDX.dll]' to 'SharpDX.Color' C:\Users\Pedro\Dropbox\GAMES\NeoforceControls-SharpDX-master\Central\Code\Layout.cs 658 104 Central
Error 37 The best overloaded method match for 'SharpHelper.SharpBatch.DrawString(string, int, int, SharpDX.Color)' has some invalid arguments C:\Users\Pedro\Dropbox\GAMES\NeoforceControls-SharpDX-master\Central\Code\Layout.cs 659 17 Central
Error 38 Argument 4: cannot convert from 'SharpDX.Color [c:\Users\Pedro\Dropbox\GAMES\NeoforceControls-SharpDX-master\packages\SharpDX.2.6.2\Bin\DirectX11-Signed-net40\SharpDX.dll]' to 'SharpDX.Color' C:\Users\Pedro\Dropbox\GAMES\NeoforceControls-SharpDX-master\Central\Code\Layout.cs 659 113 Central
Error 39 The best overloaded method match for 'SharpHelper.SharpBatch.DrawString(string, int, int, SharpDX.Color)' has some invalid arguments C:\Users\Pedro\Dropbox\GAMES\NeoforceControls-SharpDX-master\Central\Code\Layout.cs 660 17 Central
Error 40 Argument 4: cannot convert from 'SharpDX.Color [c:\Users\Pedro\Dropbox\GAMES\NeoforceControls-SharpDX-master\packages\SharpDX.2.6.2\Bin\DirectX11-Signed-net40\SharpDX.dll]' to 'SharpDX.Color' C:\Users\Pedro\Dropbox\GAMES\NeoforceControls-SharpDX-master\Central\Code\Layout.cs 660 112 Central