예제 #1
0
파일: 11_Spawner.c 프로젝트: gfphoenix/orx
/** Loads configuration
 */
static orxINLINE orxSTATUS LoadConfig()
{
  orxVIEWPORT  *pstViewport;
  orxSTATUS     eResult = orxSTATUS_FAILURE;

  /* Deletes our scene */
  if(pstScene)
  {
    orxObject_Delete(pstScene);
    pstScene = orxNULL;
  }

  /* For all the viewports */
  while((pstViewport = orxVIEWPORT(orxStructure_GetFirst(orxSTRUCTURE_ID_VIEWPORT))) != orxNULL)
  {
    /* Deletes it */
    orxViewport_Delete(pstViewport);
  }

  /* Clears all config data */
  orxConfig_Clear();

  /* Loads main config and selects tutorial section */
  orxConfig_Load(orxConfig_GetMainFileName());
  orxConfig_SelectSection("Tutorial");

  /* Is current ID valid? */
  if(ss32ConfigID < orxConfig_GetListCounter("ConfigList"))
  {
    const orxSTRING zConfigFile;

    /* Gets config file */
    zConfigFile = orxConfig_GetListString("ConfigList", ss32ConfigID);

    /* Can load it? */
    if((eResult = orxConfig_Load(zConfigFile)) != orxSTATUS_FAILURE)
    {
      orxS32 i;

      /* Pushes tutorial section */
      orxConfig_PushSection("Tutorial");

      /* For all defined viewports */
      for(i = 0; i < orxConfig_GetListCounter("ViewportList"); i++)
      {
        /* Creates it */
        orxViewport_CreateFromConfig(orxConfig_GetListString("ViewportList", i));
      }

      /* Creates our scene */
      pstScene = orxObject_CreateFromConfig("Scene");
    }
  }

  /* Done! */
  return eResult;
}
orxSTATUS orxFASTCALL Init()
{
  viewport = orxViewport_CreateFromConfig("Viewport");
  orxObject_CreateFromConfig("TextObject");

  // Create the light bulb
  light_bulb = orxObject_CreateFromConfig("LightBulb");

  // Register our shader parameter handler
  orxEvent_AddHandler ( orxEVENT_TYPE_SHADER, lightPosHandler);
  return orxSTATUS_SUCCESS;
}
예제 #3
0
파일: orxTest.c 프로젝트: iar-wain/orx-test
static orxSTATUS orxFASTCALL Init()
{
  /* Creates viewport */
  spstViewport = orxViewport_CreateFromConfig("Viewport");

  /* Creates generator */
  spstGenerator = orxObject_CreateFromConfig("Generator");

  /* Creates texture table */
  pstTextureTable = orxHashTable_Create(16, orxHASHTABLE_KU32_FLAG_NONE, orxMEMORY_TYPE_MAIN);

  /* Creates walls */
  orxObject_CreateFromConfig("Walls");

  /* Registers event handler */
  orxEvent_AddHandler(orxEVENT_TYPE_PHYSICS, EventHandler);

  /* Done! */
  return (spstViewport && spstGenerator) ? orxSTATUS_SUCCESS : orxSTATUS_FAILURE;
}
예제 #4
0
파일: 05_Viewport.c 프로젝트: orx/orx
/** Inits the tutorial
 */
