treeform / windy

Windowing library for Nim using OS native APIs.
MIT License
115 stars 16 forks source link

incompatible function pointer types #103

Open konsumer opened 1 year ago

konsumer commented 1 year ago

I thought I had this working, but started getting this on new projects:

Users/konsumer/.cache/nim/null0_d/@m..@s..@s..@s.nimble@spkgs2@swindy-0.0.0-e0506a1d00e0daf1ffa44f00959853bbae29b01f@swindy@splatforms@smacos@splatform.nim.c:820:10: error: incompatible function pointer types assigning to 'tyProc__ELDcQK9cgdUyzj5KMs6i3sA' (aka 'long long (*)(long long, long long)') from 'tyProc__ln4kdL5W9bbX4a1xl8nnVXQ' (aka 'void (*)(void)') [-Wincompatible-function-pointer-types]
        msgSend = Dl_3472883728_;
                ^ ~~~~~~~~~~~~~~

Here is my simple demo code:

import opengl, windy

let window = newWindow("Windy Basic", ivec2(1280, 800))

window.makeContextCurrent()
loadExtensions()

proc display() =
  glClear(GL_COLOR_BUFFER_BIT)
  # Your OpenGL display code here
  window.swapBuffers()

while not window.closeRequested:
  display()
  pollEvents()

OS: MacOSX Ventura 13.3.1 (22E261) Arch: x86_64 Nim: 1.6.12

requires "opengl >= 1.2.6"
requires "windy >= 0.0.0"
requires "boxy >= 0.4.1"
konsumer commented 1 year ago

I really like all your game-oriented nim libs @treeform, and I saw that you deprecated staticglfw on hobby, so I want to make sure windy can run on the systems I have available.

I made a minimal tester that hopefully will help troubleshoot.

The only real software difference between the stuff installed on them, that I can tell, is I am using Nim 1.6.12 (on broken intel64 build) and 1.6.10 (on working arm64 build) but there is probably some other dependency-lib differences.

Additionally, I am pretty sure it worked at one point on my Intel mac, so it's probably some update or something that made it stop working. My arm64 laptop is my "work laptop" so it might be a bit slower to get updates (IT policies, etc.) I can run tests on it, but my primary dev-machine for games and things is the intel mac.

I can also setup some emulators and test on other systems, if that is helpful.

konsumer commented 1 year ago

I did a brew update && brew upgrade on Intel mac and removed ~/.nimble and ~/.cache/nim, and still having similar problems. Is there anything else I can do to help troubleshoot?

konsumer commented 1 year ago

I am new to nim, and not great at C/ObjC troubleshooting, but as far as I can tell it seems to be a mismatch here

It's trying to do this:

void (*)(long long, long long, long long)

Where is expects:

void (*)(void)
konsumer commented 1 year ago

If it is any hint: Running the boxy glut example results in this error:

Vertex shader compilation failed:
/Users/konsumer/.nimble/pkgs/boxy-0.4.1/boxy/glsl/410/atlas.vert: ERROR: 0:1: '' :  version '410' is not supported

If I do this:

echo cast[cstring](glGetString(GL_VERSION))

I get 2.1 ATI-4.10.12. Is my hardware GL version just too old on this Intel mac?

Here I read:

Under macOS, you MUST add the FL_OPENGL3 flag to your Fl_GlWindow::mode() calls to get a context for GL version 3 or above. If you don't, you're stuck with GL 2.

Is that what is happening here? How can I add the equivalent of FL_OPENGL3 flag?

guzba commented 1 year ago

If I remember correctly you should get OpenGL 4.1 or whatever the highest Mac supported version is (less than on Windows, no compute shaders etc).

I am not working on Windy right now so I will not be able to look into issues for the time being.

konsumer commented 1 year ago

I am not working on Windy right now so I will not be able to look into issues for the time being.

I hear that. I will add one other troubleshooting note, for later.

If I use staticglfw, it works, but scales it weird:

Screenshot 2023-05-21 at 1 40 23 PM

There, I can do this to set the GL version:

windowHint(RESIZABLE, false.cint)
windowHint(CONTEXT_VERSION_MAJOR, 4)
windowHint(CONTEXT_VERSION_MINOR, 1)

I think it is a few unrelated problems:

The windy problem itself is the one I am asking about, so the other stuff is just things I found while trying to figure it out.