Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / How to make a plugin with PureBasic

Author
Message
PartTimeCoder
AGK Tool Maker
9
Years of Service
User Offline
Joined: 9th Mar 2015
Location: London UK
Posted: 24th Jul 2021 18:21
I had a request for some pointers on making plugins for AppGameKit with PureBasic so I thought I would post a detailed 'How To' guide

PureBasic is a powerful language that has a long history and a bright future, v6 will see native inline C support and a new C backend and compiler, this will open many doors when combined with AppGameKit, it really is a very easy to use and powerful union.

The Basics:

The first thing we need to do is setup some folders:

navigate to your AppGameKit install dir and find the Plugins folder...

Classic: C:\Program Files (x86)\The Game Creators\AGK2\Tier 1\Compiler\Plugins
Studio: C:\Program Files (x86)\The Game Creators\AppGameKit Studio\Plugins

Create a folder, name it myPlugin (yes this is basic, humour me for now, aye), Inside this folder create a text file, name it 'Commands.txt' and paste the following text



we will worry about what this content means in a bit, lets get something working first.

Create the PB project

Now, Open PureBasic (x86 - 32 Bit, we will deal with 64 bit later) and create a project, again call it myPlugin and save it where ever you save your PB stuff,

Use the project creation dialog to add a file, call it main.pb and click the 'Create Project' button, this will open the project overview tab.

Now we need to set the compile targets, in the 'Project Targets' list, right click 'Default Target' and click 'Edit Target', this opens the project compiler options.

Set executable format, Shared DLL

Set the input file to the main.pb file that was created with the project and set the output executable to :

Classic: C:\Program Files (x86)\The Game Creators\AGK2\Tier 1\Compiler\Plugins\myPlugin\Windows.dll

Studio: C:\Program Files (x86)\The Game Creators\AppGameKit Studio\Plugins\myPlugin\Windows.dll

you can add both if you want to compile for both systems but set your preferred as default (I set classic) (checkbox at bottom of compile targets list) and set the other 'Studio' Enable in build all targets, now we can compile our plugin for both Classic and Studio at a single button click, handy stuff

Click OK in the dialog, you are now greeted with an empty code page, first lets test our compile targets to make sure we got it right, go to the main menu, click Compiler>>Build All Targets, a dialog will appear and tell you what's going on, when its done you should now have a new DLL in the plugin folder (you will need to launch PureBasic with admin rights to compile to the Program Files folder)

if everything is good, we can add some code, if something went wrong, check each step and try again.

Add some code

Now we will add the a basic function:

When AppGameKit loads the plugin it looks for a function 'ReceiveAGKPtr', this function is called by the runtime and sends the full set of function pointers to the plugin, we will setup this function but not use it yet, this function must exist for the plugin to work so we set this us with a C prototype



we will come back to this later.

Now lets add a basic function, we use the function name we put in the Commands.txt



And once again, Menu>>Compile>>Build all Targets.


Now open AppGameKit, any flavor if you added both compile targets, or just the one you added and create a new project, call it Example - Plugin

Add:

#Import_Plugin myPlugin
or
#Import_Plugin myPlugin as mp

In the first case we call our functions with the syntax myPlugin.MyFunction, in the second case we use an alias 'mp' so the call becomes mp.MyFunction



or



Now hit run, you should see a dialog box with a message "Hello from a PB plugin"

Congrats you have made your first Plugin.

Arguments

Ok so now lets send in some arguments, go back to the Commands.txt file


Change : MyFunction,0,0,MyFunction,0,0,0,0,0

To MyFunction,0,S,MyFunction,0,0,0,0,0

This tells AppGameKit we want to send 1 string argument to the pkugin (S=String, I= Integer, F = Float)

Sidenote:
If we had 2 string and an integer we would stack them like so: MyFunction,0,SSI,MyFunction,0,0,0,0,0

Now go back to the PureBasic file and change the function to:



and recompile, now to the AppGameKit project and change

mp.MyFunction()

to

mp.MyFunction("Hello from AGK")

and click run ... you should see a dialog box with jibberish, see PureBasic is Unicode, AppGameKit is not so we need to let PB know its Ascii text coming in, we do this with a helper function and a memory peek



