Example #1
0
static orxSTATUS orxFASTCALL ProcessFontParams(orxU32 _u32ParamCount, const orxSTRING _azParams[])
{
  orxSTATUS eResult = orxSTATUS_FAILURE;

  // Has a valid font parameter?
  if(_u32ParamCount > 1)
  {
    // Inits FreeType
    if(!FT_Init_FreeType(&sstFontGen.pstFontLibrary))
    {
      // Loads font's default face
      if(!FT_New_Face(sstFontGen.pstFontLibrary, _azParams[1], 0, &sstFontGen.pstFontFace))
      {
        // Sets unicode map
        if(!FT_Select_Charmap(sstFontGen.pstFontFace, ft_encoding_unicode))
        {
          // Updates character size
          sstFontGen.vCharacterSize.fX = sstFontGen.vCharacterSize.fY;

          // Updates character spacing
          sstFontGen.vCharacterSpacing.fX = orx2F(2.0f);
          sstFontGen.vCharacterSpacing.fY = orx2F(2.0f);

          // Stores scale
          sstFontGen.fFontScale = sstFontGen.vCharacterSize.fY / orxS2F(sstFontGen.pstFontFace->bbox.yMax - sstFontGen.pstFontFace->bbox.yMin);

          // Sets pixel's size
          eResult = FT_Set_Pixel_Sizes(sstFontGen.pstFontFace, (FT_UInt)orxF2U(sstFontGen.vCharacterSize.fX) - 2, (FT_UInt)orxF2U(sstFontGen.vCharacterSize.fY) - 2) ? orxSTATUS_FAILURE : orxSTATUS_SUCCESS;
        }
      }
    }

    // Success?
    if(eResult != orxSTATUS_FAILURE)
    {
      // Updates status
      orxFLAG_SET(sstFontGen.u32Flags, orxFONTGEN_KU32_STATIC_FLAG_FONT, orxFONTGEN_KU32_STATIC_FLAG_NONE);

      // Logs message
      orxFONTGEN_LOG(FONT, "Using font '%s'.", _azParams[1]);
    }
    else
    {
      // Logs message
      orxFONTGEN_LOG(FONT, "Couldn't load font '%s'.", _azParams[1]);
    }
  }
  else
  {
    // Logs message
    orxFONTGEN_LOG(FONT, "No font specified, aborting.");
  }

  // Done!
  return eResult;
}
Example #2
0
/** Gets a random orxU32 value
 * @param[in]   _u32Min                         Minimum boundary
 * @param[in]   _u32Max                         Maximum boundary
 * @return      Random value
 */
orxU32 orxFASTCALL orxMath_GetRandomU32(orxU32 _u32Min, orxU32 _u32Max)
{
  orxU32 u32Rand;

  /* Gets raw random number */
  u32Rand = rand();

  /* Done! */
  return (u32Rand == RAND_MAX) ? _u32Max : (orxF2U((orx2F(u32Rand) * (orx2F(1.0f / RAND_MAX)) * (orxU2F(_u32Max) + 1 - orxU2F(_u32Min))) + orxS2F(_u32Min)));
}
Example #3
0
File: orxSystem.c Project: orx/orx
/** Delay the program for given number of seconds
 * @param[in] _fSeconds             Number of seconds to wait
 */
void orxFASTCALL orxSystem_Delay(orxFLOAT _fSeconds)
{
  /* Checks */
  orxASSERT((sstSystem.u32Flags & orxSYSTEM_KU32_STATIC_FLAG_READY) == orxSYSTEM_KU32_STATIC_FLAG_READY);
  orxASSERT(_fSeconds >= orxFLOAT_0);

#ifdef __orxWINDOWS__

  /* Sleeps */
  Sleep(orxF2U(_fSeconds * orx2F(1000.0f)));

#else /* __orxWINDOWS__ */

  /* Sleeps */
  usleep(orxF2U(_fSeconds * orx2F(1000000.0f)));

#endif /* __orxWINDOWS__ */

  /* Done! */
  return;
}