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

OpenGL Bindings #16

Merged
merged 6 commits into from
Aug 18, 2024
Merged

OpenGL Bindings #16

merged 6 commits into from
Aug 18, 2024

Conversation

ellipse12
Copy link
Contributor

I was not sure if it was better to have multiple files or just one. So I added one file for each sub-module, I am willing to merge them together if necessary though.

@ellipse12
Copy link
Contributor Author

ellipse12 commented Aug 13, 2024

I also was not sure what to link to for every target, so I just did the ones I know.

@lerno
Copy link
Contributor

lerno commented Aug 14, 2024

Oh, this was an interesting solution. So the idea was that to avoid the user having to specify a version, all are available and you pick from the versions you know are available?

@ellipse12
Copy link
Contributor Author

Sort of? I believe the version number in the source is in reference to when the specific functions were added, as the earlier versions definitely do not have all of the functions of that version (e.g. fixed pipeline functions like glStart and glEnd are not included). I came from a background of using Java/LWJGL which does something similar with their bindings.

@ellipse12
Copy link
Contributor Author

I could probably add the old functions, though it would likely take a little while longer.

@lerno
Copy link
Contributor

lerno commented Aug 14, 2024

There is the alternative to use the env so for module opengl::gl13; replace that by module opengl @if(env::GL_VERSION >= 13);. Another thing would be to have module opengl13::gl and then have each version essentially include the other and you'd import module opengl15::gl and you get everything

@ellipse12
Copy link
Contributor Author

Is env defined in the project.json? or is it a separate custom module?

@lerno
Copy link
Contributor

lerno commented Aug 14, 2024

I am talking about std::core::env, which can be injected. Another option is to have import opengl in every module, and it then looks for the constant opengl::VERSION which a user of the module must define, so essentially:

module opengl;
const int VERSION = 22;
module mycode;
...

This would work.

@ellipse12
Copy link
Contributor Author

how do you inject it? (sorry I am still a bit new to C3)

@ellipse12
Copy link
Contributor Author

Also as of this moment the bindings should be fully functional with the latest version of OpenGL.

@lerno
Copy link
Contributor

lerno commented Aug 14, 2024

Literally just placing these rows anywhere in your sources:

module opengl;
const int VERSION = 22;

@ellipse12
Copy link
Contributor Author

You can access it then through env?

@lerno
Copy link
Contributor

lerno commented Aug 14, 2024

That's not even needed if all opengl modules import this.

@ellipse12
Copy link
Contributor Author

Do you mind explaining to me how it(injecting variables into env) works anyway, it may be useful in other ways.

@ellipse12
Copy link
Contributor Author

I'll start working on supporting earlier versions

@lerno
Copy link
Contributor

lerno commented Aug 14, 2024

Basically all modules are extendable, so if your program adds something to some other module it's there.

@ellipse12
Copy link
Contributor Author

Ooh ok so it's just like the opengl thing but with std::core::env

@ellipse12
Copy link
Contributor Author

I have been looking around and I can't seem to find older versions of the OpenGL headers/ xml spec. Would it be alright if you just merged this pull request and I will work on trying to find sources for older versions.

@ellipse12
Copy link
Contributor Author

Oh wait I found the previous versions. It will probably take a day or two to do all of them.

@ellipse12
Copy link
Contributor Author

Finished adding all of the previous versions! I also tested it by making a simple triangle and everything seemed to work.

@lerno
Copy link
Contributor

lerno commented Aug 18, 2024

Awesome work!

@lerno lerno merged commit d308efa into c3lang:main Aug 18, 2024
2 checks passed
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

Successfully merging this pull request may close these issues.

2 participants