GithubHelp home page GithubHelp logo

google / dart-glfw Goto Github PK

View Code? Open in Web Editor NEW
36.0 16.0 19.0 172 KB

Dart bindings for GLFW, a multiplatform library for creating windows with OpenGL contexts.

License: BSD 3-Clause "New" or "Revised" License

Dart 38.68% C++ 53.77% C 1.80% Objective-C 4.94% Makefile 0.82%

dart-glfw's Introduction

Dart bindings to GLFW 3.2.1.

Supports Linux and Windows. OSX is not supported due to inherent incompatibilites in the OSX UI threading model, as well as Apple announcing the discontinuing of support of OpenGL on OSX (https://goo.gl/qQdeQ5).

Steps to generate the bindings

mkdir -p lib/src/generated/
pub run tools/glfw_generator.dart --glfw3_path=<path to glfw3.h>
clang-format -i --style=Google generated/*.{cc,h}
dartfmt -w generated/*.dart
mv generated/* lib/src/generated

Steps to compile the bindings

The previous method for compiling the bindings is no longer available. We are working on a new solution for both Linux and Windows.

In the meantime, the Makefile in the lib/ directory is a good starting point for compiling on Linux.

Notes about the auto-generated bindings

  • glfwWindowShouldClose returns an int, rather than a bool, but unlike in C, the expression !(1) returns true so you must explicitly test glfwWindowShouldClose(window) != 1
    • There is also a convenience function
      bool glfwWindowShouldCloseAsBool(GLFWwindow window)

The following functions have changed from the C GLFW API

These changes are due to the C library's use of pointer arguments to return values. See also lib/src/manual_bindings.dart.

  • glfwGetVersion
    • Returns a GLFWVersion instance which has major, minor, rev fields.
  • glfwGetMonitors
    • Returns a List<GLFWmonitor> instance.
  • glfwGetMonitorPos
    • Returns a Point instance.
  • glfwGetMonitorPhysicalSize
    • Returns a Rectangle instance with xpos and ypos set to 0.
  • glfwGetVideoModes
    • Returns a List<GLFWvidmode> instance.
  • glfwGetWindowPos
    • Returns a Point instance.
  • glfwGetWindowSize
    • Returns a Rectangle instance with xpos and ypos set to 0.
  • glfwGetFramebufferSize
    • Returns a Rectangle instance with xpos and ypos set to 0.
  • glfwGetWindowFrameSize
    • Returns a Rectangle instance.
  • glfwSetWindowUserPointer
    • pointer parameter is a Dart Object.
  • glfwGetWindowUserPointer
    • Returns an Object instance.
  • glfwGetCursorPos
    • Returns a Point instance.
  • glfwGetJoystickAxes
    • Returns a List<double> instance.
  • glfwGetJoystickButtons
    • Returns a List<int> instance.

The following functions are additions to the C GLFW API

  • glfwSwapBuffersAsync
    • An async version of glfwSwapBuffers that can be await-ed. This avoids blocking the current isolate while the glfwSwapBuffers call is waiting to finish.

dart-glfw's People

Contributors

cbracken avatar davidmorgan avatar domesticmouse avatar jtmcdole avatar lyceel avatar michaelrfairhurst avatar mmclenna avatar munificent avatar tvolkert avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

dart-glfw's Issues

vulkan osx

any plans to update to the last glfw supporting vulkan ?

Will this be maintained in the future?

I was wondering if it is possible for dart to be supported by vulkan (and MeltenVK)..
Quite few I know about these stuffs, so it's kind of you to forgive my stupid :)

thanks for your work!

255 does not fit into an unsigned char

import 'package:image/image.dart' show Image, decodeImage;

iconProvider: () => decodeImage(File('example/icon.png').readAsBytesSync()),
// ----------
if (iconProvider != null) {
  final image = iconProvider();
  glfwSetWindowIcon(window, 0, GLFWimage(image.width, image.height, image.getBytes()));
}

error in generated code

Dart_Handle Dart_IntegerToUChar(Dart_Handle integer, unsigned char* value) {
  int64_t actual;
  HandleError(Dart_IntegerToInt64(integer, &actual));

  // here
  if (actual < UCHAR_MAX) { // <- actual <= UCHAR_MAX
    *value = static_cast<unsigned char>(actual);
    return Dart_True();
  } else {
    char buf[50];  // Technically we only need 46 characters for this.
    snprintf(buf, sizeof(buf),
             "%" PRId64 " does not fit into an unsigned char.", actual);
    return Dart_NewApiError(buf);
  }
}

idk it is right, but this solve my problem

Exception while running example on macOS

dart example_es2_window.dart gave this error:

2017-08-27 09:53:59.449 dart[867:11447] WARNING: nextEventMatchingMask should only be called from the Main Thread! This will throw an exception in the future.
2017-08-27 09:53:59.449 dart[867:11447] *** Assertion failure in +[NSUndoManager _endTopLevelGroupings], /Library/Caches/com.apple.xbs/Sources/Foundation/Foundation-1349/Misc.subproj/NSUndoManager.m:363
2017-08-27 09:53:59.538 dart[867:11447] *** Assertion failure in +[NSUndoManager _endTopLevelGroupings], /Library/Caches/com.apple.xbs/Sources/Foundation/Foundation-1349/Misc.subproj/NSUndoManager.m:363
2017-08-27 09:53:59.540 dart[867:11447] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '+[NSUndoManager(NSInternal) _endTopLevelGroupings] is only safe to invoke on the main thread.'
*** First throw call stack:
(
	0   CoreFoundation                      0x00007fffc498d7bb __exceptionPreprocess + 171
	1   libobjc.A.dylib                     0x00007fffd90f0a2a objc_exception_throw + 48
	2   CoreFoundation                      0x00007fffc4992312 +[NSException raise:format:arguments:] + 98
	3   Foundation                          0x00007fffc63e5390 -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 195
	4   Foundation                          0x00007fffc636fa93 +[NSUndoManager(NSPrivate) _endTopLevelGroupings] + 170
	5   AppKit                              0x00007fffc25900cf -[NSApplication run] + 1200
	6   libglfw.3.dylib                     0x000000010751af7c initializeAppKit + 1420
	7   libglfw.3.dylib                     0x000libc++abi.dylib: terminating with uncaught exception of type NSException
fish: 'dart example_es2_window.dart' terminated by signal SIGABRT (Abort)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.