|
Post by EmilHalim on Apr 2, 2016 10:44:42 GMT -5
Hi Tom is there a way to call basic4gl function from our PlugIn ?
for example , I want to call WindowWidth() function from my pwn PlugIn.
also can we call a function from other PlugIns?
thanks.
|
|
|
Post by Tom Mulgrew on Apr 5, 2016 5:55:46 GMT -5
is there a way to call basic4gl function from our PlugIn ? for example , I want to call WindowWidth() function from my pwn PlugIn. also can we call a function from other PlugIns? You can access certain functions via shared interfaces. It's a little bit advanced though. In your plugin's Load method, you can call registry.FetchInterface(...) to fetch an interface. Basic4GL registers a few of them, which are declared in Basic4GLStandardObjects.h and Basic4GLOpenGLObjects.h. This one: //////////////////////////////////////////////////////////////////////////////// // IB4GLOpenGLWindow // /// Interface to the OpenGL window.
class IB4GLOpenGLWindow { public: virtual int DLLFUNC Width() = 0; virtual int DLLFUNC Height() = 0; virtual int DLLFUNC BPP() = 0; // (Bits per pixel) virtual bool DLLFUNC Fullscreen() = 0; virtual void DLLFUNC SwapBuffers() = 0; virtual const char *DLLFUNC Title() = 0; }; Gives access to the window width and height (and other things). You would fetch it from within your Load method with: IB4GLOpenGLWindow* openGLWindow = (IB4GLOpenGLWindow *) registry.FetchInterface("IB4GLOpenGLWindow", 1, 0); It's good practice to check whether it's NULL: if (openGLWindow == NULL) { pluginError = "Could not get IB4GLOpenGLWindow interface to text screen. Is this the right Basic4GL version?"; return false; } Then you can access the window width as: openGLWindow->Width() You can access other functions, even BASIC functions using the IB4GLCompiler interface (declared in Basic4GLStandardObjects.h). This allows you to compile and execute BASIC code within your plugin at runtime. It's a bit tricky to access the return value (i.e. you could call WindowWidth() this way, but accessing the value it returns is a bit tricky). Calling functions from other plugins should also possible using the IB4GLCompiler interface. -Tom
|
|
|
Post by EmilHalim on Apr 5, 2016 9:55:56 GMT -5
Thanks Tom for that valuable information.
|
|