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

Add GLFW/glfw3.h and update opengl.h #28

Closed
wants to merge 23 commits into from
Closed

Add GLFW/glfw3.h and update opengl.h #28

wants to merge 23 commits into from

Conversation

TotallyGamerJet
Copy link
Contributor

No description provided.

Copy link
Contributor

@dennwc dennwc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@TotallyGamerJet Looks good overall, is it ready for the merge, or you want to add something else?

I noticed that there are a few notes regarding incorrect signatures and different types returned. I suggest using the same approach as is used for SDL: make a small adapter library to convert signatures.

@TotallyGamerJet
Copy link
Contributor Author

I wouldn't merge it just yet. I wanted to make sure the header looked good before I wrote an adapter. I had a few questions:

  • what to do about glfwSetErrorCallback. There is no equivalent in the go-gl/glfw library. Should I just make a function that does nothing in the adapter library?
  • Also, I didn't know how to properly handle the callbacks. The set callbacks functions are methods on a window which is easy enough to implement. However, the callback function itself takes a pointer to the window. How would I define a callback type since the windowT wasn't defined yet?
  • Once I finished the adapter library would it be cloned onto gotranspile account?

@dennwc
Copy link
Contributor

dennwc commented Aug 18, 2021

what to do about glfwSetErrorCallback. There is no equivalent in the go-gl/glfw library. Should I just make a function that does nothing in the adapter library?

Yes, looking at the name we can fake it for now.

Also, I didn't know how to properly handle the callbacks. The set callbacks functions are methods on a window which is easy enough to implement. However, the callback function itself takes a pointer to the window. How would I define a callback type since the windowT wasn't defined yet?

If I understand correctly you are asking how to define a pointer to a type, before defining the type, right?

If so, you can check how FILE is defined. The general idea is that you first create a pointer type with no underlying type (aka void*), then define a named type with all the callback which can potentially use the pointer type that you defined, and then set the underlying type of the pointer to the named type you just created.

Once I finished the adapter library would it be cloned onto gotranspile account?

Yes, if it's okay for you. It would be easier to move it to the same org. I should also invite you to the organization, by the way.

@TotallyGamerJet
Copy link
Contributor Author

@dennwc sorry I haven’t been working on this. I have been busy with uni. I’m not sure when I’ll have time again to work on the commit. It is just missing some callbacks and methods but overall it is correct. If you want to just merge this in you can or wait until I have time to add the rest. Also the gotranspile/glfw is 100% done as long as there are no future functions that need specific changes. I don’t know any off the top of my head.

@Zyko0
Copy link

Zyko0 commented Nov 3, 2021

Hello, I was wondering if the end-goal of this work is to transpile glfw to pure go ?
I've seen this adapter https://github.com/gotranspile/glfw, but I don't understand its use, is it a first step toward it ?
edit: Also I probably should have created an issue there ? (Sorry)

@dennwc
Copy link
Contributor

dennwc commented Nov 14, 2021

Hey @Zyko0 ! Cxgo could be used to eventually transpile GLFW to pure Go, but that's not the main goal. This specific PR make it easier to transpile C projects that use GLFW to Go. Having said that, it would be interesting to try what you proposed.

@Zyko0
Copy link

Zyko0 commented Nov 14, 2021

Thank you for clarifying ! Yes we might need to port glfw to Go for https://github.com/hajimehoshi/ebiten project anyway, so I wanted to know if this work started somewhere else 😅

@TotallyGamerJet
Copy link
Contributor Author

@Zyko0 I've actually really wanted to port glfw to pure go. The main issue is that it would require porting the windowing apis for windows and linux. There are many pure go windows api libraries but none are complete so someone would need to use the metadata to generate it (see this issue). For linux, there is an XCB port but glfw uses XLib and wayland so those would need to be ported. Then headers will also need to be written which would be a lot of work. Either way, glfw on mac would still require c because there is no way to create a window without ObjC. It's a noble effort that I hope eventually gets done!

@Zyko0
Copy link

Zyko0 commented Nov 16, 2021

@TotallyGamerJet Thanks for your explanations about the current state of such a port ! 😄

@dennwc
Copy link
Contributor

dennwc commented May 30, 2023

This is open for quite a while now, so I'll review it again and will port these changes to main branch.

@TotallyGamerJet
Copy link
Contributor Author

Oh wow it definitely has. I totally forgot about this. I could take a look today and if it's not too difficult to port to main I can do that.

TotallyGamerJet added a commit to TotallyGamerJet/cxgo that referenced this pull request Jun 2, 2023
Updated from gotranspile#28. I also removed the OpenGL parts to make it easier to merge.
@TotallyGamerJet
Copy link
Contributor Author

Closing in favor of #71

dennwc pushed a commit that referenced this pull request Jun 5, 2023
Updated from #28. I also removed the OpenGL parts to make it easier to merge.
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.

3 participants