Partially.YYG has put this into the new version:
So now finally this can actually be updated.get_function_address() function has been added to help with external DLLs calling into GameMaker.
Gmapi V0.6.2 [updated: 26 Feb 2010]
#321
Posted 04 July 2011 - 11:06 PM
#322
Posted 15 October 2011 - 10:51 PM
Is that possible? I'm not getting to implement this.
#323
Posted 31 March 2012 - 11:39 AM
Edited by solano, 31 March 2012 - 11:41 AM.
#324
Posted 31 March 2012 - 11:39 AM
#325
Posted 26 April 2012 - 01:32 PM
im getting a error when i use the dll
"Unexpected error ocurred"
this is my dll
#include <gmapi.h>
#define GML extern "C" __declspec(dllexport)
// a sample exported function
GML double SomeFunction(void)
{
gm::show_message("DAFUQ!");
return(1);
}
#326
Posted 26 April 2012 - 02:04 PM
#327
Posted 26 April 2012 - 02:06 PM
original code
#define GMAPI_NO_D3D
#include <windows.h>
#include <gmapi.h>
using namespace gm;
CGMAPI* g_gmapi = NULL;
extern "C" __declspec(dllexport) double SomeFunction(void)
{
show_message("working?");
return(1);
}
BOOL WINAPI DllMain( HMODULE aModule, int aReason, int aReserved ) {
unsigned long result = 0;
switch ( aReason ) {
case DLL_PROCESS_ATTACH:
g_gmapi = gm::CGMAPI::Create( &result );
if ( result != gm::GMAPI_INITIALIZATION_SUCCESS ) {
MessageBoxA( 0, "Unable to initialize GMAPI.", 0, MB_SYSTEMMODAL | MB_ICONERROR );
return FALSE;
}
break;
case DLL_PROCESS_DETACH:
g_gmapi->Destroy();
break;
}
return TRUE;
}
im using CODEBLOCKS and mingw compiler
in game maker im using this:
def=external_define("gmAPITESTE.dll","SomeFunction",dll_cdecl,ty_real,0);
external_call(def);
windows 7 ultimate 32bits
Atom®3.8ghz 2gbs of ram, 500gbs HD
Edited by ChaosMaker, 26 April 2012 - 03:32 PM.
#328
Posted 26 April 2012 - 07:57 PM
...
Works only for GM 6.1,7 and 8 BTW
#329
Posted 26 April 2012 - 11:11 PM
but ever which i use gm::d3d_model_create();
i get this error in game maker "UNEXPEDTEC ERROR OCURRED"
for(int FRAME=FINDEX;FRAME<FLEN;FRAME++)//workis
{
MessageBox( 0, "Trying to create 3d model", 0,MB_OK);//here works
gm::d3d_model_create();// HERE WHEN I USE THIS, the game maker show "UNEXPECTED ERROR"
//the code stops here...
MessageBox( 0, "Model Created! trying to store in ds", 0,MB_OK);
gm::ds_list_add(DS,MODELTEMP);
MessageBox( 0, "STORED!", 0,MB_OK);
SetFrame(FRAME);
gm::d3d_model_primitive_begin(MODELTEMP,gm::pr_trianglestrip);
my gm code
def=external_define("GMAPI NEW TESTE.dll","WSHIRO_LOADMD2",dll_cdecl,ty_real,3,ty_string,ty_real,ty_real);
DS=external_call(def,"Play.md2",0,2);
show_message(ds_list_size(DS));
can someone help me ? D:
Edited by ChaosMaker, 26 April 2012 - 11:37 PM.
#330
Posted 27 April 2012 - 12:27 AM
I bypassed this by deferring the creation of the model to the GML caller.
change your API implementation from
model = MakeMeDaModel();
to
model = d3d_model_create();
FillMaModel(model);
In your case, you would need to split your method so to be able to fill a list with d3d models on the gm side and pass that list
script MD2ReadMD2File(md2filename as argument0)
//modellist = MD2ReadMD2File(md2filename)
//return -1 on fail, or the ds_list with the d3d models on success;
//you must free the models and the list with
//MD2FreeModels (modellist)
//call function that loads the file in memory
var md2Data; md2Data = MD2ReadFile(argument0);
//failed, exit;
if(md2Data == 0) return -1;
//ask how many frames
var NumModels; NumModels = MD2NumFrames(md2Data);
//pre gen the list, fill with models
var modlist; modlist = ds_list_create();
repeat(NumModels)
{
ds_list_add_value(modlist,d3d_model_create());
}
//pass the list and ask the models be populated
var success; success = MD2TransferToList(md2Data, modlist));
//free data
MD2FreeData(md2Data);
//if fail, cleaup exit -1
if(!success)
{
MD2FreeModels (modlist);
modlist = -1;
}
return modlist;
MD2FreeModels would d3d_model_destroy all items in the ds list and ds_list_destroy() the list
BTW, look at my tutorial on dll. you should not re-external_defining you stuff each call.
#331
Posted 17 May 2012 - 07:46 AM
#332
Posted 23 June 2012 - 07:41 PM
This would lighten the work a lot.
#333
Posted 15 September 2012 - 05:00 PM
the compiler shows this error
fatal error C1047: The object or library file '.\Release\dllmain.obj' was created with an older compiler than other objects; rebuild old objects and libraries
when i try to rebuild the source in visual c++ 2010
then compiler show a popup error
"Unable to start program C:\User\...\GMAPI\Source\Release-DLL\GMAPI.lib
the system cannot found the file"
i dont have antivirus and my firewalls is off...
#334
Posted 15 September 2012 - 07:10 PM
...
Rebuild with the special option that was defined for the lib... not release, not debug but one of the other 2. Then add the include in the extra include for your project and add the .lib in the extra library for your project
You can also bypass this level of dependency by building the source right with your dll. Make a sub folder under your project with the gmaip h and c++ files in it. Drag Drop the folder onto your project. You will have to tell MS Dev to allow compiling in multiple languages in the project properties and right click the asm file (which may not have been included by MS when you dropped the files on the project, so manually add it in) to tell ms to compile it with masm. Disable pre-compile headers or add #include "stdafx.h" in all the GMAPI headers.
I also had to fetch, online, the missing asm kernel32.inc file and add it to the project compiled also with masm.
#335
Posted 15 September 2012 - 11:27 PM
thanks!
#336
Posted 16 September 2012 - 02:13 AM
Yay working!
thanks!
How did you fix it?
#338
Posted 13 March 2013 - 07:45 PM
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users









