S
Sijmen Mulder
For my SDL wrapper, I wrote some code to correctly convert 256-color
palettes. That needed some interop, so this is what I did:
1. Added the native function definition to my interop class.
3. Added extra required structs to the interop class.
2. Added the call to the method.
But now I am getting this error, at runtime:
---
** ERROR **: Invalid IL code at IL0000 in
ManagedGL.Native.Sdl:SDL_SetColors
(ManagedGL.Native.Sdl/SDL_Surface*,ManagedGL.Native.Sdl/SDL_Color*,int,int):
IL_0000: stloc.s 48
---
Here is the interop definition:
---
[DllImport(SDL_DLL, CallingConvention=CallingConvention.Cdecl),
SuppressUnmanagedCodeSecurity]
public static extern int SDL_SetColors(SDL_Surface *surface, SDL_Color *colors,
int firstcolor, int ncolors);
---
Here are the definitions of the added structs:
---
[StructLayout(LayoutKind.Sequential, Pack=4)]
public struct SDL_Color
{
public byte r;
public byte g;
public byte b;
public byte unused;
}
[StructLayout(LayoutKind.Sequential, Pack=4)]
public struct SDL_Palette
{
public int ncolors;
public SDL_Color *colors;
}
---
Here, at final, is the call that caused all the problems:
---
Sdl.SDL_SetColors(ret.surface, surface->format->palette->colors, 0,
surface->format->palette->ncolors);
---
The platform on which I ran this is Linux/Mono/x86, nothing weird.
IMPORTANT NOTE: There are 10+ other native structs and 100+ more
functions declared in the interop class, they work great. They are defined
exactly the same as the new one.
To take a further look at the source files, checkout
www.sourceforge.net/projects/managedgl
Thanks in advance!
palettes. That needed some interop, so this is what I did:
1. Added the native function definition to my interop class.
3. Added extra required structs to the interop class.
2. Added the call to the method.
But now I am getting this error, at runtime:
---
** ERROR **: Invalid IL code at IL0000 in
ManagedGL.Native.Sdl:SDL_SetColors
(ManagedGL.Native.Sdl/SDL_Surface*,ManagedGL.Native.Sdl/SDL_Color*,int,int):
IL_0000: stloc.s 48
---
Here is the interop definition:
---
[DllImport(SDL_DLL, CallingConvention=CallingConvention.Cdecl),
SuppressUnmanagedCodeSecurity]
public static extern int SDL_SetColors(SDL_Surface *surface, SDL_Color *colors,
int firstcolor, int ncolors);
---
Here are the definitions of the added structs:
---
[StructLayout(LayoutKind.Sequential, Pack=4)]
public struct SDL_Color
{
public byte r;
public byte g;
public byte b;
public byte unused;
}
[StructLayout(LayoutKind.Sequential, Pack=4)]
public struct SDL_Palette
{
public int ncolors;
public SDL_Color *colors;
}
---
Here, at final, is the call that caused all the problems:
---
Sdl.SDL_SetColors(ret.surface, surface->format->palette->colors, 0,
surface->format->palette->ncolors);
---
The platform on which I ran this is Linux/Mono/x86, nothing weird.
IMPORTANT NOTE: There are 10+ other native structs and 100+ more
functions declared in the interop class, they work great. They are defined
exactly the same as the new one.
To take a further look at the source files, checkout
www.sourceforge.net/projects/managedgl
Thanks in advance!