Otter  0.9.88
2d Game Development Framework based on SFML.Net
 All Classes Namespaces Functions Variables Enumerations Properties
Otter.Surface Class Reference

Graphic that represents a render target. By default the game uses a master surface to render the game to the window. Be aware of graphics card limiations of render textures when creating surfaces. More...

Inherits Otter.Image.

Public Member Functions

float SurfaceX (float x)
 Convert an X position into the same position but on the Surface. TODO: Make this work with scale and rotation. More...
 
float SurfaceY (float y)
 Convert a Y position into the same position but on the Surface. TODO: Make this work with scale and rotation. More...
 
 Surface (int width, int height, Color color=null)
 Creates a Surface with a specified size. More...
 
 Surface (int width, int height)
 Creates a Surface of a specified size. More...
 
 Surface (int size)
 Creates a Surface of a specified size. More...
 
 Surface (int size, Color color)
 Creates a Surface of a specified size. More...
 
void AddShader (Shader shader)
 Add a shader to be drawn on the surface. If "Shader" is set, the shader list is ignored. More...
 
void RemoveShader (Shader shader)
 Remove a shader from the surface. More...
 
Shader PopShader ()
 Remove the top most shader on the list of shaders. More...
 
void Display ()
 Calls the SFML Display function on the internal render texture. Should be used before any sort of rendering, otherwise the texture will be upside down! More...
 
void ClearShaders ()
 Remove all shaders from the surface. More...
 
void SetShader (Shader shader)
 Replace all shaders with a single shader. This will be ignored if "Shader" is set. More...
 
void Draw (Graphic graphic, float x=0, float y=0)
 Draws a graphic to this surface. More...
 
void Fill (Color color)
 Fills the surface with the specified color. More...
 
void Clear ()
 Clears the surface with the fill color. More...
 
void Clear (Color color)
 Clears the surface with a specified color. More...
 
override void Render (float x=0, float y=0)
 Draw the Surface. More...
 
void DrawToWindow (Game game)
 Draw the surface directly to the game window. This will refresh the view, and Display the surface, as well as clear it if AutoClear is true. More...
 
void DrawToWindow ()
 Draw the Surface to the Game window. More...
 
void SetView (float x, float y, float angle=0, float zoom=1f)
 Set view of the Surface. More...
 
Texture GetTexture ()
 Returns a texture by getting the current render texture. I don't know if this works right yet. More...
 
void SaveToFile (string path="")
 Saves the next completed render to a file. The supported image formats are bmp, png, tga and jpg. Note that this waits until the end of the game's Render() to actually export, otherwise it will be blank! More...
 
void CameraScene (Scene scene)
 Matches the view of the surface to the same view of a Scene. More...
 
void CenterCamera (float x, float y)
 Centers the camera of the surface. More...
 
- Public Member Functions inherited from Otter.Image
 Image (string source=null)
 Creates a new Image using a filepath to a texture. More...
 
 Image (Texture texture)
 Creates a new Image using a Texture. More...
 
 Image (AtlasTexture texture)
 Creates a new Image using an AtlasTexture. More...
 
 Image (int width, int height)
 Creates a new Image using a specified width and height. More...
 
- Public Member Functions inherited from Otter.Graphic
Transformation AddTransform (Transformation transform)
 
Transformation AddTransform (Vector2 translation, Vector2 scale, Vector2 origin, float rotation)
 
Transformation AddTransform ()
 
Transformation RemoveTransformation (Transformation transform)
 
Transformation PopTransformation ()
 
virtual void ClearShader ()
 Removes the shader from the graphic. More...
 
void SetPosition (float x, float y)
 Set the position of the Graphic. More...
 
void SetPosition (Graphic g, float offsetX=0, float offsetY=0)
 Set the position of the Graphic. More...
 
void SetPosition (Vector2 xy)
 Set the position of the Graphic. More...
 
void SetOrigin (float x, float y)
 Set the origin of the Graphic. More...
 
void SetOrigin (Vector2 xy)
 Set the origin of the Graphic. More...
 
void SetTexture (string path)
 Set the Texture that the Graphic is using (if it is using one.) More...
 
void SetTexture (Texture texture)
 Set the Texture that the Graphic is using (if it is using one.) More...
 
void SetTexture (AtlasTexture atlasTexture)
 Set the Texture that the Graphic is using (if it is using one.) More...
 
virtual void Update ()
 Update the graphic. More...
 
virtual void CenterOrigin ()
 Centers the graphic origin. More...
 
virtual void CenterOriginZero ()
 Centers the graphic origin while retaining its relative position. More...
 

Public Attributes

Color FillColor
 The color that the surface will fill with at the start of each render. More...
 
bool AutoClear = true
 Determines if the Surface will automatically clear at the start of the next render cycle. More...
 
bool UseSceneCamera
 Determines if the Surface will automatically set its camera to the Scene's camera. More...
 
- Public Attributes inherited from Otter.Graphic
List< TransformationTransforms = new List<Transformation>() { new Transformation() }
 
bool Relative = true
 Determines if the Graphic is rendered relative to its Entity. More...
 
bool Visible = true
 Determines if the Graphic will render. More...
 
float ScrollX = 1
 The scroll factor for the x position. Used for parallax like effects. Values lower than 1 will scroll slower than the camera (appear to be further away) and values higher than 1 will scroll faster than the camera (appear to be closer.) More...
 
float ScrollY = 1
 The scroll factor for the y position. Used for parallax like effects. Values lower than 1 will scroll slower than the camera (appear to be further away) and values higher than 1 will scroll faster than the camera (appear to be closer.) More...
 
float ShakeX
 The horizontal amount to randomly offset the graphic by each frame. More...
 
float ShakeY
 The vertial amount to randomly offset the graphic by each frame. More...
 
Rectangle TextureRegion
 The region to render the Texture with. More...
 
Rectangle AtlasRegion
 The Rectangle to render an AtlasTexture with. More...
 
Shader Shader
 The shader to be applied to this graphic. More...
 
string Name = "Graphic"
 The name of the graphic. More...
 
BlendMode Blend = BlendMode.Alpha
 The blend mode to be applied to this graphic. More...
 
bool RepeatX
 Determines if the image should be rendered multiple times horizontally. More...
 
bool RepeatY
 Determines if the image should be rendered multiple times vertically. More...
 

Properties

Game Game [get, set]
 The reference to the Game using this Surface (if it is the main Surface the game is rendering to!) More...
 
float CameraX [get, set]
 The camera X for the view of the surface. Note: For the game's main surface, this is controlled by the active Scene. More...
 
float CameraY [get, set]
 The camera Y for the view of the surface. Note: For the game's main surface, this is controlled by the active Scene. More...
 
float CameraAngle [get, set]
 The camera angle for the view of the surface. Note: For the game's main surface, this is controlled by the active Scene. More...
 
float CameraZoom [get, set]
 The camera zoom for the view of the surface. Note: For the game's main surface, this is controlled by the active Scene. More...
 
float CameraWidth [get]
 
float CameraHeight [get]
 
override Texture Texture [get]
 The Texture the Surface has rendered to. More...
 
override bool Smooth [get, set]
 Determines the pixel smoothing for the surface. More...
 
- Properties inherited from Otter.Image
Rectangle ClippingRegion [get, set]
 Defines which area of the Image to show. More...
 
bool FlippedX [get, set]
 Flip the texture coordinates on the X axis. More...
 
bool FlippedY [get, set]
 Flip the texture coordinates on the Y axis. More...
 
Color OutlineColor [get, set]
 The outline color of the Image (only applies to circles and rectangles.) More...
 
float OutlineThickness [get, set]
 The outline thickness of the Image (only applies to circles and rectangles.) More...
 
- Properties inherited from Otter.Graphic
Transformation Transform [get]
 
float X [get, set]
 The X position of the Graphic. More...
 
float Y [get, set]
 The Y position of the Graphic. More...
 
float ScaleX [get, set]
 The horizontal scale of the graphic. Used in the final transformation. More...
 
float ScaleY [get, set]
 The vertical scale of the graphic. Used in the final transformation. More...
 
float Angle [get, set]
 The angle of rotation of the graphic. Used in the final transformation. More...
 
float OriginX [get, set]
 The X origin point to scale and rotate the graphic with. Used in the final transformation. More...
 
float OriginY [get, set]
 The Y origin point to scale and rotate the graphic with. Used in the final transformation. More...
 
Color Color [get, set]
 The base color of the Graphic. Multiplies the vertices of the graphic by this color. More...
 
virtual Texture Texture [get, set]
 The texture that the graphic is using. More...
 
float Alpha [get, set]
 The base transparency of the graphic. A shortcut to access the base color's Alpha. More...
 
