I upgraded from MonoGame 3.2 to MonoGame 3.4 and I have some sprites that are not appearing after the upgrade.
GL.TexImage2D(TextureTarget.Texture2D, 0, glInternalFormat, this.width, this.height, 0, glFormat, glType, IntPtr.Zero);
GraphicsExtensions.CheckGLError();
var elementSizeInByte = ReflectionHelpers.SizeOf<T>.Get();
var dataHandle = GCHandle.Alloc(data, GCHandleType.Pinned);
// Use try..finally to make sure dataHandle is freed in case of an error
try
{
var startBytes = startIndex * elementSizeInByte;
var dataPtr = new IntPtr(dataHandle.AddrOfPinnedObject().ToInt64() + startBytes);
// Store the current bound texture.
var prevTexture = GraphicsExtensions.GetBoundTexture2D();
if (prevTexture != glTexture)
{
GL.BindTexture(TextureTarget.Texture2D, glTexture);
GraphicsExtensions.CheckGLError();
}
GenerateGLTextureIfRequired();
GL.PixelStore(PixelStoreParameter.UnpackAlignment, Math.Min(_format.GetSize(), 8));
if (glFormat == (PixelFormat)GLPixelFormat.CompressedTextureFormats)
{
GraphicsExtensions.CheckGLError();
Reveals the error:
Microsoft.Xna.Framework.Graphics.MonoGameGLException: GL.GetError() returned InvalidValue
The parameters being used are:
glInternalFormat = OpenTK.Graphics.ES20.PixelInternalFormat.Rgba
this.width = 3840
this.height = 624
glFormat = OpenTK.Graphics.ES20.PixelFormat.Rgba
glType = OpenTK.Graphics.ES20.PixelType.UnsignedByte
Same issue and parameters here.
GraphicsExtensions.CheckGLError();
#endif
// Restore the bound texture.
if (prevTexture != glTexture)
{
GL.BindTexture(TextureTarget.Texture2D, prevTexture);
GraphicsExtensions.CheckGLError();
}
}
finally
{
dataHandle.Free();
}
});
}
private void PlatformGetData<T>(int level, int arraySlice, Rectangle rect, T[] data, int startIndex, int elementCount) where T : struct
{
Threading.EnsureUIThread();
#if GLES
I’ll keep digging around…
This is likely device specific. I didn’t see this error on Razer Forge TV. I’m seeing the error on OUYA. I have missing sprite issues on both devices. Tracking it down…
Thanks,
~Tim Graupmann
Is that width and height correct? They seem to be odd values.
The port project has a bunch of odd sized textures with sprite sheets. It could be Forge TV is okay with a 4k texture where OUYA has a 2k texture limit.
Given that, both consoles have issues displaying sprites after the upgrade. But the issue is like sprites are being culled and I need to track down the draw calls. It could be a blending issue or a depth issue or something else.
I found the issue.
It’s something related to layerDepth handling that changed between MG 3.2 and MG 3.4.
If I set the layerDepth to zero I can see the sprites fighting, but I least now I know they are being drawn.
spriteBatch.Draw (Texture2D texture,
Rectangle destinationRectangle,
Rectangle? sourceRectangle,
Color color,
float rotation,
Vector2 origin,
SpriteEffects effects,
float layerDepth)