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

Abierto
#329 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
4/5
Tiempo estimado
3-5 días
Aptitud para principiantes
52/100
Tipo de issue
Error
Claridad
Bastante claro
Estado de actividad
Activo
Stack tecnológico
csharp, github

Línea de trabajo

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.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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.
Lenguaje dominante
C#
Estrellas
20
Forks
97
Merge medio
8 d 1 h
PR fusionados (30 d)
4

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de MonoGame/docs.monogame.github.io

Todos los issues de MonoGame/docs.monogame.github.io

Issues similares

Más issues de C#

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.