Pointer on island

(Friedrich Westermann) #1

Is there a way to use a plain pointer as method result on windows?
I’m try to use Opengl on windows. I have there a funtion to return function pointers for exports in opengl

(SH) #2
method GetPlainPtr: ^Void;

or what do you mean?

(Friedrich Westermann) #3

I think something like these:

namespace Test;

uses rtl;

method callMyProc(const i : Integer);


Tmyproc = procedure(const i : Integer);

method callMyProc(const i : Integer);
var h : HMODULE;
lp : Tmyproc;
h := HMODULE(0); // Only for Test the Code here
// lp := GetProcAddress(h, ‘myproc’); // Will not work
lp := Tmyproc(GetProcAddress(h, ‘myproc’)); // will work



without the need to Cast every call to getProcAdress to a Type

(marc hoffman) #4

Not aur enow that would work. GetProcAddress is defined to return a FARPROC, which in turn is defined as

rtl.FARPROC = public block(): Int32;

i.e. a parameterless method that returns an integer; since GetProcAddress can return the dress of any kind of method, but Oxygene is a strongly typed language, you’ll need some kind of cast to let the compiler know what the actual method looks like.

Even though GetProcAddress is “special” in that way, the compiler also can’t just treat any kind of method pointer as compatible, as that wold reach all kind of havoc when they don’t match.

A cast is the (proper) way to tell the compiler “i know you think this is a specific type, but i know better, so let me override that”.

(Friedrich Westermann) #5

ok, i understand these. Is there a way to import opengl.h ?
if not i will write a tool to convert my source to oxygene syntax.

(marc hoffman) #6

Yes, via HeaderImporter. Carlo knows the AI to that better, for Island, so i’ll have to defer to him chiming in on this on Monday (we really need to get some docs written ;).

Might also be that we can include OpenGL.h by default in a future update.

(Friedrich Westermann) #7

Thanks, so i go now in weekend. You should also😀

(marc hoffman) #8

:wink: done

(SH) #9

where did u shoot this pic? :open_mouth: really beatiful!

(marc hoffman) #10

thanx! a little east of Parasasa beach, around here:

(marc hoffman) #11

hmm. apparently google maps links don’t preserve the exact location, that link but goes by the street name it seems. scroll about 2km to the east, thereaboutish:

(SH) #12

Saw it, really cool :astonished: Are you also living their near the beach or more far away?

(marc hoffman) #13

ca 3 minutes walk for me to have me feet in the sand :wink: different one that the one from the link though, i live in Blue Bay, about 5km or so west from there.

(SH) #14

ah cool :slight_smile:

Yeah, sometimes I wish to live near the beach as well :slight_smile:

(marc hoffman) #15

guess how many times i have actually been in the ocean this year? i think it was three times :wink:

but yeah, don’t get me wrong, this is an amazing place to live, we’re very lucky.