Advertisement
Guest User

patch.diff

a guest
Dec 1st, 2013
246
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 34.79 KB | None | 0 0
  1. diff --git a/examples/opengl/OpenGL.cpp b/examples/opengl/OpenGL.cpp
  2. index 639254b..3831508 100644
  3. --- a/examples/opengl/OpenGL.cpp
  4. +++ b/examples/opengl/OpenGL.cpp
  5. @@ -68,7 +68,7 @@ int main()
  6.      // Setup a perspective projection
  7.      glMatrixMode(GL_PROJECTION);
  8.      glLoadIdentity();
  9. -    GLfloat ratio = static_cast<float>(window.getSize().x) / window.getSize().y;
  10. +    GLfloat ratio = static_cast<float>(window.getSize().x) / static_cast<float>(window.getSize().y);
  11.      glFrustum(-ratio, ratio, -1.f, 1.f, 1.f, 500.f);
  12.  
  13.      // Bind the texture
  14. @@ -164,8 +164,8 @@ int main()
  15.          glClear(GL_DEPTH_BUFFER_BIT);
  16.  
  17.          // We get the position of the mouse cursor, so that we can move the box accordingly
  18. -        float x =  sf::Mouse::getPosition(window).x * 200.f / window.getSize().x - 100.f;
  19. -        float y = -sf::Mouse::getPosition(window).y * 200.f / window.getSize().y + 100.f;
  20. +        float x =  static_cast<float>(sf::Mouse::getPosition(window).x) * 200.f / static_cast<float>(window.getSize().x) - 100.f;
  21. +        float y = -static_cast<float>(sf::Mouse::getPosition(window).y) * 200.f / static_cast<float>(window.getSize().y) + 100.f;
  22.  
  23.          // Apply some transformations
  24.          glMatrixMode(GL_MODELVIEW);
  25. diff --git a/examples/pong/Pong.cpp b/examples/pong/Pong.cpp
  26. index 1b9a74f..20de537 100644
  27. --- a/examples/pong/Pong.cpp
  28. +++ b/examples/pong/Pong.cpp
  29. @@ -90,7 +90,7 @@ int main()
  30.          while (window.pollEvent(event))
  31.          {
  32.              // Window closed or escape key pressed: exit
  33. -            if ((event.type == sf::Event::Closed) ||
  34. +            if ((event.type == sf::Event::Closed) ||
  35.                 ((event.type == sf::Event::KeyPressed) && (event.key.code == sf::Keyboard::Escape)))
  36.              {
  37.                  window.close();
  38. @@ -115,7 +115,7 @@ int main()
  39.                      do
  40.                      {
  41.                          // Make sure the ball initial angle is not too much vertical
  42. -                        ballAngle = (std::rand() % 360) * 2 * pi / 360;
  43. +                        ballAngle = static_cast<float>(std::rand() % 360) * 2.f * pi / 360.f;
  44.                      }
  45.                      while (std::abs(std::cos(ballAngle)) < 0.7f);
  46.                  }
  47. @@ -187,15 +187,15 @@ int main()
  48.  
  49.              // Check the collisions between the ball and the paddles
  50.              // Left Paddle
  51. -            if (ball.getPosition().x - ballRadius < leftPaddle.getPosition().x + paddleSize.x / 2 &&
  52. +            if (ball.getPosition().x - ballRadius < leftPaddle.getPosition().x + paddleSize.x / 2 &&
  53.                  ball.getPosition().x - ballRadius > leftPaddle.getPosition().x &&
  54.                  ball.getPosition().y + ballRadius >= leftPaddle.getPosition().y - paddleSize.y / 2 &&
  55.                  ball.getPosition().y - ballRadius <= leftPaddle.getPosition().y + paddleSize.y / 2)
  56.              {
  57.                  if (ball.getPosition().y > leftPaddle.getPosition().y)
  58. -                    ballAngle = pi - ballAngle + (std::rand() % 20) * pi / 180;
  59. +                    ballAngle = pi - ballAngle + static_cast<float>(std::rand() % 20) * pi / 180.f;
  60.                  else
  61. -                    ballAngle = pi - ballAngle - (std::rand() % 20) * pi / 180;
  62. +                    ballAngle = pi - ballAngle - static_cast<float>(std::rand() % 20) * pi / 180.f;
  63.  
  64.                  ballSound.play();
  65.                  ball.setPosition(leftPaddle.getPosition().x + ballRadius + paddleSize.x / 2 + 0.1f, ball.getPosition().y);
  66. @@ -208,9 +208,9 @@ int main()
  67.                  ball.getPosition().y - ballRadius <= rightPaddle.getPosition().y + paddleSize.y / 2)
  68.              {
  69.                  if (ball.getPosition().y > rightPaddle.getPosition().y)
  70. -                    ballAngle = pi - ballAngle + (std::rand() % 20) * pi / 180;
  71. +                    ballAngle = pi - ballAngle + static_cast<float>(std::rand() % 20) * pi / 180.f;
  72.                  else
  73. -                    ballAngle = pi - ballAngle - (std::rand() % 20) * pi / 180;
  74. +                    ballAngle = pi - ballAngle - static_cast<float>(std::rand() % 20) * pi / 180.f;
  75.  
  76.                  ballSound.play();
  77.                  ball.setPosition(rightPaddle.getPosition().x - ballRadius - paddleSize.x / 2 - 0.1f, ball.getPosition().y);
  78. diff --git a/examples/shader/Shader.cpp b/examples/shader/Shader.cpp
  79. index 9595920..af013a5 100644
  80. --- a/examples/shader/Shader.cpp
  81. +++ b/examples/shader/Shader.cpp
  82. @@ -139,9 +139,9 @@ public :
  83.          {
  84.              float x = static_cast<float>(std::rand() % 800);
  85.              float y = static_cast<float>(std::rand() % 600);
  86. -            sf::Uint8 r = std::rand() % 255;
  87. -            sf::Uint8 g = std::rand() % 255;
  88. -            sf::Uint8 b = std::rand() % 255;
  89. +            sf::Uint8 r = static_cast<sf::Uint8>(std::rand() % 255);
  90. +            sf::Uint8 g = static_cast<sf::Uint8>(std::rand() % 255);
  91. +            sf::Uint8 b = static_cast<sf::Uint8>(std::rand() % 255);
  92.              m_points.append(sf::Vertex(sf::Vector2f(x, y), sf::Color(r, g, b)));
  93.          }
  94.  
  95. @@ -228,8 +228,8 @@ public :
  96.          for (std::size_t i = 0; i < m_entities.size(); ++i)
  97.          {
  98.              sf::Vector2f position;
  99. -            position.x = std::cos(0.25f * (time * i + (m_entities.size() - i))) * 300 + 350;
  100. -            position.y = std::sin(0.25f * (time * (m_entities.size() - i) + i)) * 200 + 250;
  101. +            position.x = std::cos(0.25f * (time * static_cast<float>(i + (m_entities.size() - i)))) * 300.f + 350.f;
  102. +            position.y = std::sin(0.25f * (time * static_cast<float>((m_entities.size() - i) + i))) * 200.f + 250.f;
  103.              m_entities[i].setPosition(position);
  104.          }
  105.  
  106. @@ -352,8 +352,8 @@ int main()
  107.          }
  108.  
  109.          // Update the current example
  110. -        float x = static_cast<float>(sf::Mouse::getPosition(window).x) / window.getSize().x;
  111. -        float y = static_cast<float>(sf::Mouse::getPosition(window).y) / window.getSize().y;
  112. +        float x = static_cast<float>(sf::Mouse::getPosition(window).x) / static_cast<float>(window.getSize().x);
  113. +        float y = static_cast<float>(sf::Mouse::getPosition(window).y) / static_cast<float>(window.getSize().y);
  114.          effects[current]->update(clock.getElapsedTime().asSeconds(), x, y);
  115.  
  116.          // Clear the window
  117. diff --git a/examples/window/Window.cpp b/examples/window/Window.cpp
  118. index 360703b..e9ec847 100644
  119. --- a/examples/window/Window.cpp
  120. +++ b/examples/window/Window.cpp
  121. @@ -41,7 +41,7 @@ int main()
  122.      // Setup a perspective projection
  123.      glMatrixMode(GL_PROJECTION);
  124.      glLoadIdentity();
  125. -    GLfloat ratio = static_cast<float>(window.getSize().x) / window.getSize().y;
  126. +    GLfloat ratio = static_cast<float>(window.getSize().x) / static_cast<float>(window.getSize().y);
  127.      glFrustum(-ratio, ratio, -1.f, 1.f, 1.f, 500.f);
  128.  
  129.      // Define a 3D cube (6 faces made of 2 triangles composed by 3 vertices)
  130. diff --git a/src/SFML/Audio/Music.cpp b/src/SFML/Audio/Music.cpp
  131. index b8dc6eb..eddc74f 100644
  132. --- a/src/SFML/Audio/Music.cpp
  133. +++ b/src/SFML/Audio/Music.cpp
  134. @@ -139,7 +139,7 @@ void Music::onSeek(Time timeOffset)
  135.  void Music::initialize()
  136.  {
  137.      // Compute the music duration
  138. -    m_duration = seconds(static_cast<float>(m_file->getSampleCount()) / m_file->getSampleRate() / m_file->getChannelCount());
  139. +    m_duration = seconds(static_cast<float>(m_file->getSampleCount()) / static_cast<float>(m_file->getSampleRate()) / static_cast<float>(m_file->getChannelCount()));
  140.  
  141.      // Resize the internal buffer so that it can contain 1 second of audio samples
  142.      m_samples.resize(m_file->getSampleRate() * m_file->getChannelCount());
  143. diff --git a/src/SFML/Audio/SoundBuffer.cpp b/src/SFML/Audio/SoundBuffer.cpp
  144. index cfd1c6a..bf4ac08 100644
  145. --- a/src/SFML/Audio/SoundBuffer.cpp
  146. +++ b/src/SFML/Audio/SoundBuffer.cpp
  147. @@ -253,7 +253,7 @@ bool SoundBuffer::update(unsigned int channelCount, unsigned int sampleRate)
  148.      alCheck(alBufferData(m_buffer, format, &m_samples[0], size, sampleRate));
  149.  
  150.      // Compute the duration
  151. -    m_duration = seconds(static_cast<float>(m_samples.size()) / sampleRate / channelCount);
  152. +    m_duration = seconds(static_cast<float>(m_samples.size()) / static_cast<float>(sampleRate) / static_cast<float>(channelCount));
  153.  
  154.      return true;
  155.  }
  156. diff --git a/src/SFML/Audio/SoundFile.cpp b/src/SFML/Audio/SoundFile.cpp
  157. index fdd7667..e0101d3 100644
  158. --- a/src/SFML/Audio/SoundFile.cpp
  159. +++ b/src/SFML/Audio/SoundFile.cpp
  160. @@ -284,7 +284,7 @@ void SoundFile::seek(Time timeOffset)
  161.  {
  162.      if (m_file)
  163.      {
  164. -        sf_count_t frameOffset = static_cast<sf_count_t>(timeOffset.asSeconds() * m_sampleRate);
  165. +        sf_count_t frameOffset = static_cast<sf_count_t>(timeOffset.asSeconds() * static_cast<float>(m_sampleRate));
  166.          sf_seek(m_file, frameOffset, SEEK_SET);
  167.      }
  168.  }
  169. diff --git a/src/SFML/Audio/SoundStream.cpp b/src/SFML/Audio/SoundStream.cpp
  170. index 31df188..7fb6ece 100644
  171. --- a/src/SFML/Audio/SoundStream.cpp
  172. +++ b/src/SFML/Audio/SoundStream.cpp
  173. @@ -159,7 +159,7 @@ void SoundStream::setPlayingOffset(Time timeOffset)
  174.      onSeek(timeOffset);
  175.  
  176.      // Restart streaming
  177. -    m_samplesProcessed = static_cast<Uint64>(timeOffset.asSeconds() * m_sampleRate * m_channelCount);
  178. +    m_samplesProcessed = static_cast<Uint64>(timeOffset.asSeconds() * static_cast<float>(m_sampleRate) * static_cast<float>(m_channelCount));
  179.      m_isStreaming = true;
  180.      m_thread.launch();
  181.  }
  182. @@ -173,7 +173,7 @@ Time SoundStream::getPlayingOffset() const
  183.          ALfloat secs = 0.f;
  184.          alCheck(alGetSourcef(m_source, AL_SEC_OFFSET, &secs));
  185.  
  186. -        return seconds(secs + static_cast<float>(m_samplesProcessed) / m_sampleRate / m_channelCount);
  187. +        return seconds(secs + static_cast<float>(m_samplesProcessed) / static_cast<float>(m_sampleRate) / static_cast<float>(m_channelCount));
  188.      }
  189.      else
  190.      {
  191. diff --git a/src/SFML/Graphics/CircleShape.cpp b/src/SFML/Graphics/CircleShape.cpp
  192. index 23e9e77..c51c533 100644
  193. --- a/src/SFML/Graphics/CircleShape.cpp
  194. +++ b/src/SFML/Graphics/CircleShape.cpp
  195. @@ -74,7 +74,7 @@ Vector2f CircleShape::getPoint(unsigned int index) const
  196.  {
  197.      static const float pi = 3.141592654f;
  198.  
  199. -    float angle = index * 2 * pi / m_pointCount - pi / 2;
  200. +    float angle = static_cast<float>(index) * 2.f * pi / static_cast<float>(m_pointCount) - pi / 2.f;
  201.      float x = std::cos(angle) * m_radius;
  202.      float y = std::sin(angle) * m_radius;
  203.  
  204. diff --git a/src/SFML/Graphics/Font.cpp b/src/SFML/Graphics/Font.cpp
  205. index 1e26c81..72b101c 100644
  206. --- a/src/SFML/Graphics/Font.cpp
  207. +++ b/src/SFML/Graphics/Font.cpp
  208. @@ -542,7 +542,7 @@ IntRect Font::findGlyphRect(Page& page, unsigned int width, unsigned int height)
  209.      float bestRatio = 0;
  210.      for (std::vector<Row>::iterator it = page.rows.begin(); it != page.rows.end() && !row; ++it)
  211.      {
  212. -        float ratio = static_cast<float>(height) / it->height;
  213. +        float ratio = static_cast<float>(height) / static_cast<float>(it->height);
  214.  
  215.          // Ignore rows that are either too small or too high
  216.          if ((ratio < 0.7f) || (ratio > 1.f))
  217. diff --git a/src/SFML/Graphics/GLExtensions.cpp b/src/SFML/Graphics/GLExtensions.cpp
  218. index 83afa86..ad6cdd4 100644
  219. --- a/src/SFML/Graphics/GLExtensions.cpp
  220. +++ b/src/SFML/Graphics/GLExtensions.cpp
  221. @@ -26,6 +26,7 @@
  222.  // Headers
  223.  ////////////////////////////////////////////////////////////
  224.  #include <SFML/Graphics/GLExtensions.hpp>
  225. +#include <SFML/System/Err.hpp>
  226.  
  227.  
  228.  namespace sf
  229. diff --git a/src/SFML/Graphics/GLExtensions.hpp b/src/SFML/Graphics/GLExtensions.hpp
  230. index de12af6..0f74d3a 100644
  231. --- a/src/SFML/Graphics/GLExtensions.hpp
  232. +++ b/src/SFML/Graphics/GLExtensions.hpp
  233. @@ -34,56 +34,186 @@
  234.  
  235.      #include <SFML/OpenGL.hpp>
  236.  
  237. -    #define GL_blend_func_separate           GL_OES_blend_func_separate
  238. -    #define glBlendFuncSeparate              glBlendFuncSeparateOES
  239. -    #define GL_framebuffer_object            GL_OES_framebuffer_object
  240. -    #define glGenFramebuffers                glGenFramebuffersOES
  241. -    #define glGenRenderbuffers               glGenRenderbuffersOES
  242. -    #define glBindFramebuffer                glBindFramebufferOES
  243. -    #define glBindRenderbuffer               glBindRenderbufferOES
  244. -    #define glDeleteFramebuffers             glDeleteFramebuffersOES
  245. -    #define glDeleteRenderbuffers            glDeleteRenderbuffersOES
  246. -    #define glRenderbufferStorage            glRenderbufferStorageOES
  247. -    #define glFramebufferRenderbuffer        glFramebufferRenderbufferOES
  248. -    #define glFramebufferTexture2D           glFramebufferTexture2DOES
  249. -    #define glCheckFramebufferStatus         glCheckFramebufferStatusOES
  250. -    #define GL_FRAMEBUFFER                   GL_FRAMEBUFFER_OES
  251. -    #define GL_FRAMEBUFFER_BINDING           GL_FRAMEBUFFER_BINDING_OES
  252. -    #define GL_RENDERBUFFER                  GL_RENDERBUFFER_OES
  253. -    #define GL_COLOR_ATTACHMENT0             GL_COLOR_ATTACHMENT0_OES
  254. -    #define GL_DEPTH_ATTACHMENT              GL_DEPTH_ATTACHMENT_OES
  255. -    #define GL_FRAMEBUFFER_COMPLETE          GL_FRAMEBUFFER_COMPLETE_OES
  256. -    #define GL_DEPTH_COMPONENT               GL_DEPTH_COMPONENT16_OES
  257. -    #define GL_INVALID_FRAMEBUFFER_OPERATION GL_INVALID_FRAMEBUFFER_OPERATION_OES
  258. -    #define GL_texture_non_power_of_two      false
  259. +    #if !defined(GL_blend_func_separate)
  260. +        #define GL_blend_func_separate             GL_OES_blend_func_separate
  261. +    #endif
  262. +
  263. +    #if !defined(glBlendFuncSeparate)
  264. +        #define glBlendFuncSeparate                glBlendFuncSeparateOES
  265. +    #endif
  266. +
  267. +    #if !defined(GL_framebuffer_object)
  268. +        #define GL_framebuffer_object              GL_OES_framebuffer_object
  269. +    #endif
  270. +
  271. +    #if !defined(glGenFramebuffers)
  272. +        #define glGenFramebuffers                  glGenFramebuffersOES
  273. +    #endif
  274. +
  275. +    #if !defined(glGenRenderbuffers)
  276. +        #define glGenRenderbuffers                 glGenRenderbuffersOES
  277. +    #endif
  278. +
  279. +    #if !defined(glBindFramebuffer)
  280. +        #define glBindFramebuffer                  glBindFramebufferOES
  281. +    #endif
  282. +
  283. +    #if !defined(glBindRenderbuffer)
  284. +        #define glBindRenderbuffer                 glBindRenderbufferOES
  285. +    #endif
  286. +
  287. +    #if !defined(glDeleteFramebuffers)
  288. +        #define glDeleteFramebuffers               glDeleteFramebuffersOES
  289. +    #endif
  290. +
  291. +    #if !defined(glDeleteRenderbuffers)
  292. +        #define glDeleteRenderbuffers              glDeleteRenderbuffersOES
  293. +    #endif
  294. +
  295. +    #if !defined(glRenderbufferStorage)
  296. +        #define glRenderbufferStorage              glRenderbufferStorageOES
  297. +    #endif
  298. +
  299. +    #if !defined(glFramebufferRenderbuffer)
  300. +        #define glFramebufferRenderbuffer          glFramebufferRenderbufferOES
  301. +    #endif
  302. +
  303. +    #if !defined(glFramebufferTexture2D)
  304. +        #define glFramebufferTexture2D             glFramebufferTexture2DOES
  305. +    #endif
  306. +
  307. +    #if !defined(glCheckFramebufferStatus)
  308. +        #define glCheckFramebufferStatus           glCheckFramebufferStatusOES
  309. +    #endif
  310. +
  311. +    #if !defined(GL_FRAMEBUFFER)
  312. +        #define GL_FRAMEBUFFER                     GL_FRAMEBUFFER_OES
  313. +    #endif
  314. +
  315. +    #if !defined(GL_FRAMEBUFFER_BINDING)
  316. +        #define GL_FRAMEBUFFER_BINDING             GL_FRAMEBUFFER_BINDING_OES
  317. +    #endif
  318. +
  319. +    #if !defined(GL_RENDERBUFFER)
  320. +        #define GL_RENDERBUFFER                    GL_RENDERBUFFER_OES
  321. +    #endif
  322. +
  323. +    #if !defined(GL_COLOR_ATTACHMENT0)
  324. +        #define GL_COLOR_ATTACHMENT0               GL_COLOR_ATTACHMENT0_OES
  325. +    #endif
  326. +
  327. +    #if !defined(GL_DEPTH_ATTACHMENT)
  328. +        #define GL_DEPTH_ATTACHMENT                GL_DEPTH_ATTACHMENT_OES
  329. +    #endif
  330. +
  331. +    #if !defined(GL_FRAMEBUFFER_COMPLETE)
  332. +        #define GL_FRAMEBUFFER_COMPLETE            GL_FRAMEBUFFER_COMPLETE_OES
  333. +    #endif
  334. +
  335. +    #if !defined(GL_DEPTH_COMPONENT)
  336. +        #define GL_DEPTH_COMPONENT                 GL_DEPTH_COMPONENT16_OES
  337. +    #endif
  338. +
  339. +    #if !defined(GL_INVALID_FRAMEBUFFER_OPERATION)
  340. +        #define GL_INVALID_FRAMEBUFFER_OPERATION   GL_INVALID_FRAMEBUFFER_OPERATION_OES
  341. +    #endif
  342. +
  343. +    #if !defined(GL_texture_non_power_of_two
  344. +        #define GL_texture_non_power_of_two        false
  345. +    #endif
  346.  
  347.  #else
  348.  
  349.      #include <GL/glew.h>
  350.      #include <SFML/OpenGL.hpp>
  351.  
  352. -    #define GL_blend_func_separate           GLEW_EXT_blend_func_separate
  353. -    #define glBlendFuncSeparate              glBlendFuncSeparateEXT
  354. -    #define GL_framebuffer_object            GLEW_EXT_framebuffer_object
  355. -    #define glGenFramebuffers                glGenFramebuffersEXT
  356. -    #define glGenRenderbuffers               glGenRenderbuffersEXT
  357. -    #define glBindFramebuffer                glBindFramebufferEXT
  358. -    #define glBindRenderbuffer               glBindRenderbufferEXT
  359. -    #define glDeleteFramebuffers             glDeleteFramebuffersEXT
  360. -    #define glDeleteRenderbuffers            glDeleteRenderbuffersEXT
  361. -    #define glRenderbufferStorage            glRenderbufferStorageEXT
  362. -    #define glFramebufferRenderbuffer        glRenderbufferStorageEXT
  363. -    #define glFramebufferTexture2D           glFramebufferTexture2DEXT
  364. -    #define glCheckFramebufferStatus         glCheckFramebufferStatusEXT
  365. -    #define GL_FRAMEBUFFER                   GL_FRAMEBUFFER_EXT
  366. -    #define GL_FRAMEBUFFER_BINDING           GL_FRAMEBUFFER_BINDING_EXT
  367. -    #define GL_RENDERBUFFER                  GL_RENDERBUFFER_EXT
  368. -    #define GL_COLOR_ATTACHMENT0             GL_COLOR_ATTACHMENT0_EXT
  369. -    #define GL_DEPTH_ATTACHMENT              GL_DEPTH_ATTACHMENT_EXT
  370. -    #define GL_FRAMEBUFFER_COMPLETE          GL_FRAMEBUFFER_COMPLETE_EXT
  371. -    //#define GL_DEPTH_COMPONENT               GL_DEPTH_COMPONENT
  372. -    #define GL_INVALID_FRAMEBUFFER_OPERATION GL_INVALID_FRAMEBUFFER_OPERATION_EXT
  373. -    #define GL_texture_non_power_of_two      GLEW_ARB_texture_non_power_of_two
  374. +    #if !defined(GL_blend_func_separate)
  375. +        #define GL_blend_func_separate             GLEW_EXT_blend_func_separate
  376. +    #endif
  377. +
  378. +    #if !defined(glBlendFuncSeparate)
  379. +        #define glBlendFuncSeparate                glBlendFuncSeparateEXT
  380. +    #endif
  381. +
  382. +    #if !defined(GL_framebuffer_object)
  383. +        #define GL_framebuffer_object              GLEW_EXT_framebuffer_object
  384. +    #endif
  385. +
  386. +    #if !defined(glGenFramebuffers)
  387. +        #define glGenFramebuffers                  glGenFramebuffersEXT
  388. +    #endif
  389. +
  390. +    #if !defined(glGenRenderbuffers)
  391. +        #define glGenRenderbuffers                 glGenRenderbuffersEXT
  392. +    #endif
  393. +
  394. +    #if !defined(glBindFramebuffer)
  395. +        #define glBindFramebuffer                  glBindFramebufferEXT
  396. +    #endif
  397. +
  398. +    #if !defined(glBindRenderbuffer)
  399. +        #define glBindRenderbuffer                 glBindRenderbufferEXT
  400. +    #endif
  401. +
  402. +    #if !defined(glDeleteFramebuffers)
  403. +        #define glDeleteFramebuffers               glDeleteFramebuffersEXT
  404. +    #endif
  405. +
  406. +    #if !defined(glDeleteRenderbuffers)
  407. +        #define glDeleteRenderbuffers              glDeleteRenderbuffersEXT
  408. +    #endif
  409. +
  410. +    #if !defined(glRenderbufferStorage)
  411. +        #define glRenderbufferStorage              glRenderbufferStorageEXT
  412. +    #endif
  413. +
  414. +    #if !defined(glFramebufferRenderbuffer)
  415. +        #define glFramebufferRenderbuffer          glRenderbufferStorageEXT
  416. +    #endif
  417. +
  418. +    #if !defined(glFramebufferTexture2D)
  419. +        #define glFramebufferTexture2D             glFramebufferTexture2DEXT
  420. +    #endif
  421. +
  422. +    #if !defined(glCheckFramebufferStatus)
  423. +        #define glCheckFramebufferStatus           glCheckFramebufferStatusEXT
  424. +    #endif
  425. +
  426. +    #if !defined(GL_FRAMEBUFFER)
  427. +        #define GL_FRAMEBUFFER                     GL_FRAMEBUFFER_EXT
  428. +    #endif
  429. +
  430. +    #if !defined(GL_FRAMEBUFFER_BINDING)
  431. +        #define GL_FRAMEBUFFER_BINDING             GL_FRAMEBUFFER_BINDING_EXT
  432. +    #endif
  433. +
  434. +    #if !defined(GL_RENDERBUFFER)
  435. +        #define GL_RENDERBUFFER                    GL_RENDERBUFFER_EXT
  436. +    #endif
  437. +
  438. +    #if !defined(GL_COLOR_ATTACHMENT0)
  439. +        #define GL_COLOR_ATTACHMENT0               GL_COLOR_ATTACHMENT0_EXT
  440. +    #endif
  441. +
  442. +    #if !defined(GL_DEPTH_ATTACHMENT)
  443. +        #define GL_DEPTH_ATTACHMENT                GL_DEPTH_ATTACHMENT_EXT
  444. +    #endif
  445. +
  446. +    #if !defined(GL_FRAMEBUFFER_COMPLETE)
  447. +        #define GL_FRAMEBUFFER_COMPLETE            GL_FRAMEBUFFER_COMPLETE_EXT
  448. +    #endif
  449. +
  450. +    #if !defined(GL_DEPTH_COMPONENT)
  451. +        //#define GL_DEPTH_COMPONENT                 GL_DEPTH_COMPONENT
  452. +    #endif
  453. +
  454. +    #if !defined(GL_INVALID_FRAMEBUFFER_OPERATION)
  455. +        #define GL_INVALID_FRAMEBUFFER_OPERATION   GL_INVALID_FRAMEBUFFER_OPERATION_EXT
  456. +    #endif
  457. +
  458. +    #if !defined(GL_texture_non_power_of_two)
  459. +        #define GL_texture_non_power_of_two        GLEW_ARB_texture_non_power_of_two
  460. +    #endif
  461.  
  462.  #endif
  463.  
  464. diff --git a/src/SFML/Graphics/Image.cpp b/src/SFML/Graphics/Image.cpp
  465. index 8efb9c7..a4d575b 100644
  466. --- a/src/SFML/Graphics/Image.cpp
  467. +++ b/src/SFML/Graphics/Image.cpp
  468. @@ -240,10 +240,10 @@ void Image::copy(const Image& source, unsigned int destX, unsigned int destY, co
  469.  
  470.                  // Interpolate RGBA components using the alpha value of the source pixel
  471.                  Uint8 alpha = src[3];
  472. -                dst[0] = (src[0] * alpha + dst[0] * (255 - alpha)) / 255;
  473. -                dst[1] = (src[1] * alpha + dst[1] * (255 - alpha)) / 255;
  474. -                dst[2] = (src[2] * alpha + dst[2] * (255 - alpha)) / 255;
  475. -                dst[3] = alpha + dst[3] * (255 - alpha) / 255;
  476. +                dst[0] = static_cast<Uint8>((src[0] * alpha + dst[0] * (255 - alpha)) / 255);
  477. +                dst[1] = static_cast<Uint8>((src[1] * alpha + dst[1] * (255 - alpha)) / 255);
  478. +                dst[2] = static_cast<Uint8>((src[2] * alpha + dst[2] * (255 - alpha)) / 255);
  479. +                dst[3] = static_cast<Uint8>(alpha + dst[3] * (255 - alpha) / 255);
  480.              }
  481.  
  482.              srcPixels += srcStride;
  483. diff --git a/src/SFML/Graphics/RenderTarget.cpp b/src/SFML/Graphics/RenderTarget.cpp
  484. index f015139..c5205ec 100644
  485. --- a/src/SFML/Graphics/RenderTarget.cpp
  486. +++ b/src/SFML/Graphics/RenderTarget.cpp
  487. @@ -113,8 +113,8 @@ Vector2f RenderTarget::mapPixelToCoords(const Vector2i& point, const View& view)
  488.      // First, convert from viewport coordinates to homogeneous coordinates
  489.      Vector2f normalized;
  490.      IntRect viewport = getViewport(view);
  491. -    normalized.x = -1.f + 2.f * (point.x - viewport.left) / viewport.width;
  492. -    normalized.y =  1.f - 2.f * (point.y - viewport.top)  / viewport.height;
  493. +    normalized.x = -1.f + 2.f * static_cast<float>(point.x - viewport.left) / static_cast<float>(viewport.width);
  494. +    normalized.y =  1.f - 2.f * static_cast<float>(point.y - viewport.top)  / static_cast<float>(viewport.height);
  495.  
  496.      // Then transform by the inverse of the view matrix
  497.      return view.getInverseTransform().transformPoint(normalized);
  498. @@ -137,8 +137,8 @@ Vector2i RenderTarget::mapCoordsToPixel(const Vector2f& point, const View& view)
  499.      // Then convert to viewport coordinates
  500.      Vector2i pixel;
  501.      IntRect viewport = getViewport(view);
  502. -    pixel.x = static_cast<int>(( normalized.x + 1.f) / 2.f * viewport.width  + viewport.left);
  503. -    pixel.y = static_cast<int>((-normalized.y + 1.f) / 2.f * viewport.height + viewport.top);
  504. +    pixel.x = static_cast<int>(( normalized.x + 1.f) / 2.f * static_cast<float>(viewport.width  + viewport.left));
  505. +    pixel.y = static_cast<int>((-normalized.y + 1.f) / 2.f * static_cast<float>(viewport.height + viewport.top));
  506.  
  507.      return pixel;
  508.  }
  509. diff --git a/src/SFML/Graphics/Shader.cpp b/src/SFML/Graphics/Shader.cpp
  510. index 0b6efc6..a2a13d7 100644
  511. --- a/src/SFML/Graphics/Shader.cpp
  512. +++ b/src/SFML/Graphics/Shader.cpp
  513. @@ -54,7 +54,7 @@ namespace
  514.          if (file)
  515.          {
  516.              file.seekg(0, std::ios_base::end);
  517. -            std::streamsize size = file.tellg();
  518. +            std::streamsize size = static_cast<std::streamsize>(file.tellg());
  519.              if (size > 0)
  520.              {
  521.                  file.seekg(0, std::ios_base::beg);
  522. diff --git a/src/SFML/Graphics/Shape.cpp b/src/SFML/Graphics/Shape.cpp
  523. index 16524f5..2d15367 100644
  524. --- a/src/SFML/Graphics/Shape.cpp
  525. +++ b/src/SFML/Graphics/Shape.cpp
  526. @@ -39,7 +39,7 @@ namespace
  527.      {
  528.          sf::Vector2f normal(p1.y - p2.y, p2.x - p1.x);
  529.          float length = std::sqrt(normal.x * normal.x + normal.y * normal.y);
  530. -        if (length != 0.f)
  531. +        if (std::abs(length) > 0.f)
  532.              normal /= length;
  533.          return normal;
  534.      }
  535. @@ -219,7 +219,7 @@ void Shape::draw(RenderTarget& target, RenderStates states) const
  536.      target.draw(m_vertices, states);
  537.  
  538.      // Render the outline
  539. -    if (m_outlineThickness != 0)
  540. +    if (std::abs(m_outlineThickness) > 0.f)
  541.      {
  542.          states.texture = NULL;
  543.          target.draw(m_outlineVertices, states);
  544. @@ -242,8 +242,8 @@ void Shape::updateTexCoords()
  545.      {
  546.          float xratio = (m_vertices[i].position.x - m_insideBounds.left) / m_insideBounds.width;
  547.          float yratio = (m_vertices[i].position.y - m_insideBounds.top) / m_insideBounds.height;
  548. -        m_vertices[i].texCoords.x = m_textureRect.left + m_textureRect.width * xratio;
  549. -        m_vertices[i].texCoords.y = m_textureRect.top + m_textureRect.height * yratio;
  550. +        m_vertices[i].texCoords.x = static_cast<float>(m_textureRect.left + m_textureRect.width) * xratio;
  551. +        m_vertices[i].texCoords.y = static_cast<float>(m_textureRect.top + m_textureRect.height) * yratio;
  552.      }
  553.  }
  554.  
  555. diff --git a/src/SFML/Graphics/Sprite.cpp b/src/SFML/Graphics/Sprite.cpp
  556. index a64f920..b625ac0 100644
  557. --- a/src/SFML/Graphics/Sprite.cpp
  558. +++ b/src/SFML/Graphics/Sprite.cpp
  559. @@ -161,9 +161,9 @@ void Sprite::updatePositions()
  560.  void Sprite::updateTexCoords()
  561.  {
  562.      float left   = static_cast<float>(m_textureRect.left);
  563. -    float right  = left + m_textureRect.width;
  564. +    float right  = left + static_cast<float>(m_textureRect.width);
  565.      float top    = static_cast<float>(m_textureRect.top);
  566. -    float bottom = top + m_textureRect.height;
  567. +    float bottom = top + static_cast<float>(m_textureRect.height);
  568.  
  569.      m_vertices[0].texCoords = Vector2f(left, top);
  570.      m_vertices[1].texCoords = Vector2f(left, bottom);
  571. diff --git a/src/SFML/Graphics/Text.cpp b/src/SFML/Graphics/Text.cpp
  572. index ec9128c..745bb7f 100644
  573. --- a/src/SFML/Graphics/Text.cpp
  574. +++ b/src/SFML/Graphics/Text.cpp
  575. @@ -241,8 +241,8 @@ void Text::updateGeometry()
  576.      bool  bold               = (m_style & Bold) != 0;
  577.      bool  underlined         = (m_style & Underlined) != 0;
  578.      float italic             = (m_style & Italic) ? 0.208f : 0.f; // 12 degrees
  579. -    float underlineOffset    = m_characterSize * 0.1f;
  580. -    float underlineThickness = m_characterSize * (bold ? 0.1f : 0.07f);
  581. +    float underlineOffset    = static_cast<float>(m_characterSize) * 0.1f;
  582. +    float underlineThickness = static_cast<float>(m_characterSize) * (bold ? 0.1f : 0.07f);
  583.  
  584.      // Precompute the variables needed by the algorithm
  585.      float hspace = static_cast<float>(m_font->getGlyph(L' ', m_characterSize, bold).advance);
  586. @@ -304,10 +304,10 @@ void Text::updateGeometry()
  587.          // Extract the current glyph's description
  588.          const Glyph& glyph = m_font->getGlyph(curChar, m_characterSize, bold);
  589.  
  590. -        int left   = glyph.bounds.left;
  591. -        int top    = glyph.bounds.top;
  592. -        int right  = glyph.bounds.left + glyph.bounds.width;
  593. -        int bottom = glyph.bounds.top  + glyph.bounds.height;
  594. +        float left   = static_cast<float>(glyph.bounds.left);
  595. +        float top    = static_cast<float>(glyph.bounds.top);
  596. +        float right  = static_cast<float>(glyph.bounds.left + glyph.bounds.width);
  597. +        float bottom = static_cast<float>(glyph.bounds.top  + glyph.bounds.height);
  598.  
  599.          float u1 = static_cast<float>(glyph.textureRect.left);
  600.          float v1 = static_cast<float>(glyph.textureRect.top);
  601. @@ -329,7 +329,7 @@ void Text::updateGeometry()
  602.          maxY = std::max(maxY, y + bottom);
  603.  
  604.          // Advance to the next character
  605. -        x += glyph.advance;
  606. +        x += static_cast<float>(glyph.advance);
  607.      }
  608.  
  609.      // If we're using the underlined style, add the last line
  610. diff --git a/src/SFML/Graphics/Texture.cpp b/src/SFML/Graphics/Texture.cpp
  611. index 322f18e..1097f90 100644
  612. --- a/src/SFML/Graphics/Texture.cpp
  613. +++ b/src/SFML/Graphics/Texture.cpp
  614. @@ -485,15 +485,15 @@ void Texture::bind(const Texture* texture, CoordinateType coordinateType)
  615.              // setup scale factors that convert the range [0 .. size] to [0 .. 1]
  616.              if (coordinateType == Pixels)
  617.              {
  618. -                matrix[0] = 1.f / texture->m_actualSize.x;
  619. -                matrix[5] = 1.f / texture->m_actualSize.y;
  620. +                matrix[0] = 1.f / static_cast<float>(texture->m_actualSize.x);
  621. +                matrix[5] = 1.f / static_cast<float>(texture->m_actualSize.y);
  622.              }
  623.  
  624.              // If pixels are flipped we must invert the Y axis
  625.              if (texture->m_pixelsFlipped)
  626.              {
  627.                  matrix[5] = -matrix[5];
  628. -                matrix[13] = static_cast<float>(texture->m_size.y) / texture->m_actualSize.y;
  629. +                matrix[13] = static_cast<float>(texture->m_size.y) / static_cast<float>(texture->m_actualSize.y);
  630.              }
  631.  
  632.              // Load the matrix
  633. diff --git a/src/SFML/Graphics/Transform.cpp b/src/SFML/Graphics/Transform.cpp
  634. index 6da0b51..10049cb 100644
  635. --- a/src/SFML/Graphics/Transform.cpp
  636. +++ b/src/SFML/Graphics/Transform.cpp
  637. @@ -27,6 +27,7 @@
  638.  ////////////////////////////////////////////////////////////
  639.  #include <SFML/Graphics/Transform.hpp>
  640.  #include <cmath>
  641. +#include <limits>
  642.  
  643.  
  644.  namespace sf
  645. @@ -75,7 +76,8 @@ Transform Transform::getInverse() const
  646.  
  647.      // Compute the inverse if the determinant is not zero
  648.      // (don't use an epsilon because the determinant may *really* be tiny)
  649. -    if (det != 0.f)
  650. +    // (instead, compare against the smallest representable positive value)
  651. +    if (std::abs(det) >= std::numeric_limits<float>::min())
  652.      {
  653.          return Transform( (m_matrix[15] * m_matrix[5] - m_matrix[7] * m_matrix[13]) / det,
  654.                           -(m_matrix[15] * m_matrix[4] - m_matrix[7] * m_matrix[12]) / det,
  655. diff --git a/src/SFML/Network/Ftp.cpp b/src/SFML/Network/Ftp.cpp
  656. index 079e655..40089ae 100644
  657. --- a/src/SFML/Network/Ftp.cpp
  658. +++ b/src/SFML/Network/Ftp.cpp
  659. @@ -546,7 +546,7 @@ Ftp::Response Ftp::DataChannel::open(Ftp::TransferMode mode)
  660.                  // Extract the current number
  661.                  while (isdigit(str[index]))
  662.                  {
  663. -                    data[i] = data[i] * 10 + (str[index] - '0');
  664. +                    data[i] = static_cast<Uint8>(data[i] * 10 + (str[index] - '0'));
  665.                      index++;
  666.                  }
  667.  
  668. @@ -555,7 +555,7 @@ Ftp::Response Ftp::DataChannel::open(Ftp::TransferMode mode)
  669.              }
  670.  
  671.              // Reconstruct connection port and address
  672. -            unsigned short port = data[4] * 256 + data[5];
  673. +            unsigned short port = static_cast<unsigned short>(data[4] * 256 + data[5]);
  674.              IpAddress address(static_cast<Uint8>(data[0]),
  675.                                static_cast<Uint8>(data[1]),
  676.                                static_cast<Uint8>(data[2]),
  677. diff --git a/src/SFML/System/Time.cpp b/src/SFML/System/Time.cpp
  678. index b41ae9d..1e6fb0c 100644
  679. --- a/src/SFML/System/Time.cpp
  680. +++ b/src/SFML/System/Time.cpp
  681. @@ -44,7 +44,7 @@ m_microseconds(0)
  682.  ////////////////////////////////////////////////////////////
  683.  float Time::asSeconds() const
  684.  {
  685. -    return m_microseconds / 1000000.f;
  686. +    return static_cast<float>(m_microseconds) / 1000000.f;
  687.  }
  688.  
  689.  
  690. diff --git a/src/SFML/Window/Win32/InputImpl.cpp b/src/SFML/Window/Win32/InputImpl.cpp
  691. index f38ada7..1f2bc8e 100644
  692. --- a/src/SFML/Window/Win32/InputImpl.cpp
  693. +++ b/src/SFML/Window/Win32/InputImpl.cpp
  694. @@ -157,7 +157,7 @@ bool InputImpl::isKeyPressed(Keyboard::Key key)
  695.  
  696.  
  697.  ////////////////////////////////////////////////////////////
  698. -void InputImpl::setVirtualKeyboardVisible(bool visible)
  699. +void InputImpl::setVirtualKeyboardVisible(bool /*visible*/)
  700.  {
  701.      // Not applicable
  702.  }
  703. diff --git a/src/SFML/Window/Win32/JoystickImpl.cpp b/src/SFML/Window/Win32/JoystickImpl.cpp
  704. index 7f2bec2..3c86d55 100644
  705. --- a/src/SFML/Window/Win32/JoystickImpl.cpp
  706. +++ b/src/SFML/Window/Win32/JoystickImpl.cpp
  707. @@ -156,17 +156,17 @@ JoystickState JoystickImpl::update()
  708.          state.connected = true;
  709.  
  710.          // Axes
  711. -        state.axes[Joystick::X] = (pos.dwXpos - (m_caps.wXmax + m_caps.wXmin) / 2.f) * 200.f / (m_caps.wXmax - m_caps.wXmin);
  712. -        state.axes[Joystick::Y] = (pos.dwYpos - (m_caps.wYmax + m_caps.wYmin) / 2.f) * 200.f / (m_caps.wYmax - m_caps.wYmin);
  713. -        state.axes[Joystick::Z] = (pos.dwZpos - (m_caps.wZmax + m_caps.wZmin) / 2.f) * 200.f / (m_caps.wZmax - m_caps.wZmin);
  714. -        state.axes[Joystick::R] = (pos.dwRpos - (m_caps.wRmax + m_caps.wRmin) / 2.f) * 200.f / (m_caps.wRmax - m_caps.wRmin);
  715. -        state.axes[Joystick::U] = (pos.dwUpos - (m_caps.wUmax + m_caps.wUmin) / 2.f) * 200.f / (m_caps.wUmax - m_caps.wUmin);
  716. -        state.axes[Joystick::V] = (pos.dwVpos - (m_caps.wVmax + m_caps.wVmin) / 2.f) * 200.f / (m_caps.wVmax - m_caps.wVmin);
  717. +        state.axes[Joystick::X] = (static_cast<float>(pos.dwXpos - (m_caps.wXmax + m_caps.wXmin)) / 2.f) * 200.f / static_cast<float>(m_caps.wXmax - m_caps.wXmin);
  718. +        state.axes[Joystick::Y] = (static_cast<float>(pos.dwYpos - (m_caps.wYmax + m_caps.wYmin)) / 2.f) * 200.f / static_cast<float>(m_caps.wYmax - m_caps.wYmin);
  719. +        state.axes[Joystick::Z] = (static_cast<float>(pos.dwZpos - (m_caps.wZmax + m_caps.wZmin)) / 2.f) * 200.f / static_cast<float>(m_caps.wZmax - m_caps.wZmin);
  720. +        state.axes[Joystick::R] = (static_cast<float>(pos.dwRpos - (m_caps.wRmax + m_caps.wRmin)) / 2.f) * 200.f / static_cast<float>(m_caps.wRmax - m_caps.wRmin);
  721. +        state.axes[Joystick::U] = (static_cast<float>(pos.dwUpos - (m_caps.wUmax + m_caps.wUmin)) / 2.f) * 200.f / static_cast<float>(m_caps.wUmax - m_caps.wUmin);
  722. +        state.axes[Joystick::V] = (static_cast<float>(pos.dwVpos - (m_caps.wVmax + m_caps.wVmin)) / 2.f) * 200.f / static_cast<float>(m_caps.wVmax - m_caps.wVmin);
  723.  
  724.          // Special case for POV, it is given as an angle
  725.          if (pos.dwPOV != 0xFFFF)
  726.          {
  727. -            float angle = pos.dwPOV / 18000.f * 3.141592654f;
  728. +            float angle = static_cast<float>(pos.dwPOV) / 18000.f * 3.141592654f;
  729.              state.axes[Joystick::PovX] = std::sin(angle) * 100;
  730.              state.axes[Joystick::PovY] = std::cos(angle) * 100;
  731.          }
  732. diff --git a/src/SFML/Window/Window.cpp b/src/SFML/Window/Window.cpp
  733. index 658c7ff..ce8638f 100644
  734. --- a/src/SFML/Window/Window.cpp
  735. +++ b/src/SFML/Window/Window.cpp
  736. @@ -299,7 +299,7 @@ void Window::setKeyRepeatEnabled(bool enabled)
  737.  void Window::setFramerateLimit(unsigned int limit)
  738.  {
  739.      if (limit > 0)
  740. -        m_frameTimeLimit = seconds(1.f / limit);
  741. +        m_frameTimeLimit = seconds(1.f / static_cast<float>(limit));
  742.      else
  743.          m_frameTimeLimit = Time::Zero;
  744.  }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement