Beispiel #1
0
/** Loads a plugin using OS common library extension + release/debug suffixes
 * @param[in] _zPluginFileName  The complete path of the plugin file, without its library extension
 * @param[in] _zPluginName      The name that the plugin will be given in the plugin list
 * @return The plugin handle on success, orxHANDLE_UNDEFINED on failure
 */
orxHANDLE orxFASTCALL orxPlugin_LoadUsingExt(const orxSTRING _zPluginFileName, const orxSTRING _zPluginName)
{
  orxHANDLE hResult = orxHANDLE_UNDEFINED;

#ifdef __orxPLUGIN_DYNAMIC__

  orxCHAR zFileName[256];

#ifdef __orxDEBUG__

  orxSTRING zDebugSuffix;

  /* Pushes section */
  orxConfig_PushSection(orxPLUGIN_KZ_CONFIG_SECTION);

#endif /* __ orxDEBUG__ */

  /* Checks */
  orxASSERT(sstPlugin.u32Flags & orxPLUGIN_KU32_STATIC_FLAG_READY);
  orxASSERT(_zPluginFileName != orxNULL);
  orxASSERT(orxString_GetLength(_zPluginFileName) + orxMAX(orxString_GetLength(orxConfig_GetString(orxPLUGIN_KZ_CONFIG_DEBUG_SUFFIX)), orxString_GetLength(orxPLUGIN_KZ_DEFAULT_DEBUG_SUFFIX)) < 252);
  orxASSERT(_zPluginName != orxNULL);

  /* Inits buffer */
  zFileName[sizeof(zFileName) - 1] = orxCHAR_NULL;

#ifdef __orxDEBUG__

  /* Gets debug suffix */
  zDebugSuffix = (orxSTRING)((orxConfig_HasValue(orxPLUGIN_KZ_CONFIG_DEBUG_SUFFIX) != orxFALSE) ? orxConfig_GetString(orxPLUGIN_KZ_CONFIG_DEBUG_SUFFIX) : orxPLUGIN_KZ_DEFAULT_DEBUG_SUFFIX);

  /* Gets complete name */
  orxString_NPrint(zFileName, sizeof(zFileName) - 1, "%s%s.%s", _zPluginFileName, zDebugSuffix, szPluginLibraryExt);

  /* Loads it */
  hResult = orxPlugin_Load(zFileName, _zPluginName);

  /* Not valid? */
  if(hResult == orxHANDLE_UNDEFINED)
  {

#endif /* __orxDEBUG__ */

  /* Gets complete name */
  orxString_NPrint(zFileName, sizeof(zFileName) - 1, "%s.%s", _zPluginFileName, szPluginLibraryExt);

  /* Loads it */
  hResult = orxPlugin_Load(zFileName, _zPluginName);

#ifdef __orxDEBUG__

  }

  /* Pops previous section */
  orxConfig_PopSection();

#endif /* __orxDEBUG__ */

#else /* __orxPLUGIN_DYNAMIC__ */

  /* Logs message */
  orxDEBUG_PRINT(orxDEBUG_LEVEL_PLUGIN, "Ignoring function call: this version of orx has been compiled without dynamic plugin support.");

#endif /* __orxPLUGIN_DYNAMIC__ */

  /* Done! */
  return hResult;
}
Beispiel #2
0
static void Run()
{
  // Ready?
  if(orxFLAG_TEST_ALL(sstFontGen.u32Flags, orxFONTGEN_KU32_STATIC_MASK_READY))
  {
    orxU32 u32Counter;

    // Gets glyph list's counter
    u32Counter = orxLinkList_GetCounter(&sstFontGen.stGlyphList);

    // Valid?
    if(u32Counter)
    {
      orxS32      s32Width, s32Height, s32BaseLine, s32MaxAscend, s32MaxDescend;
      orxSTRING  *azWidthList = orxNULL;
      orxFLOAT    fWidth, fHeight;
      orxU8      *pu8ImageBuffer;

      // Not monospaced?
      if(!orxFLAG_TEST(sstFontGen.u32Flags, orxFONTGEN_KU32_STATIC_FLAG_MONOSPACE))
      {
        orxU32 i;

        // Allocates width list
        azWidthList = (orxSTRING *)orxMemory_Allocate(u32Counter * sizeof(orxSTRING), orxMEMORY_TYPE_MAIN);

        // Checks
        orxASSERT(azWidthList);

        // For all strings
        for(i = 0; i < u32Counter; i++)
        {
          azWidthList[i] = (orxSTRING)orxMemory_Allocate(8 * sizeof(orxCHAR), orxMEMORY_TYPE_MAIN);
        }
      }

      // No font name?
      if(!sstFontGen.zFontName)
      {
        // Uses default one
        sstFontGen.zFontName = orxString_Duplicate(orxFONTGEN_KZ_DEFAULT_NAME);

        // Logs message
        orxFONTGEN_LOG(OUTPUT, "No output name specified, defaulting to '%s'.", orxFONTGEN_KZ_DEFAULT_NAME);
      }

      // Is not monospaced?
      if(!orxFLAG_TEST(sstFontGen.u32Flags, orxFONTGEN_KU32_STATIC_FLAG_MONOSPACE))
      {
        orxFONTGEN_GLYPH *pstGlyph;
        orxS32            s32LargestWidth = 0;

        // For all defined glyphs
        for(pstGlyph = (orxFONTGEN_GLYPH *)orxLinkList_GetFirst(&sstFontGen.stGlyphList);
            pstGlyph;
            pstGlyph = (orxFONTGEN_GLYPH *)orxLinkList_GetNext(&pstGlyph->stNode))
        {
          orxS32    s32CharacterWidth;
          FT_Error  eError;

          // Loads rendered glyph
          eError = FT_Load_Glyph(sstFontGen.pstFontFace, (FT_UInt)pstGlyph->u32Index, FT_LOAD_RENDER);
          orxASSERT(!eError);

          // Use original advance value?
          if(orxFLAG_TEST(sstFontGen.u32Flags, orxFONTGEN_KU32_STATIC_FLAG_ADVANCE))
          {
            // Gets character width
            s32CharacterWidth = sstFontGen.pstFontFace->glyph->advance.x >> 6;
          }
          else
          {
            // Gets character width
            s32CharacterWidth = orxMAX((orxS32)sstFontGen.pstFontFace->glyph->bitmap_left, 0) + (orxS32)sstFontGen.pstFontFace->glyph->bitmap.width;
          }

          // Updates largest character width
          s32LargestWidth = orxMAX(s32LargestWidth, s32CharacterWidth);
        }
Beispiel #3
0
/** Updates text size
 * @param[in]   _pstText      Concerned text
 */
static void orxFASTCALL orxText_UpdateSize(orxTEXT *_pstText)
{
  /* Checks */
  orxSTRUCTURE_ASSERT(_pstText);

  /* Has string and font? */
  if((_pstText->zString != orxNULL) && (_pstText->zString != orxSTRING_EMPTY) && (_pstText->pstFont != orxNULL))
  {
    orxFLOAT        fWidth, fMaxWidth, fHeight, fCharacterHeight;
    orxU32          u32CharacterCodePoint;
    const orxCHAR  *pc;

    /* Gets character height */
    fCharacterHeight = orxFont_GetCharacterHeight(_pstText->pstFont);

    /* For all characters */
    for(u32CharacterCodePoint = orxString_GetFirstCharacterCodePoint(_pstText->zString, &pc), fHeight = fCharacterHeight, fWidth = fMaxWidth = orxFLOAT_0;
        u32CharacterCodePoint != orxCHAR_NULL;
        u32CharacterCodePoint = orxString_GetFirstCharacterCodePoint(pc, &pc))
    {
      /* Depending on character */
      switch(u32CharacterCodePoint)
      {
        case orxCHAR_CR:
        {
          /* Half EOL? */
          if(*pc == orxCHAR_LF)
          {
            /* Updates pointer */
            pc++;
          }

          /* Fall through */
        }

        case orxCHAR_LF:
        {
          /* Updates height */
          fHeight += fCharacterHeight;

          /* Updates max width */
          fMaxWidth = orxMAX(fMaxWidth, fWidth);

          /* Resets width */
          fWidth = orxFLOAT_0;

          break;
        }

        default:
        {
          /* Updates width */
          fWidth += orxFont_GetCharacterWidth(_pstText->pstFont, u32CharacterCodePoint);

          break;
        }
      }
    }

    /* Stores values */
    _pstText->fWidth  = orxMAX(fWidth, fMaxWidth);
    _pstText->fHeight = fHeight;
  }
  else
  {
    /* Clears values */
    _pstText->fWidth = _pstText->fHeight = orxFLOAT_0;
  }

  /* Done! */
  return;
}