Jump to content


Photo

Gmapi V0.6.2 [updated: 26 Feb 2010]


  • Please log in to reply
337 replies to this topic

#321 TheMagicNumber

TheMagicNumber

    GMC Member

  • GMC Member
  • 5247 posts
  • Version:Unknown

Posted 04 July 2011 - 11:06 PM

YYG has put this into the new version:

get_function_address() function has been added to help with external DLLs calling into GameMaker.

So now finally this can actually be updated.

Partially.
  • 0

#322 kabecao

kabecao

    GMC Member

  • GMC Member
  • 83 posts
  • Version:GM:Studio

Posted 15 October 2011 - 10:51 PM

And to chance a pixel color of the bitmap of the sprite?
Is that possible? I'm not getting to implement this.
  • 0

#323 solano

solano

    GMC Member

  • GMC Member
  • 460 posts
  • Version:GM8

Posted 31 March 2012 - 11:39 AM

## double post ###

Edited by solano, 31 March 2012 - 11:41 AM.

  • 0

#324 solano

solano

    GMC Member

  • GMC Member
  • 460 posts
  • Version:GM8

Posted 31 March 2012 - 11:39 AM

Can someone post a mirror for the wiki? The link in the first post is dead and it is really hard for me to search the source code for functions that I need.
  • 0

#325 ChaosMaker

ChaosMaker

    GMC Member

  • GMC Member
  • 288 posts
  • Version:GM:HTML5

Posted 26 April 2012 - 01:32 PM

im trying to use the gm api, but is a bit confuse

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);
}







  • 0

#326 PsichiX

PsichiX

    GMC Member

  • GMC Member
  • 358 posts

Posted 26 April 2012 - 02:04 PM

you don't have dllmain function with creation of gmapi instance - it is required.
  • 0

#327 ChaosMaker

ChaosMaker

    GMC Member

  • GMC Member
  • 288 posts
  • Version:GM:HTML5

Posted 26 April 2012 - 02:06 PM

yes i have, but still give me same error

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.

  • 0

#328 icuurd12b42

icuurd12b42

    Self Formed Sentient

  • Global Moderators
  • 14384 posts
  • Version:GM:Studio

Posted 26 April 2012 - 07:57 PM

...


Works only for GM 6.1,7 and 8 BTW
  • 0

#329 ChaosMaker

ChaosMaker

    GMC Member

  • GMC Member
  • 288 posts
  • Version:GM:HTML5

Posted 26 April 2012 - 11:11 PM

im using game maker 8, i did it solve all errors

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.

  • 0

#330 icuurd12b42

icuurd12b42

    Self Formed Sentient

  • Global Moderators
  • 14384 posts
  • Version:GM:Studio

Posted 27 April 2012 - 12:27 AM

I studied the same problem when implementing GMModelEx (In my tools page) and I can only assume the function address fetched from the runner is wrong or possibly, currently defined as returning int, short or long another data type than int should be used for the implementation of d3d_model_create. I tried fiddling with it and gave up. Under MS debug, MS reported the stack being misaligned if I remember, indicating either the return type of arguments are wrong. but I failed to figure it out.

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.
  • 0

#331 Camman

Camman

    UnReal Software CEO

  • GMC Member
  • 634 posts
  • Version:GM:Studio

Posted 17 May 2012 - 07:46 AM

Would it be possible to take the 0.6.2 source code and modify the GmapiConsts.cpp (and .h) files to add compatibility for GM 8.1?
  • 0

#332 famous

famous

    GMC Member

  • GMC Member
  • 169 posts
  • Version:Unknown

Posted 23 June 2012 - 07:41 PM

Would be very great if you can proceed this. Im gonna write a Unlimited Basic (self written Bytecode Interpreter by Mevedia) Integration to replace GML. The syntax is nealy 100% the same like PureBasic or a few VB and the capabilites are mostly the same.

This would lighten the work a lot.
  • 0

#333 ChaosMaker

ChaosMaker

    GMC Member

  • GMC Member
  • 288 posts
  • Version:GM:HTML5

Posted 15 September 2012 - 05:00 PM

when i try to build the example in release

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...


  • 0

#334 icuurd12b42

icuurd12b42

    Self Formed Sentient

  • Global Moderators
  • 14384 posts
  • Version:GM:Studio

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.
  • 1

#335 ChaosMaker

ChaosMaker

    GMC Member

  • GMC Member
  • 288 posts
  • Version:GM:HTML5

Posted 15 September 2012 - 11:27 PM

Yay working!

thanks! :)


  • 0

#336 icuurd12b42

icuurd12b42

    Self Formed Sentient

  • Global Moderators
  • 14384 posts
  • Version:GM:Studio

Posted 16 September 2012 - 02:13 AM

Yay working!

thanks! :)


How did you fix it?
  • 0

#337 ChaosMaker

ChaosMaker

    GMC Member

  • GMC Member
  • 288 posts
  • Version:GM:HTML5

Posted 16 September 2012 - 02:25 AM

downloading DX8.1 SDK...





  • 0

#338 fel666

fel666

    GMC Member

  • GMC Member
  • 68 posts
  • Version:GM:Studio

Posted 13 March 2013 - 07:45 PM

will we ever see this for gm:studio?
  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users