orxSTATUS orxFASTCALL Init()
{
  orxCLOCK       *pstClock;
  orxINPUT_TYPE   eType;
  orxENUM         eID;
  orxINPUT_MODE   eMode;
  const orxSTRING zInputCameraLeft;
  const orxSTRING zInputCameraRight;
  const orxSTRING zInputCameraUp;
  const orxSTRING zInputCameraDown;
  const orxSTRING zInputCameraRotateLeft;
  const orxSTRING zInputCameraRotateRight;
  const orxSTRING zInputCameraZoomIn;
  const orxSTRING zInputCameraZoomOut;
  const orxSTRING zInputViewportLeft;
  const orxSTRING zInputViewportRight;
  const orxSTRING zInputViewportUp;
  const orxSTRING zInputViewportDown;
  const orxSTRING zInputViewportScaleUp;
  const orxSTRING zInputViewportScaleDown;

  /* Gets input binding names */
  orxInput_GetBinding("CameraLeft", 0, &eType, &eID, &eMode);
  zInputCameraLeft = orxInput_GetBindingName(eType, eID, eMode);

  orxInput_GetBinding("CameraRight", 0, &eType, &eID, &eMode);
  zInputCameraRight = orxInput_GetBindingName(eType, eID, eMode);

  orxInput_GetBinding("CameraUp", 0, &eType, &eID, &eMode);
  zInputCameraUp = orxInput_GetBindingName(eType, eID, eMode);

  orxInput_GetBinding("CameraDown", 0, &eType, &eID, &eMode);
  zInputCameraDown = orxInput_GetBindingName(eType, eID, eMode);

  orxInput_GetBinding("CameraRotateLeft", 0, &eType, &eID, &eMode);
  zInputCameraRotateLeft = orxInput_GetBindingName(eType, eID, eMode);

  orxInput_GetBinding("CameraRotateRight", 0, &eType, &eID, &eMode);
  zInputCameraRotateRight = orxInput_GetBindingName(eType, eID, eMode);

  orxInput_GetBinding("CameraZoomIn", 0, &eType, &eID, &eMode);
  zInputCameraZoomIn = orxInput_GetBindingName(eType, eID, eMode);

  orxInput_GetBinding("CameraZoomOut", 0, &eType, &eID, &eMode);
  zInputCameraZoomOut = orxInput_GetBindingName(eType, eID, eMode);

  orxInput_GetBinding("ViewportLeft", 0, &eType, &eID, &eMode);
  zInputViewportLeft = orxInput_GetBindingName(eType, eID, eMode);

  orxInput_GetBinding("ViewportRight", 0, &eType, &eID, &eMode);
  zInputViewportRight = orxInput_GetBindingName(eType, eID, eMode);

  orxInput_GetBinding("ViewportUp", 0, &eType, &eID, &eMode);
  zInputViewportUp = orxInput_GetBindingName(eType, eID, eMode);

  orxInput_GetBinding("ViewportDown", 0, &eType, &eID, &eMode);
  zInputViewportDown = orxInput_GetBindingName(eType, eID, eMode);

  orxInput_GetBinding("ViewportScaleUp", 0, &eType, &eID, &eMode);
  zInputViewportScaleUp = orxInput_GetBindingName(eType, eID, eMode);

  orxInput_GetBinding("ViewportScaleDown", 0, &eType, &eID, &eMode);
  zInputViewportScaleDown = orxInput_GetBindingName(eType, eID, eMode);

  /* Displays a small hint in console */
  orxLOG("\n* Worskpaces 1 & 4 display camera 1 content"
         "\n* Workspace 2 displays camera 2 (by default it's twice as close as the other cameras)"
         "\n* Workspace 3 displays camera 3"
         "\n- Soldier will be positioned (in the world) so as to be always displayed under the mouse"
         "\n- '%s', '%s', '%s' & '%s' control camera 1 positioning"
         "\n- '%s' & '%s' control camera 1 rotation"
         "\n- '%s' & '%s' control camera 1 zoom"
         "\n- '%s', '%s', '%s' & '%s' control viewport 1 positioning"
         "\n- '%s' & '%s' control viewport 1 size",
         zInputCameraUp, zInputCameraLeft, zInputCameraDown, zInputCameraRight,
         zInputCameraRotateLeft, zInputCameraRotateRight,
         zInputCameraZoomIn, zInputCameraZoomOut,
         zInputViewportUp, zInputViewportLeft, zInputViewportDown, zInputViewportRight,
         zInputViewportScaleUp, zInputViewportScaleDown);

  /* Creates all viewports */
  orxViewport_CreateFromConfig("Viewport4");
  orxViewport_CreateFromConfig("Viewport3");
  orxViewport_CreateFromConfig("Viewport2");
  pstViewport = orxViewport_CreateFromConfig("Viewport1");

  /* Creates objects */
  orxObject_CreateFromConfig("Box");
  pstSoldier = orxObject_CreateFromConfig("Soldier");

  /* Gets the main clock */
  pstClock = orxClock_FindFirst(orx2F(-1.0f), orxCLOCK_TYPE_CORE);

  /* Registers our update callback */
  orxClock_Register(pstClock, Update, orxNULL, orxMODULE_ID_MAIN, orxCLOCK_PRIORITY_NORMAL);

  /* Done! */
  return orxSTATUS_SUCCESS;
}
예제 #5
0
파일: orxBounce.c 프로젝트: enobayram/orx
/** Inits the bounce demo
 */
