SFML community forums
Bindings - other languages => DotNet => Topic started by: zombiekiller222 on October 06, 2011, 01:30:33 pm
-
using System;
using SFML.Window;
using SFML.Graphics;
namespace Utilities
{
public class Utilities
{
public static Sprite TextToSprite (Text text)
{
FloatRect textb=text.GetRect();
RenderTexture rtex = new RenderTexture((uint)textb.Width, (uint)textb.Height);
rtex.Draw (text);
return new Sprite(rtex.Texture);
}
}
}
Returns an error:
Failed to share the OpenGL context
Impossible to create render texture (failed to link the target texture to the fr
ame buffer)
The failed to create an Opengl texture is a seperate error, I would assume, which causes the second.
-
Can you show a complete and minimal source code that reproduces the problem?
-
With the other peice of the code:
using System;
using SFML.Window;
using SFML.Graphics;
using SFML.Audio;
using Utilities;
namespace IsoGame
{
static class Program
{
private static uint width = 800;
private static uint height = 600;
static void Main ()
{
RenderWindow window = new RenderWindow(new VideoMode(width, height), "Retrogons");
while (true)
{
Render(window);
}
}
private static void Render (RenderWindow window)
{
window.Clear();
Text error = new Text("Play");
error.Position = new Vector2f(width/2, height/2);
Utilities.Utilities.TextToSprite(error);
window.Display();
}
}
}
-
Works for me, except that the text position is out of the render-texture area ;)
But no error message, and with position at (0, 0) it works as expected.
-
Strange... What could the problem possibly be? Also, is my method of converting a text into a sprite bad? Btw, off topic, but why is image.Pixels 1 dimensional?
-
What could the problem possibly be?
Your graphics drivers ;)
Also, is my method of converting a text into a sprite bad?
No. But I hope that you have a good reason for doing so :P
Btw, off topic, but why is image.Pixels 1 dimensional?
Because internally, the pixels are stored in a contiguous array in memory. Much easier to work with (at least from a C++ point of view).
-
I'm using an intel integrated graphics card, and I'm not sure which driver I should update? The chipset driver, or some other driver?
-
I'm using an intel integrated graphics card
Oh... so a driver update may not be enough :lol:
I'm not sure which driver I should update? The chipset driver, or some other driver?
I don't know, I never worked with integrated graphics.