@@ -951,9 +951,9 @@ void RenderWindow::draw(SDLTexture &obj)
951951
952952 // We keep the value of the origin x and y of the object to be drawn.
953953 // This allows to keep the value of the original variables intact during recalculations.
954- float objOriginX ((obj.getScale ().x < 0 .f && static_cast <int >(obj.getOrigin ().y ) == 0 &&
954+ float objOriginX ((obj.getScale ().x < 0 .f /* && static_cast<int>(obj.getOrigin().y) == 0*/ &&
955955 static_cast <int >(obj.getOrigin ().x ) == 0 ) ? obj.getTextureRect ().width : obj.getOrigin ().x );
956- float objOriginY ((obj.getScale ().y < 0 .f && static_cast <int >(obj.getOrigin ().x ) == 0 &&
956+ float objOriginY ((obj.getScale ().y < 0 .f /* && static_cast<int>(obj.getOrigin().x) == 0*/ &&
957957 static_cast <int >(obj.getOrigin ().y ) == 0 ) ? obj.getTextureRect ().height : obj.getOrigin ().y );
958958 float xOrigin (objOriginX);
959959 float yOrigin (objOriginY);
@@ -972,18 +972,31 @@ void RenderWindow::draw(SDLTexture &obj)
972972 yOrigin = rec.h / (obj.getTextureRect ().height / objOriginY);
973973
974974 // We do a corresponding flip according to the sign of the variables x scale and y scale
975- if (obj.getScale ().x < 0 .f && obj.getScale ().y < 0 .f ) obj.m_SDLFlip = (SDL_RendererFlip)(SDL_FLIP_HORIZONTAL | SDL_FLIP_VERTICAL);
975+ if (obj.getScale ().x < 0 .f && obj.getScale ().y < 0 .f )
976+ {
977+ obj.m_SDLFlip = (SDL_RendererFlip)(SDL_FLIP_HORIZONTAL | SDL_FLIP_VERTICAL);
978+ if (static_cast <int >(obj.getOrigin ().x ) != static_cast <int >(obj.getTextureRect ().width / 2 ) &&
979+ static_cast <int >(obj.getOrigin ().x ) != 0 )
980+ xOrigin += obj.getTextureRect ().width ;
981+ if (static_cast <int >(obj.getOrigin ().y ) != static_cast <int >(obj.getTextureRect ().height / 2 ) &&
982+ static_cast <int >(obj.getOrigin ().y ) != 0 )
983+ yOrigin -= obj.getTextureRect ().height ;
984+ }
976985 else if (obj.getScale ().x < 0 .f )
977986 {
978987 obj.m_SDLFlip = SDL_FLIP_HORIZONTAL;
979- // xOrigin *= 1.65f;
980- // rotation *= -1.f;
988+ if (static_cast <int >(obj.getOrigin ().x ) != static_cast <int >(obj.getTextureRect ().width / 2 ) &&
989+ static_cast <int >(obj.getOrigin ().x ) != 0 ) xOrigin += obj.getTextureRect ().width ;
990+ }
991+ else if (obj.getScale ().y < 0 .f )
992+ {
993+ obj.m_SDLFlip = SDL_FLIP_VERTICAL;
994+ if (static_cast <int >(obj.getOrigin ().y ) != static_cast <int >(obj.getTextureRect ().height / 2 ) &&
995+ static_cast <int >(obj.getOrigin ().y ) != 0 )
996+ yOrigin -= obj.getTextureRect ().height ;
981997 }
982- else if (obj.getScale ().y < 0 .f ) obj.m_SDLFlip = SDL_FLIP_VERTICAL;
983998 else obj.m_SDLFlip = SDL_FLIP_NONE;
984999
985- SDL_SetTextureColorMod (obj.getSDLTexture (), obj.getColor ().r , obj.getColor ().g , obj.getColor ().b );
986-
9871000 // Move the object according to the position of the camera
9881001 rec.x = (obj.getPosition ().x - xOrigin) - (m_view.getCenter ().x - (m_view.getSize ().x / 2 .f ));
9891002 rec.y = (obj.getPosition ().y - yOrigin) - (m_view.getCenter ().y - (m_view.getSize ().y / 2 .f ));
@@ -1018,15 +1031,12 @@ void RenderWindow::draw(SDLTexture &obj)
10181031 rec.w , obj.getTextureRect ().height , objOriginY);
10191032 }
10201033
1021- SDL_SetTextureBlendMode (obj.getSDLTexture (), SDL_BLENDMODE_BLEND);
1022- SDL_SetTextureAlphaMod (obj.getSDLTexture (), obj.getColor ().a );
1023-
10241034 if (obj.m_SDLTextureType == SDLTexture::SDLTextureType::IS_ENGINE_SDL_TEXT)
10251035 {
10261036 if (obj.getSDLOutlineTexture () != NULL )
10271037 {
10281038 SDL_SetTextureBlendMode (obj.getSDLOutlineTexture (), SDL_BLENDMODE_BLEND);
1029- // SDL_SetTextureAlphaMod(obj.getSDLOutlineTexture(), obj.getColor().a);
1039+ SDL_SetTextureAlphaMod (obj.getSDLOutlineTexture (), obj.getColor ().a );
10301040
10311041 SDL_Rect SDLoutlineTextureRec, outlineTextureRecSrc;
10321042 SDLoutlineTextureRec.x = rec.x ;
@@ -1045,6 +1055,9 @@ void RenderWindow::draw(SDLTexture &obj)
10451055 &outlineTextureRecSrc, &SDLoutlineTextureRec, rotation, &point, obj.m_SDLFlip );
10461056 }
10471057 }
1058+ SDL_SetTextureBlendMode (obj.getSDLTexture (), SDL_BLENDMODE_BLEND);
1059+ SDL_SetTextureAlphaMod (obj.getSDLTexture (), obj.getColor ().a );
1060+ SDL_SetTextureColorMod (obj.getSDLTexture (), obj.getColor ().r , obj.getColor ().g , obj.getColor ().b );
10481061 SDL_RenderCopyEx (is::IS_ENGINE_SDL_renderer, obj.getSDLTexture (), &recSrc, &rec, rotation, &point, obj.m_SDLFlip );
10491062}
10501063
0 commit comments