C# Class SFML.Graphics.RenderTexture

Target for off-screen 2D rendering into an texture
Inheritance: SFML.System.ObjectBase, RenderTarget
ファイルを表示 Open project: SFML/SFML.Net Class Usage Examples

Public Methods

Method Description
Clear ( ) : void

Clear the entire render texture with black color

Clear ( System.Color color ) : void

Clear the entire render texture with a single color

Display ( ) : void

Update the contents of the target texture

Draw ( Drawable drawable ) : void

Draw a drawable object to the render-target, with default render states

Draw ( Drawable drawable, RenderStates states ) : void

Draw a drawable object to the render-target

Draw ( Vertex vertices, PrimitiveType type ) : void

Draw primitives defined by an array of vertices, with default render states

Draw ( Vertex vertices, PrimitiveType type, RenderStates states ) : void

Draw primitives defined by an array of vertices

Draw ( Vertex vertices, uint start, uint count, PrimitiveType type ) : void

Draw primitives defined by a sub-array of vertices, with default render states

Draw ( Vertex vertices, uint start, uint count, PrimitiveType type, RenderStates states ) : void

Draw primitives defined by a sub-array of vertices

GenerateMipmap ( ) : bool

Generate a mipmap using the current texture data

This function is similar to Texture.GenerateMipmap and operates on the texture used as the target for drawing. Be aware that any draw operation may modify the base level image data. For this reason, calling this function only makes sense after all drawing is completed and display has been called. Not calling display after subsequent drawing will lead to undefined behavior if a mipmap had been previously generated.

GetView ( ) : View

Return the current active view

GetViewport ( View view ) : IntRect

Get the viewport of a view applied to this target

MapCoordsToPixel ( Vector2f point ) : Vector2i

Convert a point from world coordinates to target coordinates, using the current view This function is an overload of the mapCoordsToPixel function that implicitly uses the current view. It is equivalent to: target.MapCoordsToPixel(point, target.GetView());

MapCoordsToPixel ( Vector2f point, View view ) : Vector2i

Convert a point from world coordinates to target coordinates This function finds the pixel of the render-target that matches the given 2D point. In other words, it goes through the same process as the graphics card, to compute the final position of a rendered point. Initially, both coordinate systems (world units and target pixels) match perfectly. But if you define a custom view or resize your render-target, this assertion is not true anymore, ie. a point located at (150, 75) in your 2D world may map to the pixel (10, 50) of your render-target -- 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-target.

MapPixelToCoords ( Vector2i point ) : Vector2f

Convert a point from target coordinates to world coordinates, using the current view This function is an overload of the MapPixelToCoords function that implicitly uses the current view. It is equivalent to: target.MapPixelToCoords(point, target.GetView());

MapPixelToCoords ( Vector2i point, View view ) : Vector2f

Convert a point from target coordinates to world coordinates This function finds the 2D position that matches the given pixel of the render-target. 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 render-target, this assertion is not true anymore, ie. a point located at (10, 50) in your render-target may map to the point (150, 75) in your 2D world -- if the view is translated by (140, 25). For render-windows, this function is typically used to find which point (or object) is located below the mouse cursor. 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-target.

PopGLStates ( ) : void

Restore the previously saved OpenGL render states and matrices. See the description of PushGLStates to get a detailed description of these functions.

PushGLStates ( ) : void

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: \li SFML's internal states are not messed up by your OpenGL code \li your OpenGL states are not modified by a call to a SFML function More specifically, it must be used around code that calls Draw functions. Example: // OpenGL code here... window.PushGLStates(); window.Draw(...); window.Draw(...); window.PopGLStates(); // OpenGL code here... 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.

RenderTexture ( uint width, uint height ) : System

Create the render-texture with the given dimensions

RenderTexture ( uint width, uint height, bool depthBuffer ) : System

Create the render-texture with the given dimensions and an optional depth-buffer attached

ResetGLStates ( ) : void

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/PopGLStates. It makes sure that all OpenGL states needed by SFML are set, so that subsequent Draw() calls will work as expected. Example: // OpenGL code here... glPushAttrib(...); window.ResetGLStates(); window.Draw(...); window.Draw(...); glPopAttrib(...); // OpenGL code here...

SetActive ( bool active ) : bool

Activate of deactivate the render texture as the current target for rendering

SetView ( View view ) : void

Change the current active view

ToString ( ) : string

Provide a string describing the object

Protected Methods

Method Description
Destroy ( bool disposing ) : void

Handle the destruction of the object

Private Methods

Method Description
sfRenderTexture_clear ( IntPtr CPointer, System.Color ClearColor ) : void
sfRenderTexture_create ( uint Width, uint Height, bool DepthBuffer ) : IntPtr
sfRenderTexture_destroy ( IntPtr CPointer ) : void
sfRenderTexture_display ( IntPtr CPointer ) : bool
sfRenderTexture_drawPrimitives ( IntPtr CPointer, Vertex vertexPtr, uint vertexCount, PrimitiveType type, RenderStates &renderStates ) : void
sfRenderTexture_generateMipmap ( IntPtr CPointer ) : bool
sfRenderTexture_getDefaultView ( IntPtr CPointer ) : IntPtr
sfRenderTexture_getSize ( IntPtr CPointer ) : Vector2u
sfRenderTexture_getTexture ( IntPtr CPointer ) : IntPtr
sfRenderTexture_getView ( IntPtr CPointer ) : IntPtr
sfRenderTexture_getViewport ( IntPtr CPointer, IntPtr TargetView ) : IntRect
sfRenderTexture_isRepeated ( IntPtr CPointer ) : bool
sfRenderTexture_isSmooth ( IntPtr CPointer ) : bool
sfRenderTexture_mapCoordsToPixel ( IntPtr CPointer, Vector2f point, IntPtr View ) : Vector2i
sfRenderTexture_mapPixelToCoords ( IntPtr CPointer, Vector2i point, IntPtr View ) : Vector2f
sfRenderTexture_popGLStates ( IntPtr CPointer ) : void
sfRenderTexture_pushGLStates ( IntPtr CPointer ) : void
sfRenderTexture_resetGLStates ( IntPtr CPointer ) : void
sfRenderTexture_restoreGLStates ( IntPtr CPointer ) : bool
sfRenderTexture_saveGLStates ( IntPtr CPointer ) : bool
sfRenderTexture_setActive ( IntPtr CPointer, bool Active ) : bool
sfRenderTexture_setRepeated ( IntPtr CPointer, bool repeated ) : void
sfRenderTexture_setSmooth ( IntPtr CPointer, bool smooth ) : void
sfRenderTexture_setView ( IntPtr CPointer, IntPtr View ) : void

Method Details

Clear() public method

Clear the entire render texture with black color
public Clear ( ) : void
return void

Clear() public method

Clear the entire render texture with a single color
public Clear ( System.Color color ) : void
color System.Color Color to use to clear the texture
return void

Destroy() protected method

Handle the destruction of the object
protected Destroy ( bool disposing ) : void
disposing bool Is the GC disposing the object, or is it an explicit call ?
return void

Display() public method

Update the contents of the target texture
public Display ( ) : void
return void

Draw() public method

Draw a drawable object to the render-target, with default render states
public Draw ( Drawable drawable ) : void
drawable Drawable Object to draw
return void

Draw() public method

Draw a drawable object to the render-target
public Draw ( Drawable drawable, RenderStates states ) : void
drawable Drawable Object to draw
states RenderStates Render states to use for drawing
return void

Draw() public method

Draw primitives defined by an array of vertices, with default render states
public Draw ( Vertex vertices, PrimitiveType type ) : void
vertices Vertex Pointer to the vertices
type PrimitiveType Type of primitives to draw
return void

Draw() public method

Draw primitives defined by an array of vertices
public Draw ( Vertex vertices, PrimitiveType type, RenderStates states ) : void
vertices Vertex Pointer to the vertices
type PrimitiveType Type of primitives to draw
states RenderStates Render states to use for drawing
return void

Draw() public method

Draw primitives defined by a sub-array of vertices, with default render states
public Draw ( Vertex vertices, uint start, uint count, PrimitiveType type ) : void
vertices Vertex Array of vertices to draw
start uint Index of the first vertex to draw in the array
count uint Number of vertices to draw
type PrimitiveType Type of primitives to draw
return void

Draw() public method

Draw primitives defined by a sub-array of vertices
public Draw ( Vertex vertices, uint start, uint count, PrimitiveType type, RenderStates states ) : void
vertices Vertex Pointer to the vertices
start uint Index of the first vertex to use in the array
count uint Number of vertices to draw
type PrimitiveType Type of primitives to draw
states RenderStates Render states to use for drawing
return void

