How to create a BasicEffect - Errors in Vulkan / OpenGL renderers

Open
#329 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
52/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Active
Tech stack
csharp, github
Domain
documentation

Research direction

Start with the linked Basic Effect guide and reproduce the issue using the linked BasicEffectFromEmptyGame project, running its DesktopVK and DesktopGL projects as described. Compare the guide’s example with the error and black triangle reported across the two renderers; done means the documented example runs without the Vulkan crash and displays the vertex colors in OpenGL.

Written by the indexing model from the issue text.

Description

What happened?

While trying to follow the How to create a Basic Effect guide, starting from the new Empty Game template, running the Platforms.DesktopVK project ended up crashing with the following error:

Unhandled exception. System.InvalidOperationException: An error occurred while preparing to draw. This is probably because the current vertex declaration does not include all the elements required by the current vertex shader. The current vertex declaration includes these elements: POSITION0, NORMAL0, COLOR0.
at Microsoft.Xna.Framework.Graphics.VertexInputLayout.GenerateInputElements(VertexAttribute[] inputs, MGG_InputElement[]& elements, Int32[]& strides)
at Microsoft.Xna.Framework.Graphics.Shader.GetOrCreateLayout(VertexBufferBindings vertexBuffers)
at Microsoft.Xna.Framework.Graphics.GraphicsDevice.PlatformApplyState(Boolean applyShaders)
at Microsoft.Xna.Framework.Graphics.GraphicsDevice.DrawUserPrimitives[T](PrimitiveType primitiveType, T[] vertexData, Int32 vertexOffset, Int32 primitiveCount, VertexDeclaration vertexDeclaration)
at BasicEffectFromEmptyGame.Game1.Draw(GameTime gameTime) in /home/sylvain/Programmes/Jeux/DungeonCrawlerTest (Copie)/Source/Game1.cs:line 99
at Microsoft.Xna.Framework.Game.DoDraw(GameTime gameTime)
at Microsoft.Xna.Framework.Game.Tick()
at Microsoft.Xna.Framework.NativeGamePlatform.RunLoop()
at Program.

$(String[] args) in /home/sylvain/Programmes/Jeux/DungeonCrawlerTest (Copie)/Platforms/DesktopVK/Program.cs:line 4

The same code when running the Platforms.DesktopGL project doesn't crash, but prints a black triangle (it should have been vertex colored):

Capture d’écran du 2026-11-16 13-00-17

I couldn't test the Platforms.DirectX12 build working on a Linux environment with the following specs:

  • OS: Ubuntu 24.04.5 LTS (64-bit)
  • GNOME version: 46
  • windowing system: X11
  • kernel version: Linux 7.0.0-43-generic

How to reproduce?

  1. Clone the reproduction repository: [https://github.com/raaaahman/BasicEffectFromEmptyGame][https://github.com/raaaahman/BasicEffectFromEmptyGame)
  2. Run dotnet run --project Platforms/DesktopVK/BasicEffectFromEmptyGame.DesktopVK.csproj and dotnet run --project Platforms/DesktopGL/BasicEffectFromEmptyGame.DesktopGL.csproj
  3. Optional. Comment Game1.cs: line 44 and run the projects again. Notice this doesn't change the issue.
Dominant language
C#
Stars
20
Forks
97
Avg merge
8d 1h
Merged PRs (30d)
4

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from MonoGame/docs.monogame.github.io

All issues in MonoGame/docs.monogame.github.io

Similar issues

More C# issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.