本文整理汇总了C#中RenderTarget.GetView方法的典型用法代码示例。如果您正苦于以下问题:C# RenderTarget.GetView方法的具体用法?C# RenderTarget.GetView怎么用?C# RenderTarget.GetView使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RenderTarget
的用法示例。
在下文中一共展示了RenderTarget.GetView方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Draw
public override void Draw(RenderTarget r)
{
var text = ((int)(1000/EntityManager.FrameTime)).ToString () + " FPS";
DebugText = new Text(text, DebugText.Font)
{Position = r.GetView ().Center - r.GetView ().Size/2, Color = DebugText.Color};
r.Draw (DebugText);
}
示例2: Draw
public override void Draw(RenderTarget rt)
{
base.Draw(rt);
var textBackSize = new Vector2f(150, 54);
var textBack = new RectangleShape(textBackSize);
textBack.FillColor = new Color(0, 0, 0, 150);
textBack.Origin = textBackSize / 2;
textBack.Position = rt.GetView().Center;
var text = new Text("PAUSED", Assets.LoadFont("OpenSans-Regular.ttf"), 32);
text.Color = Color.White;
text.Position = rt.GetView().Center;
text.Center();
rt.Draw(textBack);
rt.Draw(text);
}
示例3: Draw
public static void Draw(RenderTarget surface)
{
if (EntityToFollow != null)
{
surface.SetView (new View(EntityToFollow.GetPosition (), surface.GetView ().Size));
}
surface.Clear (BackgroundColor);
foreach (Entity e in Entities)
e._Draw (surface);
}
示例4: Draw
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// <summary>
/// Draws the widget on the render target
/// </summary>
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
public override void Draw(RenderTarget target, RenderStates states)
{
// Calculate the scale factor of the view
float scaleViewX = target.Size.X / target.GetView().Size.X;
float scaleViewY = target.Size.Y / target.GetView().Size.Y;
// Get the global position
Vector2f topLeftPosition = states.Transform.TransformPoint(Position - target.GetView().Center + (target.GetView().Size / 2.0f));
Vector2f bottomRightPosition = states.Transform.TransformPoint(Position + m_Size - target.GetView().Center + (target.GetView().Size / 2.0f));
// Adjust the transformation
states.Transform *= Transform;
// Calculate the scale of the slider
Vector2f scaling;
scaling.X = m_Size.X / m_TextureTrackNormal.Size.X;
scaling.Y = m_Size.Y / m_TextureTrackNormal.Size.Y;
// Set the scale of the slider
states.Transform.Scale(scaling);
// Draw the track image
if (m_SeparateHoverImage)
{
if (m_MouseHover && (m_WidgetPhase & (byte)WidgetPhase.Hover) != 0)
target.Draw(m_TextureTrackHover.sprite, states);
else
target.Draw(m_TextureTrackNormal.sprite, states);
}
else // The hover image should be drawn on top of the normal image
{
target.Draw(m_TextureTrackNormal.sprite, states);
if (m_MouseHover && (m_WidgetPhase & (byte)WidgetPhase.Hover) != 0)
target.Draw(m_TextureTrackHover.sprite, states);
}
// Undo the scale
states.Transform.Scale(1.0f / scaling.X, 1.0f / scaling.Y);
// Check if the thumb should be scaled together with the slider
if (m_FixedThumbSize)
{
states.Transform.Translate((((m_Value.X - m_Minimum.X) / (m_Maximum.X - m_Minimum.X)) * m_TextureTrackNormal.Size.X * scaling.X) - (m_TextureThumbNormal.Size.X * 0.5f),
(((m_Value.Y - m_Minimum.Y) / (m_Maximum.Y - m_Minimum.Y)) * m_TextureTrackNormal.Size.Y * scaling.Y) - (m_TextureThumbNormal.Size.Y * 0.5f));
}
else // The thumb must be scaled
{
states.Transform.Translate((((m_Value.X - m_Minimum.X) / (m_Maximum.X - m_Minimum.X)) * m_TextureTrackNormal.Size.X * scaling.X) - (m_TextureThumbNormal.Size.X * 0.5f * scaling.Y),
(((m_Value.Y - m_Minimum.Y) / (m_Maximum.Y - m_Minimum.Y)) * m_TextureTrackNormal.Size.Y * scaling.Y) - (m_TextureThumbNormal.Size.Y * 0.5f * scaling.X));
// Set the scale for the thumb
states.Transform.Scale(scaling);
}
// Get the old clipping area
int[] scissor = new int[4];
Gl.glGetIntegerv(Gl.GL_SCISSOR_BOX, scissor);
// Calculate the clipping area
int scissorLeft = System.Math.Max((int)(topLeftPosition.X * scaleViewX), scissor[0]);
int scissorTop = System.Math.Max((int)(topLeftPosition.Y * scaleViewY), (int)(target.Size.Y) - scissor[1] - scissor[3]);
int scissorRight = System.Math.Min((int)(bottomRightPosition.X * scaleViewX), scissor[0] + scissor[2]);
int scissorBottom = System.Math.Min((int)(bottomRightPosition.Y * scaleViewY), (int)(target.Size.Y) - scissor[1]);
// If the object outside the window then don't draw anything
if (scissorRight < scissorLeft)
scissorRight = scissorLeft;
else if (scissorBottom < scissorTop)
scissorTop = scissorBottom;
// Set the clipping area
Gl.glScissor(scissorLeft, (int)(target.Size.Y - scissorBottom), scissorRight - scissorLeft, scissorBottom - scissorTop);
// Draw the thumb image
if (m_SeparateHoverImage)
{
if (m_MouseHover && (m_WidgetPhase & (byte)WidgetPhase.Hover) != 0)
target.Draw(m_TextureThumbHover.sprite, states);
else
target.Draw(m_TextureThumbNormal.sprite, states);
}
else // The hover image should be drawn on top of the normal image
{
target.Draw(m_TextureThumbNormal.sprite, states);
if (m_MouseHover && (m_WidgetPhase & (byte)WidgetPhase.Hover) != 0)
target.Draw(m_TextureThumbHover.sprite, states);
}
// Reset the old clipping area
Gl.glScissor(scissor[0], scissor[1], scissor[2], scissor[3]);
}
示例5: CalcVisibleBounds
public IntRect CalcVisibleBounds(RenderTarget target) {
var vp = target.GetView();
float leftBorder = Math.Max(0, vp.Center.X - vp.Size.X / 2);
float topBorder = Math.Max(0, vp.Center.Y - vp.Size.Y / 2);
float regionWidth = Math.Min(Width - leftBorder + 1, vp.Size.X + 1);
float regionHeight = Math.Min(Height - topBorder + 1, vp.Size.Y + 1);
return new IntRect((int) leftBorder, (int) topBorder,
(int) regionWidth, (int) regionHeight);
}
示例6: CalcView
public View CalcView(RenderTarget app) {
var view = app.GetView();
// Can't view to the right, left, above or below of the map.
var x = player.Box.Position.X.Clamp(view.Size.X / 2, level.Width - view.Size.X / 2);
var y = player.Box.Position.Y.Clamp(view.Size.Y / 2, level.Height - view.Size.Y / 2);
view.Center = new Vector2f(x, y);
return view;
}
示例7: Draw
public void Draw(RenderTarget target, RenderStates states) {
View view = new View(target.GetView());
View bgView = new View(view);
bgView.Center = v2f(bgView.Size.X + bgView.Center.X * 0.5F, bgView.Center.Y);
target.SetView(bgView);
background.Draw(target, states);
target.SetView(view);
DrawBlocks(target, states, CalcVisibleBounds(target));
}
示例8: WindowContainsLight
bool WindowContainsLight(RenderTarget window, LightEffect effect)
{
const float DRAW_MARGIN = 20F;
Vector2f viewTopLeft = window.GetView().Center - window.GetView().Size / 2F;
Vector2f viewBottomRight = viewTopLeft + window.GetView().Size;
FloatRect viewRect = new FloatRect(
viewTopLeft.X - DRAW_MARGIN,
viewTopLeft.Y - DRAW_MARGIN,
viewBottomRight.X + DRAW_MARGIN,
viewBottomRight.Y + DRAW_MARGIN);
return !(
effect.Right < viewRect.Left ||
effect.Bottom < viewRect.Top ||
effect.Left >= viewRect.Right ||
effect.Top >= viewRect.Bottom);
}
示例9: Draw
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// <summary>
/// Draws the widget on the render target
/// </summary>
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
public override void Draw(RenderTarget target, RenderStates states)
{
// Calculate the scale factor of the view
float scaleViewX = target.Size.X / target.GetView().Size.X;
float scaleViewY = target.Size.Y / target.GetView().Size.Y;
Vector2f viewPosition = (target.GetView ().Size / 2.0f) - target.GetView ().Center;
// Get the global position
Vector2f topLeftPosition = states.Transform.TransformPoint(Position + viewPosition);
Vector2f bottomRightPosition = states.Transform.TransformPoint(Position.X + m_ListBox.Size.X - (m_TextureArrowDownNormal.Size.X * ((float)(m_ListBox.ItemHeight) / m_TextureArrowDownNormal.Size.Y)) + viewPosition.X,
Position.Y + m_ListBox.Size.Y + viewPosition.Y);
// Adjust the transformation
states.Transform *= Transform;
// Remember the current transformation
Transform oldTransform = states.Transform;
// Draw left border
RectangleShape border = new RectangleShape(new Vector2f(m_Borders.Left, m_ListBox.ItemHeight + m_Borders.Top));
border.Position = new Vector2f(-(float)m_Borders.Left, -(float)m_Borders.Top);
border.FillColor = m_ListBox.BorderColor;
target.Draw(border, states);
// Draw top border
border.Size = new Vector2f(m_ListBox.Size.X + m_Borders.Right, m_Borders.Top);
border.Position = new Vector2f(0, -(float)m_Borders.Top);
target.Draw(border, states);
// Draw right border
border.Size = new Vector2f(m_Borders.Right, m_ListBox.ItemHeight + m_Borders.Bottom);
border.Position = new Vector2f(m_ListBox.Size.X, 0);
target.Draw(border, states);
// Draw bottom border
border.Size = new Vector2f(m_ListBox.Size.X + m_Borders.Left, m_Borders.Bottom);
border.Position = new Vector2f(-(float)m_Borders.Left, m_ListBox.ItemHeight);
target.Draw(border, states);
// Draw the combo box
RectangleShape front = new RectangleShape (new Vector2f((float)(m_ListBox.Size.X), (float)(m_ListBox.ItemHeight)));
front.FillColor = m_ListBox.BackgroundColor;
target.Draw(front, states);
// Create a text widget to draw it
Text tempText = new Text("kg", m_ListBox.TextFont);
tempText.CharacterSize = m_ListBox.ItemHeight;
tempText.CharacterSize = (uint)(tempText.CharacterSize - tempText.GetLocalBounds().Top);
tempText.Color = m_ListBox.TextColor;
// Get the old clipping area
int[] scissor = new int[4];
Gl.glGetIntegerv(Gl.GL_SCISSOR_BOX, scissor);
// Calculate the clipping area
int scissorLeft = System.Math.Max((int)(topLeftPosition.X * scaleViewX), scissor[0]);
int scissorTop = System.Math.Max((int)(topLeftPosition.Y * scaleViewY), (int)(target.Size.Y) - scissor[1] - scissor[3]);
int scissorRight = System.Math.Min((int)(bottomRightPosition.X * scaleViewX), scissor[0] + scissor[2]);
int scissorBottom = System.Math.Min((int)(bottomRightPosition.Y * scaleViewY), (int)(target.Size.Y) - scissor[1]);
// If the widget outside the window then don't draw anything
if (scissorRight < scissorLeft)
scissorRight = scissorLeft;
else if (scissorBottom < scissorTop)
scissorTop = scissorBottom;
// Set the clipping area
Gl.glScissor(scissorLeft, (int)(target.Size.Y - scissorBottom), scissorRight - scissorLeft, scissorBottom - scissorTop);
// Draw the selected item
states.Transform.Translate(2, (float)System.Math.Floor((m_ListBox.ItemHeight - tempText.GetLocalBounds().Height) / 2.0f - tempText.GetLocalBounds().Top));
tempText.DisplayedString = m_ListBox.GetSelectedItem();
target.Draw(tempText, states);
// Reset the old clipping area
Gl.glScissor(scissor[0], scissor[1], scissor[2], scissor[3]);
// Reset the transformations
states.Transform = oldTransform;
// Set the arrow like it should (down when list box is invisible, up when it is visible)
if (m_ListBox.Visible)
{
float scaleFactor = (float)(m_ListBox.ItemHeight) / m_TextureArrowUpNormal.Size.Y;
states.Transform.Translate(m_ListBox.Size.X - m_TextureArrowUpNormal.Size.X * scaleFactor, 0);
states.Transform.Scale(scaleFactor, scaleFactor);
// Draw the arrow
if (m_SeparateHoverImage)
{
if ((m_MouseHover) && ((m_WidgetPhase & (byte)WidgetPhase.Hover) != 0))
target.Draw(m_TextureArrowUpHover.sprite, states);
else
//.........这里部分代码省略.........
示例10: Draw
public void Draw(RenderTarget rt)
{
var view = rt.GetView();
var tileSize = GameOptions.TileSize;
var chunkSize = GameOptions.TileChunkSize;
var startX = (int)Math.Max(0, ((view.Center.X - (view.Size.X / 2)) / tileSize) / chunkSize);
var startY = (int)Math.Max(0, ((view.Center.Y - (view.Size.Y / 2)) / tileSize) / chunkSize);
var endX = (int)Math.Ceiling(Math.Min(chunks.GetUpperBound(0) + 1, startX + 1 + ((view.Size.X / tileSize) / chunkSize)));
var endY = (int)Math.Ceiling(Math.Min(chunks.GetUpperBound(1) + 1, startY + 1 + ((view.Size.Y / tileSize) / chunkSize)));
for (var y = startY; y < endY; y++)
{
for (var x = startX; x < endX; x++)
{
rt.Draw(chunks[x, y]);
}
}
}
示例11: Draw
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// <summary>
/// Draws the widget on the render target
/// </summary>
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
public override void Draw(RenderTarget target, RenderStates states)
{
// Get the old clipping area
int[] scissor = new int[4];
Gl.glGetIntegerv(Gl.GL_SCISSOR_BOX, scissor);
// Calculate the scale factor of the view
float scaleViewX = target.Size.X / target.GetView().Size.X;
float scaleViewY = target.Size.Y / target.GetView().Size.Y;
// Apply the transformations
states.Transform *= Transform;
float scalingY = m_TabHeight / (float)(m_TextureNormal_M.Size.Y);
bool clippingRequired = false;
uint tabWidth;
FloatRect realRect;
FloatRect defaultRect;
Text tempText = new Text(m_Text);
// Calculate the height and top of all strings
tempText.DisplayedString = "kg";
defaultRect = tempText.GetLocalBounds();
// Loop through all tabs
for (int i = 0; i < m_TabNames.Count; ++i)
{
// Find the tab height
if (m_MaximumTabWidth != 0)
{
if (m_MaximumTabWidth < m_NameWidth[i] + (2 * m_DistanceToSide))
{
tabWidth = m_MaximumTabWidth;
clippingRequired = true;
}
else
tabWidth = (uint)(m_NameWidth[i] + (2 * m_DistanceToSide));
}
else
tabWidth = (uint)(m_NameWidth[i] + (2 * m_DistanceToSide));
// There is a minimum tab width
if (tabWidth < 2 * m_DistanceToSide)
tabWidth = 2 * m_DistanceToSide;
// Check if the image is split
if (m_SplitImage)
{
// There is another minimum when using SplitImage
float minimumWidth = (m_TextureNormal_L.Size.X + m_TextureNormal_R.Size.X) * scalingY;
if (tabWidth < minimumWidth)
tabWidth = (uint)(minimumWidth);
// Set the scaling
states.Transform.Scale(scalingY, scalingY);
// Draw the left tab image
if (m_SeparateSelectedImage)
{
if ((m_SelectedTab == i) && ((m_WidgetPhase & (byte)WidgetPhase.Selected) != 0))
target.Draw(m_TextureSelected_L.sprite, states);
else
target.Draw(m_TextureNormal_L.sprite, states);
}
else // There is no separate selected image
{
target.Draw(m_TextureNormal_L.sprite, states);
if ((m_SelectedTab == i) && ((m_WidgetPhase & (byte)WidgetPhase.Selected) != 0))
target.Draw(m_TextureSelected_L.sprite, states);
}
// Check if the middle image may be drawn
if ((scalingY * (m_TextureNormal_L.Size.X + m_TextureNormal_R.Size.X)) < tabWidth)
{
// Calculate the scale for our middle image
float scaleX = (tabWidth / (float)(m_TextureNormal_M.Size.X)) - (((m_TextureNormal_L.Size.X + m_TextureNormal_R.Size.X) * scalingY) / m_TextureNormal_M.Size.X);
// Put the middle image on the correct position
states.Transform.Translate((float)(m_TextureNormal_L.Size.X), 0);
// Set the scale for the middle image
states.Transform.Scale(scaleX / scalingY, 1);
// Draw the middle tab image
if (m_SeparateSelectedImage)
{
if ((m_SelectedTab == i) && ((m_WidgetPhase & (byte)WidgetPhase.Selected) != 0))
target.Draw(m_TextureSelected_M.sprite, states);
else
target.Draw(m_TextureNormal_M.sprite, states);
}
else // There is no separate selected image
{
//.........这里部分代码省略.........
示例12: Draw
public void Draw(RenderTarget window)
{
int left = (int)(window.GetView().Center.X - window.GetView().Size.X / 2) / GameData.TILE_SIZE - GameData.GROUND_DRAW_MARGIN;
int top = (int)(window.GetView().Center.Y - window.GetView().Size.Y / 2) / GameData.TILE_SIZE - GameData.GROUND_DRAW_MARGIN;
int right = (int)(window.GetView().Center.X + window.GetView().Size.X / 2) / GameData.TILE_SIZE + GameData.GROUND_DRAW_MARGIN;
int bottom = (int)(window.GetView().Center.Y + window.GetView().Size.Y / 2) / GameData.TILE_SIZE + GameData.GROUND_DRAW_MARGIN;
int minLeft = 0;
int minTop = 0;
int maxRight = Width;
int maxBottom = Height;
if (left < minLeft)
left = minLeft;
if (top < minTop)
top = minTop;
if (right > maxRight)
right = maxRight;
if (bottom > maxBottom)
bottom = maxBottom;
for (int line = top; line < bottom; ++line)
for (int column = left; column < right; ++column)
GetCell(column, line).Draw(window);
}
示例13: Draw
public void Draw(RenderTarget target, RenderStates states)
{
var view = target.GetView();
// get dimensions of viewing window
var topLeft = new Vector2i((int) (view.Center.X - view.Size.X / 2f),
(int) (view.Center.Y - view.Size.Y / 2f));
var bottomRight = new Vector2i((int) (view.Center.X + view.Size.X / 2f),
(int) (view.Center.Y + view.Size.Y / 2f));
topLeft /= CellSize;
bottomRight /= CellSize;
// pad / restrict bounds
if (topLeft.X >= 2) topLeft.X -= 2;
if (topLeft.X < 0) topLeft.X = 0;
if (topLeft.Y >= 2) topLeft.Y -= 2;
if (topLeft.Y < 0) topLeft.Y = 0;
if (bottomRight.X < Size.X) bottomRight.X += 2;
if (bottomRight.X > Size.X) bottomRight.X = Size.X;
if (bottomRight.Y < Size.Y) bottomRight.Y += 2;
if (bottomRight.Y > Size.Y) bottomRight.Y = Size.Y;
// draw world
for (var x = topLeft.X; x < bottomRight.X; x++)
{
for (var y = topLeft.Y; y < bottomRight.Y; y++)
{
// draw layer 0 tiles (floors, etc)
Layer0Cells[x, y].Draw(target, states);
// draw layer 1 tiles (walls, collidables)
Layer1Cells[x, y].Draw(target, states);
}
}
// draw entities
foreach (var e in _entities)
e.Update(target, this);
// draw layer 2 tiles (non - collidables)
for (var x = topLeft.X; x < bottomRight.X; x++)
{
for (var y = topLeft.Y; y < bottomRight.Y; y++)
{
if (Layer2Cells[x, y].IsEmpty()) continue;
Layer2Cells[x, y].Draw(target, states);
}
}
// draw lights to light texture buffer
_lightTexture.Clear(AmbientLightColor);
foreach (var light in _lights)
_lightTexture.Draw(light);
_lightTexture.Display();
// multiply the light texture with the screen
_lightSprite.Draw(target, new RenderStates(BlendMode.Multiply));
}
示例14: Draw
public void Draw(RenderTarget rt, RenderStates states)
{
var view = rt.GetView();
//states.Texture = tilesettexture;
foreach (var kv in vertexArrays)
{
states.Texture = tilesetTextures[kv.Key];
kv.Value.Draw(rt, states);
}
/*
for ( var y = 0; y < Height - 1; y++ )
for ( var x = 0; x < Width - 1; x++ )
{
Tile tile = tiles[x, y];
var sprite = new Sprite(tilesettexture);
sprite.Position = new Vector2f(
(y * 96 / 2) + (x * 96 / 2),
(x * 48 / 2) - (y * 48 / 2)
);
rt.Draw(sprite);
}
*/
}
示例15: Draw
public void Draw(RenderTarget window)
{
if (!IsActive)
return;
RenderTexture.SetView(window.GetView());
RenderTexture.Clear(GlobalColor);
foreach (LightEffect effect in DynamicEffects)
if (WindowContainsLight(window, effect))
effect.Draw(RenderTexture);
foreach (LightEffect effect in StaticEffects)
if (WindowContainsLight(window, effect))
effect.Draw(RenderTexture);
RenderTexture.Display();
Sprite sprite = new Sprite(RenderTexture.Texture);
sprite.BlendMode = BlendMode.Multiply;
sprite.Position = window.GetView().Center - window.GetView().Size / 2F;
window.Draw(sprite, BlurEffect);
}