SDL_render first draft done.

This commit is contained in:
Ethan Lee 2013-04-04 04:18:59 -04:00
parent 97b982d3f5
commit de5f266324
3 changed files with 351 additions and 6 deletions

2
README
View file

@ -27,5 +27,7 @@ Roadmap
- Implement the SDL2 libraries.
- For SDL2 itself, organize it according to this API reference page:
http://wiki.libsdl.org/moin.fcg/APIByCategory
- Document the SDL2 methods.
- I have some parameter info, but having full SDL2 docs would be great.
- Add OpenGL and OpenAL support.
- Just rip this off of OpenTK for now. Too much work, not enough time...

View file

@ -20,6 +20,7 @@
<WarningLevel>4</WarningLevel>
<PlatformTarget>x86</PlatformTarget>
<ConsolePause>false</ConsolePause>
<additionalargs>/unsafe</additionalargs>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
<DebugType>none</DebugType>
@ -29,6 +30,7 @@
<WarningLevel>4</WarningLevel>
<PlatformTarget>x86</PlatformTarget>
<ConsolePause>false</ConsolePause>
<additionalargs>/unsafe</additionalargs>
</PropertyGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<ItemGroup>

View file

@ -831,10 +831,348 @@ namespace SDL2
#region SDL_render.h
/* TODO: SDL_render.h:
* http://wiki.libsdl.org/moin.fcg/CategoryRender
* http://hg.libsdl.org/SDL/file/default/include/SDL_render.h
*/
public enum SDL_RendererFlags
{
SDL_RENDERER_SOFTWARE = 0x00000001,
SDL_RENDERER_ACCELERATED = 0x00000002,
SDL_RENDERER_PRESENTVSYNC = 0x00000004,
SDL_RENDERER_TARGETTEXTURE = 0x00000008
}
public enum SDL_RendererFlip
{
SDL_FLIP_NONE = 0x00000000,
SDL_FLIP_HORIZONTAL = 0x00000001,
SDL_FLIP_VERTICAL = 0x00000002
}
public enum SDL_TextureAccess
{
SDL_TEXTUREACCES_STATIC,
SDL_TEXTUREACCESS_STREAMING,
SDL_TEXTUREACCESS_TARGET
}
public enum SDL_TextureModulate
{
SDL_TEXTUREMODULATE_NONE = 0x00000000,
SDL_TEXTUREMODULATE_HORIZONTAL = 0x00000001,
SDL_TEXTUREMODULATE_VERTICAL = 0x00000002
}
[StructLayout(LayoutKind.Sequential)]
public unsafe struct SDL_RendererInfo
{
public string name; // const char*
public uint flags;
public uint num_texture_formats;
public fixed uint texture_formats[16];
public int max_texture_width;
public int max_texture_height;
}
/* IntPtr refers to an SDL_Renderer*, window to an SDL_Window* */
[DllImport(nativeLibName)]
public static extern IntPtr SDL_CreateRenderer(
IntPtr window,
int index,
uint flags
);
/* IntPtr refers to an SDL_Renderer* */
[DllImport(nativeLibName)]
public static extern IntPtr SDL_CreateRenderer(
ref SDL_Surface surface
);
/* IntPtr refers to an SDL_Texture*, renderer to an SDL_Renderer* */
[DllImport(nativeLibName)]
public static extern IntPtr SDL_CreateTexture(
IntPtr renderer,
uint format,
int access,
int w,
int h
);
/* IntPtr refers to an SDL_Texture*, renderer to an SDL_Renderer* */
[DllImport(nativeLibName)]
public static extern IntPtr SDL_CreateTextureFromSurface(
IntPtr renderer,
ref SDL_Surface surface
);
/* renderer refers to an SDL_Renderer* */
[DllImport(nativeLibName)]
public static extern void SDL_DestroyRenderer(IntPtr renderer);
/* texture refers to an SDL_Texture* */
[DllImport(nativeLibName)]
public static extern void SDL_DestroyTexture(IntPtr texture);
[DllImport(nativeLibName)]
public static extern int SDL_GetNumRenderDrivers();
/* renderer refers to an SDL_Renderer* */
[DllImport(nativeLibName)]
public static extern int SDL_GetRenderDrawBlendMode(
IntPtr renderer,
ref SDL_BlendMode blendMode
);
/* renderer refers to an SDL_Renderer* */
[DllImport(nativeLibName)]
public static extern int SDL_GetRenderDrawColor(
IntPtr renderer,
ref byte r,
ref byte g,
ref byte b,
ref byte a
);
[DllImport(nativeLibName)]
public static extern int SDL_GetRenderDriverInfo(
int index,
ref SDL_RendererInfo info
);
/* IntPtr refers to an SDL_Renderer*, window to an SDL_Window* */
[DllImport(nativeLibName)]
public static extern IntPtr SDL_GetRenderer(IntPtr window);
/* renderer refers to an SDL_Renderer* */
[DllImport(nativeLibName)]
public static extern int SDL_GetRendererInfo(
IntPtr renderer,
ref SDL_RendererInfo info
);
/* texture refers to an SDL_Texture* */
[DllImport(nativeLibName)]
public static extern int SDL_GetTextureAlphaMod(
IntPtr texture,
ref byte alpha
);
/* texture refers to an SDL_Texture* */
[DllImport(nativeLibName)]
public static extern int SDL_GetTextureBlendMode(
IntPtr texture,
ref SDL_BlendMode blendMode
);
/* texture refers to an SDL_Texture* */
[DllImport(nativeLibName)]
public static extern int SDL_GetTextureColorMod(
IntPtr texture,
ref byte r,
ref byte g,
ref byte b
);
/* texture refers to an SDL_Texture*, pixels to a void* */
[DllImport(nativeLibName)]
public static extern int SDL_LockTexture(
IntPtr texture,
ref SDL_Rect rect,
ref IntPtr pixels,
ref int pitch
);
/* texture refers to an SDL_Texture* */
[DllImport(nativeLibName)]
public static extern int SDL_QueryTexture(
IntPtr texture,
ref uint format,
ref int access,
ref int w,
ref int h
);
/* texture refers to an SDL_Texture, pixels to a void* */
[DllImport(nativeLibName)]
public static extern int SDL_QueryTexturePixels(
IntPtr texture,
ref IntPtr pixels,
ref int pitch
);
/* renderer refers to an SDL_Renderer* */
[DllImport(nativeLibName)]
public static extern int SDL_RenderClear(IntPtr renderer);
/* renderer refers to an SDL_Renderer*, texture to an SDL_Texture* */
[DllImport(nativeLibName)]
public static extern int SDL_RenderCopy(
IntPtr renderer,
IntPtr texture,
ref SDL_Rect srcrect,
ref SDL_Rect dstrect
);
/* renderer refers to an SDL_Renderer*, texture to an SDL_Texture* */
[DllImport(nativeLibName)]
public static extern int SDL_RenderCopyEx(
IntPtr renderer,
IntPtr texture,
ref SDL_Rect srcrect,
ref SDL_Rect dstrect,
double angle,
ref SDL_Point center,
SDL_RendererFlip flip
);
/* renderer refers to an SDL_Renderer* */
[DllImport(nativeLibName)]
public static extern int SDL_RenderDrawLine(
IntPtr renderer,
int x1,
int y1,
int x2,
int y2
);
/* renderer refers to an SDL_Renderer* */
[DllImport(nativeLibName)]
public static extern int SDL_RenderDrawLines(
IntPtr renderer,
SDL_Point[] points,
int count
);
/* renderer refers to an SDL_Renderer* */
[DllImport(nativeLibName)]
public static extern int SDL_RenderDrawPoint(
IntPtr renderer,
int x,
int y
);
/* renderer refers to an SDL_Renderer* */
[DllImport(nativeLibName)]
public static extern int SDL_RenderDrawPoints(
IntPtr renderer,
SDL_Point[] points,
int count
);
/* renderer refers to an SDL_Renderer* */
[DllImport(nativeLibName)]
public static extern int SDL_RenderDrawRect(
IntPtr renderer,
ref SDL_Rect rect
);
/* renderer refers to an SDL_Renderer* */
[DllImport(nativeLibName)]
public static extern int SDL_RenderDrawRects(
IntPtr renderer,
SDL_Rect[] rects,
int count
);
/* renderer refers to an SDL_Renderer* */
[DllImport(nativeLibName)]
public static extern int SDL_RenderFillRect(
IntPtr renderer,
ref SDL_Rect rect
);
/* renderer refers to an SDL_Renderer* */
[DllImport(nativeLibName)]
public static extern int SDL_RenderFillRects(
IntPtr renderer,
SDL_Rect[] rects,
int count
);
/* renderer refers to an SDL_Renderer* */
[DllImport(nativeLibName)]
public static extern int SDL_RendererGetViewport(
IntPtr renderer,
ref SDL_Rect rect
);
/* renderer refers to an SDL_Renderer* */
[DllImport(nativeLibName)]
public static extern void SDL_RenderPresent(IntPtr renderer);
/* renderer refers to an SDL_Renderer* */
[DllImport(nativeLibName)]
public static extern int SDL_RenderReadPixels(
IntPtr renderer,
ref SDL_Rect rect,
uint format,
IntPtr pixels,
int pitch
);
/* renderer refers to an SDL_Renderer* */
[DllImport(nativeLibName)]
public static extern int SDL_RenderSetViewport(
IntPtr renderer,
ref SDL_Rect rect
);
/* renderer refers to an SDL_Renderer* */
[DllImport(nativeLibName)]
public static extern int SDL_SetRenderDrawBlendMode(
IntPtr renderer,
SDL_BlendMode blendMode
);
/* renderer refers to an SDL_Renderer* */
[DllImport(nativeLibName)]
public static extern int SDL_SetRenderDrawColor(
IntPtr renderer,
byte r,
byte g,
byte b,
byte a
);
/* renderer refers to an SDL_Renderer*, texture to an SDL_Texture* */
[DllImport(nativeLibName)]
public static extern int SDL_SetRenderTarget(
IntPtr renderer,
IntPtr texture
);
/* texture refers to an SDL_Texture* */
[DllImport(nativeLibName)]
public static extern int SDL_SetTextureAlphaMod(
IntPtr texture,
byte alpha
);
/* texture refers to an SDL_Texture* */
[DllImport(nativeLibName)]
public static extern int SDL_SetTextureBlendMode(
IntPtr texture,
SDL_BlendMode blendMode
);
/* texture refers to an SDL_Texture* */
[DllImport(nativeLibName)]
public static extern int SDL_SetTextureColorMod(
IntPtr texture,
byte r,
byte g,
byte b
);
/* texture refers to an SDL_Texture* */
[DllImport(nativeLibName)]
public static extern void SDL_UnlockTexture(IntPtr texture);
/* texture refers to an SDL_Texture* */
[DllImport(nativeLibName)]
public static extern int SDL_UpdateTexture(
IntPtr texture,
ref SDL_Rect rect,
IntPtr pixels,
int pitch
);
#endregion
@ -849,12 +1187,14 @@ namespace SDL2
#region SDL_rect.h
[StructLayout(LayoutKind.Sequential)]
public struct SDL_Point
{
public int x;
public int y;
}
[StructLayout(LayoutKind.Sequential)]
public struct SDL_Rect
{
public int x;
@ -913,6 +1253,7 @@ namespace SDL2
#region SDL_surface.h
[StructLayout(LayoutKind.Sequential)]
public struct SDL_Surface
{
// TODO...