No subject


Fri Feb 8 08:55:55 EST 2008


surface.w
surface.h
surface.pixels
etc.

Hope this helps.

BTW, I have updated Tao.Sdl a lot recently. Please do a checkout from CVS.
I recommend looking at the unit tests for code snippets to use when
marshaling pointers to structs.

Dave

> From: Jonathan Turner <joturner at vt.edu>
> To: mono-devel-list at lists.ximian.com
> Date: Wed, 11 Aug 2004 23:08:47 -0500
> Subject: [Mono-devel-list] IntPtr and accessing structures
>
> Hopefully this is the correct list.  I couldn't find a "mono-users" or
> "mono-beginner-developers" list.
>
> My question's pretty straight forward.
>
> I'm trying to connect to SDL using the Tao.Sdl.  I use:
>
> IntPtr mySurface = Sdl.SDL_SetVideoMode(640, 480, 16,
> Sdl.SDL_SWSURFACE);
>
> Which gives me a window.  That's great, exactly what I wanted.
>
> Now I want to access mySurface, but it's an IntPtr, so I can't access
> any members that are SDL_Surface type members.  I'm a C/C++ guy, so I
> think let's cast it.
>
> I try something like:
>
> unsafe {
>    Sdl.SDL_Surface *mySurfaceReal = (Sdl.SDL_Surface
*)mySurface.ToPointer
> ();
>    Console.WriteLine("Surface bytes per: {0}", mySurfaceReal->pitch);
>    Console.WriteLine("Width: {0}", mySurfaceReal->w);
>    Console.WriteLine("Height: {0}", mySurfaceReal->h);
>    Console.WriteLine("My address for pixels: {0}",
mySurfaceReal->pixels);
> }
>
> Which doesn't work.
>
> Any ideas?
>
> I'm trying to get to the pixels member, which is a pointer to the screen
> data.  Once I learn how to manipulate that I'm off and running, it's
> just these bits I can't seem to wrap my head around.
>
> Jonathan
>




More information about the Mono-devel-list mailing list