Lime 4, how to get GLUInt ID?


#1

I have a c++ lib that draws directly to the texture in bitmap… and for that i need the gl tex ID…
…in Lime < 4 i can do this:

var gluID:UInt = glTexture.id.get();

Buut… now with the GL improvements in Lime 4, “id” is no longer available.
So, how to get the texture ID?


#2

Looks like they made it private. In Haxe, privacy is more of a polite suggestion, so you can do this:

var gluID:Int = @:privateAccess glTexture.id;

That said, it would definitely be preferable if they provided an official way to access this.


#3

Right, that was the first thing i tried… but it does not seem to work…

characters 38-46 : openfl.gl.GLTexture has no field id

#4

The ID is hidden because we have garbage collection tied to your object. If you get the ID, but the Haxe object falls out of scope, the texture will be deleted

That said, I want to improve the interoperability with native APIs, not make it harder.

The abstracts could convert directly, or we could have an ID field, open to ideas. Thanks :slight_smile:


#5

Ok, thats understandable. But in certain cases this is needed if you say are mixing some c++ libs with haxe… and with knowing these limitations is its ok… so by using it the application will need to take care into how this is used, specifically regarding GC. … an open ID field would be preferable i think :slight_smile:


#6

So basically the difference:

var id:Int = glTexture;
var id = glTexture.id;

The other concern is HTML5 does not have an ID value, though we could try and fake one with a value of zero


#7

yeah, boils down to how “hidden” this should be? By using the abstract you kind of have to know about this to use it… and you should perhaps be, in the first place… so maybe thats ok… :slight_smile: