SFML community forums

Bindings - other languages => DotNet => Topic started by: zombiekiller222 on October 06, 2011, 01:30:33 pm

Title: Impossible to create rendertexture?...
Post by: zombiekiller222 on October 06, 2011, 01:30:33 pm
Code: [Select]
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.
Title: Impossible to create rendertexture?...
Post by: Laurent on October 06, 2011, 02:12:38 pm
Can you show a complete and minimal source code that reproduces the problem?
Title: Impossible to create rendertexture?...
Post by: zombiekiller222 on October 06, 2011, 02:17:41 pm
With the other peice of the code:

Code: [Select]
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();
}
}
}
Title: Impossible to create rendertexture?...
Post by: Laurent on October 06, 2011, 06:26:27 pm
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.
Title: Impossible to create rendertexture?...
Post by: zombiekiller222 on October 07, 2011, 12:02:38 am
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?
Title: Impossible to create rendertexture?...
Post by: Laurent on October 07, 2011, 07:55:46 am
Quote
What could the problem possibly be?

Your graphics drivers ;)

Quote
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

Quote
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).
Title: Impossible to create rendertexture?...
Post by: zombiekiller222 on October 07, 2011, 08:39:05 am
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?
Title: Impossible to create rendertexture?...
Post by: Laurent on October 07, 2011, 08:58:48 am
Quote
I'm using an intel integrated graphics card

Oh... so a driver update may not be enough :lol:

Quote
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.