Search code examples
c#openglopentkopengl-4

OpenTK: Sprites not Rendering?


I have been able to get the window to render, Im pretty sure my shader is working, and I can fetch the Image from my assets, however when I actually render the view I just get my blue background and no sprite shows up.

Basic design is as follows:

Views inherit the abstract class WindowBase, which has most of the heavy lifting in it and declares a Shader (I only have one right now in Assets). My only view right now is just Main.cs

I can then Declare ObjectBase instances in a View. Objects have Animations composed of Sprites which are linked to Textures generated by the Texture Service via OpenGL.

There's also an input service that doesnt do much yet, though I do have it bound to Escape Key to close the window right now. But I doubt that part of the program is linked to this problem.

Update: Piece by piece, I slowly converted the original to mine and found it broke as soon as I swapped to my Shader system, so the issue lies within there. I'll post my code vs their's here:

Their Shader class

My version

I'm guessing at this point I must've typo'd somewhere. Or one of my loops just isn't compatible. Perhaps the way I'm handling my streamreader in the Assets Class?


Solution

  • Solved it: My problem was on line 114, I had the following code:

        public int Attribute(string name)
        {
            return _attributes.ContainsKey(name) ? _attributes[name].Address : -1;
        }
    
        public int Uniform(string name)
        {
            return _uniforms.ContainsKey("name") ? _uniforms[name].Address : -1;
        }
    
        public uint Buffer(string name)
        {
            return _buffers.ContainsKey(name) ? _buffers[name] : 0;
        }
    

    As follows:

    _uniforms.ContainsKey("name") should be _uniforms.ContainsKey(name)