Skip to content

add minimal_zgui_glfw_gl sample #1

New issue

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

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

Already on GitHub? # to your account

Merged

Conversation

hazeycode
Copy link

@hazeycode hazeycode commented Oct 3, 2023

zig build minimal_zgui_glfw_gl-run

Currently not working. I think zopengl's C exports are broken

lldb output
(lldb) target create "./zig-out/bin/minimal_zgui_glfw_gl"
Current executable set to '/Users/chris/Desktop/zig-gamedev/zig-out/bin/minimal_zgui_glfw_gl' (x86_64).
(lldb) run
Process 13338 launched: '/Users/chris/Desktop/zig-gamedev/zig-out/bin/minimal_zgui_glfw_gl' (x86_64)
2023-10-03 23:27:56.698007+0100 minimal_zgui_glfw_gl[13338:421632] SecTaskLoadEntitlements failed error=22 cs_flags=20, pid=13338
2023-10-03 23:27:56.698110+0100 minimal_zgui_glfw_gl[13338:421632] SecTaskCopyDebugDescription: minimal_zgui_glf[13338]/0#-1 LF=0
2023-10-03 23:27:57.477379+0100 minimal_zgui_glfw_gl[13338:421632] [Window] Warning: Window GLFWWindow 0x100f07ae0 ordered front from a non-active application and may order beneath the active application's windows.
2023-10-03 23:27:57.482626+0100 minimal_zgui_glfw_gl[13338:421632] [Window] Warning: Window GLFWWindow 0x100f07ae0 ordered front from a non-active application and may order beneath the active application's windows.
Process 13338 stopped
* thread zig-gamedev/zig-gamedev#1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=2, address=0x10079b298)
    frame #0: 0x000000010079b298 minimal_zgui_glfw_gl`glGetIntegerv
minimal_zgui_glfw_gl`glGetIntegerv:
->  0x10079b298 <+0>: rep    jns	0x10079b2e3           ; glViewport + 3
    0x10079b29b <+3>: subl   $0x7ffa, %eax             ; imm = 0x7FFA 

@kanewallmann
Copy link
Owner

Oh I see what's going on. zopengl is exporting function pointers and GL_GLEXT_PROTOTYPES doesn't declare the symbols as function pointers.

Also you need to call zgui.backend.newFrame() before zgui.begin() and zgui.backend.draw() before window.swapBuffers().

Rebase your PR with my latest commit, fix those two things and I think it should work.

Not sure if this is the best way to fix it but it is working.

@kanewallmann
Copy link
Owner

Your sample is working for me with those changes. At least on Linux.

@hazeycode
Copy link
Author

hazeycode commented Oct 4, 2023

Thanks. Working for me now (except mouse input is incorrectly scaled).

I tried scaling using the method mentioned in this issue: https://github.com/michal-z/zig-gamedev/issues/258 but it did not work for me. The display, font size, etc. looks ok but the mouse position is incorrectly scaled.

@kanewallmann
Copy link
Owner

The wgpu backend has a function that accepts a framebuffer width and height which the sample uses.

https://github.com/michal-z/zig-gamedev/blob/b70608b6d8e79192dfbb4ab60e3c5b05eb9b7f6d/libs/zgui/src/backend_glfw_wgpu.zig#L40

When you say you tried the scaling method used in that issue, did it include implementing the same in the gl backend?

I don't have a high DPI display to test it on myself.

@hazeycode
Copy link
Author

I probably missed something. I'll have another go at it. The backend interface should probably be changed to match that of the wgpu backend anyway.

@hazeycode
Copy link
Author

DPI scaling is working now

@kanewallmann kanewallmann merged commit bd3098d into kanewallmann:glfw-opengl3-support Oct 5, 2023
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants