16
DotNet / SFML.NET doesn't expose sf::Context
« on: November 17, 2011, 05:59:55 pm »
The person is telling me that he's running with updated drivers.
This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.
Have you tried it on other 64-bits systems?
using System;
using System.Threading;
using SFML.Window;
using SFML.Graphics;
namespace ThreadingTest
{
public class Test
{
static Texture myTexture;
static bool threadOver = false;
static void myThreadProc()
{
myTexture = new Texture("texture.png");
threadOver = true;
}
static void Main()
{
using (var win = new RenderWindow(new VideoMode(640, 480, 32), "threading test"))
{
new Thread(myThreadProc).Start();
win.Closed += (sender, e) => win.Close();
while (win.IsOpened()) {
win.DispatchEvents();
win.Clear(Color.Black);
if (threadOver)
{
using (var mySprite = new Sprite(myTexture))
{
win.Draw(mySprite);
}
}
win.Display();
}
}
}
}
}
Creating many objects every frame is a bad idea. Not because of SFML internals, but because .NET's garbage collector will need to collect them very often. Hence your performance drops.
sprite.Move(speed * clock.GetElapsedTime());
t = img.GetTextureForName("Interface/TileOutline");
using (var spr = new Sprite(t))
{
spr.Position = pos;
spr.Origin = new Vector2f(128, t.Height / 2);
spr.Scale = new Vector2f(zoomLevel, zoomLevel);
spr.Color = color;
info.Target.Draw(spr);
}
string texPath = "hello-world.png";
using (var img = new Image(texPath))
{
var tex = new Texture(img);
tex.Smooth = true;
tex.Bind();
Gl.glTexParameteri(Gl.GL_TEXTURE_2D, Gl.GL_GENERATE_MIPMAP, Gl.GL_TRUE);
Gl.glTexParameteri(Gl.GL_TEXTURE_2D, Gl.GL_TEXTURE_MIN_FILTER, Gl.GL_LINEAR_MIPMAP_LINEAR);
tex.Update(img);
//Store tex somewhere
}