and wrap the text in our function



compile, go back to AppGameKit and run,, you should now see the message "Hello from AGK"

As we have a message requester with 2 string arguments, let add them both


Commands.txt
MyFunction,0,SS,MyFunction,0,0,0,0,0

PureBasic:
ProcedureCDLL MyFunction(title.s, message.s)

MessageRequester(S(title), S(message), #PB_MessageRequester_Info)

EndProcedure

AGK:
mp.MyFunction("AppGameKit", "Hello from AGK")

Now see if you can add the integer icon argument by yourself


Return Values

Now lets return a value from the plugin, we tell AppGameKit this function returns a value in the Commands.txt

MyFunction,I,SS,MyFunction,0,0,0,0,0

for this case we return an integer value

Now in PureBasic, lets change the message requester to a Yes/No dialog and return its value



and in AppGameKit we check the value, but lets add a button so we can check each case



And there you have it, sending and receiving data to/from a plugin


Returning Strings:

Floats and Integers can be returned directly but we have to handle strings a little different.

For this we head back into PureBasic and the ReceiveAGKPtr function, we need to import some string functions, for this we use the _GetAGKFunction prototype we setup earlier

SideNote, there is a full function wrapper attached to this post, I am showing it this way so you understand what's going on in the code.



Change Commands.txt from Intger return to String

MyFunction,S,SS,MyFunction,0,0,0,0,0



In PB, we need to create a string pointer to send to AppGameKit, for this we use a handy helper function to poke the memory




And change our function to:




And change the AppGameKit code to:



run the project, now the string is returned from the plugin,

There is one important factor to consider when using agkCreateString, string pointers must be deleted with agkDeleteString but we have the situation where we return the pointer and no longer have access to it, in this case I THINK! AppGameKit handles the deletion of the pointer, I ran some tests with a global pointer and while the pointer refers to valid memory the contents seem to be deleted, there is no documentation to support or disprove this so some input here would help @TGC


Errors:

If you want to prompt an error message from within your plugin we use another helper function



and we muse add the agkPluginError to oue ReceiveAGKPtr function




And add an error to our function



and change the call in agk to prompt the error



This simply shows the AppGameKit message box, you could of course just use your own feed back system but this function is here for convince.

And that is the basic setup of PureBasic for plugin production, the full wrap of ReceiveAGKPtr exposing all AppGameKit functions is attached below, the overloaded calls have been commented out and not all functions are tested but should work, you could literally write your entire game in PureBasic and include it and run with a single function call in AGK.

Next, Advanced usage



Attachments

Login to view attachments
PartTimeCoder
AGK Tool Maker
9
Years of Service
User Offline
Joined: 9th Mar 2015
Location: London UK
Posted: 24th Jul 2021 18:21 Edited at: 24th Jul 2021 21:36
Window Handle

Once we get the AppGameKit window handle we can do all sorts of intrestng stuff, lets start by adding a function to our PureBasic code.



Compile the plugin

Add to Commands.txt

RegisterWindow,I,S,RegisterWindow,0,0,0,0,0

and change AppGameKit code



So now we can send the title to the plugin and store its handle and get an error report if the title can not be found, this is a staple of most of my plugins, heres why.

Callbacks

Callback functions are an intregrial part of the windows messaging system, so lets add one to the AppGameKit window, under the hood AppGameKit already has a callback in Core.cpp, we will get a pointer to this so we can call it from our callback when we are done, we must do this or bad things will happen.


This is the very least your callback should contain



Add a function to set the callback



and change the RegisterWindow function to set the callback



Compile the plugin and run the AppGameKit project to ensure everythibg is working, nothing should change to be honest it should just act normally as we have not change any behaviour we only added a callback function, now we can have some fun ...

Lets intercept the window close button

Add a case to the select statment in the AGKCallback:



Compile the plugin and run the project, dang the window wont close, no panic hit the run button again the it will kill the runtime, remove or comment the return and now it closes.

If your project requires users to save data and they exit without saving there is no way to warn them, if we intercept the close message like this we can check if the user data needs saving and inform the user with the obligtory "Do you want to save" message, a simple but effective use of a callback.

EG:



Limit the window size



If you want your window to be resibile but within a range.

There are a whole host of things we can do with the window from here, depennds on your needs.


Embedding AppGameKit Window

Now have full access to the plugin system and a window callback in place we are ready to take full control of the AppGameKit window by embedding it into a PureBasic UI but before we do lets tidy up our project a bit

In PureBasic, add the wrapper file to the project folder and add it to the project (Project Tab>>Project Options>>Project Files>>Open and start the main.pb with the below code



And Commands.txt

#CommandName,ReturnType,ParameterTypes,Windows,Linux,Mac,Android,iOS,Windows64
RegisterWindow,I,S,RegisterWindow,0,0,0,0,0

And AppGameKit code



So now we have a clean set of project to work with and the full AppGameKit API to play with, lets build a basic form, add a container and a button



and a helper function to embed the agk window into our PB window




And call teese functions from RegisterWindow



We need to make sure our application can close so add these



and finally add a function for the Add Sprite button



Now compile the plugin

in Commands.txt add:
UIClose,I,0,UIClose,0,0,0,0,0

and in agk, change the loop code to



And finally run the project, AppGameKit is now effectivally a PureBasic gadget but unlike PB gadgets we can not bind events to AppGameKit so we need a update function

Add to PB


Add to Commands.txt
Update,0,0,Update,0,0,0,0,0

Set to AGK


Now we have an update function called at the frame rate set by agk

Now there was some issue I encouterd with mouse and keyboard events not making it to the AppGameKit window because of the parental rearranging so that is why I left the callback because this will be needed to pipe them correctly, I will append that info to this thread when I have written it I cant remember what functions were affected so I will have to test

But that for the basic part is pretty much it, you build your PureBasic UI as normal but use BindEvent, BindGadget/MenuEvent, if you absoluly need an event loop for gadgets then attach a callback to the UI window and use that but DO NOT add a repeat loop inside the plugin.

Have fun.
matty47
16
Years of Service
User Offline
Joined: 20th Nov 2007
Location:
Posted: 24th Jul 2021 22:00
Absolutely wonderful! Thank you for your instruction.
MikeHart
AGK Bronze Backer
20
Years of Service
User Offline
Joined: 9th Jun 2003
Location:
Posted: 25th Jul 2021 12:12
Does the PureBasics license allows wrapping its API inside DLLs? I remember a case back then that this wasn't allowed someone was creating a 3d engine with purebasic, basically wrapping its api
Loktofeit
AGK Developer
15
Years of Service
User Offline
Joined: 21st Jan 2009
Location: Sarasota, FL
Posted: 25th Jul 2021 12:27
This was both informative and fascinating. Thank you so much for posting this!
LynxJSA's web games/quizzes - LynxJSA's Android apps
AGK Resource Directory
"Stick to a single main loop (DO...LOOP) and loop through it every frame.
Do everything inside functions.
Use finite state machines to control your game.
Use lots and lots of source files.
PartTimeCoder
AGK Tool Maker
9
Years of Service
User Offline
Joined: 9th Mar 2015
Location: London UK
Posted: 25th Jul 2021 15:22
Quote: "Thank you for your instruction."


No Problem Mat, did you get it up and running?

Quote: "Does the PureBasics license allows wrapping its API inside DLLs?"


You are right, you can not just wrap up PB's commands and export them, but there is the caveat that PB wraps the WinAPI so you can export as much of that as you like as PB can not take ownership of it, so as long as you include as much API as possible, like I usually do then its well within the EULA.

at the end of the day you can not make a DLL without exporting some of PB' functionally, what Fred asks is simply don't wrap the API and call it your own, which is fair enough.

Quote: "This was both informative and fascinating. "


Yea I am not exactly cut out for this tutorial stuff but had to recreate most of the code so I just documented the steps I took, I know its a bit messy but that's my work flow lol

I would be happy to let someone a bit more literate than myself reformat the entire thing
PartTimeCoder
AGK Tool Maker
9
Years of Service
User Offline
Joined: 9th Mar 2015
Location: London UK
Posted: 25th Jul 2021 17:36
I am not sure how stable this is, it would need more testing, but ....

add this function to PB


and start the thread in the OpenUI function




and in AppGameKit set:


Threaded support, the thread is creating 100,000 sprites in a loop while AppGameKit is spinning the red sprite.

OpenGL is single threaded, how does this even work?
PartTimeCoder
AGK Tool Maker
9
Years of Service
User Offline
Joined: 9th Mar 2015
Location: London UK
Posted: 25th Jul 2021 22:38
Right, as mentioned the keyboard events do not make it to agk because of the parental rearrangement so we have to pipe the events.

in the OpenUI function, under the OpenWindow, put: SetWindowCallback




and add this callback function



compile and run, the keyboard events are now piped correctly to the agk window so the default callback can take care of them
n00bstar
20
Years of Service
User Offline
Joined: 9th Feb 2004
Location: Montreal, Canada.
Posted: 25th Jul 2021 23:01
This is definitely information that belongs in a wiki or at the very least, in a sticky post. This is a great way to circumvent some of AGK's limitation especially when it comes to interacting with the OS directly...well at least Windows.
-----------------------------------------------------------------------------
We all got a chicken duck woman thing waiting for us
PartTimeCoder
AGK Tool Maker
9
Years of Service
User Offline
Joined: 9th Mar 2015
Location: London UK
Posted: 26th Jul 2021 00:25
Well, PureBasic is cross platform so this system can be applied to Linux and MacOS but the windowing code would need to be change (any function with an underscore at the end) and I don't use either so that would take someone else to implement but the wrapper and base code is ready to compile on any desktop platform.

It is a great way to circumvent some of AGK's limitation without the complexity of C++ and 7GB overhead of VS!!
PartTimeCoder
AGK Tool Maker
9
Years of Service
User Offline
Joined: 9th Mar 2015
Location: London UK
Posted: 26th Jul 2021 14:29 Edited at: 26th Jul 2021 17:07
This is the source for my CL plugin, I am posting this so you can see the usefulness of the plugin system and window callbacks.

PB Source


Commands.txt



Example


EDIT: I just change the code above because it was not working on 64bit, it seems 64bit is a lot more fussy about argument typing, I changed some int;s to longs and removed typed info from pointer arguments and it works as expected on both 32 and 64 bit ... something learned today!

Attachments

Login to view attachments
SkinK4ir3
8
Years of Service
User Offline
Joined: 25th Aug 2015
Location:
Posted: 28th Jul 2021 03:35
is there any way to embed AGK.Lib directly into Purebasic? Imagine the power that would give AppGameKit xD
MikeHart
AGK Bronze Backer
20
Years of Service
User Offline
Joined: 9th Jun 2003
Location:
Posted: 28th Jul 2021 06:19
If the transpiler Version of PB works like my language Cerberus X, which I assume, then it should be possible.
PartTimeCoder
AGK Tool Maker
9
Years of Service
User Offline
Joined: 9th Mar 2015
Location: London UK
Posted: 28th Jul 2021 16:02 Edited at: 28th Jul 2021 16:03
I have looed at it, and failed!!

The AppGameKit lib would need to be recompiled as DLL with exported functions, and I probably could muster the skill level needed unfortunately Visual Studio runs like a snail on my system it takes an hour to compile the lib to test the slightest code change so mustering the patience to see the task through it not going to happen, I have made a few local changes to my AppGameKit and to be honest the time it takes I could just write a PB plugin and have lunch!!

I looked at AGKSharp (AGKWrapper.dll) with DLL Export Viewer and most of the functions look wrappable but there are a few commands (format) I don't quite understand, I think they might be internal, but the dll is outdated anyway.



I would love to have AppGameKit ported to a PureBasic lib or dll but the framework will need completely rewritten, or wrapped?
Open Source plugins
Cl - DnD Plugin

Attachments

Login to view attachments
SkinK4ir3
8
Years of Service
User Offline
Joined: 25th Aug 2015
Location:
Posted: 28th Jul 2021 23:34 Edited at: 28th Jul 2021 23:38
A while ago, I went to fellow community member Adam Biser, asking if he could convert the plugin he made AGKPython, to .DLL that I could use with PUREBASIC

thanks to his genius, he managed to make a simple example " use the Message() command, to display a MessageBox, and apparently it worked, I'll share it here :

Adam's mail :
Quote: "
Here's what I have for it.
appgamekit.pb is the module
agktest.pb is my test file
symbols.txt (in the zip) contains the symbols from AGKWindows.lib. AGK
Functions are located around line 89000.

As I mentioned before, you'd have to convert an AppGameKit C++ template project
code to PureBasic for it to work.

Also, you need to change #AGK_Base_Path in appgamekit.pb to have the
correct path to your AGKWindows.lib file.

Adam Biser
"


Note : Download files :
https://www.soqueto.com/cdn/agk/agkpb.zip
PartTimeCoder
AGK Tool Maker
9
Years of Service
User Offline
Joined: 9th Mar 2015
Location: London UK
Posted: 29th Jul 2021 01:58
Impressive!

It compiles and runs out the box after setting #AGK_Base_Path, recreating the C++ template is not much of task just dupe Core.cpp and edit for PB, its all the same function calls if I go the API route or I might even be able to render AppGameKit in a PB OpenGL gadget which would be very handy for multiple instances running in threads (think Godot type editor, multiple 3D and 2D tabs)

I'll have to study the symbols.txt and see if I can scan it and pull the function set with a tool, I ripped the plugin function set with this method, scan the header and build the include file automatically, and sort any errors after, its far quicker than coding each function one by one.

One step closer to having my perfect engine, AppGameKit function set in PureBasic, my personal utopia! lol

Thank you SkinK4ir3 and Adam Biser.
Open Source plugins
Cl - DnD Plugin
PartTimeCoder
AGK Tool Maker
9
Years of Service
User Offline
Joined: 9th Mar 2015
Location: London UK
Posted: 29th Jul 2021 16:28
OK, I don't think this is the solution, I started coding a framework with this and immediately hit a brick wall, some functions do not seem to be exposed by the static lib, (InitGraphics) for one or at least there is no symbol for it in the symbols.txt and also reading over at the PB forums it seems that static libs for PB must be compiled with the same version and with the same toolchain ... have you seen the Wiki on this ... not something I consider fun!! lol

So its going to need to be wrapped, see you in a couple of weeks, I'm off to my man cave with a large supply of caffeine!!

Open Source plugins
Cl - DnD Plugin
adambiser
AGK Developer
8
Years of Service
User Offline
Joined: 16th Sep 2015
Location: US
Posted: 30th Jul 2021 02:54
@PartTimeCoder: First, let me say that I'm not very familiar with PureBasic. What I did was just a test case to show it was possible.
What InitGraphics are you meaning? I'm not seeing it defined in the interpreter project.
PartTimeCoder
AGK Tool Maker
9
Years of Service
User Offline
Joined: 9th Mar 2015
Location: London UK
Posted: 30th Jul 2021 03:54
agk::InitGraphics is called In Core.cpp inside tWinMain function at the bottom of the file along with a few other setup functions that also can not find in the symbols.txt file.

The Message function is a direct wrap of MessageBoxA so at a guess I assume this is why it can be called through your framework, I also imported a handful of other functions and although there was no linker error I am unable to test them as I can not Init the window

I was talking to someone at the PB forums and he gave me a few tips for compiling for PB but I don't know if the AppGameKit lib will like the settings as it needs to be compiled as C, this will also prevent the name mangling on the function names and (hopefully) solve the issue of importing functions but I got that xAudio2 issue going on here I need to solve first, downloaded a new repo to sync it with Git and its now refusing to compile!

Open Source plugins
Cl - DnD Plugin
adambiser
AGK Developer
8
Years of Service
User Offline
Joined: 16th Sep 2015
Location: US
Posted: 30th Jul 2021 04:14 Edited at: 30th Jul 2021 04:30
Still not seeing InitGraphics. I see

Is that what you mean?

EDIT: If so then maybe this?
InitGL(hwnd.i) As "?InitGL@agk@AGK@@SAXPAX@Z"

Guessing on the parameter type.

EDIT 2:
OH! Now I see. They changed it to InitGraphics for Studio. In Classic it's InitGL. The symbols are for Classic, not Studio.
Symbols for studio attached.

Command to get symbols:
"C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30037\bin\Hostx86\x86\dumpbin" /symbols AGKWindows.lib > symbols.txt
This depends on VS2019 community edition being installed. "14.29.30037" may differ.

Attachments

Login to view attachments
PartTimeCoder
AGK Tool Maker
9
Years of Service
User Offline
Joined: 9th Mar 2015
Location: London UK
Posted: 30th Jul 2021 04:26 Edited at: 30th Jul 2021 04:32
Interpreter: Core.cpp line 971



Template vs2015: Core.cpp line 913


What local version do you have?

I just checked both Classic and Studio tier 2 files and they both the same

Edit: No, I stand corrected, it is InitGL in Classic you are right.

Edit2: I will have another crack at this tomorrow, with the right libs this time, a silly oversight there on my part!
Open Source plugins
Cl - DnD Plugin
adambiser
AGK Developer
8
Years of Service
User Offline
Joined: 16th Sep 2015
Location: US
Posted: 30th Jul 2021 04:30 Edited at: 30th Jul 2021 04:32
See above, I've attached the studio symbols from "AppGameKit Studio\Tier 2\platform\windows\Lib\VS2015\Release"
PartTimeCoder
AGK Tool Maker
9
Years of Service
User Offline
Joined: 9th Mar 2015
Location: London UK
Posted: 30th Jul 2021 04:33
Super cool, thanks for your help, I'll post my results

Thanks Adam
Open Source plugins
Cl - DnD Plugin
SkinK4ir3
8
Years of Service
User Offline
Joined: 25th Aug 2015
Location:
Posted: 31st Jul 2021 22:14
Awesome !!!
if you need any help or have any questions, you can contact cmgo whenever you can. .
Zaxxan
AGK Developer
3
Years of Service
User Offline
Joined: 17th Nov 2020
Location: England
Posted: 1st Aug 2021 10:40
Great tutorial. Thanks for posting
SkinK4ir3
8
Years of Service
User Offline
Joined: 25th Aug 2015
Location:
Posted: 8th Aug 2021 00:26 Edited at: 8th Aug 2021 00:27
with the wrapper you made is it possible to send and receive any information from the AppGameKit application through the plugin?
PartTimeCoder
AGK Tool Maker
9
Years of Service
User Offline
Joined: 9th Mar 2015
Location: London UK
Posted: 8th Aug 2021 16:31
Could you be more specific... sending information between ... is exactly what plugins do.

I don't understand the question?
Open Source plugins
Cl - DnD Plugin
SkinK4ir3
8
Years of Service
User Offline
Joined: 25th Aug 2015
Location:
Posted: 9th Aug 2021 03:17
sorry for not being specific, taking the opportunity, I have 2 questions to ask

Question 1: a few weeks ago I was looking for ways to "protect and encrypt" my assets in agk tier 1, so I decided to make a "raw" example, packaging an image inside a purebasic DLL, and trying to import it into AppGameKit before I could create an image encryption algorithm to protect them ... Is there anything I can do about it using the Plugin Wrapper you created above?
this is the topic i created asking : https://forum.thegamecreators.com/thread/227684

Question 2:
besides the asset protection issue, I would also like to know if with the wrapper you created, I can control assets position, create or destroy entities such as: music, sprites, meshs, and others...
because I would like to create a Thread inside the DLL made in purebasic (Plugin) that starts a "Socket Client" so that I can send and receive information from a server asynchronously

example : if i send a string message > :


through the plugin made in purebasic imported into AppGameKit, the game AppGameKit would create a sprite asynchronously through external messages...

I hope I conveyed my questions well. I am very grateful for your attention
PartTimeCoder
AGK Tool Maker
9
Years of Service
User Offline
Joined: 9th Mar 2015
Location: London UK
Posted: 10th Aug 2021 16:46
Sure the framework is capable of doing all that, you have access to all AppGameKit functions inside your plugin code thats what the wrapper is for.

As for protecting assets, PB has a packer and a cypher lib, you could certainly code a entity encryption system but bear in mind that that protected asset had to be unprotected at some point for agk to load it, you could rip them to memory and encrypt then load in on a memblock, you dont need a plugin for this you can code that in basic look at [href=https://forum.thegamecreators.com/thread/220121]WadPacker
[/href]

And the server creating the sprites, sure, just setup a messaging system, the server does not actually call the sprite create function it sends a command to the client to create the sprite.

for a messaging system you want low latency which usually means DONT SEND STRINGS

CONST_CREATE_SPRITE = 100
CONST_IMAGE_A = 101

setup some constants that both the server and client understand CONST_CREATE_SPRITE|CONST_IMAGE_A|100|100|

and send as data, 4 ints travel the net a lot faster than a long ass string, do some bit shifting to make longs you now have 2 longs with HI and LO words.

But, yea, everything you ask is possible with the plugin framework





Open Source plugins
Cl - DnD Plugin
SkinK4ir3
8
Years of Service
User Offline
Joined: 25th Aug 2015
Location:
Posted: 11th Aug 2021 01:42 Edited at: 11th Aug 2021 01:44
it's wonderful to know that!!

thank you for solving my doubts, but i still have a question about how to manipulate memories allocated in purebasic, with the agk memblocks

PartTimeCoder wrote: "

As for protecting assets, PB has a packer and a cypher lib, you could certainly code a entity encryption system but bear in mind that that protected asset had to be unprotected at some point for agk to load it, you could rip them to memory and encrypt then load in on a memblock, you dont need a plugin for this you can code that in basic look at https://forum.thegamecreators.com/thread/220121

"


would you have any example of how i could import the image through a memblock in agk from a memory allocated from pb ?

in this topic >: https://forum.thegamecreators.com/thread/227684 i packaged an image inside the Plugin.dll, and the pb returns the allocated memory of the image, can I display it in AppGameKit?
PartTimeCoder
AGK Tool Maker
9
Years of Service
User Offline
Joined: 9th Mar 2015
Location: London UK
Posted: 11th Aug 2021 15:02
I have not tried to load embedded resources in AppGameKit but I do this often in PB, use ImportFile in a data section and then catchImage ... from there I am not quite sure what AppGameKit does with the image I would need to look at the core source but I would hazard a guess and say its a hBitMap GDI+ conversion (thats how I'd do it)

I'll take a poke round the source...
Open Source plugins
Cl - DnD Plugin
SkinK4ir3
8
Years of Service
User Offline
Joined: 25th Aug 2015
Location:
Posted: 16th Aug 2021 05:16
can i inject a memory with a png image inside a memblock in AppGameKit ?
Unseen Ghost
21
Years of Service
User Offline
Joined: 2nd Sep 2002
Location: Ohio
Posted: 3rd Oct 2021 22:24 Edited at: 3rd Oct 2021 22:56
@PartTimeCoder

How do we know what to put and how to put it in the text file that is with the dll's in AppGameKit directory? What is the format how it goes in the txt file? Is it from what I see in the command.txt files in each plugin, the top line is the same and everything underneath is the commands with their parameters after that on each line. Is this correct?

Also, I have notice that your CL plugin for AppGameKit doesn't have the function listed below anywhere in the code. Do we have to have the function to use our own created plugins in AppGameKit or not?



Of course I do see that there is an #IncludeFile statement at the top of your code, so do that mean you do have to have that particular function above in your code to activate any created plugin and we can just add #IncludeFile sources to add other stuff from PB to it. Or can we activate any plugin from PB any way we can/need to to use in AppGameKit and not have to use that particular function?
Gigabyte Board/ AMD 3.3 Ghtz Quad core/8GB Ram/Nvidia Geforce 1080 GTX 8GB/1TB Western Dig. SSD/Windows 10 Home/Dark Basic Pro 9Ex

No one cares how much you know until they know how much you care.

Login to post a reply

Server time is: 2024-03-29 09:35:09
Your offset time is: 2024-03-29 09:35:09