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

GLFW Boolean return type #181

Closed
ShadowLordAlpha opened this issue Apr 17, 2016 · 5 comments
Closed

GLFW Boolean return type #181

ShadowLordAlpha opened this issue Apr 17, 2016 · 5 comments

Comments

@ShadowLordAlpha
Copy link

Both OpenAL and OpenGL have Boolean return methods that are used in place of their *_TRUE and *_FALSE return values. GLFW also does this but does not make a special type for the Boolean value and instead treats it as an int (OpenGL and OpenAL treat it as a byte if I remember correctly but only give it the true or false value) so it should be possible to make it so that certain GLFW functions that are documented Boolean returns actually return a Boolean java type. Its not really required as its easy enough to just do glfwInit() != GLFW_TRUE but it would be nice to have.

@Spasi
Copy link
Member

Spasi commented Apr 17, 2016

Technically it's possible (and easy). LWJGL normally does this only when the native API has a dedicated boolean type.

Is anyone against such a change? It will affect the following functions:

  • glfwInit
  • glfwWindowShouldClose
  • glfwSetWindowShouldClose
  • glfwJoystickPresent
  • glfwExtensionSupported
  • glfwVulkanSupported
  • glfwGetPhysicalDevicePresentationSupport

@quazi-irfan
Copy link

quazi-irfan commented Apr 18, 2016

In GLFW we do,
if (!glfwInit())
But in LWJGL 3 we write the same things as,
if ( glfwInit() != GLFW_TRUE )

@Spasi Why GLFW_TRUE was chosen instead of native Java boolean?

@Spasi
Copy link
Member

Spasi commented Apr 18, 2016

@iamcreasy I mentioned this, int is used because that's what the native API uses. C code can do:

if ( !glfwInit() )

because C supports numeric values in conditions (they are automatically compared against 0).

@arisona
Copy link

arisona commented Apr 18, 2016

That would be great! In addition, there are a few callbacks that have boolean type arguments, such as the iconify callback or the cursor enter callback. Could this be done there as well for consistency?

@Spasi
Copy link
Member

Spasi commented Apr 20, 2016

@arisona Thanks for the reminder, those callbacks have changed too.

Spasi added a commit that referenced this issue Jun 30, 2016
This commit fixes functions that were missed in #181.
Spasi added a commit that referenced this issue Jan 18, 2017
This commit fixes functions that were missed in #181 and d6b0694.
Spasi added a commit that referenced this issue Jan 18, 2017
This commit fixes functions that were missed in #181 and d6b0694.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants