C# OpenTK - Textured Quad

前端 未结 1 972
梦如初夏
梦如初夏 2021-01-07 03:38

I\'ve recently downloaded OpenTK. I\'ve created a basic game class and a quad. I\'ve tried rendering a texture in my quad but it doesn\'t work. Here\'s my code. This is the

相关标签:
1条回答
  • 2021-01-07 04:11

    Try replacing:

    GL.TexImage2D (TextureTarget.Texture2D, 0, PixelInternalFormat.Rgba, Texture.GetWidth(), Texture.GetHeight(), 0, OpenTK.Graphics.OpenGL.PixelFormat.Rgba, PixelType.Bitmap, data.Scan0);
    

    with:

    GL.TexImage2D (TextureTarget.Texture2D, 0, PixelInternalFormat.Rgba, Texture.GetWidth(), Texture.GetHeight(), 0, OpenTK.Graphics.OpenGL.PixelFormat.Bgra, PixelType.UnsignedByte, data.Scan0);
    GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureWrapS, TextureWrapMode.ClampToEdge);
    GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureWrapT, TextureWrapMode.ClampToEdge);
    

    This should solve it. In yours there are format issues where what you used is does not accurately represent how System.Drawing.Bitmap represents 32bpp Argb bitmaps.

    0 讨论(0)
提交回复
热议问题