packages feed

SFML (empty) → 0.2.0.0

raw patch · 98 files changed

+10903/−0 lines, 98 filesdep +basesetup-changed

Dependencies added: base

Files

+ LICENSE view
@@ -0,0 +1,7 @@+Copyright (c) 2012 Marc Sunet++Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:++The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.++THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ SFML.cabal view
@@ -0,0 +1,132 @@+name:                SFML+version:             0.2.0.0+synopsis:            SFML bindings+description:+    Low level bindings for SFML 2.0.+license:             MIT+license-file:        LICENSE+author:              Marc Sunet+maintainer:          jeannekamikaze@gmail.com+homepage:            https://github.com/jeannekamikaze/SFML+bug-reports:         https://github.com/jeannekamikaze/SFML/issues+category:            Game+build-type:          Simple+cabal-version:       >=1.8++library+  hs-source-dirs:+      src++  exposed-modules:+      SFML.Audio+      SFML.Graphics+      SFML.System+      SFML.Window+      SFML.Audio.Listener+      SFML.Audio.Music+      SFML.Audio.SFSampled+      SFML.Audio.SFSound+      SFML.Audio.SFSoundBuffer+      SFML.Audio.SFSoundRecorder+      SFML.Audio.Sound+      SFML.Audio.SoundBuffer+      SFML.Audio.SoundBufferRecorder+      SFML.Audio.SoundRecorder+      SFML.Audio.SoundStatus+      SFML.Audio.SoundStream+      SFML.Audio.Types+      SFML.Graphics.BlendMode+      SFML.Graphics.CircleShape+      SFML.Graphics.Color+      SFML.Graphics.ConvexShape+      SFML.Graphics.Font+      SFML.Graphics.Glyph+      SFML.Graphics.Image+      SFML.Graphics.PrimitiveType+      SFML.Graphics.Rect+      SFML.Graphics.RectangleShape+      SFML.Graphics.RenderStates+      SFML.Graphics.RenderTexture+      SFML.Graphics.RenderWindow+      SFML.Graphics.SFBindable+      SFML.Graphics.SFBounded+      SFML.Graphics.SFCoordSpace+      SFML.Graphics.SFRenderTarget+      SFML.Graphics.SFShape+      SFML.Graphics.SFShapeResizable+      SFML.Graphics.SFSmoothTexture+      SFML.Graphics.SFTexturable+      SFML.Graphics.SFViewable+      SFML.Graphics.Shader+      SFML.Graphics.Shape+      SFML.Graphics.Sprite+      SFML.Graphics.Text+      SFML.Graphics.Texture+      SFML.Graphics.Transform+      SFML.Graphics.Transformable SFML.Graphics.Types+      SFML.Graphics.Vertex+      SFML.Graphics.VertexArray+      SFML.Graphics.View+      SFML.SFCopyable+      SFML.SFDisplayable+      SFML.SFResource+      SFML.System.Clock+      SFML.System.InputStream+      SFML.System.Sleep+      SFML.System.Time+      SFML.System.Vector2+      SFML.System.Vector3+      SFML.Utils+      SFML.Window.Context+      SFML.Window.ContextSettings+      SFML.Window.Event+      SFML.Window.Joystick+      SFML.Window.Keyboard+      SFML.Window.Mouse+      SFML.Window.SFWindow+      SFML.Window.Types+      SFML.Window.VideoMode+      SFML.Window.Window+      SFML.Window.WindowHandle++  c-sources:+      cbits/SFML/Audio/Listener_helper.c+      cbits/SFML/Audio/Music_helper.c+      cbits/SFML/Audio/Sound_helper.c+      cbits/SFML/Audio/SoundBuffer_helper.c+      cbits/SFML/Audio/SoundStream_helper.c+      cbits/SFML/Graphics/CircleShape_helper.c+      cbits/SFML/Graphics/ConvexShape_helper.c+      cbits/SFML/Graphics/Font_helper.c+      cbits/SFML/Graphics/Image_helper.c+      cbits/SFML/Graphics/RectangleShape_helper.c+      cbits/SFML/Graphics/RenderTexture_helper.c+      cbits/SFML/Graphics/RenderWindow_helper.c+      cbits/SFML/Graphics/Shader_helper.c+      cbits/SFML/Graphics/Shape_helper.c+      cbits/SFML/Graphics/Sprite_helper.c+      cbits/SFML/Graphics/Text_helper.c+      cbits/SFML/Graphics/Texture_helper.c+      cbits/SFML/Graphics/VertexArray_helper.c+      cbits/SFML/Graphics/View_helper.c+      cbits/SFML/System/Clock_helper.c+      cbits/SFML/System/Time_helper.c+      cbits/SFML/System/Sleep_helper.c+      cbits/SFML/Window/VideoMode_helper.c+      cbits/SFML/Window/Window_helper.c++  build-depends:+      base > 4 && < 5++  build-tools:+      hsc2hs -any++  extensions:+      ForeignFunctionInterface++  extra-libraries:+      csfml-window,+      csfml-system,+      csfml-graphics,+      csfml-network,+      csfml-audio
+ Setup.hs view
@@ -0,0 +1,2 @@+import Distribution.Simple+main = defaultMain
+ cbits/SFML/Audio/Listener_helper.c view
@@ -0,0 +1,26 @@+#include <SFML/Audio/Listener.h>+++void sfListener_setPosition_helper (sfVector3f* position)+{+    sfListener_setPosition (*position);+}+++void sfListener_getPosition_helper (sfVector3f* position)+{+    *position = sfListener_getPosition ();+}+++void sfListener_setDirection_helper (sfVector3f* orientation)+{+    sfListener_setDirection (*orientation);+}+++void sfListener_getDirection_helper (sfVector3f* direction)+{+    *direction = sfListener_getDirection ();+}+
+ cbits/SFML/Audio/Music_helper.c view
@@ -0,0 +1,26 @@+#include <SFML/Audio/Music.h>+++void sfMusic_getDuration_helper (const sfMusic* music, sfTime* time)+{+    *time = sfMusic_getDuration (music);+}+++void sfMusic_getPlayingOffset_helper (const sfMusic* music, sfTime* time)+{+    *time = sfMusic_getPlayingOffset (music);+}+++void sfMusic_setPosition_helper (sfMusic* music, sfVector3f* position)+{+    sfMusic_setPosition (music, *position);+}+++void sfMusic_getPosition_helper (const sfMusic* music, sfVector3f* position)+{+    *position = sfMusic_getPosition (music);+}+
+ cbits/SFML/Audio/SoundBuffer_helper.c view
@@ -0,0 +1,8 @@+#include <SFML/Audio/SoundBuffer.h>+++void sfSoundBuffer_getDuration_helper (const sfSoundBuffer* soundBuffer, sfTime* time)+{+    *time = sfSoundBuffer_getDuration (soundBuffer);+}+
+ cbits/SFML/Audio/SoundStream_helper.c view
@@ -0,0 +1,20 @@+#include <SFML/Audio/SoundStream.h>+++void sfSoundStream_getPlayingOffset_helper (const sfSoundStream* stream, sfTime* time)+{+    *time = sfSoundStream_getPlayingOffset (stream);+}+++void sfSoundStream_setPosition_helper (sfSoundStream* stream, sfVector3f* position)+{+    sfSoundStream_setPosition (stream, *position);+}+++void sfSoundStream_getPosition_helper (const sfSoundStream* stream, sfVector3f* position)+{+    *position = sfSoundStream_getPosition (stream);+}+
+ cbits/SFML/Audio/Sound_helper.c view
@@ -0,0 +1,20 @@+#include <SFML/Audio/Sound.h>+++void sfSound_setPosition_helper (sfSound* sound, sfVector3f* position)+{+    sfSound_setPosition (sound, *position);+}+++void sfSound_getPosition_helper (const sfSound* sound, sfVector3f* position)+{+    *position = sfSound_getPosition (sound);+}+++void sfSound_getPlayingOffset_helper (const sfSound* sound, sfTime* time)+{+    *time = sfSound_getPlayingOffset (sound);+}+
+ cbits/SFML/Graphics/CircleShape_helper.c view
@@ -0,0 +1,116 @@+#include <SFML/Graphics/CircleShape.h>+++void sfCircleShape_setPosition_helper (sfCircleShape* shape, sfVector2f* position)+{+    sfCircleShape_setPosition (shape, *position);+}+++void sfCircleShape_setScale_helper (sfCircleShape* shape, sfVector2f* scale)+{+    sfCircleShape_setScale (shape, *scale);+}+++void sfCircleShape_setOrigin_helper (sfCircleShape* shape, sfVector2f* origin)+{+    sfCircleShape_setOrigin (shape, *origin);+}+++void sfCircleShape_getPosition_helper (const sfCircleShape* shape, sfVector2f* position)+{+    *position = sfCircleShape_getPosition (shape);+}+++void sfCircleShape_getScale_helper (const sfCircleShape* shape, sfVector2f* scale)+{+    *scale = sfCircleShape_getScale (shape);+}+++void sfCircleShape_getOrigin_helper (const sfCircleShape* shape, sfVector2f* origin)+{+    *origin = sfCircleShape_getOrigin (shape);+}+++void sfCircleShape_move_helper (sfCircleShape* shape, sfVector2f* offset)+{+    sfCircleShape_move (shape, *offset);+}+++void sfCircleShape_scale_helper (sfCircleShape* shape, sfVector2f* factors)+{+    sfCircleShape_scale (shape, *factors);+}+++void sfCircleShape_getTransform_helper (const sfCircleShape* shape, sfTransform* transform)+{+    *transform = sfCircleShape_getTransform (shape);+}+++void sfCircleShape_getInverseTransform_helper (const sfCircleShape* shape, sfTransform* itransform)+{+    *itransform = sfCircleShape_getInverseTransform (shape);+}+++void sfCircleShape_setTextureRect_helper (sfCircleShape* shape, sfIntRect* rect)+{+    sfCircleShape_setTextureRect (shape, *rect);+}+++void sfCircleShape_getTextureRect_helper (const sfCircleShape* shape, sfIntRect* rect)+{+    *rect = sfCircleShape_getTextureRect (shape);+}+++void sfCircleShape_setFillColor_helper (sfCircleShape* shape, sfColor* color)+{+    sfCircleShape_setFillColor (shape, *color);+}+++void sfCircleShape_setOutlineColor_helper (sfCircleShape* shape, sfColor* color)+{+    sfCircleShape_setOutlineColor (shape, *color);+}+++void sfCircleShape_getFillColor_helper (const sfCircleShape* shape, sfColor* color)+{+    *color = sfCircleShape_getFillColor (shape);+}+++void sfCircleShape_getOutlineColor_helper (const sfCircleShape* shape, sfColor* color)+{+    *color = sfCircleShape_getOutlineColor (shape);+}+++void sfCircleShape_getPoint_helper (const sfCircleShape* shape, unsigned int index, sfVector2f* point)+{+    *point = sfCircleShape_getPoint (shape, index);+}+++void sfCircleShape_getLocalBounds_helper (const sfCircleShape* shape, sfFloatRect* rect)+{+    *rect = sfCircleShape_getLocalBounds (shape);+}+++void sfCircleShape_getGlobalBounds_helper (const sfCircleShape* shape, sfFloatRect* rect)+{+    *rect = sfCircleShape_getGlobalBounds (shape);+}+
+ cbits/SFML/Graphics/ConvexShape_helper.c view
@@ -0,0 +1,122 @@+#include <SFML/Graphics/ConvexShape.h>+++void sfConvexShape_setPosition_helper (sfConvexShape* shape, sfVector2f* position)+{+    sfConvexShape_setPosition (shape, *position);+}+++void sfConvexShape_setScale_helper (sfConvexShape* shape, sfVector2f* scale)+{+    sfConvexShape_setScale (shape, *scale);+}+++void sfConvexShape_setOrigin_helper (sfConvexShape* shape, sfVector2f* origin)+{+    sfConvexShape_setOrigin (shape, *origin);+}+++void sfConvexShape_getPosition_helper (const sfConvexShape* shape, sfVector2f* position)+{+    *position = sfConvexShape_getPosition (shape);+}+++void sfConvexShape_getScale_helper (const sfConvexShape* shape, sfVector2f* scale)+{+    *scale = sfConvexShape_getScale (shape);+}+++void sfConvexShape_getOrigin_helper (const sfConvexShape* shape, sfVector2f* origin)+{+    *origin = sfConvexShape_getOrigin (shape);+}+++void sfConvexShape_move_helper (sfConvexShape* shape, sfVector2f* offset)+{+    sfConvexShape_move (shape, *offset);+}+++void sfConvexShape_scale_helper (sfConvexShape* shape, sfVector2f* factors)+{+    sfConvexShape_scale (shape, *factors);+}+++void sfConvexShape_getTransform_helper (const sfConvexShape* shape, sfTransform* transform)+{+    *transform = sfConvexShape_getTransform (shape);+}+++void sfConvexShape_getInverseTransform_helper (const sfConvexShape* shape, sfTransform* itransform)+{+    *itransform = sfConvexShape_getInverseTransform (shape);+}+++void sfConvexShape_setTextureRect_helper (sfConvexShape* shape, sfIntRect* rect)+{+    sfConvexShape_setTextureRect (shape, *rect);+}+++void sfConvexShape_getTextureRect_helper (const sfConvexShape* shape, sfIntRect* rect)+{+    *rect = sfConvexShape_getTextureRect (shape);+}+++void sfConvexShape_setFillColor_helper (sfConvexShape* shape, sfColor* color)+{+    sfConvexShape_setFillColor (shape, *color);+}+++void sfConvexShape_setOutlineColor_helper (sfConvexShape* shape, sfColor* color)+{+    sfConvexShape_setOutlineColor (shape, *color);+}+++void sfConvexShape_getFillColor_helper (const sfConvexShape* shape, sfColor* color)+{+    *color = sfConvexShape_getFillColor (shape);+}+++void sfConvexShape_getOutlineColor_helper (const sfConvexShape* shape, sfColor* color)+{+    *color = sfConvexShape_getOutlineColor (shape);+}+++void sfConvexShape_getPoint_helper (const sfConvexShape* shape, unsigned int index, sfVector2f* point)+{+    *point = sfConvexShape_getPoint (shape, index);+}+++void sfConvexShape_getLocalBounds_helper (const sfConvexShape* shape, sfFloatRect* rect)+{+    *rect = sfConvexShape_getLocalBounds (shape);+}+++void sfConvexShape_getGlobalBounds_helper (const sfConvexShape* shape, sfFloatRect* rect)+{+    *rect = sfConvexShape_getGlobalBounds (shape);+}+++void sfConvexShape_setPoint_helper (sfConvexShape* shape, unsigned int index, sfVector2f* point)+{+    sfConvexShape_setPoint (shape, index, *point);+}+
+ cbits/SFML/Graphics/Font_helper.c view
@@ -0,0 +1,8 @@+#include <SFML/Graphics/Font.h>+++void sfFont_getGlyph_helper (sfFont* font, sfUint32 codePoint, unsigned int characterSize, sfBool bold, sfGlyph* glyph)+{+    *glyph = sfFont_getGlyph (font, codePoint, characterSize, bold);+}+
+ cbits/SFML/Graphics/Image_helper.c view
@@ -0,0 +1,39 @@+#include <SFML/Graphics/Image.h>+++sfImage* sfImage_createFromColor_helper (unsigned int width, unsigned int height, sfColor* color)+{+    return sfImage_createFromColor (width, height, *color);+}+++void sfImage_getSize_helper (const sfImage* image, sfVector2u* size)+{+    *size = sfImage_getSize (image);+}+++void sfImage_createMaskFromColor_helper (sfImage* image, sfColor* color, sfUint8 alpha)+{+    sfImage_createMaskFromColor (image, *color, alpha);+}+++void sfImage_copyImage_helper+(sfImage* image, const sfImage* source, unsigned int destX, unsigned int destY, sfIntRect* sourceRect, sfBool applyAlpha)+{+    sfImage_copyImage (image, source, destX, destY, *sourceRect, applyAlpha);+}+++void sfImage_setPixel_helper (sfImage* image, unsigned int x, unsigned int y, sfColor* color)+{+    sfImage_setPixel (image, x, y, *color);+}+++void sfImage_getPixel_helper (const sfImage* image, unsigned int x, unsigned int y, sfColor* color)+{+    *color = sfImage_getPixel (image, x, y);+}+
+ cbits/SFML/Graphics/RectangleShape_helper.c view
@@ -0,0 +1,128 @@+#include <SFML/Graphics/RectangleShape.h>+++void sfRectangleShape_setPosition_helper (sfRectangleShape* shape, sfVector2f* position)+{+    sfRectangleShape_setPosition (shape, *position);+}+++void sfRectangleShape_setScale_helper (sfRectangleShape* shape, sfVector2f* scale)+{+    sfRectangleShape_setScale (shape, *scale);+}+++void sfRectangleShape_setOrigin_helper (sfRectangleShape* shape, sfVector2f* origin)+{+    sfRectangleShape_setOrigin (shape, *origin);+}+++void sfRectangleShape_getPosition_helper (const sfRectangleShape* shape, sfVector2f* position)+{+    *position = sfRectangleShape_getPosition (shape);+}+++void sfRectangleShape_getScale_helper (const sfRectangleShape* shape, sfVector2f* scale)+{+    *scale = sfRectangleShape_getScale (shape);+}+++void sfRectangleShape_getOrigin_helper (const sfRectangleShape* shape, sfVector2f* origin)+{+    *origin = sfRectangleShape_getOrigin (shape);+}+++void sfRectangleShape_move_helper (sfRectangleShape* shape, sfVector2f* offset)+{+    sfRectangleShape_move (shape, *offset);+}+++void sfRectangleShape_scale_helper (sfRectangleShape* shape, sfVector2f* factors)+{+    sfRectangleShape_scale (shape, *factors);+}+++void sfRectangleShape_getTransform_helper (const sfRectangleShape* shape, sfTransform* transform)+{+    *transform = sfRectangleShape_getTransform (shape);+}+++void sfRectangleShape_getInverseTransform_helper (const sfRectangleShape* shape, sfTransform* itransform)+{+    *itransform = sfRectangleShape_getInverseTransform (shape);+}+++void sfRectangleShape_setTextureRect_helper (sfRectangleShape* shape, sfIntRect* rect)+{+    sfRectangleShape_setTextureRect (shape, *rect);+}+++void sfRectangleShape_getTextureRect_helper (const sfRectangleShape* shape, sfIntRect* rect)+{+    *rect = sfRectangleShape_getTextureRect (shape);+}+++void sfRectangleShape_setFillColor_helper (sfRectangleShape* shape, sfColor* color)+{+    sfRectangleShape_setFillColor (shape, *color);+}+++void sfRectangleShape_setOutlineColor_helper (sfRectangleShape* shape, sfColor* color)+{+    sfRectangleShape_setOutlineColor (shape, *color);+}+++void sfRectangleShape_getFillColor_helper (const sfRectangleShape* shape, sfColor* color)+{+    *color = sfRectangleShape_getFillColor (shape);+}+++void sfRectangleShape_getOutlineColor_helper (const sfRectangleShape* shape, sfColor* color)+{+    *color = sfRectangleShape_getOutlineColor (shape);+}+++void sfRectangleShape_getPoint_helper (const sfRectangleShape* shape, unsigned int index, sfVector2f* point)+{+    *point = sfRectangleShape_getPoint (shape, index);+}+++void sfRectangleShape_getLocalBounds_helper (const sfRectangleShape* shape, sfFloatRect* rect)+{+    *rect = sfRectangleShape_getLocalBounds (shape);+}+++void sfRectangleShape_getGlobalBounds_helper (const sfRectangleShape* shape, sfFloatRect* rect)+{+    *rect = sfRectangleShape_getGlobalBounds (shape);+}+++void sfRectangleShape_setSize_helper (sfRectangleShape* shape, sfVector2f* size)+{+    sfRectangleShape_setSize (shape, *size);+}+++void sfRectangleShape_getSize_helper (const sfRectangleShape* shape, sfVector2f* size)+{+    *size = sfRectangleShape_getSize (shape);+}+
+ cbits/SFML/Graphics/RenderTexture_helper.c view
@@ -0,0 +1,27 @@+#include <SFML/Graphics/RenderTexture.h>+++void sfRenderTexture_getSize_helper (const sfRenderTexture* renderTexture, sfVector2u* size)+{+    *size = sfRenderTexture_getSize (renderTexture);+}+++void sfRenderTexture_clear_helper (sfRenderTexture* renderTexture, sfColor* color)+{+    sfRenderTexture_clear (renderTexture, *color);+}+++void sfRenderTexture_getViewport_helper (const sfRenderTexture* renderTexture, const sfView* view, sfIntRect* vp)+{+    *vp = sfRenderTexture_getViewport (renderTexture, view);+}+++void sfRenderTexture_mapPixelToCoords_helper+(const sfRenderTexture* renderTexture, sfVector2i* point, const sfView* targetView, sfVector2f* coords)+{+    *coords = sfRenderTexture_mapPixelToCoords (renderTexture, *point, targetView);+}+
+ cbits/SFML/Graphics/RenderWindow_helper.c view
@@ -0,0 +1,70 @@+#include <SFML/Graphics/RenderWindow.h>+++sfRenderWindow* sfRenderWindow_create_helper+(sfVideoMode* mode, const char* title, sfUint32 style, const sfContextSettings* settings)+{+    return sfRenderWindow_create (*mode, title, style, settings);+}+++void sfRenderWindow_getSettings_helper (const sfRenderWindow* renderWindow, sfContextSettings* settings)+{+    *settings = sfRenderWindow_getSettings (renderWindow);+}+++void sfRenderWindow_getPosition_helper (const sfRenderWindow* renderWindow, sfVector2i* position)+{+    *position = sfRenderWindow_getPosition (renderWindow);+}+++void sfRenderWindow_setPosition_helper (sfRenderWindow* renderWindow, sfVector2i* position)+{+    sfRenderWindow_setPosition (renderWindow, *position);+}+++void sfRenderWindow_getSize_helper (const sfRenderWindow* renderWindow, sfVector2u* size)+{+    *size = sfRenderWindow_getSize (renderWindow);+}+++void sfRenderWindow_setSize_helper (sfRenderWindow* renderWindow, sfVector2u* size)+{+    sfRenderWindow_setSize (renderWindow, *size);+}+++void sfRenderWindow_clear_helper (sfRenderWindow* renderWindow, sfColor* color)+{+    sfRenderWindow_clear (renderWindow, *color);+}+++void sfRenderWindow_getViewport_helper (const sfRenderWindow* renderWindow, const sfView* view, sfIntRect* rect)+{+    *rect = sfRenderWindow_getViewport (renderWindow, view);+}+++void sfRenderWindow_mapPixelToCoords_helper+(const sfRenderWindow* renderWindow, sfVector2i point, const sfView* targetView, sfVector2f* out)+{+    *out = sfRenderWindow_mapPixelToCoords (renderWindow, point, targetView);+}+++void sfMouse_getPositionRenderWindow_helper (const sfRenderWindow* relativeTo, sfVector2i* position)+{+    *position = sfMouse_getPositionRenderWindow (relativeTo);+}+++void sfMouse_setPositionRenderWindow_helper (sfVector2i* position, const sfRenderWindow* relativeTo)+{+    sfMouse_setPositionRenderWindow (*position, relativeTo);+}+
+ cbits/SFML/Graphics/Shader_helper.c view
@@ -0,0 +1,26 @@+#include <SFML/Graphics/Shader.h>+++void sfShader_setVector2Parameter_helper (sfShader* shader, const char* name, sfVector2f* vector)+{+    sfShader_setVector2Parameter (shader, name, *vector);+}+++void sfShader_setVector3Parameter_helper (sfShader* shader, const char* name, sfVector3f* vector)+{+    sfShader_setVector3Parameter (shader, name, *vector);+}+++void sfShader_setColorParameter_helper (sfShader* shader, const char* name, sfColor* color)+{+    sfShader_setColorParameter (shader, name, *color);+}+++void sfShader_setTransformParameter_helper (sfShader* shader, const char* name, sfTransform* transform)+{+    sfShader_setTransformParameter (shader, name, *transform);+}+
+ cbits/SFML/Graphics/Shape_helper.c view
@@ -0,0 +1,116 @@+#include <SFML/Graphics/Shape.h>+++void sfShape_setPosition_helper (sfShape* shape, sfVector2f* position)+{+    sfShape_setPosition (shape, *position);+}+++void sfShape_setScale_helper (sfShape* shape, sfVector2f* scale)+{+    sfShape_setScale (shape, *scale);+}+++void sfShape_setOrigin_helper (sfShape* shape, sfVector2f* origin)+{+    sfShape_setOrigin (shape, *origin);+}+++void sfShape_getPosition_helper (const sfShape* shape, sfVector2f* position)+{+    *position = sfShape_getPosition (shape);+}+++void sfShape_getScale_helper (const sfShape* shape, sfVector2f* scale)+{+    *scale = sfShape_getScale (shape);+}+++void sfShape_getOrigin_helper (const sfShape* shape, sfVector2f* origin)+{+    *origin = sfShape_getOrigin (shape);+}+++void sfShape_move_helper (sfShape* shape, sfVector2f* offset)+{+    sfShape_move (shape, *offset);+}+++void sfShape_scale_helper (sfShape* shape, sfVector2f* factors)+{+    sfShape_scale (shape, *factors);+}+++void sfShape_getTransform_helper (const sfShape* shape, sfTransform* transform)+{+    *transform = sfShape_getTransform (shape);+}+++void sfShape_getInverseTransform_helper (const sfShape* shape, sfTransform* itransform)+{+    *itransform = sfShape_getInverseTransform (shape);+}+++void sfShape_setTextureRect_helper (sfShape* shape, sfIntRect* rect)+{+    sfShape_setTextureRect (shape, *rect);+}+++void sfShape_getTextureRect_helper (const sfShape* shape, sfIntRect* rect)+{+    *rect = sfShape_getTextureRect (shape);+}+++void sfShape_setFillColor_helper (sfShape* shape, sfColor* color)+{+    sfShape_setFillColor (shape, *color);+}+++void sfShape_setOutlineColor_helper (sfShape* shape, sfColor* color)+{+    sfShape_setOutlineColor (shape, *color);+}+++void sfShape_getFillColor_helper (const sfShape* shape, sfColor* color)+{+    *color = sfShape_getFillColor (shape);+}+++void sfShape_getOutlineColor_helper (const sfShape* shape, sfColor* color)+{+    *color = sfShape_getOutlineColor (shape);+}+++void sfShape_getPoint_helper (const sfShape* shape, unsigned int index, sfVector2f* point)+{+    *point = sfShape_getPoint (shape, index);+}+++void sfShape_getLocalBounds_helper (const sfShape* shape, sfFloatRect* rect)+{+    *rect = sfShape_getLocalBounds (shape);+}+++void sfShape_getGlobalBounds_helper (const sfShape* shape, sfFloatRect* rect)+{+    *rect = sfShape_getGlobalBounds (shape);+}+
+ cbits/SFML/Graphics/Sprite_helper.c view
@@ -0,0 +1,98 @@+#include <SFML/Graphics/Sprite.h>+++void sfSprite_setPosition_helper (sfSprite* sprite, sfVector2f* position)+{+    sfSprite_setPosition (sprite, *position);+}+++void sfSprite_setScale_helper (sfSprite* sprite, sfVector2f* scale)+{+    sfSprite_setScale (sprite, *scale);+}+++void sfSprite_setOrigin_helper (sfSprite* sprite, sfVector2f* origin)+{+    sfSprite_setOrigin (sprite, *origin);+}+++void sfSprite_getPosition_helper (const sfSprite* sprite, sfVector2f* position)+{+    *position = sfSprite_getPosition (sprite);+}+++void sfSprite_getScale_helper (const sfSprite* sprite, sfVector2f* scale)+{+    *scale = sfSprite_getScale (sprite);+}+++void sfSprite_getOrigin_helper (const sfSprite* sprite, sfVector2f* origin)+{+    *origin = sfSprite_getOrigin (sprite);+}+++void sfSprite_move_helper (sfSprite* sprite, sfVector2f* offset)+{+    sfSprite_move (sprite, *offset);+}+++void sfSprite_scale_helper (sfSprite* sprite, sfVector2f* factors)+{+    sfSprite_scale (sprite, *factors);+}+++void sfSprite_getTransform_helper (const sfSprite* sprite, sfTransform* transform)+{+    *transform = sfSprite_getTransform (sprite);+}+++void sfSprite_getInverseTransform_helper (const sfSprite* sprite, sfTransform* transform)+{+    *transform = sfSprite_getInverseTransform (sprite);+}+++void sfSprite_setColor_helper (sfSprite* sprite, sfColor* color)+{+    sfSprite_setColor (sprite, *color);+}+++void sfSprite_getColor_helper (const sfSprite* sprite, sfColor* color)+{+    *color = sfSprite_getColor (sprite);+}+++void sfSprite_setTextureRect_helper (sfSprite* sprite, sfIntRect* rectangle)+{+    sfSprite_setTextureRect (sprite, *rectangle);+}+++void sfSprite_getTextureRect_helper (const sfSprite* sprite, sfIntRect* rect)+{+    *rect = sfSprite_getTextureRect (sprite);+}+++void sfSprite_getLocalBounds_helper (const sfSprite* sprite, sfFloatRect* rect)+{+    *rect = sfSprite_getLocalBounds (sprite);+}+++void sfSprite_getGlobalBounds_helper (const sfSprite* sprite, sfFloatRect* rect)+{+    *rect = sfSprite_getGlobalBounds (sprite);+}+
+ cbits/SFML/Graphics/Text_helper.c view
@@ -0,0 +1,92 @@+#include <SFML/Graphics/Text.h>+++void sfText_setPosition_helper (sfText* text, sfVector2f* position)+{+    sfText_setPosition (text, *position);+}+++void sfText_setScale_helper (sfText* text, sfVector2f* scale)+{+    sfText_setScale (text, *scale);+}+++void sfText_setOrigin_helper (sfText* text, sfVector2f* origin)+{+    sfText_setOrigin (text, *origin);+}+++void sfText_getPosition_helper (const sfText* text, sfVector2f* position)+{+    *position = sfText_getPosition (text);+}+++void sfText_getScale_helper (const sfText* text, sfVector2f* scale)+{+    *scale = sfText_getScale (text);+}+++void sfText_getOrigin_helper (const sfText* text, sfVector2f* origin)+{+    *origin = sfText_getOrigin (text);+}+++void sfText_move_helper (sfText* text, sfVector2f* offset)+{+    sfText_move (text, *offset);+}+++void sfText_scale_helper (sfText* text, sfVector2f* factors)+{+    sfText_scale (text, *factors);+}+++void sfText_getTransform_helper (const sfText* text, sfTransform* transform)+{+    *transform = sfText_getTransform (text);+}+++void sfText_getInverseTransform_helper (const sfText* text, sfTransform* itransform)+{+    *itransform = sfText_getInverseTransform (text);+}+++void sfText_setColor_helper (sfText* text, sfColor* color)+{+    sfText_setColor (text, *color);+}+++void sfText_getColor_helper (const sfText* text, sfColor* color)+{+    *color = sfText_getColor (text);+}+++void sfText_findCharacterPos_helper (const sfText* text, size_t index, sfVector2f* position)+{+    *position = sfText_findCharacterPos (text, index);+}+++void sfText_getLocalBounds_helper (const sfText* text, sfFloatRect* rect)+{+    *rect = sfText_getLocalBounds (text);+}+++void sfText_getGlobalBounds_helper (const sfText* text, sfFloatRect* rect)+{+    *rect = sfText_getGlobalBounds (text);+}+
+ cbits/SFML/Graphics/Texture_helper.c view
@@ -0,0 +1,8 @@+#include <SFML/Graphics/Texture.h>+++void sfTexture_getSize_helper (const sfTexture* texture, sfVector2u* size)+{+    *size = sfTexture_getSize (texture);+}+
+ cbits/SFML/Graphics/VertexArray_helper.c view
@@ -0,0 +1,14 @@+#include <SFML/Graphics/VertexArray.h>+++void sfVertexArray_append_helper (sfVertexArray* vertexArray, sfVertex* vertex)+{+    sfVertexArray_append (vertexArray, *vertex);+}+++void sfVertexArray_getBounds_helper (sfVertexArray* vertexArray, sfFloatRect* rect)+{+    *rect = sfVertexArray_getBounds (vertexArray);+}+
+ cbits/SFML/Graphics/View_helper.c view
@@ -0,0 +1,50 @@+#include <SFML/Graphics/View.h>+++sfView* sfView_createFromRect_helper (sfFloatRect* rectangle)+{+    return sfView_createFromRect (*rectangle);+}+++void sfView_setCenter_helper (sfView* view, sfVector2f* center)+{+    sfView_setCenter (view, *center);+}+++void sfView_setSize_helper (sfView* view, sfVector2f* size)+{+    sfView_setSize (view, *size);+}+++void sfView_setViewport_helper (sfView* view, sfFloatRect* viewport)+{+    sfView_setViewport (view, *viewport);+}+++void sfView_reset_helper (sfView* view, sfFloatRect* rectangle)+{+    sfView_reset (view, *rectangle);+}+++void sfView_getSize_helper (const sfView* view, sfVector2f* size)+{+    *size = sfView_getSize (view);+}+++void sfView_getViewport_helper (const sfView* view, sfFloatRect* vp)+{+    *vp = sfView_getViewport (view);+}+++void sfView_move_helper (sfView* view, sfVector2f* offset)+{+    sfView_move (view, *offset);+}+
+ cbits/SFML/System/Clock_helper.c view
@@ -0,0 +1,14 @@+#include <SFML/System/Clock.h>+++void sfClock_getElapsedTime_helper (const sfClock* clock, sfTime* time)+{+    *time = sfClock_getElapsedTime (clock);+}+++void sfClock_restart_helper (sfClock* clock, sfTime* time)+{+    *time = sfClock_restart (clock);+}+
+ cbits/SFML/System/Sleep_helper.c view
@@ -0,0 +1,8 @@+#include <SFML/System/Sleep.h>+++void sfSleep_helper (sfTime* duration)+{+    sfSleep (*duration);+}+
+ cbits/SFML/System/Time_helper.c view
@@ -0,0 +1,20 @@+#include <SFML/System/Time.h>+++void sfSeconds_helper (float amount, sfTime* time)+{+    *time = sfSeconds (amount);+}+++void sfMilliseconds_helper (sfInt32 amount, sfTime* time)+{+    *time = sfMilliseconds (amount);+}+++void sfMicroseconds_helper (sfInt64 amount, sfTime* time)+{+    *time = sfMicroseconds (amount);+}+
+ cbits/SFML/Window/VideoMode_helper.c view
@@ -0,0 +1,14 @@+#include <SFML/Window/VideoMode.h>+++sfBool sfVideoMode_isValid_helper (sfVideoMode* mode)+{+    return sfVideoMode_isValid (*mode);+}+++void sfVideoMode_getDesktopMode_helper (sfVideoMode* mode)+{+    *mode = sfVideoMode_getDesktopMode ();+}+
+ cbits/SFML/Window/Window_helper.c view
@@ -0,0 +1,53 @@+#include <SFML/Window/Mouse.h>+#include <SFML/Window/Window.h>+++sfWindow* sfWindow_create_helper+(sfVideoMode* mode, char* title, sfUint32 style, sfContextSettings* settings)+{+    return sfWindow_create (*mode, title, style, settings);+}+++void sfWindow_getSettings_helper (sfWindow* window, sfContextSettings* settings)+{+    *settings = sfWindow_getSettings (window);+}+++void sfWindow_getPosition_helper (sfWindow* window, sfVector2i* pos)+{+    *pos = sfWindow_getPosition (window);+}+++void sfWindow_setPosition_helper (sfWindow* window, sfVector2i* position)+{+    sfWindow_setPosition (window, *position);+}+++void sfWindow_getSize_helper (const sfWindow* window, sfVector2u* size)+{+    *size = sfWindow_getSize (window);+}+++void sfWindow_setSize_helper (sfWindow* window, sfVector2u* size)+{+    sfWindow_setSize (window, *size);+}+++void sfMouse_getPosition_helper (const sfWindow* relativeTo, sfVector2i* pos)+{+    *pos = sfMouse_getPosition (relativeTo);+}+++void sfMouse_setPosition_helper (sfVector2i* position, const sfWindow* relativeTo)+{+    sfMouse_setPosition (*position, relativeTo);+}++
+ src/SFML/Audio.hs view
@@ -0,0 +1,31 @@+module SFML.Audio+(+    module SFML.Audio.Listener+,   module SFML.Audio.Music+,   module SFML.Audio.SFSampled+,   module SFML.Audio.SFSound+,   module SFML.Audio.SFSoundRecorder+,   module SFML.Audio.Sound+,   module SFML.Audio.SoundBuffer+,   module SFML.Audio.SoundBufferRecorder+,   module SFML.Audio.SoundRecorder+,   module SFML.Audio.SoundStatus+,   module SFML.Audio.SoundStream+,   module SFML.Audio.Types+)+where+++import SFML.Audio.Listener+import SFML.Audio.Music+import SFML.Audio.SFSampled+import SFML.Audio.SFSound+import SFML.Audio.SFSoundRecorder+import SFML.Audio.Sound+import SFML.Audio.SoundBuffer+import SFML.Audio.SoundBufferRecorder+import SFML.Audio.SoundRecorder+import SFML.Audio.SoundStatus+import SFML.Audio.SoundStream+import SFML.Audio.Types+
+ src/SFML/Audio/Listener.hs view
@@ -0,0 +1,97 @@+module SFML.Audio.Listener+(+    setGlobalVolume+,   getGlobalVolume+,   setListenerPosition+,   getListenerPosition+,   setListenerDirection+,   getListenerDirection+)+where+++import SFML.System.Vector3++import Control.Monad ((>=>))+import Foreign.C.Types+import Foreign.Marshal.Alloc (alloca)+import Foreign.Marshal.Utils (with)+import Foreign.Ptr (Ptr)+import Foreign.Storable (peek)+++-- | Change the global volume of all the sounds and musics.+--+-- The volume is a number between 0 and 100; it is combined with+-- the individual volume of each sound or music.+--+-- The default value for the volume is 100 (maximum).+setGlobalVolume+    :: Float -- ^ New global volume, in the range [0, 100]+    -> IO ()++setGlobalVolume = sfListener_setGlobalVolume . realToFrac++foreign import ccall unsafe "sfListener_setGlobalVolume"+    sfListener_setGlobalVolume :: CFloat -> IO ()++--CSFML_AUDIO_API void sfListener_setGlobalVolume(float volume);+++-- | Get the current value of the global volume.+getGlobalVolume :: IO Float -- ^ Current global volume, in the range [0, 100]+getGlobalVolume = fmap realToFrac sfListener_getGlobalVolume++foreign import ccall unsafe "sfListener_getGlobalVolume"+    sfListener_getGlobalVolume :: IO CFloat++--CSFML_AUDIO_API float sfListener_getGlobalVolume(void);+++-- | Set the position of the listener in the scene.+--+-- The default listener's position is (0, 0, 0).+setListenerPosition :: Vec3f -> IO ()+setListenerPosition pos = with pos sfListener_setPosition_helper++foreign import ccall unsafe "sfListener_setPosition_helper"+    sfListener_setPosition_helper :: Ptr Vec3f -> IO ()++--CSFML_AUDIO_API void sfListener_setPosition(sfVector3f position);+++-- | Get the current position of the listener in the scene.+getListenerPosition :: IO Vec3f+getListenerPosition = alloca $ \ptr -> sfListener_getPosition_helper ptr >> peek ptr++foreign import ccall unsafe "sfListener_getPosition_helper"+    sfListener_getPosition_helper :: Ptr Vec3f -> IO ()++--CSFML_AUDIO_API sfVector3f sfListener_getPosition();+++-- | Set the orientation of the listener in the scene.+--+-- The orientation defines the 3D axes of the listener+-- (left, up, front) in the scene. The orientation vector+-- doesn't have to be normalized.+--+-- The default listener's orientation is (0, 0, -1).+setListenerDirection :: Vec3f -> IO ()+setListenerDirection dir = with dir sfListener_setDirection_helper++foreign import ccall unsafe "sfListener_setDirection_helper"+    sfListener_setDirection_helper :: Ptr Vec3f -> IO ()++--CSFML_AUDIO_API void sfListener_setDirection(sfVector3f orientation);+++-- | Get the current orientation of the listener in the scene.+getListenerDirection :: IO Vec3f+getListenerDirection = alloca $ \ptr -> sfListener_getDirection_helper ptr >> peek ptr++foreign import ccall unsafe "sfListener_getDirection_helper"+    sfListener_getDirection_helper :: Ptr Vec3f -> IO ()++--CSFML_AUDIO_API sfVector3f sfListener_getDirection();+
+ src/SFML/Audio/Music.hs view
@@ -0,0 +1,340 @@+{-# LANGUAGE DeriveDataTypeable #-}+module SFML.Audio.Music+(+    module SFML.Utils+,   MusicException(..)+,   musicFromFile+,   musicFromMemory+,   musicFromStream+,   destroy+,   setLoop+,   getLoop+,   getDuration+,   play+,   pause+,   stop+,   getChannelCount+,   getSampleRate+,   getStatus+,   getPlayingOffset+,   setPitch+,   setVolume+,   setPosition+,   setRelativeToListener+,   setMinDistance+,   setAttenuation+,   setPlayingOffset+,   getPitch+,   getVolume+,   getPosition+,   isRelativeToListener+,   getMinDistance+,   getAttenuation+)+where+++import SFML.Audio.SFSampled+import SFML.Audio.SFSound+import SFML.Audio.SFSoundBuffer+import SFML.Audio.SoundStatus+import SFML.Audio.Types+import SFML.SFResource+import SFML.System.InputStream+import SFML.System.Time+import SFML.System.Vector3+import SFML.Utils++import Control.Exception+import Control.Monad ((>=>))+import Data.Typeable+import Foreign.Marshal.Utils (with)+import Foreign.Marshal.Alloc (alloca)+import Foreign.C.String+import Foreign.C.Types+import Foreign.Ptr (Ptr, nullPtr)+import Foreign.Storable (peek)+++checkNull :: Music -> Maybe Music+checkNull music@(Music ptr) = if ptr == nullPtr then Nothing else Just music+++data MusicException = MusicException String deriving (Show, Typeable)++instance Exception MusicException+++-- | Create a new music and load it from a file.+-- +-- This function doesn't start playing the music (call+-- 'play' to do so).+-- +-- Here is a complete list of all the supported audio formats:+-- ogg, wav, flac, aiff, au, raw, paf, svx, nist, voc, ircam,+-- w64, mat4, mat5 pvf, htk, sds, avr, sd2, caf, wve, mpc2k, rf64.+musicFromFile :: FilePath -> IO (Either MusicException Music)+musicFromFile path =+    let err = MusicException $ "Failed loading music from file " ++ path+    in withCAString path $ \cstr -> sfMusic_createFromFile cstr >>= return . tagErr err . checkNull++foreign import ccall unsafe "sfMusic_createFromFile"+    sfMusic_createFromFile :: CString -> IO Music++-- \return A new sfMusic object (NULL if failed)++-- CSFML_AUDIO_API sfMusic* sfMusic_createFromFile(const char* filename);+++-- | Create a new music and load it from a file in memory.+-- +-- This function doesn't start playing the music (call+-- 'play' to do so).+-- +-- Here is a complete list of all the supported audio formats:+-- ogg, wav, flac, aiff, au, raw, paf, svx, nist, voc, ircam,+-- w64, mat4, mat5 pvf, htk, sds, avr, sd2, caf, wve, mpc2k, rf64.+musicFromMemory+    :: Ptr a -- ^ Pointer to the file data in memory+    -> Int   -- ^ Size of the data to load, in bytes+    -> IO (Either MusicException Music)++musicFromMemory ptr size =+    let err = MusicException $ "Failed loading music from memory address " ++ show ptr+    in fmap (tagErr err . checkNull) $ sfMusic_createFromMemory ptr (fromIntegral size)++foreign import ccall unsafe "sfMusic_createFromMemory"+    sfMusic_createFromMemory :: Ptr a -> CUInt -> IO Music++-- \return A new sfMusic object (NULL if failed)++-- CSFML_AUDIO_API sfMusic* sfMusic_createFromMemory(const void* data, size_t sizeInBytes);+++-- | Create a new music and load it from a custom stream.+-- +-- This function doesn't start playing the music (call+-- 'play' to do so).+-- +-- Here is a complete list of all the supported audio formats:+-- ogg, wav, flac, aiff, au, raw, paf, svx, nist, voc, ircam,+-- w64, mat4, mat5 pvf, htk, sds, avr, sd2, caf, wve, mpc2k, rf64.+musicFromStream :: InputStream -> IO (Either MusicException Music)+musicFromStream is =+    let err = MusicException $ "Failed loading music from input stream " ++ show is+    in with is $ \ptr -> sfMusic_createFromStream ptr >>= return . tagErr err . checkNull++foreign import ccall unsafe "sfMusic_createFromStream"+    sfMusic_createFromStream :: Ptr InputStream -> IO Music++-- \return A new sfMusic object (NULL if failed)++-- CSFML_AUDIO_API sfMusic* sfMusic_createFromStream(sfInputStream* stream);+++instance SFResource Music where+    +    {-# INLINABLE destroy #-}+    destroy = sfMusic_destroy++foreign import ccall unsafe "sfMusic_destroy"+    sfMusic_destroy :: Music -> IO ()++-- CSFML_AUDIO_API void sfMusic_destroy(sfMusic* music);+++instance SFSoundBuffer Music where+    +    {-# INLINABLE getChannelCount #-}+    getChannelCount = sfMusic_getChannelCount >=> return . fromIntegral+    +    {-# INLINABLE getDuration #-}+    getDuration music = alloca $ \ptr -> sfMusic_getDuration_helper music ptr >> peek ptr+++foreign import ccall unsafe "sfMusic_getDuration_helper"+    sfMusic_getDuration_helper :: Music -> Ptr Time -> IO ()++-- CSFML_AUDIO_API sfTime sfMusic_getDuration(const sfMusic* music);++foreign import ccall unsafe "sfMusic_getChannelCount"+    sfMusic_getChannelCount :: Music -> IO CUInt++-- CSFML_AUDIO_API unsigned int sfMusic_getChannelCount(const sfMusic* music);+++instance SFSampled Music where+    +    {-# INLINABLE getSampleRate #-}+    getSampleRate = sfMusic_getSampleRate+++foreign import ccall unsafe "sfMusic_getSampleRate"+    sfMusic_getSampleRate :: Music -> IO Int++-- CSFML_AUDIO_API unsigned int sfMusic_getSampleRate(const sfMusic* music);+++instance SFSound Music where+    +    {-# INLINABLE play #-}+    play = sfMusic_play+    +    {-# INLINABLE pause #-}+    pause = sfMusic_pause+    +    {-# INLINABLE stop #-}+    stop = sfMusic_stop+    +    {-# INLINABLE getAttenuation #-}+    getAttenuation = sfMusic_getAttenuation >=> return . realToFrac+    +    {-# INLINABLE getLoop #-}+    getLoop music = fmap (toEnum . fromIntegral) $ sfMusic_getLoop music+    +    {-# INLINABLE getMinDistance #-}+    getMinDistance = sfMusic_getMinDistance >=> return . realToFrac+    +    {-# INLINABLE getPitch #-}+    getPitch = sfMusic_getPitch >=> return . realToFrac+    +    {-# INLINABLE getPlayingOffset #-}+    getPlayingOffset music = alloca $ \ptr -> sfMusic_getPlayingOffset_helper music ptr >> peek ptr+    +    {-# INLINABLE getPosition #-}+    getPosition music = alloca $ \ptr -> sfMusic_getPosition_helper music ptr >> peek ptr+    +    {-# INLINABLE getStatus #-}+    getStatus = sfMusic_getStatus >=> return . toEnum . fromIntegral+    +    {-# INLINABLE getVolume #-}+    getVolume = sfMusic_getVolume >=> return . realToFrac+    +    {-# INLINABLE isRelativeToListener #-}+    isRelativeToListener = sfMusic_isRelativeToListener >=> return . toEnum . fromIntegral+    +    {-# INLINABLE setAttenuation #-}+    setAttenuation m a = sfMusic_setAttenuation m $ realToFrac a+    +    {-# INLINABLE setLoop #-}+    setLoop music val = sfMusic_setLoop music (fromIntegral . fromEnum $ val)+    +    {-# INLINABLE setMinDistance #-}+    setMinDistance m d = sfMusic_setMinDistance m $ realToFrac d+    +    {-# INLINABLE setPitch #-}+    setPitch m p = sfMusic_setPitch m $ realToFrac p+    +    {-# INLINABLE setPlayingOffset #-}+    setPlayingOffset = sfMusic_setPlayingOffset+    +    {-# INLINABLE setPosition #-}+    setPosition music pos = with pos $ sfMusic_setPosition_helper music+    +    {-# INLINABLE setRelativeToListener #-}+    setRelativeToListener music val = sfMusic_setRelativeToListener music (fromIntegral . fromEnum $ val)+    +    {-# INLINABLE setVolume #-}+    setVolume m v = sfMusic_setVolume m $ realToFrac v+++foreign import ccall unsafe "sfMusic_play"+    sfMusic_play :: Music -> IO ()++-- CSFML_AUDIO_API void sfMusic_play(sfMusic* music);++foreign import ccall unsafe "sfMusic_pause"+    sfMusic_pause :: Music -> IO ()++-- CSFML_AUDIO_API void sfMusic_pause(sfMusic* music);++foreign import ccall unsafe "sfMusic_stop"+    sfMusic_stop :: Music -> IO ()++-- CSFML_AUDIO_API void sfMusic_stop(sfMusic* music);++foreign import ccall unsafe "sfMusic_getAttenuation"+    sfMusic_getAttenuation :: Music -> IO CFloat++-- CSFML_AUDIO_API float sfMusic_getAttenuation(const sfMusic* music);++foreign import ccall unsafe "sfMusic_getLoop"+    sfMusic_getLoop :: Music -> IO CInt++-- CSFML_AUDIO_API sfBool sfMusic_getLoop(const sfMusic* music);++foreign import ccall unsafe "sfMusic_getMinDistance"+    sfMusic_getMinDistance :: Music -> IO CFloat++-- CSFML_AUDIO_API float sfMusic_getMinDistance(const sfMusic* music);++foreign import ccall unsafe "sfMusic_getPitch"+    sfMusic_getPitch :: Music -> IO CFloat++-- CSFML_AUDIO_API float sfMusic_getPitch(const sfMusic* music);++foreign import ccall unsafe "sfMusic_getPlayingOffset_helper"+    sfMusic_getPlayingOffset_helper :: Music -> Ptr Time -> IO ()++-- CSFML_AUDIO_API sfTime sfMusic_getPlayingOffset(const sfMusic* music);++foreign import ccall unsafe "sfMusic_getPosition_helper"+    sfMusic_getPosition_helper :: Music -> Ptr Vec3f -> IO ()++-- CSFML_AUDIO_API sfVector3f sfMusic_getPosition(const sfMusic* music);++foreign import ccall unsafe "sfMusic_getStatus"+    sfMusic_getStatus :: Music -> IO CInt++-- CSFML_AUDIO_API sfSoundStatus sfMusic_getStatus(const sfMusic* music);++foreign import ccall unsafe "sfMusic_getVolume"+    sfMusic_getVolume :: Music -> IO CFloat++-- CSFML_AUDIO_API float sfMusic_getVolume(const sfMusic* music);++foreign import ccall unsafe "sfMusic_isRelativeToListener"+    sfMusic_isRelativeToListener :: Music -> IO CInt++-- CSFML_AUDIO_API sfBool sfMusic_isRelativeToListener(const sfMusic* music);++foreign import ccall unsafe "sfMusic_setAttenuation"+    sfMusic_setAttenuation :: Music -> CFloat -> IO ()++-- CSFML_AUDIO_API void sfMusic_setAttenuation(sfMusic* music, float attenuation);++foreign import ccall unsafe "sfMusic_setLoop"+    sfMusic_setLoop :: Music -> CInt -> IO ()++-- CSFML_AUDIO_API void sfMusic_setLoop(sfMusic* music, sfBool loop);++foreign import ccall unsafe "sfMusic_setMinDistance"+    sfMusic_setMinDistance :: Music -> CFloat -> IO ()++-- CSFML_AUDIO_API void sfMusic_setMinDistance(sfMusic* music, float distance);++foreign import ccall unsafe "sfMusic_setPitch"+    sfMusic_setPitch :: Music -> CFloat -> IO ()++-- CSFML_AUDIO_API void sfMusic_setPitch(sfMusic* music, float pitch);++foreign import ccall unsafe "sfMusic_setPlayingOffset"+    sfMusic_setPlayingOffset :: Music -> Time -> IO ()++-- CSFML_AUDIO_API void sfMusic_setPlayingOffset(sfMusic* music, sfTime timeOffset);++foreign import ccall unsafe "sfMusic_setPosition_helper"+    sfMusic_setPosition_helper :: Music -> Ptr Vec3f -> IO ()++-- CSFML_AUDIO_API void sfMusic_setPosition(sfMusic* music, sfVector3f position);++foreign import ccall unsafe "sfMusic_setRelativeToListener"+    sfMusic_setRelativeToListener :: Music -> CInt -> IO ()++-- CSFML_AUDIO_API void sfMusic_setRelativeToListener(sfMusic* music, sfBool relative);++foreign import ccall unsafe "sfMusic_setVolume"+    sfMusic_setVolume :: Music -> CFloat -> IO ()++-- CSFML_AUDIO_API void sfMusic_setVolume(sfMusic* music, float volume);+
+ src/SFML/Audio/SFSampled.hs view
@@ -0,0 +1,13 @@+module SFML.Audio.SFSampled+where+++class SFSampled a where+    +    -- | Get the sample rate of a sound buffer.+    --+    -- The sample rate is the number of samples played per second.+    -- The higher, the better the quality (for example, 44100+    -- samples/s is CD quality).+    getSampleRate :: a -> IO Int+
+ src/SFML/Audio/SFSound.hs view
@@ -0,0 +1,136 @@+module SFML.Audio.SFSound+where+++import SFML.Audio.SoundStatus+import SFML.System.Time+import SFML.System.Vector3+++class SFSound a where+    +    -- | Start or resume playing a sound.+    -- +    -- This function starts the sound if it was stopped, resumes+    -- it if it was paused, and restarts it from beginning if it+    -- was it already playing.+    -- +    -- This function uses its own thread so that it doesn't block+    -- the rest of the program while the sound is played.+    play :: a -> IO ()+    +    -- | Pause a sound.+    -- +    -- This function pauses the sound if it was playing,+    -- otherwise (sound already paused or stopped) it has no effect.+    pause :: a -> IO ()+    +    -- | Stop playing a sound.+    -- +    -- This function stops the sound if it was playing or paused,+    -- and does nothing if it was already stopped.+    -- +    -- It also resets the playing position (unlike 'pause').+    stop :: a -> IO ()+    +    -- | Get the attenuation factor of a sound.+    getAttenuation :: a -> IO Float+    +    -- | Tell whether or not a sound is in loop mode.+    getLoop :: a -> IO Bool+    +    -- | Get the minimum distance of a sound.+    getMinDistance :: a -> IO Float+    +    -- | Get the pitch of a sound.+    getPitch :: a -> IO Float+    +    -- | Get the current playing position of a sound.+    getPlayingOffset :: a -> IO Time+    +    -- | Get the 3D position of a sound in the audio scene.+    getPosition :: a -> IO Vec3f+    +    -- | Get the current status of a sound (stopped, paused, playing).+    getStatus :: a -> IO SoundStatus+    +    -- | Get the volume of a sound.+    getVolume :: a -> IO Float+    +    -- | Tell whether a sound's position is relative to the listener or is absolute.+    isRelativeToListener :: a -> IO Bool+    +    -- | Set the attenuation factor of a sound.+    -- +    -- The attenuation is a multiplicative factor which makes+    -- the sound more or less loud according to its distance+    -- from the listener. An attenuation of 0 will produce a+    -- non-attenuated sound, i.e. its volume will always be the same+    -- whether it is heard from near or from far. On the other hand,+    -- an attenuation value such as 100 will make the sound fade out+    -- very quickly as it gets further from the listener.+    -- +    -- The default value of the attenuation is 1.+    setAttenuation :: a -> Float -> IO ()+    +    -- | Set whether or not a sound should loop after reaching the end.+    -- +    -- If set, the sound will restart from beginning after+    -- reaching the end and so on, until it is stopped or+    -- 'setLoop' 'False' is called.+    -- +    -- The default looping state for sounds is false.+    setLoop :: a -> Bool -> IO ()+    +    -- | Set the minimum distance of a sound.+    -- +    -- The minimum distance of a sound is the maximum+    -- distance at which it is heard at its maximum volume. Further+    -- than the minimum distance, it will start to fade out according+    -- to its attenuation factor. A value of 0 (inside the head+    -- of the listener) is an invalid value and is forbidden.+    -- +    -- The default value of the minimum distance is 1.+    setMinDistance :: a -> Float -> IO ()+    +    -- | Set the pitch of a sound.+    -- +    -- The pitch represents the perceived fundamental frequency+    -- of a sound; thus you can make a sound more acute or grave+    -- by changing its pitch. A side effect of changing the pitch+    -- is to modify the playing speed of the sound as well.+    -- +    -- The default value for the pitch is 1.+    setPitch :: a -> Float -> IO ()+    +    -- | Change the current playing position of a sound.+    -- +    -- The playing position can be changed when the sound is+    -- either paused or playing.+    setPlayingOffset :: a -> Time -> IO ()+    +    -- | Set the 3D position of a sound in the audio scene.+    -- +    -- Only sounds with one channel (mono sounds) can be+    -- spatialized.+    -- +    -- The default position of a sound is (0, 0, 0).+    setPosition :: a -> Vec3f -> IO ()+    +    -- | Make the sound's position relative to the listener or absolute.+    -- +    -- Making a sound relative to the listener will ensure that it will always+    -- be played the same way regardless the position of the listener.+    -- This can be useful for non-spatialized sounds, sounds that are+    -- produced by the listener, or sounds attached to it.+    -- +    -- The default value is false (position is absolute).+    setRelativeToListener :: a -> Bool -> IO ()+    +    -- | Set the volume of a sound.+    -- +    -- The volume is a value between 0 (mute) and 100 (full volume).+    -- +    -- The default value for the volume is 100.+    setVolume :: a -> Float -> IO ()+
+ src/SFML/Audio/SFSoundBuffer.hs view
@@ -0,0 +1,18 @@+module SFML.Audio.SFSoundBuffer+where+++import SFML.System.Time (Time)+++class SFSoundBuffer a where+    +    -- | Get the number of channels used by a sound buffer.+    --+    -- If the sound is mono then the number of channels will+    -- be 1, 2 for stereo, etc.+    getChannelCount :: a -> IO Int+    +    -- | Get the total duration of a sound buffer.+    getDuration :: a -> IO Time+
+ src/SFML/Audio/SFSoundRecorder.hs view
@@ -0,0 +1,24 @@+module SFML.Audio.SFSoundRecorder+where+++class SFSoundRecorder a where+    +    -- | Start the capture of a sound recorder.+    --+    -- The sample rate parameter defines the number of audio samples+    -- captured per second. The higher, the better the quality+    -- (for example, 44100 samples/sec is CD quality).+    --+    -- This function uses its own thread so that it doesn't block+    -- the rest of the program while the capture runs.+    -- +    -- Please note that only one capture can happen at the same time.+    startRecording+        :: a+        -> Int -- ^ Desired capture rate, in number of samples per second+        -> IO ()+    +    -- | Stop the capture of a sound recorder.+    stopRecording :: a -> IO ()+
+ src/SFML/Audio/Sound.hs view
@@ -0,0 +1,264 @@+module SFML.Audio.Sound+(+    createSound+,   copySound+,   destroy+,   play+,   pause+,   stop+,   setSoundBuffer+,   getSoundBuffer+,   setLoop+,   getLoop+,   getStatus+,   setPitch+,   setVolume+,   setPosition+,   setRelativeToListener+,   setMinDistance+,   setAttenuation+,   setPlayingOffset+,   getPitch+,   getVolume+,   getPosition+,   isRelativeToListener+,   getMinDistance+,   getAttenuation+,   getPlayingOffset+)+where+++import SFML.Audio.SFSound+import SFML.Audio.SoundStatus+import SFML.Audio.Types+import SFML.SFResource+import SFML.System.Time+import SFML.System.Vector3++import Control.Monad ((>=>))+import Foreign.C.Types+import Foreign.Ptr (Ptr)+import Foreign.Storable (peek)+import Foreign.Marshal.Alloc (alloca)+import Foreign.Marshal.Utils (with)+++-- | Create a new sound.+createSound :: IO Sound+createSound = sfSound_create++foreign import ccall unsafe "sfSound_create"+    sfSound_create :: IO Sound++-- CSFML_AUDIO_API sfSound* sfSound_create(void);+++-- | Create a new sound by copying an existing one.+copySound :: Sound -> IO Sound+copySound = sfSound_copy++foreign import ccall unsafe "sfSound_copy"+    sfSound_copy :: Sound -> IO Sound++-- CSFML_AUDIO_API sfSound* sfSound_copy(sfSound* sound);+++instance SFResource Sound where+    +    {-# INLINABLE destroy #-}+    destroy = sfSound_destroy++foreign import ccall unsafe "sfSound_destroy"+    sfSound_destroy :: Sound -> IO ()++-- CSFML_AUDIO_API void sfSound_destroy(sfSound* sound);+++-- | Set the source buffer containing the audio data to play.+-- +-- It is important to note that the sound buffer is not copied,+-- thus the 'SoundBuffer' object must remain alive as long+-- as it is attached to the sound.+setSoundBuffer :: Sound -> SoundBuffer -> IO ()+setSoundBuffer = sfSound_setBuffer++foreign import ccall unsafe "sfSound_setBuffer"+    sfSound_setBuffer :: Sound -> SoundBuffer -> IO ()++-- CSFML_AUDIO_API void sfSound_setBuffer(sfSound* sound, const sfSoundBuffer* buffer);+++-- | Get the audio buffer attached to a sound.+getSoundBuffer :: Sound -> IO SoundBuffer+getSoundBuffer = sfSound_getBuffer++foreign import ccall unsafe "sfSound_getBuffer"+    sfSound_getBuffer :: Sound -> IO SoundBuffer++-- CSFML_AUDIO_API const sfSoundBuffer* sfSound_getBuffer(const sfSound* sound);+++instance SFSound Sound where+    +    {-# INLINABLE play #-}+    play = sfSound_play+    +    {-# INLINABLE pause #-}+    pause = sfSound_pause+    +    {-# INLINABLE stop #-}+    stop = sfSound_stop+    +    {-# INLINABLE getAttenuation #-}+    getAttenuation = sfSound_getAttenuation >=> return . realToFrac+    +    {-# INLINABLE getLoop #-}+    getLoop = sfSound_getLoop >=> return . toEnum . fromIntegral+    +    {-# INLINABLE getMinDistance #-}+    getMinDistance = sfSound_getMinDistance >=> return . realToFrac+    +    {-# INLINABLE getPitch #-}+    getPitch = sfSound_getPitch >=> return . realToFrac+    +    {-# INLINABLE getPlayingOffset #-}+    getPlayingOffset sound = alloca $ \ptr -> sfSound_getPlayingOffset_helper sound ptr >> peek ptr+    +    {-# INLINABLE getPosition #-}+    getPosition sound = alloca $ \ptr -> sfSound_getPosition_helper sound ptr >> peek ptr+    +    {-# INLINABLE getStatus #-}+    getStatus = sfSound_getStatus >=> return . toEnum . fromIntegral+    +    {-# INLINABLE getVolume #-}+    getVolume = sfSound_getVolume >=> return . realToFrac+    +    {-# INLINABLE isRelativeToListener #-}+    isRelativeToListener = sfSound_isRelativeToListener >=> return . toEnum . fromIntegral+    +    {-# INLINABLE setAttenuation #-}+    setAttenuation m a = sfSound_setAttenuation m (realToFrac a)+    +    {-# INLINABLE setLoop #-}+    setLoop sound val = sfSound_setLoop sound (fromIntegral . fromEnum $ val)+    +    {-# INLINABLE setMinDistance #-}+    setMinDistance m d = sfSound_setMinDistance m (realToFrac d)+    +    {-# INLINABLE setPitch #-}+    setPitch m p = sfSound_setPitch m (realToFrac p)+    +    {-# INLINABLE setPlayingOffset #-}+    setPlayingOffset = sfSound_setPlayingOffset+    +    {-# INLINABLE setPosition #-}+    setPosition sound pos = with pos $ sfSound_setPosition_helper sound+    +    {-# INLINABLE setRelativeToListener #-}+    setRelativeToListener sound val = sfSound_setRelativeToListener sound (fromIntegral . fromEnum $ val)+    +    {-# INLINABLE setVolume #-}+    setVolume m v = sfSound_setVolume m (realToFrac v)+++foreign import ccall unsafe "sfSound_play"+    sfSound_play :: Sound -> IO ()++-- CSFML_AUDIO_API void sfSound_play(sfSound* sound);++foreign import ccall unsafe "sfSound_pause"+    sfSound_pause :: Sound -> IO ()++-- CSFML_AUDIO_API void sfSound_pause(sfSound* sound);++foreign import ccall unsafe "sfSound_stop"+    sfSound_stop :: Sound -> IO ()++-- CSFML_AUDIO_API void sfSound_stop(sfSound* sound);++foreign import ccall unsafe "sfSound_getAttenuation"+    sfSound_getAttenuation :: Sound -> IO CFloat++-- CSFML_AUDIO_API float sfSound_getAttenuation(const sfSound* sound);++foreign import ccall unsafe "sfSound_getLoop"+    sfSound_getLoop :: Sound -> IO CInt++-- CSFML_AUDIO_API sfBool sfSound_getLoop(const sfSound* sound);++foreign import ccall unsafe "sfSound_getMinDistance"+    sfSound_getMinDistance :: Sound -> IO CFloat++-- CSFML_AUDIO_API float sfSound_getMinDistance(const sfSound* sound);++foreign import ccall unsafe "sfSound_getPitch"+    sfSound_getPitch :: Sound -> IO CFloat++-- CSFML_AUDIO_API float sfSound_getPitch(const sfSound* sound);++foreign import ccall unsafe "sfSound_getPlayingOffset_helper"+    sfSound_getPlayingOffset_helper :: Sound -> Ptr Time -> IO ()++-- CSFML_AUDIO_API sfTime sfSound_getPlayingOffset(const sfSound* sound);++foreign import ccall unsafe "sfSound_getPosition_helper"+    sfSound_getPosition_helper :: Sound -> Ptr Vec3f -> IO ()++-- CSFML_AUDIO_API sfVector3f sfSound_getPosition(const sfSound* sound);++foreign import ccall unsafe "sfSound_getStatus"+    sfSound_getStatus :: Sound -> IO CInt++-- CSFML_AUDIO_API sfSoundStatus sfSound_getStatus(const sfSound* sound);++foreign import ccall unsafe "sfSound_getVolume"+    sfSound_getVolume :: Sound -> IO CFloat++-- CSFML_AUDIO_API float sfSound_getVolume(const sfSound* sound);++foreign import ccall unsafe "sfSound_isRelativeToListener"+    sfSound_isRelativeToListener :: Sound -> IO CInt++-- CSFML_AUDIO_API sfBool sfSound_isRelativeToListener(const sfSound* sound);++foreign import ccall unsafe "sfSound_setAttenuation"+    sfSound_setAttenuation :: Sound -> CFloat -> IO ()++-- CSFML_AUDIO_API void sfSound_setAttenuation(sfSound* sound, float attenuation);++foreign import ccall unsafe "sfSound_setLoop"+    sfSound_setLoop :: Sound -> CInt -> IO ()++-- CSFML_AUDIO_API void sfSound_setLoop(sfSound* sound, sfBool loop);++foreign import ccall unsafe "sfSound_setMinDistance"+    sfSound_setMinDistance :: Sound -> CFloat -> IO ()++-- CSFML_AUDIO_API void sfSound_setMinDistance(sfSound* sound, float distance);++foreign import ccall unsafe "sfSound_setPitch"+    sfSound_setPitch :: Sound -> CFloat -> IO ()++-- CSFML_AUDIO_API void sfSound_setPitch(sfSound* sound, float pitch);++foreign import ccall unsafe "sfSound_setPlayingOffset"+    sfSound_setPlayingOffset :: Sound -> Time -> IO ()++-- CSFML_AUDIO_API void sfSound_setPlayingOffset(sfSound* sound, sfTime timeOffset);++foreign import ccall unsafe "sfSound_setPosition_helper"+    sfSound_setPosition_helper :: Sound -> Ptr Vec3f -> IO ()++-- CSFML_AUDIO_API void sfSound_setPosition(sfSound* sound, sfVector3f position);++foreign import ccall unsafe "sfSound_setRelativeToListener"+    sfSound_setRelativeToListener :: Sound -> CInt -> IO ()++-- CSFML_AUDIO_API void sfSound_setRelativeToListener(sfSound* sound, sfBool relative);++foreign import ccall unsafe "sfSound_setVolume"+    sfSound_setVolume :: Sound -> CFloat -> IO ()++-- CSFML_AUDIO_API void sfSound_setVolume(sfSound* sound, float volume);+
+ src/SFML/Audio/SoundBuffer.hs view
@@ -0,0 +1,226 @@+{-# LANGUAGE DeriveDataTypeable #-}+module SFML.Audio.SoundBuffer+(+    module SFML.Utils+,   SoundBufferException(..)+,   soundBufferFromFile+,   soundBufferFromMemory+,   soundBufferFromStream+,   soundBufferFromSamples+,   copySoundBuffer+,   destroy+,   saveSoundBufferToFile+,   getSamples+,   getSampleCount+,   getSampleRate+,   getChannelCount+,   getDuration+)+where+++import SFML.Audio.SFSampled+import SFML.Audio.SFSoundBuffer+import SFML.Audio.Types+import SFML.SFResource+import SFML.System.InputStream+import SFML.System.Time+import SFML.Utils++import Control.Exception+import Control.Monad ((>=>))+import Data.Typeable+import Foreign.C.String+import Foreign.C.Types+import Foreign.Marshal.Alloc (alloca)+import Foreign.Marshal.Utils (with)+import Foreign.Ptr (Ptr, nullPtr)+import Foreign.Storable (peek)+++checkNull :: SoundBuffer -> Maybe SoundBuffer+checkNull buf@(SoundBuffer ptr) = if ptr == nullPtr then Nothing else Just buf+++data SoundBufferException = SoundBufferException String deriving (Show, Typeable)++instance Exception SoundBufferException+++-- | Create a new sound buffer and load it from a file.+--+-- Here is a complete list of all the supported audio formats:+-- ogg, wav, flac, aiff, au, raw, paf, svx, nist, voc, ircam,+-- w64, mat4, mat5 pvf, htk, sds, avr, sd2, caf, wve, mpc2k, rf64.+soundBufferFromFile :: FilePath -> IO (Either SoundBufferException SoundBuffer)+soundBufferFromFile path =+    let err = SoundBufferException $ "Failed loading sound buffer from file: " ++ show path+    in fmap (tagErr err . checkNull) $ withCAString path sfSoundBuffer_createFromFile++foreign import ccall unsafe "sfSoundBuffer_createFromFile"+    sfSoundBuffer_createFromFile :: CString -> IO SoundBuffer++-- \return A new sfSoundBuffer object (NULL if failed)++-- CSFML_AUDIO_API sfSoundBuffer* sfSoundBuffer_createFromFile(const char* filename);+++-- | Create a new sound buffer and load it from a file in memory.+--+-- Here is a complete list of all the supported audio formats:+-- ogg, wav, flac, aiff, au, raw, paf, svx, nist, voc, ircam,+-- w64, mat4, mat5 pvf, htk, sds, avr, sd2, caf, wve, mpc2k, rf64.+soundBufferFromMemory+    :: Ptr a -- ^ Pointer to the file data in memory+    -> Int   -- ^ Size of the data to load, in bytes+    -> IO (Either SoundBufferException SoundBuffer) -- ^ A new sfSoundBuffer object ('Nothing' if failed)++soundBufferFromMemory ptr size =+    let err = SoundBufferException $ "Failed loading sound buffer from memory address " ++ show ptr+    in sfSoundBuffer_createFromMemory ptr (fromIntegral size) >>= return . tagErr err . checkNull++foreign import ccall unsafe "sfSoundBuffer_createFromMemory"+    sfSoundBuffer_createFromMemory :: Ptr a -> CUInt -> IO SoundBuffer++-- CSFML_AUDIO_API sfSoundBuffer* sfSoundBuffer_createFromMemory(const void* data, size_t sizeInBytes);+++-- | Create a new sound buffer and load it from a custom stream.+--+-- Here is a complete list of all the supported audio formats:+-- ogg, wav, flac, aiff, au, raw, paf, svx, nist, voc, ircam,+-- w64, mat4, mat5 pvf, htk, sds, avr, sd2, caf, wve, mpc2k, rf64.+soundBufferFromStream+    :: InputStream+    -> IO (Either SoundBufferException SoundBuffer) -- ^ A new sfSoundBuffer object ('Nothing' if failed)++soundBufferFromStream is =+    let err = SoundBufferException $ "Failed loading sound buffer from input stream " ++ show is+    in with is sfSoundBuffer_createFromStream >>= return . tagErr err . checkNull++foreign import ccall unsafe "sfSoundBuffer_createFromStream"+    sfSoundBuffer_createFromStream :: Ptr InputStream -> IO SoundBuffer++-- CSFML_AUDIO_API sfSoundBuffer* sfSoundBuffer_createFromStream(sfInputStream* stream);+++-- | Create a new sound buffer and load it from an array of samples in memory.+--+-- The assumed format of the audio samples is 16 bits signed integer+-- (sfInt16).+soundBufferFromSamples+    :: Ptr a -- ^ Pointer to the array of samples in memory+    -> Int   -- ^ Number of samples in the array+    -> Int   -- ^ Number of channels (1 = mono, 2 = stereo, ...)+    -> Int   -- ^ Sample rate (number of samples to play per second)+    -> IO (Maybe SoundBuffer) -- ^ A new sfSoundBuffer object ('Nothing' if failed)++soundBufferFromSamples ptr i j k =+    sfSoundBuffer_createFromSamples ptr (fromIntegral i) (fromIntegral j) (fromIntegral k) >>= return . checkNull++foreign import ccall unsafe "sfSoundBuffer_createFromSamples"+    sfSoundBuffer_createFromSamples :: Ptr a -> CUInt -> CUInt -> CUInt -> IO SoundBuffer++-- CSFML_AUDIO_API sfSoundBuffer* sfSoundBuffer_createFromSamples(const sfInt16* samples, size_t sampleCount, unsigned int channelCount, unsigned int sampleRate);+++-- | Create a new sound buffer by copying an existing one.+copySoundBuffer :: SoundBuffer -> IO SoundBuffer+copySoundBuffer = sfSoundBuffer_copy++foreign import ccall unsafe "sfSoundBuffer_copy"+    sfSoundBuffer_copy :: SoundBuffer -> IO SoundBuffer++-- CSFML_AUDIO_API sfSoundBuffer* sfSoundBuffer_copy(sfSoundBuffer* soundBuffer);+++instance SFResource SoundBuffer where+    +    {-# INLINABLE destroy #-}+    destroy = sfSoundBuffer_destroy++foreign import ccall unsafe "sfSoundBuffer_destroy"+    sfSoundBuffer_destroy :: SoundBuffer -> IO ()++-- CSFML_AUDIO_API void sfSoundBuffer_destroy(sfSoundBuffer* soundBuffer);+++-- | Save a sound buffer to an audio file.+--+-- Here is a complete list of all the supported audio formats:+-- ogg, wav, flac, aiff, au, raw, paf, svx, nist, voc, ircam,+-- w64, mat4, mat5 pvf, htk, sds, avr, sd2, caf, wve, mpc2k, rf64.+saveSoundBufferToFile+    :: SoundBuffer+    -> FilePath -- ^ Path of the sound file to write+    -> IO Bool  -- ^ 'True' if saving succeeded, 'False' if it failed++saveSoundBufferToFile sb path = fmap (toEnum . fromIntegral) . withCAString path $ sfSoundBuffer_saveToFile sb++foreign import ccall unsafe "sfSoundBuffer_saveToFile"+    sfSoundBuffer_saveToFile :: SoundBuffer -> CString -> IO CInt++-- CSFML_AUDIO_API sfBool sfSoundBuffer_saveToFile(const sfSoundBuffer* soundBuffer, const char* filename);+++-- | Get the array of audio samples stored in a sound buffer.+--+-- The format of the returned samples is 16 bits signed integer+-- (sfInt16). The total number of samples in this array+-- is given by the 'getSampleCount' function.+getSamples+    :: SoundBuffer+    -> IO (Ptr a) -- ^ Read-only pointer to the array of sound samples++getSamples = sfSoundBuffer_getSamples++foreign import ccall unsafe "sfSoundBuffer_getSamples"+    sfSoundBuffer_getSamples :: SoundBuffer -> IO (Ptr a)++-- CSFML_AUDIO_API const sfInt16* sfSoundBuffer_getSamples(const sfSoundBuffer* soundBuffer);+++-- | Get the number of samples stored in a sound buffer.+--+-- The array of samples can be accessed with the+-- sfSoundBuffer_getSamples function.+getSampleCount :: SoundBuffer -> IO Int+getSampleCount = sfSoundBuffer_getSampleCount >=> return . fromIntegral++foreign import ccall unsafe "sfSoundBuffer_getSampleCount"+    sfSoundBuffer_getSampleCount :: SoundBuffer -> IO CUInt++-- CSFML_AUDIO_API size_t sfSoundBuffer_getSampleCount(const sfSoundBuffer* soundBuffer);+++instance SFSoundBuffer SoundBuffer where+    +    {-# INLINABLE getChannelCount #-}+    getChannelCount = sfSoundBuffer_getChannelCount >=> return . fromIntegral+    +    {-# INLINABLE getDuration #-}+    getDuration sb = alloca $ \ptr -> sfSoundBuffer_getDuration_helper sb ptr >> peek ptr+++foreign import ccall unsafe "sfSoundBuffer_getChannelCount"+    sfSoundBuffer_getChannelCount :: SoundBuffer -> IO CUInt++-- CSFML_AUDIO_API unsigned int sfSoundBuffer_getChannelCount(const sfSoundBuffer* soundBuffer);++foreign import ccall unsafe "sfSoundBuffer_getDuration_helper"+    sfSoundBuffer_getDuration_helper :: SoundBuffer -> Ptr Time -> IO ()++-- CSFML_AUDIO_API sfTime sfSoundBuffer_getDuration(const sfSoundBuffer* soundBuffer);+++instance SFSampled SoundBuffer where+    +    {-# INLINABLE getSampleRate #-}+    getSampleRate = sfSoundBuffer_getSampleRate >=> return . fromIntegral+++foreign import ccall unsafe "sfSoundBuffer_getSampleRate"+    sfSoundBuffer_getSampleRate :: SoundBuffer -> IO CUInt++-- CSFML_AUDIO_API unsigned int sfSoundBuffer_getSampleRate(const sfSoundBuffer* soundBuffer);+
+ src/SFML/Audio/SoundBufferRecorder.hs view
@@ -0,0 +1,111 @@+{-# LANGUAGE DeriveDataTypeable #-}+module SFML.Audio.SoundBufferRecorder+(+    module SFML.Utils+,   SoundBufferRecorderException(..)+,   createSoundBufferRecorder+,   destroy+,   startRecording+,   stopRecording+,   getSampleRate+,   getRecorderBuffer+)+where+++import SFML.Audio.SFSampled+import SFML.Audio.SFSoundRecorder+import SFML.Audio.Types+import SFML.SFResource+import SFML.Utils++import Control.Exception+import Control.Monad ((>=>))+import Data.Typeable+import Foreign.C.Types+import Foreign.Ptr (nullPtr)+++checkNull :: SoundBufferRecorder -> Maybe SoundBufferRecorder+checkNull sbr@(SoundBufferRecorder ptr) = if ptr == nullPtr then Nothing else Just sbr+++data SoundBufferRecorderException = SoundBufferRecorderException String deriving (Show, Typeable)++instance Exception SoundBufferRecorderException+++-- | Create a new sound buffer recorder.+createSoundBufferRecorder :: IO (Either SoundBufferRecorderException SoundBufferRecorder)+createSoundBufferRecorder =+    let err = SoundBufferRecorderException $ "Failed creating sound buffer recorder"+    in fmap (tagErr err . checkNull) sfSoundBufferRecorder_create++foreign import ccall unsafe "sfSoundBufferRecorder_create"+    sfSoundBufferRecorder_create :: IO SoundBufferRecorder++-- \return A new sfSoundBufferRecorder object (NULL if failed)++-- CSFML_AUDIO_API sfSoundBufferRecorder* sfSoundBufferRecorder_create(void);+++instance SFResource SoundBufferRecorder where+    +    {-# INLINABLE destroy #-}+    destroy = sfSoundBufferRecorder_destroy++foreign import ccall unsafe "sfSoundBufferRecorder_destroy"+    sfSoundBufferRecorder_destroy :: SoundBufferRecorder -> IO ()++-- CSFML_AUDIO_API void sfSoundBufferRecorder_destroy(sfSoundBufferRecorder* soundBufferRecorder);+++instance SFSoundRecorder SoundBufferRecorder where+    +    {-# INLINABLE startRecording #-}+    startRecording rec rate = sfSoundBufferRecorder_start rec (fromIntegral rate)+    +    {-# INLINABLE stopRecording #-}+    stopRecording = sfSoundBufferRecorder_stop+++foreign import ccall unsafe "sfSoundBufferRecorder_start"+    sfSoundBufferRecorder_start :: SoundBufferRecorder -> CUInt -> IO ()++-- CSFML_AUDIO_API void sfSoundBufferRecorder_start(sfSoundBufferRecorder* soundBufferRecorder, unsigned int sampleRate);++foreign import ccall unsafe "sfSoundBufferRecorder_stop"+    sfSoundBufferRecorder_stop :: SoundBufferRecorder -> IO ()++-- CSFML_AUDIO_API void sfSoundBufferRecorder_stop(sfSoundBufferRecorder* soundBufferRecorder);+++instance SFSampled SoundBufferRecorder where+    +    {-# INLINABLE getSampleRate #-}+    getSampleRate = sfSoundBufferRecorder_getSampleRate >=> return . fromIntegral+++foreign import ccall unsafe "sfSoundBufferRecorder_getSampleRate"+    sfSoundBufferRecorder_getSampleRate :: SoundBufferRecorder -> IO CUInt++-- CSFML_AUDIO_API unsigned int sfSoundBufferRecorder_getSampleRate(const sfSoundBufferRecorder* soundBufferRecorder);+++-- | Get the sound buffer containing the captured audio data.+--+-- The sound buffer is valid only after the capture has ended.+-- This function provides a read-only access to the internal+-- sound buffer, but it can be copied if you need to+-- make any modification to it.+getRecorderBuffer+    :: SoundBufferRecorder+    -> IO SoundBuffer -- ^ Read-only access to the sound buffer++getRecorderBuffer = sfSoundBufferRecorder_getBuffer++foreign import ccall unsafe "sfSoundBufferRecorder_getBuffer"+    sfSoundBufferRecorder_getBuffer :: SoundBufferRecorder -> IO SoundBuffer++-- CSFML_AUDIO_API const sfSoundBuffer* sfSoundBufferRecorder_getBuffer(const sfSoundBufferRecorder* soundBufferRecorder);+
+ src/SFML/Audio/SoundRecorder.hs view
@@ -0,0 +1,141 @@+{-# LANGUAGE DeriveDataTypeable #-}+module SFML.Audio.SoundRecorder+(+    module SFML.Utils+,   SoundRecorderException(..)+,   SoundRecorderStartCallback+,   SoundRecorderProcessCallback+,   SoundRecorderStopCallback+,   createSoundRecorder+,   destroy+,   startRecording+,   stopRecording+,   getSampleRate+,   isSoundRecorderAvailable+)+where+++import SFML.Audio.SFSampled+import SFML.Audio.SFSoundRecorder+import SFML.Audio.Types+import SFML.SFResource+import SFML.Utils++import Control.Exception+import Control.Monad ((>=>))+import Data.Typeable+import Data.Word (Word16)+import Foreign.C.Types+import Foreign.Ptr (Ptr, nullPtr)+++checkNull :: SoundRecorder -> Maybe SoundRecorder+checkNull sr@(SoundRecorder ptr) = if ptr == nullPtr then Nothing else Just sr+++data SoundRecorderException = SoundRecorderException String deriving (Show, Typeable)++instance Exception SoundRecorderException+++-- | Type of the callback used when starting a capture.+type SoundRecorderStartCallback a = Ptr a -> IO CInt++-- | Type of the callback used to process audio data.+type SoundRecorderProcessCallback a = Ptr Word16 -> CUInt -> Ptr a -> IO Bool++-- | Type of the callback used when stopping a capture.+type SoundRecorderStopCallback a = Ptr a -> IO ()++-- typedef sfBool (*sfSoundRecorderStartCallback)(void*);++-- typedef sfBool (*sfSoundRecorderProcessCallback)(const sfInt16*, size_t, void*);++-- typedef void   (*sfSoundRecorderStopCallback)(void*);++++-- | Construct a new sound recorder from callback functions.+createSoundRecorder+    :: Ptr (SoundRecorderStartCallback a)   -- ^ (onStart) Callback function which will be called when a new capture starts (can be NULL)+    -> Ptr (SoundRecorderProcessCallback a) -- ^ (onProcess) Callback function which will be called each time there's audio data to process+    -> Ptr (SoundRecorderStopCallback a)    -- ^ (onStop) Callback function which will be called when the current capture stops (can be NULL)+    -> Ptr a -- ^ Data to pass to the callback function (can be NULL)+    -> IO (Either SoundRecorderException SoundRecorder) -- ^ A new 'SoundRecorder' object ('Nothing' if failed)++createSoundRecorder c1 c2 c3 d =+    let err = SoundRecorderException $+            "Failed creating sound recorder: onStart = " ++ show c1 +++                                           " onProcess = " ++ show c2 +++                                           " onStop = " ++ show c3 +++                                           " userData = " ++ show d+    in sfSoundRecorder_create c1 c2 c3 d >>= return . tagErr err . checkNull++foreign import ccall unsafe "sfSoundRecorder_create"+    sfSoundRecorder_create+        :: Ptr (SoundRecorderStartCallback a)+        -> Ptr (SoundRecorderProcessCallback a)+        -> Ptr (SoundRecorderStopCallback a)+        -> Ptr a+        -> IO SoundRecorder++-- CSFML_AUDIO_API sfSoundRecorder* sfSoundRecorder_create(sfSoundRecorderStartCallback onStart, sfSoundRecorderProcessCallback onProcess, sfSoundRecorderStopCallback onStop, void* userData);+++instance SFResource SoundRecorder where+    +    {-# INLINABLE destroy #-}+    destroy = sfSoundRecorder_destroy++foreign import ccall unsafe "sfSoundRecorder_destroy"+    sfSoundRecorder_destroy :: SoundRecorder -> IO ()++-- CSFML_AUDIO_API void sfSoundRecorder_destroy(sfSoundRecorder* soundRecorder);+++instance SFSoundRecorder SoundRecorder where+    +    {-# INLINABLE startRecording #-}+    startRecording rec rate = sfSoundRecorder_start rec (fromIntegral rate)+    +    {-# INLINABLE stopRecording #-}+    stopRecording = sfSoundRecorder_stop+++foreign import ccall unsafe "sfSoundRecorder_start"+    sfSoundRecorder_start :: SoundRecorder -> CUInt -> IO ()++-- CSFML_AUDIO_API void sfSoundRecorder_start(sfSoundRecorder* soundRecorder, unsigned int sampleRate);++foreign import ccall unsafe "sfSoundRecorder_stop"+    sfSoundRecorder_stop :: SoundRecorder -> IO ()++-- CSFML_AUDIO_API void sfSoundRecorder_stop(sfSoundRecorder* soundRecorder);+++instance SFSampled SoundRecorder where+    +    {-# INLINABLE getSampleRate #-}+    getSampleRate = sfSoundRecorder_getSampleRate >=> return . fromIntegral+++foreign import ccall unsafe "sfSoundRecorder_getSampleRate"+    sfSoundRecorder_getSampleRate :: SoundRecorder -> IO CUInt++-- CSFML_AUDIO_API unsigned int sfSoundRecorder_getSampleRate(const sfSoundRecorder* soundRecorder);+++-- | Check if the system supports audio capture.+--+-- This function should always be called before using+-- the audio capture features. If it returns false, then+-- any attempt to use 'SoundRecorder' will fail.+isSoundRecorderAvailable :: IO Bool+isSoundRecorderAvailable = fmap (toEnum . fromIntegral) sfSoundRecorder_isAvailable++foreign import ccall unsafe "sfSoundRecorder_isAvailable"+    sfSoundRecorder_isAvailable :: IO CInt++-- CSFML_AUDIO_API sfBool sfSoundRecorder_isAvailable(void);+
+ src/SFML/Audio/SoundStatus.hs view
@@ -0,0 +1,11 @@+module SFML.Audio.SoundStatus+where+++-- | Enumeration of statuses for sounds and musics+data SoundStatus+    = Stopped -- ^ Sound or music is not playing+    | Paused  -- ^ Sound or music is paused+    | Playing -- ^ Sound or music is playing+    deriving (Eq, Enum, Bounded, Show)+
+ src/SFML/Audio/SoundStream.hsc view
@@ -0,0 +1,305 @@+module SFML.Audio.SoundStream+(+    SoundStreamChunk(..)+,   SoundStreamGetDataCallback+,   SoundStreamSeekCallback+,   createSoundStream+,   destroy+,   play+,   pause+,   stop+,   getAttenuation+,   getLoop+,   getMinDistance+,   getPitch+,   getPlayingOffset+,   getPosition+,   getStatus+,   getVolume+,   isRelativeToListener+,   setAttenuation+,   setLoop+,   setMinDistance+,   setPitch+,   setPlayingOffset+,   setPosition+,   setRelativeToListener+,   setVolume+)+where+++import SFML.Audio.SFSound+import SFML.Audio.SoundStatus+import SFML.Audio.Types+import SFML.SFResource+import SFML.System.Time+import SFML.System.Vector3++import Control.Monad ((>=>))+import Data.Word (Word16)+import Foreign.C.Types+import Foreign.Marshal.Alloc (alloca)+import Foreign.Marshal.Utils (with)+import Foreign.Ptr (Ptr)+import Foreign.Storable+++#include <SFML/Audio/SoundStream.h>+++-- | Defines the data to fill by the onGetData callback.+data SoundStreamChunk = SoundStreamChunk+    { samples :: Ptr Word16 -- ^ Pointer to the audio samples+    , sampleCount :: Int -- ^ Number of samples pointed by Samples+    }+++{-+typedef struct+{+    sfInt16*     samples;     --< Pointer to the audio samples+    unsigned int sampleCount; --< Number of samples pointed by Samples+} sfSoundStreamChunk;+-}+++size_SoundStreamChunk = #{size sfSoundStreamChunk}+++instance Storable SoundStreamChunk where+    sizeOf _ = size_SoundStreamChunk+    alignment _ = alignment (undefined :: CInt)+    +    peek ptr = do+        samples <- #{peek sfSoundStreamChunk, samples} ptr+        sampleCount <- #{peek sfSoundStreamChunk, sampleCount} ptr :: IO CUInt+        return $ SoundStreamChunk samples (fromIntegral sampleCount)+    +    poke ptr (SoundStreamChunk samples sampleCount) = do+        #{poke sfSoundStreamChunk, samples} ptr samples+        #{poke sfSoundStreamChunk, sampleCount} ptr (fromIntegral sampleCount :: CUInt)+++-- | Type of the callback used to get a sound stream data.+type SoundStreamGetDataCallback a = Ptr SoundStreamChunk -> Ptr a -> IO CInt+++-- | Type of the callback used to seek in a sound stream.+type SoundStreamSeekCallback a = Time -> Ptr a -> IO ()++{-+typedef sfBool (*sfSoundStreamGetDataCallback)(sfSoundStreamChunk*, void*); --< Type of the callback used to get a sound stream data++typedef void   (*sfSoundStreamSeekCallback)(sfTime, void*);                 --< Type of the callback used to seek in a sound stream+-}++++-- | Create a new sound stream.+createSoundStream+    :: Ptr (SoundStreamGetDataCallback a) -- ^ (onGetData) Function called when the stream needs more data (can't be NULL)+    -> Ptr (SoundStreamSeekCallback a) -- ^ (onSeek) Function called when the stream seeks (can't be NULL)+    -> Int -- ^ Number of channels to use (1 = mono, 2 = stereo)+    -> Int -- ^ Sample rate of the sound (44100 = CD quality)+    -> Ptr a -- ^ Data to pass to the callback functions+    -> IO SoundStream++createSoundStream = sfSoundStream_create++foreign import ccall unsafe "sfSoundStream_create"+    sfSoundStream_create+        :: Ptr (SoundStreamGetDataCallback a)+        -> Ptr (SoundStreamSeekCallback a)+        -> Int+        -> Int+        -> Ptr a+        -> IO SoundStream++-- CSFML_AUDIO_API sfSoundStream* sfSoundStream_create(sfSoundStreamGetDataCallback onGetData, sfSoundStreamSeekCallback    onSeek, unsigned int channelCount, unsigned int sampleRate, void* userData);+++instance SFResource SoundStream where+    +    {-# INLINABLE destroy #-}+    destroy = sfSoundStream_destroy++foreign import ccall unsafe "sfSoundStream_destroy"+    sfSoundStream_destroy :: SoundStream -> IO ()++-- CSFML_AUDIO_API void sfSoundStream_destroy(sfSoundStream* soundStream);+++instance SFSound SoundStream where+    +    {-# INLINABLE play #-}+    play = sfSoundStream_play+    +    {-# INLINABLE pause #-}+    pause = sfSoundStream_pause+    +    {-# INLINABLE stop #-}+    stop = sfSoundStream_stop+    +    {-# INLINABLE getAttenuation #-}+    getAttenuation = sfSoundStream_getAttenuation >=> return . realToFrac+    +    {-# INLINABLE getLoop #-}+    getLoop music = fmap (toEnum . fromIntegral) $ sfSoundStream_getLoop music+    +    {-# INLINABLE getMinDistance #-}+    getMinDistance = sfSoundStream_getMinDistance >=> return . realToFrac+    +    {-# INLINABLE getPitch #-}+    getPitch = sfSoundStream_getPitch >=> return . realToFrac+    +    {-# INLINABLE getPlayingOffset #-}+    getPlayingOffset music = alloca $ \ptr -> sfSoundStream_getPlayingOffset_helper music ptr >> peek ptr+    +    {-# INLINABLE getPosition #-}+    getPosition music = alloca $ \ptr -> sfSoundStream_getPosition_helper music ptr >> peek ptr+    +    {-# INLINABLE getStatus #-}+    getStatus = sfSoundStream_getStatus >=> return . toEnum . fromIntegral+    +    {-# INLINABLE getVolume #-}+    getVolume = sfSoundStream_getVolume >=> return . realToFrac+    +    {-# INLINABLE isRelativeToListener #-}+    isRelativeToListener = sfSoundStream_isRelativeToListener >=> return . toEnum . fromIntegral+    +    {-# INLINABLE setAttenuation #-}+    setAttenuation m a = sfSoundStream_setAttenuation m (realToFrac a)+    +    {-# INLINABLE setLoop #-}+    setLoop music val = sfSoundStream_setLoop music (fromIntegral . fromEnum $ val)+    +    {-# INLINABLE setMinDistance #-}+    setMinDistance m d = sfSoundStream_setMinDistance m (realToFrac d)+    +    {-# INLINABLE setPitch #-}+    setPitch m p = sfSoundStream_setPitch m (realToFrac p)+    +    {-# INLINABLE setPlayingOffset #-}+    setPlayingOffset = sfSoundStream_setPlayingOffset+    +    {-# INLINABLE setPosition #-}+    setPosition music pos = with pos $ sfSoundStream_setPosition_helper music+    +    {-# INLINABLE setRelativeToListener #-}+    setRelativeToListener music val = sfSoundStream_setRelativeToListener music (fromIntegral . fromEnum $ val)+    +    {-# INLINABLE setVolume #-}+    setVolume m v = sfSoundStream_setVolume m (realToFrac v)+++foreign import ccall unsafe "sfSoundStream_play"+    sfSoundStream_play :: SoundStream -> IO ()++-- CSFML_AUDIO_API void sfSoundStream_play(sfSoundStream* soundStream);++foreign import ccall unsafe "sfSoundStream_pause"+    sfSoundStream_pause :: SoundStream -> IO ()++-- CSFML_AUDIO_API void sfSoundStream_pause(sfSoundStream* soundStream);++foreign import ccall unsafe "sfSoundStream_stop"+    sfSoundStream_stop :: SoundStream -> IO ()++-- CSFML_AUDIO_API void sfSoundStream_stop(sfSoundStream* soundStream);++foreign import ccall unsafe "sfSoundStream_getStatus"+    sfSoundStream_getStatus :: SoundStream -> IO CInt++-- CSFML_AUDIO_API sfSoundStatus sfSoundStream_getStatus(const sfSoundStream* soundStream);++foreign import ccall unsafe "sfSoundStream_getChannelCount"+    sfSoundStream_getChannelCount :: SoundStream -> IO CUInt++-- CSFML_AUDIO_API unsigned int sfSoundStream_getChannelCount(const sfSoundStream* soundStream);++foreign import ccall unsafe "sfSoundStream_getSampleRate"+    sfSoundStream_getSampleRate :: SoundStream -> IO CUInt++-- CSFML_AUDIO_API unsigned int sfSoundStream_getSampleRate(const sfSoundStream* soundStream);++foreign import ccall unsafe "sfSoundStream_setPitch"+    sfSoundStream_setPitch :: SoundStream -> CFloat -> IO ()++-- CSFML_AUDIO_API void sfSoundStream_setPitch(sfSoundStream* soundStream, float pitch);++foreign import ccall unsafe "sfSoundStream_setVolume"+    sfSoundStream_setVolume :: SoundStream -> CFloat -> IO ()++-- CSFML_AUDIO_API void sfSoundStream_setVolume(sfSoundStream* soundStream, float volume);++foreign import ccall unsafe "sfSoundStream_setPosition_helper"+    sfSoundStream_setPosition_helper :: SoundStream -> Ptr Vec3f -> IO ()++-- CSFML_AUDIO_API void sfSoundStream_setPosition(sfSoundStream* soundStream, sfVector3f position);++foreign import ccall unsafe "sfSoundStream_setRelativeToListener"+    sfSoundStream_setRelativeToListener :: SoundStream -> CInt -> IO ()++-- CSFML_AUDIO_API void sfSoundStream_setRelativeToListener(sfSoundStream* soundStream, sfBool relative);++foreign import ccall unsafe "sfSoundStream_setMinDistance"+    sfSoundStream_setMinDistance :: SoundStream -> CFloat -> IO ()++-- CSFML_AUDIO_API void sfSoundStream_setMinDistance(sfSoundStream* soundStream, float distance);++foreign import ccall unsafe "sfSoundStream_setAttenuation"+    sfSoundStream_setAttenuation :: SoundStream -> CFloat -> IO ()++-- CSFML_AUDIO_API void sfSoundStream_setAttenuation(sfSoundStream* soundStream, float attenuation);++foreign import ccall unsafe "sfSoundStream_setPlayingOffset"+    sfSoundStream_setPlayingOffset :: SoundStream -> Time -> IO ()++-- CSFML_AUDIO_API void sfSoundStream_setPlayingOffset(sfSoundStream* soundStream, sfTime timeOffset);++foreign import ccall unsafe "sfSoundStream_setLoop"+    sfSoundStream_setLoop :: SoundStream -> CInt -> IO ()++-- CSFML_AUDIO_API void sfSoundStream_setLoop(sfSoundStream* soundStream, sfBool loop);++foreign import ccall unsafe "sfSoundStream_getPitch"+    sfSoundStream_getPitch :: SoundStream -> IO CFloat++-- CSFML_AUDIO_API float sfSoundStream_getPitch(const sfSoundStream* soundStream);++foreign import ccall unsafe "sfSoundStream_getVolume"+    sfSoundStream_getVolume :: SoundStream -> IO CFloat++-- CSFML_AUDIO_API float sfSoundStream_getVolume(const sfSoundStream* soundStream);++foreign import ccall unsafe "sfSoundStream_getPosition_helper"+    sfSoundStream_getPosition_helper :: SoundStream -> Ptr Vec3f -> IO ()++-- CSFML_AUDIO_API sfVector3f sfSoundStream_getPosition(const sfSoundStream* soundStream);++foreign import ccall unsafe "sfSoundStream_isRelativeToListener"+    sfSoundStream_isRelativeToListener :: SoundStream -> IO CInt++-- CSFML_AUDIO_API sfBool sfSoundStream_isRelativeToListener(const sfSoundStream* soundStream);++foreign import ccall unsafe "sfSoundStream_getMinDistance"+    sfSoundStream_getMinDistance :: SoundStream -> IO CFloat++-- CSFML_AUDIO_API float sfSoundStream_getMinDistance(const sfSoundStream* soundStream);++foreign import ccall unsafe "sfSoundStream_getAttenuation"+    sfSoundStream_getAttenuation :: SoundStream -> IO CFloat++-- CSFML_AUDIO_API float sfSoundStream_getAttenuation(const sfSoundStream* soundStream);++foreign import ccall unsafe "sfSoundStream_getLoop"+    sfSoundStream_getLoop :: SoundStream -> IO CInt++-- CSFML_AUDIO_API sfBool sfSoundStream_getLoop(const sfSoundStream* soundStream);++foreign import ccall unsafe "sfSoundStream_getPlayingOffset_helper"+    sfSoundStream_getPlayingOffset_helper :: SoundStream -> Ptr Time -> IO ()++-- CSFML_AUDIO_API sfTime sfSoundStream_getPlayingOffset(const sfSoundStream* soundStream);+
+ src/SFML/Audio/Types.hs view
@@ -0,0 +1,14 @@+module SFML.Audio.Types+where+++import Foreign.Ptr+++newtype Music = Music (Ptr Music)+newtype Sound = Sound (Ptr Sound)+newtype SoundBuffer = SoundBuffer (Ptr SoundBuffer)+newtype SoundBufferRecorder = SoundBufferRecorder (Ptr SoundBufferRecorder)+newtype SoundRecorder = SoundRecorder (Ptr SoundRecorder)+newtype SoundStream = SoundStream (Ptr SoundStream)+
+ src/SFML/Graphics.hs view
@@ -0,0 +1,72 @@+module SFML.Graphics+(+    module SFML.Graphics.BlendMode+,   module SFML.Graphics.CircleShape+,   module SFML.Graphics.Color+,   module SFML.Graphics.ConvexShape+,   module SFML.Graphics.Font+,   module SFML.Graphics.Glyph+,   module SFML.Graphics.Image+,   module SFML.Graphics.PrimitiveType+,   module SFML.Graphics.Rect+,   module SFML.Graphics.RectangleShape+,   module SFML.Graphics.RenderStates+,   module SFML.Graphics.RenderTexture+,   module SFML.Graphics.RenderWindow+,   module SFML.Graphics.SFBindable+,   module SFML.Graphics.SFBounded+,   module SFML.Graphics.SFCoordSpace+,   module SFML.Graphics.SFRenderTarget+,   module SFML.Graphics.SFShape+,   module SFML.Graphics.SFShapeResizable+,   module SFML.Graphics.SFSmoothTexture+,   module SFML.Graphics.SFTexturable+,   module SFML.Graphics.SFViewable+,   module SFML.Graphics.Shader+,   module SFML.Graphics.Shape+,   module SFML.Graphics.Sprite+,   module SFML.Graphics.Text+,   module SFML.Graphics.Texture+,   module SFML.Graphics.Transform+,   module SFML.Graphics.Transformable+,   module SFML.Graphics.Types+,   module SFML.Graphics.Vertex+,   module SFML.Graphics.VertexArray+,   module SFML.Graphics.View+)+where+++import SFML.Graphics.BlendMode+import SFML.Graphics.CircleShape+import SFML.Graphics.Color+import SFML.Graphics.ConvexShape+import SFML.Graphics.Font+import SFML.Graphics.Glyph+import SFML.Graphics.Image+import SFML.Graphics.PrimitiveType+import SFML.Graphics.Rect+import SFML.Graphics.RectangleShape+import SFML.Graphics.RenderStates+import SFML.Graphics.RenderTexture+import SFML.Graphics.RenderWindow+import SFML.Graphics.SFBindable+import SFML.Graphics.SFBounded+import SFML.Graphics.SFCoordSpace+import SFML.Graphics.SFRenderTarget+import SFML.Graphics.SFShape+import SFML.Graphics.SFShapeResizable+import SFML.Graphics.SFSmoothTexture+import SFML.Graphics.SFTexturable+import SFML.Graphics.SFViewable+import SFML.Graphics.Shader+import SFML.Graphics.Shape+import SFML.Graphics.Sprite+import SFML.Graphics.Text+import SFML.Graphics.Texture+import SFML.Graphics.Transform+import SFML.Graphics.Transformable+import SFML.Graphics.Types+import SFML.Graphics.Vertex+import SFML.Graphics.VertexArray+import SFML.Graphics.View
+ src/SFML/Graphics/BlendMode.hs view
@@ -0,0 +1,36 @@+module SFML.Graphics.BlendMode+(+    BlendMode(..)+)+where+++import Foreign.C.Types (CInt)+import Foreign.Ptr+import Foreign.Storable+++-- | Available blending modes for drawing.+data BlendMode+    = BlendAlpha     -- ^ Pixel = Src * a + Dest * (1 - a)+    | BlendAdd       -- ^ Pixel = Src + Dest+    | BlendMultiply  -- ^ Pixel = Src * Dest+    | BlendNone      -- ^ No blending+    deriving (Eq, Enum, Bounded, Show)+++instance Storable BlendMode where+    sizeOf _ = sizeOf (undefined :: CInt)+    alignment _ = alignment (undefined :: CInt)+    +    peek ptr = fmap (toEnum . fromIntegral) $ peek (castPtr ptr :: Ptr CInt)+    poke ptr bm = poke (castPtr ptr :: Ptr CInt) (fromIntegral . fromEnum $ bm)++{-typedef enum +{+    sfBlendAlpha,    ///< Pixel = Src * a + Dest * (1 - a)+    sfBlendAdd,      ///< Pixel = Src + Dest+    sfBlendMultiply, ///< Pixel = Src * Dest+    sfBlendNone      ///< No blending+} sfBlendMode;-}+
+ src/SFML/Graphics/CircleShape.hs view
@@ -0,0 +1,384 @@+{-# LANGUAGE DeriveDataTypeable #-}+module SFML.Graphics.CircleShape+(+    module SFML.Utils+,   CircleShapeException(..)+,   createCircleShape+,   copy+,   destroy+,   setPosition+,   setRotation+,   setScale+,   setOrigin+,   getPosition+,   getRotation+,   getScale+,   getOrigin+,   move+,   rotate+,   scale+,   getTransform+,   getInverseTransform+,   setTexture+,   setTextureRect+,   getTexture+,   getTextureRect+,   setFillColor+,   setOutlineColor+,   setOutlineThickness+,   getFillColor+,   getOutlineColor+,   getOutlineThickness+,   getPointCount+,   getPoint+,   setRadius+,   getRadius+,   setPointCount+,   getLocalBounds+,   getGlobalBounds+)+where+++import SFML.Graphics.SFBounded+import SFML.Graphics.Color+import SFML.Graphics.Rect+import SFML.Graphics.SFShape+import SFML.Graphics.SFShapeResizable+import SFML.Graphics.SFTexturable+import SFML.Graphics.Transform+import SFML.Graphics.Transformable+import SFML.Graphics.Types+import SFML.SFCopyable+import SFML.SFResource+import SFML.System.Vector2+import SFML.Utils++import Control.Exception+import Control.Monad ((>=>))+import Data.Typeable+import Foreign.C.Types+import Foreign.Ptr (Ptr, nullPtr)+import Foreign.Marshal.Alloc (alloca)+import Foreign.Marshal.Utils (with)+import Foreign.Storable (peek)+++checkNull :: CircleShape -> Maybe CircleShape+checkNull cs@(CircleShape ptr) = if ptr == nullPtr then Nothing else Just cs+++checkNullTexture :: Texture -> Maybe Texture+checkNullTexture tex@(Texture ptr) = if ptr == nullPtr then Nothing else Just tex+++data CircleShapeException = CircleShapeException String deriving (Show, Typeable)++instance Exception CircleShapeException+++-- | Create a new circle shape.+createCircleShape :: IO (Either CircleShapeException CircleShape)+createCircleShape =+    let err = CircleShapeException "Failed creating circle shape"+    in fmap (tagErr err . checkNull) sfCircleShape_create++foreign import ccall unsafe "sfCircleShape_create"+    sfCircleShape_create :: IO CircleShape++-- \return A new sfCircleShape object, or NULL if it failed++--CSFML_GRAPHICS_API sfCircleShape* sfCircleShape_create(void);+++instance SFCopyable CircleShape where++    {-# INLINABLE copy #-}+    copy = sfCircleShape_copy+++foreign import ccall unsafe "sfCircleShape_copy"+    sfCircleShape_copy :: CircleShape -> IO CircleShape++--CSFML_GRAPHICS_API sfCircleShape* sfCircleShape_copy(sfCircleShape* shape);+++instance SFResource CircleShape where++    {-# INLINABLE destroy #-}+    destroy = sfCircleShape_destroy++foreign import ccall unsafe "sfCircleShape_destroy"+    sfCircleShape_destroy :: CircleShape -> IO ()++--CSFML_GRAPHICS_API void sfCircleShape_destroy(sfCircleShape* shape);+++instance Transformable CircleShape where++    {-# INLINABLE setPosition #-}+    setPosition c p = with p $ sfCircleShape_setPosition_helper c++    {-# INLINABLE setRotation #-}+    setRotation c r = sfCircleShape_setRotation c (realToFrac r)++    {-# INLINABLE setScale #-}+    setScale c s = with s $ sfCircleShape_setScale_helper c++    {-# INLINABLE setOrigin #-}+    setOrigin c o = with o $ sfCircleShape_setOrigin_helper c++    {-# INLINABLE getPosition #-}+    getPosition c = alloca $ \ptr -> sfCircleShape_getPosition_helper c ptr >> peek ptr++    {-# INLINABLE getRotation #-}+    getRotation = sfCircleShape_getRotation >=> return . realToFrac++    {-# INLINABLE getScale #-}+    getScale c = alloca $ \ptr -> sfCircleShape_getScale_helper c ptr >> peek ptr++    {-# INLINABLE getOrigin #-}+    getOrigin c = alloca $ \ptr -> sfCircleShape_getOrigin_helper c ptr >> peek ptr++    {-# INLINABLE move #-}+    move c off = with off $ sfCircleShape_move_helper c++    {-# INLINABLE rotate #-}+    rotate c a = sfCircleShape_rotate c (realToFrac a)++    {-# INLINABLE scale #-}+    scale c s = with s $ sfCircleShape_scale_helper c++    {-# INLINABLE getTransform #-}+    getTransform c = alloca $ \ptr -> sfCircleShape_getTransform_helper c ptr >> peek ptr++    {-# INLINABLE getInverseTransform #-}+    getInverseTransform c = alloca $ \ptr -> sfCircleShape_getInverseTransform_helper c ptr >> peek ptr+++foreign import ccall unsafe "sfCircleShape_setPosition_helper"+    sfCircleShape_setPosition_helper :: CircleShape -> Ptr Vec2f -> IO ()++--CSFML_GRAPHICS_API void sfCircleShape_setPosition(sfCircleShape* shape, sfVector2f position);++foreign import ccall unsafe "sfCircleShape_setRotation"+    sfCircleShape_setRotation :: CircleShape -> CFloat -> IO ()++--CSFML_GRAPHICS_API void sfCircleShape_setRotation(sfCircleShape* shape, float angle);++foreign import ccall unsafe "sfCircleShape_setScale_helper"+    sfCircleShape_setScale_helper :: CircleShape -> Ptr Vec2f -> IO ()++--CSFML_GRAPHICS_API void sfCircleShape_setScale(sfCircleShape* shape, sfVector2f scale);++foreign import ccall unsafe "sfCircleShape_setOrigin_helper"+    sfCircleShape_setOrigin_helper :: CircleShape -> Ptr Vec2f -> IO ()++--CSFML_GRAPHICS_API void sfCircleShape_setOrigin(sfCircleShape* shape, sfVector2f origin);++foreign import ccall unsafe "sfCircleShape_getPosition_helper"+    sfCircleShape_getPosition_helper :: CircleShape -> Ptr Vec2f -> IO ()++--CSFML_GRAPHICS_API sfVector2f sfCircleShape_getPosition(const sfCircleShape* shape);++foreign import ccall unsafe "sfCircleShape_getRotation"+    sfCircleShape_getRotation :: CircleShape -> IO CFloat++--CSFML_GRAPHICS_API float sfCircleShape_getRotation(const sfCircleShape* shape);++foreign import ccall unsafe "sfCircleShape_getScale_helper"+    sfCircleShape_getScale_helper :: CircleShape -> Ptr Vec2f -> IO ()++--CSFML_GRAPHICS_API sfVector2f sfCircleShape_getScale(const sfCircleShape* shape);++foreign import ccall unsafe "sfCircleShape_getOrigin_helper"+    sfCircleShape_getOrigin_helper :: CircleShape -> Ptr Vec2f -> IO ()++--CSFML_GRAPHICS_API sfVector2f sfCircleShape_getOrigin(const sfCircleShape* shape);++foreign import ccall unsafe "sfCircleShape_move_helper"+    sfCircleShape_move_helper :: CircleShape -> Ptr Vec2f -> IO ()++--CSFML_GRAPHICS_API void sfCircleShape_move(sfCircleShape* shape, sfVector2f offset);++foreign import ccall unsafe "sfCircleShape_rotate"+    sfCircleShape_rotate :: CircleShape -> CFloat -> IO ()++--CSFML_GRAPHICS_API void sfCircleShape_rotate(sfCircleShape* shape, float angle);++foreign import ccall unsafe "sfCircleShape_scale_helper"+    sfCircleShape_scale_helper :: CircleShape -> Ptr Vec2f -> IO ()++--CSFML_GRAPHICS_API void sfCircleShape_scale(sfCircleShape* shape, sfVector2f factors);++foreign import ccall unsafe "sfCircleShape_getTransform_helper"+    sfCircleShape_getTransform_helper :: CircleShape -> Ptr Transform -> IO ()++--CSFML_GRAPHICS_API sfTransform sfCircleShape_getTransform(const sfCircleShape* shape);++foreign import ccall unsafe "sfCircleShape_getInverseTransform_helper"+    sfCircleShape_getInverseTransform_helper :: CircleShape -> Ptr Transform -> IO ()++--CSFML_GRAPHICS_API sfTransform sfCircleShape_getInverseTransform(const sfCircleShape* shape);+++instance SFTexturable CircleShape where++    {-# INLINABLE setTexture #-}+    setTexture c tex reset = sfCircleShape_setTexture c tex (fromIntegral . fromEnum $ reset)++    {-# INLINABLE setTextureRect #-}+    setTextureRect c rect = with rect $ sfCircleShape_setTextureRect_helper c++    {-# INLINABLE getTexture #-}+    getTexture = sfCircleShape_getTexture >=> return . checkNullTexture++    {-# INLINABLE getTextureRect #-}+    getTextureRect c = alloca $ \ptr -> sfCircleShape_getTextureRect_helper c ptr >> peek ptr+++foreign import ccall unsafe "sfCircleShape_setTexture"+    sfCircleShape_setTexture :: CircleShape -> Texture -> CInt -> IO ()++--CSFML_GRAPHICS_API void sfCircleShape_setTexture(sfCircleShape* shape, const sfTexture* texture, sfBool resetRect);++foreign import ccall unsafe "sfCircleShape_setTextureRect_helper"+    sfCircleShape_setTextureRect_helper :: CircleShape -> Ptr IntRect -> IO ()++--CSFML_GRAPHICS_API void sfCircleShape_setTextureRect(sfCircleShape* shape, sfIntRect rect);++foreign import ccall unsafe "sfCircleShape_getTexture"+    sfCircleShape_getTexture :: CircleShape -> IO Texture++--CSFML_GRAPHICS_API const sfTexture* sfCircleShape_getTexture(const sfCircleShape* shape);++foreign import ccall unsafe "sfCircleShape_getTextureRect_helper"+    sfCircleShape_getTextureRect_helper :: CircleShape -> Ptr IntRect -> IO ()++--CSFML_GRAPHICS_API sfIntRect sfCircleShape_getTextureRect(const sfCircleShape* shape);+++instance SFShape CircleShape where++    {-# INLINABLE setFillColor #-}+    setFillColor c color = with color $ sfCircleShape_setFillColor_helper c++    {-# INLINABLE setOutlineColor #-}+    setOutlineColor c color = with color $ sfCircleShape_setOutlineColor_helper c++    {-# INLINABLE setOutlineThickness #-}+    setOutlineThickness c t = sfCircleShape_setOutlineThickness c (realToFrac t)++    {-# INLINABLE getFillColor #-}+    getFillColor c = alloca $ \ptr -> sfCircleShape_getFillColor_helper c ptr >> peek ptr++    {-# INLINABLE getOutlineColor #-}+    getOutlineColor c = alloca $ \ptr -> sfCircleShape_getOutlineColor_helper c ptr >> peek ptr++    {-# INLINABLE getOutlineThickness #-}+    getOutlineThickness = sfCircleShape_getOutlineThickness >=> return . realToFrac++    {-# INLINABLE getPointCount #-}+    getPointCount = sfCircleShape_getPointCount >=> return . fromIntegral++    {-# INLINABLE getPoint #-}+    getPoint c idx = alloca $ \ptr -> sfCircleShape_getPoint_helper c (fromIntegral idx) ptr >> peek ptr+++foreign import ccall unsafe "sfCircleShape_setFillColor_helper"+    sfCircleShape_setFillColor_helper :: CircleShape -> Ptr Color -> IO ()++--CSFML_GRAPHICS_API void sfCircleShape_setFillColor(sfCircleShape* shape, sfColor color);++foreign import ccall unsafe "sfCircleShape_setOutlineColor_helper"+    sfCircleShape_setOutlineColor_helper :: CircleShape -> Ptr Color -> IO ()++--CSFML_GRAPHICS_API void sfCircleShape_setOutlineColor(sfCircleShape* shape, sfColor color);++foreign import ccall unsafe "sfCircleShape_setOutlineThickness"+    sfCircleShape_setOutlineThickness :: CircleShape -> CFloat -> IO ()++--CSFML_GRAPHICS_API void sfCircleShape_setOutlineThickness(sfCircleShape* shape, float thickness);++foreign import ccall unsafe "sfCircleShape_getFillColor_helper"+    sfCircleShape_getFillColor_helper :: CircleShape -> Ptr Color -> IO ()++--CSFML_GRAPHICS_API sfColor sfCircleShape_getFillColor(const sfCircleShape* shape);++foreign import ccall unsafe "sfCircleShape_getOutlineColor_helper"+    sfCircleShape_getOutlineColor_helper :: CircleShape -> Ptr Color -> IO ()++--CSFML_GRAPHICS_API sfColor sfCircleShape_getOutlineColor(const sfCircleShape* shape);++foreign import ccall unsafe "sfCircleShape_getOutlineThickness"+    sfCircleShape_getOutlineThickness :: CircleShape -> IO CFloat++--CSFML_GRAPHICS_API float sfCircleShape_getOutlineThickness(const sfCircleShape* shape);++foreign import ccall unsafe "sfCircleShape_getPointCount"+    sfCircleShape_getPointCount :: CircleShape -> IO CUInt++--CSFML_GRAPHICS_API unsigned int sfCircleShape_getPointCount(const sfCircleShape* shape);++foreign import ccall unsafe "sfCircleShape_getPoint_helper"+    sfCircleShape_getPoint_helper :: CircleShape -> CUInt -> Ptr Vec2f -> IO ()++--CSFML_GRAPHICS_API sfVector2f sfCircleShape_getPoint(const sfCircleShape* shape, unsigned int index);+++-- | Set the radius of a circle.+setRadius+    :: CircleShape+    -> Float -- ^ New radius of the circle+    -> IO ()++setRadius c r = sfCircleShape_setRadius c (realToFrac r)++foreign import ccall unsafe "sfCircleShape_setRadius"+    sfCircleShape_setRadius :: CircleShape -> CFloat -> IO ()++--CSFML_GRAPHICS_API void sfCircleShape_setRadius(sfCircleShape* shape, float radius);+++-- | Get the radius of a circle.+getRadius+    :: CircleShape+    -> IO Float -- ^ Radius of the circle++getRadius = sfCircleShape_getRadius >=> return . realToFrac++foreign import ccall unsafe "sfCircleShape_getRadius"+    sfCircleShape_getRadius :: CircleShape -> IO CFloat++--CSFML_GRAPHICS_API float sfCircleShape_getRadius(const sfCircleShape* shape);+++instance SFShapeResizable CircleShape where++    {-# INLINABLE setPointCount #-}+    setPointCount c count = sfCircleShape_setPointCount c (fromIntegral count)+++foreign import ccall unsafe "sfCircleShape_setPointCount"+    sfCircleShape_setPointCount :: CircleShape -> CUInt -> IO ()++--CSFML_GRAPHICS_API void sfCircleShape_setPointCount(sfCircleShape* shape, unsigned int count);+++instance SFBounded CircleShape where++    {-# INLINABLE getLocalBounds #-}+    getLocalBounds c = alloca $ \ptr -> sfCircleShape_getLocalBounds_helper c ptr >> peek ptr++    {-# INLINABLE getGlobalBounds #-}+    getGlobalBounds c = alloca $ \ptr -> sfCircleShape_getGlobalBounds_helper c ptr >> peek ptr++foreign import ccall unsafe "sfCircleShape_getLocalBounds_helper"+    sfCircleShape_getLocalBounds_helper :: CircleShape -> Ptr FloatRect -> IO ()++--CSFML_GRAPHICS_API sfFloatRect sfCircleShape_getLocalBounds(const sfCircleShape* shape);++foreign import ccall unsafe "sfCircleShape_getGlobalBounds_helper"+    sfCircleShape_getGlobalBounds_helper :: CircleShape -> Ptr FloatRect -> IO ()++--CSFML_GRAPHICS_API sfFloatRect sfCircleShape_getGlobalBounds(const sfCircleShape* shape);
+ src/SFML/Graphics/Color.hsc view
@@ -0,0 +1,72 @@+module SFML.Graphics.Color+(+    Color(..)+,   black+,   white+,   red+,   green+,   blue+,   yellow+,   magenta+,   cyan+,   transparent+)+where+++import Data.Word (Word8)+import Foreign.Storable++#include <SFML/Graphics/Color.h>+++-- | Utility data type for manpulating RGBA colors.+data Color = Color+    { r :: Word8+    , g :: Word8+    , b :: Word8+    , a :: Word8+    }+    deriving (Eq, Show)+++instance Storable Color where+    sizeOf _ = 4 * sizeOf (undefined :: Word8)+    alignment _ = alignment (undefined :: Word8)+    +    peek ptr = do+        r <- #{peek sfColor, r} ptr+        g <- #{peek sfColor, g} ptr+        b <- #{peek sfColor, b} ptr+        a <- #{peek sfColor, a} ptr+        return $ Color r g b a+    +    poke ptr (Color r g b a) = do+        #{poke sfColor, r} ptr r+        #{poke sfColor, g} ptr g+        #{poke sfColor, b} ptr b+        #{poke sfColor, a} ptr a+++black       = Color   0   0   0 255+white       = Color 255 255 255 255+red         = Color 255   0   0 255+green       = Color   0 255   0 255+blue        = Color   0   0 255 255+yellow      = Color 255 255   0 255+magenta     = Color 255   0 255 255+cyan        = Color   0 255 255 255+transparent = Color   0   0   0 0+++instance Num Color where+    +    (Color r1 g1 b1 a1) + (Color r2 g2 b2 a2) = Color (r1+r2) (g1+g2) (b1+b2) (a1+a2)+    (Color r1 g1 b1 a1) - (Color r2 g2 b2 a2) = Color (r1-r2) (g1-g2) (b1-b2) (a1-a2)+    (Color r1 g1 b1 a1) * (Color r2 g2 b2 a2) = Color (r1*r2) (g1*g2) (b1*b2) (a1*a2)+    negate (Color r g b a) = Color (-r) (-g) (-b) (-a)+    abs (Color r g b a) = Color (abs r) (abs g) (abs b) (abs a)+    signum (Color r g b a) = Color (signum r) (signum g) (signum b) (signum a)+    fromInteger i = let i' = fromIntegral i in Color i' i' i' i'++
+ src/SFML/Graphics/ConvexShape.hs view
@@ -0,0 +1,378 @@+{-# LANGUAGE DeriveDataTypeable #-}+module SFML.Graphics.ConvexShape+(+    module SFML.Utils+,   ConvexShapeException(..)+,   createConvexShape+,   copy+,   destroy+,   setPosition+,   setRotation+,   setScale+,   setOrigin+,   getPosition+,   getRotation+,   getScale+,   getOrigin+,   move+,   rotate+,   scale+,   getTransform+,   getInverseTransform+,   setTexture+,   setTextureRect+,   getTexture+,   getTextureRect+,   setFillColor+,   setOutlineColor+,   setOutlineThickness+,   getFillColor+,   getOutlineColor+,   getOutlineThickness+,   getPointCount+,   getPoint+,   setPointCount+,   setPoint+,   getLocalBounds+,   getGlobalBounds+)+where+++import SFML.Graphics.SFBounded+import SFML.Graphics.Color+import SFML.Graphics.Rect+import SFML.Graphics.SFShape+import SFML.Graphics.SFShapeResizable+import SFML.Graphics.SFTexturable+import SFML.Graphics.Transform+import SFML.Graphics.Transformable+import SFML.Graphics.Types+import SFML.SFCopyable+import SFML.SFResource+import SFML.System.Vector2+import SFML.Utils++import Control.Exception+import Control.Monad ((>=>))+import Data.Typeable+import Foreign.C.Types+import Foreign.Ptr (Ptr, nullPtr)+import Foreign.Marshal.Alloc (alloca)+import Foreign.Marshal.Utils (with)+import Foreign.Storable (peek)+++checkNull :: ConvexShape -> Maybe ConvexShape+checkNull cs@(ConvexShape ptr) = if ptr == nullPtr then Nothing else Just cs+++checkNullTexture :: Texture -> Maybe Texture+checkNullTexture tex@(Texture ptr) = if ptr == nullPtr then Nothing else Just tex+++data ConvexShapeException = ConvexShapeException String deriving (Show, Typeable)++instance Exception ConvexShapeException+++-- | Create a new convex shape.+createConvexShape :: IO (Either ConvexShapeException ConvexShape)+createConvexShape =+    let err = ConvexShapeException "Failed creating convex shape"+    in fmap (tagErr err . checkNull) sfConvexShape_create++foreign import ccall unsafe "sfConvexShape_create"+    sfConvexShape_create :: IO ConvexShape++-- \return A new sfConvexShape object, or NULL if it failed++--CSFML_GRAPHICS_API sfConvexShape* sfConvexShape_create(void);+++instance SFCopyable ConvexShape where++    {-# INLINABLE copy #-}+    copy = sfConvexShape_copy+++foreign import ccall unsafe "sfConvexShape_copy"+    sfConvexShape_copy :: ConvexShape -> IO ConvexShape++--CSFML_GRAPHICS_API sfConvexShape* sfConvexShape_copy(sfConvexShape* shape);+++instance SFResource ConvexShape where++    {-# INLINABLE destroy #-}+    destroy = sfConvexShape_destroy++foreign import ccall unsafe "sfConvexShape_destroy"+    sfConvexShape_destroy :: ConvexShape -> IO ()++--CSFML_GRAPHICS_API void sfConvexShape_destroy(sfConvexShape* shape);+++instance Transformable ConvexShape where++    {-# INLINABLE setPosition #-}+    setPosition c p = with p $ sfConvexShape_setPosition_helper c++    {-# INLINABLE setRotation #-}+    setRotation c r = sfConvexShape_setRotation c (realToFrac r)++    {-# INLINABLE setScale #-}+    setScale c s = with s $ sfConvexShape_setScale_helper c++    {-# INLINABLE setOrigin #-}+    setOrigin c o = with o $ sfConvexShape_setOrigin_helper c++    {-# INLINABLE getPosition #-}+    getPosition c = alloca $ \ptr -> sfConvexShape_getPosition_helper c ptr >> peek ptr++    {-# INLINABLE getRotation #-}+    getRotation = sfConvexShape_getRotation >=> return . realToFrac++    {-# INLINABLE getScale #-}+    getScale c = alloca $ \ptr -> sfConvexShape_getScale_helper c ptr >> peek ptr++    {-# INLINABLE getOrigin #-}+    getOrigin c = alloca $ \ptr -> sfConvexShape_getOrigin_helper c ptr >> peek ptr++    {-# INLINABLE move #-}+    move c off = with off $ sfConvexShape_move_helper c++    {-# INLINABLE rotate #-}+    rotate c a = sfConvexShape_rotate c (realToFrac a)++    {-# INLINABLE scale #-}+    scale c s = with s $ sfConvexShape_scale_helper c++    {-# INLINABLE getTransform #-}+    getTransform c = alloca $ \ptr -> sfConvexShape_getTransform_helper c ptr >> peek ptr++    {-# INLINABLE getInverseTransform #-}+    getInverseTransform c = alloca $ \ptr -> sfConvexShape_getInverseTransform_helper c ptr >> peek ptr+++foreign import ccall unsafe "sfConvexShape_setPosition_helper"+    sfConvexShape_setPosition_helper :: ConvexShape -> Ptr Vec2f -> IO ()++--CSFML_GRAPHICS_API void sfConvexShape_setPosition(sfConvexShape* shape, sfVector2f position);++foreign import ccall unsafe "sfConvexShape_setRotation"+    sfConvexShape_setRotation :: ConvexShape -> CFloat -> IO ()++--CSFML_GRAPHICS_API void sfConvexShape_setRotation(sfConvexShape* shape, float angle);++foreign import ccall unsafe "sfConvexShape_setScale_helper"+    sfConvexShape_setScale_helper :: ConvexShape -> Ptr Vec2f -> IO ()++--CSFML_GRAPHICS_API void sfConvexShape_setScale(sfConvexShape* shape, sfVector2f scale);++foreign import ccall unsafe "sfConvexShape_setOrigin_helper"+    sfConvexShape_setOrigin_helper :: ConvexShape -> Ptr Vec2f -> IO ()++--CSFML_GRAPHICS_API void sfConvexShape_setOrigin(sfConvexShape* shape, sfVector2f origin);++foreign import ccall unsafe "sfConvexShape_getPosition_helper"+    sfConvexShape_getPosition_helper :: ConvexShape -> Ptr Vec2f -> IO ()++--CSFML_GRAPHICS_API sfVector2f sfConvexShape_getPosition(const sfConvexShape* shape);++foreign import ccall unsafe "sfConvexShape_getRotation"+    sfConvexShape_getRotation :: ConvexShape -> IO CFloat++--CSFML_GRAPHICS_API float sfConvexShape_getRotation(const sfConvexShape* shape);++foreign import ccall unsafe "sfConvexShape_getScale_helper"+    sfConvexShape_getScale_helper :: ConvexShape -> Ptr Vec2f -> IO ()++--CSFML_GRAPHICS_API sfVector2f sfConvexShape_getScale(const sfConvexShape* shape);++foreign import ccall unsafe "sfConvexShape_getOrigin_helper"+    sfConvexShape_getOrigin_helper :: ConvexShape -> Ptr Vec2f -> IO ()++--CSFML_GRAPHICS_API sfVector2f sfConvexShape_getOrigin(const sfConvexShape* shape);++foreign import ccall unsafe "sfConvexShape_move_helper"+    sfConvexShape_move_helper :: ConvexShape -> Ptr Vec2f -> IO ()++--CSFML_GRAPHICS_API void sfConvexShape_move(sfConvexShape* shape, sfVector2f offset);++foreign import ccall unsafe "sfConvexShape_rotate"+    sfConvexShape_rotate :: ConvexShape -> CFloat -> IO ()++--CSFML_GRAPHICS_API void sfConvexShape_rotate(sfConvexShape* shape, float angle);++foreign import ccall unsafe "sfConvexShape_scale_helper"+    sfConvexShape_scale_helper :: ConvexShape -> Ptr Vec2f -> IO ()++--CSFML_GRAPHICS_API void sfConvexShape_scale(sfConvexShape* shape, sfVector2f factors);++foreign import ccall unsafe "sfConvexShape_getTransform_helper"+    sfConvexShape_getTransform_helper :: ConvexShape -> Ptr Transform -> IO ()++--CSFML_GRAPHICS_API sfTransform sfConvexShape_getTransform(const sfConvexShape* shape);++foreign import ccall unsafe "sfConvexShape_getInverseTransform_helper"+    sfConvexShape_getInverseTransform_helper :: ConvexShape -> Ptr Transform -> IO ()++--CSFML_GRAPHICS_API sfTransform sfConvexShape_getInverseTransform(const sfConvexShape* shape);+++instance SFTexturable ConvexShape where++    {-# INLINABLE setTexture #-}+    setTexture c tex reset = sfConvexShape_setTexture c tex (fromIntegral . fromEnum $ reset)++    {-# INLINABLE setTextureRect #-}+    setTextureRect c rect = with rect $ sfConvexShape_setTextureRect_helper c++    {-# INLINABLE getTexture #-}+    getTexture = sfConvexShape_getTexture >=> return . checkNullTexture++    {-# INLINABLE getTextureRect #-}+    getTextureRect c = alloca $ \ptr -> sfConvexShape_getTextureRect_helper c ptr >> peek ptr+++foreign import ccall unsafe "sfConvexShape_setTexture"+    sfConvexShape_setTexture :: ConvexShape -> Texture -> CInt -> IO ()++--CSFML_GRAPHICS_API void sfConvexShape_setTexture(sfConvexShape* shape, const sfTexture* texture, sfBool resetRect);++foreign import ccall unsafe "sfConvexShape_setTextureRect_helper"+    sfConvexShape_setTextureRect_helper :: ConvexShape -> Ptr IntRect -> IO ()++--CSFML_GRAPHICS_API void sfConvexShape_setTextureRect(sfConvexShape* shape, sfIntRect rect);++foreign import ccall unsafe "sfConvexShape_getTexture"+    sfConvexShape_getTexture :: ConvexShape -> IO Texture++--CSFML_GRAPHICS_API const sfTexture* sfConvexShape_getTexture(const sfConvexShape* shape);++foreign import ccall unsafe "sfConvexShape_getTextureRect_helper"+    sfConvexShape_getTextureRect_helper :: ConvexShape -> Ptr IntRect -> IO ()++--CSFML_GRAPHICS_API sfIntRect sfConvexShape_getTextureRect(const sfConvexShape* shape);+++instance SFShape ConvexShape where++    {-# INLINABLE setFillColor #-}+    setFillColor c color = with color $ sfConvexShape_setFillColor_helper c++    {-# INLINABLE setOutlineColor #-}+    setOutlineColor c color = with color $ sfConvexShape_setOutlineColor_helper c++    {-# INLINABLE setOutlineThickness #-}+    setOutlineThickness c t = sfConvexShape_setOutlineThickness c (realToFrac t)++    {-# INLINABLE getFillColor #-}+    getFillColor c = alloca $ \ptr -> sfConvexShape_getFillColor_helper c ptr >> peek ptr++    {-# INLINABLE getOutlineColor #-}+    getOutlineColor c = alloca $ \ptr -> sfConvexShape_getOutlineColor_helper c ptr >> peek ptr++    {-# INLINABLE getOutlineThickness #-}+    getOutlineThickness = sfConvexShape_getOutlineThickness >=> return . realToFrac++    {-# INLINABLE getPointCount #-}+    getPointCount = sfConvexShape_getPointCount >=> return . fromIntegral++    {-# INLINABLE getPoint #-}+    getPoint c idx = alloca $ \ptr -> sfConvexShape_getPoint_helper c (fromIntegral idx) ptr >> peek ptr+++foreign import ccall unsafe "sfConvexShape_setFillColor_helper"+    sfConvexShape_setFillColor_helper :: ConvexShape -> Ptr Color -> IO ()++--CSFML_GRAPHICS_API void sfConvexShape_setFillColor(sfConvexShape* shape, sfColor color);++foreign import ccall unsafe "sfConvexShape_setOutlineColor_helper"+    sfConvexShape_setOutlineColor_helper :: ConvexShape -> Ptr Color -> IO ()++--CSFML_GRAPHICS_API void sfConvexShape_setOutlineColor(sfConvexShape* shape, sfColor color);++foreign import ccall unsafe "sfConvexShape_setOutlineThickness"+    sfConvexShape_setOutlineThickness :: ConvexShape -> CFloat -> IO ()++--CSFML_GRAPHICS_API void sfConvexShape_setOutlineThickness(sfConvexShape* shape, float thickness);++foreign import ccall unsafe "sfConvexShape_getFillColor_helper"+    sfConvexShape_getFillColor_helper :: ConvexShape -> Ptr Color -> IO ()++--CSFML_GRAPHICS_API sfColor sfConvexShape_getFillColor(const sfConvexShape* shape);++foreign import ccall unsafe "sfConvexShape_getOutlineColor_helper"+    sfConvexShape_getOutlineColor_helper :: ConvexShape -> Ptr Color -> IO ()++--CSFML_GRAPHICS_API sfColor sfConvexShape_getOutlineColor(const sfConvexShape* shape);++foreign import ccall unsafe "sfConvexShape_getOutlineThickness"+    sfConvexShape_getOutlineThickness :: ConvexShape -> IO CFloat++--CSFML_GRAPHICS_API float sfConvexShape_getOutlineThickness(const sfConvexShape* shape);++foreign import ccall unsafe "sfConvexShape_getPointCount"+    sfConvexShape_getPointCount :: ConvexShape -> IO CUInt++--CSFML_GRAPHICS_API unsigned int sfConvexShape_getPointCount(const sfConvexShape* shape);++foreign import ccall unsafe "sfConvexShape_getPoint_helper"+    sfConvexShape_getPoint_helper :: ConvexShape -> CUInt -> Ptr Vec2f -> IO ()++--CSFML_GRAPHICS_API sfVector2f sfConvexShape_getPoint(const sfConvexShape* shape, unsigned int index);+++instance SFShapeResizable ConvexShape where++    {-# INLINABLE setPointCount #-}+    setPointCount c count = sfConvexShape_setPointCount c (fromIntegral count)+++foreign import ccall unsafe "sfConvexShape_setPointCount"+    sfConvexShape_setPointCount :: ConvexShape -> CUInt -> IO ()++--CSFML_GRAPHICS_API void sfConvexShape_setPointCount(sfConvexShape* shape, unsigned int count);+++-- | Set the position of a point in a convex shape.+--+-- Don't forget that the polygon must remain convex, and+-- the points need to stay ordered!+--+-- 'setPointCount' must be called first in order to set the total+-- number of points. The result is undefined if the index is out+-- of the valid range.+setPoint+    :: ConvexShape+    -> Int   -- ^ Index of the point to change, in range [0 .. 'getPointCount' - 1]+    -> Vec2f -- ^ New point+    -> IO ()++setPoint s idx p = with p $ sfConvexShape_setPoint_helper s (fromIntegral idx)++foreign import ccall unsafe "sfConvexShape_setPoint_helper"+    sfConvexShape_setPoint_helper :: ConvexShape -> CUInt -> Ptr Vec2f -> IO ()++--CSFML_GRAPHICS_API void sfConvexShape_setPoint(sfConvexShape* shape, unsigned int index, sfVector2f point);+++instance SFBounded ConvexShape where++    {-# INLINABLE getLocalBounds #-}+    getLocalBounds c = alloca $ \ptr -> sfConvexShape_getLocalBounds_helper c ptr >> peek ptr++    {-# INLINABLE getGlobalBounds #-}+    getGlobalBounds c = alloca $ \ptr -> sfConvexShape_getGlobalBounds_helper c ptr >> peek ptr++foreign import ccall unsafe "sfConvexShape_getLocalBounds_helper"+    sfConvexShape_getLocalBounds_helper :: ConvexShape -> Ptr FloatRect -> IO ()++--CSFML_GRAPHICS_API sfFloatRect sfConvexShape_getLocalBounds(const sfConvexShape* shape);++foreign import ccall unsafe "sfConvexShape_getGlobalBounds_helper"+    sfConvexShape_getGlobalBounds_helper :: ConvexShape -> Ptr FloatRect -> IO ()++--CSFML_GRAPHICS_API sfFloatRect sfConvexShape_getGlobalBounds(const sfConvexShape* shape);
+ src/SFML/Graphics/Font.hs view
@@ -0,0 +1,178 @@+{-# LANGUAGE DeriveDataTypeable #-}+module SFML.Graphics.Font+(+    module SFML.Utils+,   FontException(..)+,   fontFromFile+,   fontFromMemory+,   fontFromStream+,   copy+,   destroy+,   getGlyph+,   getKerning+,   getLineSpacing+,   getFontTexture+)+where+++import SFML.Graphics.Glyph+import SFML.Graphics.Types+import SFML.SFCopyable+import SFML.SFResource+import SFML.System.InputStream+import SFML.Utils++import Control.Exception+import Data.Typeable+import Data.Word+import Foreign.C.String+import Foreign.C.Types+import Foreign.Marshal.Alloc (alloca)+import Foreign.Marshal.Utils (with)+import Foreign.Ptr+import Foreign.Storable+++checkNull :: Font -> Maybe Font+checkNull font@(Font ptr) = if ptr == nullPtr then Nothing else Just font+++data FontException = FontException String deriving (Show, Typeable)++instance Exception FontException+++-- | Create a new font from a file.+fontFromFile :: FilePath -> IO (Either FontException Font)+fontFromFile path =+    let err = FontException $ "Failed loading font from file " ++ show path+    in fmap (tagErr err . checkNull) $ withCAString path sfFont_createFromFile++foreign import ccall unsafe "sfFont_createFromFile"+    sfFont_createFromFile :: CString -> IO Font++-- \return A new sfFont object, or NULL if it failed++--CSFML_GRAPHICS_API sfFont* sfFont_createFromFile(const char* filename);+++-- | Create a new image font a file in memory.+fontFromMemory+    :: Ptr Char -- ^ Pointer to the file data in memory+    -> Int -- ^ Size of the data to load, in bytes+    -> IO (Either FontException Font)++fontFromMemory pixels size =+    let err = FontException $ "Failed loading font from memory address " ++ show pixels+    in fmap (tagErr err . checkNull) $ sfFont_createFromMemory pixels (fromIntegral size)++foreign import ccall unsafe "sfFont_createFromMemory"+    sfFont_createFromMemory :: Ptr a -> CInt -> IO Font++-- \return A new sfFont object, or NULL if it failed++--CSFML_GRAPHICS_API sfFont* sfFont_createFromMemory(const void* data, size_t sizeInBytes);+++-- | Create a new image font a custom stream.+fontFromStream :: InputStream -> IO (Either FontException Font)+fontFromStream stream =+    let err = FontException $ "Failed loading font from stream " ++ show stream+    in fmap (tagErr err . checkNull) $ with stream sfFont_createFromStream++foreign import ccall "sfFont_createFromStream"+    sfFont_createFromStream :: Ptr InputStream -> IO Font++-- \return A new sfFont object, or NULL if it failed++--CSFML_GRAPHICS_API sfFont* sfFont_createFromStream(sfInputStream* stream);+++instance SFCopyable Font where+    +    {-# INLINABLE copy #-}+    copy = sfFont_copy+++foreign import ccall unsafe "sfFont_copy"+    sfFont_copy :: Font -> IO Font++--CSFML_GRAPHICS_API sfFont* sfFont_copy(sfFont* font);+++instance SFResource Font where+    +    {-# INLINABLE destroy #-}+    destroy = sfFont_destroy++foreign import ccall unsafe "sfFont_destroy"+    sfFont_destroy :: Font -> IO ()++--CSFML_GRAPHICS_API void sfFont_destroy(sfFont* font);+++-- | Get a glyph in a font.+getGlyph+    :: Font -- ^ Source font+    -> Int -- ^ Unicode code point of the character to get+    -> Int -- ^ Character size, in pixels+    -> Bool -- ^ Retrieve the bold version or the regular one?+    -> IO Glyph++getGlyph font codePoint size bold =+    alloca $ \glyphPtr -> do+        sfFont_getGlyph_helper+            font (fromIntegral codePoint) (fromIntegral size) (fromIntegral . fromEnum $ bold) glyphPtr+        peek glyphPtr++foreign import ccall unsafe "sfFont_getGlyph_helper"+    sfFont_getGlyph_helper :: Font -> Word32 -> CUInt -> CInt -> Ptr Glyph -> IO ()++--CSFML_GRAPHICS_API sfGlyph sfFont_getGlyph(sfFont* font, sfUint32 codePoint, unsigned int characterSize, sfBool bold);+++-- | Get the kerning value corresponding to a given pair of characters in a font.+getKerning+    :: Font -- ^ Source font+    -> Int  -- ^ Unicode code point of the first character+    -> Int  -- ^ Unicode code point of the second characte.r+    -> Int  -- ^ Character size, in pixels+    -> IO Int++getKerning font first second size =+    fmap fromIntegral $ sfFont_getKerning font (fromIntegral first) (fromIntegral second) (fromIntegral size)++foreign import ccall unsafe "sfFont_getKerning"+    sfFont_getKerning :: Font -> Word32 -> Word32 -> CUInt -> IO CInt++--CSFML_GRAPHICS_API int sfFont_getKerning(sfFont* font, sfUint32 first, sfUint32 second, unsigned int characterSize);+++-- | Get the line spacing value.+getLineSpacing+    :: Font -- ^ Source font+    -> Int    -- ^ Character size, in pixels+    -> IO Int++getLineSpacing font size = fmap fromIntegral $ sfFont_getLineSpacing font (fromIntegral size)++foreign import ccall unsafe "sfFont_getLineSpacing"+    sfFont_getLineSpacing :: Font -> CUInt -> IO CInt++--CSFML_GRAPHICS_API int sfFont_getLineSpacing(sfFont* font, unsigned int characterSize);+++-- | Get the texture containing the glyphs of a given size in a font.+getFontTexture+    :: Font -- ^ Source font+    -> Int    -- ^ Character size, in pixels+    -> IO Texture++getFontTexture font size = sfFont_getTexture font (fromIntegral size)++foreign import ccall unsafe "sfFont_getTexture"+    sfFont_getTexture :: Font -> CUInt -> IO Texture++--CSFML_GRAPHICS_API const sfTexture* sfFont_getTexture(sfFont* font, unsigned int characterSize);+
+ src/SFML/Graphics/Glyph.hsc view
@@ -0,0 +1,43 @@+{-# LANGUAGE CPP, ForeignFunctionInterface #-}+module SFML.Graphics.Glyph+(+    Glyph(..)+)+where+++import SFML.Graphics.Rect++import Foreign.C.Types+import Foreign.Storable++#include <SFML/Graphics/Glyph.h>+++sizeInt = #{size int}+sizeIntRect = #{size sfIntRect}+++-- | Describes a glyph (a visual character).+data Glyph = Glyph+    { advance     :: Int     -- ^ Offset to move horizontically to the next character+    , bounds      :: IntRect -- ^ Bounding rectangle of the glyph, in coordinates relative to the baseline+    , textureRect :: IntRect -- ^ Texture coordinates of the glyph inside the font's image+    }+++instance Storable Glyph where+    sizeOf _ = sizeInt + 2*sizeIntRect+    alignment _ = alignment (undefined :: IntRect)+    +    peek ptr = do+        advance <- #{peek sfGlyph, advance} ptr :: IO CInt+        bounds  <- #{peek sfGlyph, bounds} ptr+        rect    <- #{peek sfGlyph, textureRect} ptr+        return $ Glyph (fromIntegral advance) bounds rect+    +    poke ptr (Glyph advance bounds rect) = do+        #{poke sfGlyph, advance} ptr (fromIntegral advance :: CInt)+        #{poke sfGlyph, bounds} ptr bounds+        #{poke sfGlyph, textureRect} ptr rect+
+ src/SFML/Graphics/Image.hs view
@@ -0,0 +1,348 @@+{-# LANGUAGE DeriveDataTypeable #-}+module SFML.Graphics.Image+(+    module SFML.Utils+,   ImageException(..)+,   createImage+,   imageFromColor+,   imageFromPixels+,   imageFromFile+,   imageFromMemory+,   imageFromStream+,   copy+,   destroy+,   saveImage+,   imageSize+,   createMaskFromColor+,   copyImage'+,   setPixel+,   getPixel+,   getPixels+,   flipHorizontally+,   flipVertically+)+where+++import SFML.Graphics.Color+import SFML.Graphics.Rect+import SFML.Graphics.Types+import SFML.SFCopyable+import SFML.SFResource+import SFML.System.InputStream+import SFML.System.Vector2+import SFML.Utils++import Control.Exception+import Data.Typeable+import Data.Word (Word8)+import Foreign.Ptr+import Foreign.C.String+import Foreign.C.Types+import Foreign.Marshal.Alloc (alloca)+import Foreign.Marshal.Utils (with)+import Foreign.Storable (peek)+++checkNull :: Image -> Maybe Image+checkNull img@(Image ptr) = if ptr == nullPtr then Nothing else Just img+++data ImageException = ImageException String deriving (Show, Typeable)++instance Exception ImageException+++-- | Create an image.+--+-- This image is filled with black pixels.+createImage+    :: Int -- ^ Width of the image+    -> Int -- ^ Height of the image+    -> IO (Either ImageException Image)++createImage w h =+    let err = ImageException "Failed creating image"+    in fmap (tagErr err . checkNull) $ sfImage_create (fromIntegral w) (fromIntegral h)++foreign import ccall unsafe "sfImage_create"+    sfImage_create :: CUInt -> CUInt -> IO Image++--CSFML_GRAPHICS_API sfImage* sfImage_create(unsigned int width, unsigned int height);+++-- | Create an image and fill it with a unique color.+imageFromColor+    :: Int   -- ^ Width of the image+    -> Int   -- ^ Height of the image+    -> Color -- ^ Fill color+    -> IO Image++imageFromColor w h color = with color $+    sfImage_createFromColor_helper (fromIntegral w) (fromIntegral h)++foreign import ccall unsafe "sfImage_createFromColor_helper"+    sfImage_createFromColor_helper :: CUInt -> CUInt -> Ptr Color -> IO Image++--CSFML_GRAPHICS_API sfImage* sfImage_createFromColor(unsigned int width, unsigned int height, sfColor color);+++-- | Create an image from an array of pixels.+--+-- The pixel array is assumed to contain 32-bits RGBA pixels,+-- and have the given width and height. If not, this is+-- an undefined behaviour.+--+-- If pixels is null, an empty image is created.+imageFromPixels+    :: Int -- ^ Width of the image+    -> Int -- ^ Height of the image+    -> Ptr a -- ^ Array of pixels to copy to the image+    -> IO Image++imageFromPixels w h pixels = sfImage_createFromPixels (fromIntegral w) (fromIntegral h) pixels++foreign import ccall unsafe "sfImage_createFromPixels"+    sfImage_createFromPixels :: CUInt -> CUInt -> Ptr a -> IO Image++--CSFML_GRAPHICS_API sfImage* sfImage_createFromPixels(unsigned int width, unsigned int height, const sfUint8* pixels);+++-- | Create an image from a file on disk.++-- The supported image formats are bmp, png, tga, jpg, gif,+-- psd, hdr and pic. Some format options are not supported,+-- like progressive jpeg.+--+-- If this function fails, the image is left unchanged.+imageFromFile :: FilePath -> IO (Maybe Image)++imageFromFile path = fmap checkNull $ withCAString path sfImage_createFromFile++foreign import ccall unsafe "sfImage_createFromFile"+    sfImage_createFromFile :: CString -> IO Image++--CSFML_GRAPHICS_API sfImage* sfImage_createFromFile(const char* filename);+++-- | Create an image from a file in memory.+--+-- The supported image formats are bmp, png, tga, jpg, gif,+-- psd, hdr and pic. Some format options are not supported,+-- like progressive jpeg.+--+-- If this function fails, the image is left unchanged.+imageFromMemory+    :: Ptr a -- ^ Pointer to the file data in memory+    -> Int   -- ^ Size of the data to load, in bytes+    -> IO (Maybe Image)++imageFromMemory pixels size = fmap checkNull $ sfImage_createFromMemory pixels (fromIntegral size)++foreign import ccall unsafe "sfImage_createFromMemory"+    sfImage_createFromMemory :: Ptr a -> CUInt -> IO Image++--CSFML_GRAPHICS_API sfImage* sfImage_createFromMemory(const void* data, size_t size);+++-- | Create an image from a custom stream.+--+-- The supported image formats are bmp, png, tga, jpg, gif,+-- psd, hdr and pic. Some format options are not supported,+-- like progressive jpeg.+--+-- If this function fails, the image is left unchanged.+imageFromStream :: InputStream -> IO (Maybe Image)++imageFromStream stream = fmap checkNull $ with stream sfImage_createFromStream++foreign import ccall "sfImage_createFromStream"+    sfImage_createFromStream :: Ptr InputStream -> IO Image++--CSFML_GRAPHICS_API sfImage* sfImage_createFromStream(sfInputStream* stream);+++instance SFCopyable Image where+    +    {-# INLINABLE copy #-}+    copy = sfImage_copy+++foreign import ccall unsafe "sfImage_copy"+    sfImage_copy :: Image -> IO Image++--CSFML_GRAPHICS_API sfImage* sfImage_copy(sfImage* image);+++instance SFResource Image where+    +    {-# INLINABLE destroy #-}+    destroy = sfImage_destroy++foreign import ccall unsafe "sfImage_destroy"+    sfImage_destroy :: Image -> IO ()++--CSFML_GRAPHICS_API void sfImage_destroy(sfImage* image);+++-- | Save an image to a file on disk.+--+-- The format of the image is automatically deduced from+-- the extension. The supported image formats are bmp, png,+-- tga and jpg. The destination file is overwritten+-- if it already exists. This function fails if the image is empty.+--+-- Return 'True' if saving was successful.+saveImage :: Image -> FilePath -> IO Bool++saveImage image path = fmap (/=0) . withCAString path $ sfImage_saveToFile image++foreign import ccall unsafe "sfImage_saveToFile"+    sfImage_saveToFile :: Image -> CString -> IO CInt++--CSFML_GRAPHICS_API sfBool sfImage_saveToFile(const sfImage* image, const char* filename);+++-- | Return the size of an image in pixels.+imageSize :: Image -> IO Vec2u++imageSize image = alloca $ \ptr -> sfImage_getSize_helper image ptr >> peek ptr++foreign import ccall unsafe "sfImage_getSize_helper"+    sfImage_getSize_helper :: Image -> Ptr Vec2u -> IO ()++--CSFML_GRAPHICS_API sfVector2u sfImage_getSize(const sfImage* image);+++-- | Create a transparency mask from a specified color-key.+--+-- This function sets the alpha value of every pixel matching+-- the given color to alpha (0 by default), so that they+-- become transparent.+createMaskFromColor+    :: Image -- ^ Image object+    -> Color -- ^ Color to make transparent+    -> Int   -- ^ Alpha value to assign to transparent pixels+    -> IO ()++createMaskFromColor image color alpha = with color $+    \ptrColor -> sfImage_createMaskFromColor_helper image ptrColor (fromIntegral alpha)++foreign import ccall unsafe "sfImage_createMaskFromColor_helper"+    sfImage_createMaskFromColor_helper :: Image -> Ptr Color -> Word8 -> IO ()++--CSFML_GRAPHICS_API void sfImage_createMaskFromColor(sfImage* image, sfColor color, sfUint8 alpha);+++-- | Copy pixels from an image onto another+--+-- This function does a slow pixel copy and should not be+-- used intensively. It can be used to prepare a complex+-- static image from several others, but if you need this+-- kind of feature in real-time you'd better use sfRenderTexture.+--+-- If sourceRect is empty, the whole image is copied.+-- If applyAlpha is set to true, the transparency of+-- source pixels is applied. If it is false, the pixels are+-- copied unchanged with their alpha value.+copyImage'+    :: Image   -- ^ Dest image object+    -> Image   -- ^ Source image to copy+    -> Int     -- ^ X coordinate of the destination position+    -> Int     -- ^ Y coordinate of the destination position+    -> IntRect -- ^ Sub-rectangle of the source image to copy+    -> Bool    -- ^ Should the copy take in account the source transparency?+    -> IO ()++copyImage' dst src x y rect transp = with rect $+    \ptrRect ->+        sfImage_copyImage_helper src dst (fromIntegral x) (fromIntegral y) ptrRect (fromIntegral . fromEnum $ transp)++foreign import ccall unsafe "sfImage_copyImage_helper"+    sfImage_copyImage_helper :: Image -> Image -> CUInt -> CUInt -> Ptr IntRect -> CInt -> IO ()++--CSFML_GRAPHICS_API void sfImage_copyImage(sfImage* image, const sfImage* source, unsigned int destX, unsigned int destY, sfIntRect sourceRect, sfBool applyAlpha);+++-- | Change the color of a pixel in an image.+--+-- This function doesn't check the validity of the pixel+-- coordinates, using out-of-range values will result in+-- an undefined behaviour.+setPixel+    :: Image -- ^ Image object+    -> Int   -- ^ X coordinate of pixel to change+    -> Int   -- ^ Y coordinate of pixel to change+    -> Color -- ^ New color of the pixel+    -> IO ()++setPixel image x y color = with color $ sfImage_setPixel_helper image (fromIntegral x) (fromIntegral y)++foreign import ccall unsafe "sfImage_setPixel_helper"+    sfImage_setPixel_helper :: Image -> CUInt -> CUInt -> Ptr Color -> IO ()++--CSFML_GRAPHICS_API void sfImage_setPixel(sfImage* image, unsigned int x, unsigned int y, sfColor color);+++-- | Get the color of a pixel in an image.+--+-- This function doesn't check the validity of the pixel+-- coordinates, using out-of-range values will result in+-- an undefined behaviour.+getPixel+    :: Image -- ^ Image object+    -> Int   -- ^ X coordinate of pixel to get+    -> Int   -- ^ Y coordinate of pixel to get+    -> IO Color++getPixel image x y = alloca $+    \ptr -> sfImage_getPixel_helper image (fromIntegral x) (fromIntegral y) ptr >> peek ptr++foreign import ccall unsafe "sfImage_getPixel_helper"+    sfImage_getPixel_helper :: Image -> CUInt -> CUInt -> Ptr Color -> IO ()++--CSFML_GRAPHICS_API sfColor sfImage_getPixel(const sfImage* image, unsigned int x, unsigned int y);+++-- | Get a read-only pointer to the array of pixels of an image.+--+-- The returned value points to an array of RGBA pixels made of+-- 8 bits integers components. The size of the array is+-- getWidth() * getHeight() * 4.+--+-- Warning: the returned pointer may become invalid if you+-- modify the image, so you should never store it for too long.+-- If the image is empty, a null pointer is returned.+getPixels+    :: Image+    -> IO (Ptr a)++getPixels = sfImage_getPixelsPtr++foreign import ccall unsafe "sfImage_getPixelsPtr"+    sfImage_getPixelsPtr :: Image -> IO (Ptr a)++--CSFML_GRAPHICS_API const sfUint8* sfImage_getPixelsPtr(const sfImage* image);+++-- | Flip an image horizontally (left <-> right).+flipHorizontally :: Image -> IO ()++flipHorizontally = sfImage_flipHorizontally++foreign import ccall unsafe "sfImage_flipHorizontally"+    sfImage_flipHorizontally :: Image -> IO ()++--CSFML_GRAPHICS_API void sfImage_flipHorizontally(sfImage* image);+++-- | Flip an image vertically (top <-> bottom)+flipVertically :: Image -> IO ()++flipVertically = sfImage_flipVertically++foreign import ccall unsafe "sfImage_flipVertically"+    sfImage_flipVertically :: Image -> IO ()++--CSFML_GRAPHICS_API void sfImage_flipVertically(sfImage* image);+
+ src/SFML/Graphics/PrimitiveType.hs view
@@ -0,0 +1,47 @@+module SFML.Graphics.PrimitiveType+(+    PrimitiveType(..)+)+where+++import Foreign.C.Types (CInt)+import Foreign.Ptr+import Foreign.Storable+++-- | Types of primitives that a sf::VertexArray can render.+--+-- Points and lines have no area, therefore their thickness+-- will always be 1 pixel, regardless of the current transform+-- and view.+data PrimitiveType+    = Points        -- ^ List of individual points+    | Lines         -- ^ List of individual lines+    | LineStrip     -- ^ List of connected lines, a point uses the previous point to form a line+    | Triangles     -- ^ List of individual triangles+    | TriangleStrip -- ^ List of connected triangles, a point uses the two previous points to form a triangle+    | TriangleFan   -- ^ List of connected triangles, a point uses the common center and the previous point to form a triangle+    | Quads         -- ^ List of individual quads+    deriving (Eq, Enum, Bounded, Show)+++instance Storable PrimitiveType where+    sizeOf _ = sizeOf (undefined :: CInt)+    alignment _ = alignment (undefined :: CInt)+    +    peek ptr = peek (castPtr ptr :: Ptr CInt) >>= return . toEnum . fromIntegral+    poke ptr pt = poke (castPtr ptr :: Ptr CInt) (fromIntegral . fromEnum $ pt)+++{-typedef enum +{+    sfPoints,         +    sfLines,          +    sfLinesStrip,     +    sfTriangles,      +    sfTrianglesStrip, +    sfTrianglesFan,   +    sfQuads           +} sfPrimitiveType;-}+
+ src/SFML/Graphics/Rect.hsc view
@@ -0,0 +1,158 @@+{-# LANGUAGE CPP, ForeignFunctionInterface #-}+module SFML.Graphics.Rect+(+    FloatRect(..)+,   IntRect(..)+,   Rect(..)+,   floatRectContains+,   intRectContains+)+where+++import Foreign.C.Types+import Foreign.Marshal.Alloc (alloca)+import Foreign.Marshal.Utils (with)+import Foreign.Ptr (Ptr)+import Foreign.Storable+import System.IO.Unsafe++#include <SFML/Graphics/Rect.h>+++sizeInt = #{size int}+sizeFloat = #{size float}+++-- | Utility class for manipulating rectangles.+data FloatRect = FloatRect+    { fleft   :: Float+    , ftop    :: Float+    , fwidth  :: Float+    , fheight :: Float+    }+++instance Storable FloatRect where+    sizeOf _ = 4 * sizeFloat+    alignment _ = alignment (undefined :: CFloat)+    +    peek ptr = do+        l <- fmap realToFrac (#{peek sfFloatRect, left} ptr :: IO CFloat)+        t <- fmap realToFrac (#{peek sfFloatRect, top} ptr :: IO CFloat)+        w <- fmap realToFrac (#{peek sfFloatRect, width} ptr :: IO CFloat)+        h <- fmap realToFrac (#{peek sfFloatRect, height} ptr :: IO CFloat)+        return $ FloatRect l t w h+    +    poke ptr (FloatRect l t w h) = do+        #{poke sfFloatRect, left} ptr (realToFrac l :: CFloat)+        #{poke sfFloatRect, top} ptr (realToFrac t :: CFloat)+        #{poke sfFloatRect, width} ptr (realToFrac w :: CFloat)+        #{poke sfFloatRect, height} ptr (realToFrac h :: CFloat)+++-- | Utility class for manipulating rectangles.+data IntRect = IntRect+    { ileft   :: Int+    , itop    :: Int+    , iwidth  :: Int+    , iheight :: Int+    }+++instance Storable IntRect where+    sizeOf _ = 4 * sizeInt+    alignment _ = alignment (undefined :: CInt)+    +    peek ptr = do+        l <- #{peek sfIntRect, left} ptr   :: IO CInt+        t <- #{peek sfIntRect, top} ptr    :: IO CInt+        w <- #{peek sfIntRect, width} ptr  :: IO CInt+        h <- #{peek sfIntRect, height} ptr :: IO CInt+        return $ IntRect (fromIntegral l) (fromIntegral t) (fromIntegral w) (fromIntegral h)+    +    poke ptr (IntRect l t w h) = do+        #{poke sfIntRect, left} ptr (fromIntegral l :: CInt)+        #{poke sfIntRect, top} ptr (fromIntegral t :: CInt)+        #{poke sfIntRect, width} ptr (fromIntegral w :: CInt)+        #{poke sfIntRect, height} ptr (fromIntegral h :: CInt)+++-- | Check if a point is inside a rectangle's area.+floatRectContains+    :: Float -- ^ X coordinate of the point to test+    -> Float -- ^ Y coordinate of the point to test+    -> FloatRect -- ^ Rectangle to test+    -> Bool++floatRectContains x y r = unsafeDupablePerformIO $ fmap (/=0) . with r $ \ptr -> sfFloatRect_contains ptr x y++foreign import ccall unsafe "sfFloatRect_contains"+    sfFloatRect_contains :: Ptr FloatRect -> Float -> Float -> IO CInt++--CSFML_GRAPHICS_API sfBool sfFloatRect_contains(const sfFloatRect* rect, float x, float y);+++-- | Check if a point is inside a rectangle's area.+intRectContains+    :: Int -- ^ X coordinate of the point to test+    -> Int -- ^ Y coordinate of the point to test+    -> IntRect -- ^ Rectangle to test+    -> Bool++intRectContains x y r = unsafeDupablePerformIO $ fmap (/=0) . with r $+    \ptr -> sfIntRect_contains ptr (fromIntegral x) (fromIntegral y)++foreign import ccall unsafe "sfIntRect_contains"+    sfIntRect_contains :: Ptr IntRect -> CInt -> CInt -> IO CInt++--CSFML_GRAPHICS_API sfBool sfIntRect_contains(const sfIntRect* rect, int x, int y);+++class Rect a where+    -- | Check intersection between two rectangles.+    intersectRect+        :: a -- ^ First rectangle to test+        -> a -- ^ Second rectangle to test+        -> Maybe a -- ^ Overlapping rect+++instance Rect FloatRect where+    +    intersectRect r1 r2 = unsafeDupablePerformIO $+        alloca $ \ptr1 ->+        alloca $ \ptr2 ->+        alloca $ \ptrOut -> do+        poke ptr1 r1+        poke ptr2 r2+        result <- sfFloatRect_intersects ptr1 ptr2 ptrOut+        case result of+            0 -> return Nothing+            _ -> peek ptrOut >>= return . Just+++foreign import ccall unsafe "sfFloatRect_intersects"+    sfFloatRect_intersects :: Ptr FloatRect -> Ptr FloatRect -> Ptr FloatRect -> IO CInt++--CSFML_GRAPHICS_API sfBool sfFloatRect_intersects(const sfFloatRect* rect1, const sfFloatRect* rect2, sfFloatRect* intersection);+++instance Rect IntRect where+    +    intersectRect r1 r2 = unsafeDupablePerformIO $+        alloca $ \ptr1 ->+        alloca $ \ptr2 ->+        alloca $ \ptrOut -> do+        poke ptr1 r1+        poke ptr2 r2+        result <- sfIntRect_intersects ptr1 ptr2 ptrOut+        case result of+            0 -> return Nothing+            _ -> peek ptrOut >>= return . Just+++foreign import ccall unsafe "sfIntRect_intersects"+    sfIntRect_intersects :: Ptr IntRect -> Ptr IntRect -> Ptr IntRect -> IO CInt++--CSFML_GRAPHICS_API sfBool sfIntRect_intersects(const sfIntRect* rect1, const sfIntRect* rect2, sfIntRect* intersection);+
+ src/SFML/Graphics/RectangleShape.hs view
@@ -0,0 +1,362 @@+{-# LANGUAGE DeriveDataTypeable #-}+module SFML.Graphics.RectangleShape+(+    module SFML.Utils+,   RectangleShapeException(..)+,   createRectangleShape+,   copy+,   destroy+,   setPosition+,   setRotation+,   setScale+,   setOrigin+,   getPosition+,   getRotation+,   getScale+,   getOrigin+,   move+,   rotate+,   scale+,   getTransform+,   getInverseTransform+,   setTexture+,   setTextureRect+,   getTexture+,   getTextureRect+,   setFillColor+,   setOutlineColor+,   setOutlineThickness+,   getFillColor+,   getOutlineColor+,   getOutlineThickness+,   getPointCount+,   getPoint+,   setPointCount+,   setSize+,   getSize+,   getLocalBounds+,   getGlobalBounds+)+where+++import SFML.Graphics.SFBounded+import SFML.Graphics.Color+import SFML.Graphics.Rect+import SFML.Graphics.SFShape+import SFML.Graphics.SFShapeResizable+import SFML.Graphics.SFTexturable+import SFML.Graphics.Transform+import SFML.Graphics.Transformable+import SFML.Graphics.Types+import SFML.SFCopyable+import SFML.SFResource+import SFML.System.Vector2+import SFML.Utils++import Control.Exception+import Control.Monad ((>=>))+import Data.Typeable+import Foreign.C.Types+import Foreign.Ptr (Ptr, nullPtr)+import Foreign.Marshal.Alloc (alloca)+import Foreign.Marshal.Utils (with)+import Foreign.Storable (peek)+++checkNull :: RectangleShape -> Maybe RectangleShape+checkNull rs@(RectangleShape ptr) = if ptr == nullPtr then Nothing else Just rs+++checkNullTexture :: Texture -> Maybe Texture+checkNullTexture tex@(Texture ptr) = if ptr == nullPtr then Nothing else Just tex+++data RectangleShapeException = RectangleShapeException String deriving (Show, Typeable)++instance Exception RectangleShapeException+++-- | Create a new rectangle shape.+createRectangleShape :: IO (Either RectangleShapeException RectangleShape)+createRectangleShape =+    let err = RectangleShapeException "Failed creating rectangle shape"+    in fmap (tagErr err . checkNull) sfRectangleShape_create++foreign import ccall unsafe "sfRectangleShape_create"+    sfRectangleShape_create :: IO RectangleShape++-- \return A new sfRectangleShape object, or NULL if it failed++--CSFML_GRAPHICS_API sfRectangleShape* sfRectangleShape_create(void);+++instance SFCopyable RectangleShape where++    {-# INLINABLE copy #-}+    copy = sfRectangleShape_copy+++foreign import ccall unsafe "sfRectangleShape_copy"+    sfRectangleShape_copy :: RectangleShape -> IO RectangleShape++--CSFML_GRAPHICS_API sfRectangleShape* sfRectangleShape_copy(sfRectangleShape* shape);+++instance SFResource RectangleShape where++    {-# INLINABLE destroy #-}+    destroy = sfRectangleShape_destroy++foreign import ccall unsafe "sfRectangleShape_destroy"+    sfRectangleShape_destroy :: RectangleShape -> IO ()++--CSFML_GRAPHICS_API void sfRectangleShape_destroy(sfRectangleShape* shape);++instance Transformable RectangleShape where++    {-# INLINABLE setPosition #-}+    setPosition c p = with p $ sfRectangleShape_setPosition_helper c++    {-# INLINABLE setRotation #-}+    setRotation s r = sfRectangleShape_setRotation s (realToFrac r)++    {-# INLINABLE setScale #-}+    setScale c s = with s $ sfRectangleShape_setScale_helper c++    {-# INLINABLE setOrigin #-}+    setOrigin c o = with o $ sfRectangleShape_setOrigin_helper c++    {-# INLINABLE getPosition #-}+    getPosition c = alloca $ \ptr -> sfRectangleShape_getPosition_helper c ptr >> peek ptr++    {-# INLINABLE getRotation #-}+    getRotation = sfRectangleShape_getRotation >=> return . realToFrac++    {-# INLINABLE getScale #-}+    getScale c = alloca $ \ptr -> sfRectangleShape_getScale_helper c ptr >> peek ptr++    {-# INLINABLE getOrigin #-}+    getOrigin c = alloca $ \ptr -> sfRectangleShape_getOrigin_helper c ptr >> peek ptr++    {-# INLINABLE move #-}+    move c off = with off $ sfRectangleShape_move_helper c++    {-# INLINABLE rotate #-}+    rotate r a = sfRectangleShape_rotate r (realToFrac a)++    {-# INLINABLE scale #-}+    scale c s = with s $ sfRectangleShape_scale_helper c++    {-# INLINABLE getTransform #-}+    getTransform c = alloca $ \ptr -> sfRectangleShape_getTransform_helper c ptr >> peek ptr++    {-# INLINABLE getInverseTransform #-}+    getInverseTransform c = alloca $ \ptr -> sfRectangleShape_getInverseTransform_helper c ptr >> peek ptr+++foreign import ccall unsafe "sfRectangleShape_setPosition_helper"+    sfRectangleShape_setPosition_helper :: RectangleShape -> Ptr Vec2f -> IO ()++--CSFML_GRAPHICS_API void sfRectangleShape_setPosition(sfRectangleShape* shape, sfVector2f position);++foreign import ccall unsafe "sfRectangleShape_setRotation"+    sfRectangleShape_setRotation :: RectangleShape -> CFloat -> IO ()++--CSFML_GRAPHICS_API void sfRectangleShape_setRotation(sfRectangleShape* shape, float angle);++foreign import ccall unsafe "sfRectangleShape_setScale_helper"+    sfRectangleShape_setScale_helper :: RectangleShape -> Ptr Vec2f -> IO ()++--CSFML_GRAPHICS_API void sfRectangleShape_setScale(sfRectangleShape* shape, sfVector2f scale);++foreign import ccall unsafe "sfRectangleShape_setOrigin_helper"+    sfRectangleShape_setOrigin_helper :: RectangleShape -> Ptr Vec2f -> IO ()++--CSFML_GRAPHICS_API void sfRectangleShape_setOrigin(sfRectangleShape* shape, sfVector2f origin);++foreign import ccall unsafe "sfRectangleShape_getPosition_helper"+    sfRectangleShape_getPosition_helper :: RectangleShape -> Ptr Vec2f -> IO ()++--CSFML_GRAPHICS_API sfVector2f sfRectangleShape_getPosition(const sfRectangleShape* shape);++foreign import ccall unsafe "sfRectangleShape_getRotation"+    sfRectangleShape_getRotation :: RectangleShape -> IO CFloat++--CSFML_GRAPHICS_API float sfRectangleShape_getRotation(const sfRectangleShape* shape);++foreign import ccall unsafe "sfRectangleShape_getScale_helper"+    sfRectangleShape_getScale_helper :: RectangleShape -> Ptr Vec2f -> IO ()++--CSFML_GRAPHICS_API sfVector2f sfRectangleShape_getScale(const sfRectangleShape* shape);++foreign import ccall unsafe "sfRectangleShape_getOrigin_helper"+    sfRectangleShape_getOrigin_helper :: RectangleShape -> Ptr Vec2f -> IO ()++--CSFML_GRAPHICS_API sfVector2f sfRectangleShape_getOrigin(const sfRectangleShape* shape);++foreign import ccall unsafe "sfRectangleShape_move_helper"+    sfRectangleShape_move_helper :: RectangleShape -> Ptr Vec2f -> IO ()++--CSFML_GRAPHICS_API void sfRectangleShape_move(sfRectangleShape* shape, sfVector2f offset);++foreign import ccall unsafe "sfRectangleShape_rotate"+    sfRectangleShape_rotate :: RectangleShape -> CFloat -> IO ()++--CSFML_GRAPHICS_API void sfRectangleShape_rotate(sfRectangleShape* shape, float angle);++foreign import ccall unsafe "sfRectangleShape_scale_helper"+    sfRectangleShape_scale_helper :: RectangleShape -> Ptr Vec2f -> IO ()++--CSFML_GRAPHICS_API void sfRectangleShape_scale(sfRectangleShape* shape, sfVector2f factors);++foreign import ccall unsafe "sfRectangleShape_getTransform_helper"+    sfRectangleShape_getTransform_helper :: RectangleShape -> Ptr Transform -> IO ()++--CSFML_GRAPHICS_API sfTransform sfRectangleShape_getTransform(const sfRectangleShape* shape);++foreign import ccall unsafe "sfRectangleShape_getInverseTransform_helper"+    sfRectangleShape_getInverseTransform_helper :: RectangleShape -> Ptr Transform -> IO ()++--CSFML_GRAPHICS_API sfTransform sfRectangleShape_getInverseTransform(const sfRectangleShape* shape);++instance SFTexturable RectangleShape where++    {-# INLINABLE setTexture #-}+    setTexture c tex reset = sfRectangleShape_setTexture c tex (fromIntegral . fromEnum $ reset)++    {-# INLINABLE setTextureRect #-}+    setTextureRect c rect = with rect $ sfRectangleShape_setTextureRect_helper c++    {-# INLINABLE getTexture #-}+    getTexture = sfRectangleShape_getTexture >=> return . checkNullTexture++    {-# INLINABLE getTextureRect #-}+    getTextureRect c = alloca $ \ptr -> sfRectangleShape_getTextureRect_helper c ptr >> peek ptr+++foreign import ccall unsafe "sfRectangleShape_setTexture"+    sfRectangleShape_setTexture :: RectangleShape -> Texture -> CInt -> IO ()++--CSFML_GRAPHICS_API void sfRectangleShape_setTexture(sfRectangleShape* shape, const sfTexture* texture, sfBool resetRect);++foreign import ccall unsafe "sfRectangleShape_setTextureRect_helper"+    sfRectangleShape_setTextureRect_helper :: RectangleShape -> Ptr IntRect -> IO ()++--CSFML_GRAPHICS_API void sfRectangleShape_setTextureRect(sfRectangleShape* shape, sfIntRect rect);++foreign import ccall unsafe "sfRectangleShape_getTexture"+    sfRectangleShape_getTexture :: RectangleShape -> IO Texture++--CSFML_GRAPHICS_API const sfTexture* sfRectangleShape_getTexture(const sfRectangleShape* shape);++foreign import ccall unsafe "sfRectangleShape_getTextureRect_helper"+    sfRectangleShape_getTextureRect_helper :: RectangleShape -> Ptr IntRect -> IO ()++--CSFML_GRAPHICS_API sfIntRect sfRectangleShape_getTextureRect(const sfRectangleShape* shape);++instance SFShape RectangleShape where++    {-# INLINABLE setFillColor #-}+    setFillColor c color = with color $ sfRectangleShape_setFillColor_helper c++    {-# INLINABLE setOutlineColor #-}+    setOutlineColor c color = with color $ sfRectangleShape_setOutlineColor_helper c++    {-# INLINABLE setOutlineThickness #-}+    setOutlineThickness r t = sfRectangleShape_setOutlineThickness r (realToFrac t)++    {-# INLINABLE getFillColor #-}+    getFillColor c = alloca $ \ptr -> sfRectangleShape_getFillColor_helper c ptr >> peek ptr++    {-# INLINABLE getOutlineColor #-}+    getOutlineColor c = alloca $ \ptr -> sfRectangleShape_getOutlineColor_helper c ptr >> peek ptr++    {-# INLINABLE getOutlineThickness #-}+    getOutlineThickness = sfRectangleShape_getOutlineThickness >=> return . realToFrac++    {-# INLINABLE getPointCount #-}+    getPointCount = sfRectangleShape_getPointCount >=> return . fromIntegral++    {-# INLINABLE getPoint #-}+    getPoint c idx = alloca $ \ptr -> sfRectangleShape_getPoint_helper c (fromIntegral idx) ptr >> peek ptr+++foreign import ccall unsafe "sfRectangleShape_setFillColor_helper"+    sfRectangleShape_setFillColor_helper :: RectangleShape -> Ptr Color -> IO ()++--CSFML_GRAPHICS_API void sfRectangleShape_setFillColor(sfRectangleShape* shape, sfColor color);++foreign import ccall unsafe "sfRectangleShape_setOutlineColor_helper"+    sfRectangleShape_setOutlineColor_helper :: RectangleShape -> Ptr Color -> IO ()++--CSFML_GRAPHICS_API void sfRectangleShape_setOutlineColor(sfRectangleShape* shape, sfColor color);++foreign import ccall unsafe "sfRectangleShape_setOutlineThickness"+    sfRectangleShape_setOutlineThickness :: RectangleShape -> CFloat -> IO ()++--CSFML_GRAPHICS_API void sfRectangleShape_setOutlineThickness(sfRectangleShape* shape, float thickness);++foreign import ccall unsafe "sfRectangleShape_getFillColor_helper"+    sfRectangleShape_getFillColor_helper :: RectangleShape -> Ptr Color -> IO ()++--CSFML_GRAPHICS_API sfColor sfRectangleShape_getFillColor(const sfRectangleShape* shape);++foreign import ccall unsafe "sfRectangleShape_getOutlineColor_helper"+    sfRectangleShape_getOutlineColor_helper :: RectangleShape -> Ptr Color -> IO ()++--CSFML_GRAPHICS_API sfColor sfRectangleShape_getOutlineColor(const sfRectangleShape* shape);++foreign import ccall unsafe "sfRectangleShape_getOutlineThickness"+    sfRectangleShape_getOutlineThickness :: RectangleShape -> IO CFloat++--CSFML_GRAPHICS_API float sfRectangleShape_getOutlineThickness(const sfRectangleShape* shape);++foreign import ccall unsafe "sfRectangleShape_getPointCount"+    sfRectangleShape_getPointCount :: RectangleShape -> IO CUInt++--CSFML_GRAPHICS_API unsigned int sfRectangleShape_getPointCount(const sfRectangleShape* shape);++foreign import ccall unsafe "sfRectangleShape_getPoint_helper"+    sfRectangleShape_getPoint_helper :: RectangleShape -> CUInt -> Ptr Vec2f -> IO ()++--CSFML_GRAPHICS_API sfVector2f sfRectangleShape_getPoint(const sfRectangleShape* shape, unsigned int index);+++-- | Set the size of a rectangle shape.+setSize :: RectangleShape -> Vec2f -> IO ()+setSize rs s = with s $ sfRectangleShape_setSize_helper rs++foreign import ccall unsafe "sfRectangleShape_setSize_helper"+    sfRectangleShape_setSize_helper :: RectangleShape -> Ptr Vec2f -> IO ()++--CSFML_GRAPHICS_API void sfRectangleShape_setSize(sfRectangleShape* shape, sfVector2f size);+++-- | Get the size of a rectangle shape.+getSize :: RectangleShape -> IO Vec2f+getSize r = alloca $ \ptr -> sfRectangleShape_getSize_helper r ptr >> peek ptr++foreign import ccall unsafe "sfRectangleShape_getSize_helper"+    sfRectangleShape_getSize_helper :: RectangleShape -> Ptr Vec2f -> IO ()++--CSFML_GRAPHICS_API sfVector2f sfRectangleShape_getSize(const sfRectangleShape* shape);+++instance SFBounded RectangleShape where++    {-# INLINABLE getLocalBounds #-}+    getLocalBounds c = alloca $ \ptr -> sfRectangleShape_getLocalBounds_helper c ptr >> peek ptr++    {-# INLINABLE getGlobalBounds #-}+    getGlobalBounds c = alloca $ \ptr -> sfRectangleShape_getGlobalBounds_helper c ptr >> peek ptr++foreign import ccall unsafe "sfRectangleShape_getLocalBounds_helper"+    sfRectangleShape_getLocalBounds_helper :: RectangleShape -> Ptr FloatRect -> IO ()++--CSFML_GRAPHICS_API sfFloatRect sfRectangleShape_getLocalBounds(const sfRectangleShape* shape);++foreign import ccall unsafe "sfRectangleShape_getGlobalBounds_helper"+    sfRectangleShape_getGlobalBounds_helper :: RectangleShape -> Ptr FloatRect -> IO ()++--CSFML_GRAPHICS_API sfFloatRect sfRectangleShape_getGlobalBounds(const sfRectangleShape* shape);
+ src/SFML/Graphics/RenderStates.hsc view
@@ -0,0 +1,76 @@+{-# LANGUAGE CPP, ForeignFunctionInterface #-}+module SFML.Graphics.RenderStates+(+    RenderStates(..)+,   renderStates+)+where+++import SFML.Graphics.BlendMode+import SFML.Graphics.Transform+import SFML.Graphics.Types++import Foreign.C.Types (CFloat)+import Foreign.Ptr (nullPtr)+import Foreign.Storable++#include <SFML/Graphics/RenderStates.h>+++-- | Define the states used for drawing to a RenderTarget.+data RenderStates = RenderStates+    { blendMode :: BlendMode+    , transform :: Transform+    , texture   :: Texture+    , shader    :: Shader+    }+++instance Storable RenderStates where+    sizeOf _ = size_sfRenderStates+    alignment _ = alignment (undefined :: CFloat)++    peek ptr = do+        bm <- #{peek sfRenderStates, blendMode} ptr+        tr <- #{peek sfRenderStates, transform} ptr+        tx <- #{peek sfRenderStates, texture} ptr+        sh <- #{peek sfRenderStates, shader} ptr+        return $ RenderStates bm tr tx sh++    poke ptr (RenderStates bm tr tx sh) = do+        #{poke sfRenderStates, blendMode} ptr  bm+        #{poke sfRenderStates, transform} ptr tr+        #{poke sfRenderStates, texture} ptr tx+        #{poke sfRenderStates, shader} ptr sh+++size_sfRenderStates = #{size sfRenderStates}++-- | Default render states, defined as+--+-- @+-- renderStates = RenderStates 'BlendAlpha' 'idTransform' (Texture 'nullPtr') (Shader 'nullPtr')+-- @+--+-- This constant tries to mimic the C++ RenderStates default constructor to ease+-- the construction of render states. For example, instead of typing+--+-- @+-- states = RenderStates BlendAlpha idTransform tex (Shader nullptr)+-- @+--+-- Now we can simply type+--+-- @+-- states = renderStates { texture = tex }+-- @+renderStates = RenderStates BlendAlpha idTransform (Texture nullPtr) (Shader nullPtr)++{-typedef struct+{+    sfBlendMode      blendMode; ///< Blending mode+    sfTransform      transform; ///< Transform+    const sfTexture* texture;   ///< Texture+    const sfShader*  shader;    ///< Shader+} sfRenderStates;-}
+ src/SFML/Graphics/RenderTexture.hs view
@@ -0,0 +1,345 @@+{-# LANGUAGE DeriveDataTypeable #-}+module SFML.Graphics.RenderTexture+(+    module SFML.Utils+,   RenderTextureException(..)+,   createRenderTexture+,   destroy+,   getTextureSize+,   setActive+,   display+,   clear+,   setView+,   getView+,   getDefaultView+,   getViewport+,   mapPixelToCoords+,   drawSprite+,   drawText+,   drawShape+,   drawCircle+,   drawConvexShape+,   drawRectangle+,   drawVertexArray+,   drawPrimitives+,   drawPrimitives'+,   pushGLStates+,   popGLStates+,   resetGLStates+,   getRenderTexture+,   setSmooth+,   isSmooth+)+where+++import SFML.Graphics.Color+import SFML.Graphics.Rect+import SFML.Graphics.SFCoordSpace+import SFML.Graphics.SFSmoothTexture+import SFML.Graphics.SFViewable+import SFML.Graphics.Types+import SFML.Graphics.PrimitiveType+import SFML.Graphics.RenderStates+import SFML.Graphics.SFRenderTarget+import SFML.Graphics.SFSmoothTexture+import SFML.Graphics.Vertex+import SFML.SFDisplayable+import SFML.SFResource+import SFML.System.Vector2+import SFML.Utils++import Control.Exception+import Data.Typeable+import Foreign.C.Types+import Foreign.Marshal.Alloc (alloca)+import Foreign.Marshal.Array (withArray)+import Foreign.Marshal.Utils (with)+import Foreign.Ptr+import Foreign.Storable (peek)+++checkNull :: RenderTexture -> Maybe RenderTexture+checkNull tex@(RenderTexture ptr) = if ptr == nullPtr then Nothing else Just tex+++data RenderTextureException = RenderTextureException String deriving (Show, Typeable)++instance Exception RenderTextureException+++-- | Construct a new render texture.+createRenderTexture+    :: Int -- ^ Width of the render texture+    -> Int -- ^ Height of the render texture+    -> Bool -- ^ Do you want a depth-buffer attached? (useful only if you're doing 3D OpenGL on the render texture)+    -> IO (Either RenderTextureException RenderTexture)++createRenderTexture w h d =+    let err = RenderTextureException "Failed creating render texture"+    in fmap (tagErr err . checkNull) $ sfRenderTexture_create (fromIntegral w) (fromIntegral h) (fromIntegral . fromEnum $ d)++foreign import ccall unsafe "sfRenderTexture_create"+    sfRenderTexture_create :: CUInt -> CUInt -> CInt -> IO RenderTexture++-- \return A new sfRenderTexture object, or NULL if it failed++--CSFML_GRAPHICS_API sfRenderTexture* sfRenderTexture_create(unsigned int width, unsigned int height, sfBool depthBuffer);+++instance SFResource RenderTexture where+    +    {-# INLINABLE destroy #-}+    destroy = sfRenderTexture_destroy++foreign import ccall unsafe "sfRenderTexture_destroy"+    sfRenderTexture_destroy :: RenderTexture -> IO ()++--CSFML_GRAPHICS_API void sfRenderTexture_destroy(sfRenderTexture* renderTexture);+++-- | Get the size of the rendering region of a render texture.+getTextureSize+    :: RenderTexture+    -> IO Vec2u -- ^ Size in pixels++getTextureSize tex = alloca $ \ptr -> sfRenderTexture_getSize_helper tex ptr >> peek ptr++foreign import ccall unsafe "sfRenderTexture_getSize_helper"+    sfRenderTexture_getSize_helper :: RenderTexture -> Ptr Vec2u -> IO ()++--CSFML_GRAPHICS_API sfVector2u sfRenderTexture_getSize(const sfRenderTexture* renderTexture);+++-- | Activate or deactivate a render texture as the current target for rendering.+setActive+    :: RenderTexture -- ^ Render texture object+    -> Bool -- ^ 'True' to activate, 'False' to deactivate+    -> IO Bool -- ^ 'True' if operation was successful, 'False' otherwise++setActive tex val =+    fmap (toEnum . fromIntegral) $ sfRenderTexture_setActive tex (fromIntegral . fromEnum $ val)++foreign import ccall unsafe "sfRenderTexture_setActive"+    sfRenderTexture_setActive :: RenderTexture -> CInt -> IO CInt++--CSFML_GRAPHICS_API sfBool sfRenderTexture_setActive(sfRenderTexture* renderTexture, sfBool active);+++instance SFDisplayable RenderTexture where+    +    {-# INLINABLE display #-}+    display = sfRenderTexture_display++foreign import ccall unsafe "sfRenderTexture_display"+    sfRenderTexture_display :: RenderTexture -> IO ()++--CSFML_GRAPHICS_API void sfRenderTexture_display(sfRenderTexture* renderTexture);+++-- | Clear the rendertexture with the given color.+clear+    :: RenderTexture -- ^ Render texture object+    -> Color -- ^ Fill color+    -> IO ()++clear tex col = with col $ sfRenderTexture_clear_helper tex++foreign import ccall unsafe "sfRenderTexture_clear_helper"+    sfRenderTexture_clear_helper :: RenderTexture -> Ptr Color -> IO ()++--CSFML_GRAPHICS_API void sfRenderTexture_clear(sfRenderTexture* renderTexture, sfColor color);+++instance SFViewable RenderTexture where+    +    {-# INLINABLE setView #-}+    setView = sfRenderTexture_setView+    +    {-# INLINABLE getView #-}+    getView = sfRenderTexture_getView+    +    {-# INLINABLE getDefaultView #-}+    getDefaultView = sfRenderTexture_getDefaultView+    +    {-# INLINABLE getViewport #-}+    getViewport tex view = alloca $ \ptr -> sfRenderTexture_getViewport_helper tex view ptr >> peek ptr+++foreign import ccall unsafe "sfRenderTexture_setView"+    sfRenderTexture_setView :: RenderTexture -> View -> IO ()++--CSFML_GRAPHICS_API void sfRenderTexture_setView(sfRenderTexture* renderTexture, const sfView* view);++foreign import ccall unsafe "sfRenderTexture_getView"+    sfRenderTexture_getView :: RenderTexture -> IO View++--CSFML_GRAPHICS_API const sfView* sfRenderTexture_getView(const sfRenderTexture* renderTexture);++foreign import ccall unsafe "sfRenderTexture_getDefaultView"+    sfRenderTexture_getDefaultView :: RenderTexture -> IO View++--CSFML_GRAPHICS_API const sfView* sfRenderTexture_getDefaultView(const sfRenderTexture* renderTexture);++foreign import ccall unsafe "sfRenderTexture_getViewport_helper"+    sfRenderTexture_getViewport_helper :: RenderTexture -> View -> Ptr IntRect -> IO ()++--CSFML_GRAPHICS_API sfIntRect sfRenderTexture_getViewport(const sfRenderTexture* renderTexture, const sfView* view);+++instance SFCoordSpace RenderTexture where+    +    {-# INLINABLE mapPixelToCoords #-}+    mapPixelToCoords tex point view =+        alloca $ \out ->+        with point $ \ptr -> case view of+            Nothing -> sfRenderTexture_mapPixelToCoords_helper tex ptr (View nullPtr) out >> peek out+            Just v  -> sfRenderTexture_mapPixelToCoords_helper tex ptr v out >> peek out++foreign import ccall unsafe "sfRenderTexture_mapPixelToCoords_helper"+    sfRenderTexture_mapPixelToCoords_helper :: RenderTexture -> Ptr Vec2i -> View -> Ptr Vec2f -> IO ()++--CSFML_GRAPHICS_API sfVector2f sfRenderTexture_mapPixelToCoords(const sfRenderTexture* renderTexture, sfVector2i point, const sfView* targetView);+++instance SFRenderTarget RenderTexture where+    +    {-# INLINABLE drawSprite #-}+    drawSprite tex sprite Nothing = sfRenderTexture_drawSprite tex sprite nullPtr+    drawSprite tex sprite (Just r) = with r $ sfRenderTexture_drawSprite tex sprite+    +    {-# INLINABLE drawText #-}+    drawText tex text Nothing = sfRenderTexture_drawText tex text nullPtr+    drawText tex text (Just r) = with r $ sfRenderTexture_drawText tex text+    +    {-# INLINABLE drawShape #-}+    drawShape tex shape Nothing = sfRenderTexture_drawShape tex shape nullPtr+    drawShape tex shape (Just r) = with r $ sfRenderTexture_drawShape tex shape+    +    {-# INLINABLE drawCircle #-}+    drawCircle tex circle Nothing = sfRenderTexture_drawCircleShape tex circle nullPtr+    drawCircle tex circle (Just r) = with r $ sfRenderTexture_drawCircleShape tex circle+    +    {-# INLINABLE drawConvexShape #-}+    drawConvexShape tex shape Nothing = sfRenderTexture_drawConvexShape tex shape nullPtr+    drawConvexShape tex shape (Just r) = with r $ sfRenderTexture_drawConvexShape tex shape+    +    {-# INLINABLE drawRectangle #-}+    drawRectangle tex shape Nothing = sfRenderTexture_drawRectangleShape tex shape nullPtr+    drawRectangle tex shape (Just r) = with r $ sfRenderTexture_drawRectangleShape tex shape+    +    {-# INLINABLE drawVertexArray #-}+    drawVertexArray tex va Nothing = sfRenderTexture_drawVertexArray tex va nullPtr+    drawVertexArray tex va (Just r) = with r $ sfRenderTexture_drawVertexArray tex va+    +    {-# INLINABLE drawPrimitives #-}+    drawPrimitives tex verts prim Nothing =+        let count = fromIntegral $ length verts+        in withArray verts $ \vertsPtr ->+            sfRenderTexture_drawPrimitives tex vertsPtr count (fromIntegral . fromEnum $ prim) nullPtr+    +    drawPrimitives tex verts prim (Just r) =+        let count = fromIntegral $ length verts+        in withArray verts $ \vertsPtr ->+           with r $ sfRenderTexture_drawPrimitives tex vertsPtr count (fromIntegral . fromEnum $ prim)+    +    drawPrimitives' tex verts count prim Nothing =+        sfRenderTexture_drawPrimitives tex verts (fromIntegral count) (fromIntegral . fromEnum $ prim) nullPtr+    +    drawPrimitives' tex verts count prim (Just r) =+        with r $ sfRenderTexture_drawPrimitives tex verts (fromIntegral count) (fromIntegral . fromEnum $ prim)+    +    {-# INLINABLE pushGLStates #-}+    pushGLStates = sfRenderTexture_pushGLStates+    +    {-# INLINABLE popGLStates #-}+    popGLStates = sfRenderTexture_popGLStates+    +    {-# INLINABLE resetGLStates #-}+    resetGLStates = sfRenderTexture_resetGLStates+++foreign import ccall unsafe "sfRenderTexture_drawSprite"+    sfRenderTexture_drawSprite :: RenderTexture -> Sprite -> Ptr RenderStates -> IO ()++--CSFML_GRAPHICS_API void sfRenderTexture_drawSprite(sfRenderTexture* renderTexture, const sfSprite* object, const sfRenderStates* states);++foreign import ccall unsafe "sfRenderTexture_drawText"+    sfRenderTexture_drawText :: RenderTexture -> Text -> Ptr RenderStates -> IO ()++--CSFML_GRAPHICS_API void sfRenderTexture_drawText(sfRenderTexture* renderTexture, const sfText* object, const sfRenderStates* states);++foreign import ccall unsafe "sfRenderTexture_drawShape"+    sfRenderTexture_drawShape :: RenderTexture -> Shape -> Ptr RenderStates -> IO ()++--CSFML_GRAPHICS_API void sfRenderTexture_drawShape(sfRenderTexture* renderTexture, const sfShape* object, const sfRenderStates* states);++foreign import ccall unsafe "sfRenderTexture_drawCircleShape"+    sfRenderTexture_drawCircleShape :: RenderTexture -> CircleShape -> Ptr RenderStates -> IO ()++--CSFML_GRAPHICS_API void sfRenderTexture_drawCircleShape(sfRenderTexture* renderTexture, const sfCircleShape* object, const sfRenderStates* states);++foreign import ccall unsafe "sfRenderTexture_drawConvexShape"+    sfRenderTexture_drawConvexShape :: RenderTexture -> ConvexShape -> Ptr RenderStates -> IO ()++--CSFML_GRAPHICS_API void sfRenderTexture_drawConvexShape(sfRenderTexture* renderTexture, const sfConvexShape* object, const sfRenderStates* states);++foreign import ccall unsafe "sfRenderTexture_drawRectangleShape"+    sfRenderTexture_drawRectangleShape :: RenderTexture -> RectangleShape -> Ptr RenderStates -> IO ()++--CSFML_GRAPHICS_API void sfRenderTexture_drawRectangleShape(sfRenderTexture* renderTexture, const sfRectangleShape* object, const sfRenderStates* states);++foreign import ccall unsafe "sfRenderTexture_drawVertexArray"+    sfRenderTexture_drawVertexArray :: RenderTexture -> VertexArray -> Ptr RenderStates -> IO ()++--CSFML_GRAPHICS_API void sfRenderTexture_drawVertexArray(sfRenderTexture* renderTexture, const sfVertexArray* object, const sfRenderStates* states);++foreign import ccall unsafe "sfRenderTexture_drawPrimitives"+    sfRenderTexture_drawPrimitives :: RenderTexture -> Ptr Vertex -> CUInt -> CInt -> Ptr RenderStates -> IO ()++--CSFML_GRAPHICS_API void sfRenderTexture_drawPrimitives(sfRenderTexture* renderTexture, const sfVertex* vertices, unsigned int vertexCount, sfPrimitiveType type, const sfRenderStates* states);++foreign import ccall unsafe "sfRenderTexture_pushGLStates"+    sfRenderTexture_pushGLStates :: RenderTexture -> IO ()++--CSFML_GRAPHICS_API void sfRenderTexture_pushGLStates(sfRenderTexture* renderTexture);++foreign import ccall unsafe "sfRenderTexture_popGLStates"+    sfRenderTexture_popGLStates :: RenderTexture -> IO ()++--CSFML_GRAPHICS_API void sfRenderTexture_popGLStates(sfRenderTexture* renderTexture);++foreign import ccall unsafe "sfRenderTexture_resetGLStates"+    sfRenderTexture_resetGLStates :: RenderTexture -> IO ()++--CSFML_GRAPHICS_API void sfRenderTexture_resetGLStates(sfRenderTexture* renderTexture);+++-- | Get the target texture of a render texture.+getRenderTexture :: RenderTexture -> IO Texture+getRenderTexture = sfRenderTexture_getTexture++foreign import ccall unsafe "sfRenderTexture_getTexture"+    sfRenderTexture_getTexture :: RenderTexture -> IO Texture++--CSFML_GRAPHICS_API const sfTexture* sfRenderTexture_getTexture(const sfRenderTexture* renderTexture);+++instance SFSmoothTexture RenderTexture where+    +    {-# INLINABLE setSmooth #-}+    setSmooth tex val = sfRenderTexture_setSmooth tex (fromIntegral . fromEnum $ val)+    +    {-# INLINABLE isSmooth #-}+    isSmooth tex = fmap (toEnum . fromIntegral ) $ sfRenderTexture_isSmooth tex++foreign import ccall unsafe "sfRenderTexture_setSmooth"+    sfRenderTexture_setSmooth :: RenderTexture -> CInt -> IO ()++--CSFML_GRAPHICS_API void sfRenderTexture_setSmooth(sfRenderTexture* renderTexture, sfBool smooth);++foreign import ccall unsafe "sfRenderTexture_isSmooth"+    sfRenderTexture_isSmooth :: RenderTexture -> IO CInt++--CSFML_GRAPHICS_API sfBool sfRenderTexture_isSmooth(const sfRenderTexture* renderTexture);+
+ src/SFML/Graphics/RenderWindow.hs view
@@ -0,0 +1,556 @@+{-# LANGUAGE CPP, ForeignFunctionInterface #-}+module SFML.Graphics.RenderWindow+(+    createRenderWindow+,   renderWindowFromHandle+,   destroy+,   close+,   isWindowOpen+,   getWindowSettings+,   pollEvent+,   waitEvent+,   getWindowPosition+,   setWindowPosition+,   getWindowSize+,   setWindowSize+,   setWindowTitle+,   setWindowIcon+,   setWindowVisible+,   setMouseVisible+,   setVSync+,   setKeyRepeat+,   setWindowActive+,   display+,   setFramerateLimit+,   setJoystickThreshold+,   getSystemHandle+,   clearRenderWindow+,   setView+,   getView+,   getDefaultView+,   getViewport+,   mapPixelToCoords+,   drawSprite+,   drawText+,   drawShape+,   drawCircle+,   drawConvexShape+,   drawRectangle+,   drawVertexArray+,   drawPrimitives+,   drawPrimitives'+,   pushGLStates+,   popGLStates+,   resetGLStates+,   captureRenderWindow+,   getMousePosition+,   setMousePosition+)+where+++import SFML.Graphics.Color+import SFML.Graphics.Rect+import SFML.Graphics.Types+import SFML.Graphics.PrimitiveType+import SFML.Graphics.RenderStates+import SFML.Graphics.SFCoordSpace+import SFML.Graphics.SFRenderTarget+import SFML.Graphics.SFViewable+import SFML.Graphics.Vertex+import SFML.Window.ContextSettings+import SFML.Window.Event+import SFML.Window.SFWindow+import SFML.Window.VideoMode+import SFML.Window.WindowHandle+import SFML.Window.Window+import SFML.SFDisplayable+import SFML.SFResource+import SFML.System.Vector2++import Data.Bits ((.|.))+import Data.List (foldl')+import Foreign.C.String+import Foreign.C.Types+import Foreign.Marshal.Alloc (alloca)+import Foreign.Marshal.Array (withArray)+import Foreign.Marshal.Utils (with)+import Foreign.Ptr+import Foreign.Storable+++-- | Construct a new render window.+createRenderWindow+    :: VideoMode     -- ^ Video mode to use+    -> String        -- ^ Window title+    -> [WindowStyle] -- ^ Window style+    -> Maybe ContextSettings -- ^ Creation settings ('Nothing' to use default values)+    -> IO RenderWindow++createRenderWindow vm title styles ctx =+    withCAString title $ \ctitle ->+    with vm $ \ptrVM ->+    let style = foldl' (.|.) 0 $ fmap fromEnum styles+    in case ctx of+        Nothing -> sfRenderWindow_create_helper ptrVM ctitle (fromIntegral . fromEnum $ style) nullPtr+        Just c  -> with c $ sfRenderWindow_create_helper ptrVM ctitle (fromIntegral . fromEnum $ style)++foreign import ccall unsafe "sfRenderWindow_create_helper"+    sfRenderWindow_create_helper :: Ptr VideoMode -> CString -> CUInt -> Ptr ContextSettings -> IO RenderWindow++--CSFML_GRAPHICS_API sfRenderWindow* sfRenderWindow_create(sfVideoMode mode, const char* title, sfUint32 style, const sfContextSettings* settings);+++-- | Construct a render window from an existing control.+renderWindowFromHandle+    :: WindowHandle -- ^ Platform-specific handle of the control+    -> Maybe ContextSettings -- ^ Creation settings ('Nothing' to use default values)+    -> IO RenderWindow++renderWindowFromHandle wm Nothing  = sfRenderWindow_createFromHandle wm nullPtr+renderWindowHandleFrom wm (Just c) = with c $ sfRenderWindow_createFromHandle wm++foreign import ccall unsafe "sfRenderWindow_createFromHandle"+    sfRenderWindow_createFromHandle :: WindowHandle -> Ptr ContextSettings -> IO RenderWindow++--CSFML_GRAPHICS_API sfRenderWindow* sfRenderWindow_createFromHandle(sfWindowHandle handle, const sfContextSettings* settings);+++instance SFResource RenderWindow where+    +    {-# INLINABLE destroy #-}+    destroy = sfRenderWindow_destroy++foreign import ccall unsafe "sfRenderWindow_destroy"+    sfRenderWindow_destroy :: RenderWindow -> IO ()++--CSFML_GRAPHICS_API void sfRenderWindow_destroy(sfRenderWindow* renderWindow);+++instance SFDisplayable RenderWindow where+    +    {-# INLINABLE display #-}+    display = sfRenderWindow_display+++instance SFWindow RenderWindow where+    +    {-# INLINABLE close #-}    +    close = sfRenderWindow_close+    +    {-# INLINABLE isWindowOpen #-}+    isWindowOpen = fmap (/=0) . sfRenderWindow_isOpen+    +    {-# INLINABLE getWindowSettings #-}+    getWindowSettings wnd = alloca $ \ptr -> sfRenderWindow_getSettings_helper wnd ptr >> peek ptr+    +    {-# INLINABLE pollEvent #-}+    pollEvent wnd =+        alloca $ \ptr -> do+        result <- sfRenderWindow_pollEvent wnd ptr+        case result of+            0 -> return Nothing+            _ -> peek ptr >>= return . Just+    +    {-# INLINABLE waitEvent #-}+    waitEvent wnd =+        alloca $ \ptr -> do+        result <- sfRenderWindow_waitEvent wnd ptr+        case result of+            0 -> return Nothing+            _ -> peek ptr >>= return . Just+    +    {-# INLINABLE getWindowPosition #-}+    getWindowPosition wnd = alloca $ \ptr -> sfRenderWindow_getPosition_helper wnd ptr >> peek ptr+    +    {-# INLINABLE setWindowPosition #-}+    setWindowPosition wnd pos = with pos $ sfRenderWindow_setPosition_helper wnd+    +    {-# INLINABLE getWindowSize #-}+    getWindowSize wnd = alloca $ \ptr -> sfRenderWindow_getSize_helper wnd ptr >> peek ptr+    +    {-# INLINABLE setWindowSize #-}+    setWindowSize wnd size = with size $ sfRenderWindow_setSize_helper wnd+    +    {-# INLINABLE setWindowTitle #-}+    setWindowTitle wnd title = withCAString title $ sfRenderWindow_setTitle wnd+    +    {-# INLINABLE setWindowIcon #-}+    setWindowIcon wnd w h pixels =+        sfRenderWindow_setIcon wnd (fromIntegral w) (fromIntegral h) pixels+    +    {-# INLINABLE setWindowVisible #-}+    setWindowVisible wnd val = sfRenderWindow_setVisible wnd (fromIntegral . fromEnum $ val)+    +    {-# INLINABLE setMouseVisible #-}+    setMouseVisible wnd val = sfRenderWindow_setMouseCursorVisible wnd (fromIntegral . fromEnum $ val)+    +    {-# INLINABLE setVSync #-}+    setVSync wnd val = sfRenderWindow_setVerticalSyncEnabled wnd (fromIntegral . fromEnum $ val)+    +    {-# INLINABLE setKeyRepeat #-}+    setKeyRepeat wnd val = sfRenderWindow_setKeyRepeatEnabled wnd (fromIntegral . fromEnum $ val)+    +    {-# INLINABLE setWindowActive #-}+    setWindowActive wnd val =+        fmap (toEnum . fromIntegral) $ sfRenderWindow_setActive wnd (fromIntegral . fromEnum $ val)+    +    {-# INLINABLE setFramerateLimit #-}+    setFramerateLimit wnd fps = sfRenderWindow_setFramerateLimit wnd (fromIntegral fps)+    +    {-# INLINABLE setJoystickThreshold #-}+    setJoystickThreshold w t = sfRenderWindow_setJoystickThreshold w (realToFrac t)+    +    {-# INLINABLE getSystemHandle #-}+    getSystemHandle = sfRenderWindow_getSystemHandle+    +    {-# INLINABLE getMousePosition #-}+    getMousePosition Nothing =+        alloca $ \ptr -> sfMouse_getPositionRenderWindow_helper (RenderWindow nullPtr) ptr >> peek ptr+    +    getMousePosition (Just wnd) =+        alloca $ \ptr -> sfMouse_getPositionRenderWindow_helper wnd ptr >> peek ptr+    +    {-# INLINABLE setMousePosition #-}+    setMousePosition pos Nothing =+        with pos $ \ptr -> sfMouse_setPositionRenderWindow_helper ptr (RenderWindow nullPtr)+    +    setMousePosition pos (Just wnd) =+        with pos $ \ptr -> sfMouse_setPositionRenderWindow_helper ptr wnd+++foreign import ccall unsafe "sfRenderWindow_close"+    sfRenderWindow_close :: RenderWindow -> IO ()++--CSFML_GRAPHICS_API void sfRenderWindow_close(sfRenderWindow* renderWindow);++foreign import ccall unsafe "sfRenderWindow_isOpen"+    sfRenderWindow_isOpen :: RenderWindow -> IO CInt++--CSFML_GRAPHICS_API sfBool sfRenderWindow_isOpen(const sfRenderWindow* renderWindow);+++foreign import ccall unsafe "sfRenderWindow_getSettings_helper"+    sfRenderWindow_getSettings_helper :: RenderWindow -> Ptr ContextSettings -> IO ()++--CSFML_GRAPHICS_API sfContextSettings sfRenderWindow_getSettings(const sfRenderWindow* renderWindow);+++foreign import ccall unsafe "sfRenderWindow_pollEvent"+    sfRenderWindow_pollEvent :: RenderWindow -> Ptr SFEvent -> IO CInt++-- \return sfTrue if an event was returned, sfFalse if event queue was empty++--CSFML_GRAPHICS_API sfBool sfRenderWindow_pollEvent(sfRenderWindow* renderWindow, sfEvent* event);+++foreign import ccall unsafe "sfRenderWindow_waitEvent"+    sfRenderWindow_waitEvent :: RenderWindow -> Ptr SFEvent -> IO CInt++-- \return sfFalse if an error occured++--CSFML_GRAPHICS_API sfBool sfRenderWindow_waitEvent(sfRenderWindow* renderWindow, sfEvent* event);+++foreign import ccall unsafe "sfRenderWindow_getPosition_helper"+    sfRenderWindow_getPosition_helper :: RenderWindow -> Ptr Vec2i -> IO ()++--CSFML_GRAPHICS_API sfVector2i sfRenderWindow_getPosition(const sfRenderWindow* renderWindow);+++foreign import ccall unsafe "sfRenderWindow_setPosition_helper"+    sfRenderWindow_setPosition_helper :: RenderWindow -> Ptr Vec2i -> IO ()++--CSFML_GRAPHICS_API void sfRenderWindow_setPosition(sfRenderWindow* renderWindow, sfVector2i position);+++foreign import ccall unsafe "sfRenderWindow_getSize_helper"+    sfRenderWindow_getSize_helper :: RenderWindow -> Ptr Vec2u -> IO ()++--CSFML_GRAPHICS_API sfVector2u sfRenderWindow_getSize(const sfRenderWindow* renderWindow);+++foreign import ccall unsafe "sfRenderWindow_setSize_helper"+    sfRenderWindow_setSize_helper :: RenderWindow -> Ptr Vec2u -> IO ()++--CSFML_GRAPHICS_API void sfRenderWindow_setSize(sfRenderWindow* renderWindow, sfVector2u size);+++foreign import ccall unsafe "sfRenderWindow_setTitle"+    sfRenderWindow_setTitle :: RenderWindow -> CString -> IO ()++--CSFML_GRAPHICS_API void sfRenderWindow_setTitle(sfRenderWindow* renderWindow, const char* title);+++foreign import ccall unsafe "sfRenderWindow_setIcon"+    sfRenderWindow_setIcon :: RenderWindow -> CUInt -> CUInt -> Ptr a -> IO ()++--CSFML_GRAPHICS_API void sfRenderWindow_setIcon(sfRenderWindow* renderWindow, unsigned int width, unsigned int height, const sfUint8* pixels);+++foreign import ccall unsafe "sfRenderWindow_setVisible"+    sfRenderWindow_setVisible :: RenderWindow -> CInt -> IO ()++--CSFML_GRAPHICS_API void sfRenderWindow_setVisible(sfRenderWindow* renderWindow, sfBool visible);+++foreign import ccall unsafe "sfRenderWindow_setMouseCursorVisible"+    sfRenderWindow_setMouseCursorVisible :: RenderWindow -> CInt -> IO ()++--CSFML_GRAPHICS_API void sfRenderWindow_setMouseCursorVisible(sfRenderWindow* renderWindow, sfBool show);+++foreign import ccall unsafe "sfRenderWindow_setVerticalSyncEnabled"+    sfRenderWindow_setVerticalSyncEnabled :: RenderWindow -> CInt -> IO ()++--CSFML_GRAPHICS_API void sfRenderWindow_setVerticalSyncEnabled(sfRenderWindow* renderWindow, sfBool enabled);+++foreign import ccall unsafe "sfRenderWindow_setKeyRepeatEnabled"+    sfRenderWindow_setKeyRepeatEnabled :: RenderWindow -> CInt -> IO ()++--CSFML_GRAPHICS_API void sfRenderWindow_setKeyRepeatEnabled(sfRenderWindow* renderWindow, sfBool enabled);+    ++foreign import ccall unsafe "sfRenderWindow_setActive"+    sfRenderWindow_setActive :: RenderWindow -> CInt -> IO CInt++-- \return True if operation was successful, false otherwise++--CSFML_GRAPHICS_API sfBool sfRenderWindow_setActive(sfRenderWindow* renderWindow, sfBool active);+++foreign import ccall unsafe "sfRenderWindow_display"+    sfRenderWindow_display :: RenderWindow -> IO ()++--CSFML_GRAPHICS_API void sfRenderWindow_display(sfRenderWindow* renderWindow);+++foreign import ccall unsafe "sfRenderWindow_setFramerateLimit"+    sfRenderWindow_setFramerateLimit :: RenderWindow -> CInt -> IO ()++--CSFML_GRAPHICS_API void sfRenderWindow_setFramerateLimit(sfRenderWindow* renderWindow, unsigned int limit);+    ++foreign import ccall unsafe "sfRenderWindow_setJoystickThreshold"+    sfRenderWindow_setJoystickThreshold :: RenderWindow -> CFloat -> IO ()++--CSFML_GRAPHICS_API void sfRenderWindow_setJoystickThreshold(sfRenderWindow* renderWindow, float threshold);+++foreign import ccall unsafe "sfRenderWindow_getSystemHandle"+    sfRenderWindow_getSystemHandle :: RenderWindow -> IO WindowHandle++--CSFML_GRAPHICS_API sfWindowHandle sfRenderWindow_getSystemHandle(const sfRenderWindow* renderWindow);+++foreign import ccall unsafe "sfMouse_getPositionRenderWindow_helper"+    sfMouse_getPositionRenderWindow_helper :: RenderWindow -> Ptr Vec2i -> IO ()++--CSFML_GRAPHICS_API sfVector2i sfMouse_getPositionRenderWindow(const sfRenderWindow* relativeTo);+++foreign import ccall unsafe "sfMouse_setPositionRenderWindow_helper"+    sfMouse_setPositionRenderWindow_helper :: Ptr Vec2i -> RenderWindow -> IO ()++--CSFML_GRAPHICS_API void sfMouse_setPositionRenderWindow(sfVector2i position, const sfRenderWindow* relativeTo);+++-- | Clear a render window with the given color.+clearRenderWindow+    :: RenderWindow -- ^ Render window object+    -> Color -- ^ Fill color+    -> IO ()++clearRenderWindow wnd color = with color $ sfRenderWindow_clear_helper wnd++foreign import ccall unsafe "sfRenderWindow_clear_helper"+    sfRenderWindow_clear_helper :: RenderWindow -> Ptr Color -> IO ()++--CSFML_GRAPHICS_API void sfRenderWindow_clear(sfRenderWindow* renderWindow, sfColor color);+++instance SFViewable RenderWindow where+    +    {-# INLINABLE setView #-}+    setView = sfRenderWindow_setView++    {-# INLINABLE getView #-}+    getView = sfRenderWindow_getView+    +    {-# INLINABLE getDefaultView #-}+    getDefaultView = sfRenderWindow_getDefaultView+    +    {-# INLINABLE getViewport #-}+    getViewport wnd view = alloca $ \ptr -> sfRenderWindow_getViewport_helper wnd view ptr >> peek ptr+++foreign import ccall unsafe "sfRenderWindow_setView"+    sfRenderWindow_setView :: RenderWindow -> View -> IO ()++--CSFML_GRAPHICS_API void sfRenderWindow_setView(sfRenderWindow* renderWindow, const sfView* view);++foreign import ccall unsafe "sfRenderWindow_getView"+    sfRenderWindow_getView :: RenderWindow -> IO View++--CSFML_GRAPHICS_API const sfView* sfRenderWindow_getView(const sfRenderWindow* renderWindow);++foreign import ccall unsafe "sfRenderWindow_getDefaultView"+    sfRenderWindow_getDefaultView :: RenderWindow -> IO View++--CSFML_GRAPHICS_API const sfView* sfRenderWindow_getDefaultView(const sfRenderWindow* renderWindow);++foreign import ccall unsafe "sfRenderWindow_getViewport_helper"+    sfRenderWindow_getViewport_helper :: RenderWindow -> View -> Ptr IntRect -> IO ()++--CSFML_GRAPHICS_API sfIntRect sfRenderWindow_getViewport(const sfRenderWindow* renderWindow, const sfView* view);+++instance SFCoordSpace RenderWindow where+    +    {-# INLINABLE mapPixelToCoords #-}+    mapPixelToCoords wnd p view =+        alloca $ \ptr ->+        with p $ \posPtr -> case view of+            Nothing -> sfRenderWindow_mapPixelToCoords_helper wnd posPtr (View nullPtr) ptr >> peek ptr+            Just v  -> sfRenderWindow_mapPixelToCoords_helper wnd posPtr v ptr >> peek ptr++foreign import ccall unsafe "sfRenderWindow_mapPixelToCoords_helper"+    sfRenderWindow_mapPixelToCoords_helper :: RenderWindow -> Ptr Vec2i -> View -> Ptr Vec2f -> IO ()++-- \return The converted point, in "world" units++--CSFML_GRAPHICS_API sfVector2f sfRenderWindow_mapPixelToCoords(const sfRenderWindow* renderWindow, sfVector2i point, const sfView* targetView);+++instance SFRenderTarget RenderWindow where+    +    {-# INLINABLE drawSprite #-}+    drawSprite wnd sprite Nothing   = sfRenderWindow_drawSprite wnd sprite nullPtr+    drawSprite wnd sprite (Just rs) = with rs $ sfRenderWindow_drawSprite wnd sprite+    +    {-# INLINABLE drawText #-}+    drawText wnd text Nothing   = sfRenderWindow_drawText wnd text nullPtr+    drawText wnd text (Just rs) = with rs $ sfRenderWindow_drawText wnd text+    +    {-# INLINABLE drawShape #-}+    drawShape wnd shape Nothing   = sfRenderWindow_drawShape wnd shape nullPtr+    drawShape wnd shape (Just rs) = with rs $ sfRenderWindow_drawShape wnd shape+    +    {-# INLINABLE drawCircle #-}+    drawCircle wnd circle Nothing   = sfRenderWindow_drawCircleShape wnd circle nullPtr+    drawCircle wnd circle (Just rs) = with rs $ sfRenderWindow_drawCircleShape wnd circle+    +    {-# INLINABLE drawConvexShape #-}+    drawConvexShape wnd shape Nothing   = sfRenderWindow_drawConvexShape wnd shape nullPtr+    drawConvexShape wnd shape (Just rs) = with rs $ sfRenderWindow_drawConvexShape wnd shape+    +    {-# INLINABLE drawRectangle #-}+    drawRectangle wnd rect Nothing   = sfRenderWindow_drawRectangleShape wnd rect nullPtr+    drawRectangle wnd rect (Just rs) = with rs $ sfRenderWindow_drawRectangleShape wnd rect+    +    {-# INLINABLE drawVertexArray #-}+    drawVertexArray wnd va Nothing   = sfRenderWindow_drawVertexArray wnd va nullPtr+    drawVertexArray wnd va (Just rs) = with rs $ sfRenderWindow_drawVertexArray wnd va+    +    {-# INLINABLE drawPrimitives #-}+    drawPrimitives wnd verts prim Nothing =+        let n = length verts+        in withArray verts $ \ptr ->+            sfRenderWindow_drawPrimitives wnd ptr (fromIntegral n) (fromIntegral . fromEnum $ prim) nullPtr+    +    drawPrimitives wnd verts prim (Just r) =+        let n = length verts+        in withArray verts $ \ptr ->+            with r $ sfRenderWindow_drawPrimitives wnd ptr (fromIntegral n) (fromIntegral . fromEnum $ prim)+    +    drawPrimitives' wnd verts n prim Nothing =+        sfRenderWindow_drawPrimitives wnd verts (fromIntegral n) (fromIntegral . fromEnum $ prim) nullPtr+    +    drawPrimitives' wnd verts n prim (Just r) =+        with r $ sfRenderWindow_drawPrimitives wnd verts (fromIntegral n) (fromIntegral . fromEnum $ prim)+    +    {-# INLINABLE pushGLStates #-}+    pushGLStates = sfRenderWindow_pushGLStates+    +    {-# INLINABLE popGLStates #-}+    popGLStates = sfRenderWindow_popGLStates+    +    {-# INLINABLE resetGLStates #-}+    resetGLStates = sfRenderWindow_resetGLStates+++foreign import ccall unsafe "sfRenderWindow_drawSprite"+    sfRenderWindow_drawSprite :: RenderWindow -> Sprite -> Ptr RenderStates -> IO ()++--CSFML_GRAPHICS_API void sfRenderWindow_drawSprite(sfRenderWindow* renderWindow, const sfSprite* object, const sfRenderStates* states);++foreign import ccall unsafe "sfRenderWindow_drawText"+    sfRenderWindow_drawText :: RenderWindow -> Text -> Ptr RenderStates -> IO ()++--CSFML_GRAPHICS_API void sfRenderWindow_drawText(sfRenderWindow* renderWindow, const sfText* object, const sfRenderStates* states);++foreign import ccall unsafe "sfRenderWindow_drawShape"+    sfRenderWindow_drawShape :: RenderWindow -> Shape -> Ptr RenderStates -> IO ()++--CSFML_GRAPHICS_API void sfRenderWindow_drawShape(sfRenderWindow* renderWindow, const sfShape* object, const sfRenderStates* states);++foreign import ccall unsafe "sfRenderWindow_drawCircleShape"+    sfRenderWindow_drawCircleShape :: RenderWindow -> CircleShape -> Ptr RenderStates -> IO ()++--CSFML_GRAPHICS_API void sfRenderWindow_drawCircleShape(sfRenderWindow* renderWindow, const sfCircleShape* object, const sfRenderStates* states);++foreign import ccall unsafe "sfRenderWindow_drawConvexShape"+    sfRenderWindow_drawConvexShape :: RenderWindow -> ConvexShape -> Ptr RenderStates -> IO ()++--CSFML_GRAPHICS_API void sfRenderWindow_drawConvexShape(sfRenderWindow* renderWindow, const sfConvexShape* object, const sfRenderStates* states);++foreign import ccall unsafe "sfRenderWindow_drawRectangleShape"+    sfRenderWindow_drawRectangleShape :: RenderWindow -> RectangleShape -> Ptr RenderStates -> IO ()++--CSFML_GRAPHICS_API void sfRenderWindow_drawRectangleShape(sfRenderWindow* renderWindow, const sfRectangleShape* object, const sfRenderStates* states);++foreign import ccall unsafe "sfRenderWindow_drawVertexArray"+    sfRenderWindow_drawVertexArray :: RenderWindow -> VertexArray -> Ptr RenderStates -> IO ()++--CSFML_GRAPHICS_API void sfRenderWindow_drawVertexArray(sfRenderWindow* renderWindow, const sfVertexArray* object, const sfRenderStates* states);++foreign import ccall unsafe "sfRenderWindow_drawPrimitives"+    sfRenderWindow_drawPrimitives :: RenderWindow -> Ptr Vertex -> CUInt -> CInt -> Ptr RenderStates -> IO ()++--CSFML_GRAPHICS_API void sfRenderWindow_drawPrimitives(sfRenderWindow* renderWindow, const sfVertex* vertices, unsigned int vertexCount, sfPrimitiveType type, const sfRenderStates* states);++foreign import ccall unsafe "sfRenderWindow_pushGLStates"+    sfRenderWindow_pushGLStates :: RenderWindow -> IO ()++--CSFML_GRAPHICS_API void sfRenderWindow_pushGLStates(sfRenderWindow* renderWindow);++foreign import ccall unsafe "sfRenderWindow_popGLStates"+    sfRenderWindow_popGLStates :: RenderWindow -> IO ()++--CSFML_GRAPHICS_API void sfRenderWindow_popGLStates(sfRenderWindow* renderWindow);++foreign import ccall unsafe "sfRenderWindow_resetGLStates"+    sfRenderWindow_resetGLStates :: RenderWindow -> IO ()++--CSFML_GRAPHICS_API void sfRenderWindow_resetGLStates(sfRenderWindow* renderWindow);+++-- | Copy the current contents of a render window to an image.+--+-- This is a slow operation, whose main purpose is to make+-- screenshots of the application. If you want to update an+-- image with the contents of the window and then use it for+-- drawing, you should rather use a 'Texture' and its+-- update(sfWindow*) function.+--+-- You can also draw things directly to a texture with the+-- sfRenderWindow class.+captureRenderWindow :: RenderWindow -> IO Image+captureRenderWindow = sfRenderWindow_capture++foreign import ccall unsafe "sfRenderWindow_capture"+    sfRenderWindow_capture :: RenderWindow -> IO Image++--CSFML_GRAPHICS_API sfImage* sfRenderWindow_capture(const sfRenderWindow* renderWindow);+
+ src/SFML/Graphics/SFBindable.hs view
@@ -0,0 +1,10 @@+module SFML.Graphics.SFBindable+where++class SFBindable a where+      -- | Bind the resource for rendering (activate it).+      --+      -- This function is not part of the graphics API, it mustn't be+      -- used when drawing SFML entities. It must be used only if you+      -- mix sfShader with OpenGL code.+      bind :: a -> IO ()
+ src/SFML/Graphics/SFBounded.hs view
@@ -0,0 +1,26 @@+module SFML.Graphics.SFBounded+where+++import SFML.Graphics.Rect+++class SFBounded a where++    -- | Get the local bounding rectangle of a boundable.+    --+    -- The returned rectangle is in local coordinates, which means+    -- that it ignores the transformations (translation, rotation,+    -- scale, ...) that are applied to the entity.+    -- In other words, this function returns the bounds of the+    -- entity in the entity's coordinate system.+    getLocalBounds :: a -> IO FloatRect++    -- | Get the global bounding rectangle of a shape.+    --+    -- The returned rectangle is in global coordinates, which means+    -- that it takes in account the transformations (translation,+    -- rotation, scale, ...) that are applied to the entity.+    -- In other words, this function returns the bounds of the+    -- sprite in the global 2D world's coordinate system.+    getGlobalBounds :: a -> IO FloatRect
+ src/SFML/Graphics/SFCoordSpace.hs view
@@ -0,0 +1,32 @@+module SFML.Graphics.SFCoordSpace+where+++import SFML.Graphics.Types+import SFML.System.Vector2+++class SFCoordSpace a where+    +    -- | Convert a point to world coordinates+    --+    -- This function finds the 2D position that matches the+    -- given pixel of the coord space. In other words, it does+    -- the inverse of what the graphics card does, to find the+    -- initial position of a rendered pixel.+    --+    -- Initially, both coordinate systems (world units and target pixels)+    -- match perfectly. But if you define a custom view or resize your+    -- coord space, this assertion is not true anymore, ie. a point+    -- located at (10, 50) in your coord space may map to the point+    -- (150, 75) in your 2D world -- if the view is translated by (140, 25).+    --+    -- This version uses a custom view for calculations, see the other+    -- overload of the function if you want to use the current view of the+    -- render-texture.+    mapPixelToCoords+        :: a+        -> Vec2i -- ^ Pixel to convert+        -> Maybe View -- ^ The view to use for converting the point+        -> IO Vec2f+
+ src/SFML/Graphics/SFRenderTarget.hs view
@@ -0,0 +1,114 @@+module SFML.Graphics.SFRenderTarget+where+++import SFML.Graphics.PrimitiveType+import SFML.Graphics.RenderStates+import SFML.Graphics.Types+import SFML.Graphics.Vertex++import Foreign.Ptr (Ptr)+++class SFRenderTarget a where+    +    -- | Draw a sprite to the render-target.+    drawSprite+        :: a+        -> Sprite -- ^ Sprite to draw+        -> Maybe RenderStates -- ^ Render states to use for drawing ('Nothing' to use the default states)+        -> IO ()+    +    -- | Draw text to the render-target.+    drawText+        :: a+        -> Text -- ^ Text to draw+        -> Maybe RenderStates -- ^ Render states to use for drawing ('Nothing' to use the default states)+        -> IO ()+    +    -- | Draw a sprite to the render-target.+    drawShape+        :: a+        -> Shape -- ^ Shape to draw+        -> Maybe RenderStates -- ^ Render states to use for drawing ('Nothing' to use the default states)+        -> IO ()+    +    -- | Draw a sprite to the render-target.+    drawCircle+        :: a+        -> CircleShape -- ^ CircleShape to draw+        -> Maybe RenderStates -- ^ Render states to use for drawing ('Nothing' to use the default states)+        -> IO ()+    +    -- | Draw a sprite to the render-target.+    drawConvexShape+        :: a+        -> ConvexShape -- ^ ConvexShape to draw+        -> Maybe RenderStates -- ^ Render states to use for drawing ('Nothing' to use the default states)+        -> IO ()+        +    -- | Draw a sprite to the render-target.+    drawRectangle+        :: a+        -> RectangleShape -- ^ RectangleShape to draw+        -> Maybe RenderStates -- ^ Render states to use for drawing ('Nothing' to use the default states)+        -> IO ()+    +    -- | Draw a sprite to the render-target.+    drawVertexArray+        :: a+        -> VertexArray -- ^ VertexArray to draw+        -> Maybe RenderStates -- ^ Render states to use for drawing ('Nothing' to use the default states)+        -> IO ()+    +    -- | Draw primitives defined by an array of vertices to a render texture.+    drawPrimitives+        :: a+        -> [Vertex] -- ^ Vertices to render+        -> PrimitiveType -- ^ Type of primitives to draw+        -> Maybe RenderStates -- ^ Render states to use for drawing ('Nothing' to use the default states)+        -> IO ()+    +    drawPrimitives'+        :: a+        -> Ptr Vertex -- ^ Pointer to the vertices+        -> Int -- ^ Number of vertices in the array+        -> PrimitiveType -- ^ Type of primitives to draw+        -> Maybe RenderStates -- ^ Render states to use for drawing ('Nothing' to use the default states)+        -> IO ()+    +    -- | Save the current OpenGL render states and matrices.+    --+    -- This function can be used when you mix SFML drawing+    -- and direct OpenGL rendering. Combined with popGLStates,+    -- it ensures that:+    --+    -- * SFML's internal states are not messed up by your OpenGL code+    --+    -- * Your OpenGL states are not modified by a call to a SFML function+    --+    -- Note that this function is quite expensive: it saves all the+    -- possible OpenGL states and matrices, even the ones you+    -- don't care about. Therefore it should be used wisely.+    -- It is provided for convenience, but the best results will+    -- be achieved if you handle OpenGL states yourself (because+    -- you know which states have really changed, and need to be+    -- saved and restored). Take a look at the resetGLStates+    -- function if you do so.+    pushGLStates :: a -> IO ()+    +    -- | Restore the previously saved OpenGL render states and matrices.+    --+    -- See the description of pushGLStates to get a detailed+    -- description of these functions.+    popGLStates :: a -> IO ()+    +    -- | Reset the internal OpenGL states so that the target is ready for drawing+    --+    -- This function can be used when you mix SFML drawing+    -- and direct OpenGL rendering, if you choose not to use+    -- 'pushGLStates' or 'popGLStates'. It makes sure that all OpenGL+    -- states needed by SFML are set, so that subsequent draw+    -- calls will work as expected.+    resetGLStates :: a -> IO ()+
+ src/SFML/Graphics/SFShape.hs view
@@ -0,0 +1,60 @@+module SFML.Graphics.SFShape+where+++import SFML.Graphics.Color+import SFML.System.Vector2+++class SFShape a where+    +    -- | Set the fill color of a shape.+    --+    -- This color is modulated (multiplied) with the shape's+    -- texture if any. It can be used to colorize the shape,+    -- or change its global opacity.+    --+    -- You can use 'Transparent' to make the inside of+    -- the shape transparent, and have the outline alone.+    --+    -- By default, the shape's fill color is opaque white.+    setFillColor :: a -> Color -> IO ()+    +    -- | Set the outline color of a shape.+    --+    -- You can use 'Transparent' to disable the outline.+    --+    -- By default, the shape's outline color is opaque white.+    setOutlineColor :: a -> Color -> IO ()+    +    -- | Set the thickness of a shape's outline.+    --+    -- This number cannot be negative. Using zero disables+    -- the outline.+    --+    -- By default, the outline thickness is 0.+    setOutlineThickness+        :: a+        -> Float -- ^ New outline thickness+        -> IO ()+    +    -- | Get the fill color of a shape.+    getFillColor :: a -> IO Color+    +    -- | Get the outline color of a shape.+    getOutlineColor :: a -> IO Color+    +    -- | Get the outline thickness of a shape.+    getOutlineThickness :: a -> IO Float+    +    -- | Get the total number of points of a shape.+    getPointCount :: a -> IO Int++    -- | Get the ith point of a shape.+    --+    -- The result is undefined if index is out of the valid range.+    getPoint+        :: a+        -> Int -- ^ Index of the point to get, in range [0 .. 'getPointCount' - 1]+        -> IO Vec2f+
+ src/SFML/Graphics/SFShapeResizable.hs view
@@ -0,0 +1,12 @@+module SFML.Graphics.SFShapeResizable+where+++class SFShapeResizable a where+    +    -- | Set the number of points of a resizable shape.+    setPointCount+        :: a+        -> Int -- ^ New number of points of the shape+        -> IO ()+
+ src/SFML/Graphics/SFSmoothTexture.hs view
@@ -0,0 +1,15 @@+module SFML.Graphics.SFSmoothTexture+where+++import SFML.Graphics.Types+++class SFSmoothTexture a where+    +    -- | Enable or disable the smooth filter on a texture.+    setSmooth :: a -> Bool -> IO ()+    +    -- | Tell whether the smooth filter is enabled or not for a texture.+    isSmooth :: a -> IO Bool+
+ src/SFML/Graphics/SFTexturable.hs view
@@ -0,0 +1,52 @@+module SFML.Graphics.SFTexturable+where+++import SFML.Graphics.Color+import SFML.Graphics.Rect+import SFML.Graphics.Types+++class SFTexturable a where+    +    -- | Change the source texture of a Texturable.+    --+    -- The texture argument refers to a texture that must+    -- exist as long as the texturable uses it. Indeed, the texturable+    -- doesn't store its own copy of the texture, but rather keeps+    -- a pointer to the one that you passed to this function.+    --+    -- If the source texture is destroyed and the texturable tries to+    -- use it, the behaviour is undefined.+    --+    -- If resetRect is 'True', the TextureRect property of+    -- the texturable is automatically adjusted to the size of the new+    -- texture. If it is false, the texture rect is left unchanged.+    setTexture+        :: a+        -> Texture -- ^ New texture+        -> Bool    -- ^ Should the texture rect be reset to the size of the new texture?+        -> IO ()++    -- | Set the sub-rectangle of the texture that a texturable will display.+    --+    -- The texture rect is useful when you don't want to display+    -- the whole texture, but rather a part of it.+    --+    -- By default, the texture rect covers the entire texture.+    setTextureRect+        :: a+        -> IntRect -- ^ Rectangle defining the region of the texture to display+        -> IO ()+    +    -- | Get the source texture of a texturable.+    --+    -- If the texturable has no source texture, 'Nothing' is returned.+    --+    -- The returned pointer is const, which means that you can't+    -- modify the texture when you retrieve it with this function.+    getTexture :: a -> IO (Maybe Texture)+    +    -- | Get the sub-rectangle of the texture displayed by a texturable.+    getTextureRect :: a -> IO IntRect+
+ src/SFML/Graphics/SFViewable.hs view
@@ -0,0 +1,22 @@+module SFML.Graphics.SFViewable+where+++import SFML.Graphics.Rect+import SFML.Graphics.Types+++class SFViewable a where+    +    -- | Change the target's current active view.+    setView :: a -> View -> IO ()+    +    -- | Get the target's current active view.+    getView :: a -> IO View+    +    -- | Get the target's default view.+    getDefaultView :: a -> IO View+    +    -- | Get the viewport of a view applied to this target, expressed in pixels in the current target.+    getViewport :: a -> View -> IO IntRect+
+ src/SFML/Graphics/Shader.hs view
@@ -0,0 +1,388 @@+{-# LANGUAGE DeriveDataTypeable #-}+module SFML.Graphics.Shader+(+    module SFML.Utils+,   ShaderException(..)+,   nullShader+,   shaderFromFile+,   shaderFromMemory+,   shaderFromStream+,   destroy+,   setFloatParameter+,   setFloat2Parameter+,   setFloat3Parameter+,   setFloat4Parameter+,   setVector2Parameter+,   setVector3Parameter+,   setColorParameter+,   setTransformParameter+,   setTextureParameter+,   setCurrentTextureParameter+,   bind+,   isShaderAvailable+)+where+++import SFML.Graphics.Color+import SFML.Graphics.Transform+import SFML.Graphics.Types+import SFML.Graphics.SFBindable+import SFML.SFResource+import SFML.System.InputStream+import SFML.System.Vector2+import SFML.System.Vector3+import SFML.Utils++import Control.Exception+import Data.Typeable+import Foreign.C.Types+import Foreign.C.String+import Foreign.Marshal.Utils (with)+import Foreign.Ptr+++checkNull :: Shader -> Maybe Shader+checkNull shader@(Shader ptr) = if ptr == nullPtr then Nothing else Just shader+++data ShaderException = ShaderException String deriving (Show, Typeable)++instance Exception ShaderException+++exf :: Show a => Maybe a -> Maybe a -> ShaderException+exf vs fs = ShaderException $ "Failed loading shader program from files " ++ show vs ++ ", " ++ show fs++exs :: Show a => Maybe a -> Maybe a -> ShaderException+exs vs fs = ShaderException $ "Failed loading shader program from sources " ++ show vs ++ ", " ++ show fs++exi :: Show a => Maybe a -> Maybe a -> ShaderException+exi vs fs = ShaderException $ "Failed loading shader program from input streams " ++ show vs ++ ", " ++ show fs++nullstr = Nothing :: Maybe String+nullis  = Nothing :: Maybe InputStream+++-- | A null shader.+nullShader = Shader nullPtr+++-- | Load both the vertex and fragment shaders from files.+--+-- This function can load both the vertex and the fragment+-- shaders, or only one of them: pass 'Nothing' if you don't want to load+-- either the vertex shader or the fragment shader.+--+-- The sources must be text files containing valid shaders+-- in GLSL language. GLSL is a C-like language dedicated to+-- OpenGL shaders; you'll probably need to read a good documentation+-- for it before writing your own shaders.+shaderFromFile+    :: Maybe FilePath -- ^ Path of the vertex shader file to load, or 'Nothing' to skip this shader+    -> Maybe FilePath -- ^ Path of the fragment shader file to load, or 'Nothing' to skip this shader+    -> IO (Either ShaderException Shader)++shaderFromFile Nothing Nothing = fmap (tagErr (exf nullstr nullstr) . checkNull) $ sfShader_createFromFile nullPtr nullPtr++shaderFromFile Nothing fs@(Just frag) =+    fmap (tagErr (exf Nothing fs) . checkNull) . withCString frag $ sfShader_createFromFile nullPtr++shaderFromFile vs@(Just vert) Nothing =+    fmap (tagErr (exf vs Nothing) . checkNull) . withCString vert $ flip sfShader_createFromFile nullPtr++shaderFromFile vs@(Just vert) fs@(Just frag) =+    fmap (tagErr (exf vs fs) . checkNull) $ withCString vert $ \cvert -> withCString frag $ sfShader_createFromFile cvert++foreign import ccall unsafe "sfShader_createFromFile"+    sfShader_createFromFile :: CString -> CString -> IO Shader++-- \return A new sfShader object, or NULL if it failed++--CSFML_GRAPHICS_API sfShader* sfShader_createFromFile(const char* vertexShaderFilename, const char* fragmentShaderFilename);+++-- | Load both the vertex and fragment shaders from source codes in memory.+--+-- This function can load both the vertex and the fragment+-- shaders, or only one of them: pass 'Nothing' if you don't want to load+-- either the vertex shader or the fragment shader.+--+-- The sources must be valid shaders in GLSL language. GLSL is+-- a C-like language dedicated to OpenGL shaders; you'll+-- probably need to read a good documentation for it before+-- writing your own shaders.+shaderFromMemory+    :: Maybe String -- ^ String containing the source code of the vertex shader, or 'Nothing' to skip this shader+    -> Maybe String -- ^ String containing the source code of the fragment shader, or 'Nothing' to skip this shader+    -> IO (Either ShaderException Shader)++shaderFromMemory Nothing Nothing+    = fmap (tagErr (exs nullstr nullstr) . checkNull) $ sfShader_createFromMemory nullPtr nullPtr++shaderFromMemory Nothing fs@(Just frag) =+    fmap (tagErr (exs Nothing fs) . checkNull) . withCString frag $ sfShader_createFromMemory nullPtr++shaderFromMemory vs@(Just vert) Nothing =+    fmap (tagErr (exs vs Nothing) . checkNull) . withCString vert $ flip sfShader_createFromMemory nullPtr++shaderFromMemory vs@(Just vert) fs@(Just frag)+    = fmap (tagErr (exs vs fs) . checkNull) $ withCString vert $ \cvert -> withCString frag $ sfShader_createFromMemory cvert++foreign import ccall unsafe "sfShader_createFromMemory"+    sfShader_createFromMemory :: CString -> CString -> IO Shader++-- \return A new sfShader object, or NULL if it failed++--CSFML_GRAPHICS_API sfShader* sfShader_createFromMemory(const char* vertexShader, const char* fragmentShader);+++-- | Load both the vertex and fragment shaders from custom streams.+--+-- This function can load both the vertex and the fragment+-- shaders, or only one of them: pass 'Nothing' if you don't want to load+-- either the vertex shader or the fragment shader.+--+-- The source codes must be valid shaders in GLSL language.+-- GLSL is a C-like language dedicated to OpenGL shaders;+-- you'll probably need to read a good documentation for+-- it before writing your own shaders.+shaderFromStream+    :: Maybe InputStream -- ^ Source stream to read the vertex shader from, or 'Nothing' to skip this shader+    -> Maybe InputStream -- ^ Source stream to read the fragment shader from, or 'Nothing' to skip this shader+    -> IO (Either ShaderException Shader)++shaderFromStream Nothing Nothing+    = fmap (tagErr (exi nullis nullis) . checkNull) $ sfShader_createFromStream nullPtr nullPtr++shaderFromStream Nothing fs@(Just frag)+    = fmap (tagErr (exi Nothing fs) . checkNull) . with frag $ sfShader_createFromStream nullPtr++shaderFromStream vs@(Just vert) Nothing+    = fmap (tagErr (exi vs Nothing) . checkNull) . with vert $ flip sfShader_createFromStream nullPtr++shaderFromStream vs@(Just vert) fs@(Just frag)+    = fmap (tagErr (exi vs fs) . checkNull) $ with vert $ \cvert -> with frag $ sfShader_createFromStream cvert++foreign import ccall unsafe "sfShader_createFromStream"+    sfShader_createFromStream :: Ptr InputStream -> Ptr InputStream -> IO Shader++-- \return A new sfShader object, or NULL if it failed++--CSFML_GRAPHICS_API sfShader* sfShader_createFromStream(sfInputStream* vertexShaderStream, sfInputStream* fragmentShaderStream);+++instance SFResource Shader where++    {-# INLINABLE destroy #-}+    destroy = sfShader_destroy++foreign import ccall unsafe "sfShader_destroy"+    sfShader_destroy :: Shader -> IO ()++--CSFML_GRAPHICS_API void sfShader_destroy(sfShader* shader);+++-- | Change a float parameter of a shader.+setFloatParameter+    :: Shader+    -> String -- ^ Name of the parameter in the shader+    -> Float  -- ^ Value to assign+    -> IO ()++setFloatParameter shader name val =+    withCString name $ \cname ->+    sfShader_setFloatParameter shader cname $ realToFrac val++foreign import ccall unsafe "sfShader_setFloatParameter"+    sfShader_setFloatParameter :: Shader -> CString -> CFloat -> IO ()++--CSFML_GRAPHICS_API void sfShader_setFloatParameter(sfShader* shader, const char* name, float x);+++-- | Change a 2-components vector parameter of a shader.+setFloat2Parameter+    :: Shader+    -> String -- ^ Name of the parameter in the shader+    -> Float  -- ^ First component of the value to assign+    -> Float  -- ^ Second component of the value to assign+    -> IO ()++setFloat2Parameter shader name f1 f2 =+    withCString name $ \cname ->+    sfShader_setFloat2Parameter shader cname (realToFrac f1) (realToFrac f2)++foreign import ccall unsafe "sfShader_setFloat2Parameter"+    sfShader_setFloat2Parameter :: Shader -> CString -> CFloat -> CFloat -> IO ()++--CSFML_GRAPHICS_API void sfShader_setFloat2Parameter(sfShader* shader, const char* name, float x, float y);+++-- | Change a 3-components vector parameter of a shader.+setFloat3Parameter+    :: Shader+    -> String -- ^ Name of the parameter in the shader+    -> Float  -- ^ First component of the value to assign+    -> Float  -- ^ Second component of the value to assign+    -> Float  -- ^ Third component of the value to assign+    -> IO ()++setFloat3Parameter shader name f1 f2 f3 =+    withCString name $ \cname ->+    sfShader_setFloat3Parameter shader cname (realToFrac f1) (realToFrac f2) (realToFrac f3)++foreign import ccall unsafe "sfShader_setFloat3Parameter"+    sfShader_setFloat3Parameter :: Shader -> CString -> CFloat -> CFloat -> CFloat -> IO ()++--CSFML_GRAPHICS_API void sfShader_setFloat3Parameter(sfShader* shader, const char* name, float x, float y, float z);+++-- | Change a 4-components vector parameter of a shader.+setFloat4Parameter+    :: Shader+    -> String -- ^ Name of the parameter in the shader+    -> Float  -- ^ First component of the value to assign+    -> Float  -- ^ Second component of the value to assign+    -> Float  -- ^ Third component of the value to assign+    -> Float  -- ^ Fourth component of the value to assign+    -> IO ()++setFloat4Parameter shader name f1 f2 f3 f4 =+    withCString name $ \cname ->+    sfShader_setFloat4Parameter shader cname (realToFrac f1) (realToFrac f2) (realToFrac f3) (realToFrac f4)++foreign import ccall unsafe "sfShader_setFloat4Parameter"+    sfShader_setFloat4Parameter :: Shader -> CString -> CFloat -> CFloat -> CFloat -> CFloat -> IO ()++--CSFML_GRAPHICS_API void sfShader_setFloat4Parameter(sfShader* shader, const char* name, float x, float y, float z, float w);+++-- | Change a 2-components vector parameter of a shader.+setVector2Parameter+    :: Shader+    -> String -- ^ Name of the parameter in the shader+    -> Vec2f  -- ^ Vector to assign+    -> IO ()++setVector2Parameter shader name vec =+    withCString name $ \cname ->+    with vec $ sfShader_setVector2Parameter_helper shader cname++foreign import ccall unsafe "sfShader_setVector2Parameter_helper"+    sfShader_setVector2Parameter_helper :: Shader -> CString -> Ptr Vec2f -> IO ()++--CSFML_GRAPHICS_API void sfShader_setVector2Parameter(sfShader* shader, const char* name, sfVector2f vector);+++-- | Change a 3-components vector parameter of a shader.+setVector3Parameter+    :: Shader+    -> String -- ^ Name of the parameter in the shader+    -> Vec3f  -- ^ Vector to assign+    -> IO ()++setVector3Parameter shader name vec =+    withCString name $ \cname ->+    with vec $ sfShader_setVector3Parameter_helper shader cname++foreign import ccall unsafe "sfShader_setVector3Parameter_helper"+    sfShader_setVector3Parameter_helper :: Shader -> CString -> Ptr Vec3f -> IO ()++--CSFML_GRAPHICS_API void sfShader_setVector3Parameter(sfShader* shader, const char* name, sfVector3f vector);+++-- | Change a color parameter of a shader.+setColorParameter+    :: Shader+    -> String -- ^ Name of the parameter in the shader+    -> Color  -- ^ Color to assign+    -> IO ()++setColorParameter shader name color =+    withCString name $ \cname ->+    with color $ sfShader_setColorParameter_helper shader cname++foreign import ccall unsafe "sfShader_setColorParameter_helper"+    sfShader_setColorParameter_helper :: Shader -> CString -> Ptr Color -> IO ()++--CSFML_GRAPHICS_API void sfShader_setColorParameter(sfShader* shader, const char* name, sfColor color);+++-- | Change a matrix parameter of a shader.+setTransformParameter+    :: Shader+    -> String    -- ^ Name of the parameter in the shader+    -> Transform -- ^ Transform to assign+    -> IO ()++setTransformParameter shader name transf =+    withCString name $ \cname ->+    with transf $ sfShader_setTransformParameter_helper shader cname++foreign import ccall unsafe "sfShader_setTransformParameter_helper"+    sfShader_setTransformParameter_helper :: Shader -> CString -> Ptr Transform -> IO ()++--CSFML_GRAPHICS_API void sfShader_setTransformParameter(sfShader* shader, const char* name, sfTransform transform);+++-- | Change a texture parameter of a shader.+--+-- The corresponding parameter in the shader must be a 2D texture (sampler2D GLSL type).+setTextureParameter+    :: Shader+    -> String  -- ^ Name of the texture in the shader+    -> Texture -- ^ Texture to assign+    -> IO ()++setTextureParameter shader name tex =+    withCString name $ \cname -> sfShader_setTextureParameter shader cname tex++foreign import ccall unsafe "sfShader_setTextureParameter"+    sfShader_setTextureParameter :: Shader -> CString -> Texture -> IO ()++--CSFML_GRAPHICS_API void sfShader_setTextureParameter(sfShader* shader, const char* name, const sfTexture* texture);+++-- | Change a texture parameter of a shader.+--+-- This function maps a shader texture variable to the+-- texture of the object being drawn, which cannot be+-- known in advance.+--+-- The corresponding parameter in the shader must be a 2D texture+-- (sampler2D GLSL type).+setCurrentTextureParameter+    :: Shader+    -> String -- ^ Name of the texture in the shader+    -> IO ()++setCurrentTextureParameter shader name = withCString name $ sfShader_setCurrentTextureParameter shader++foreign import ccall unsafe "sfShader_setCurrentTextureParameter"+    sfShader_setCurrentTextureParameter :: Shader -> CString -> IO ()++--CSFML_GRAPHICS_API void sfShader_setCurrentTextureParameter(sfShader* shader, const char* name);+++instance SFBindable Shader where+         {-# INLINABLE bind #-}+         bind = sfShader_bind++foreign import ccall unsafe "sfShader_bind"+    sfShader_bind :: Shader -> IO ()++--CSFML_GRAPHICS_API void sfShader_bind(const sfShader* shader);+++-- | Tell whether or not the system supports shaders.+--+-- This function should always be called before using+-- the shader features. If it returns 'False', then+-- any attempt to use 'Shader' will fail.+isShaderAvailable :: IO Bool+isShaderAvailable = fmap (toEnum . fromIntegral) sfShader_isAvailable++foreign import ccall unsafe "sfShader_isAvailable"+    sfShader_isAvailable :: IO CInt++--CSFML_GRAPHICS_API sfBool sfShader_isAvailable(void);
+ src/SFML/Graphics/Shape.hs view
@@ -0,0 +1,330 @@+module SFML.Graphics.Shape+(+    createShape+,   destroy+,   setPosition+,   setRotation+,   setScale+,   setOrigin+,   getPosition+,   getRotation+,   getScale+,   getOrigin+,   move+,   rotate+,   scale+,   getTransform+,   getInverseTransform+,   setTexture+,   setTextureRect+,   getTexture+,   getTextureRect+,   setFillColor+,   setOutlineColor+,   setOutlineThickness+,   getFillColor+,   getOutlineColor+,   getOutlineThickness+,   getPointCount+,   getPoint+,   setPointCount+,   getLocalBounds+,   getGlobalBounds+,   updateShape+)+where+++import SFML.Graphics.SFBounded+import SFML.Graphics.Color+import SFML.Graphics.Rect+import SFML.Graphics.SFShape+import SFML.Graphics.SFShapeResizable+import SFML.Graphics.SFTexturable+import SFML.Graphics.Transform+import SFML.Graphics.Transformable+import SFML.Graphics.Types+import SFML.SFResource+import SFML.System.Vector2++import Control.Monad ((>=>))+import Foreign.C.Types+import Foreign.Ptr (Ptr, nullPtr)+import Foreign.Marshal.Alloc (alloca)+import Foreign.Marshal.Utils (with)+import Foreign.Storable (peek)+++checkNullTexture :: Texture -> Maybe Texture+checkNullTexture tex@(Texture ptr) = if ptr == nullPtr then Nothing else Just tex+++-- | Create a new shape.+createShape+    :: Ptr a -- ^ Callback that provides the point count of the shape+    -> Ptr b -- ^ Callback that provides the points of the shape+    -> Ptr c -- ^ Data to pass to the callback functions+    -> IO Shape++createShape = sfShape_create++foreign import ccall unsafe "sfShape_create"+    sfShape_create :: Ptr a -> Ptr b -> Ptr c -> IO Shape++--CSFML_GRAPHICS_API sfShape* sfShape_create(sfShapeGetPointCountCallback getPointCount, sfShapeGetPointCallback getPoint, void* userData);+++instance SFResource Shape where++    {-# INLINABLE destroy #-}+    destroy = sfShape_destroy++foreign import ccall unsafe "sfShape_destroy"+    sfShape_destroy :: Shape -> IO ()++--CSFML_GRAPHICS_API void sfShape_destroy(sfShape* shape);+++instance Transformable Shape where++    {-# INLINABLE setPosition #-}+    setPosition c p = with p $ sfShape_setPosition_helper c++    {-# INLINABLE setRotation #-}+    setRotation s r = sfShape_setRotation s (realToFrac r)++    {-# INLINABLE setScale #-}+    setScale c s = with s $ sfShape_setScale_helper c++    {-# INLINABLE setOrigin #-}+    setOrigin c o = with o $ sfShape_setOrigin_helper c++    {-# INLINABLE getPosition #-}+    getPosition c = alloca $ \ptr -> sfShape_getPosition_helper c ptr >> peek ptr++    {-# INLINABLE getRotation #-}+    getRotation = sfShape_getRotation >=> return . realToFrac++    {-# INLINABLE getScale #-}+    getScale c = alloca $ \ptr -> sfShape_getScale_helper c ptr >> peek ptr++    {-# INLINABLE getOrigin #-}+    getOrigin c = alloca $ \ptr -> sfShape_getOrigin_helper c ptr >> peek ptr++    {-# INLINABLE move #-}+    move c off = with off $ sfShape_move_helper c++    {-# INLINABLE rotate #-}+    rotate s a = sfShape_rotate s (realToFrac a)++    {-# INLINABLE scale #-}+    scale c s = with s $ sfShape_scale_helper c++    {-# INLINABLE getTransform #-}+    getTransform c = alloca $ \ptr -> sfShape_getTransform_helper c ptr >> peek ptr++    {-# INLINABLE getInverseTransform #-}+    getInverseTransform c = alloca $ \ptr -> sfShape_getInverseTransform_helper c ptr >> peek ptr+++foreign import ccall unsafe "sfShape_setPosition_helper"+    sfShape_setPosition_helper :: Shape -> Ptr Vec2f -> IO ()++--CSFML_GRAPHICS_API void sfShape_setPosition(sfShape* shape, sfVector2f position);++foreign import ccall unsafe "sfShape_setRotation"+    sfShape_setRotation :: Shape -> CFloat -> IO ()++--CSFML_GRAPHICS_API void sfShape_setRotation(sfShape* shape, float angle);++foreign import ccall unsafe "sfShape_setScale_helper"+    sfShape_setScale_helper :: Shape -> Ptr Vec2f -> IO ()++--CSFML_GRAPHICS_API void sfShape_setScale(sfShape* shape, sfVector2f scale);++foreign import ccall unsafe "sfShape_setOrigin_helper"+    sfShape_setOrigin_helper :: Shape -> Ptr Vec2f -> IO ()++--CSFML_GRAPHICS_API void sfShape_setOrigin(sfShape* shape, sfVector2f origin);++foreign import ccall unsafe "sfShape_getPosition_helper"+    sfShape_getPosition_helper :: Shape -> Ptr Vec2f -> IO ()++--CSFML_GRAPHICS_API sfVector2f sfShape_getPosition(const sfShape* shape);++foreign import ccall unsafe "sfShape_getRotation"+    sfShape_getRotation :: Shape -> IO CFloat++--CSFML_GRAPHICS_API float sfShape_getRotation(const sfShape* shape);++foreign import ccall unsafe "sfShape_getScale_helper"+    sfShape_getScale_helper :: Shape -> Ptr Vec2f -> IO ()++--CSFML_GRAPHICS_API sfVector2f sfShape_getScale(const sfShape* shape);++foreign import ccall unsafe "sfShape_getOrigin_helper"+    sfShape_getOrigin_helper :: Shape -> Ptr Vec2f -> IO ()++--CSFML_GRAPHICS_API sfVector2f sfShape_getOrigin(const sfShape* shape);++foreign import ccall unsafe "sfShape_move_helper"+    sfShape_move_helper :: Shape -> Ptr Vec2f -> IO ()++--CSFML_GRAPHICS_API void sfShape_move(sfShape* shape, sfVector2f offset);++foreign import ccall unsafe "sfShape_rotate"+    sfShape_rotate :: Shape -> CFloat -> IO ()++--CSFML_GRAPHICS_API void sfShape_rotate(sfShape* shape, float angle);++foreign import ccall unsafe "sfShape_scale_helper"+    sfShape_scale_helper :: Shape -> Ptr Vec2f -> IO ()++--CSFML_GRAPHICS_API void sfShape_scale(sfShape* shape, sfVector2f factors);++foreign import ccall unsafe "sfShape_getTransform_helper"+    sfShape_getTransform_helper :: Shape -> Ptr Transform -> IO ()++--CSFML_GRAPHICS_API sfTransform sfShape_getTransform(const sfShape* shape);++foreign import ccall unsafe "sfShape_getInverseTransform_helper"+    sfShape_getInverseTransform_helper :: Shape -> Ptr Transform -> IO ()++--CSFML_GRAPHICS_API sfTransform sfShape_getInverseTransform(const sfShape* shape);+++instance SFTexturable Shape where++    {-# INLINABLE setTexture #-}+    setTexture c tex reset = sfShape_setTexture c tex (fromIntegral . fromEnum $ reset)++    {-# INLINABLE setTextureRect #-}+    setTextureRect c rect = with rect $ sfShape_setTextureRect_helper c++    {-# INLINABLE getTexture #-}+    getTexture = sfShape_getTexture >=> return . checkNullTexture++    {-# INLINABLE getTextureRect #-}+    getTextureRect c = alloca $ \ptr -> sfShape_getTextureRect_helper c ptr >> peek ptr+++foreign import ccall unsafe "sfShape_setTexture"+    sfShape_setTexture :: Shape -> Texture -> CInt -> IO ()++--CSFML_GRAPHICS_API void sfShape_setTexture(sfShape* shape, const sfTexture* texture, sfBool resetRect);++foreign import ccall unsafe "sfShape_setTextureRect_helper"+    sfShape_setTextureRect_helper :: Shape -> Ptr IntRect -> IO ()++--CSFML_GRAPHICS_API void sfShape_setTextureRect(sfShape* shape, sfIntRect rect);++foreign import ccall unsafe "sfShape_getTexture"+    sfShape_getTexture :: Shape -> IO Texture++--CSFML_GRAPHICS_API const sfTexture* sfShape_getTexture(const sfShape* shape);++foreign import ccall unsafe "sfShape_getTextureRect_helper"+    sfShape_getTextureRect_helper :: Shape -> Ptr IntRect -> IO ()++--CSFML_GRAPHICS_API sfIntRect sfShape_getTextureRect(const sfShape* shape);+++instance SFShape Shape where++    {-# INLINABLE setFillColor #-}+    setFillColor c color = with color $ sfShape_setFillColor_helper c++    {-# INLINABLE setOutlineColor #-}+    setOutlineColor c color = with color $ sfShape_setOutlineColor_helper c++    {-# INLINABLE setOutlineThickness #-}+    setOutlineThickness s t = sfShape_setOutlineThickness s (realToFrac t)++    {-# INLINABLE getFillColor #-}+    getFillColor c = alloca $ \ptr -> sfShape_getFillColor_helper c ptr >> peek ptr++    {-# INLINABLE getOutlineColor #-}+    getOutlineColor c = alloca $ \ptr -> sfShape_getOutlineColor_helper c ptr >> peek ptr++    {-# INLINABLE getOutlineThickness #-}+    getOutlineThickness = sfShape_getOutlineThickness >=> return . realToFrac++    {-# INLINABLE getPointCount #-}+    getPointCount = sfShape_getPointCount >=> return . fromIntegral++    {-# INLINABLE getPoint #-}+    getPoint c idx = alloca $ \ptr -> sfShape_getPoint_helper c (fromIntegral idx) ptr >> peek ptr+++foreign import ccall unsafe "sfShape_setFillColor_helper"+    sfShape_setFillColor_helper :: Shape -> Ptr Color -> IO ()++--CSFML_GRAPHICS_API void sfShape_setFillColor(sfShape* shape, sfColor color);++foreign import ccall unsafe "sfShape_setOutlineColor_helper"+    sfShape_setOutlineColor_helper :: Shape -> Ptr Color -> IO ()++--CSFML_GRAPHICS_API void sfShape_setOutlineColor(sfShape* shape, sfColor color);++foreign import ccall unsafe "sfShape_setOutlineThickness"+    sfShape_setOutlineThickness :: Shape -> CFloat -> IO ()++--CSFML_GRAPHICS_API void sfShape_setOutlineThickness(sfShape* shape, float thickness);++foreign import ccall unsafe "sfShape_getFillColor_helper"+    sfShape_getFillColor_helper :: Shape -> Ptr Color -> IO ()++--CSFML_GRAPHICS_API sfColor sfShape_getFillColor(const sfShape* shape);++foreign import ccall unsafe "sfShape_getOutlineColor_helper"+    sfShape_getOutlineColor_helper :: Shape -> Ptr Color -> IO ()++--CSFML_GRAPHICS_API sfColor sfShape_getOutlineColor(const sfShape* shape);++foreign import ccall unsafe "sfShape_getOutlineThickness"+    sfShape_getOutlineThickness :: Shape -> IO CFloat++--CSFML_GRAPHICS_API float sfShape_getOutlineThickness(const sfShape* shape);++foreign import ccall "sfShape_getPointCount"+    sfShape_getPointCount :: Shape -> IO CUInt++--CSFML_GRAPHICS_API unsigned int sfShape_getPointCount(const sfShape* shape);++foreign import ccall "sfShape_getPoint_helper"+    sfShape_getPoint_helper :: Shape -> CUInt -> Ptr Vec2f -> IO ()++--CSFML_GRAPHICS_API sfVector2f sfShape_getPoint(const sfShape* shape, unsigned int index);+++instance SFBounded Shape where++    {-# INLINABLE getLocalBounds #-}+    getLocalBounds c = alloca $ \ptr -> sfShape_getLocalBounds_helper c ptr >> peek ptr++    {-# INLINABLE getGlobalBounds #-}+    getGlobalBounds c = alloca $ \ptr -> sfShape_getGlobalBounds_helper c ptr >> peek ptr++foreign import ccall unsafe "sfShape_getLocalBounds_helper"+    sfShape_getLocalBounds_helper :: Shape -> Ptr FloatRect -> IO ()++--CSFML_GRAPHICS_API sfFloatRect sfShape_getLocalBounds(const sfShape* shape);++foreign import ccall unsafe "sfShape_getGlobalBounds_helper"+    sfShape_getGlobalBounds_helper :: Shape -> Ptr FloatRect -> IO ()++--CSFML_GRAPHICS_API sfFloatRect sfShape_getGlobalBounds(const sfShape* shape);+++-- | Recompute the internal geometry of a shape.+--+-- This function must be called by specialized shape objects+-- everytime their points change (ie. the result of either+-- the getPointCount or getPoint callbacks is different).+updateShape :: Shape -> IO ()+updateShape = sfShape_update++foreign import ccall unsafe "sfShape_update"+    sfShape_update :: Shape -> IO ()++--CSFML_GRAPHICS_API void sfShape_update(sfShape* shape);
+ src/SFML/Graphics/Sprite.hs view
@@ -0,0 +1,296 @@+{-# LANGUAGE DeriveDataTypeable #-}+module SFML.Graphics.Sprite+(+    module SFML.Utils+,   SpriteException(..)+,   createSprite+,   copy+,   destroy+,   setPosition+,   setRotation+,   setScale+,   setOrigin+,   getPosition+,   getRotation+,   getScale+,   getOrigin+,   move+,   rotate+,   scale+,   getTransform+,   getInverseTransform+,   setColor+,   getColor+,   setTexture+,   setTextureRect+,   getTexture+,   getTextureRect+,   getLocalBounds+,   getGlobalBounds+)+where+++import SFML.Graphics.BlendMode+import SFML.Graphics.SFBounded+import SFML.Graphics.Color+import SFML.Graphics.Rect+import SFML.Graphics.SFTexturable+import SFML.Graphics.Transform+import SFML.Graphics.Transformable+import SFML.Graphics.Types+import SFML.SFCopyable+import SFML.SFResource+import SFML.System.Vector2+import SFML.Utils++import Control.Exception+import Control.Monad ((>=>))+import Data.Typeable+import Foreign.C.Types+import Foreign.Marshal.Alloc (alloca)+import Foreign.Marshal.Utils (with)+import Foreign.Ptr+import Foreign.Storable (peek)+++checkNull :: Sprite -> Maybe Sprite+checkNull sprite@(Sprite ptr) = if ptr == nullPtr then Nothing else Just sprite+++checkNullTexture :: Texture -> Maybe Texture+checkNullTexture tex@(Texture ptr) = if ptr == nullPtr then Nothing else Just tex+++data SpriteException = SpriteException String deriving (Show, Typeable)++instance Exception SpriteException+++-- | Create a new sprite.+createSprite :: IO (Either SpriteException Sprite)+createSprite =+    let err = SpriteException "Failed creating sprite"+    in fmap (tagErr err . checkNull) sfSprite_create++foreign import ccall unsafe "sfSprite_create"+    sfSprite_create :: IO Sprite++-- \return A new sfSprite object, or NULL if it failed++--CSFML_GRAPHICS_API sfSprite* sfSprite_create(void);+++instance SFCopyable Sprite where++    {-# INLINABLE copy #-}+    copy = sfSprite_copy+++foreign import ccall unsafe "sfSprite_copy"+    sfSprite_copy :: Sprite -> IO Sprite++--CSFML_GRAPHICS_API sfSprite* sfSprite_copy(sfSprite* sprite);+++instance SFResource Sprite where++    {-# INLINABLE destroy #-}+    destroy = sfSprite_destroy++foreign import ccall unsafe "sfSprite_destroy"+    sfSprite_destroy :: Sprite -> IO ()++--CSFML_GRAPHICS_API void sfSprite_destroy(sfSprite* sprite);+++instance Transformable Sprite where++    {-# INLINABLE setPosition #-}+    setPosition sprite pos = with pos $ sfSprite_setPosition_helper sprite++    {-# INLINABLE setRotation #-}+    setRotation s r = sfSprite_setRotation s (realToFrac r)++    {-# INLINABLE setScale #-}+    setScale sprite s = with s $ sfSprite_setScale_helper sprite++    {-# INLINABLE setOrigin #-}+    setOrigin sprite o = with o $ sfSprite_setOrigin_helper sprite++    {-# INLINABLE getPosition #-}+    getPosition sprite = alloca $ \ptr -> sfSprite_getPosition_helper sprite ptr >> peek ptr++    {-# INLINABLE getRotation #-}+    getRotation = sfSprite_getRotation >=> return . realToFrac++    {-# INLINABLE getScale #-}+    getScale sprite = alloca $ \ptr -> sfSprite_getScale_helper sprite ptr >> peek ptr++    {-# INLINABLE getOrigin #-}+    getOrigin sprite = alloca $ \ptr -> sfSprite_getOrigin_helper sprite ptr >> peek ptr++    {-# INLINABLE move #-}+    move sprite off = with off $ sfSprite_move_helper sprite++    {-# INLINABLE rotate #-}+    rotate s a = sfSprite_rotate s (realToFrac a)++    {-# INLINABLE scale #-}+    scale sprite s = with s $ sfSprite_scale_helper sprite++    {-# INLINABLE getTransform #-}+    getTransform sprite = alloca $ \ptr -> sfSprite_getTransform_helper sprite ptr >> peek ptr++    {-# INLINABLE getInverseTransform #-}+    getInverseTransform sprite = alloca $ \ptr -> sfSprite_getInverseTransform_helper sprite ptr >> peek ptr+++foreign import ccall unsafe "sfSprite_setPosition_helper"+    sfSprite_setPosition_helper :: Sprite -> Ptr Vec2f -> IO ()++--CSFML_GRAPHICS_API void sfSprite_setPosition(sfSprite* sprite, sfVector2f position);++foreign import ccall unsafe "sfSprite_setRotation"+    sfSprite_setRotation :: Sprite -> CFloat -> IO ()++--CSFML_GRAPHICS_API void sfSprite_setRotation(sfSprite* sprite, float angle);++foreign import ccall unsafe "sfSprite_setScale_helper"+    sfSprite_setScale_helper :: Sprite -> Ptr Vec2f -> IO ()++--CSFML_GRAPHICS_API void sfSprite_setScale(sfSprite* sprite, sfVector2f scale);++foreign import ccall unsafe "sfSprite_setOrigin_helper"+    sfSprite_setOrigin_helper :: Sprite -> Ptr Vec2f -> IO ()++--CSFML_GRAPHICS_API void sfSprite_setOrigin(sfSprite* sprite, sfVector2f origin);++foreign import ccall unsafe "sfSprite_getPosition_helper"+    sfSprite_getPosition_helper :: Sprite -> Ptr Vec2f -> IO ()++--CSFML_GRAPHICS_API sfVector2f sfSprite_getPosition(const sfSprite* sprite);++foreign import ccall unsafe "sfSprite_getRotation"+    sfSprite_getRotation :: Sprite -> IO CFloat++--CSFML_GRAPHICS_API float sfSprite_getRotation(const sfSprite* sprite);++foreign import ccall unsafe "sfSprite_getScale_helper"+    sfSprite_getScale_helper :: Sprite -> Ptr Vec2f -> IO ()++--CSFML_GRAPHICS_API sfVector2f sfSprite_getScale(const sfSprite* sprite);++foreign import ccall unsafe "sfSprite_getOrigin_helper"+    sfSprite_getOrigin_helper :: Sprite -> Ptr Vec2f -> IO ()++--CSFML_GRAPHICS_API sfVector2f sfSprite_getOrigin(const sfSprite* sprite);++foreign import ccall unsafe "sfSprite_move_helper"+    sfSprite_move_helper :: Sprite -> Ptr Vec2f -> IO ()++--CSFML_GRAPHICS_API void sfSprite_move(sfSprite* sprite, sfVector2f offset);++foreign import ccall unsafe "sfSprite_rotate"+    sfSprite_rotate :: Sprite -> CFloat -> IO ()++--CSFML_GRAPHICS_API void sfSprite_rotate(sfSprite* sprite, float angle);++foreign import ccall unsafe "sfSprite_scale_helper"+    sfSprite_scale_helper :: Sprite -> Ptr Vec2f -> IO ()++--CSFML_GRAPHICS_API void sfSprite_scale(sfSprite* sprite, sfVector2f factors);++foreign import ccall unsafe "sfSprite_getTransform_helper"+    sfSprite_getTransform_helper :: Sprite -> Ptr Transform -> IO ()++--CSFML_GRAPHICS_API sfTransform sfSprite_getTransform(const sfSprite* sprite);++foreign import ccall unsafe "sfSprite_getInverseTransform_helper"+    sfSprite_getInverseTransform_helper :: Sprite -> Ptr Transform -> IO ()++--CSFML_GRAPHICS_API sfTransform sfSprite_getInverseTransform(const sfSprite* sprite);+++-- | Set the global color of a sprite.+--+-- This color is modulated (multiplied) with the sprite's+-- texture. It can be used to colorize the sprite, or change+-- its global opacity.+-- By default, the sprite's color is opaque white.+setColor :: Sprite -> Color -> IO ()+setColor sprite color = with color $ sfSprite_setColor_helper sprite++foreign import ccall unsafe "sfSprite_setColor_helper"+    sfSprite_setColor_helper :: Sprite -> Ptr Color -> IO ()++--CSFML_GRAPHICS_API void sfSprite_setColor(sfSprite* sprite, sfColor color);+++-- | Get the global color of a sprite.+getColor :: Sprite -> IO Color+getColor sprite = alloca $ \ptr -> sfSprite_getColor_helper sprite ptr >> peek ptr++foreign import ccall unsafe "sfSprite_getColor_helper"+    sfSprite_getColor_helper :: Sprite -> Ptr Color -> IO ()++--CSFML_GRAPHICS_API sfColor sfSprite_getColor(const sfSprite* sprite);+++instance SFTexturable Sprite where++    {-# INLINABLE setTexture #-}+    setTexture sprite tex reset = sfSprite_setTexture sprite tex (fromIntegral . fromEnum $ reset)++    {-# INLINABLE setTextureRect #-}+    setTextureRect sprite rect = with rect $ sfSprite_setTextureRect_helper sprite++    {-# INLINABLE getTexture #-}+    getTexture = fmap checkNullTexture . sfSprite_getTexture++    {-# INLINABLE getTextureRect #-}+    getTextureRect sprite = alloca $ \ptr -> sfSprite_getTextureRect_helper sprite ptr >> peek ptr++foreign import ccall unsafe "sfSprite_setTexture"+    sfSprite_setTexture :: Sprite -> Texture -> CInt -> IO ()++--CSFML_GRAPHICS_API void sfSprite_setTexture(sfSprite* sprite, const sfTexture* texture, sfBool resetRect);+++foreign import ccall unsafe "sfSprite_setTextureRect_helper"+    sfSprite_setTextureRect_helper :: Sprite -> Ptr IntRect -> IO ()++--CSFML_GRAPHICS_API void sfSprite_setTextureRect(sfSprite* sprite, sfIntRect rectangle);+++foreign import ccall unsafe "sfSprite_getTexture"+    sfSprite_getTexture :: Sprite -> IO Texture++-- \return Pointer to the sprite's texture (can be null)++--CSFML_GRAPHICS_API const sfTexture* sfSprite_getTexture(const sfSprite* sprite);+++foreign import ccall unsafe "sfSprite_getTextureRect_helper"+    sfSprite_getTextureRect_helper :: Sprite -> Ptr IntRect -> IO ()++--CSFML_GRAPHICS_API sfIntRect sfSprite_getTextureRect(const sfSprite* sprite);+++instance SFBounded Sprite where++    {-# INLINABLE getLocalBounds #-}+    getLocalBounds sprite = alloca $ \ptr -> sfSprite_getLocalBounds_helper sprite ptr >> peek ptr++    {-# INLINABLE getGlobalBounds #-}+    getGlobalBounds sprite = alloca $ \ptr -> sfSprite_getGlobalBounds_helper sprite ptr >> peek ptr++foreign import ccall unsafe "sfSprite_getLocalBounds_helper"+    sfSprite_getLocalBounds_helper :: Sprite -> Ptr FloatRect -> IO ()++--CSFML_GRAPHICS_API sfFloatRect sfSprite_getLocalBounds(const sfSprite* sprite);++foreign import ccall unsafe "sfSprite_getGlobalBounds_helper"+    sfSprite_getGlobalBounds_helper :: Sprite -> Ptr FloatRect -> IO ()++--CSFML_GRAPHICS_API sfFloatRect sfSprite_getGlobalBounds(const sfSprite* sprite);
+ src/SFML/Graphics/Text.hs view
@@ -0,0 +1,438 @@+{-# LANGUAGE DeriveDataTypeable #-}+module SFML.Graphics.Text+(+    module SFML.Utils+,   TextException(..)+,   TextStyle(..)+,   createText+,   copy+,   destroy+,   setTextString+,   setTextStringU+,   setTextFont+,   setTextCharacterSize+,   setTextStyle+,   setTextColor+,   getTextString+,   getTextUnicodeString+,   getTextFont+,   getTextCharacterSize+,   getTextStyle+,   getTextColor+,   findTextCharacterPos+,   getTextLocalBounds+,   getTextGlobalBounds+)+where+++import SFML.Graphics.Color+import SFML.Graphics.Rect+import SFML.Graphics.Transform+import SFML.Graphics.Transformable+import SFML.Graphics.Types+import SFML.SFCopyable+import SFML.SFResource+import SFML.System.Vector2+import SFML.Utils++import Control.Exception+import Control.Monad+import Data.Typeable+import Data.Bits ((.|.))+import Data.List (foldl')+import Foreign.C.String+import Foreign.C.Types+import Foreign.Marshal.Alloc (alloca)+import Foreign.Marshal.Utils (with)+import Foreign.Ptr+import Foreign.Storable+++-- | Text styles.+data TextStyle+    = TextRegular    -- ^ Regular characters, no style+    | TextBold       -- ^ Characters are bold+    | TextItalic     -- ^ Characters are in italic+    | TextUnderlined -- ^ Characters are underlined+    deriving (Eq, Bounded, Show)+++instance Enum TextStyle where+    +    fromEnum TextRegular    = 0+    fromEnum TextBold       = 1+    fromEnum TextItalic     = 2+    fromEnum TextUnderlined = 4+    +    toEnum 0 = TextRegular+    toEnum 1 = TextBold+    toEnum 2 = TextItalic+    toEnum 4 = TextUnderlined+++data TextException = TextException String deriving (Show, Typeable)++instance Exception TextException+++checkNull :: Text -> Maybe Text+checkNull text@(Text ptr) = if ptr == nullPtr then Nothing else Just text+++checkNullFont :: Font -> Maybe Font+checkNullFont font@(Font ptr) = if ptr == nullPtr then Nothing else Just font+++-- | Create a new text.+createText :: IO (Either TextException Text)+createText =+    let err = TextException "Failed creating text"+    in fmap (tagErr err . checkNull) sfText_create++foreign import ccall unsafe "sfText_create"+    sfText_create :: IO Text++-- \return A new sfText object, or NULL if it failed++--CSFML_GRAPHICS_API sfText* sfText_create(void);+++instance SFCopyable Text where+    +    {-# INLINABLE copy #-}+    copy = sfText_copy+++foreign import ccall unsafe "sfText_copy"+    sfText_copy :: Text -> IO Text++--CSFML_GRAPHICS_API sfText* sfText_copy(sfText* text);+++instance SFResource Text where+    +    {-# INLINABLE destroy #-}+    destroy = sfText_destroy++foreign import ccall unsafe "sfText_destroy"+    sfText_destroy :: Text -> IO ()++--CSFML_GRAPHICS_API void sfText_destroy(sfText* text);+++instance Transformable Text where++    {-# INLINABLE setPosition #-}+    setPosition text pos = with pos $ sfText_setPosition_helper text+    +    {-# INLINABLE setRotation #-}+    setRotation t r = sfText_setRotation t (realToFrac r)+    +    {-# INLINABLE setScale #-}+    setScale text s = with s $ sfText_setScale_helper text+    +    {-# INLINABLE setOrigin #-}+    setOrigin text o = with o $ sfText_setOrigin_helper text+    +    {-# INLINABLE getPosition #-}+    getPosition text = alloca $ \ptr -> sfText_getPosition_helper text ptr >> peek ptr+    +    {-# INLINABLE getRotation #-}+    getRotation = sfText_getRotation >=> return . realToFrac+    +    {-# INLINABLE getScale #-}+    getScale text = alloca $ \ptr -> sfText_getScale_helper text ptr >> peek ptr+    +    {-# INLINABLE getOrigin #-}+    getOrigin text = alloca $ \ptr -> sfText_getOrigin_helper text ptr >> peek ptr+    +    {-# INLINABLE move #-}+    move text pos = with pos $ sfText_move_helper text+    +    {-# INLINABLE rotate #-}+    rotate t a = sfText_rotate t (realToFrac a)+    +    {-# INLINABLE scale #-}+    scale text s = with s $ sfText_scale_helper text+    +    {-# INLINABLE getTransform #-}+    getTransform text = alloca $ \ptr -> sfText_getTransform_helper text ptr >> peek ptr+    +    {-# INLINABLE getInverseTransform #-}+    getInverseTransform text = alloca $ \ptr -> sfText_getInverseTransform_helper text ptr >> peek ptr+++foreign import ccall unsafe "sfText_setPosition_helper"+    sfText_setPosition_helper :: Text -> Ptr Vec2f -> IO ()++--CSFML_GRAPHICS_API void sfText_setPosition(sfText* text, sfVector2f position);++foreign import ccall unsafe "sfText_setRotation"+    sfText_setRotation :: Text -> CFloat -> IO ()++--CSFML_GRAPHICS_API void sfText_setRotation(sfText* text, float angle);++foreign import ccall unsafe "sfText_setScale_helper"+    sfText_setScale_helper :: Text -> Ptr Vec2f -> IO ()++--CSFML_GRAPHICS_API void sfText_setScale(sfText* text, sfVector2f scale);++foreign import ccall unsafe "sfText_setOrigin_helper"+    sfText_setOrigin_helper :: Text -> Ptr Vec2f -> IO ()++--CSFML_GRAPHICS_API void sfText_setOrigin(sfText* text, sfVector2f origin);++foreign import ccall unsafe "sfText_getPosition_helper"+    sfText_getPosition_helper :: Text -> Ptr Vec2f -> IO ()++--CSFML_GRAPHICS_API sfVector2f sfText_getPosition(const sfText* text);++foreign import ccall unsafe "sfText_getRotation"+    sfText_getRotation :: Text -> IO CFloat++--CSFML_GRAPHICS_API float sfText_getRotation(const sfText* text);++foreign import ccall unsafe "sfText_getScale_helper"+    sfText_getScale_helper :: Text -> Ptr Vec2f -> IO ()++--CSFML_GRAPHICS_API sfVector2f sfText_getScale(const sfText* text);++foreign import ccall unsafe "sfText_getOrigin_helper"+    sfText_getOrigin_helper :: Text -> Ptr Vec2f -> IO ()++--CSFML_GRAPHICS_API sfVector2f sfText_getOrigin(const sfText* text);++foreign import ccall unsafe "sfText_move_helper"+    sfText_move_helper :: Text -> Ptr Vec2f -> IO ()++--CSFML_GRAPHICS_API void sfText_move(sfText* text, sfVector2f offset);++foreign import ccall unsafe "sfText_rotate"+    sfText_rotate :: Text -> CFloat -> IO ()++--CSFML_GRAPHICS_API void sfText_rotate(sfText* text, float angle);++foreign import ccall unsafe "sfText_scale_helper"+    sfText_scale_helper :: Text -> Ptr Vec2f -> IO ()++--CSFML_GRAPHICS_API void sfText_scale(sfText* text, sfVector2f factors);++foreign import ccall unsafe "sfText_getTransform_helper"+    sfText_getTransform_helper :: Text -> Ptr Transform -> IO ()++--CSFML_GRAPHICS_API sfTransform sfText_getTransform(const sfText* text);++foreign import ccall unsafe "sfText_getInverseTransform_helper"+    sfText_getInverseTransform_helper :: Text -> Ptr Transform -> IO ()++--CSFML_GRAPHICS_API sfTransform sfText_getInverseTransform(const sfText* text);+++-- | Set the string of a text (from an ANSI string).+--+-- A text's string is empty by default.+setTextString :: Text -> String -> IO ()+setTextString text str = withCAString str $ sfText_setString text++foreign import ccall unsafe "sfText_setString"+    sfText_setString :: Text -> CString -> IO ()++--CSFML_GRAPHICS_API void sfText_setString(sfText* text, const char* string);+++-- | Set the string of a text (from a unicode string).+setTextStringU :: Text -> String -> IO ()++-- withCString is locale dependent. SFML expects UTF-32. Needs fix.+setTextStringU text str = withCString str $ sfText_setUnicodeString text++foreign import ccall unsafe "sfText_setUnicodeString"+    sfText_setUnicodeString :: Text -> CString -> IO ()++--CSFML_GRAPHICS_API void sfText_setUnicodeString(sfText* text, const sfUint32* string);+++-- | Set the font of a text.+--+-- The font argument refers to a texture that must+-- exist as long as the text uses it. Indeed, the text+-- doesn't store its own copy of the font, but rather keeps+-- a pointer to the one that you passed to this function.+-- If the font is destroyed and the text tries to+-- use it, the behaviour is undefined.+setTextFont :: Text -> Font -> IO ()+setTextFont = sfText_setFont++foreign import ccall unsafe "sfText_setFont"+    sfText_setFont :: Text -> Font -> IO ()++--CSFML_GRAPHICS_API void sfText_setFont(sfText* text, const sfFont* font);+++-- | Set the character size of a text.+--+-- The default size is 30.+setTextCharacterSize+    :: Text+    -> Int -- ^ New character size, in pixels+    -> IO ()++setTextCharacterSize text size = sfText_setCharacterSize text (fromIntegral size)++foreign import ccall unsafe "sfText_setCharacterSize"+    sfText_setCharacterSize :: Text -> CUInt -> IO ()++--CSFML_GRAPHICS_API void sfText_setCharacterSize(sfText* text, unsigned int size);+++-- | Set the style of a text.+--+-- You can pass a combination of one or more styles, for+-- example [TextBold, sfTextItalic].+--+-- The default style is TextRegular.+setTextStyle :: Text -> [TextStyle] -> IO ()+setTextStyle text styles = sfText_setStyle text $ foldl' (.|.) 0 $ fmap (fromIntegral . fromEnum) styles++-- Fix: Should be using a 32-bit int instead of CUInt.+foreign import ccall unsafe "sfText_setStyle"+    sfText_setStyle :: Text -> CUInt -> IO ()++--CSFML_GRAPHICS_API void sfText_setStyle(sfText* text, sfUint32 style);+++-- | Set the global color of a text.+--+-- By default, the text's color is opaque white.+setTextColor :: Text -> Color -> IO ()+setTextColor text color = with color $ sfText_setColor_helper text++foreign import ccall unsafe "sfText_setColor_helper"+    sfText_setColor_helper :: Text -> Ptr Color -> IO ()++--CSFML_GRAPHICS_API void sfText_setColor(sfText* text, sfColor color);+++-- | Get the string of a text as an ANSI string.+getTextString :: Text -> IO String+getTextString = sfText_getString >=> peekCString++foreign import ccall unsafe "sfText_getString"+    sfText_getString :: Text -> IO CString++--CSFML_GRAPHICS_API const char* sfText_getString(const sfText* text);+++-- | Get the string of a text as a UTF-32 string.+getTextUnicodeString :: Text -> IO String+-- Fix: peekCString is locale-dependent. SFML will return a UTF-32 string.+getTextUnicodeString = sfText_getString >=> peekCString++foreign import ccall unsafe "sfText_getUnicodeString"+    sfText_getUnicodeString :: Text -> IO CString++--CSFML_GRAPHICS_API const sfUint32* sfText_getUnicodeString(const sfText* text);+++-- | Get the font used by a text.+--+-- If the text has no font attached, 'Nothing' is returned.+--+-- The returned pointer is const, which means that you can't+-- modify the font when you retrieve it with this function.+getTextFont :: Text -> IO (Maybe Font)+getTextFont = fmap checkNullFont . sfText_getFont++foreign import ccall unsafe "sfText_getFont"+    sfText_getFont :: Text -> IO Font++--CSFML_GRAPHICS_API const sfFont* sfText_getFont(const sfText* text);+++-- | Get the size of the characters of a text.+getTextCharacterSize :: Text -> IO Int+getTextCharacterSize = fmap fromIntegral . sfText_getCharacterSize++foreign import ccall unsafe "sfText_getCharacterSize"+    sfText_getCharacterSize :: Text -> IO CUInt++--CSFML_GRAPHICS_API unsigned int sfText_getCharacterSize(const sfText* text);+++-- | Get the style of a text+getTextStyle :: Text -> IO TextStyle+getTextStyle = fmap (toEnum . fromIntegral) . sfText_getStyle++foreign import ccall unsafe "sfText_getStyle"+    sfText_getStyle :: Text -> IO CUInt++--CSFML_GRAPHICS_API sfUint32 sfText_getStyle(const sfText* text);+++-- | Get the global color of a text.+getTextColor :: Text -> IO Color+getTextColor text = alloca $ \ptr -> sfText_getColor_helper text ptr >> peek ptr++foreign import ccall unsafe "sfText_getColor_helper"+    sfText_getColor_helper :: Text -> Ptr Color -> IO ()++--CSFML_GRAPHICS_API sfColor sfText_getColor(const sfText* text);+++-- | Return the position of the ith character in a text.+--+-- This function computes the visual position of a character+-- from its index in the string. The returned position is+-- in global coordinates (translation, rotation, scale and+-- origin are applied).+--+-- If the index is out of range, the position of the end of+-- the string is returned.+findTextCharacterPos+    :: Text+    -> Int -- ^ Index of the character+    -> IO Vec2f++findTextCharacterPos text idx =+    alloca $ \ptr -> sfText_findCharacterPos_helper text (fromIntegral idx) ptr >> peek ptr++foreign import ccall unsafe "sfText_findCharacterPos_helper"+    sfText_findCharacterPos_helper :: Text -> CUInt -> Ptr Vec2f -> IO ()++--CSFML_GRAPHICS_API sfVector2f sfText_findCharacterPos(const sfText* text, size_t index);+++-- | Get the local bounding rectangle of a text.+--+-- The returned rectangle is in local coordinates, which means+-- that it ignores the transformations (translation, rotation,+-- scale, ...) that are applied to the entity.+--+-- In other words, this function returns the bounds of the+-- entity in the entity's coordinate system.+getTextLocalBounds :: Text -> IO FloatRect+getTextLocalBounds text = alloca $ \ptr -> sfText_getLocalBounds_helper text ptr >> peek ptr++foreign import ccall unsafe "sfText_getLocalBounds_helper"+    sfText_getLocalBounds_helper :: Text -> Ptr FloatRect -> IO ()++--CSFML_GRAPHICS_API sfFloatRect sfText_getLocalBounds(const sfText* text);+++-- | Get the global bounding rectangle of a text.+--+-- The returned rectangle is in global coordinates, which means+-- that it takes in account the transformations (translation,+-- rotation, scale, ...) that are applied to the entity.+--+-- In other words, this function returns the bounds of the+-- text in the global 2D world's coordinate system.+getTextGlobalBounds :: Text -> IO FloatRect+getTextGlobalBounds text = alloca $ \ptr -> sfText_getGlobalBounds_helper text ptr >> peek ptr++foreign import ccall unsafe "sfText_getGlobalBounds_helper"+    sfText_getGlobalBounds_helper :: Text -> Ptr FloatRect -> IO ()++--CSFML_GRAPHICS_API sfFloatRect sfText_getGlobalBounds(const sfText* text);+
+ src/SFML/Graphics/Texture.hs view
@@ -0,0 +1,354 @@+{-# LANGUAGE DeriveDataTypeable #-}+module SFML.Graphics.Texture+(+    module SFML.Utils+,   TextureException(..)+,   nullTexture+,   createTexture+,   textureFromFile+,   textureFromMemory+,   textureFromStream+,   textureFromImage+,   copy+,   destroy+,   textureSize+,   copyTextureToImage+,   updateTextureFromPixels+,   updateTextureFromImage+,   updateTextureFromWindow+,   updateTextureFromRenderWindow+,   bind+,   setSmooth+,   isSmooth+,   setRepeated+,   isRepeated+,   textureMaxSize+)+where+++import SFML.Graphics.Rect+import SFML.Graphics.SFBindable+import SFML.Graphics.SFSmoothTexture+import SFML.Graphics.Types+import SFML.Window.Types+import SFML.SFCopyable+import SFML.SFResource+import SFML.System.InputStream+import SFML.System.Vector2+import SFML.Utils++import Control.Exception+import Data.Typeable+import Foreign.C.String+import Foreign.C.Types+import Foreign.Marshal.Alloc (alloca)+import Foreign.Marshal.Utils (with)+import Foreign.Ptr+import Foreign.Storable (peek)+import System.IO.Unsafe+++checkNull :: Texture -> Maybe Texture+checkNull tex@(Texture ptr) = if ptr == nullPtr then Nothing else Just tex+++data TextureException = TextureException String deriving (Show, Typeable)++instance Exception TextureException+++-- | A null texture.+nullTexture = Texture nullPtr+++-- | Create a new texture.+createTexture+    :: Int -- ^ Texture width+    -> Int -- ^ Texture height+    -> IO (Either TextureException Texture)++createTexture w h =+    let err = TextureException "Failed creating texture"+    in fmap (tagErr err . checkNull) $ sfTexture_create (fromIntegral w) (fromIntegral h)++foreign import ccall unsafe "sfTexture_create"+    sfTexture_create :: CUInt -> CUInt -> IO Texture++-- \return A new sfTexture object, or NULL if it failed++--CSFML_GRAPHICS_API sfTexture* sfTexture_create(unsigned int width, unsigned int height);+++-- | Create a new texture from a file.+textureFromFile+    :: FilePath -- ^ Path of the image file to load+    -> Maybe IntRect  -- ^ Area of the source image to load ('Nothing' to load the entire image)+    -> IO (Either TextureException Texture)++textureFromFile path rect =+    let err = TextureException $ "Failed loading texture from file " ++ show path+    in withCAString path $ \cpath ->+       fmap (tagErr err . checkNull) $+           case rect of+               Nothing -> sfTexture_createFromFile cpath nullPtr+               Just r  -> with r $ sfTexture_createFromFile cpath++foreign import ccall unsafe "sfTexture_createFromFile"+    sfTexture_createFromFile :: CString -> Ptr IntRect -> IO Texture++-- \return A new sfTexture object, or NULL if it failed++--CSFML_GRAPHICS_API sfTexture* sfTexture_createFromFile(const char* filename, const sfIntRect* area);+++-- | Create a new texture from a file in memory.+textureFromMemory+    :: Ptr a   -- ^ Pointer to the file data in memory+    -> Int     -- ^ Size of the data to load, in bytes+    -> Maybe IntRect -- ^ Area of the source image to load ('Nothing' to load the entire image)+    -> IO (Either TextureException Texture)++textureFromMemory pixels size rect =+    let err = TextureException $ "Failed creating texture from memory address " ++ show pixels+    in fmap (tagErr err . checkNull) $ case rect of+           Nothing -> sfTexture_createFromMemory pixels (fromIntegral size) nullPtr+           Just r  -> with r $ sfTexture_createFromMemory pixels (fromIntegral size)++foreign import ccall unsafe "sfTexture_createFromMemory"+    sfTexture_createFromMemory :: Ptr a -> CUInt -> Ptr IntRect -> IO Texture++-- \return A new sfTexture object, or NULL if it failed++--CSFML_GRAPHICS_API sfTexture* sfTexture_createFromMemory(const void* data, size_t sizeInBytes, const sfIntRect* area);+++-- | Create a new texture from a custom stream.+textureFromStream+    :: InputStream -- ^ Source stream to read from+    -> Maybe IntRect     -- ^ Area of the source image to load ('Nothing' to load the entire image)+    -> IO (Either TextureException Texture)++textureFromStream stream rect =+    let err = TextureException $ "Failed creating texture from input stream " ++ show stream+    in fmap (tagErr err . checkNull) $+       with stream $ \streamPtr ->+       case rect of+           Nothing -> sfTexture_createFromStream streamPtr nullPtr+           Just r  -> with r $ sfTexture_createFromStream streamPtr++foreign import ccall "sfTexture_createFromStream"+     sfTexture_createFromStream :: Ptr InputStream -> Ptr IntRect -> IO Texture++-- \return A new sfTexture object, or NULL if it failed++--CSFML_GRAPHICS_API sfTexture* sfTexture_createFromStream(sfInputStream* stream, const sfIntRect* area);+++-- | Create a new texture from an image.+textureFromImage+    :: Image -- ^ Image to upload to the texture+    -> Maybe IntRect -- ^ Area of the source image to load ('Nothing' to load the entire image)+    -> IO (Either TextureException Texture)++textureFromImage image rect =+    let (Image addr) = image+        err = TextureException $ "Failed creating texture from image " ++ show addr+    in fmap (tagErr err . checkNull) $ case rect of+           Nothing -> sfTexture_createFromImage image nullPtr+           Just r  -> with r $ sfTexture_createFromImage image++foreign import ccall unsafe "sfTexture_createFromImage"+    sfTexture_createFromImage :: Image -> Ptr IntRect -> IO Texture++-- \return A new sfTexture object, or NULL if it failed++--CSFML_GRAPHICS_API sfTexture* sfTexture_createFromImage(const sfImage* image, const sfIntRect* area);+++instance SFCopyable Texture where++    {-# INLINABLE copy #-}+    copy = sfTexture_copy+++foreign import ccall unsafe "sfTexture_copy"+    sfTexture_copy :: Texture -> IO Texture++--CSFML_GRAPHICS_API sfTexture* sfTexture_copy(sfTexture* texture);+++instance SFResource Texture where++    {-# INLINABLE destroy #-}+    destroy = sfTexture_destroy++foreign import ccall unsafe "sfTexture_destroy"+    sfTexture_destroy :: Texture -> IO ()++--CSFML_GRAPHICS_API void sfTexture_destroy(sfTexture* texture);+++-- | Return the size of the texture in pixels.+textureSize :: Texture -> IO Vec2u+textureSize tex = alloca $ \ptr -> sfTexture_getSize_helper tex ptr >> peek ptr++foreign import ccall unsafe "sfTexture_getSize_helper"+    sfTexture_getSize_helper :: Texture -> Ptr Vec2u -> IO ()++--CSFML_GRAPHICS_API sfVector2u sfTexture_getSize(const sfTexture* texture);+++-- | Copy a texture's pixels to an image+copyTextureToImage :: Texture -> IO Image+copyTextureToImage = sfTexture_copyToImage++foreign import ccall unsafe "sfTexture_copyToImage"+    sfTexture_copyToImage :: Texture -> IO Image++--CSFML_GRAPHICS_API sfImage* sfTexture_copyToImage(const sfTexture* texture);+++-- | Update a texture from an array of pixels.+updateTextureFromPixels+    :: Texture -- ^ Texture to update+    -> Ptr a   -- ^ Array of pixels to copy to the texture+    -> Int     -- ^ Width of the pixel region contained in the pixels array+    -> Int     -- ^ Height of the pixel region contained in the pixels array+    -> Int     -- ^ X offset in the texture where to copy the source pixels+    -> Int     -- ^ Y offset in the texture where to copy the source pixels+    -> IO ()++updateTextureFromPixels tex pixels w h x y =+    sfTexture_updateFromPixels tex pixels (fromIntegral w) (fromIntegral h) (fromIntegral x) (fromIntegral y)++foreign import ccall unsafe "sfTexture_updateFromPixels"+    sfTexture_updateFromPixels :: Texture -> Ptr a -> CUInt -> CUInt -> CUInt -> CUInt -> IO ()++--CSFML_GRAPHICS_API void sfTexture_updateFromPixels(sfTexture* texture, const sfUint8* pixels, unsigned int width, unsigned int height, unsigned int x, unsigned int y);+++-- | Update a texture from an image.+updateTextureFromImage+    :: Texture -- ^ Texture to update+    -> Image   -- ^ Image to copy to the texture+    -> Int     -- ^ X offset in the texture where to copy the source pixels+    -> Int     -- ^ Y offset in the texture where to copy the source pixels+    -> IO ()++updateTextureFromImage tex image x y+    = sfTexture_updateFromImage tex image (fromIntegral x) (fromIntegral y)++foreign import ccall unsafe "sfTexture_updateFromImage"+    sfTexture_updateFromImage :: Texture -> Image -> CUInt -> CUInt -> IO ()++--CSFML_GRAPHICS_API void sfTexture_updateFromImage(sfTexture* texture, const sfImage* image, unsigned int x, unsigned int y);+++-- | Update a texture from the contents of a window.+updateTextureFromWindow+    :: Texture -- ^ Texture to update+    -> Window  -- ^ Window to copy to the texture+    -> Int     -- ^ X offset in the texture where to copy the source pixels+    -> Int     -- ^ Y offset in the texture where to copy the source pixels+    -> IO ()++updateTextureFromWindow tex wnd x y+    = sfTexture_updateFromWindow tex wnd (fromIntegral x) (fromIntegral y)++foreign import ccall unsafe "sfTexture_updateFromWindow"+    sfTexture_updateFromWindow :: Texture -> Window -> CUInt -> CUInt -> IO ()++--CSFML_GRAPHICS_API void sfTexture_updateFromWindow(sfTexture* texture, const sfWindow* window, unsigned int x, unsigned int y);+++-- | Update a texture from the contents of a render-window.+updateTextureFromRenderWindow+    :: Texture      -- ^ Texture to update+    -> RenderWindow -- ^ Render-window to copy to the texture+    -> Int          -- ^ X offset in the texture where to copy the source pixels+    -> Int          -- ^ Y offset in the texture where to copy the source pixels+    -> IO ()++updateTextureFromRenderWindow tex rwnd x y+    = sfTexture_updateFromRenderWindow tex rwnd (fromIntegral x) (fromIntegral y)++foreign import ccall unsafe "sfTexture_updateFromRenderWindow"+    sfTexture_updateFromRenderWindow :: Texture -> RenderWindow -> CUInt -> CUInt -> IO ()++--CSFML_GRAPHICS_API void sfTexture_updateFromRenderWindow(sfTexture* texture, const sfRenderWindow* renderWindow, unsigned int x, unsigned int y);+++instance SFBindable Texture where+         {-# INLINABLE bind #-}+         bind = sfTexture_bind++foreign import ccall unsafe "sfTexture_bind"+    sfTexture_bind :: Texture -> IO ()++--CSFML_GRAPHICS_API void sfTexture_bind(const sfTexture* texture);+++instance SFSmoothTexture Texture where++    {-# INLINABLE setSmooth #-}+    setSmooth tex val  = sfTexture_setSmooth tex (fromIntegral . fromEnum $ val)++    {-# INLINABLE isSmooth #-}+    isSmooth = fmap (/=0) . sfTexture_isSmooth++foreign import ccall unsafe "sfTexture_setSmooth"+    sfTexture_setSmooth :: Texture -> CInt -> IO ()++--CSFML_GRAPHICS_API void sfTexture_setSmooth(sfTexture* texture, sfBool smooth);++foreign import ccall unsafe "sfTexture_isSmooth"+    sfTexture_isSmooth :: Texture -> IO CInt++--CSFML_GRAPHICS_API sfBool sfTexture_isSmooth(const sfTexture* texture);+++-- | Enable or disable repeating for a texture.+--+-- Repeating is involved when using texture coordinates+-- outside the texture rectangle [0, 0, width, height].+-- In this case, if repeat mode is enabled, the whole texture+-- will be repeated as many times as needed to reach the+-- coordinate (for example, if the X texture coordinate is+-- 3 * width, the texture will be repeated 3 times).+-- If repeat mode is disabled, the "extra space" will instead+-- be filled with border pixels.+--+-- Warning: on very old graphics cards, white pixels may appear+-- when the texture is repeated. With such cards, repeat mode+-- can be used reliably only if the texture has power-of-two+-- dimensions (such as 256x128).+-- Repeating is disabled by default.+setRepeated :: Texture -> Bool -> IO ()+setRepeated tex True  = sfTexture_setRepeated tex 1+setRepeated tex False = sfTexture_setRepeated tex 0++foreign import ccall unsafe "sfTexture_setRepeated"+    sfTexture_setRepeated :: Texture -> CInt -> IO ()++--CSFML_GRAPHICS_API void sfTexture_setRepeated(sfTexture* texture, sfBool repeated);+++-- | Tell whether a texture is repeated or not+isRepeated :: Texture -> IO Bool+isRepeated = fmap (/=0) . sfTexture_isRepeated++foreign import ccall unsafe "sfTexture_isRepeated"+    sfTexture_isRepeated :: Texture -> IO CInt++--CSFML_GRAPHICS_API sfBool sfTexture_isRepeated(const sfTexture* texture);+++-- | The maximum texture size allowed in pixels.+textureMaxSize :: Int+textureMaxSize = unsafeDupablePerformIO $ fmap fromIntegral sfTexture_getMaximumSize++foreign import ccall unsafe "sfTexture_getMaximumSize"+    sfTexture_getMaximumSize :: IO CUInt++--CSFML_GRAPHICS_API unsigned int sfTexture_getMaximumSize();
+ src/SFML/Graphics/Transform.hsc view
@@ -0,0 +1,303 @@+{-# LANGUAGE CPP #-}+module SFML.Graphics.Transform+(+    Transform+,   m00, m10, m20+,   m01, m11, m21+,   m02, m12, m22+,   createTransform+,   idTransform+,   translation+,   rotation+,   rotationWithCenter+,   scaling+,   scalingWithCenter+,   inverse+,   fastInverse+,   transformPoint+,   transformDir+,   transformRect+)+where+++import SFML.Graphics.Rect+import SFML.Graphics.Types+import SFML.System.Vector2++import Data.List (foldl')+import Foreign.C.Types+import Foreign.Storable+++sizeFloat = #{size float}+++-- | Encapsulate a 3x3 transform matrix.+data Transform = Transform+    { m00 :: !Float, m10 :: !Float, m20 :: !Float+    , m01 :: !Float, m11 :: !Float, m21 :: !Float+    , m02 :: !Float, m12 :: !Float, m22 :: !Float+    }+++instance Storable Transform where+    sizeOf _ = 9 * sizeFloat+    alignment _ = alignment (undefined :: CFloat)+    +    peek ptr = do+        m00 <- fmap realToFrac $ (peekByteOff ptr 0 :: IO CFloat)+        m01 <- fmap realToFrac $ (peekByteOff ptr sizeFloat :: IO CFloat)+        m02 <- fmap realToFrac $ (peekByteOff ptr $ 2*sizeFloat :: IO CFloat)+        m10 <- fmap realToFrac $ (peekByteOff ptr $ 3*sizeFloat :: IO CFloat)+        m11 <- fmap realToFrac $ (peekByteOff ptr $ 4*sizeFloat :: IO CFloat)+        m12 <- fmap realToFrac $ (peekByteOff ptr $ 5*sizeFloat :: IO CFloat)+        m20 <- fmap realToFrac $ (peekByteOff ptr $ 6*sizeFloat :: IO CFloat)+        m21 <- fmap realToFrac $ (peekByteOff ptr $ 7*sizeFloat :: IO CFloat)+        m22 <- fmap realToFrac $ (peekByteOff ptr $ 8*sizeFloat :: IO CFloat)+        return $ Transform m00 m01 m02 m10 m11 m12 m20 m21 m22+    +    poke ptr (Transform m00 m01 m02 m10 m11 m12 m20 m21 m22) = do+        pokeByteOff ptr 0 (realToFrac m00 :: CFloat)+        pokeByteOff ptr sizeFloat (realToFrac m01 :: CFloat)+        pokeByteOff ptr (2*sizeFloat) (realToFrac m02 :: CFloat)+        pokeByteOff ptr (3*sizeFloat) (realToFrac m10 :: CFloat)+        pokeByteOff ptr (4*sizeFloat) (realToFrac m11 :: CFloat)+        pokeByteOff ptr (5*sizeFloat) (realToFrac m12 :: CFloat)+        pokeByteOff ptr (6*sizeFloat) (realToFrac m20 :: CFloat)+        pokeByteOff ptr (7*sizeFloat) (realToFrac m21 :: CFloat)+        pokeByteOff ptr (8*sizeFloat) (realToFrac m22 :: CFloat)+++instance Num Transform where+    (Transform a00 a01 a02 a03 a04 a05 a06 a07 a08)+        + (Transform b00 b01 b02 b03 b04 b05 b06 b07 b08)+            = Transform (a00 + b00) (a01 + b01) (a02 + b02)+                        (a03 + b03) (a04 + b04) (a05 + b05)+                        (a06 + b06) (a07 + b07) (a08 + b08)+    +    (Transform a00 a01 a02 a03 a04 a05 a06 a07 a08)+        - (Transform b00 b01 b02 b03 b04 b05 b06 b07 b08)+            = Transform (a00 - b00) (a01 - b01) (a02 - b02)+                        (a03 - b03) (a04 - b04) (a05 - b05)+                        (a06 - b06) (a07 - b07) (a08 - b08)+    +    (Transform a00 a10 a20 a01 a11 a21 a02 a12 a22)+        * (Transform b00 b10 b20 b01 b11 b21 b02 b12 b22)+            = Transform (a00 * b00 + a10 * b01 + a20 * b02)+                        (a00 * b10 + a10 * b11 + a20 * b12)+                        (a00 * b20 + a10 * b21 + a20 * b22)+                        +                        (a01 * b00 + a11 * b01 + a21 * b02)+                        (a01 * b10 + a11 * b11 + a21 * b12)+                        (a01 * b20 + a11 * b21 + a21 * b22)+                        +                        (a02 * b00 + a12 * b01 + a22 * b02)+                        (a02 * b10 + a12 * b11 + a22 * b12)+                        (a02 * b20 + a12 * b21 + a22 * b22)+    +    abs (Transform a00 a01 a02 a03 a04 a05 a06 a07 a08) =+        (Transform (abs a00) (abs a01) (abs a02) (abs a03)+            (abs a04) (abs a05) (abs a06) (abs a07) (abs a08))+    +    signum (Transform a00 a01 a02 a03 a04 a05 a06 a07 a08) =+        (Transform (signum a00) (signum a01) (signum a02) (signum a03)+            (signum a04) (signum a05) (signum a06) (signum a07) (signum a08))+    +    fromInteger i = Transform i' i' i' i' i' i' i' i' i' where i' = fromInteger i+++-- | Create a new transform from a matrix.+createTransform+    :: Float -- ^ Element (0, 0) of the matrix+    -> Float -- ^ Element (0, 1) of the matrix+    -> Float -- ^ Element (0, 2) of the matrix+    -> Float -- ^ Element (1, 0) of the matrix+    -> Float -- ^ Element (1, 1) of the matrix+    -> Float -- ^ Element (1, 2) of the matrix+    -> Float -- ^ Element (2, 0) of the matrix+    -> Float -- ^ Element (2, 1) of the matrix+    -> Float -- ^ Element (2, 2) of the matrix+    -> Transform++createTransform = Transform+++-- | Identity transform.+idTransform :: Transform+idTransform = Transform 1 0 0 0 1 0 0 0 1+++-- | Create a translation.+translation+    :: Float -- ^ Offset to apply on X axis+    -> Float -- ^ Offset to apply on Y axis+    -> Transform++translation x y = Transform+    1 0 x+    0 1 y+    0 0 1++-- | Create a rotation.+rotation+    :: Float -- ^ Rotation angle in degrees+    -> Transform++rotation deg =+    let rad = deg * pi / 180+        sa  = sin rad+        ca  = cos rad+    in Transform+        ca (-sa) 0+        sa   ca  0+        0    0   1++-- | Create a rotation.+--+-- The center of rotation is provided for convenience as a second+-- argument, so that you can build rotations around arbitrary points+-- more easily (and efficiently) than the usual+-- [translate(-center), rotate(angle), translate(center)].+rotationWithCenter+    :: Float -- ^ Rotation angle, in degrees+    -> Float -- ^ X coordinate of the center of rotation+    -> Float -- ^ Y coordinate of the center of rotation+    -> Transform++rotationWithCenter deg x y =+    let rad = deg * pi / 180+        ca  = cos rad+        sa  = sin rad+    in Transform+        ca (-sa) (x * (1 - ca) + y * sa)+        sa   ca  (y * (1 - ca) - x * sa)+        0    0    1+++-- | Create a scaling.+scaling+    :: Float -- ^ Scaling factor on the X axis+    -> Float -- ^ Scaling factor on the Y axis+    -> Transform++scaling x y = Transform+    x 0 0+    0 y 0+    0 0 1+++-- | Create a scaling.+--+-- The center of scaling is provided for convenience as a second+-- argument, so that you can build scaling around arbitrary points+-- more easily (and efficiently) than the usual+-- [translate(-center), scale(factors), translate(center)]+scalingWithCenter+    :: Float -- ^ Scaling factor on X axis+    -> Float -- ^ Scaling factor on Y axis+    -> Float -- ^ X coordinate of the center of scaling+    -> Float -- ^ Y coordinate of the center of scaling+    -> Transform++scalingWithCenter sx sy cx cy = Transform+    sx 0  (cx * (1 - sx))+    0  sy (cy * (1 - sy))+    0  0   1+++-- | Return the determinant of the transform.+determinant :: Transform -> Float+determinant (Transform m00 m10 m20 m01 m11 m21 m02 m12 m22)+    = m00 * (m11 * m22 - m12 * m21)+    + m01 * (m12 * m20 - m10 * m22)+    + m02 * (m10 * m21 - m11 * m20)+++-- | Return the inverse of a transform.+--+-- If the inverse cannot be computed, a new identity transform+-- is returned.+inverse :: Transform -> Transform+inverse t@(Transform m00 m10 m20 m01 m11 m21 m02 m12 m22) =+    let det = determinant t+        det_inv = 1 / det+        t00 =   m11 * m22 - m12 * m21+        t01 = - m10 * m22 + m12 * m20+        t02 =   m10 * m21 - m11 * m20+        t10 = - m01 * m22 + m02 * m21+        t11 =   m00 * m22 - m02 * m20+        t12 = - m00 * m21 + m01 * m20+        t20 =   m01 * m12 - m02 * m11+        t21 = - m00 * m12 + m02 * m10+        t22 =   m00 * m11 - m01 * m10+    in+        if determinant t /= 0 then Transform+            (t00*det_inv) (t01*det_inv) (t02*det_inv)+            (t10*det_inv) (t11*det_inv) (t12*det_inv)+            (t20*det_inv) (t21*det_inv) (t22*det_inv)+        else+            idTransform+++-- | Return the inverse of a transform.+--+-- This function is only applicable when the transform is composed+-- of rotations and translations only.+fastInverse :: Transform -> Transform+fastInverse mat =+    let rx = m00 mat+        ry = m01 mat+        fx = m10 mat+        fy = m11 mat+        tx = (-m20 mat)+        ty = (-m21 mat)+    in Transform+        rx ry (tx*rx + ty*ry)+        fx fy (tx*fx + ty*fy)+        0  0   1+++-- | Apply a transform to a 2D point.+transformPoint :: Transform -> Vec2f -> Vec2f+transformPoint (Transform m00 m10 m20 m01 m11 m21 _ _ _) (Vec2f x y) = Vec2f x' y'+    where+        x' = m00 * x + m10 * y + m20+        y' = m01 * x + m11 * y + m21+++-- | Apply a transform to a 2D direction vector.+transformDir :: Transform -> Vec2f -> Vec2f+transformDir (Transform m00 m10 _ m01 m11 _ _ _ _) (Vec2f x y) = Vec2f x' y'+    where+        x' = m00 * x + m10 * y+        y' = m01 * x + m11 * y+++-- | Apply a transform to a rectangle.+--+-- Since SFML doesn't provide support for oriented rectangles,+-- the result of this function is always an axis-aligned+-- rectangle, which means that if the transform contains a+-- rotation, the bounding rectangle of the transformed rectangle+-- is returned.+transformRect :: Transform -> FloatRect -> FloatRect+transformRect transf (FloatRect l t w h) = FloatRect l' t' w' h'+    where+        p0@(Vec2f p0x p0y) = transformPoint transf (Vec2f l $ t)+        p1@(Vec2f p1x p1y) = transformPoint transf (Vec2f l $ t + h)+        p2@(Vec2f p2x p2y) = transformPoint transf (Vec2f (l + w) t)+        p3@(Vec2f p3x p3y) = transformPoint transf (Vec2f (l + w) (t + h))+        +        left   = p0x;+        top    = p0y;+        right  = p0x;+        bottom = p0y;+        +        l' = min p3x $ min p2x $ min p1x p0x+        t' = min p3y $ min p2y $ min p1y p0y+        r' = max p3x $ max p2x $ max p1x p0x+        b' = max p3y $ max p2y $ max p1y p0y+        w' = r' - l'+        h' = b' - t'+
+ src/SFML/Graphics/Transformable.hs view
@@ -0,0 +1,93 @@+module SFML.Graphics.Transformable+where+++import SFML.Graphics.Transform+import SFML.System.Vector2+++class Transformable a where+    +    -- | Set the position of a transformable.+    --+    -- This function completely overwrites the previous position.+    --+    -- See 'move' to apply an offset based on the previous position instead.+    --+    -- The default position of a transformable object is (0, 0).+    setPosition :: a -> Vec2f -> IO ()+    +    -- | Set the orientation of a transformable.+    --+    -- This function completely overwrites the previous rotation.+    --+    -- See 'rotate' to add an angle based on the previous rotation instead.+    --+    -- The default rotation of a transformable Transformable object is 0.+    setRotation+        :: a+        -> Float -- ^ New rotation, in degrees+        -> IO ()+    +    -- | Set the scale factors of a transformable.+    --+    -- This function completely overwrites the previous scale.+    --+    -- See 'scale' to add a factor based on the previous scale instead.+    --+    -- The default scale of a transformable Transformable object is (1, 1).+    setScale :: a -> Vec2f -> IO ()+    +    -- | Set the local origin of a transformable.+    --+    -- The origin of an object defines the center point for+    -- all transformations (position, scale, rotation).+    --+    -- The coordinates of this point must be relative to the+    -- top-left corner of the object, and ignore all+    -- transformations (position, scale, rotation).+    --+    -- The default origin of a transformable Transformable object is (0, 0).+    setOrigin :: a -> Vec2f -> IO ()+    +    -- | Get the position of a transformable.+    getPosition :: a -> IO Vec2f+    +    -- | Get the orientation of a transformable.+    getRotation+        :: a+        -> IO Float -- ^ Current rotation, in degrees+    +    -- | Get the current scale of a transformable+    getScale :: a -> IO Vec2f+    +    -- | Get the local origin of a transformable.+    getOrigin :: a -> IO Vec2f+    +    -- | Move a transformable by a given offset+    --+    -- This function adds to the current position of the object,+    -- unlike 'setPosition' which overwrites it.+    move :: a -> Vec2f -> IO ()+    +    -- | Rotate a transformable.+    --+    -- This function adds to the current rotation of the object,+    -- unlike 'setRotation' which overwrites it.+    rotate+        :: a+        -> Float -- ^ Angle of rotation, in degrees+        -> IO ()+    +    -- | Scale a transformable.+    --+    -- This function multiplies the current scale of the object,+    -- unlike 'setScale' which overwrites it.+    scale :: a -> Vec2f -> IO ()+    +    -- | Get the combined transform of a transformable.+    getTransform :: a -> IO Transform+    +    -- | Get the inverse of the combined transform of a transformable.+    getInverseTransform :: a -> IO Transform+
+ src/SFML/Graphics/Types.hs view
@@ -0,0 +1,40 @@+module SFML.Graphics.Types+where+++import Foreign.C.Types (CInt)+import Foreign.Ptr+import Foreign.Storable+++newtype CircleShape = CircleShape (Ptr CircleShape)+newtype ConvexShape = ConvexShape (Ptr ConvexShape)+newtype Font = Font (Ptr Font)+newtype Image = Image (Ptr Image)+newtype Shader = Shader (Ptr Shader)+newtype RectangleShape = RectangleShape (Ptr RectangleShape)+newtype RenderTexture = RenderTexture (Ptr RenderTexture)+newtype RenderWindow = RenderWindow (Ptr RenderWindow)+newtype Shape = Shape (Ptr Shape)+newtype Sprite = Sprite (Ptr Sprite)+newtype Text = Text (Ptr Text)+newtype Texture = Texture (Ptr Texture)+newtype VertexArray = VertexArray (Ptr VertexArray)+newtype View = View (Ptr View)+++instance Storable Texture where+    sizeOf _ = sizeOf (undefined :: CInt)+    alignment _ = alignment (undefined :: CInt)+    +    peek ptr = peek (castPtr ptr) >>= return . Texture+    poke ptr (Texture p) = poke (castPtr ptr) p+++instance Storable Shader where+    sizeOf _ = sizeOf (undefined :: CInt)+    alignment _ = alignment (undefined :: CInt)+    +    peek ptr = peek (castPtr ptr) >>= return . Shader+    poke ptr (Shader p) = poke (castPtr ptr) p+
+ src/SFML/Graphics/Vertex.hsc view
@@ -0,0 +1,51 @@+{-# LANGUAGE CPP, ForeignFunctionInterface #-}+module SFML.Graphics.Vertex+(+    Vertex(..)+)+where+++import SFML.Graphics.Color+import SFML.System.Vector2++import Foreign.C.Types (CFloat)+import Foreign.Storable++#include <SFML/Graphics/Vertex.h>+++-- | Define a point with color and texture coordinates.+data Vertex = Vertex+    { position  :: Vec2f+    , color     :: Color+    , texCoords :: Vec2f+    }+    deriving (Show)+++instance Storable Vertex where+    sizeOf _ = size_sfVertex+    alignment _ = alignment (undefined :: CFloat)+    +    peek ptr = do+        pos <- #{peek sfVertex, position} ptr+        col <- #{peek sfVertex, color} ptr+        tex <- #{peek sfVertex, texCoords} ptr+        return $ Vertex pos col tex+    +    poke ptr (Vertex pos col tex) = do+        #{poke sfVertex, position} ptr pos+        #{poke sfVertex, color} ptr col+        #{poke sfVertex, texCoords} ptr tex+++size_sfVertex = #{size sfVertex}++{-typedef struct+{+    sfVector2f position;  ///< Position of the vertex+    sfColor    color;     ///< Color of the vertex+    sfVector2f texCoords; ///< Coordinates of the texture's pixel to map to the vertex+} sfVertex;-}+
+ src/SFML/Graphics/VertexArray.hs view
@@ -0,0 +1,179 @@+module SFML.Graphics.VertexArray+(+    createVA+,   copy+,   destroy+,   getVertexCount+,   getVertex+,   clearVA+,   resizeVA+,   appendVA+,   setPrimitiveType+,   getPrimitiveType+,   getVABounds+)+where+++import SFML.Graphics.PrimitiveType+import SFML.Graphics.Rect+import SFML.Graphics.Types+import SFML.Graphics.Vertex+import SFML.SFCopyable+import SFML.SFResource++import Control.Monad+import Foreign.C.Types+import Foreign.Marshal.Alloc (alloca)+import Foreign.Marshal.Utils (with)+import Foreign.Ptr+import Foreign.Storable (peek)+++-- | Create a new vertex array.+createVA :: IO VertexArray+createVA = sfVertexArray_create++foreign import ccall unsafe "sfVertexArray_create"+    sfVertexArray_create :: IO VertexArray++--CSFML_GRAPHICS_API sfVertexArray* sfVertexArray_create(void);+++instance SFCopyable VertexArray where+    +    {-# INLINABLE copy #-}+    copy = sfVertexArray_copy+++foreign import ccall unsafe "sfVertexArray_copy"+    sfVertexArray_copy :: VertexArray -> IO VertexArray++--CSFML_GRAPHICS_API sfVertexArray* sfVertexArray_copy(sfVertexArray* vertexArray);+++instance SFResource VertexArray where+    +    {-# INLINABLE destroy #-}+    destroy = sfVertexArray_destroy++foreign import ccall unsafe "sfVertexArray_destroy"+    sfVertexArray_destroy :: VertexArray -> IO ()++--CSFML_GRAPHICS_API void sfVertexArray_destroy(sfVertexArray* vertexArray);+++-- | Return the vertex count of a vertex array.+getVertexCount :: VertexArray -> IO Int+getVertexCount = sfVertexArray_getVertexCount >=> return . fromIntegral++foreign import ccall unsafe "sfVertexArray_getVertexCount"+    sfVertexArray_getVertexCount :: VertexArray -> IO CUInt++--CSFML_GRAPHICS_API unsigned int sfVertexArray_getVertexCount(const sfVertexArray* vertexArray);+++-- | Return the ith vertex.++-- This function doesn't check the index; it must be in range+-- [0, vertex count - 1]. The behaviour is otherwise undefined.+getVertex :: VertexArray -> Int -> IO (Ptr Vertex)+getVertex va i = sfVertexArray_getVertex va (fromIntegral i)++foreign import ccall unsafe "sfVertexArray_getVertex"+    sfVertexArray_getVertex :: VertexArray -> CUInt -> IO (Ptr Vertex)++--CSFML_GRAPHICS_API sfVertex* sfVertexArray_getVertex(sfVertexArray* vertexArray, unsigned int index);+++-- | Clear a vertex array.+--+-- This function removes all the vertices from the array.+-- It doesn't deallocate the corresponding memory, so that+-- adding new vertices after clearing doesn't involve+-- reallocating all the memory.+clearVA :: VertexArray -> IO ()+clearVA = sfVertexArray_clear++foreign import ccall unsafe "sfVertexArray_clear"+    sfVertexArray_clear :: VertexArray -> IO ()++--CSFML_GRAPHICS_API void sfVertexArray_clear(sfVertexArray* vertexArray);+++-- | Resize the vertex array.+--+-- If vertex count is greater than the current size, the previous+-- vertices are kept and new (default-constructed) vertices are+-- added.+--+-- If vertex count is less than the current size, existing vertices+-- are removed from the array.+resizeVA+    :: VertexArray+    -> Int -- ^ Vertex count; New size of the array (number of vertices)+    -> IO ()++resizeVA va size = sfVertexArray_resize va (fromIntegral size)++foreign import ccall unsafe "sfVertexArray_resize"+    sfVertexArray_resize :: VertexArray -> CUInt -> IO ()++--CSFML_GRAPHICS_API void sfVertexArray_resize(sfVertexArray* vertexArray, unsigned int vertexCount);+++-- | Add a vertex to a vertex array array.+appendVA :: VertexArray -> Vertex -> IO ()+appendVA va v = with v $ sfVertexArray_append_helper va++foreign import ccall unsafe "sfVertexArray_append_helper"+    sfVertexArray_append_helper :: VertexArray -> Ptr Vertex -> IO ()++--CSFML_GRAPHICS_API void sfVertexArray_append(sfVertexArray* vertexArray, sfVertex vertex);+++-- | Set the type of primitives of a vertex array.+--+-- This function defines how the vertices must be interpreted+-- when it's time to draw them:+--+-- * As points+--+-- * As lines+--+-- * As triangles+--+-- * As quads+--+-- The default primitive type is sfPoints.+setPrimitiveType :: VertexArray -> PrimitiveType -> IO ()+setPrimitiveType va pt = sfVertexArray_setPrimitiveType va (fromIntegral . fromEnum $ pt)++foreign import ccall unsafe "sfVertexArray_setPrimitiveType"+    sfVertexArray_setPrimitiveType :: VertexArray -> CInt -> IO ()++--CSFML_GRAPHICS_API void sfVertexArray_setPrimitiveType(sfVertexArray* vertexArray, sfPrimitiveType type);+++-- | Get the type of primitives drawn by a vertex array.+getPrimitiveType :: VertexArray -> IO PrimitiveType+getPrimitiveType = sfVertexArray_getPrimitiveType >=> return . toEnum . fromIntegral++foreign import ccall unsafe "sfVertexArray_getPrimitiveType"+    sfVertexArray_getPrimitiveType :: VertexArray -> IO CInt++--CSFML_GRAPHICS_API sfPrimitiveType sfVertexArray_getPrimitiveType(sfVertexArray* vertexArray);+++-- | Compute the bounding rectangle of a vertex array.+--+-- This function returns the axis-aligned rectangle that+-- contains all the vertices of the array.+getVABounds :: VertexArray -> IO FloatRect+getVABounds va = alloca $ \ptr -> sfVertexArray_getBounds_helper va ptr >> peek ptr++foreign import ccall unsafe "sfVertexArray_getBounds_helper"+    sfVertexArray_getBounds_helper :: VertexArray -> Ptr FloatRect -> IO ()++--CSFML_GRAPHICS_API sfFloatRect sfVertexArray_getBounds(sfVertexArray* vertexArray);+
+ src/SFML/Graphics/View.hs view
@@ -0,0 +1,247 @@+module SFML.Graphics.View+(+    createView+,   viewFromRect+,   copyView+,   destroy+,   setViewCenter+,   setViewSize+,   setViewRotation+,   setViewport+,   resetView+,   getViewCenter+,   getViewSize+,   getViewRotation+,   getViewViewport+,   moveView+,   rotateView+,   zoomView+)+where+++import SFML.Graphics.Rect+import SFML.Graphics.Types+import SFML.SFResource+import SFML.System.Vector2++import Control.Monad ((>=>))+import Foreign.C.Types+import Foreign.Marshal.Alloc (alloca)+import Foreign.Marshal.Utils (with)+import Foreign.Ptr+import Foreign.Storable (peek)+++-- | Create a default view.+--+-- This function creates a default view of (0, 0, 1000, 1000)+createView :: IO View+createView = sfView_create++foreign import ccall unsafe "sfView_create"+    sfView_create :: IO View++--CSFML_GRAPHICS_API sfView* sfView_create(void);+++-- | Construct a view from a rectangle+viewFromRect+    :: FloatRect -- ^ Rectangle defining the zone to display+    -> IO View++viewFromRect rect = with rect sfView_createFromRect++foreign import ccall unsafe "sfView_createFromRect_helper"+    sfView_createFromRect :: Ptr FloatRect -> IO View++--CSFML_GRAPHICS_API sfView* sfView_createFromRect(sfFloatRect rectangle);+++-- | Copy an existing view.+copyView :: View -> IO View+copyView = sfView_copy++foreign import ccall unsafe "sfView_copy"+    sfView_copy :: View -> IO View++--CSFML_GRAPHICS_API sfView* sfView_copy(sfView* view);+++instance SFResource View where+    +    {-# INLINABLE destroy #-}+    destroy = sfView_destroy++foreign import ccall unsafe "sfView_destroy"+    sfView_destroy :: View -> IO ()++--CSFML_GRAPHICS_API void sfView_destroy(sfView* view);+++-- | Set the center of a view.+setViewCenter :: View -> Vec2f -> IO ()+setViewCenter view center = with center $ sfView_setCenter_helper view++foreign import ccall unsafe "sfView_setCenter_helper"+    sfView_setCenter_helper :: View -> Ptr Vec2f -> IO ()++--CSFML_GRAPHICS_API void sfView_setCenter(sfView* view, sfVector2f center);+++-- | Set the size of a view.+setViewSize :: View -> Vec2f -> IO ()+setViewSize view size = with size $ sfView_setSize_helper view++foreign import ccall unsafe "sfView_setSize_helper"+    sfView_setSize_helper :: View -> Ptr Vec2f -> IO ()++--CSFML_GRAPHICS_API void sfView_setSize(sfView* view, sfVector2f size);+++-- | Set the orientation of a view.+--+-- The default rotation of a view is 0 degrees.+setViewRotation+    :: View  -- ^ View object+    -> Float -- ^ New angle, in degrees+    -> IO ()++setViewRotation v r = sfView_setRotation v (realToFrac r)++foreign import ccall unsafe "sfView_setRotation"+    sfView_setRotation :: View -> CFloat -> IO ()++--CSFML_GRAPHICS_API void sfView_setRotation(sfView* view, float angle);+++-- | Set the target viewport of a view+--+-- The viewport is the rectangle into which the contents of the+-- view are displayed, expressed as a factor (between 0 and 1)+-- of the size of the render target to which the view is applied.+-- For example, a view which takes the left side of the target would+-- be defined by a rect of (0, 0, 0.5, 1).+--+-- By default, a view has a viewport which covers the entire target.+setViewport+    :: View -- ^ View object+    -> FloatRect -- ^ New viewport rectangle+    -> IO ()++setViewport view rect = with rect $ sfView_setViewport_helper view++foreign import ccall unsafe "sfView_setViewport_helper"+    sfView_setViewport_helper :: View -> Ptr FloatRect -> IO ()++--CSFML_GRAPHICS_API void sfView_setViewport(sfView* view, sfFloatRect viewport);+++-- | Reset a view to the given rectangle.+--+-- Note that this function resets the rotation angle to 0.+resetView+    :: View -- ^ View object+    -> FloatRect -- ^ Rectangle defining the zone to display+    -> IO ()++resetView view rect = with rect $ sfView_reset_helper view++foreign import ccall unsafe "sfView_reset_helper"+    sfView_reset_helper :: View -> Ptr FloatRect -> IO ()++--CSFML_GRAPHICS_API void sfView_reset(sfView* view, sfFloatRect rectangle);+++-- | Get the center of a view.+getViewCenter :: View -> IO Vec2f+getViewCenter view = alloca $ \ptr -> sfView_getCenter view ptr >> peek ptr++foreign import ccall unsafe "sfView_getCenter"+    sfView_getCenter :: View -> Ptr Vec2f -> IO ()++--CSFML_GRAPHICS_API sfVector2f sfView_getCenter(const sfView* view);+++-- | Get the size of a view.+getViewSize :: View -> IO Vec2f+getViewSize view = alloca $ \ptr -> sfView_getSize_helper view ptr >> peek ptr++foreign import ccall unsafe "sfView_getSize_helper"+    sfView_getSize_helper :: View -> Ptr Vec2f -> IO ()++--CSFML_GRAPHICS_API sfVector2f sfView_getSize(const sfView* view);+++-- | Get the current orientation of a view, in degrees.+getViewRotation :: View -> IO Float+getViewRotation = sfView_getRotation >=> return . realToFrac++foreign import ccall unsafe "sfView_getRotation"+    sfView_getRotation :: View -> IO CFloat++--CSFML_GRAPHICS_API float sfView_getRotation(const sfView* view);+++-- | Get the target viewport rectangle of a view, expressed as a factor of the target size.+getViewViewport :: View -> IO FloatRect+getViewViewport view = alloca $ \ptr -> sfView_getViewport_helper view ptr >> peek ptr++foreign import ccall unsafe "sfView_getViewport_helper"+    sfView_getViewport_helper :: View -> Ptr FloatRect -> IO ()++--CSFML_GRAPHICS_API sfFloatRect sfView_getViewport(const sfView* view);+++-- | Move a view relatively to its current position.+moveView+    :: View  -- ^ View object+    -> Vec2f -- ^ Offset+    -> IO ()++moveView view pos = with pos $ sfView_move_helper view++foreign import ccall unsafe "sfView_move_helper"+    sfView_move_helper :: View -> Ptr Vec2f -> IO ()++--CSFML_GRAPHICS_API void sfView_move(sfView* view, sfVector2f offset);+++-- | Rotate a view relatively to its current orientation.+rotateView+    :: View  -- ^ View object+    -> Float -- ^ Angle to rotate, in degrees+    -> IO ()++rotateView v a = sfView_rotate v (realToFrac a)++foreign import ccall unsafe "sfView_rotate"+    sfView_rotate :: View -> CFloat -> IO ()++--CSFML_GRAPHICS_API void sfView_rotate(sfView* view, float angle);+++-- | Resize a view rectangle relatively to its current size+--+-- Resizing the view simulates a zoom, as the zone displayed on+-- screen grows or shrinks.+--+-- factor is a multiplier:+--+-- * 1 keeps the size unchanged+--+-- * > 1 makes the view bigger (objects appear smaller)+--+-- * < 1 makes the view smaller (objects appear bigger)+zoomView+    :: View  -- ^ View object+    -> Float -- ^ Zoom factor to apply+    -> IO ()++zoomView v z = sfView_zoom v (realToFrac z)++foreign import ccall unsafe "sfView_zoom"+    sfView_zoom :: View -> CFloat -> IO ()++--CSFML_GRAPHICS_API void sfView_zoom(sfView* view, float factor);+
+ src/SFML/SFCopyable.hs view
@@ -0,0 +1,9 @@+module SFML.SFCopyable+where+++class SFCopyable a where+    +    -- | Copy the given SFML resource.+    copy :: a -> IO a+
+ src/SFML/SFDisplayable.hs view
@@ -0,0 +1,9 @@+module SFML.SFDisplayable+where+++class SFDisplayable a where+    +    -- | Update the target's contents.+    display :: a -> IO ()+
+ src/SFML/SFResource.hs view
@@ -0,0 +1,9 @@+module SFML.SFResource+where+++class SFResource a where+    +    -- | Destroy the given SFML resource.+    destroy :: a -> IO ()+
+ src/SFML/System.hs view
@@ -0,0 +1,17 @@+module SFML.System+(+    module SFML.System.Clock+,   module SFML.System.Sleep+,   module SFML.System.Time+,   module SFML.System.Vector2+,   module SFML.System.Vector3+)+where+++import SFML.System.Clock+import SFML.System.Sleep+import SFML.System.Time+import SFML.System.Vector2+import SFML.System.Vector3+
+ src/SFML/System/Clock.hs view
@@ -0,0 +1,86 @@+{-# LANGUAGE CPP, ForeignFunctionInterface #-}+module SFML.System.Clock+(+    Clock(..)+,   createClock+,   copy+,   destroy+,   getElapsedTime+,   restartClock+)+where+++import SFML.SFCopyable+import SFML.SFResource+import SFML.System.Time++import Foreign.Marshal.Alloc (alloca)+import Foreign.Ptr+import Foreign.Storable (peek)+++newtype Clock = Clock (Ptr Clock)+++-- | Create a new clock and start it.+createClock :: IO Clock+createClock = sfClock_create++foreign import ccall unsafe "sfClock_create"+    sfClock_create :: IO Clock++--CSFML_SYSTEM_API sfClock* sfClock_create(void);+++instance SFCopyable Clock where+    +    {-# INLINABLE copy #-}+    copy = sfClock_copy+++foreign import ccall unsafe "sfClock_copy"+    sfClock_copy :: Clock -> IO Clock++--CSFML_SYSTEM_API sfClock* sfClock_copy(sfClock* clock);+++instance SFResource Clock where+    +    {-# INLINABLE destroy #-}+    destroy = sfClock_destroy++foreign import ccall unsafe "sfClock_destroy"+    sfClock_destroy :: Clock -> IO ()++--CSFML_SYSTEM_API void sfClock_destroy(sfClock* clock);+++-- | Get the time elapsed in a clock.+--+-- This function returns the time elapsed since the last call+-- to sfClock_restart (or the construction of the object if+-- sfClock_restart has not been called).++getElapsedTime :: Clock -> IO Time+getElapsedTime clock = alloca $ \ptr -> sfClock_getElapsedTime_helper clock ptr >> peek ptr++foreign import ccall unsafe "sfClock_getElapsedTime_helper"+    sfClock_getElapsedTime_helper :: Clock -> Ptr Time -> IO ()++--CSFML_SYSTEM_API sfTime sfClock_getElapsedTime(const sfClock* clock);+++-- | Restart a clock.+--+-- This function puts the time counter back to zero.+-- It also returns the time elapsed since the clock was started.++restartClock :: Clock -> IO Time+restartClock clock = alloca $ \ptr -> sfClock_restart_helper clock ptr >> peek ptr++foreign import ccall unsafe "sfClock_restart_helper"+    sfClock_restart_helper :: Clock -> Ptr Time -> IO ()++--CSFML_SYSTEM_API sfTime sfClock_restart(sfClock* clock);+
+ src/SFML/System/InputStream.hsc view
@@ -0,0 +1,87 @@+{-# LANGUAGE CPP, ForeignFunctionInterface, ExistentialQuantification #-}+module SFML.System.InputStream+(+    InputStreamReadFunc+,   InputStreamSeekFunc+,   InputStreamTellFunc+,   InputStreamGetSizeFunc+,   InputStream(..)+)+where+++import Data.Word (Word64)+import Foreign.C.Types (CInt)+import Foreign.Ptr (Ptr)+import Foreign.Storable+++#include <SFML/System/InputStream.h>+++-- | Function to read data from the stream.+type InputStreamReadFunc a+    =  Ptr Char  -- ^ Buffer where to copy the read data+    -> Word64    -- ^ Desired number of bytes to read+    -> Ptr a     -- ^ User data+    -> IO Word64 -- ^ The number of bytes actually read++-- | Function to set the current read position.+type InputStreamSeekFunc a+    =  Word64    -- ^ The position to seek to, from the beginning+    -> Ptr a     -- ^ User data+    -> IO Word64 -- ^ The position actually sought to, or -1 on error++-- | Function to get the current read position.+type InputStreamTellFunc a+    =  Ptr a     -- ^ User data+    -> IO Word64 -- ^ The current position, or -1 on error++-- | Function to get the total number of bytes in the stream.+type InputStreamGetSizeFunc a+    =  Ptr a     -- ^ User data+    -> IO Word64 -- ^ The total number of bytes available in the stream, or -1 on error+++-- | Set of callbacks that allow users to define custom file streams.+data InputStream = forall a. InputStream+    { read       :: Ptr (InputStreamReadFunc a)+    , seek       :: Ptr (InputStreamSeekFunc a)+    , tell       :: Ptr (InputStreamTellFunc a)+    , getSize    :: Ptr (InputStreamGetSizeFunc a)+    , userData   :: Ptr a+    }++instance Storable InputStream where+    sizeOf _ = size_InputStream+    alignment _ = alignment (undefined :: CInt)+    +    peek ptr = do+        read  <- #{peek sfInputStream, read} ptr+        seek  <- #{peek sfInputStream, seek} ptr+        tell  <- #{peek sfInputStream, tell} ptr+        gets  <- #{peek sfInputStream, getSize} ptr+        udata <- #{peek sfInputStream, userData} ptr+        return $ InputStream read seek tell gets udata+    +    poke ptr (InputStream read seek tell gets udata) = do+        #{poke sfInputStream, read} ptr read+        #{poke sfInputStream, seek} ptr seek+        #{poke sfInputStream, tell} ptr tell+        #{poke sfInputStream, getSize} ptr gets+        #{poke sfInputStream, userData} ptr udata+++size_InputStream = #{size sfInputStream}+++instance Show InputStream where+    +    show (InputStream read seek tell getSize userData) =+        "InputStream { read = " ++ show read +++                    ", seek = " ++ show seek +++                    ", tell = " ++ show tell +++                    ", getSize = " ++ show getSize +++                    ", userData = " ++ show userData +++                    "}"+
+ src/SFML/System/Sleep.hsc view
@@ -0,0 +1,27 @@+{-# LANGUAGE CPP, ForeignFunctionInterface #-}+module SFML.System.Sleep+(+    sfSleep+)+where+++import SFML.System.Time++import Foreign.Marshal.Utils (with)+import Foreign.Ptr (Ptr)+++-- | Make the current thread sleep for a given duration.+--+-- sfSleep is the best way to block a program or one of its+-- threads, as it doesn't consume any CPU power.++sfSleep :: Time -> IO ()+sfSleep t = with t sfSleep_helper++foreign import ccall unsafe "sfSleep_helper"+    sfSleep_helper :: Ptr Time -> IO ()++--CSFML_SYSTEM_API void sfSleep(sfTime duration);+
+ src/SFML/System/Time.hsc view
@@ -0,0 +1,103 @@+{-# LANGUAGE CPP, ForeignFunctionInterface #-}+module SFML.System.Time+(+    Time+,   timeZero+,   asSeconds+,   asMilliseconds+,   asMicroseconds+,   seconds+,   milliseconds+,   microseconds+)+where+++import Control.Monad ((>=>))+import Data.Int (Int64, Int32)+import Foreign.C.Types+import Foreign.Marshal.Alloc (alloca)+import Foreign.Ptr+import Foreign.Storable+import System.IO.Unsafe (unsafePerformIO)++#include <SFML/Config.h>++sizeInt64 = #{size sfInt64}++type Time = Int64+++-- | Predefined "zero" time value.+timeZero :: Time+timeZero = 0++--CSFML_SYSTEM_API sfTime sfTime_Zero;+++-- | Return a time value as a number of seconds.+asSeconds :: Time -> Float+asSeconds = realToFrac . sfTime_asSeconds++foreign import ccall unsafe "sfTime_asSeconds"+    sfTime_asSeconds :: Time -> CFloat++--CSFML_SYSTEM_API float sfTime_asSeconds(sfTime time);+++-- | Return a time value as a number of milliseconds.+asMilliseconds :: Time -> Int+asMilliseconds t = fromIntegral $ sfTime_asMilliseconds t++foreign import ccall unsafe "sfTime_asMilliseconds"+    sfTime_asMilliseconds :: Time -> Int32++--CSFML_SYSTEM_API sfInt32 sfTime_asMilliseconds(sfTime time);+++-- | Return a time value as a number of microseconds.+asMicroseconds :: Time -> Int64+asMicroseconds t = sfTime_asMicroseconds t++foreign import ccall unsafe "sfTime_asMicroseconds"+    sfTime_asMicroseconds :: Time -> Int64++--CSFML_SYSTEM_API sfInt64 sfTime_asMicroseconds(sfTime time);+++-- | Construct a time value from a number of seconds.+seconds+    :: Float -- ^ Number of seconds+    -> Time+seconds s = unsafePerformIO $ alloca $ \ptr -> sfSeconds_helper (realToFrac s) ptr >> peek ptr++foreign import ccall unsafe "sfSeconds_helper"+    sfSeconds_helper :: CFloat -> Ptr Time -> IO ()++--CSFML_SYSTEM_API sfTime sfSeconds(float amount);+++-- | Construct a time value from a number of milliseconds.+milliseconds+    :: Int -- ^ Number of milliseconds+    -> Time+milliseconds t =+    unsafePerformIO $ alloca $ \ptr -> sfMilliseconds_helper (fromIntegral t) ptr >> peek ptr++foreign import ccall unsafe "sfMilliseconds_helper"+    sfMilliseconds_helper :: Int32 -> Ptr Time -> IO ()++--CSFML_SYSTEM_API sfTime sfMilliseconds(sfInt32 amount);+++-- | Construct a time value from a number of microseconds.+microseconds+    :: Int64 -- ^ Number of microseconds+    -> Time+microseconds t = unsafePerformIO $ alloca $ \ptr -> sfMicroseconds_helper t ptr >> peek ptr++foreign import ccall unsafe "sfMicroseconds_helper"+    sfMicroseconds_helper :: Int64 -> Ptr Time -> IO ()++--CSFML_SYSTEM_API sfTime sfMicroseconds(sfInt64 amount);+
+ src/SFML/System/Vector2.hsc view
@@ -0,0 +1,103 @@+{-# LANGUAGE CPP, ForeignFunctionInterface #-}+module SFML.System.Vector2+(+    Vec2i(..)+,   Vec2u(..)+,   Vec2f(..)+)+where+++import Data.Word+import Foreign.C.Types+import Foreign.Storable++#include <SFML/System/Vector2.h>+++sizeFloat = #{size float}+sizeInt   = #{size int}+++data Vec2i = Vec2i {-# UNPACK #-} !Int {-# UNPACK #-} !Int deriving Show+++instance Storable Vec2i where+    sizeOf _ = 2*sizeInt+    alignment _ = alignment (undefined :: CInt)+    +    peek ptr = do+        x <- #{peek sfVector2i, x} ptr :: IO CInt+        y <- #{peek sfVector2i, y} ptr :: IO CInt+        return $ Vec2i (fromIntegral x) (fromIntegral y)+    +    poke ptr (Vec2i x y) = do+        #{poke sfVector2i, x} ptr (fromIntegral x :: CInt)+        #{poke sfVector2i, y} ptr (fromIntegral y :: CInt)+++instance Num Vec2i where+    Vec2i ax ay + Vec2i bx by = Vec2i (ax + bx) (ay + by)+    Vec2i ax ay - Vec2i bx by = Vec2i (ax - bx) (ay - by)+    Vec2i ax ay * Vec2i bx by = Vec2i (ax * bx) (ay * by)+    abs (Vec2i ax ay) = Vec2i (abs ax) (abs ay)+    signum (Vec2i ax ay) = Vec2i (signum ax) (signum ay)+    fromInteger i = Vec2i i' i' where i' = fromInteger i+++data Vec2u = Vec2u {-# UNPACK #-} !Word {-# UNPACK #-} !Word deriving Show+++instance Storable Vec2u where+    sizeOf _ = 2*sizeInt+    alignment _ = alignment (undefined :: CUInt)+    +    peek ptr = do+        x <- #{peek sfVector2u, x} ptr :: IO CUInt+        y <- #{peek sfVector2u, y} ptr :: IO CUInt+        return $ Vec2u (fromIntegral x) (fromIntegral y)+    +    poke ptr (Vec2u x y) = do+        #{poke sfVector2u, x} ptr (fromIntegral x :: CUInt)+        #{poke sfVector2u, y} ptr (fromIntegral y :: CUInt)+++instance Num Vec2u where+    Vec2u ax ay + Vec2u bx by = Vec2u (ax + bx) (ay + by)+    Vec2u ax ay - Vec2u bx by = Vec2u (ax - bx) (ay - by)+    Vec2u ax ay * Vec2u bx by = Vec2u (ax * bx) (ay * by)+    abs (Vec2u ax ay) = Vec2u (abs ax) (abs ay)+    signum (Vec2u ax ay) = Vec2u (signum ax) (signum ay)+    fromInteger i = Vec2u i' i' where i' = fromInteger i+++data Vec2f = Vec2f {-# UNPACK #-} !Float {-# UNPACK #-} !Float deriving Show+++instance Storable Vec2f where+    sizeOf _ = 2*sizeFloat+    alignment _ = alignment (undefined :: CFloat)+    +    peek ptr = do+        x <- fmap realToFrac (#{peek sfVector2f, x} ptr :: IO CFloat)+        y <- fmap realToFrac (#{peek sfVector2f, y} ptr :: IO CFloat)+        return $ Vec2f x y+    +    poke ptr (Vec2f x y) = do+        #{poke sfVector2f, x} ptr (realToFrac x :: CFloat)+        #{poke sfVector2f, y} ptr (realToFrac y :: CFloat)+++instance Num Vec2f where+    Vec2f ax ay + Vec2f bx by = Vec2f (ax + bx) (ay + by)+    Vec2f ax ay - Vec2f bx by = Vec2f (ax - bx) (ay - by)+    Vec2f ax ay * Vec2f bx by = Vec2f (ax * bx) (ay * by)+    abs (Vec2f ax ay) = Vec2f (abs ax) (abs ay)+    signum (Vec2f ax ay) = Vec2f (signum ax) (signum ay)+    fromInteger i = Vec2f i' i' where i' = fromInteger i+++instance Fractional Vec2f where+    Vec2f ax ay / Vec2f bx by = Vec2f (ax / bx) (ay / by)+    fromRational r = Vec2f r' r' where r' = fromRational r+
+ src/SFML/System/Vector3.hsc view
@@ -0,0 +1,35 @@+{-# LANGUAGE CPP, ForeignFunctionInterface #-}+module SFML.System.Vector3+(+    Vec3f(..)+)+where+++import Foreign.C.Types+import Foreign.Storable++#include <SFML/System/Vector3.h>+++sizeFloat = #{size float}+++data Vec3f = Vec3f {-# UNPACK #-} !Float {-# UNPACK #-} !Float {-# UNPACK #-} !Float deriving Show+++instance Storable Vec3f where+    sizeOf _ = 3*sizeFloat+    alignment _ = alignment (undefined :: CFloat)+    +    peek ptr = do+        x <- fmap realToFrac (#{peek sfVector3f, x} ptr :: IO CFloat)+        y <- fmap realToFrac (#{peek sfVector3f, y} ptr :: IO CFloat)+        z <- fmap realToFrac (#{peek sfVector3f, z} ptr :: IO CFloat)+        return $ Vec3f x y z+    +    poke ptr (Vec3f x y z) = do+        #{poke sfVector3f, x} ptr (realToFrac x :: CFloat)+        #{poke sfVector3f, y} ptr (realToFrac y :: CFloat)+        #{poke sfVector3f, z} ptr (realToFrac z :: CFloat)+
+ src/SFML/Utils.hs view
@@ -0,0 +1,21 @@+module SFML.Utils+(+    err+,   tagErr+)+where+++import Control.Exception (Exception, throwIO)+++-- | Run the given IO action and throw an error if it fails.+err :: Exception e => IO (Either e a) -> IO a+err = (either throwIO return =<<)+++-- | Potentially tag a 'Maybe' value with an error.+tagErr :: e -> Maybe a -> Either e a+tagErr err Nothing  = Left err+tagErr err (Just x) = Right x+
+ src/SFML/Window.hs view
@@ -0,0 +1,29 @@+module SFML.Window+(+    module SFML.System+,   module SFML.Window.Context+,   module SFML.Window.ContextSettings+,   module SFML.Window.Event+,   module SFML.Window.Joystick+,   module SFML.Window.Keyboard+,   module SFML.Window.Mouse+,   module SFML.Window.SFWindow+,   module SFML.Window.Types+,   module SFML.Window.VideoMode+,   module SFML.Window.Window+)+where+++import SFML.System+import SFML.Window.Context+import SFML.Window.ContextSettings+import SFML.Window.Event+import SFML.Window.Joystick+import SFML.Window.Keyboard+import SFML.Window.Mouse+import SFML.Window.SFWindow+import SFML.Window.Types+import SFML.Window.VideoMode+import SFML.Window.Window+
+ src/SFML/Window/Context.hsc view
@@ -0,0 +1,49 @@+{-# LANGUAGE CPP, ForeignFunctionInterface #-}+module SFML.Window.Context+(+    createContext+,   destroy+,   setActiveContext+)+where+++import SFML.SFResource+import SFML.Window.Types++import Foreign.C.Types++#include <SFML/Window/Context.h>+++-- | Create a new context.+-- +-- This function activates the new context.+createContext = sfContext_create++foreign import ccall unsafe "sfContext_create"+    sfContext_create :: IO Context++-- CSFML_WINDOW_API sfContext* sfContext_create(void);+++instance SFResource Context where+    +    {-# INLINABLE destroy #-}+    destroy = sfContext_destroy++foreign import ccall unsafe "sfContext_destroy"+    sfContext_destroy :: Context -> IO ()++-- CSFML_WINDOW_API void sfContext_destroy(sfContext* context);+++-- | Activate or deactivate explicitely a context.+setActiveContext :: Context -> Bool -> IO ()+setActiveContext ctx val = sfContext_setActive ctx (fromIntegral . fromEnum $ val)++foreign import ccall unsafe "sfContext_setActive"+    sfContext_setActive :: Context -> CInt -> IO ()++-- CSFML_WINDOW_API void sfContext_setActive(sfContext* context, sfBool active);+
+ src/SFML/Window/ContextSettings.hsc view
@@ -0,0 +1,48 @@+{-# LANGUAGE CPP, ForeignFunctionInterface #-}+module SFML.Window.ContextSettings+(+    ContextSettings(..)+)+where+++import Foreign.C.Types+import Foreign.Storable+++#include <SFML/Window/Window.h>+++sizeInt = #{size int}+++data ContextSettings = ContextSettings+    { depthBits         :: Int -- ^ Bits of the depth buffer+    , stencilBits       :: Int -- ^ Bits of the stencil buffer+    , antialiasingLevel :: Int -- ^ Level of antialiasing+    , majorVersion      :: Int -- ^ Major number of the context version to create+    , minorVersion      :: Int -- ^ Minor number of the context version to create+    }+    deriving (Show)+++instance Storable ContextSettings where+    sizeOf _ = 5*sizeInt+    alignment _ = alignment (undefined :: CUInt)+    +    peek ptr = do+        db <- #{peek sfContextSettings, depthBits} ptr :: IO CInt+        sb <- #{peek sfContextSettings, stencilBits} ptr :: IO CInt+        al <- #{peek sfContextSettings, antialiasingLevel} ptr :: IO CInt+        ma <- #{peek sfContextSettings, majorVersion} ptr :: IO CInt+        mi <- #{peek sfContextSettings, minorVersion} ptr :: IO CInt+        return $ ContextSettings (fromIntegral db) (fromIntegral sb) (fromIntegral al)+            (fromIntegral ma) (fromIntegral mi)+    +    poke ptr (ContextSettings db sb al ma mi) = do+        #{poke sfContextSettings, depthBits} ptr (fromIntegral db :: CInt)+        #{poke sfContextSettings, stencilBits} ptr (fromIntegral sb :: CInt)+        #{poke sfContextSettings, antialiasingLevel} ptr (fromIntegral al :: CInt)+        #{poke sfContextSettings, majorVersion} ptr (fromIntegral ma :: CInt)+        #{poke sfContextSettings, minorVersion} ptr (fromIntegral mi :: CInt)+
+ src/SFML/Window/Event.hsc view
@@ -0,0 +1,165 @@+{-# LANGUAGE CPP, ForeignFunctionInterface #-}+module SFML.Window.Event+(+    SFEvent(..)+)+where+++import SFML.Window.Joystick+import SFML.Window.Keyboard+import SFML.Window.Mouse++import Foreign.C.String+import Foreign.C.Types+import Foreign.Marshal.Array+import Foreign.Ptr+import Foreign.Storable++#include <SFML/Window/Event.h>+++data SFEvent+    = SFEvtClosed+    | SFEvtResized+    { width  :: Int+    , height :: Int+    }+    | SFEvtLostFocus+    | SFEvtGainedFocus+    | SFEvtTextEntered+    { text :: String+    }+    | SFEvtKeyPressed+    { code  :: KeyCode+    , alt   :: Bool+    , ctrl  :: Bool+    , shift :: Bool+    , sys   :: Bool+    }+    | SFEvtKeyReleased+    { code  :: KeyCode+    , alt   :: Bool+    , ctrl  :: Bool+    , shift :: Bool+    , sys   :: Bool+    }+    | SFEvtMouseWheelMoved+    { delta :: Int+    , x     :: Int+    , y     :: Int+    }+    | SFEvtMouseButtonPressed+    { button :: MouseButton+    , x      :: Int+    , y      :: Int+    }+    | SFEvtMouseButtonReleased+    { button :: MouseButton+    , x      :: Int+    , y      :: Int+    }+    | SFEvtMouseMoved+    { x :: Int+    , y :: Int+    }+    | SFEvtMouseEntered+    | SFEvtMouseLeft+    | SFEvtJoystickButtonPressed+    { joystickId :: Int+    , joystickBt :: Int+    }+    | SFEvtJoystickButtonReleased+    { joystickId :: Int+    , joystickBt :: Int+    }+    | SFEvtJoystickMoved+    { joystickId   :: Int+    , joystickAxis :: JoystickAxis+    , position     :: Float+    }+    | SFEvtJoystickConnected+    { joystickId :: Int+    }+    | SFEvtJoystickDisconnected+    { joystickId :: Int+    }+++sizeInt = #{size int}+sizeChar = #{size char}+++instance Storable SFEvent where+    sizeOf _ = #{size sfEvent}+    alignment _ = alignment (undefined :: CInt)+    +    peek ptr' =+        let ptr'' = castPtr ptr' :: Ptr CInt+        in do+            let ptr = castPtr ptr''+            eventType <- peek ptr'' :: IO CInt+            case eventType of+                0  -> return SFEvtClosed+                1  -> do+                    w <- #{peek sfSizeEvent, width} ptr  :: IO CUInt+                    h <- #{peek sfSizeEvent, height} ptr :: IO CUInt+                    return $ SFEvtResized (fromIntegral w) (fromIntegral h)+                2  -> return SFEvtLostFocus+                3  -> return SFEvtGainedFocus+                4  -> peekCAString (plusPtr ptr sizeInt) >>= return . SFEvtTextEntered+                5  -> do+                    code  <- #{peek sfKeyEvent, code} ptr+                    alt   <- #{peek sfKeyEvent, alt} ptr :: IO CInt+                    ctrl  <- #{peek sfKeyEvent, control} ptr :: IO CInt+                    shift <- #{peek sfKeyEvent, shift} ptr :: IO CInt+                    sys   <- #{peek sfKeyEvent, system} ptr :: IO CInt+                    return $ SFEvtKeyPressed code (toEnum . fromIntegral $ alt) (toEnum . fromIntegral $ ctrl)+                               (toEnum . fromIntegral $ shift) (toEnum . fromIntegral $ sys)+                6  -> do+                    code  <- #{peek sfKeyEvent, code} ptr+                    alt   <- #{peek sfKeyEvent, alt} ptr :: IO CInt+                    ctrl  <- #{peek sfKeyEvent, control} ptr :: IO CInt+                    shift <- #{peek sfKeyEvent, shift} ptr :: IO CInt+                    sys   <- #{peek sfKeyEvent, system} ptr :: IO CInt+                    return $ SFEvtKeyReleased code (toEnum . fromIntegral $ alt) (toEnum . fromIntegral $ ctrl)+                               (toEnum . fromIntegral $ shift) (toEnum . fromIntegral $ sys)+                7  -> do+                    delta <- #{peek sfMouseWheelEvent, delta} ptr :: IO CInt+                    x     <- #{peek sfMouseWheelEvent, x} ptr :: IO CInt+                    y     <- #{peek sfMouseWheelEvent, y} ptr :: IO CInt+                    return $ SFEvtMouseWheelMoved (fromIntegral delta) (fromIntegral x) (fromIntegral y)+                8  -> do+                    button <- #{peek sfMouseButtonEvent, button} ptr+                    x      <- #{peek sfMouseButtonEvent, x} ptr :: IO CInt+                    y      <- #{peek sfMouseButtonEvent, y} ptr :: IO CInt+                    return $ SFEvtMouseButtonPressed button (fromIntegral x) (fromIntegral y)+                9  -> do+                    button <- #{peek sfMouseButtonEvent, button} ptr+                    x      <- #{peek sfMouseButtonEvent, x} ptr :: IO CInt+                    y      <- #{peek sfMouseButtonEvent, y} ptr :: IO CInt+                    return $ SFEvtMouseButtonReleased button (fromIntegral x) (fromIntegral y)+                10 -> do+                    x <- #{peek sfMouseMoveEvent, x} ptr :: IO CInt+                    y <- #{peek sfMouseMoveEvent, y} ptr :: IO CInt+                    return $ SFEvtMouseMoved (fromIntegral x) (fromIntegral y)+                11 -> return SFEvtMouseEntered+                12 -> return SFEvtMouseLeft+                13 -> do+                    j  <- #{peek sfJoystickButtonEvent, joystickId} ptr :: IO CUInt+                    bt <- #{peek sfJoystickButtonEvent, button} ptr :: IO CUInt+                    return $ SFEvtJoystickButtonPressed (fromIntegral j) (fromIntegral bt)+                14 -> do+                    j  <- #{peek sfJoystickButtonEvent, joystickId} ptr :: IO CUInt+                    bt <- #{peek sfJoystickButtonEvent, button} ptr :: IO CUInt+                    return $ SFEvtJoystickButtonReleased (fromIntegral j) (fromIntegral bt)+                15 -> do+                    j    <- #{peek sfJoystickMoveEvent, joystickId} ptr :: IO CUInt+                    axis <- #{peek sfJoystickMoveEvent, axis} ptr+                    pos  <- fmap realToFrac (#{peek sfJoystickMoveEvent, position} ptr :: IO CFloat)+                    return $ SFEvtJoystickMoved (fromIntegral j) axis pos+                16 -> peekByteOff ptr sizeInt >>= return . SFEvtJoystickConnected+                17 -> peekByteOff ptr sizeInt >>= return . SFEvtJoystickDisconnected+    +    poke ptr evt = return ()+
+ src/SFML/Window/Joystick.hsc view
@@ -0,0 +1,153 @@+{-# LANGUAGE CPP, ForeignFunctionInterface #-}+module SFML.Window.Joystick+(+    JoystickCap(..)+,   JoystickAxis(..)+,   isJoystickConnected+,   getButtonCount+,   hasAxis+,   isJoystickButtonPressed+,   getAxisPosition+,   updateJoystick+)+where+++import Foreign.C.Types+import Foreign.Storable+import Foreign.Ptr (Ptr, castPtr)+++-- | Global joysticks capabilities+data JoystickCap+    = JoystickCount -- ^ Maximum number of supported joysticks+    | JoystickButtonCount -- ^ Maximum number of supported buttons+    | JoystickAxisCount -- ^ Maximum number of supported axes+    deriving (Eq, Bounded, Show)+++instance Enum JoystickCap where+    +    fromEnum JoystickCount       = 8+    fromEnum JoystickButtonCount = 32+    fromEnum JoystickAxisCount   = 8+    +    toEnum 8  = JoystickCount+    toEnum 32 = JoystickButtonCount+    --toEnum 8  = JoystickAxisCount+++-- | Axes supported by SFML joysticks+data JoystickAxis+    = JoystickX    -- ^ The X axis+    | JoystickY    -- ^ The Y axis+    | JoystickZ    -- ^ The Z axis+    | JoystickR    -- ^ The R axis+    | JoystickU    -- ^ The U axis+    | JoystickV    -- ^ The V axis+    | JoystickPovX -- ^ The X axis of the point-of-view hat+    | JoystickPovY -- ^ The Y axis of the point-of-view hat+    deriving (Eq, Enum, Bounded, Show)+++sizeInt = #{size int}+++instance Storable JoystickAxis where+    sizeOf _ = sizeInt+    alignment _ = alignment (undefined :: CInt)+    +    peek ptr = peek (castPtr ptr :: Ptr CInt) >>= return . toEnum . fromIntegral+    poke ptr bt = poke (castPtr ptr :: Ptr CInt) (fromIntegral . fromEnum $ bt)+++-- | Check if a joystick is connected.+isJoystickConnected+    :: Int -- ^ Index of the joystick to check+    -> IO Bool++isJoystickConnected j = sfJoystick_isConnected (fromIntegral j) >>= return . (/=0)++foreign import ccall unsafe "sfJoystick_isConnected"+    sfJoystick_isConnected :: CUInt -> IO CChar++--CSFML_WINDOW_API sfBool sfJoystick_isConnected(unsigned int joystick);+++-- | Return the number of buttons supported by a joystick.+--+-- If the joystick is not connected, this function returns 0.+getButtonCount+    :: Int -- ^ Index of the joystick+    -> IO Int++getButtonCount j = fmap fromIntegral $ sfJoystick_getButtonCount (fromIntegral j)++foreign import ccall unsafe "sfJoystick_getButtonCount"+    sfJoystick_getButtonCount :: CUInt -> IO CUInt++--CSFML_WINDOW_API unsigned int sfJoystick_getButtonCount(unsigned int joystick);+++-- | Check if a joystick supports a given axis.+--+-- If the joystick is not connected, this function returns 'False'.+hasAxis+    :: Int -- ^ Index of the joystick+    -> Int -- ^ Axis to check+    -> IO Bool++hasAxis j a = sfJoystick_hasAxis (fromIntegral j) (fromIntegral a) >>= return . (/=0)++foreign import ccall unsafe "sfJoystick_hasAxis"+    sfJoystick_hasAxis :: CUInt -> CUInt -> IO CChar++--CSFML_WINDOW_API sfBool sfJoystick_hasAxis(unsigned int joystick, sfJoystickAxis axis);+++-- | Check if a joystick button is pressed.+--+-- If the joystick is not connected, this function returns 'False'.+isJoystickButtonPressed+    :: Int -- ^ Index of the joystick+    -> Int -- ^ Button to check+    -> IO Bool++isJoystickButtonPressed j b = sfJoystick_isButtonPressed (fromIntegral j) (fromIntegral b) >>= return . (/=0)++foreign import ccall unsafe "sfJoystick_isButtonPressed"+    sfJoystick_isButtonPressed :: CUInt -> CUInt -> IO CChar++--CSFML_WINDOW_API sfBool sfJoystick_isButtonPressed(unsigned int joystick, unsigned int button);+++-- | Get the current position of a joystick axis.+--+-- If the joystick is not connected, this function returns 0.+getAxisPosition+    :: Int -- ^ Index of the joystick+    -> Int -- ^ Axis to check+    -> IO Float++getAxisPosition j a = sfJoystick_getAxisPosition (fromIntegral j) (fromIntegral a) >>= return . realToFrac++foreign import ccall unsafe "sfJoystick_getAxisPosition"+    sfJoystick_getAxisPosition :: CUInt -> CUInt -> IO CFloat++--CSFML_WINDOW_API float sfJoystick_getAxisPosition(unsigned int joystick, sfJoystickAxis axis);+++-- | Update the states of all joysticks.+--+-- This function is used internally by SFML, so you normally+-- don't have to call it explicitely. However, you may need to+-- call it if you have no window yet (or no window at all):+-- in this case the joysticks states are not updated automatically.+updateJoystick :: IO ()+updateJoystick = sfJoystick_update++foreign import ccall unsafe "sfJoystick_update"+    sfJoystick_update :: IO ()++--CSFML_WINDOW_API void sfJoystick_update(void);+
+ src/SFML/Window/Keyboard.hsc view
@@ -0,0 +1,145 @@+{-# LANGUAGE CPP, ForeignFunctionInterface #-}+module SFML.Window.Keyboard+(+    KeyCode(..)+,   isKeyPressed+)+where+++import Foreign.C.Types+import Foreign.Ptr+import Foreign.Storable+++-- | Key codes.+data KeyCode+    = KeyA          -- ^ The A key+    | KeyB          -- ^ The B key+    | KeyC          -- ^ The C key+    | KeyD          -- ^ The D key+    | KeyE          -- ^ The E key+    | KeyF          -- ^ The F key+    | KeyG          -- ^ The G key+    | KeyH          -- ^ The H key+    | KeyI          -- ^ The I key+    | KeyJ          -- ^ The J key+    | KeyK          -- ^ The K key+    | KeyL          -- ^ The L key+    | KeyM          -- ^ The M key+    | KeyN          -- ^ The N key+    | KeyO          -- ^ The O key+    | KeyP          -- ^ The P key+    | KeyQ          -- ^ The Q key+    | KeyR          -- ^ The R key+    | KeyS          -- ^ The S key+    | KeyT          -- ^ The T key+    | KeyU          -- ^ The U key+    | KeyV          -- ^ The V key+    | KeyW          -- ^ The W key+    | KeyX          -- ^ The X key+    | KeyY          -- ^ The Y key+    | KeyZ          -- ^ The Z key+    | KeyNum0       -- ^ The 0 key+    | KeyNum1       -- ^ The 1 key+    | KeyNum2       -- ^ The 2 key+    | KeyNum3       -- ^ The 3 key+    | KeyNum4       -- ^ The 4 key+    | KeyNum5       -- ^ The 5 key+    | KeyNum6       -- ^ The 6 key+    | KeyNum7       -- ^ The 7 key+    | KeyNum8       -- ^ The 8 key+    | KeyNum9       -- ^ The 9 key+    | KeyEscape     -- ^ The Escape key+    | KeyLControl   -- ^ The left Control key+    | KeyLShift     -- ^ The left Shift key+    | KeyLAlt       -- ^ The left Alt key+    | KeyLSystem    -- ^ The left OS specific key: window (Windows and Linux), apple (MacOS X), ...+    | KeyRControl   -- ^ The right Control key+    | KeyRShift     -- ^ The right Shift key+    | KeyRAlt       -- ^ The right Alt key+    | KeyRSystem    -- ^ The right OS specific key: window (Windows and Linux), apple (MacOS X), ...+    | KeyMenu       -- ^ The Menu key+    | KeyLBracket   -- ^ The [ key+    | KeyRBracket   -- ^ The ] key+    | KeySemiColon  -- ^ The ; key+    | KeyComma      -- ^ The , key+    | KeyPeriod     -- ^ The . key+    | KeyQuote      -- ^ The ' key+    | KeySlash      -- ^ The / key+    | KeyBackSlash  -- ^ The \ key+    | KeyTilde      -- ^ The ~ key+    | KeyEqual      -- ^ The = key+    | KeyDash       -- ^ The - key+    | KeySpace      -- ^ The Space key+    | KeyReturn     -- ^ The Return key+    | KeyBack       -- ^ The Backspace key+    | KeyTab        -- ^ The Tabulation key+    | KeyPageUp     -- ^ The Page up key+    | KeyPageDown   -- ^ The Page down key+    | KeyEnd        -- ^ The End key+    | KeyHome       -- ^ The Home key+    | KeyInsert     -- ^ The Insert key+    | KeyDelete     -- ^ The Delete key+    | KeyAdd        -- ^ ++    | KeySubtract   -- ^ -+    | KeyMultiply   -- ^ *+    | KeyDivide     -- ^ /+    | KeyLeft       -- ^ Left arrow+    | KeyRight      -- ^ Right arrow+    | KeyUp         -- ^ Up arrow+    | KeyDown       -- ^ Down arrow+    | KeyNumpad0    -- ^ The numpad 0 key+    | KeyNumpad1    -- ^ The numpad 1 key+    | KeyNumpad2    -- ^ The numpad 2 key+    | KeyNumpad3    -- ^ The numpad 3 key+    | KeyNumpad4    -- ^ The numpad 4 key+    | KeyNumpad5    -- ^ The numpad 5 key+    | KeyNumpad6    -- ^ The numpad 6 key+    | KeyNumpad7    -- ^ The numpad 7 key+    | KeyNumpad8    -- ^ The numpad 8 key+    | KeyNumpad9    -- ^ The numpad 9 key+    | KeyF1         -- ^ The F1 key+    | KeyF2         -- ^ The F2 key+    | KeyF3         -- ^ The F3 key+    | KeyF4         -- ^ The F4 key+    | KeyF5         -- ^ The F5 key+    | KeyF6         -- ^ The F6 key+    | KeyF7         -- ^ The F7 key+    | KeyF8         -- ^ The F8 key+    | KeyF9         -- ^ The F8 key+    | KeyF10        -- ^ The F10 key+    | KeyF11        -- ^ The F11 key+    | KeyF12        -- ^ The F12 key+    | KeyF13        -- ^ The F13 key+    | KeyF14        -- ^ The F14 key+    | KeyF15        -- ^ The F15 key+    | KeyPause      -- ^ The Pause key+    | Undefined     -- ^ Undefined key+    deriving (Eq, Enum, Bounded, Show)+++sizeInt = #{size int}+++instance Storable KeyCode where+    sizeOf _ = sizeInt+    alignment _ = alignment (undefined :: CInt)+    +    peek ptr = peek (castPtr ptr :: Ptr CInt) >>= return . toEnum . checkUndef . fromIntegral+    poke ptr bt = poke (castPtr ptr :: Ptr CInt) (fromIntegral . fromEnum $ bt)+++checkUndef = min (fromEnum Undefined) . (\k -> if k < 0 then (fromEnum Undefined) else k)+++-- | Check if a key is pressed+isKeyPressed :: KeyCode -> IO Bool+isKeyPressed k = sfKeyboard_isKeyPressed (fromEnum k) >>= return . (/=0)+++foreign import ccall unsafe "sfKeyboard_isKeyPressed"+    sfKeyboard_isKeyPressed :: Int -> IO CChar++--CSFML_WINDOW_API sfBool sfKeyboard_isKeyPressed(sfKeyCode key);+
+ src/SFML/Window/Mouse.hsc view
@@ -0,0 +1,47 @@+{-# LANGUAGE CPP, ForeignFunctionInterface #-}+module SFML.Window.Mouse+(+    MouseButton(..)+,   isMouseButtonPressed+)+where+++import SFML.Window.Types+import SFML.System.Vector2++import Foreign.C.Types+import Foreign.Marshal.Alloc (alloca)+import Foreign.Ptr+import Foreign.Storable+++data MouseButton+    = MouseLeft+    | MouseRight+    | MouseMiddle+    | MouseXButton1+    | MouseXButton2+    deriving (Eq, Enum, Bounded, Show)+++sizeInt = #{size int}+++instance Storable MouseButton where+    sizeOf _ = sizeInt+    alignment _ = alignment (undefined :: CInt)+    +    peek ptr = peek (castPtr ptr :: Ptr CInt) >>= return . toEnum . fromIntegral+    poke ptr bt = poke (castPtr ptr :: Ptr CInt) (fromIntegral . fromEnum $ bt)+++-- | Check if a mouse button is pressed.+isMouseButtonPressed :: MouseButton -> IO Bool+isMouseButtonPressed bt = sfMouse_isButtonPressed (fromEnum bt) >>= return . (/=0)++foreign import ccall unsafe "sfMouse_isButtonPressed"+    sfMouse_isButtonPressed :: Int -> IO CChar++--CSFML_WINDOW_API sfBool sfMouse_isButtonPressed(sfMouseButton button);+
+ src/SFML/Window/SFWindow.hs view
@@ -0,0 +1,162 @@+module SFML.Window.SFWindow+where+++import SFML.SFDisplayable+import SFML.SFResource+import SFML.System.Vector2+import SFML.Window.ContextSettings+import SFML.Window.Event+import SFML.Window.Types+import SFML.Window.WindowHandle++import Foreign.Ptr (Ptr)+++class (SFResource a, SFDisplayable a) => SFWindow a where+    +    -- | Close the window.+    --+    -- After calling this function, the window object remains+    -- valid; you must call 'destroy' to actually delete it.+    close :: a -> IO ()+    +    -- | Tell whether or not a window is opened+    --+    -- This function returns whether or not the window exists.+    --+    -- Note that a hidden window (setWindowVisible 'False' ) will return+    -- 'True'.+    isWindowOpen :: a -> IO Bool+    +    -- | Get the settings of the OpenGL context of a window.+    --+    -- Note that these settings may be different from what was+    -- passed to the window create function,+    -- if one or more settings were not supported. In this case,+    -- SFML chose the closest match.+    getWindowSettings :: a -> IO ContextSettings+    +    -- | Pop the event on top of events stack, if any, and return it.+    --+    -- This function is not blocking: if there's no pending event then+    -- it will return false and leave \a event unmodified.+    -- Note that more than one event may be present in the events stack,+    -- thus you should always call this function in a loop+    -- to make sure that you process every pending event.+    pollEvent :: a -> IO (Maybe SFEvent)+    +    -- | Wait for an event and return it.+    --+    -- This function is blocking: if there's no pending event then+    -- it will wait until an event is received.+    --+    -- After this function returns (and no error occured),+    -- the event object is always valid and filled properly.+    --+    -- This function is typically used when you have a thread that+    -- is dedicated to events handling: you want to make this thread+    -- sleep as long as no new event is received.+    waitEvent :: a -> IO (Maybe SFEvent)+    +    -- | Get the position of a window.+    getWindowPosition :: a -> IO Vec2i+    +    -- | Change the position of a window on screen.+    --+    -- This function only works for top-level windows+    -- (i.e. it will be ignored for windows created from+    -- the handle of a child window/control).+    setWindowPosition :: a -> Vec2i -> IO ()+    +    -- | Get the size of the rendering region of a window.+    --+    -- The size doesn't include the titlebar and borders+    -- of the window.+    getWindowSize :: a -> IO Vec2u+    +    -- | Change the size of the rendering region of a window.+    setWindowSize :: a -> Vec2u -> IO ()++    -- | Change the title of a window.+    setWindowTitle :: a -> String -> IO ()+    +    -- | Change a window's icon.+    --+    -- Pixels must be an array of width x height pixels+    -- in 32-bits RGBA format.+    setWindowIcon+        :: a+        -> Int   -- ^ Icon's width, in pixels+        -> Int   -- ^ Icon's height, in pixels+        -> Ptr b -- ^ Pixel data+        -> IO ()+    +    -- | Show or hide a window.+    setWindowVisible :: a -> Bool -> IO ()+    +    -- | Show or hide the mouse cursor.+    setMouseVisible :: a -> Bool -> IO ()+    +    -- | Enable or disable vertical synchronization.+    -- Activating vertical synchronization will limit the number+    -- of frames displayed to the refresh rate of the monitor.+    --+    -- This can avoid some visual artifacts, and limit the framerate+    -- to a good value (but not constant across different computers).+    setVSync :: a -> Bool -> IO ()+    +    -- | Enable or disable automatic key-repeat.+    --+    -- If key repeat is enabled, you will receive repeated+    -- KeyPress events while keeping a key pressed. If it is disabled,+    -- you will only get a single event when the key is pressed.+    --+    -- Key repeat is enabled by default.+    setKeyRepeat :: a -> Bool -> IO ()+    +    -- | Activate or deactivate a window as the current target for OpenGL rendering.+    --+    -- A window is active only on the current thread, if you want to+    -- make it active on another thread you have to deactivate it+    -- on the previous thread first if it was active.+    --+    -- Only one window can be active on a thread at a time, thus+    -- the window previously active (if any) automatically gets deactivated.+    setWindowActive :: a -> Bool -> IO ()+        +    -- | Limit the framerate to a maximum fixed frequency.+    --+    -- If a limit is set, the window will use a small delay after+    -- each call to 'display' to ensure that the current frame+    -- lasted long enough to match the framerate limit.+    setFramerateLimit :: a -> Int -> IO ()+    +    -- | Change the joystick threshold.+    --+    -- The joystick threshold is the value below which+    -- no JoyMoved event will be generated.+    setJoystickThreshold :: a -> Float -> IO ()+    +    -- | Get the OS-specific handle of the window.+    --+    -- The type of the returned handle is 'WindowHandle',+    -- which is a typedef to the handle type defined by the OS.+    --+    -- You shouldn't need to use this function, unless you have+    -- very specific stuff to implement that SFML doesn't support,+    -- or implement a temporary workaround until a bug is fixed.+    getSystemHandle :: a -> IO WindowHandle+    +    -- | Get the current position of the mouse+    --+    -- This function returns the current position of the mouse+    -- cursor relative to the given window, or desktop if 'Nothing' is passed.+    getMousePosition :: Maybe a -> IO Vec2i+    +    -- | Set the current position of the mouse+    --+    -- This function sets the current position of the mouse+    -- cursor relative to the given window, or desktop if 'Nothing' is passed.+    setMousePosition :: Vec2i -> Maybe a -> IO ()+
+ src/SFML/Window/Types.hs view
@@ -0,0 +1,14 @@+module SFML.Window.Types+(+    Context(..)+,   Window(..)+)+where+++import Foreign.Ptr+++newtype Context = Context (Ptr Context)+newtype Window  = Window  (Ptr Window)+
+ src/SFML/Window/VideoMode.hsc view
@@ -0,0 +1,96 @@+{-# LANGUAGE CPP, ForeignFunctionInterface #-}+module SFML.Window.VideoMode+(+    VideoMode(..)+,   getDesktopMode+,   getFullscreenModes+,   isValid+)+where+++import Control.Applicative+import Foreign.C.Types+import Foreign.Ptr+import Foreign.Marshal.Alloc (alloca)+import Foreign.Marshal.Array (peekArray)+import Foreign.Marshal.Utils (with)+import Foreign.Storable++#include <SFML/Window/VideoMode.h>+++sizeInt = #{size int}+++data VideoMode = VideoMode+    { windowWidth  :: Int -- ^ Video mode width, in pixels+    , windowHeight :: Int -- ^ Video mode height, in pixels+    , windowBPP    :: Int -- ^ Video mode pixel depth, in bits per pixels+    }+    deriving (Show)+++instance Storable VideoMode where+    sizeOf _ = 3*sizeInt+    alignment _ = alignment (undefined :: CInt)+    +    peek ptr = do+        w <- #{peek sfVideoMode, width} ptr :: IO CUInt+        h <- #{peek sfVideoMode, height} ptr :: IO CUInt+        b <- #{peek sfVideoMode, bitsPerPixel} ptr :: IO CUInt+        return $ VideoMode (fromIntegral w) (fromIntegral h) (fromIntegral b)+    +    poke ptr (VideoMode w h b) = do+        #{poke sfVideoMode, width} ptr (fromIntegral w :: CUInt)+        #{poke sfVideoMode, height} ptr (fromIntegral h :: CUInt)+        #{poke sfVideoMode, bitsPerPixel} ptr (fromIntegral b :: CUInt)+++-- | Get the current desktop video mode+getDesktopMode = alloca $ liftA2 (*>) sfVideoMode_getDesktopMode_helper peek++foreign import ccall unsafe "sfVideoMode_getDesktopMode_helper"+    sfVideoMode_getDesktopMode_helper :: Ptr VideoMode -> IO ()++--CSFML_WINDOW_API sfVideoMode sfVideoMode_getDesktopMode(void);+++-- | Retrieve all the video modes supported in fullscreen mode+--+-- When creating a fullscreen window, the video mode is restricted+-- to be compatible with what the graphics driver and monitor+-- support.++-- This function returns the complete list of all video+-- modes that can be used in fullscreen mode.+--+-- The returned array is sorted from best to worst, so that+-- the first element will always give the best mode (higher+-- width, height and bits-per-pixel).+getFullscreenModes :: IO [VideoMode]+getFullscreenModes = do+    alloca $ \countPtr -> do+    ptrVM <- sfVideoMode_getFullscreenModes countPtr+    count <- peek countPtr+    peekArray (fromIntegral count) ptrVM++foreign import ccall unsafe "sfVideoMode_getFullscreenModes"+    sfVideoMode_getFullscreenModes :: Ptr CUInt -> IO (Ptr VideoMode)++--CSFML_WINDOW_API const sfVideoMode* sfVideoMode_getFullscreenModes(size_t* Count);+++-- | Tell whether or not a video mode is valid+--+-- The validity of video modes is only relevant when using+-- fullscreen windows; otherwise any video mode can be used+-- with no restriction.+isValid :: VideoMode -> IO Bool+isValid vm = with vm $ \ptrVm -> sfVideoMode_isValid_helper ptrVm >>= return . (/=0)++foreign import ccall unsafe "sfVideoMode_isValid_helper"+    sfVideoMode_isValid_helper :: Ptr VideoMode -> IO CChar++--CSFML_WINDOW_API sfBool sfVideoMode_isValid(sfVideoMode mode);+
+ src/SFML/Window/Window.hsc view
@@ -0,0 +1,365 @@+{-# LANGUAGE CPP, ForeignFunctionInterface #-}+module SFML.Window.Window+(+    module SFML.Window.WindowHandle+,   WindowStyle(..)+,   createWindow+,   windowFromHandle+,   destroy+,   close+,   isWindowOpen+,   getWindowSettings+,   pollEvent+,   waitEvent+,   getWindowPosition+,   setWindowPosition+,   getWindowSize+,   setWindowSize+,   setWindowTitle+,   setWindowIcon+,   setWindowVisible+,   setMouseVisible+,   setVSync+,   setKeyRepeat+,   setWindowActive+,   display+,   setFramerateLimit+,   setJoystickThreshold+,   getSystemHandle+,   getMousePosition+,   setMousePosition+)+where+++import SFML.SFDisplayable+import SFML.SFResource+import SFML.System.Vector2+import SFML.Window.ContextSettings+import SFML.Window.Event+import SFML.Window.SFWindow+import SFML.Window.Types+import SFML.Window.VideoMode+import SFML.Window.WindowHandle++import Data.Bits ((.|.))+import Data.List (foldl')+import Foreign.C.String (CString, withCAString)+import Foreign.C.Types+import Foreign.Marshal.Alloc (alloca)+import Foreign.Marshal.Utils (with)+import Foreign.Ptr+import Foreign.Storable++#include <SFML/Window/Window.h>+++data WindowStyle+    = SFNone         -- ^ No border / title bar (this flag and all others are mutually exclusive)+    | SFTitlebar     -- ^ Title bar + fixed border+    | SFResize       -- ^ Titlebar + resizable border + maximize button+    | SFClose        -- ^ Titlebar + close button+    | SFFullscreen   -- ^ Fullscreen mode (this flag and all others are mutually exclusive)+    | SFDefaultStyle -- ^ Default window style+    deriving (Eq, Bounded, Show)+++instance Enum WindowStyle where+    +    fromEnum SFNone         = 0+    fromEnum SFTitlebar     = 1+    fromEnum SFResize       = 2+    fromEnum SFClose        = 4+    fromEnum SFFullscreen   = 8+    fromEnum SFDefaultStyle = 7+    +    toEnum 0 = SFNone+    toEnum 1 = SFTitlebar+    toEnum 2 = SFResize+    toEnum 4 = SFClose+    toEnum 8 = SFFullscreen+    toEnum 7 = SFDefaultStyle+++-- | Construct a new window.+--+-- This function creates the window with the size and pixel+-- depth defined in \a mode. An optional style can be passed to+-- customize the look and behaviour of the window (borders,+-- title bar, resizable, closable, ...). If \a style contains+-- sfFullscreen, then \a mode must be a valid video mode.+--+-- The fourth parameter is a pointer to a structure specifying+-- advanced OpenGL context settings such as antialiasing,+-- depth-buffer bits, etc.++createWindow+    :: VideoMode -- ^ Video mode to use (defines the width, height and depth of the rendering area of the window)+    -> String -- ^ Window title+    -> [WindowStyle] -- ^ Window style+    -> Maybe ContextSettings -- ^ Additional settings for the underlying OpenGL context+    -> IO Window++createWindow vm title styles ctxSettings =+    with vm $ \ptrVM ->+    withCAString title $ \ptrTitle ->+    let style = foldl' (.|.) 0 $ fmap fromEnum styles+    in case ctxSettings of+        Nothing  -> sfWindow_create_helper ptrVM ptrTitle (fromIntegral style) nullPtr+        Just ctx -> with ctx $ sfWindow_create_helper ptrVM ptrTitle (fromIntegral style)++foreign import ccall unsafe "sfWindow_create_helper"+    sfWindow_create_helper :: Ptr VideoMode -> CString -> CUInt -> Ptr ContextSettings -> IO Window++--CSFML_WINDOW_API sfWindow* sfWindow_create(sfVideoMode mode, const char* title, sfUint32 style, const sfContextSettings* settings);+++-- | Construct a window from an existing control.+--+-- Use this constructor if you want to create an OpenGL+-- rendering area into an already existing control.+--+-- The second parameter is a pointer to a structure specifying+-- advanced OpenGL context settings such as antialiasing,+-- depth-buffer bits, etc.++windowFromHandle+    :: WindowHandle -- ^ Platform-specific handle of the control+    -> Maybe ContextSettings -- ^ Additional settings for the underlying OpenGL context+    -> IO Window++windowFromHandle hwnd ctxSettings =+    case ctxSettings of+        Nothing  -> sfWindow_createFromHandle hwnd nullPtr+        Just ctx -> with ctx $ sfWindow_createFromHandle hwnd++foreign import ccall unsafe "sfWindow_createFromHandle"+    sfWindow_createFromHandle :: WindowHandle -> Ptr ContextSettings -> IO Window++--CSFML_WINDOW_API sfWindow* sfWindow_createFromHandle(sfWindowHandle handle, const sfContextSettings* settings);+++instance SFResource Window where+    +    {-# INLINABLE destroy #-}+    destroy = sfWindow_destroy++foreign import ccall unsafe "sfWindow_destroy"+    sfWindow_destroy :: Window -> IO ()++--CSFML_WINDOW_API void sfWindow_destroy(sfWindow* window);+++instance SFDisplayable Window where+    +    {-# INLINABLE display #-}+    display = sfWindow_display+++instance SFWindow Window where+    +    {-# INLINABLE close #-}+    close = sfWindow_close+    +    {-# INLINABLE isWindowOpen #-}+    isWindowOpen wnd = sfWindow_isOpen wnd >>= return . (/=0)+    +    {-# INLINABLE getWindowSettings #-}+    getWindowSettings wnd =+        alloca $ \ptrCtxSettings -> do+        sfWindow_getSettings_helper wnd ptrCtxSettings+        peek ptrCtxSettings+    +    {-# INLINABLE pollEvent #-}+    pollEvent wnd =+        alloca $ \ptrEvt -> do+        result <- return . (/=0) =<< sfWindow_pollEvent wnd ptrEvt+        case result of+            True  -> peek ptrEvt >>= return . Just+            False -> return Nothing+    +    {-# INLINABLE waitEvent #-}+    waitEvent wnd =+        alloca $ \ptr -> do+        result <- sfWindow_waitEvent wnd ptr+        case result of+            0 -> return Nothing+            _ -> peek ptr >>= return . Just+    +    {-# INLINABLE getWindowPosition #-}+    getWindowPosition wnd = alloca $ \vecPtr -> sfWindow_getPosition_helper wnd vecPtr >> peek vecPtr+    +    {-# INLINABLE setWindowPosition #-}+    setWindowPosition wnd pos = with pos $ \posPtr -> sfWindow_setPosition_helper wnd posPtr+    +    {-# INLINABLE getWindowSize #-}+    getWindowSize wnd = alloca $ \vecPtr -> sfWindow_getSize_helper wnd vecPtr >> peek vecPtr+    +    {-# INLINABLE setWindowSize #-}+    setWindowSize wnd size = with size $ \ptrSize -> sfWindow_setSize_helper wnd ptrSize+    +    {-# INLINABLE setWindowTitle #-}+    setWindowTitle wnd title = withCAString title $ \ptrTitle -> sfWindow_setTitle wnd ptrTitle+    +    {-# INLINABLE setWindowIcon #-}+    setWindowIcon = sfWindow_setIcon+    +    {-# INLINABLE setWindowVisible #-}+    setWindowVisible wnd val = sfWindow_setVisible wnd (fromIntegral . fromEnum $ val)+    +    {-# INLINABLE setMouseVisible #-}+    setMouseVisible wnd val = sfWindow_setMouseCursorVisible wnd (fromIntegral . fromEnum $ val)+    +    {-# INLINABLE setVSync #-}+    setVSync wnd val = sfWindow_setVerticalSyncEnabled wnd (fromIntegral . fromEnum $ val)+    +    {-# INLINABLE setKeyRepeat #-}+    setKeyRepeat wnd val = sfWindow_setKeyRepeatEnabled wnd (fromIntegral . fromEnum $ val)+    +    {-# INLINABLE setWindowActive #-}+    setWindowActive wnd val = sfWindow_setActive wnd (fromIntegral . fromEnum $ val)+    +    {-# INLINABLE setFramerateLimit #-}+    setFramerateLimit wnd val = sfWindow_setFramerateLimit wnd (fromIntegral val)+    +    {-# INLINABLE setJoystickThreshold #-}+    setJoystickThreshold w t = sfWindow_setJoystickThreshold w (realToFrac t)+    +    {-# INLINABLE getSystemHandle #-}+    getSystemHandle = sfWindow_getSystemHandle+    +    {-# INLINABLE getMousePosition #-}+    getMousePosition Nothing    = alloca $ \ptr -> sfMouse_getPosition_helper (Window nullPtr) ptr >> peek ptr+    getMousePosition (Just wnd) = alloca $ \ptr -> sfMouse_getPosition_helper wnd ptr >> peek ptr+    +    {-# INLINABLE setMousePosition #-}+    setMousePosition pos Nothing    = with pos $ \ptr -> sfMouse_setPosition_helper ptr (Window nullPtr)+    setMousePosition pos (Just wnd) = with pos $ \ptr -> sfMouse_setPosition_helper ptr wnd+++foreign import ccall unsafe "sfWindow_close"+    sfWindow_close :: Window -> IO ()++--CSFML_WINDOW_API void sfWindow_close(sfWindow* window);++foreign import ccall unsafe "sfWindow_isOpen"+    sfWindow_isOpen :: Window -> IO CChar++--CSFML_WINDOW_API sfBool sfWindow_isOpen(const sfWindow* window);+++foreign import ccall unsafe "sfWindow_getSettings_helper"+    sfWindow_getSettings_helper :: Window -> Ptr ContextSettings -> IO ()++--CSFML_WINDOW_API sfContextSettings sfWindow_getSettings(const sfWindow* window);+++foreign import ccall unsafe "sfWindow_pollEvent"+    sfWindow_pollEvent :: Window -> Ptr SFEvent -> IO CChar++--CSFML_WINDOW_API sfBool sfWindow_pollEvent(sfWindow* window, sfEvent* event);+++foreign import ccall unsafe "sfWindow_waitEvent"+    sfWindow_waitEvent :: Window -> Ptr SFEvent -> IO CInt++--CSFML_WINDOW_API sfBool sfWindow_waitEvent(sfWindow* window, sfEvent* event);+++foreign import ccall unsafe "sfWindow_getPosition_helper"+    sfWindow_getPosition_helper :: Window -> Ptr Vec2i -> IO ()++--CSFML_WINDOW_API sfVector2i sfWindow_getPosition(const sfWindow* window);+++foreign import ccall unsafe "sfWindow_setPosition_helper"+    sfWindow_setPosition_helper :: Window -> Ptr Vec2i -> IO ()++--CSFML_WINDOW_API void sfWindow_setPosition(sfWindow* window, sfVector2i position);+++foreign import ccall unsafe "sfWindow_getSize_helper"+    sfWindow_getSize_helper :: Window -> Ptr Vec2u -> IO ()++--CSFML_WINDOW_API sfVector2u sfWindow_getSize(const sfWindow* window);+++foreign import ccall unsafe "sfWindow_setSize_helper"+    sfWindow_setSize_helper :: Window -> Ptr Vec2u -> IO ()++--CSFML_WINDOW_API void sfWindow_setSize(sfWindow* window, sfVector2u size);+++foreign import ccall unsafe "sfWindow_setTitle"+    sfWindow_setTitle :: Window -> CString -> IO ()++--CSFML_WINDOW_API void sfWindow_setTitle(sfWindow* window, const char* title);+++foreign import ccall unsafe "sfWindow_setIcon"+    sfWindow_setIcon :: Window -> Int -> Int -> Ptr a -> IO ()++--CSFML_WINDOW_API void sfWindow_setIcon(sfWindow* window, unsigned int width, unsigned int height, const sfUint8* pixels);+++foreign import ccall unsafe "sfWindow_setVisible"+    sfWindow_setVisible :: Window -> CChar -> IO ()++--CSFML_WINDOW_API void sfWindow_setVisible(sfWindow* window, sfBool visible);++foreign import ccall unsafe "sfWindow_setMouseCursorVisible"+    sfWindow_setMouseCursorVisible :: Window -> CChar -> IO ()++--CSFML_WINDOW_API void sfWindow_setMouseCursorVisible(sfWindow* window, sfBool visible);++foreign import ccall unsafe "sfWindow_setVerticalSyncEnabled"+    sfWindow_setVerticalSyncEnabled :: Window -> CChar -> IO ()++--CSFML_WINDOW_API void sfWindow_setVerticalSyncEnabled(sfWindow* window, sfBool enabled);+++foreign import ccall unsafe "sfWindow_setActive"+    sfWindow_setActive :: Window -> CChar -> IO ()++--CSFML_WINDOW_API sfBool sfWindow_setActive(sfWindow* window, sfBool active);+++foreign import ccall unsafe "sfWindow_setKeyRepeatEnabled"+    sfWindow_setKeyRepeatEnabled :: Window -> CChar -> IO ()++--CSFML_WINDOW_API void sfWindow_setKeyRepeatEnabled(sfWindow* window, sfBool enabled);+++foreign import ccall unsafe "sfWindow_display"+    sfWindow_display :: Window -> IO ()++--CSFML_WINDOW_API void sfWindow_display(sfWindow* window);+++foreign import ccall unsafe "sfWindow_setFramerateLimit"+    sfWindow_setFramerateLimit :: Window -> CUInt -> IO ()++--CSFML_WINDOW_API void sfWindow_setFramerateLimit(sfWindow* window, unsigned int limit);+++foreign import ccall unsafe "sfWindow_setJoystickThreshold"+    sfWindow_setJoystickThreshold :: Window -> CFloat -> IO ()++--CSFML_WINDOW_API void sfWindow_setJoystickThreshold(sfWindow* window, float threshold);++foreign import ccall unsafe "sfWindow_getSystemHandle"+    sfWindow_getSystemHandle :: Window -> IO WindowHandle++--CSFML_WINDOW_API sfWindowHandle sfWindow_getSystemHandle(const sfWindow* window);+++foreign import ccall unsafe "sfMouse_getPosition_helper"+    sfMouse_getPosition_helper :: Window -> Ptr Vec2i -> IO ()++--CSFML_WINDOW_API sfVector2i sfMouse_getPosition(const sfWindow* relativeTo);++foreign import ccall unsafe "sfMouse_setPosition_helper"+    sfMouse_setPosition_helper :: Ptr Vec2i -> Window -> IO ()++--CSFML_WINDOW_API void sfMouse_setPosition(sfVector2i position, const sfWindow* relativeTo);+
+ src/SFML/Window/WindowHandle.hs view
@@ -0,0 +1,12 @@+module SFML.Window.WindowHandle+(+    WindowHandle(..)+)+where+++import Foreign.Ptr (Ptr)+++newtype WindowHandle = WindowHandle (Ptr WindowHandle)+