GenerateMipmap() public method

Generate a mipmap using the current texture data
This function is similar to Texture.GenerateMipmap and operates on the texture used as the target for drawing. Be aware that any draw operation may modify the base level image data. For this reason, calling this function only makes sense after all drawing is completed and display has been called. Not calling display after subsequent drawing will lead to undefined behavior if a mipmap had been previously generated.
public GenerateMipmap ( ) : bool
return bool

GetView() public method

Return the current active view
public GetView ( ) : View
return View

GetViewport() public method

Get the viewport of a view applied to this target
public GetViewport ( View view ) : IntRect
view View Target view
return IntRect

MapCoordsToPixel() public method

Convert a point from world coordinates to target coordinates, using the current view This function is an overload of the mapCoordsToPixel function that implicitly uses the current view. It is equivalent to: target.MapCoordsToPixel(point, target.GetView());
public MapCoordsToPixel ( Vector2f point ) : Vector2i
point Vector2f Point to convert
return Vector2i

MapCoordsToPixel() public method

Convert a point from world coordinates to target coordinates This function finds the pixel of the render-target that matches the given 2D point. In other words, it goes through the same process as the graphics card, to compute the final position of a rendered point. Initially, both coordinate systems (world units and target pixels) match perfectly. But if you define a custom view or resize your render-target, this assertion is not true anymore, ie. a point located at (150, 75) in your 2D world may map to the pixel (10, 50) of your render-target -- 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-target.
public MapCoordsToPixel ( Vector2f point, View view ) : Vector2i
point Vector2f Point to convert
view View The view to use for converting the point
return Vector2i

MapPixelToCoords() public method

Convert a point from target coordinates to world coordinates, using the current view This function is an overload of the MapPixelToCoords function that implicitly uses the current view. It is equivalent to: target.MapPixelToCoords(point, target.GetView());
public MapPixelToCoords ( Vector2i point ) : Vector2f
point Vector2i Pixel to convert
return Vector2f

MapPixelToCoords() public method

Convert a point from target coordinates to world coordinates This function finds the 2D position that matches the given pixel of the render-target. 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 render-target, this assertion is not true anymore, ie. a point located at (10, 50) in your render-target may map to the point (150, 75) in your 2D world -- if the view is translated by (140, 25). For render-windows, this function is typically used to find which point (or object) is located below the mouse cursor. 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-target.
public MapPixelToCoords ( Vector2i point, View view ) : Vector2f
point Vector2i Pixel to convert
view View The view to use for converting the point
return Vector2f

PopGLStates() public method

Restore the previously saved OpenGL render states and matrices. See the description of PushGLStates to get a detailed description of these functions.
public PopGLStates ( ) : void
return void

PushGLStates() public method

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: \li SFML's internal states are not messed up by your OpenGL code \li your OpenGL states are not modified by a call to a SFML function More specifically, it must be used around code that calls Draw functions. Example: // OpenGL code here... window.PushGLStates(); window.Draw(...); window.Draw(...); window.PopGLStates(); // OpenGL code here... 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.
public PushGLStates ( ) : void
return void

RenderTexture() public method

Create the render-texture with the given dimensions
public RenderTexture ( uint width, uint height ) : System
width uint Width of the render-texture
height uint Height of the render-texture
return System

RenderTexture() public method

Create the render-texture with the given dimensions and an optional depth-buffer attached
public RenderTexture ( uint width, uint height, bool depthBuffer ) : System
width uint Width of the render-texture
height uint Height of the render-texture
depthBuffer bool Do you want a depth-buffer attached?
return System

ResetGLStates() public method

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/PopGLStates. It makes sure that all OpenGL states needed by SFML are set, so that subsequent Draw() calls will work as expected. Example: // OpenGL code here... glPushAttrib(...); window.ResetGLStates(); window.Draw(...); window.Draw(...); glPopAttrib(...); // OpenGL code here...
public ResetGLStates ( ) : void
return void

SetActive() public method

Activate of deactivate the render texture as the current target for rendering
public SetActive ( bool active ) : bool
active bool True to activate, false to deactivate (true by default)
return bool

SetView() public method

Change the current active view
public SetView ( View view ) : void
view View New view
return void

ToString() public method

Provide a string describing the object
public ToString ( ) : string
return string