Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: How to enable antialiasing for rendertexture?  (Read 5050 times)

0 Members and 2 Guests are viewing this topic.

Chris12

  • Newbie
  • *
  • Posts: 20
    • View Profile
How to enable antialiasing for rendertexture?
« 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?

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Laurent Gomila - SFML developer

Chris12

  • Newbie
  • *
  • Posts: 20
    • View Profile
How to enable antialiasing for rendertexture?
« Reply #2 on: March 07, 2012, 11:52:29 am »
Oh sorry, I'll search next time.
Thanks :)