static orxSTATUS orxBounce_Init()
{
  orxU32    i;
  orxSTATUS eResult;

  /* Loads config file and selects its section */
  orxConfig_Load("Bounce.ini");
  orxConfig_SelectSection("Bounce");

  /* Loads input */
  orxInput_Load(orxNULL);

  /* Creates ball spawner */
  spoBallSpawner = orxSpawner_CreateFromConfig("BallSpawner");

  /* Valid? */
  if(spoBallSpawner != orxNULL)
  {
    orxOBJECT  *pstParticleSource;
    orxCLOCK   *pstClock;

    /* Creates particle source */
    pstParticleSource = orxObject_CreateFromConfig("ParticleSource");

    /* Valid? */
    if(pstParticleSource != orxNULL)
    {
      /* Sets its parent */
      orxObject_SetParent(pstParticleSource, spoBallSpawner);
    }

    /* Updates cursor */
    orxMouse_ShowCursor(orxConfig_GetBool("ShowCursor"));

    /* Creates walls */
    spstWalls = orxObject_CreateFromConfig("Walls");

    /* Inits trail */
    for(i = 0; i < TRAIL_POINT_NUMBER; i++)
    {
      orxMouse_GetPosition(&savTrailPointList[i]);
    }

    /* Creates all viewports */
    for(i = 0; i < (orxU32)orxConfig_GetListCounter("ViewportList"); i++)
    {
      orxViewport_CreateFromConfig(orxConfig_GetListString("ViewportList", i));
    }

    /* Gets rendering clock */
    pstClock = orxClock_FindFirst(orx2F(-1.0f), orxCLOCK_TYPE_CORE);

    /* Registers callback */
    eResult = orxClock_Register(pstClock, &orxBounce_Update, orxNULL, orxMODULE_ID_MAIN, orxCLOCK_PRIORITY_NORMAL);

    /* Registers update trail timer */
    eResult = ((eResult != orxSTATUS_FAILURE) && (orxClock_Register(pstClock, &orxBounce_UpdateTrail, orxNULL, orxMODULE_ID_MAIN, orxCLOCK_PRIORITY_LOW) != orxSTATUS_FAILURE)) ? orxSTATUS_SUCCESS : orxSTATUS_FAILURE;

    /* Registers event handler */
    eResult = ((eResult != orxSTATUS_FAILURE) && (orxEvent_AddHandler(orxEVENT_TYPE_PHYSICS, orxBounce_EventHandler) != orxSTATUS_FAILURE)) ? orxSTATUS_SUCCESS : orxSTATUS_FAILURE;
    eResult = ((eResult != orxSTATUS_FAILURE) && (orxEvent_AddHandler(orxEVENT_TYPE_INPUT, orxBounce_EventHandler) != orxSTATUS_FAILURE)) ? orxSTATUS_SUCCESS : orxSTATUS_FAILURE;
    eResult = ((eResult != orxSTATUS_FAILURE) && (orxEvent_AddHandler(orxEVENT_TYPE_SHADER, orxBounce_EventHandler) != orxSTATUS_FAILURE)) ? orxSTATUS_SUCCESS : orxSTATUS_FAILURE;
    eResult = ((eResult != orxSTATUS_FAILURE) && (orxEvent_AddHandler(orxEVENT_TYPE_SOUND, orxBounce_EventHandler) != orxSTATUS_FAILURE)) ? orxSTATUS_SUCCESS : orxSTATUS_FAILURE;
    eResult = ((eResult != orxSTATUS_FAILURE) && (orxEvent_AddHandler(orxEVENT_TYPE_DISPLAY, orxBounce_EventHandler) != orxSTATUS_FAILURE)) ? orxSTATUS_SUCCESS : orxSTATUS_FAILURE;
    eResult = ((eResult != orxSTATUS_FAILURE) && (orxEvent_AddHandler(orxEVENT_TYPE_TIMELINE, orxBounce_EventHandler) != orxSTATUS_FAILURE)) ? orxSTATUS_SUCCESS : orxSTATUS_FAILURE;
    eResult = ((eResult != orxSTATUS_FAILURE) && (orxEvent_AddHandler(orxEVENT_TYPE_RENDER, orxBounce_EventHandler) != orxSTATUS_FAILURE)) ? orxSTATUS_SUCCESS : orxSTATUS_FAILURE;
  }
  else
  {
    /* Failure */
    eResult = orxSTATUS_FAILURE;
  }

  /* Done! */
  return eResult;
}