Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The GL.Objects.Shaders documentation on the web page doesn't mention Initialize_Id #107

Closed
esthermations opened this issue Dec 29, 2017 · 6 comments

Comments

@esthermations
Copy link
Contributor

esthermations commented Dec 29, 2017

Problem page: https://flyx.github.io/OpenGLAda/gl-objects-shaders.html

This caused me a bit of a headache to track down. As far as I can tell by looking at the examples in this repo, both shaders and GL programs need to be initialised by calling Initialize_Id on them before use, but that page of the GitHub site doesn't mention this at all. It's not in the text nor the code example.

It has this (shortened):

declare
   Vertex_Shader   : GL.Objects.Shaders.Shader (Kind => GL.Objects.Shaders.Vertex_Shader);
   Fragment_Shader : GL.Objects.Shaders.Shader (Kind => GL.Objects.Shaders.Fragment_Shader);
   Program         : GL.Objects.Programs.Program;
begin
   -- load and compile shaders
   GL.Files.Load_Shader_Source_From_File (Vertex_Shader, "vertex.glsl");
   GL.Files.Load_Shader_Source_From_File (Fragment_Shader, "fragment.glsl");
   ...

This exact code causes a constraint error in Raw_Id when it's called by Load_Shader_Source_From_File. I suppose that's because the ID defaults to -1 and its type is UInt, but I don't know specifically.

The example code should be amended to at least have something like this:

declare
   ...
begin
   -- initialise
   Vertex_Shader.Initialize_Id;
   Fragment_Shader.Initialize_Id;
   Program.Initialize_Id;

   -- load and compile shaders
   GL.Files.Load_Shader_Source_From_File (Vertex_Shader, "vertex.glsl");
   GL.Files.Load_Shader_Source_From_File (Fragment_Shader, "fragment.glsl");
   ...

The actual text on that page also describes a step-by-step process for using shaders, and it completely fails to mention Initialize_Id, so I think that should be updated too.

As far as I can tell that GitHub site doesn't have a public repo, so I'm putting this issue here.

@rogermc2
Copy link
Contributor

I don't understand what "caused me a bit of a headache to track down"?
Have you looked at using
examples/common/src/program_loader?
For example:

 Render_Graphic_Program := Program_Loader.Program_From
        ((Src ("src/shaders/vertex_shader.glsl", Vertex_Shader),
         Src ("src/shaders/fragment_shader.glsl", Fragment_Shader)));

@esthermations
Copy link
Contributor Author

Those examples are fine and work correctly. The problem is that the official documentation (linked at the top of this issue) provides an example and explanation that causes the program to crash with a constraint error on a UInt nested two function calls into the library's private implementation.

In my opinion, that should be fixed.

@rogermc2
Copy link
Contributor

Agreed.
Thanks for the explanation.

@flyx
Copy link
Owner

flyx commented Dec 30, 2017

Initialize_Id is documented on the page of the parent package, GL.Objects. I agree that this call should definitely be part of the example code.

By the way, the website's public repo is the gh-pages branch of this repository. You are welcome to create a pull request (I won't be very active between the years).

@esthermations
Copy link
Contributor Author

Ah, I didn't find it. I'll make a pull request shortly.

@flyx
Copy link
Owner

flyx commented Feb 19, 2018

Fixed by PR.

@flyx flyx closed this as completed Feb 19, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants