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

Author Topic: Impossible to create render texture (failed to link...  (Read 6684 times)

0 Members and 1 Guest are viewing this topic.

docwild

  • Newbie
  • *
  • Posts: 10
    • View Profile
Impossible to create render texture (failed to link...
« on: August 10, 2014, 10:00:24 pm »
Impossible to create render texture (failed to link the target texture to the framebuffer)

with debug libaries I also get this:

An internal OpenGL call failed in RenderTextureImplFBO.cpp (117)
 : GL_INVALID_OPERATION, the specified operation is not allowed in the current state


Some code which triggers it for me:
#include <SFML/Graphics.hpp>
#include <vector>
#include <algorithm>
#include <iostream>
int main()
{
    std::vector<unsigned int> w;
    std::vector<unsigned int> h;
    for(unsigned int i = 100; i < sf::Texture::getMaximumSize(); i +=500)
    {
        w.push_back(i);
    }
    h.reserve(w.size());
    std::copy(w.begin(),w.end(),h.begin());
    for(unsigned int i =0; i < w.size(); i++)
    {
        std::cout << "i: " << i << std::endl;
        std::cout << "wi: " << w[i] << std::endl;
        std::cout << "hi: " << h[i] << std::endl;
        sf::RenderTexture rt;

        if(!rt.create(w[i],h[i]))
            continue;
        rt.display();
    }
    return 0;
}
Outputs:
i: 0
wi: 100
hi: 100
An internal OpenGL call failed in RenderTextureImplFBO.cpp (117) : GL_INVALID_OPERATION, the specified operation is not allowed in the current state
Impossible to create render texture (failed to link the target texture to the frame buffer)
i: 1
wi: 600
hi: 600
i: 2
wi: 1100
hi: 1100
i: 3
wi: 1600
hi: 1600
i: 4
wi: 2100
hi: 2100
i: 5
wi: 2600
hi: 2600
i: 6
wi: 3100
hi: 3100
i: 7
wi: 3600
hi: 3600

I'm on arch linux with fully up to date sfml. This happens on the open source radeon driver and the intel driver on my laptop.Subsequent textures afer the first get created normally. I can write to them and copy them etc but the first one fails regardless of settings.

Can anyone else reproduce this? Am I doing it wrong? Is it a bug? Do you want more info?


Thanks.

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11030
    • View Profile
    • development blog
    • Email
AW: Impossible to create render texture (failed to link...
« Reply #1 on: August 10, 2014, 10:44:08 pm »
What's your GPU and which exact driver versions did you test?

From the error messrit seems like your GPU doesn't support the render texture implementation which usually only happens with bad drivers or very old GPUs.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

binary1248

  • SFML Team
  • Hero Member
  • *****
  • Posts: 1405
  • I am awesome.
    • View Profile
    • The server that really shouldn't be running
Re: Impossible to create render texture (failed to link...
« Reply #2 on: August 10, 2014, 10:57:04 pm »
Probably same issue as here and here. Your call to sf::Texture::getMaximumSize() before any other GlResource is created breaks context management resulting in sf::RenderTexture going crazy. Since the fix hasn't been merged yet, you can try to create an sf::Context object at the start of your main() if you don't plan on creating a window and see if that fixes the problem.
SFGUI # SFNUL # GLS # Wyrm <- Why do I waste my time on such a useless project? Because I am awesome (first meaning).

docwild

  • Newbie
  • *
  • Posts: 10
    • View Profile
Re: Impossible to create render texture (failed to link...
« Reply #3 on: August 10, 2014, 10:57:54 pm »
RenderTexture does work, I've used them before and it passes the isAvailable test. Like I said, it's only the first iteration which has the problem, it smells of a bug to me.

Nevertheless:

Radeon X1950 PRO RV570
ati-dri: 10.2.5-1

Intel Mobile 4
intel-dri: 10.2.4-1

Did you run the code?


docwild

  • Newbie
  • *
  • Posts: 10
    • View Profile
Re: Impossible to create render texture (failed to link...
« Reply #4 on: August 10, 2014, 11:00:36 pm »
Probably same issue as here and here. Your call to sf::Texture::getMaximumSize() before any other GlResource is created breaks context management resulting in sf::RenderTexture going crazy. Since the fix hasn't been merged yet, you can try to create an sf::Context object at the start of your main() if you don't plan on creating a window and see if that fixes the problem.

Looks like you hit it. As a quick test I replaced the getmaximum with a hardcoded value and the problem disappears. I'll see if I can do the context thingy.

Edit: Keeping an active context before calling getMaximum also fixes this. Thanks
« Last Edit: August 10, 2014, 11:14:47 pm by docwild »

aferents

  • Newbie
  • *
  • Posts: 7
    • View Profile
Re: Impossible to create render texture (failed to link...
« Reply #5 on: August 18, 2014, 07:45:04 am »
i have the same issue but i'm not sure that problem is with getMaximumSize() method in my case.
i try to run following code on mac for ios

window = new RenderWindow(new VideoMode(320, 480), "TestTexture", (int) SFML.NET.Window.Window.Style.Default,
                new ContextSettings());

            var vertices = new[]
                           {
                               new Vertex(new Vector2f(10f, 10f), Color.Green),
                               new Vertex(new Vector2f(100f, 10f), Color.Cyan),
                               new Vertex(new Vector2f(100f, 100f), Color.Blue)
                           };

                var renderTexture = new RenderTexture();
                renderTexture.Create(200u, 200u, false);  
 
                renderTexture.Clear(Color.Gray);
                renderTexture.Draw(vertices, 3u, PrimitiveType.Triangles, RenderStates.Default);
                renderTexture.Display();


                window.Clear();

                var shape = new RectangleShape(new Vector2f(300f, 300f));
                shape.SetTexture(renderTexture.GetTexture());
                window.Draw(shape);
                window.Window.Display();
 

i get An internal OpenGL call failed in unknown (0)
 : GL_INVALID_OPERATION, the specified operation is not allowed in the current state, after renderTextureCreate(200u, 200u, false) method,
then i get Impossible to create render texture (failed to link the target texture to the framebuffer)

main is that on windows desktop this example works well

maybe somebody can help
« Last Edit: August 18, 2014, 08:58:51 am by aferents »

binary1248

  • SFML Team
  • Hero Member
  • *****
  • Posts: 1405
  • I am awesome.
    • View Profile
    • The server that really shouldn't be running
Re: Impossible to create render texture (failed to link...
« Reply #6 on: August 18, 2014, 10:42:54 am »
It would be helpful to know:
  • What operating system you are running. "mac for ios" does not tell me anything and probably doesn't make sense.
  • What graphics hardware you have.
  • What version of the binding (obviously .Net) you are using and what version of SFML it binds to.
  • What the rest of the code, if there is even more, looks like. Provide all your code if it is less than 200 lines.
Besides those points, your problem is clearly not the same as the one discussed previously in this thread, it isn't even similar. The only thing they have in common is the OpenGL error they produce, so please start a new thread next time...
SFGUI # SFNUL # GLS # Wyrm <- Why do I waste my time on such a useless project? Because I am awesome (first meaning).

aferents

  • Newbie
  • *
  • Posts: 7
    • View Profile
Re: Impossible to create render texture (failed to link...
« Reply #7 on: August 18, 2014, 02:34:34 pm »
thanks for reply, next time i will create new thread, so

1. i use mac mini with OS X 10.9.4
2. graphics card Intel HD Graphics 4000, processor Intel Core i5
3. i'm using .Net version of the binding, i use the latest version of SFML from sources
maybe it is important i use Xamarin studio to run .Net code on mac
4. It is the Application class with main method

using System;
using System.Collections.Generic;
using System.Linq;
using MonoTouch.Foundation;
using MonoTouch.UIKit;
using System.Drawing;
using OpenTK.Graphics.ES11;
using SFML.IOS.IOS;
using SFML.NET.Graphics;

namespace GLPaintGameView
{
        public class Application
        {
                static void Main (string[] args)
                {
                        UIApplication.Main (args);
                }
        }

        // The name AppDelegate is referenced in the MainWindow.xib file.
        public partial class AppDelegate : SFAppDelegate
        {
                // This method is invoked when the application has loaded its UI and its ready to run
                public override bool FinishedLaunching (UIApplication app, NSDictionary options)
                {
                        SFML.NET.Window.Platform.Instance = new SFML.NET.iOS.IosPlatform ();

                        var test = new RenderTextureExample ();
                        test.Run ();

               
                        return true;
                }

                // This method is required in iPhoneOS 3.0
                public override void OnActivated (UIApplication application)
                {
                }

        }
}

 

it is the example

using System;
using SFML.NET.Graphics;
using SFML.NET.Systems;
using MonoTouch.UIKit;
using MonoTouch.Foundation;
using MonoTouch.CoreGraphics;

namespace GLPaintGameView
{
        public class RenderTextureExample
        {
                static RenderWindow window;

                public void Run()
                {
                        window = new RenderWindow (new SFML.NET.Window.VideoMode (400, 400), "SFML for Ios", (int)SFML.NET.Window.Window.Style.Default, new SFML.NET.Systems.ContextSettings ());

                        var vertices = new[] {
                                new Vertex (new Vector2f (10f, 10f), Color.Green),
                                new Vertex (new Vector2f (100f, 10f), Color.Cyan),
                                new Vertex (new Vector2f (100f, 100f), Color.Blue)
                        };

                        var renderTexture = new RenderTexture ();

                        renderTexture.Create (200u, 200u, false);

                        renderTexture.Clear (Color.Red);

                        renderTexture.Draw (vertices, 3u, PrimitiveType.Triangles, RenderStates.Default);
                        renderTexture.Display ();

                        window.Clear ();

                        var shape = new RectangleShape (new Vector2f (300f, 300f));

                        shape.SetTexture (renderTexture.GetTexture ());
                                //shape.SetPosition (new Vector2f (300f, 30f));

                        window.Draw (shape);

                        window.Window.Display ();
                }
        }
}

 

it is the IosPlatform class

namespace SFML.NET.iOS
{
    using System;
    using System.Collections.Generic;

    using MonoTouch.UIKit;

    using SFML.IOS.IOS;
    using SFML.NET.Systems;
    using SFML.NET.Window;

    public class IosPlatform : Platform
    {
        public override VideoMode GetDesktopMode()
        {
            var bounds = UIScreen.MainScreen.Bounds;
            return new VideoMode((uint)bounds.Size.Width, (uint)bounds.Size.Height);
        }

        public override List<VideoMode> GetFullscreenModes()
        {
            var desktop = this.GetDesktopMode();
            var list = new List<VideoMode>();
            list.Add(desktop);
            list.Add(new VideoMode(desktop.height, desktop.width, desktop.bitsPerPixel));
            return list;
        }

        public override GlContext CreateContext(EaglContext shared)
        {
            return new EaglContext(shared);
        }

                public override GlContext CreateContext(EaglContext shared, ContextSettings settings, WindowImplUiKit owner, uint bitsPerPixel)
        {
            return new EaglContext(shared, settings, owner, bitsPerPixel);
        }

        public override GlContext CreateContext(EaglContext shared, ContextSettings settings, uint width, uint height)
        {
            return new EaglContext(shared, settings, width, height);
        }

        public override PlatformWindow CreateWindow(VideoMode mode, string title, uint style, ContextSettings settings)
        {
            return new WindowImplUiKit(mode, title, style, settings);
        }

        public override PlatformWindow CreateWindow(Window owner)
        {
            return new WindowImplUiKit(owner);
        }
    }
}
 

 

zsbzsb

  • Hero Member
  • *****
  • Posts: 1409
  • Active Maintainer of CSFML/SFML.NET
    • View Profile
    • My little corner...
    • Email
Re: Impossible to create render texture (failed to link...
« Reply #8 on: August 18, 2014, 02:46:08 pm »
Please read the following post and then provide a complete and minimal example.

http://en.sfml-dev.org/forums/index.php?topic=5559.msg36368#msg36368
Motion / MotionNET - Complete video / audio playback for SFML / SFML.NET

NetEXT - An SFML.NET Extension Library based on Thor

binary1248

  • SFML Team
  • Hero Member
  • *****
  • Posts: 1405
  • I am awesome.
    • View Profile
    • The server that really shouldn't be running
Re: Impossible to create render texture (failed to link...
« Reply #9 on: August 18, 2014, 03:13:49 pm »
I still don't get why you are messing around with EaglContext in this IosPlatform class of yours... Why do you even need that class? What are you even trying to achieve?

You should take one step back and actually tell us what you original goal was, before modifying the behaviour of SFML.

SFML does not officially support hooking in your own context management behaviour, so any code that does that is more than likely to break.
SFGUI # SFNUL # GLS # Wyrm <- Why do I waste my time on such a useless project? Because I am awesome (first meaning).

 

anything