SFML community forums
Bindings - other languages => General => Topic started by: tienery on February 21, 2016, 04:51:18 am
-
I'm trying to figure out how one would convert VertexArray to const Vertex* so that the binding in my latest commit (https://github.com/tienery/hxsfml/commit/ab4b5c98974a41e1d7b5c5e46cf0fc3fd52150ac) is correct.
Because the draw function in sf::Window has the const Vertex* signature as the first param, I need to match that param so that the compiler can match the signature when resolving. Unfortunately, I can't just pass in a standard VertexArray type because the Haxe compiler complains that the types mismatch. Obviously this is nothing to do with C++.
I have an extern that identifies the type needed to match the signature:
@:include("SFML/Graphics.hpp")
@:native("const sf::Vertex *")
extern class ConstVertexArray { }
But I need a way to convert the standard extern over to this one. The standard extern looks like this:
@:include("SFML/Graphics.hpp")
@:structAccess
@:native("sf::VertexArray&")
extern class VertexArray implements Drawable {
...
Any help would be greatly appreciated.
-
Why do you need to use this overload of the draw function? sf::VertexArray is a drawable, just like sf::Sprite, sf::Text and the various sf::Shape. If you can't call the draw(sf::Drawable&) overload, then getting a Vertex* from a VertexArray is the least of your problems.
-
I'm not familiar with Haxe, but in general C++ is very hard to write bindings directly for. This is why the CSFML binding (https://github.com/SFML/CSFML) exists. You might have better luck writing your binding on top of the C interface.
-
The binding is complete now, but thanks anyway :)