int Width [get, set]
 The width of the Graphic. More...
 
int Height [get, set]
 The height of the Graphic. More...
 
float ScaledWidth [get, set]
 The width in pixels of the image after applying the X scale. More...
 
float ScaledHeight [get, set]
 The height in pixels of the image after applying the Y scale. More...
 
virtual bool Smooth [get, set]
 Smooth the texture of a sprite image while scaling it. More...
 
float Scroll [get, set]
 Set both ScrollX and ScrollY. More...
 
float HalfWidth [get]
 Half of the width. More...
 
float HalfHeight [get]
 Half of the height. More...
 
float Scale [set]
 Sets both the ScaleX and ScaleY at the same time. More...
 
bool Repeat [set]
 Sets both RepeatX and RepeatY at the same time. More...
 
float Shake [set]
 A shortcut to set both ShakeX and ShakeY. More...
 
float Left [get]
 The X position of the left side of the Graphic. More...
 
float Top [get]
 The Y position of the top of the Graphic. More...
 
float Right [get]
 The X position of the right side of the Graphic. More...
 
float Bottom [get]
 The Y position of the bottom of the Graphic. More...
 
int TextureLeft [get]
 The X position of the left of the Texture. More...
 
int TextureRight [get]
 The X position of the right of the Texture. More...
 
int TextureTop [get]
 The Y position of the top of the Texture. More...
 
int TextureBottom [get]
 The Y position of the bottom of the Texture. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from Otter.Image
static Image CreateRectangle (int width, int height, Color color)
 Creates a rectangle. More...
 
static Image CreateRectangle (Color color)
 Creates a rectangle the size of the active Game window. More...
 
static Image CreateRectangle ()
 Creates a simple black rectangle the size of the active Game window. More...
 
static Image CreateRectangle (int width, int height)
 Creates a rectangle. More...
 
static Image CreateRectangle (int size)
 Creates a rectangle. More...
 
static Image CreateRectangle (int size, Color color)
 Creates a rectangle. More...
 
static Image CreateCircle (int radius, Color color)
 Create a circle. More...
 
static Image CreateCircle (int radius)
 Create a white circle. More...
 
- Static Public Attributes inherited from Otter.Image
static int CirclePointCount = 24
 The amount of points to use when rendering a circle shape. More...
 
- Protected Member Functions inherited from Otter.Image
override void UpdateDrawable ()
 Updates the internal SFML data for rendering. More...
 
- Protected Member Functions inherited from Otter.Graphic
void Append (float x, float y, Color color, float u, float v)
 
void Append (float x, float y, Color color=null)
 
virtual void SFMLRender (Drawable drawable, float x=0, float y=0)
 
- Protected Attributes inherited from Otter.Image
bool flipX = false
 
- Protected Attributes inherited from Otter.Graphic
VertexArray SFMLVertices = new VertexArray(PrimitiveType.Quads)
 
Drawable SFMLDrawable
 
float RepeatSizeX
 
bool roundRendering = true
 
bool Dynamic
 If true the graphic will always update its drawable. More...
 

Detailed Description

Graphic that represents a render target. By default the game uses a master surface to render the game to the window. Be aware of graphics card limiations of render textures when creating surfaces.

Constructor & Destructor Documentation

Otter.Surface.Surface ( int  width,
int  height,
Color  color = null 
)

Creates a Surface with a specified size.

Parameters
widthThe width of the Surface to create.
heightThe height of the Surface to create.
colorThe default fill color of the Surface.
Otter.Surface.Surface ( int  width,
int  height 
)

Creates a Surface of a specified size.

Parameters
widthThe width of the Surface to create.
heightThe height of the Surface to create.
Otter.Surface.Surface ( int  size)

Creates a Surface of a specified size.

Parameters
sizeThe width and height of the Surface to create.
Otter.Surface.Surface ( int  size,
Color  color 
)

Creates a Surface of a specified size.

Parameters
sizeThe width and height of the Surface to create.
colorThe default fill color of the Surface.

Member Function Documentation

void Otter.Surface.AddShader ( Shader  shader)

Add a shader to be drawn on the surface. If "Shader" is set, the shader list is ignored.

Parameters
shaderThe Shader to add.
void Otter.Surface.CameraScene ( Scene  scene)

Matches the view of the surface to the same view of a Scene.

Parameters
sceneThe Scene to match the camera with.
void Otter.Surface.CenterCamera ( float  x,
float  y 
)

