0

我决定用 MonoGame 开始游戏开发,但我遇到了一个问题。

当我尝试使用 SpriteBatch 对象将精灵添加到屏幕上时,就像我在许多 XNA 教程中看到的那样,我得到了一个 OpenTK.Graphics.GraphicsErrorException。

    protected override void Draw (GameTime gameTime)
    {
        graphics.GraphicsDevice.Clear (Color.CornflowerBlue);

        spriteBatch.Begin();
        spriteBatch.Draw(spriteTexture, position, Color.White);
        spriteBatch.End(); // <—— Exception here

        base.Draw (gameTime);
    }

Exception.Message 说InvalidEnum

OpenTK.Graphics.GraphicsErrorException: InvalidEnum
  at OpenTK.Graphics.OpenGL.ErrorHelper.CheckErrors () [0x000c0] in /home/sam/Téléchargements/opentk/src/opentk/Source/OpenTK/Graphics/OpenGL/ErrorHelper.cs:118
  at OpenTK.Graphics.OpenGL.ErrorHelper.Dispose () [0x00000] in /home/sam/Téléchargements/opentk/src/opentk/Source/OpenTK/Graphics/OpenGL/ErrorHelper.cs:129
  at OpenTK.Graphics.OpenGL.GL.TexEnv (TextureEnvTarget target, TextureEnvParameter pname, Int32 param) [0x0001e] in /home/sam/Téléchargements/opentk/src/opentk/Source/OpenTK/Graphics/OpenGL/GL.cs:69308
  at Microsoft.Xna.Framework.Graphics.SpriteBatch.End () [0x00000] in <filename unknown>:0
  at FirstGame.Game1.Draw (Microsoft.Xna.Framework.GameTime gameTime) [0x0003c] in /home/sam/Developpement/C#/Test/FirstGame/Game1.cs:82
  at Microsoft.Xna.Framework.Game.DoDraw (Microsoft.Xna.Framework.GameTime gameTime) [0x00000] in <filename unknown>:0
  at Microsoft.Xna.Framework.GameWindow.OnRenderFrame (System.Object sender, OpenTK.FrameEventArgs e) [0x00000] in <filename unknown>:0
  at OpenTK.GameWindow.OnRenderFrame (OpenTK.FrameEventArgs e) [0x0000b] in /home/sam/Téléchargements/opentk/src/opentk/Source/OpenTK/GameWindow.cs:976
  at OpenTK.GameWindow.OnRenderFrameInternal (OpenTK.FrameEventArgs e) [0x00016] in /home/sam/Téléchargements/opentk/src/opentk/Source/OpenTK/GameWindow.cs:1032
  at OpenTK.GameWindow.RaiseRenderFrame (System.Diagnostics.Stopwatch render_watch, System.Double& next_render, OpenTK.FrameEventArgs render_args) [0x00104] in /home/sam/Téléchargements/opentk/src/opentk/Source/OpenTK/GameWindow.cs:527
  at OpenTK.GameWindow.DispatchUpdateAndRenderFrame (System.Object sender, System.EventArgs e) [0x00018] in /home/sam/Téléchargements/opentk/src/opentk/Source/OpenTK/GameWindow.cs:433
  at OpenTK.GameWindow.Run (Double updates_per_second, Double frames_per_second) [0x000d5] in /home/sam/Téléchargements/opentk/src/opentk/Source/OpenTK/GameWindow.cs:411
  at OpenTK.GameWindow.Run (Double updateRate) [0x00000] in /home/sam/Téléchargements/opentk/src/opentk/Source/OpenTK/GameWindow.cs:358
  at Microsoft.Xna.Framework.GameWindow.Run (Double updateRate) [0x00000] in <filename unknown>:0
  at Microsoft.Xna.Framework.LinuxGamePlatform.RunLoop () [0x00000] in <filename unknown>:0
  at Microsoft.Xna.Framework.Game.Run (GameRunBehavior runBehavior) [0x00000] in <filename unknown>:0
  at Microsoft.Xna.Framework.Game.Run () [0x00000] in <filename unknown>:0
  at FirstGame.Program.Main () [0x0000a] in /home/sam/Developpement/C#/Test/FirstGame/Program.cs:21

就像这是非常基本的东西,我不知道我是否错过了什么……</p>

我在最新的 ArchLinux 安装下使用来自 MonoDevelop 的 MonoGame 版本 2.5.10。Mono 版本是 2.10.8,OpenTK 版本是最新的稳定版本(2010.10.06)。

4

0 回答 0