Gmaker C/c++ Library V. 2
#21
Posted 23 February 2009 - 06:19 AM
#22
Posted 23 February 2009 - 07:07 AM
An important question I'd like to ask is, how fast can I get an image from a DLL into a Game Maker surface with this (if at all possible)?
You would have to convert the image (bmp) to a format acceptable by the draw_sprite command less you be forced to draw the image pixel by pixel
The guy who made this
http://gmc.yoyogames...hp/t397947.html
Could possibly know the answer..
Less you be able to get the DC of the surface directly from GM if it's a DC or it may be a directdraw handle or some other type of directx resource... Then you could draw right on on is with directx calls..
Having direct access to the directx resources created and used by GM would also be of great help in order to avoid having to go through GM's standard functions... Such has having to add a sprite to the sprite resource in order to draw it in the gm space.
#23
Posted 23 February 2009 - 08:29 AM
Its quite simple to hook Direct3DCreate(8/9)() to get the the iD3D(8/9) interface and then hook id3d8::CreateDevice() to get the Direct3D(8/9) Device pointer, which is used by every d3d app to render stuff load pixel/vertex shaders, etc etc.Having direct access to the directx resources created and used by GM would also be of great help in order to avoid having to go through GM's standard functions... Such has having to add a sprite to the sprite resource in order to draw it in the gm space.
If someone wants, I could release an example.
Edited by freaked, 23 February 2009 - 08:32 AM.
#24
Posted 23 February 2009 - 08:48 AM
Its quite simple to hook Direct3DCreate(8/9)() to get the the iD3D(8/9) interface and then hook id3d8::CreateDevice() to get the Direct3D(8/9) Device pointer, which is used by every d3d app to render stuff load pixel/vertex shaders, etc etc.Having direct access to the directx resources created and used by GM would also be of great help in order to avoid having to go through GM's standard functions... Such has having to add a sprite to the sprite resource in order to draw it in the gm space.
If someone wants, I could release an example.
Go ahead... It would complement this dll I think
#25
Posted 23 February 2009 - 09:49 PM
Go ahead... It would complement this dll I think
This is a library, not a dll. ;P
The example is a dll though. ^^
Anyway, you can do it like this in the one I'm working on:
GMPROC* pshow_message;
void init()
{
pshow_message = (GMPROC*) GetGMProcAddress("show_message");
}
GMVariable show_message(GMVariable message)
{
GMVariable args[] = { message };
return GMExternalCall(pshow_message, 1, 0, args);
}
export double call(char* message)
{
show_message(message);
}Now, I'm looking into making it more like this:
GMPROC show_message;
void init()
{
show_message = GetGMProcAddress("show_message");
}
export double call(char* message)
{
show_message(1, message); // 1 is the args used
}But I don't think you can use a class as a function... if anyone knows how to, by all means, tell me now.
If the first one is fine with everybody, I'll release it now. Otherwise, I'll look into the second one...
GMVariable has been beefed up a bit, too.
GMVariable a = 5; GMVariable b = "Hey!"; GMVariable c = 7; double d = a + b; char* e = b;
Some examples. ^
Edited by X-tra Fear, 23 February 2009 - 10:07 PM.
#26
Posted 23 February 2009 - 09:54 PM
Was that a joke? How can you know C++, and not know how to use operator overloading?But I don't think you can use a class as a function... if anyone knows how to, by all means, tell me now.
While you're at it, if you're going to encapsulate this anyway, then there's really no reason to have a separate function that serves the purpose of a constructor. Just give your GM function class a constructor that takes a string, have the class itself do the work.
And if you're going to add "GM" to the beginning of everything you make, then you might as well create a namespace to put all of this in, and make it easier to work with.
Edited by Mnementh, 23 February 2009 - 09:58 PM.
#27
Posted 23 February 2009 - 09:56 PM
Edited by X-tra Fear, 24 February 2009 - 11:19 AM.
#28
Posted 23 February 2009 - 11:07 PM
#29
Posted 24 February 2009 - 12:00 AM
#30
Posted 24 February 2009 - 06:58 AM
Inject with Winject into a game maker game.
[huge code]
[codebox]// d3dhook.cpp : Defines the entry point for the console application.
//
#define msg(text) MessageBoxW(0,text,L"D3DHOOK",0)
#include "stdafx.h"
#include <windows.h>
#include "define.h"
#include <detours.h>
#include <d3d8.h>
#pragma comment(lib,"detours.lib")
#pragma comment(lib,"d3d8.lib")
void HookCreateDevice();
void HookDirect3DCreate8();
IDirect3D8* g_interface;
IDirect3DDevice8* g_device;
IDirect3D8* (__stdcall *oDirect3DCreate8)(UINT version);
IDirect3D8* __stdcall hkDirect3DCreate8(UINT version)
{
__asm nop;
MessageBox(0,L"D3DCreate8 called -- d3dhook",L"D3DHOOK",0);
g_interface = oDirect3DCreate8(version);
HookCreateDevice();
return g_interface;
}
HRESULT (__stdcall *oCreateDevice)(IDirect3D8* me,UINT Adapter, D3DDEVTYPE DeviceType, HWND hFocusWindow, DWORD BehaviorFlags, D3DPRESENT_PARAMETERS *pPresentationParameters, IDirect3DDevice8 **ppReturnedDeviceInterface);
HRESULT __stdcall hkCreateDevice(IDirect3D8* me,UINT Adapter, D3DDEVTYPE DeviceType, HWND hFocusWindow, DWORD BehaviorFlags, D3DPRESENT_PARAMETERS *pPresentationParameters, IDirect3DDevice8 **ppReturnedDeviceInterface)
{
__asm nop;
MessageBox(0,L"CreateDevice()called! -- d3dhook",L"D3DHOOK",0);
HRESULT hr = oCreateDevice(me,Adapter,DeviceType,hFocusWindow,B
ehaviorFla
gs,pPresentationParameters,ppReturnedDeviceInterfa
c
e);
g_device = *ppReturnedDeviceInterface;
return hr;
}
void HookDirect3DCreate8()
{
MessageBox(0,L"HookingDirect3DCreate8",L"D3DHOOK",0);
oDirect3DCreate8 = (IDirect3D8 *(__stdcall *)(UINT))DetourFunction((PBYTE)GetProcAddress(Load
Library(L"d3d8.dll"),"Direct3DCreate8"),(PBYTE)hkDirect3DCreate8);
}
void HookCreateDevice()
{
MessageBox(0,L"Hooking CreateDevice() now",L"D3DHOOK",0);
DWORD* pdwNewInterface = (DWORD*)g_interface;
pdwNewInterface = (DWORD*)pdwNewInterface[0];
MessageBox(0,L"PEnter to Install Hook",L"",0);
oCreateDevice =(HRESULT (__stdcall *)(IDirect3D8 *,UINT,D3DDEVTYPE,HWND,DWORD,D3DPRESENT_PARAMETERS *,IDirect3DDevice8 **)) DetourFunction((PBYTE)pdwNewInterface[15],(PBYTE)h
kCreateDevice);
}
/*
*
*
*
* DLLMAIN
*
*
*
*/
bool __stdcall DllMain(HMODULE hHand,DWORD dwReason,LPVOID lpReserved)
{
switch(dwReason)
{
case DLL_PROCESS_ATTACH:
//DisableThreadLibraryCalls(hHand);
MessageBox(0,L"Hook Injected",L"D3DHOOK",0);
HookDirect3DCreate8();
//HookCreateDevice();
case DLL_PROCESS_DETACH:
//MessageBoxW(0,L"Exit",L"Exit",0);
GetForegroundWindow();
}
return TRUE;
}[/codebox]
[/huge code]
[Edit]Updated to use code-box
Edited by freaked, 24 February 2009 - 09:43 AM.
#31
Posted 24 February 2009 - 11:21 AM
Unless you want to cast every argument like this (GMVar)(GmVariable) 5 ;P
Going to try to get a newer version up before I go to school in 10 mins... later.
@ the guy above
I'll try to add a simple way to get it into the library using that.
I added a export thing in the GMaker.h file so you won't need to define anything.
Will you release the uncompiled source for this? Ever?
You think I really want to hear anybody else bash my code?
I'll think about it.
EDIT: Will be releasing the updated version within an hour.
There are a few major changes, it should be easier to work with now, and I even provided an example using show_message(string(number));
Edited by X-tra Fear, 24 February 2009 - 08:59 PM.
#32
Posted 24 February 2009 - 09:44 PM
And double post. x.x
Edited by X-tra Fear, 24 February 2009 - 09:44 PM.
#33
Posted 24 February 2009 - 10:09 PM
Why not just use Delphi with some typcasting? I've got this working in much less dirtier C++ code.
#34
Posted 24 February 2009 - 10:10 PM
I can't see why you people still want to use C++ for the job, you'll end up recreating most of the vcl/rtl.
Why not just use Delphi with some typcasting? I've got this working in much less dirtier C++ code.
That's cool.
Got what working?
EDIT: Sorry, misread it.
What does the _your_ mean when it has __ with it? :S
EDIT2: Ah, gotcha.
EDIT3: Nvm, lol. xD
Edited by X-tra Fear, 24 February 2009 - 10:20 PM.
#35
Posted 24 February 2009 - 10:11 PM
Would you debug PHP with a disassembler?
Edit:
1) Pointer playing
2) That's to show the focus of my message
Edit:
Huh?!
Edited by uuf6429, 24 February 2009 - 10:18 PM.
#36
Posted 25 February 2009 - 06:14 AM
#37
Posted 25 February 2009 - 07:44 PM
Very good... Now I can update a few of my dlls
I'm glad somebody wants to use it...
#38
Posted 25 February 2009 - 10:48 PM
#39
Posted 25 February 2009 - 11:00 PM
Stuff like this is kinda distorting the original intention of GM. "...You can make a game without any code!..." "...Its aimed at beginners..."
#40
Posted 26 February 2009 - 12:26 AM
Nice. The only problem is: Why the hell would someone be using GM functions in C++ if they could eaisly make a faster version in C++, and why not just switch completely to C++?
Stuff like this is kinda distorting the original intention of GM. "...You can make a game without any code!..." "...Its aimed at beginners..."
If want to have a jello 3d model... you can't morph the points fast enough. So you move that code in a dll
If you want to fiddle a grid, average them to emulate wind... Again, move the code to a dll...
If you want to quick draw a surface biit by bit, morphing it so it looks like watter... Again GML is too slow... Move the code to a dll.
If you want to pass a laerge amout of data back and forth, a ds_list or map is the only way to go... You need to acces GM's data structure in the dll to do that.
If you don't see the use of this it's your lack of imagination. I've been needing this in the first GM dll I ever made. It's so obvious we need this from day 1.
This open up the possibility for GM addons that are 1000 times more powerful than a freaking dll with APIs passing a limited number of doubles and strings. A single API call can update GM data without the need to translate information... Like (right now) calling a API 3000 time to get 1000 x,y,z points...
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users











