SFML-0.2.0.0: SFML bindings

Safe HaskellNone
LanguageHaskell98

SFML.Graphics.RenderTexture

Synopsis

Documentation

module SFML.Utils

createRenderTexture Source

Arguments

:: 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) 

Construct a new render texture.

destroy :: SFResource a => a -> IO () Source

Destroy the given SFML resource.

getTextureSize Source

Arguments

:: RenderTexture 
-> IO Vec2u

Size in pixels

Get the size of the rendering region of a render texture.

setActive Source

Arguments

:: RenderTexture

Render texture object

-> Bool

True to activate, False to deactivate

-> IO Bool

True if operation was successful, False otherwise

Activate or deactivate a render texture as the current target for rendering.

display :: SFDisplayable a => a -> IO () Source

Update the target's contents.

clear Source

Arguments

:: RenderTexture

Render texture object

-> Color

Fill color

-> IO () 

Clear the rendertexture with the given color.

setView :: SFViewable a => a -> View -> IO () Source

Change the target's current active view.

getView :: SFViewable a => a -> IO View Source

Get the target's current active view.

getDefaultView :: SFViewable a => a -> IO View Source

Get the target's default view.

getViewport :: SFViewable a => a -> View -> IO IntRect Source

Get the viewport of a view applied to this target, expressed in pixels in the current target.

mapPixelToCoords Source

Arguments

:: SFCoordSpace a 
=> a 
-> Vec2i

Pixel to convert

-> Maybe View

The view to use for converting the point

-> IO Vec2f 

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.

drawSprite Source

Arguments

:: SFRenderTarget a 
=> a 
-> Sprite

Sprite to draw

-> Maybe RenderStates

Render states to use for drawing (Nothing to use the default states)

-> IO () 

Draw a sprite to the render-target.

drawText Source

Arguments

:: SFRenderTarget a 
=> a 
-> Text

Text to draw

-> Maybe RenderStates

Render states to use for drawing (Nothing to use the default states)

-> IO () 

Draw text to the render-target.

drawShape Source

Arguments

:: SFRenderTarget a 
=> 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 Source

Arguments

:: SFRenderTarget a 
=> 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 Source

Arguments

:: SFRenderTarget a 
=> 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 Source

Arguments

:: SFRenderTarget a 
=> 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 Source

Arguments

:: SFRenderTarget a 
=> a 
-> VertexArray

VertexArray to draw

-> Maybe RenderStates

Render states to use for drawing (Nothing to use the default states)

-> IO () 

Draw a sprite to the render-target.

drawPrimitives Source

Arguments

:: SFRenderTarget a 
=> 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 () 

Draw primitives defined by an array of vertices to a render texture.

drawPrimitives' Source

Arguments

:: SFRenderTarget a 
=> 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 () 

pushGLStates :: SFRenderTarget a => a -> IO () Source

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.

popGLStates :: SFRenderTarget a => a -> IO () Source

Restore the previously saved OpenGL render states and matrices.

See the description of pushGLStates to get a detailed description of these functions.

resetGLStates :: SFRenderTarget a => a -> IO () Source

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.

getRenderTexture :: RenderTexture -> IO Texture Source

Get the target texture of a render texture.

setSmooth :: SFSmoothTexture a => a -> Bool -> IO () Source

Enable or disable the smooth filter on a texture.

isSmooth :: SFSmoothTexture a => a -> IO Bool Source

Tell whether the smooth filter is enabled or not for a texture.