LukasBanana / LLGL

Low Level Graphics Library (LLGL) is a thin abstraction layer for the modern graphics APIs OpenGL, Direct3D, Vulkan, and Metal
BSD 3-Clause "New" or "Revised" License
2.05k stars 139 forks source link

Triangle Program Reimplementation Not Working #27

Closed ForgeMistress closed 6 years ago

ForgeMistress commented 6 years ago

So I've been using the basic triangle program as my baseline for ensuring all of the systems I'm implementing for Firestorm are working properly, and I'm hitting a bit of a snag. Where it used to render the triangle properly it is now simply showing me a black screen. I've looked at the source code for the existing Triangle program and everything seems to match up, however my version is not rendering the triangle for whatever reason.

I do have a few layers of abstraction in my implementation, however outside of the asynchronous loading of the shader resources (using std::async at the moment and having it simply load up the source code for it to be compiled on the main thread as seen in the line resource->Compile({vertexFormat});), everything is fairly straightforward.

The source code for the base application class, the program's implementation of that class, and the ResourceMgr class as well as the associated ShaderLoader class that runs the asynchronous loading are all attached. The ShaderResource class is also included so that you can see how I'm loading up the shader resources.

To be honest, this issue has me stumped as I'm still a newbie when it comes to graphics programming and I would really appreciate anyone's assistance in this matter. The shader itself is simple and the differences between the existing triangle shader and the version that's implied by the code here came about as part of my debugging. It wasn't working with the existing version of the shader either. Vector2 and Vector4 are both simple structs with float x, y and float x,y,z,w as you'd expect. Nothing weird going on in there except for a few explicit constructors for Vector2 to take in either a Vector3 or Vector4 for initialization data.

class Vector2
{
public:
    Vector2(float x = 0.0f, float y = 0.0f);
    explicit Vector2(const Vector3& v);
    explicit Vector2(const Vector4& v);

    float x, y;
};

class Vector3
{
public:
    Vector3(float x = 0.0f, float y = 0.0f, float z = 0.0f);
    Vector3(const Vector2& v2d, float z = 0.0f);
    explicit Vector3(const Vector4& v2d);

    float x, y, z;
};

class Vector4
{
public:
    Vector4(float x = 0.0f, float y = 0.0f, float z = 0.0f, float w=0.0f);
    Vector4(const Vector2& v, float z = 0.0f, float w = 0.0f);
    Vector4(const Vector3& v, float w = 0.0f);

    float x, y, z, w;
};

FirestormTriangleProgramIssues.zip

ForgeMistress commented 6 years ago

Also attaching the RenderMgr class. Firestorm_RenderMgr.zip

ForgeMistress commented 6 years ago

Welp... after some tweaking to my program and how the status of resource loads are handled, suddenly my program works and I have my triangle rendering.

This issue can be closed.

LukasBanana commented 6 years ago

Have you already used the LLGL debug layer?

Here is an example:

LLGL::RenderingDebugger myDebugger;
auto myRenderer = LLGL::RenderSystem(myRendererModuleName, nullptr, &myDebugger);

This can sometimes help to find unintentional states in your render pipeline.