Load 3d library in monkey 2

About Monkey 2 Forums Monkey 2 Programming Help Load 3d library in monkey 2

This topic contains 15 replies, has 3 voices, and was last updated by  Yue 4 weeks, 1 day ago.

Viewing 15 posts - 1 through 15 (of 16 total)

  • Author

    Posts

  • #16028


    Yue

    Participant

    Hello, What is the equivalent in Monkey 2 to do the following that I do in BlitzMax?

    BlitzMax

    Monkey 2?

    #16029


    scurty

    Participant

    That’s actually a very good question, not sure how this would be done in Monkey2. I think you would need to make a Monkey2 module that wraps Gear3D as of now. Any other comments?

    #16030


    Danilo

    Participant

    First you need to import “<win32>”, that imports the file /modules/win32/win32.monkey2

    LoadLibrary and GetProcAddress are not imported yet, so you need to add it. LoadLibraryA uses ASCII chars, so better use LoadLibraryW for wide chars (Unicode).

    If LoadLibrary() and GetProcAddress() get added to the win32 import, you could remove the ‘Extern’ section.

    Of course untested, but that’s the general way how it would work with dynamic loading of DLL functions at runtime.
    If you have a DLL import file (.lib), you could directly import it. If the DLL uses ASCII strings, a conversion from Unicode to ASCII would be required for the strings.

    If you have a Unicode version of the .dll you would use this.

    #16033


    Yue

    Participant

    It’s not working. Some expert, if you want I can compile a simple library that returns a number for a simple test.

    ?

    #16038


    Danilo

    Participant

    Shouldn’t be a problem. ? Please give download links for test lib and latest gear3d.

    #16040


    Yue

    Participant

    Ok, ?

    Here download.

    Gear3D.dll
    Link.dll

    Load Gear3d.dll
    Functions on lib.

    “_InitG3D” ( 2 variables, height, widht secreen)
    “_SetAppTitle” ( 1 variable string App Title)
    “_RenderStage” ( Not Variables)
    “_FlipStage”)  ( Not Variables )

    Thanks You. ?

    #16041


    Danilo

    Participant

    • Is Gear3D compiled for 32bit or 64bit?
    • Ascii or Unicode?
    • What type are the function parameters?

      • InitG3D( Byte, Byte )
      • InitG3D( Word, Word )
      • InitG3D( Int, Int ) ?

    #16042


    Yue

    Participant

    I’ve made it work in BlitzMax NG, but I can’t in Monkey 2, because everything is more confusing and I don’t consider myself a programmer.

    InitG3D(int,int)
    for 32 bits.
    Ascii or Unicode.

    #16043


    Yue

    Participant

    Here result.

    #16044


    Danilo

    Participant

    That GetProcAddress() method brings up some casting issues,

    so it is probably easier to import a “Gear3D.lib” (DLL import).

     

    I made a quick test using LoadLibrary and GetProcAddress in a C++ file. File is attached.

    Compile it and put Gear3D.dll and Link.dll in Gear3D.products/Windows/ folder, so Gear3D.exe can find the DLLs.

    Attachments:
    1. Gear3D.zip

    #16046


    Yue

    Participant

    In monkey 2 everything is very different, but I can’t make it work.  I wonder what the downside will be.

     

    #16047


    Yue

    Participant

    Ok, this already works, when translating my lack of attention I haven’t noticed where to put the libraries correctly.

    So I already have something to investigate, by the way I did not know how to stop the application, so it touched me to close moneky 2, and when I return from work I give it a deep look. Now I have some motivation to investigate with Monkey 2.

    Thank you very much.

     

    #16048


    Danilo

    Participant

    by the way I did not know how to stop the application

     

    I put a counter 0 to 1001 in the code, otherwise it would Repeat..Forever.
    The window title counts to 1001 and quits.

    #16049


    Yue

    Participant

    No, at the moment there is no way out of the application, I only have those functions, I regret the drawbacks, in blitzmax ng the output is through the interfaces of the code writing ide.

    If I can make this work I’m going to put more commands to the library and possibly be another alternative especially for BlitzMax NG and why not, for Monkey2.

    One question that I still have to answer is that these are casting errors? When I was compiling in BlitzMax and switching to BlitzMax NG, I had some strange problems, so I have to modify certain points when exporting the library for NG. In such a case if that is corrected, is it possible to load the library in Monkey 2 without creating .h and C files?

    Translated with http://www.DeepL.com/Translator

    #16054


    Danilo

    Participant

    > is it possible to load the library in Monkey 2 without creating .h and C files?

    Monkey2 is a little bit different because it translates to C++.
    When you import something, you need to tell Monkey2 and the C++ compiler about that stuff.
    If you don’t tell Monkey2, it does not know the functions.
    If you don’t tell C++, it does not know the functions and you will get an error.

    So you need at least the Monkey2 ‘Extern’ import section and the C/C++ header with the functions/classes.

Viewing 15 posts - 1 through 15 (of 16 total)

You must be logged in to reply to this topic.