Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Converting from VertexArray& to const Vertex*  (Read 7550 times)

0 Members and 1 Guest are viewing this topic.

tienery

  • Newbie
  • *
  • Posts: 7
    • View Profile
Converting from VertexArray& to const Vertex*
« 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 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:

Code: [Select]
@: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:

Code: [Select]
@:include("SFML/Graphics.hpp")
@:structAccess
@:native("sf::VertexArray&")
extern class VertexArray implements Drawable {
...

Any help would be greatly appreciated.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: Converting from VertexArray& to const Vertex*
« Reply #1 on: February 21, 2016, 10:14:57 am »
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.
Laurent Gomila - SFML developer

zsbzsb

  • Hero Member
  • *****
  • Posts: 1409
  • Active Maintainer of CSFML/SFML.NET
    • View Profile
    • My little corner...
    • Email
Re: Converting from VertexArray& to const Vertex*
« Reply #2 on: February 26, 2016, 05:47:55 pm »
I'm not familiar with Haxe, but in general C++ is very hard to write bindings directly for. This is why the CSFML binding exists. You might have better luck writing your binding on top of the C interface.
Motion / MotionNET - Complete video / audio playback for SFML / SFML.NET

NetEXT - An SFML.NET Extension Library based on Thor

tienery

  • Newbie
  • *
  • Posts: 7
    • View Profile
Re: Converting from VertexArray& to const Vertex*
« Reply #3 on: March 05, 2016, 01:14:12 pm »
The binding is complete now, but thanks anyway :)