orxSTATUS orxFASTCALL orxDisplay_SDL_BlitBitmap(orxBITMAP *_pstDst, const orxBITMAP *_pstSrc, const orxFLOAT _fPosX, orxFLOAT _fPosY, orxDISPLAY_BLEND_MODE _eBlendMode)
{
  SDL_Rect  stSrcRect, stDstRect;
  orxSTATUS eResult;

  /* Checks */
  orxASSERT((sstDisplay.u32Flags & orxDISPLAY_KU32_STATIC_FLAG_READY) == orxDISPLAY_KU32_STATIC_FLAG_READY);
  orxASSERT(_pstDst != orxNULL);
  orxASSERT((_pstSrc != orxNULL) && (_pstSrc != (orxBITMAP *)sstDisplay.pstScreen));

  /* Inits blitting rectangles */
  stSrcRect.x = 0;
  stSrcRect.y = 0;
  stSrcRect.w = ((SDL_Surface *)_pstSrc)->w;
  stSrcRect.h = ((SDL_Surface *)_pstSrc)->h;
  stDstRect.x = (orxS16)orxF2S(_fPosX);
  stDstRect.y = (orxS16)orxF2S(_fPosY);
  stDstRect.w = 0;
  stDstRect.h = 0;

  /* Updates result */
  eResult = (SDL_BlitSurface((SDL_Surface *)_pstSrc, &stSrcRect, (SDL_Surface *)_pstDst, &stDstRect) == 0)
            ? orxSTATUS_SUCCESS
            : orxSTATUS_FAILURE;

  /* Done! */
  return eResult;
}
orxSTATUS orxFASTCALL orxDisplay_SDL_TransformBitmap(orxBITMAP *_pstDst, const orxBITMAP *_pstSrc, const orxDISPLAY_TRANSFORM *_pstTransform, orxDISPLAY_SMOOTHING _eSmoothing, orxDISPLAY_BLEND_MODE _eBlendMode)
{
  SDL_Surface  *pstSurface;
  orxSTATUS     eResult;

  /* Checks */
  orxASSERT((sstDisplay.u32Flags & orxDISPLAY_KU32_STATIC_FLAG_READY) == orxDISPLAY_KU32_STATIC_FLAG_READY);
  orxASSERT(_pstDst != orxNULL);
  orxASSERT((_pstSrc != orxNULL) && (_pstSrc != (orxBITMAP *)sstDisplay.pstScreen));
  orxASSERT(_pstTransform != orxNULL);

  /* Creates transformed surface */
  pstSurface = (SDL_Surface *)_pstSrc;//rotozoomSurface((SDL_Surface *)_pstSrc, -orxMATH_KF_RAD_TO_DEG * _pstTransform->fRotation, _pstTransform->fScaleX, 0);

  /* Valid? */
  if(pstSurface != orxNULL)
  {
    SDL_Rect stSrcRect, stDstRect;

    /* Inits blitting rectangles */
    stSrcRect.x = 0;//(orxS16)orxF2S(_pstTransform->fSrcX);
    stSrcRect.y = 0;//(orxS16)orxF2S(_pstTransform->fSrcX);
    stSrcRect.w = ((SDL_Surface *)_pstSrc)->w;
    stSrcRect.h = ((SDL_Surface *)_pstSrc)->h;
    stDstRect.x = (orxS16)orxF2S(_pstTransform->fDstX);
    stDstRect.y = (orxS16)orxF2S(_pstTransform->fDstY);
    stDstRect.w = 0;
    stDstRect.h = 0;

    /* Updates result */
    eResult = (SDL_BlitSurface(pstSurface, &stSrcRect, (SDL_Surface *)_pstDst, &stDstRect) == 0)
              ? orxSTATUS_SUCCESS
              : orxSTATUS_FAILURE;

    /* Deletes transformed surface */
    //SDL_FreeSurface(pstSurface);
  }
  else
  {
    /* Updates result */
    eResult = orxSTATUS_FAILURE;
  }

  /* Done! */
  return eResult;
}
Example #3
0
/** Gets a random orxS32 value
 * @param[in]   _s32Min                         Minimum boundary
 * @param[in]   _s32Max                         Maximum boundary
 * @return      Random value
 */
orxS32 orxFASTCALL orxMath_GetRandomS32(orxS32 _s32Min, orxS32 _s32Max)
{
  orxU32 u32Rand;

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

  /* Done! */
  return (u32Rand == RAND_MAX) ? _s32Max : (orxF2S((orx2F(u32Rand) * (orx2F(1.0f / RAND_MAX)) * (orxS2F(_s32Max) + 1 - orxS2F(_s32Min))) + orxS2F(_s32Min)));
}
Example #4
0
orxSTATUS orxFASTCALL orxMouse_GLFW_SetPosition(const orxVECTOR *_pvPosition)
{
  orxS32    s32X, s32Y;
  orxSTATUS eResult = orxSTATUS_SUCCESS;

  /* Checks */
  orxASSERT((sstMouse.u32Flags & orxMOUSE_KU32_STATIC_FLAG_READY) == orxMOUSE_KU32_STATIC_FLAG_READY);

  /* Gets mouse position */
  glfwGetMousePos((int *)&s32X, (int *)&s32Y);

  /* Updates accumulator */
  sstMouse.vMouseAcc.fX += orxS2F(s32X) - _pvPosition->fX;
  sstMouse.vMouseAcc.fY += orxS2F(s32Y) - _pvPosition->fY;

  /* Moves mouse */
  glfwSetMousePos((int)orxF2S(_pvPosition->fX), (int)orxF2S(_pvPosition->fY));

  /* Done! */
  return eResult;
}