SFML community forums

Bindings - other languages => DotNet => Topic started by: Chris12 on March 07, 2012, 11:41:20 am

Title: How to enable antialiasing for rendertexture?
Post by: Chris12 on March 07, 2012, 11:41:20 am
Code: [Select]
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using SFML.Window;
using SFML.Graphics;

namespace SFML_MatrixTest2
{
class Program
{
public static void Main(string[] args)
{
RenderWindow renderWindow = new RenderWindow(new VideoMode(800, 500), "SFML!", Styles.Default, new ContextSettings(0, 0, 8));
renderWindow.Closed += (s, e) => Environment.Exit(0);
renderWindow.SetFramerateLimit(60);

RectangleShape rect = new RectangleShape(new Vector2f(100, 70));
rect.FillColor = Color.Red;
rect.OutlineThickness = 2f;
rect.OutlineColor = Color.Green;

RenderTexture renderTexture = new RenderTexture(100, 100);
Sprite renderSprite = new Sprite(renderTexture.Texture);

while (true)
{
renderWindow.DispatchEvents();
renderWindow.Clear();


renderTexture.Clear(Color.Blue);

rect.Position = new Vector2f(50, 50);
rect.CenterOrigin();
rect.Rotation += 0.2f;

renderTexture.Draw(rect);

renderTexture.Smooth = true;
renderSprite.CenterOrigin();
renderSprite.Rotation = rect.Rotation;
renderSprite.Position = new Vector2f(200, 200);
renderSprite.Scale = new Vector2f(3, 3);
renderWindow.Draw(renderSprite);
renderWindow.Display();
}
}
}
}


Center origin might be missing, its just:
Code: [Select]
internal static void CenterOrigin(this Sprite sprite)
{
sprite.Origin = new SFML.Window.Vector2f(sprite.TextureRect.Width * 0.5f, sprite.TextureRect.Height * 0.5f);
}

internal static void CenterOrigin(this RectangleShape rect)
{
var bounds = rect.GetLocalBounds();
rect.Origin = new Vector2f(bounds.Width * 0.5f, bounds.Height * 0.5f);
}



Anyway, the draw to the render texture doesnt seem to be anti aliased :(
How do I enable it when drawing to render textures?
Title: How to enable antialiasing for rendertexture?
Post by: Laurent on March 07, 2012, 11:50:13 am
Please search before posting:
http://www.sfml-dev.org/forum/viewtopic.php?t=5746&highlight=antialiasing+rendertexture
https://github.com/SFML/SFML/issues/36
Title: How to enable antialiasing for rendertexture?
Post by: Chris12 on March 07, 2012, 11:52:29 am
Oh sorry, I'll search next time.
Thanks :)