Re: Orx Wrapper Hurdles

new topic     » goto parent     » topic index » view thread      » older message » newer message
Icy_Viking said...

Hi Greg, thanks for the input. This is where the problem lies. I'm not sure how to translate the inline functions into Eu code. I have vague ideas, but I'm really stuck as to where to go from there.

Here's a quick conversion of 01_Object.c.

include "orx.e" 
/** Inits the tutorial */ 
function Init() 
    /* Displays a small hint in console */ 
    orxLOG("\n* This tutorial creates a viewport/camera couple and an object" 
         & "\n* You can play with the config parameters in ../01_Object.ini" 
         & "\n* After changing them, relaunch the tutorial to see their effects") 
    /* Creates viewport */ 
    /* Creates object */ 
    /* Done! */ 
    return orxSTATUS_SUCCESS 
end function 
/** Run function */ 
function Run() 
    integer eResult = orxSTATUS_SUCCESS 
    /* Should quit? */ 
    if orxInput_IsActive("Quit") then 
        /* Updates result */ 
        eResult = orxSTATUS_FAILURE 
    end if 
    /* Done! */ 
    return eResult 
end function 
/** Exit function */ 
function Exit() 
    /* We're a bit lazy here so we let orx clean all our mess! :) */ 
    return 0 
end function 
/** Main function */ 
procedure main() 
    sequence argv = command_line() 
    integer argc = length(argv) 
    /* Executes a new instance of tutorial */ 
    orx_Execute(argc, argv, "Init", "Run", "Exit") 
end procedure 

Most of this hinges on orx_Execute which is of course inline, so here's how I'd (roughly) convert it:

/** Should stop execution by default event handling? */ 
integer sbStopByEvent = orxFALSE 
/** Orx main execution function 

 * @param[in]   _u32NbParams                  Main function parameters number (argc) 
 * @param[in]   _azParams                     Main function parameter list (argv) 
 * @param[in]   _pfnInit                      Main init function (should init all the main stuff and register the main event handler to override the default one) 
 * @param[in]   _pfnRun                       Main run function (will be called once per frame, should return orxSTATUS_SUCCESS to continue processing) 
 * @param[in]   _pfnExit                      Main exit function (should clean all the main stuff) 
public procedure orx_Execute(atom _u32NbParams, sequence _azParams, sequence _zInit, sequence _zRun, sequence _zExit, integer _fnInit=routine_id(_zInit), integer _fnRun=routine_id(_zRun), integer _fnExit=routine_id(_zExit)) 
    /* Inits the Debug System */ 
    /* Checks */ 
    orxASSERT(_u32NbParams > 0) 
    orxASSERT(_azParams != orxNULL) 
    orxASSERT(_fnRun != orxNULL) 
    /* Registers main module */ 
    orxModule_Register(orxMODULE_ID_MAIN, "MAIN", routine_id("orx_MainSetup"), _fnInit, _fnExit) 
    /* Sends the command line arguments to orxParam module */ 
    if orxParam_SetArgs(_u32NbParams, _azParams) != orxSTATUS_FAILURE then 
        /* Inits the engine */ 
        if orxModule_Init(orxMODULE_ID_MAIN) != orxSTATUS_FAILURE then 
            atom stPayload = allocate_data( SIZEOF_ORXSYSTEM_EVENT_PAYLOAD ) 
            integer eClockStatus, eMainStatus 
            integer bStop = orxFALSE 
            atom u32FrameCount 
            /* Registers default event handler */ 
            orxEvent_AddHandler(orxEVENT_TYPE_SYSTEM, orx_DefaultEventHandler) 
            orxEvent_SetHandlerIDFlags(orx_DefaultEventHandler, orxEVENT_TYPE_SYSTEM, orxNULL, orxEVENT_GET_FLAG(orxSYSTEM_EVENT_CLOSE), orxEVENT_KU32_MASK_ID_ALL) 
            /* Clears payload */ 
            orxMemory_Zero(stPayload, SIZEOF_ORXSYSTEM_EVENT_PAYLOAD) 
            /* Main loop */ 
            while bStop = orxFALSE do 
                /* Sends frame start event */ 
                orxEVENT_SEND(orxEVENT_TYPE_SYSTEM, orxSYSTEM_EVENT_GAME_LOOP_START, orxNULL, orxNULL, stPayload) 
                /* Runs game specific code */ 
                eMainStatus = call_func( _fnRun, {} ) 
                /* Updates clock system */ 
                eClockStatus = orxClock_Update() 
                /* Sends frame stop event */ 
                orxEVENT_SEND(orxEVENT_TYPE_SYSTEM, orxSYSTEM_EVENT_GAME_LOOP_STOP, orxNULL, orxNULL, stPayload) 
                /* Updates frame count */ 
                u32FrameCount = peek4u( stPayload + orxSYSTEM_EVENT_PAYLOAD_u32FrameCount ) 
                poke4( stPayload + orxSYSTEM_EVENT_PAYLOAD_u32FrameCount, u32FrameCount + 1 ) 
                bStop = ((sbStopByEvent != orxFALSE) or (eMainStatus = orxSTATUS_FAILURE) or (eClockStatus = orxSTATUS_FAILURE)) 
            end while 
            /* Removes event handler */ 
            orxEvent_RemoveHandler(orxEVENT_TYPE_SYSTEM, orx_DefaultEventHandler) 
            /* Exits from the engine */ 
            free( stPayload ) 
        end if 
    end if 
    /* Exits from the Debug system */ 
end procedure 


new topic     » goto parent     » topic index » view thread      » older message » newer message


Quick Links

User menu

Not signed in.

Misc Menu