Pages: « 1 2 3 4 »
  Print  
Author Topic: [Solved] Adding a new function  (Read 9549 times)
Offline (Male) Goombert
Reply #30 Posted on: October 02, 2014, 06:09:14 PM

Developer
Location: Cappuccino, CA
Joined: Jan 2013
Posts: 3110

View Profile
Those are actually warnings, you only have one error actually.
D:\Users\Jason\AppData\Local\Temp\ccD9ph1j.ltrans20.ltrans.o:ccD9ph1j.ltrans20.o:(.text+0x540): undefined reference to `enigma_user::window_device()'
D:\Users\Jason\AppData\Local\Temp\ccD9ph1j.ltrans21.ltrans.o:ccD9ph1j.ltrans21.o:(.text+0x414): undefined reference to `enigma_user::window_device()'

When you moved window_device, did you leave it in namespace enigma_user {} ?
Logged
I think it was Leonardo da Vinci who once said something along the lines of "If you build the robots, they will make games." or something to that effect.

Offline (Unknown gender) lonewolff
Reply #31 Posted on: October 02, 2014, 06:23:06 PM
"Guest"


Email
Line 40 in WINDOWSMain.h (right inside namespace enigma_user {} )

void* window_device();
Logged
Offline (Male) Goombert
Reply #32 Posted on: October 02, 2014, 06:23:57 PM

Developer
Location: Cappuccino, CA
Joined: Jan 2013
Posts: 3110

View Profile
No, in the source (graphics_bridge.cpp)?
Logged
I think it was Leonardo da Vinci who once said something along the lines of "If you build the robots, they will make games." or something to that effect.

Offline (Unknown gender) lonewolff
Reply #33 Posted on: October 02, 2014, 06:30:00 PM
"Guest"


Email
Oh as in like this?

void* enigma_user::window_device()?

Nope, although it worked the ther day without enigma_user:: at the front.

My daughter is on my PC right now, so will test in a bit. :)

[off topic]
I just found out I get a Win8 tablet today. Work is feeling generous! Happy days! :)
« Last Edit: October 02, 2014, 06:31:47 PM by lonewolff » Logged
Offline (Unknown gender) lonewolff
Reply #34 Posted on: October 02, 2014, 08:00:06 PM
"Guest"


Email
Just tried this in graphics_bridge.cpp

Code: [Select]
void* enigma_user::window_device()
{
return (void*)d3dmgr->device;
}

Still the same error.

I am sure I am making a silly mistake somewhere. :(

[edit]
** Damn! This default OpenGL thing gets me every time..... LOL
« Last Edit: October 02, 2014, 08:05:27 PM by lonewolff » Logged
Offline (Unknown gender) sorlok_reaves
Reply #35 Posted on: October 02, 2014, 08:05:30 PM
Contributor
Joined: Dec 2013
Posts: 261

View Profile
Just tried this in graphics_bridge.cpp

Code: [Select]
void* enigma_user::window_device()
{
return (void*)d3dmgr->device;
}

Still the same error.

I am sure I am making a silly mistake somewhere. :(

Is window_device() inside some other namespace? Like enigma{} maybe? Or can you post both files?
Logged
Offline (Unknown gender) lonewolff
Reply #36 Posted on: October 02, 2014, 08:11:32 PM
"Guest"


Email
I just Ninja'd you.

I had project settings on OpenGL  ::)

Not used to the defaults on ENIGMA.  :D

Compiled fine but app still crashes when trying to draw a textured quad. So, more investigating at my end now (DLL works fine in GM:S)
Logged
Offline (Unknown gender) sorlok_reaves
Reply #37 Posted on: October 02, 2014, 08:19:14 PM
Contributor
Joined: Dec 2013
Posts: 261

View Profile
I just Ninja'd you.

I had project settings on OpenGL  ::)

Not used to the defaults on ENIGMA.  :D

Compiled fine but app still crashes when trying to draw a textured quad. So, more investigating at my end now (DLL works fine in GM:S)

Can you print the pointer and make sure it's actually pointing to the same memory location?
Logged
Offline (Unknown gender) lonewolff
Reply #38 Posted on: October 02, 2014, 08:21:48 PM
"Guest"


Email
Yep, just looking now. Project became seriously garbled. Starting a new one  (Y)
Logged
Offline (Unknown gender) lonewolff
Reply #39 Posted on: October 02, 2014, 08:38:42 PM
"Guest"


Email
Still crashes on my create_quad() call, even though the window_device seems to be returning a good value :)

So this is what I have.

Create event
Code: [Select]
dll_name="t.dll";

init=external_define(dll_name,"init",dll_cdecl,ty_real,1,ty_string);
create_quad=external_define(dll_name,"createQuad",dll_cdecl,ty_real,0);
draw_quad=external_define(dll_name,"drawQuad",dll_cdecl,ty_real,0);

aaa=external_call(init,window_device());
bbb=external_call(create_quad);            // *** THIS IS CAUSING ENIGMA TO CRASH ***

Part of the DLL
Code: [Select]
export double init(void* mD3dDevice)
{
d3dDevice=(IDirect3DDevice9*)mD3dDevice;

if(!d3dDevice)
return 1000;

return 0;
}

The above returns 0 and window_device() in EDL returns a nice hex value.

The following call causes ENIGMA to crash even though I use error checking.  ???

Code: [Select]
export double createQuad()
{
if(!d3dDevice)
return 1000;

int nNumVerts=4;

if(FAILED(d3dDevice->CreateVertexBuffer((nNumVerts)*sizeof(D3DVERTEX),D3DUSAGE_DYNAMIC|D3DUSAGE_WRITEONLY,D3DFVF_XYZRHW|D3DFVF_DIFFUSE,D3DPOOL_DEFAULT,&pVertexObjectQuad,NULL)));
return 1;

return 0;
}

How can this possibly cause a crash?

If it fails it should just return '1' to the calling function.  ???

This is wierd as...

On GM:S, if I leave out the call to get window_device() (to force an error) then create_quad will return 1 as expected. If I do the same with ENIGMA it shits itself and crashes.

So, the problem isn't related to window_device anymore. It is to do with ENIGMA crashing if a error checked directx call happens.

I just can understand why an error handled call should crash anything.  ???

Possibly something to do with my DLL built on MSVC?

I have also checked that we don't have a DX9 (subversion) conflict. My DLL is using d3dx9_43 (June 2010 SDK). From what I can see, ENIGMA is built on the same version of DX9.

Only difference now that I can see is MinGW & MSVC.
« Last Edit: October 02, 2014, 09:14:47 PM by lonewolff » Logged
Offline (Unknown gender) sorlok_reaves
Reply #40 Posted on: October 03, 2014, 07:16:02 AM
Contributor
Joined: Dec 2013
Posts: 261

View Profile
I would guess it crashes becaused3dDevice is not initialized to 0. Also, passing a garbage pointer is hard to detect. But I don't know for sure --the pointer seems to be valid, so maybe the DirectX ENIGMA users have an idea?
Logged
Offline (Male) Goombert
Reply #41 Posted on: October 03, 2014, 07:38:20 AM

Developer
Location: Cappuccino, CA
Joined: Jan 2013
Posts: 3110

View Profile
Sorlok is right, it's a garbage pointer and you are checking if its null, its obviously not null because it's a garbage pointer, and then you try to access it inside the FAILED() call which leads to a segfault. Run the game in debug mode to build with debug symbols, then open git-bash and type "gdb path/to/temp/file/from/lgmsconsole" and hit enter, then when it loads the temp file LGM outputted with debug symbols just type "run" and hit enter and it should launch and then crash giving you a stack trace. Then you type "bt" for the backtrace and it will tell you the exact file and line number it crashed in, though idk if it will get the symbols from the DLL properly or not but it should, if not build a debug version of the dll.

Anyway to prove my point, remove the FAILED() macro and it should still crash. It has nothing to do with DirectX, it is still an issue in the variant.
« Last Edit: October 03, 2014, 07:41:22 AM by Robert B Colton » Logged
I think it was Leonardo da Vinci who once said something along the lines of "If you build the robots, they will make games." or something to that effect.

Offline (Unknown gender) sorlok_reaves
Reply #42 Posted on: October 03, 2014, 09:26:34 PM
Contributor
Joined: Dec 2013
Posts: 261

View Profile
All the variant is doing is wrapping the pointer and then passing it back; I've confirmed that it works for simple new'd data. It would have to be something slightly more complicated, I think, to cause the invalid pointer to be saved.

Can you post a branch and test game, so that I can run it through GDB?
Logged
Offline (Male) Goombert
Reply #43 Posted on: October 03, 2014, 11:07:46 PM

Developer
Location: Cappuccino, CA
Joined: Jan 2013
Posts: 3110

View Profile
Ok my apologies sorlok, I have run some tests and it appears your code is working fine.

WINDOWSmain.h
Code: (C++) [Select]
namespace enigma_user
{
void test_draw_clear(void* d3ddev);
void* window_device();
unsigned long long window_handle();
int sleep(int millis);
}

graphics_bridge.cpp
Code: (C++) [Select]
void* window_device() {
  return (void*)d3dmgr->device;
}

void test_draw_clear(void* d3ddev) {
  IDirect3DDevice9* dev = (IDirect3DDevice9*)d3ddev;
  dev->Clear(0, NULL, D3DCLEAR_TARGET, D3DCOLOR_RGBA(255, 0, 0, 255), 0, 0);
}

Object Draw Event
Code: (EDL) [Select]
test_draw_clear(window_device());
Works perfectly as expected and clears the background color to red. It must be an issue with the dll functions then.
« Last Edit: October 03, 2014, 11:09:23 PM by Robert B Colton » Logged
I think it was Leonardo da Vinci who once said something along the lines of "If you build the robots, they will make games." or something to that effect.

Offline (Unknown gender) sorlok_reaves
Reply #44 Posted on: October 03, 2014, 11:23:57 PM
Contributor
Joined: Dec 2013
Posts: 261

View Profile
Glad the pointer passing is working. Once you figure out the DLL issue, let me know  ---we really need to have a discussion about the "right" way to store pointers in variants (since my solution is a bit hacky).
Logged
Pages: « 1 2 3 4 »
  Print