Gorgon 2, Simple texture rendering which I can't make work?

Need to know how to do something in Gorgon? Got some info on how to do something in Gorgon? Got something that relates to Gorgon but doesn't fit anywhere else? Well now it fits here. Submit!
Forum rules
Try to keep it Gorgon related please.

  • So I Popped in here quite a while ago but due to other issues I stopped writing code for a while.

    Recently I started playing with the Gorgon 2 library which I somewhat really like the look of.

    I can't do render to texture however. Nothing happens to it and I sure i'm missing somthing stupid simple. Flipping the render buffer to the texture or somthing but no such task seems to be needed on the main rendering task? Just the call to Gorgon2D.Render()

    I already have it rendering text to the screen without issue but I can't render it to the texture.

    Setup(In different areas)
    Code: Select all
    //Texture creation
                 newtexture = Program.GameLogic.Graphics.Textures.CreateTexture(string.Format("Nondescript_Texture:_{0}x{1}", width, height), width, height, BufferFormat.R8G8B8A8_UIntNormal, BufferUsage.Default);

    //Elsewhere Target creation
                _target = _texture.Graphics.Output.CreateRenderTarget("SurfaceTarget", new GorgonRenderTarget2DSettings
                    DepthStencilFormat = BufferFormat.Unknown,
                    Width = Width,
                    Height = Height,
                    Format = BufferFormat.R8G8B8A8_UIntNormal,
                    Multisampling = GorgonMultisampling.NoMultiSampling

    //Elsewhere Renderer creation
               _gorgonText = Program.GameLogic.Renderer2D.Renderables.CreateText(name + "_label", fontInfo.GFont, text);

    Code: Select all
    //_preRenderdSurface contains the above texture and target.
    // Renderer2D = Gorgon2D instance
                Program.GameLogic.Renderer2D.Target = _preRenderdSurface.Target;


                _gorgonText.Text = _text;
                _gorgonText.Color = Color.Black;
                _gorgonText.Position = new SlimMath.Vector2(0, 0);

    //This was a guess but it did nothing.

                Program.GameLogic.Renderer2D.Target = null;

    //This is to test the output at this frame
                _preRenderdSurface.Save(@"C:\testing\debug" + (test++).ToString() + ".png");
    User avatar

  • You shouldn't need to call Render() since setting the target to NULL (or any other target) will do the exact same thing.

    I whipped up a quick bit of code to ensure that the text rendering/render target stuff is working properly, and it generated text on a render target for me, so I'm not sure why you're not seeing anything.

    Code: Select all
                GorgonGraphics g = new GorgonGraphics();
                Gorgon2D r = g.Output.Create2DRenderer(this, 640, 480);
                GorgonFont f = g.Fonts.CreateFont("MyFont", this.Font, FontAntiAliasMode.AntiAlias);
                GorgonRenderTarget2D target = g.Output.CreateRenderTarget("Target",
                                                                          new GorgonRenderTarget2DSettings
                                                                             Width = 640,
                                                                             Height = 480,
                                                                             Format = BufferFormat.R8G8B8A8_UIntNormal
                GorgonText text = r.Renderables.CreateText("MyText", f, "Test text", Color.Black);

                r.Target = target;


                r.Target = null;

                target.Save(@"text.png", new GorgonCodecPNG());

    The first thing I'd look at is whether _preRenderedSurface.Target is the correct render target. Also, ensure that _text actually has text in it, Gorgon won't bother to render anything when there's no text to render.

    Everything else in that code looks to be correct as near as I can see.
    haikus are easy
    but sometimes they don't make sense
    User avatar
    Site Admin
    Site Admin
    Posts: 324
    Joined: Wed Feb 27, 2008 9:15 pm
    Location: Canada

  • I figured it out. I also fixed my references so that the xml documentation works now. I wish I had done that sooner. I might have avoided this whole mess had I done it sooner.

    Code: Select all
            public void Save(string Path)
                _texture.Save(Path, new GorgonLibrary.IO.GorgonCodecPNG());


    Code: Select all
            public void Save(string Path)
                _target.Save(Path, new GorgonLibrary.IO.GorgonCodecPNG());

    I see my text.

    Reviewing the code I realze my error in thinking RenderTarget was somthing else its self is used as a texture.

    I stometimes feel like I have no idea what I am doing. It also doesn't help I am trying to re-import and reuse a half finished library first wrapped around SDL.net then agatelib.

    Anyways I fixed my surface class and everything works now.
    User avatar


Return to General

  • Who is online
  • Users browsing this forum: No registered users and 1 guest