I finished porting my game project from XNA to SharpDX. Since the shader file I used in XNA (which was from riemers tut) doesn't work here anymore I wanted to use SharpDX's BasicEffect shader for rendering until I get myself into shader coding.

Unfortunatly this only works as long as I keep textures disabled.

If I set TextureEnabled = true the program crashes as soon as it tries to render a model with the following error:

D3D11 ERROR: ID3D11Device::CreateInputLayout: The provided input signature expects to read an element with SemanticName/Index: 'TEXCOORD'/0, but the declaration doesn't provide a matching name. [ STATE_CREATION ERROR #163: CREATEINPUTLAYOUT_MISSINGELEMENT]

Here's the code of my model render class:

using MetastormDX.Services; using SharpDX; using SharpDX.Direct3D11; using SharpDX.Toolkit.Graphics; namespace MetastormDX.Models { public static class ModelDrawer { /// <summary> /// Generic model drawing method. /// </summary> /// <param name="model">Model to be drawn.</param> /// <param name="modelTexture">Model textures.</param> /// <param name="modelPos">Current position of the model in world space.</param> /// <param name="modelRot">Current rotation of the model.</param> public static void DrawModel(Model model, Texture2DBase[] modelTexture, Vector3 modelPos, Quaternion modelRot) { Matrix worldMatrix = Matrix.Scaling(0.05f, 0.05f, 0.05f) * Matrix.RotationQuaternion(modelRot) * Matrix.Translation(modelPos); Matrix[] modelTransforms = new Matrix[model.Bones.Count]; model.CopyAbsoluteBoneTransformsTo(modelTransforms); int i = 0; foreach (ModelMesh mesh in model.Meshes) { foreach (BasicEffect effect in mesh.Effects) { BasicEffect currentEffect = effect; currentEffect.View = ScreenManager.ScreenManager.ViewMatrix; currentEffect.Projection = ScreenManager.ScreenManager.ProjectionMatrix; currentEffect.World = worldMatrix; currentEffect.TextureView = modelTexture[i++]; currentEffect.TextureEnabled = true; currentEffect.PreferPerPixelLighting = true; currentEffect.EnableDefaultLighting(); currentEffect.CurrentTechnique.Passes[0].Apply(); } mesh.Draw(GameServices.Graphics); } } } }