Centers the camera of the surface.

Parameters
xThe X position to be the center of the scene.
yThe Y position to be the center of the scene.
void Otter.Surface.Clear ( )

Clears the surface with the fill color.

void Otter.Surface.Clear ( Color  color)

Clears the surface with a specified color.

Parameters
colorThe Color to clear the Surface with.
void Otter.Surface.ClearShaders ( )

Remove all shaders from the surface.

void Otter.Surface.Display ( )

Calls the SFML Display function on the internal render texture. Should be used before any sort of rendering, otherwise the texture will be upside down!

void Otter.Surface.Draw ( Graphic  graphic,
float  x = 0,
float  y = 0 
)

Draws a graphic to this surface.

Parameters
graphicThe Graphic to draw.
xThe X position of the Graphic.
yThe Y position of the Graphic.
void Otter.Surface.DrawToWindow ( Game  game)

Draw the surface directly to the game window. This will refresh the view, and Display the surface, as well as clear it if AutoClear is true.

Parameters
gameThe Game to render to.
void Otter.Surface.DrawToWindow ( )

Draw the Surface to the Game window.

void Otter.Surface.Fill ( Color  color)

Fills the surface with the specified color.

Parameters
colorThe Color to fill the Surface with.
Texture Otter.Surface.GetTexture ( )

Returns a texture by getting the current render texture. I don't know if this works right yet.

Returns
Shader Otter.Surface.PopShader ( )

Remove the top most shader on the list of shaders.

Returns
The removed Shader.
void Otter.Surface.RemoveShader ( Shader  shader)

Remove a shader from the surface.

Parameters
shaderThe Shader to remove.
override void Otter.Surface.Render ( float  x = 0,
float  y = 0 
)
virtual

Draw the Surface.

Parameters
xThe X position offset.
yThe Y position offset.

Reimplemented from Otter.Graphic.

void Otter.Surface.SaveToFile ( string  path = "")

Saves the next completed render to a file. The supported image formats are bmp, png, tga and jpg. Note that this waits until the end of the game's Render() to actually export, otherwise it will be blank!

Parameters
pathThe file path to save to. The type of image is deduced from the extension. If left unspecified the path will be a png file of the current time in the same folder as the executable.
void Otter.Surface.SetShader ( Shader  shader)

Replace all shaders with a single shader. This will be ignored if "Shader" is set.

Parameters
shaderThe Shader to use.
void Otter.Surface.SetView ( float  x,
float  y,
float  angle = 0,
float  zoom = 1f 
)

Set view of the Surface.

Parameters
xThe X position of the view.
yThe Y position of the view.
angleThe angle of the view.
zoomThe zoom of the view.
float Otter.Surface.SurfaceX ( float  x)

Convert an X position into the same position but on the Surface. TODO: Make this work with scale and rotation.

Parameters
xThe X position in the Scene.
Returns
The X position on the Surface.
float Otter.Surface.SurfaceY ( float  y)

Convert a Y position into the same position but on the Surface. TODO: Make this work with scale and rotation.

Parameters
yThe Y position in the Scene.
Returns
The Y position on the Surface.

Member Data Documentation

bool Otter.Surface.AutoClear = true

Determines if the Surface will automatically clear at the start of the next render cycle.

Color Otter.Surface.FillColor

The color that the surface will fill with at the start of each render.

bool Otter.Surface.UseSceneCamera

Determines if the Surface will automatically set its camera to the Scene's camera.

Property Documentation

float Otter.Surface.CameraAngle
getset

The camera angle for the view of the surface. Note: For the game's main surface, this is controlled by the active Scene.

float Otter.Surface.CameraX
getset

The camera X for the view of the surface. Note: For the game's main surface, this is controlled by the active Scene.

float Otter.Surface.CameraY
getset

The camera Y for the view of the surface. Note: For the game's main surface, this is controlled by the active Scene.

float Otter.Surface.CameraZoom
getset

The camera zoom for the view of the surface. Note: For the game's main surface, this is controlled by the active Scene.

Game Otter.Surface.Game
getset

The reference to the Game using this Surface (if it is the main Surface the game is rendering to!)

override bool Otter.Surface.Smooth
getset

Determines the pixel smoothing for the surface.

override Texture Otter.Surface.Texture
get

The Texture the Surface has rendered to.


The documentation for this class was generated from the following file: