Pages: « 1 2 3 4 »
  Print  
Author Topic: [Solved] Adding a new function  (Read 9532 times)
Offline (Male) Goombert
Reply #15 Posted on: September 29, 2014, 01:18:58 AM

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

View Profile
Something somebody needs to do if we want pointer types. First the compiler has to support parsing it, only sorlok could probably pull that off, too complex for me. Second variant type needs overloaded, I've tried overloading it myself for arrays before, and it was hell and I gave up.
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 #16 Posted on: September 29, 2014, 01:21:04 AM
"Guest"


Email
Bummer.

Looks like this is what needs to be done if window_device() and window_handle() want to work as per GM:S.

Having said that, does window_handle() work in ENIGMA in its current form?
Logged
Offline (Male) time-killer-games
Reply #17 Posted on: September 29, 2014, 01:32:31 AM

Contributor
Location: Virginia Beach
Joined: Jan 2013
Posts: 1166

View Profile Email
^it works with GM81 casted dll's. But with GMS specific dll's have no idea,
Logged
Offline (Unknown gender) lonewolff
Reply #18 Posted on: September 29, 2014, 01:53:21 AM
"Guest"


Email
Trying to cast from a double to a device but it is failing (returns 1)

Code: [Select]
export double init(double mD3dDevice)
{
void* temp=&mD3dDevice;

d3dDevice=(IDirect3DDevice9*)temp;

if(!d3dDevice)
return 1;

return 0;
}

If we can force a cast, I am confident the whole thing will still work.
Logged
Offline (Male) DaSpirit
Reply #19 Posted on: September 29, 2014, 05:47:33 AM

Member
Location: New York City
Joined: Mar 2013
Posts: 124

View Profile
Why not use C++?

If we can force a cast, I am confident the whole thing will still work.
Yes, C++ has that. It's called reinterpret_cast<T>.
Logged
Offline (Unknown gender) lonewolff
Reply #20 Posted on: September 29, 2014, 06:35:12 AM
"Guest"


Email
I can now get a return value of zero (which is good-ish), but still not sure if it is casting to a correct value as my next call (create_buffer()) in the DLL is always failing INVALID_CALL. (Normally caused by a dodgy D3D device from experience)

So, I am not completely confident I am referencing the right part of memory.

Also the window_device() function Rob helped me to write into the source is interesting.

If I draw_text(20,20, string(window_device())) in GM:S, I get a hexadecimal value 8 characters or so (not on my PC now) and if I make the same call in ENIGMA, I get a decimal value of about 12 digits or so.

So either ENIGMA's string() function is not quite right or something funky is going on.
« Last Edit: September 29, 2014, 06:37:12 AM by lonewolff » Logged
Offline (Unknown gender) TheExDeus
Reply #21 Posted on: September 29, 2014, 06:39:38 AM

Developer
Joined: Apr 2008
Posts: 1872

View Profile
I don't think GM:S prints text in hexadecimal. It could be possible GM:S shows 8 decimal digits, but ENIGMA show 12 digits. It's just a matter of taste.
Logged
Offline (Unknown gender) lonewolff
Reply #22 Posted on: September 29, 2014, 06:53:49 AM
"Guest"


Email
Definitely displays window_device() in hexadecimal on GM:S.  (Y)

Definitely... :)
Logged
Offline (Unknown gender) sorlok_reaves
Reply #23 Posted on: September 29, 2014, 08:21:15 AM
Contributor
Joined: Dec 2013
Posts: 261

View Profile
I can definitely re-write var/variant to hold and dispense a void pointer, but I'd really like some input from Josh on this. In particular, I'd like to know what the user-level interface for extracting a pointer would be like, and how it would gracefully fail. I assume something like this:

Code: [Select]
variant::variant(const void* p): rval(0), sval(), pval(p), type(ptr) { }
const void* some_function_to_get_the_ptr() { return (type==ptr) ? p : 0; }
Logged
Offline (Unknown gender) lonewolff
Reply #24 Posted on: September 29, 2014, 05:07:30 PM
"Guest"


Email
I can definitely re-write var/variant to hold and dispense a void pointer, but I'd really like some input from Josh on this. In particular, I'd like to know what the user-level interface for extracting a pointer would be like, and how it would gracefully fail. I assume something like this:

Code: [Select]
variant::variant(const void* p): rval(0), sval(), pval(p), type(ptr) { }
const void* some_function_to_get_the_ptr() { return (type==ptr) ? p : 0; }

I think it was you, that Rob mentioned to me, with regards to this (yesterday). And he did say something about you having to write a variant.

If this could be written in, it would be awesome ;)

As it stands window_handle() is implemented incorrectly in ENIGMA also (as it is a pointer, like window_device())

(This information was supplied to me by Russell Kay BTW - so not just making 'shit' up)  (Y)
« Last Edit: September 29, 2014, 05:09:18 PM by lonewolff » Logged
Offline (Unknown gender) sorlok_reaves
Reply #25 Posted on: September 30, 2014, 10:33:54 PM
Contributor
Joined: Dec 2013
Posts: 261

View Profile
I think it was you, that Rob mentioned to me, with regards to this (yesterday). And he did say something about you having to write a variant.

Just a quick update; I'm all over the country this week, so I'm afraid this feature will be slightly delayed. (Frustrating, I know.) I actually brought an external hard drive with my dev. environment on it, but I forgot my Super Grub CD (do'h!) so it's just a brick.
Logged
Offline (Unknown gender) lonewolff
Reply #26 Posted on: September 30, 2014, 11:00:24 PM
"Guest"


Email
No probs. Let me know when you get a chance. No rush.  (Y)
Logged
Offline (Male) Goombert
Reply #27 Posted on: October 01, 2014, 01:52:06 AM

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

View Profile
Hey it's ok sorlok! Enjoy yourself and I hope you have a nice time!
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 #28 Posted on: October 02, 2014, 03:12:20 PM
Contributor
Joined: Dec 2013
Posts: 261

View Profile
Ok, this is just a proof-of-concept, but it *should* work. Please merge this commit to your local repo:
https://github.com/sorlok/enigma-dev/compare/enigma-dev:master...sorlok:hacky_pointers

...and then do something like this:
Code: [Select]
export double init(variant mD3dDevice)
{
void* temp = temp_get_pointer(mD3dDevice);
}

You should also modify your init code to print the pointer address of mD3dDevice the first time it is created. Then compare that value to temp and make sure we're at least looking at the right location in memory.

If that works, try actually using the pointer.
Logged
Offline (Unknown gender) lonewolff
Reply #29 Posted on: October 02, 2014, 05:58:52 PM
"Guest"


Email
Hi Sorlok,

Still getting compilation errors, so I'll list everything I have done today (incase I have confused myself and done something silly).

1st updated the files you linked in your post.

Code: [Select]
// Added window_device to WINDOWSmain.h

namespace enigma_user
{

unsigned long long window_handle();
int sleep(int millis);
void* window_device();

}

Code: [Select]
// added window_device towards the end of graphics_bridge.cpp

void* window_device()
{
return (void*)d3dmgr->device;
}

Now getting compilation errrors

Quote
Running make from `mingw32-make.exe'
Full command line: mingw32-make.exe Game WORKDIR="C:/ProgramData/ENIGMA/" GMODE=Compile GRAPHICS=OpenGL1 AUDIO=OpenAL COLLISION=Precise WIDGETS=Win32 NETWORKING=None PLATFORM=Win32 CXXFLAGS="-I../Additional/i686-w64-mingw32/include" COMPILEPATH="Windows/Windows" EXTENSIONS=" Universal_System/Extensions/Alarms Universal_System/Extensions/Timelines Universal_System/Extensions/Paths Universal_System/Extensions/MotionPlanning Universal_System/Extensions/DateTime Universal_System/Extensions/ParticleSystems Universal_System/Extensions/DataStructures" OUTPUTNAME="D:/Users/Jason/Desktop/_aaa.exe" eTCpath=""
mingw32-make.exe -C ENIGMAsystem/SHELL
mingw32-make.exe[1]: Entering directory `D:/Users/Jason/Downloads/ENIGMA/enigma-dev/ENIGMAsystem/SHELL'
mkdir.exe -p C:/ProgramData/ENIGMA/.eobjs/Windows/Windows/Compile/
mkdir.exe -p C:/ProgramData/ENIGMA/.eobjs/Windows/Windows/Compile/Audio_Systems/OpenAL/
mkdir.exe -p C:/ProgramData/ENIGMA/.eobjs/Windows/Windows/Compile/Bridges/Win32-OpenGL1/
mkdir.exe -p C:/ProgramData/ENIGMA/.eobjs/Windows/Windows/Compile/Collision_Systems/Precise/
mkdir.exe -p C:/ProgramData/ENIGMA/.eobjs/Windows/Windows/Compile/Graphics_Systems/General/
mkdir.exe -p C:/ProgramData/ENIGMA/.eobjs/Windows/Windows/Compile/Graphics_Systems/OpenGL1/
mkdir.exe -p C:/ProgramData/ENIGMA/.eobjs/Windows/Windows/Compile/Platforms/Win32/
mkdir.exe -p C:/ProgramData/ENIGMA/.eobjs/Windows/Windows/Compile/Universal_System/
mkdir.exe -p C:/ProgramData/ENIGMA/.eobjs/Windows/Windows/Compile/Universal_System/Extensions/Alarms/
mkdir.exe -p C:/ProgramData/ENIGMA/.eobjs/Windows/Windows/Compile/Universal_System/Extensions/DataStructures/
mkdir.exe -p C:/ProgramData/ENIGMA/.eobjs/Windows/Windows/Compile/Universal_System/Extensions/DateTime/
mkdir.exe -p C:/ProgramData/ENIGMA/.eobjs/Windows/Windows/Compile/Universal_System/Extensions/MotionPlanning/
mkdir.exe -p C:/ProgramData/ENIGMA/.eobjs/Windows/Windows/Compile/Universal_System/Extensions/ParticleSystems/
mkdir.exe -p C:/ProgramData/ENIGMA/.eobjs/Windows/Windows/Compile/Universal_System/Extensions/Paths/
mkdir.exe -p C:/ProgramData/ENIGMA/.eobjs/Windows/Windows/Compile/Universal_System/Extensions/Timelines/
mkdir.exe -p C:/ProgramData/ENIGMA/.eobjs/Windows/Windows/Compile/Widget_Systems/Win32/
g++ -I../Additional/i686-w64-mingw32/include -IPlatforms/Win32/Info -IGraphics_Systems/OpenGL1/Info -IAudio_Systems/OpenAL/Info -ICollision_Systems/Precise/Info -IWidget_Systems/Win32/Info -INetworking_Systems/None/Info -IUniversal_System/Info -I. -IC:/ProgramData/ENIGMA/ -Wall -s -O3 -flto -fno-exceptions -fdata-sections -ffunction-sections  -MMD -MP -c -o C:/ProgramData/ENIGMA/.eobjs/Windows/Windows/Compile/Bridges/Win32-OpenGL1/graphics_bridge.o Bridges/Win32-OpenGL1/graphics_bridge.cpp
g++ -I../Additional/i686-w64-mingw32/include -IPlatforms/Win32/Info -IGraphics_Systems/OpenGL1/Info -IAudio_Systems/OpenAL/Info -ICollision_Systems/Precise/Info -IWidget_Systems/Win32/Info -INetworking_Systems/None/Info -IUniversal_System/Info -I. -IC:/ProgramData/ENIGMA/ -Wall -s -O3 -flto -fno-exceptions -fdata-sections -ffunction-sections  -MMD -MP -c -o C:/ProgramData/ENIGMA/.eobjs/Windows/Windows/Compile/Platforms/Win32/WINDOWSthreads.o Platforms/Win32/WINDOWSthreads.cpp
g++ -I../Additional/i686-w64-mingw32/include -IPlatforms/Win32/Info -IGraphics_Systems/OpenGL1/Info -IAudio_Systems/OpenAL/Info -ICollision_Systems/Precise/Info -IWidget_Systems/Win32/Info -INetworking_Systems/None/Info -IUniversal_System/Info -I. -IC:/ProgramData/ENIGMA/ -Wall -s -O3 -flto -fno-exceptions -fdata-sections -ffunction-sections  -MMD -MP -c -o C:/ProgramData/ENIGMA/.eobjs/Windows/Windows/Compile/Platforms/Win32/WINDOWSmain.o Platforms/Win32/WINDOWSmain.cpp
Platforms/Win32/WINDOWSmain.cpp: In function 'int WinMain(HINSTANCE, HINSTANCE, LPSTR, int)':
Platforms/Win32/WINDOWSmain.cpp:218:25: warning: unused variable 'wmain' [-Wunused-variable]
     WNDCLASS wcontainer,wmain;
                         ^
g++ -I../Additional/i686-w64-mingw32/include -IPlatforms/Win32/Info -IGraphics_Systems/OpenGL1/Info -IAudio_Systems/OpenAL/Info -ICollision_Systems/Precise/Info -IWidget_Systems/Win32/Info -INetworking_Systems/None/Info -IUniversal_System/Info -I. -IC:/ProgramData/ENIGMA/ -Wall -s -O3 -flto -fno-exceptions -fdata-sections -ffunction-sections  -MMD -MP -c -o C:/ProgramData/ENIGMA/.eobjs/Windows/Windows/Compile/Platforms/Win32/WINDOWSjoystick.o Platforms/Win32/WINDOWSjoystick.cpp
g++ -I../Additional/i686-w64-mingw32/include -IPlatforms/Win32/Info -IGraphics_Systems/OpenGL1/Info -IAudio_Systems/OpenAL/Info -ICollision_Systems/Precise/Info -IWidget_Systems/Win32/Info -INetworking_Systems/None/Info -IUniversal_System/Info -I. -IC:/ProgramData/ENIGMA/ -Wall -s -O3 -flto -fno-exceptions -fdata-sections -ffunction-sections  -MMD -MP -c -o C:/ProgramData/ENIGMA/.eobjs/Windows/Windows/Compile/SHELLmain.o SHELLmain.cpp
mingw32-make.exe[1]: Leaving directory `D:/Users/Jason/Downloads/ENIGMA/enigma-dev/ENIGMAsystem/SHELL'
mingw32-make.exe[1]: Entering directory `D:/Users/Jason/Downloads/ENIGMA/enigma-dev/ENIGMAsystem/SHELL'
mkdir.exe -p C:/ProgramData/ENIGMA/.eobjs/Windows/Windows/Compile/
mkdir.exe -p C:/ProgramData/ENIGMA/.eobjs/Windows/Windows/Compile/Audio_Systems/OpenAL/
mkdir.exe -p C:/ProgramData/ENIGMA/.eobjs/Windows/Windows/Compile/Bridges/Win32-OpenGL1/
mkdir.exe -p C:/ProgramData/ENIGMA/.eobjs/Windows/Windows/Compile/Collision_Systems/Precise/
mkdir.exe -p C:/ProgramData/ENIGMA/.eobjs/Windows/Windows/Compile/Graphics_Systems/General/
mkdir.exe -p C:/ProgramData/ENIGMA/.eobjs/Windows/Windows/Compile/Graphics_Systems/OpenGL1/
mkdir.exe -p C:/ProgramData/ENIGMA/.eobjs/Windows/Windows/Compile/Platforms/Win32/
mkdir.exe -p C:/ProgramData/ENIGMA/.eobjs/Windows/Windows/Compile/Universal_System/
mkdir.exe -p C:/ProgramData/ENIGMA/.eobjs/Windows/Windows/Compile/Universal_System/Extensions/Alarms/
mkdir.exe -p C:/ProgramData/ENIGMA/.eobjs/Windows/Windows/Compile/Universal_System/Extensions/DataStructures/
mkdir.exe -p C:/ProgramData/ENIGMA/.eobjs/Windows/Windows/Compile/Universal_System/Extensions/DateTime/
mkdir.exe -p C:/ProgramData/ENIGMA/.eobjs/Windows/Windows/Compile/Universal_System/Extensions/MotionPlanning/
mkdir.exe -p C:/ProgramData/ENIGMA/.eobjs/Windows/Windows/Compile/Universal_System/Extensions/ParticleSystems/
mkdir.exe -p C:/ProgramData/ENIGMA/.eobjs/Windows/Windows/Compile/Universal_System/Extensions/Paths/
mkdir.exe -p C:/ProgramData/ENIGMA/.eobjs/Windows/Windows/Compile/Universal_System/Extensions/Timelines/
mkdir.exe -p C:/ProgramData/ENIGMA/.eobjs/Windows/Windows/Compile/Widget_Systems/Win32/
echo "// GENERATED RESOURCE FILE FRONTEND" > C:/ProgramData/ENIGMA/.eobjs/Windows/Windows/Compile/resources.rc
for res in Preprocessor_Environment_Editable/Resources.rc Widget_Systems/Win32/getstring.rc Widget_Systems/Win32/getlogin.rc Widget_Systems/Win32/showinfo.rc Widget_Systems/Win32/showmessageext.rc; do echo "#include \"$res\"" >> C:/ProgramData/ENIGMA/.eobjs/Windows/Windows/Compile/resources.rc; done
windres.exe -o C:/ProgramData/ENIGMA/.eobjs/Windows/Windows/Compile/resources.res -I. -IC:/ProgramData/ENIGMA/ C:/ProgramData/ENIGMA/.eobjs/Windows/Windows/Compile/resources.rc -O coff
xtensions/ParticleSystems/PS_particle_system.o C:/ProgramData/ENIGMA/.eobjs/Windows/Windows/Compile/Universal_System/Extensions/DataStructures/data_structures.o C:/ProgramData/ENIGMA/.eobjs/Windows/Windows/Compile/Bridges/Win32-OpenGL1/graphics_bridge.o C:/ProgramData/ENIGMA/.eobjs/Windows/Windows/Compile/resources.res -lffi -lcomdlg32 -lgdi32 -lwinmm -lwininet -lopengl32 -lglu32 -lALURE32-static -lOpenAL32 -lvorbisfile -lvorbis -logg -lFLAC -lsndfile -lmodplug -lmpg123 -lole32 -lwinmm -lcomctl32 -luuid -lole32 -lz
windres.exe: warning: 24: 1: 1033: duplicate value
windres.exe: warning: 24: 1: 1033: duplicate value
windres.exe: warning: 24: 1: 1033: duplicate value
g++ -flto -s -O3 -L../Additional/i686-w64-mingw32/lib -static-libgcc -static-libstdc++ -static-libgcc -Wl,-subsystem,windows -o "D:/Users/Jason/Desktop/_aaa.exe"

[snipped to fit the max forum post size]

C:/ProgramData/ENIGMA/.eobjs/Windows/Windows/Compile/Bridges/Win32-OpenGL1/graphics_bridge.o C:/ProgramData/ENIGMA/.eobjs/Windows/Windows/Compile/resources.res -lffi -lcomdlg32 -lgdi32 -lwinmm -lwininet -lopengl32 -lglu32 -lALURE32-static -lOpenAL32 -lvorbisfile -lvorbis -logg -lFLAC -lsndfile -lmodplug -lmpg123 -lole32 -lwinmm -lcomctl32 -luuid -lole32 -lz
Universal_System/instance_system.cpp:185:14: warning: type of 'object_idmax' does not match original declaration [enabled by default]
   extern int object_idmax;
              ^
C:/ProgramData/ENIGMA/Preprocessor_Environment_Editable/IDE_EDIT_resourcenames.h:37:27: note: previously declared here
 namespace enigma { size_t object_idmax = 1; }
                           ^
Universal_System/resource_data.cpp:36:14: warning: type of 'script_idmax' does not match original declaration [enabled by default]
   extern int script_idmax;
              ^
C:/ProgramData/ENIGMA/Preprocessor_Environment_Editable/IDE_EDIT_resourcenames.h:117:27: note: previously declared here
 namespace enigma { size_t script_idmax = 0; }
                           ^
Universal_System/roomsystem.cpp:214:14: warning: type of 'room_idmax' does not match original declaration [enabled by default]
   extern int room_idmax;
              ^
C:/ProgramData/ENIGMA/Preprocessor_Environment_Editable/IDE_EDIT_resourcenames.h:140:27: note: previously declared here
 namespace enigma { size_t room_idmax = 1; }
                           ^
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()'
collect2.exe: error: ld returned 1 exit status
mingw32-make.exe[1]: *** [compile_game] Error 1
mingw32-make.exe[1]: Leaving directory `D:/Users/Jason/Downloads/ENIGMA/enigma-dev/ENIGMAsystem/SHELL'
mingw32-make.exe: *** [Game] Error 2
Universal_System/instance_system.cpp:185:14: warning: type of 'object_idmax' does not match original declaration [enabled by default]
   extern int object_idmax;
              ^
C:/ProgramData/ENIGMA/Preprocessor_Environment_Editable/IDE_EDIT_resourcenames.h:37:27: note: previously declared here
 namespace enigma { size_t object_idmax = 1; }
                           ^
Universal_System/resource_data.cpp:36:14: warning: type of 'script_idmax' does not match original declaration [enabled by default]
   extern int script_idmax;
              ^
C:/ProgramData/ENIGMA/Preprocessor_Environment_Editable/IDE_EDIT_resourcenames.h:117:27: note: previously declared here
 namespace enigma { size_t script_idmax = 0; }
                           ^
Universal_System/roomsystem.cpp:214:14: warning: type of 'room_idmax' does not match original declaration [enabled by default]
   extern int room_idmax;
              ^
C:/ProgramData/ENIGMA/Preprocessor_Environment_Editable/IDE_EDIT_resourcenames.h:140:27: note: previously declared here
 namespace enigma { size_t room_idmax = 1; }
                           ^
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()'
collect2.exe: error: ld returned 1 exit status
mingw32-make.exe[1]: *** [compile_game] Error 1
mingw32-make.exe[1]: Leaving directory `D:/Users/Jason/Downloads/ENIGMA/enigma-dev/ENIGMAsystem/SHELL'
mingw32-make.exe: *** [Game] Error 2

Hopefully you guys can make sense of this. MinGW compiler messages are not my srtong point.
Logged
Pages: « 1 2 3 4 »
  Print