Fix remaining warnings

- Fixes in examples
- Fixes across all the modules
This commit is contained in:
Vittorio Romeo 2021-11-19 01:15:57 +00:00 committed by Lukas Dürrenberger
parent c74694c3b2
commit 6cf124db66
30 changed files with 476 additions and 140 deletions

View File

@ -31,37 +31,60 @@ function(set_file_warnings)
# Disables, remove when appropriate
/wd4996 # disable warnings about deprecated functions
/wd4068 # disable warnings about unknown pragmas (e.g. #pragma GCC)
/wd4505 # disable warnings about unused functions that might be platform-specific
/wd4800 # disable warnings regarding implicit conversions to bool
)
set(CLANG_WARNINGS
# some warnings are not supported on older NDK versions used for CI
if (ANDROID)
set(NON_ANDROID_CLANG_AND_GCC_WARNINGS "")
set(NON_ANDROID_GCC_WARNINGS "")
else()
set(NON_ANDROID_CLANG_AND_GCC_WARNINGS
-Wnull-dereference # warn if a null dereference is detected
-Wold-style-cast # warn for c-style casts
-Wpedantic # warn if non-standard C++ is used
)
set(NON_ANDROID_GCC_WARNINGS
-Wmisleading-indentation # warn if indentation implies blocks where blocks do not exist
-Wduplicated-cond # warn if if / else chain has duplicated conditions
)
endif()
set(CLANG_AND_GCC_WARNINGS
-Wall
-Wextra # reasonable and standard
-Wshadow # warn the user if a variable declaration shadows one from a parent context
-Wnon-virtual-dtor # warn the user if a class with virtual functions has a non-virtual destructor. This helps catch hard to track down memory errors
-Wold-style-cast # warn for c-style casts
-Wcast-align # warn for potential performance problem casts
-Wunused # warn on anything being unused
-Woverloaded-virtual # warn if you overload (not override) a virtual function
-Wpedantic # warn if non-standard C++ is used
-Wconversion # warn on type conversions that may lose data
-Wsign-conversion # warn on sign conversions
-Wnull-dereference # warn if a null dereference is detected
-Wdouble-promotion # warn if float is implicit promoted to double
-Wformat=2 # warn on security issues around functions that format output (ie printf)
# -Wimplicit-fallthrough # warn when a missing break causes control flow to continue at the next case in a switch statement. Disabled until better compiler support for explicit fallthrough is available.
# -Wimplicit-fallthrough # warn when a missing break causes control flow to continue at the next case in a switch statement (disabled until better compiler support for explicit fallthrough is available)
${NON_ANDROID_CLANG_AND_GCC_WARNINGS}
)
set(CLANG_WARNINGS
${CLANG_AND_GCC_WARNINGS}
-Wno-unknown-warning-option # do not warn on GCC-specific warning diagnostic pragmas
)
if(WARNINGS_AS_ERRORS)
set(CLANG_WARNINGS ${CLANG_WARNINGS} -Werror)
set(CLANG_AND_GCC_WARNINGS ${CLANG_AND_GCC_WARNINGS} -Werror)
set(MSVC_WARNINGS ${MSVC_WARNINGS} /WX)
endif()
set(GCC_WARNINGS
${CLANG_WARNINGS}
-Wmisleading-indentation # warn if indentation implies blocks where blocks do not exist
-Wduplicated-cond # warn if if / else chain has duplicated conditions
${CLANG_AND_GCC_WARNINGS}
${NON_ANDROID_GCC_WARNINGS}
-Wlogical-op # warn about logical operations being used where bitwise were probably wanted
-Wuseless-cast # warn if you perform a cast to the same type
# -Wuseless-cast # warn if you perform a cast to the same type (disabled because it is not portable as some typedefs might vary between platforms)
)
# Don't enable -Wduplicated-branches for GCC < 8.1 since it will lead to false positives

View File

@ -322,16 +322,23 @@ float getMoisture(unsigned int x, unsigned int y)
/// Get the lowlands terrain color for the given moisture.
///
////////////////////////////////////////////////////////////
sf::Color colorFromFloats(float r, float g, float b)
{
return sf::Color(static_cast<sf::Uint8>(r),
static_cast<sf::Uint8>(g),
static_cast<sf::Uint8>(b));
}
sf::Color getLowlandsTerrainColor(float moisture)
{
sf::Color color =
moisture < 0.27f ? sf::Color(240, 240, 180) :
moisture < 0.3f ? sf::Color(240 - static_cast<sf::Uint8>(240 * (moisture - 0.27f) / 0.03f), 240 - static_cast<sf::Uint8>(40 * (moisture - 0.27f) / 0.03f), 180 - static_cast<sf::Uint8>(180 * (moisture - 0.27f) / 0.03f)) :
moisture < 0.4f ? sf::Color(0, 200, 0) :
moisture < 0.48f ? sf::Color(0, 200 - static_cast<sf::Uint8>(40 * (moisture - 0.4f) / 0.08f), 0) :
moisture < 0.6f ? sf::Color(0, 160, 0) :
moisture < 0.7f ? sf::Color(static_cast<sf::Uint8>(34 * (moisture - 0.6f) / 0.1f), 160 - static_cast<sf::Uint8>(60 * (moisture - 0.6f) / 0.1f), static_cast<sf::Uint8>(34 * (moisture - 0.6f) / 0.1f)) :
sf::Color(34, 100, 34);
moisture < 0.27f ? colorFromFloats(240, 240, 180) :
moisture < 0.3f ? colorFromFloats(240 - (240 * (moisture - 0.27f) / 0.03f), 240 - (40 * (moisture - 0.27f) / 0.03f), 180 - (180 * (moisture - 0.27f) / 0.03f)) :
moisture < 0.4f ? colorFromFloats(0, 200, 0) :
moisture < 0.48f ? colorFromFloats(0, 200 - (40 * (moisture - 0.4f) / 0.08f), 0) :
moisture < 0.6f ? colorFromFloats(0, 160, 0) :
moisture < 0.7f ? colorFromFloats((34 * (moisture - 0.6f) / 0.1f), 160 - (60 * (moisture - 0.6f) / 0.1f), (34 * (moisture - 0.6f) / 0.1f)) :
colorFromFloats(34, 100, 34);
return color;
}
@ -348,7 +355,7 @@ sf::Color getHighlandsTerrainColor(float elevation, float moisture)
sf::Color color =
moisture < 0.6f ? sf::Color(112, 128, 144) :
sf::Color(112 + static_cast<sf::Uint8>(110 * (moisture - 0.6f) / 0.4f), 128 + static_cast<sf::Uint8>(56 * (moisture - 0.6f) / 0.4f), 144 - static_cast<sf::Uint8>(9 * (moisture - 0.6f) / 0.4f));
colorFromFloats(112 + (110 * (moisture - 0.6f) / 0.4f), 128 + (56 * (moisture - 0.6f) / 0.4f), 144 - (9 * (moisture - 0.6f) / 0.4f));
float factor = std::min((elevation - 0.4f) / 0.1f, 1.f);

View File

@ -33,13 +33,13 @@ int main()
// Define some constants
const float pi = 3.14159f;
const int gameWidth = 800;
const int gameHeight = 600;
const float gameWidth = 800;
const float gameHeight = 600;
sf::Vector2f paddleSize(25, 100);
float ballRadius = 10.f;
// Create the window of the application
sf::RenderWindow window(sf::VideoMode(gameWidth, gameHeight, 32), "SFML Tennis",
sf::RenderWindow window(sf::VideoMode(static_cast<unsigned int>(gameWidth), static_cast<unsigned int>(gameHeight), 32), "SFML Tennis",
sf::Style::Titlebar | sf::Style::Close);
window.setVerticalSyncEnabled(true);
@ -134,15 +134,15 @@ int main()
clock.restart();
// Reset the position of the paddles and ball
leftPaddle.setPosition(10 + paddleSize.x / 2, gameHeight / 2);
rightPaddle.setPosition(gameWidth - 10 - paddleSize.x / 2, gameHeight / 2);
ball.setPosition(gameWidth / 2, gameHeight / 2);
leftPaddle.setPosition(10.f + paddleSize.x / 2.f, gameHeight / 2.f);
rightPaddle.setPosition(gameWidth - 10.f - paddleSize.x / 2.f, gameHeight / 2.f);
ball.setPosition(gameWidth / 2.f, gameHeight / 2.f);
// Reset the ball angle
do
{
// Make sure the ball initial angle is not too much vertical
ballAngle = static_cast<float>(std::rand() % 360) * 2 * pi / 360;
ballAngle = static_cast<float>(std::rand() % 360) * 2.f * pi / 360.f;
}
while (std::abs(std::cos(ballAngle)) < 0.7f);
}
@ -153,7 +153,7 @@ int main()
{
sf::View view;
view.setSize(gameWidth, gameHeight);
view.setCenter(gameWidth/2.f, gameHeight/2.f);
view.setCenter(gameWidth / 2.f, gameHeight /2.f);
window.setView(view);
}
}

View File

@ -4,6 +4,7 @@
////////////////////////////////////////////////////////////
#include <SFML/Audio.hpp>
#include <SFML/Network.hpp>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
@ -126,14 +127,15 @@ private:
if (id == serverAudioData)
{
// Extract audio samples from the packet, and append it to our samples buffer
const sf::Int16* samples = reinterpret_cast<const sf::Int16*>(static_cast<const char*>(packet.getData()) + 1);
std::size_t sampleCount = (packet.getDataSize() - 1) / sizeof(sf::Int16);
std::size_t sampleCount = (packet.getDataSize() - 1) / sizeof(sf::Int16);
// Don't forget that the other thread can access the sample array at any time
// (so we protect any operation on it with the mutex)
{
sf::Lock lock(m_mutex);
std::copy(samples, samples + sampleCount, std::back_inserter(m_samples));
std::size_t oldSize = m_samples.size();
m_samples.resize(oldSize + sampleCount);
std::memcpy(&(m_samples[oldSize]), static_cast<const char*>(packet.getData()) + 1, sampleCount * sizeof(sf::Int16));
}
}
else if (id == serverEndOfStream)

View File

@ -894,7 +894,7 @@ public:
return;
}
std::vector<char> buffer(static_cast<std::size_t>(file.getSize()));
std::vector<uint32_t> buffer(static_cast<std::size_t>(file.getSize()) / sizeof(uint32_t));
if (file.read(&buffer[0], file.getSize()) != file.getSize())
{
@ -902,8 +902,8 @@ public:
return;
}
shaderModuleCreateInfo.codeSize = buffer.size();
shaderModuleCreateInfo.pCode = reinterpret_cast<const uint32_t*>(&buffer[0]);
shaderModuleCreateInfo.codeSize = buffer.size() * sizeof(uint32_t);
shaderModuleCreateInfo.pCode = &buffer[0];
if (vkCreateShaderModule(device, &shaderModuleCreateInfo, 0, &vertexShaderModule) != VK_SUCCESS)
{
@ -922,7 +922,7 @@ public:
return;
}
std::vector<char> buffer(static_cast<std::size_t>(file.getSize()));
std::vector<uint32_t> buffer(static_cast<std::size_t>(file.getSize()) / sizeof(uint32_t));
if (file.read(&buffer[0], file.getSize()) != file.getSize())
{
@ -930,8 +930,8 @@ public:
return;
}
shaderModuleCreateInfo.codeSize = buffer.size();
shaderModuleCreateInfo.pCode = reinterpret_cast<const uint32_t*>(&buffer[0]);
shaderModuleCreateInfo.codeSize = buffer.size() * sizeof(uint32_t);
shaderModuleCreateInfo.pCode = &buffer[0];
if (vkCreateShaderModule(device, &shaderModuleCreateInfo, 0, &fragmentShaderModule) != VK_SUCCESS)
{
@ -1277,7 +1277,7 @@ public:
for (; memoryType < memoryProperties.memoryTypeCount; memoryType++)
{
if ((memoryRequirements.memoryTypeBits & (1 << memoryType)) &&
if ((memoryRequirements.memoryTypeBits & static_cast<unsigned int>(1 << memoryType)) &&
((memoryProperties.memoryTypes[memoryType].propertyFlags & properties) == properties))
break;
}
@ -1599,7 +1599,7 @@ public:
for (; memoryType < memoryProperties.memoryTypeCount; memoryType++)
{
if ((memoryRequirements.memoryTypeBits & (1 << memoryType)) &&
if ((memoryRequirements.memoryTypeBits & static_cast<unsigned int>(1 << memoryType)) &&
((memoryProperties.memoryTypes[memoryType].propertyFlags & properties) == properties))
break;
}
@ -1777,7 +1777,7 @@ public:
}
// Copy the image data into the buffer
std::memcpy(ptr, imageData.getPixelsPtr(), imageSize);
std::memcpy(ptr, imageData.getPixelsPtr(), static_cast<std::size_t>(imageSize));
// Unmap the buffer
vkUnmapMemory(device, stagingBufferMemory);

View File

@ -10128,6 +10128,153 @@ static void sf_glad_gl_load_GL_VERSION_4_6( GLADuserptrloadfunc load, void* user
sf_glad_glPolygonOffsetClamp = (PFNGLPOLYGONOFFSETCLAMPPROC) load(userptr, "glPolygonOffsetClamp");
sf_glad_glSpecializeShader = (PFNGLSPECIALIZESHADERPROC) load(userptr, "glSpecializeShader");
}
static void sf_glad_gl_load_GL_VERSION_ES_CM_1_0( GLADuserptrloadfunc load, void* userptr) {
if(!SF_GLAD_GL_VERSION_ES_CM_1_0) return;
sf_glad_glActiveTexture = (PFNGLACTIVETEXTUREPROC) load(userptr, "glActiveTexture");
sf_glad_glAlphaFunc = (PFNGLALPHAFUNCPROC) load(userptr, "glAlphaFunc");
sf_glad_glAlphaFuncx = (PFNGLALPHAFUNCXPROC) load(userptr, "glAlphaFuncx");
sf_glad_glBindBuffer = (PFNGLBINDBUFFERPROC) load(userptr, "glBindBuffer");
sf_glad_glBindTexture = (PFNGLBINDTEXTUREPROC) load(userptr, "glBindTexture");
sf_glad_glBlendFunc = (PFNGLBLENDFUNCPROC) load(userptr, "glBlendFunc");
sf_glad_glBufferData = (PFNGLBUFFERDATAPROC) load(userptr, "glBufferData");
sf_glad_glBufferSubData = (PFNGLBUFFERSUBDATAPROC) load(userptr, "glBufferSubData");
sf_glad_glClear = (PFNGLCLEARPROC) load(userptr, "glClear");
sf_glad_glClearColor = (PFNGLCLEARCOLORPROC) load(userptr, "glClearColor");
sf_glad_glClearColorx = (PFNGLCLEARCOLORXPROC) load(userptr, "glClearColorx");
sf_glad_glClearDepthf = (PFNGLCLEARDEPTHFPROC) load(userptr, "glClearDepthf");
sf_glad_glClearDepthx = (PFNGLCLEARDEPTHXPROC) load(userptr, "glClearDepthx");
sf_glad_glClearStencil = (PFNGLCLEARSTENCILPROC) load(userptr, "glClearStencil");
sf_glad_glClientActiveTexture = (PFNGLCLIENTACTIVETEXTUREPROC) load(userptr, "glClientActiveTexture");
sf_glad_glClipPlanef = (PFNGLCLIPPLANEFPROC) load(userptr, "glClipPlanef");
sf_glad_glClipPlanex = (PFNGLCLIPPLANEXPROC) load(userptr, "glClipPlanex");
sf_glad_glColor4f = (PFNGLCOLOR4FPROC) load(userptr, "glColor4f");
sf_glad_glColor4ub = (PFNGLCOLOR4UBPROC) load(userptr, "glColor4ub");
sf_glad_glColor4x = (PFNGLCOLOR4XPROC) load(userptr, "glColor4x");
sf_glad_glColorMask = (PFNGLCOLORMASKPROC) load(userptr, "glColorMask");
sf_glad_glColorPointer = (PFNGLCOLORPOINTERPROC) load(userptr, "glColorPointer");
sf_glad_glCompressedTexImage2D = (PFNGLCOMPRESSEDTEXIMAGE2DPROC) load(userptr, "glCompressedTexImage2D");
sf_glad_glCompressedTexSubImage2D = (PFNGLCOMPRESSEDTEXSUBIMAGE2DPROC) load(userptr, "glCompressedTexSubImage2D");
sf_glad_glCopyTexImage2D = (PFNGLCOPYTEXIMAGE2DPROC) load(userptr, "glCopyTexImage2D");
sf_glad_glCopyTexSubImage2D = (PFNGLCOPYTEXSUBIMAGE2DPROC) load(userptr, "glCopyTexSubImage2D");
sf_glad_glCullFace = (PFNGLCULLFACEPROC) load(userptr, "glCullFace");
sf_glad_glDeleteBuffers = (PFNGLDELETEBUFFERSPROC) load(userptr, "glDeleteBuffers");
sf_glad_glDeleteTextures = (PFNGLDELETETEXTURESPROC) load(userptr, "glDeleteTextures");
sf_glad_glDepthFunc = (PFNGLDEPTHFUNCPROC) load(userptr, "glDepthFunc");
sf_glad_glDepthMask = (PFNGLDEPTHMASKPROC) load(userptr, "glDepthMask");
sf_glad_glDepthRangef = (PFNGLDEPTHRANGEFPROC) load(userptr, "glDepthRangef");
sf_glad_glDepthRangex = (PFNGLDEPTHRANGEXPROC) load(userptr, "glDepthRangex");
sf_glad_glDisable = (PFNGLDISABLEPROC) load(userptr, "glDisable");
sf_glad_glDisableClientState = (PFNGLDISABLECLIENTSTATEPROC) load(userptr, "glDisableClientState");
sf_glad_glDrawArrays = (PFNGLDRAWARRAYSPROC) load(userptr, "glDrawArrays");
sf_glad_glDrawElements = (PFNGLDRAWELEMENTSPROC) load(userptr, "glDrawElements");
sf_glad_glEnable = (PFNGLENABLEPROC) load(userptr, "glEnable");
sf_glad_glEnableClientState = (PFNGLENABLECLIENTSTATEPROC) load(userptr, "glEnableClientState");
sf_glad_glFinish = (PFNGLFINISHPROC) load(userptr, "glFinish");
sf_glad_glFlush = (PFNGLFLUSHPROC) load(userptr, "glFlush");
sf_glad_glFogf = (PFNGLFOGFPROC) load(userptr, "glFogf");
sf_glad_glFogfv = (PFNGLFOGFVPROC) load(userptr, "glFogfv");
sf_glad_glFogx = (PFNGLFOGXPROC) load(userptr, "glFogx");
sf_glad_glFogxv = (PFNGLFOGXVPROC) load(userptr, "glFogxv");
sf_glad_glFrontFace = (PFNGLFRONTFACEPROC) load(userptr, "glFrontFace");
sf_glad_glFrustumf = (PFNGLFRUSTUMFPROC) load(userptr, "glFrustumf");
sf_glad_glFrustumx = (PFNGLFRUSTUMXPROC) load(userptr, "glFrustumx");
sf_glad_glGenBuffers = (PFNGLGENBUFFERSPROC) load(userptr, "glGenBuffers");
sf_glad_glGenTextures = (PFNGLGENTEXTURESPROC) load(userptr, "glGenTextures");
sf_glad_glGetBooleanv = (PFNGLGETBOOLEANVPROC) load(userptr, "glGetBooleanv");
sf_glad_glGetBufferParameteriv = (PFNGLGETBUFFERPARAMETERIVPROC) load(userptr, "glGetBufferParameteriv");
sf_glad_glGetClipPlanef = (PFNGLGETCLIPPLANEFPROC) load(userptr, "glGetClipPlanef");
sf_glad_glGetClipPlanex = (PFNGLGETCLIPPLANEXPROC) load(userptr, "glGetClipPlanex");
sf_glad_glGetError = (PFNGLGETERRORPROC) load(userptr, "glGetError");
sf_glad_glGetFixedv = (PFNGLGETFIXEDVPROC) load(userptr, "glGetFixedv");
sf_glad_glGetFloatv = (PFNGLGETFLOATVPROC) load(userptr, "glGetFloatv");
sf_glad_glGetIntegerv = (PFNGLGETINTEGERVPROC) load(userptr, "glGetIntegerv");
sf_glad_glGetLightfv = (PFNGLGETLIGHTFVPROC) load(userptr, "glGetLightfv");
sf_glad_glGetLightxv = (PFNGLGETLIGHTXVPROC) load(userptr, "glGetLightxv");
sf_glad_glGetMaterialfv = (PFNGLGETMATERIALFVPROC) load(userptr, "glGetMaterialfv");
sf_glad_glGetMaterialxv = (PFNGLGETMATERIALXVPROC) load(userptr, "glGetMaterialxv");
sf_glad_glGetPointerv = (PFNGLGETPOINTERVPROC) load(userptr, "glGetPointerv");
sf_glad_glGetString = (PFNGLGETSTRINGPROC) load(userptr, "glGetString");
sf_glad_glGetTexEnvfv = (PFNGLGETTEXENVFVPROC) load(userptr, "glGetTexEnvfv");
sf_glad_glGetTexEnviv = (PFNGLGETTEXENVIVPROC) load(userptr, "glGetTexEnviv");
sf_glad_glGetTexEnvxv = (PFNGLGETTEXENVXVPROC) load(userptr, "glGetTexEnvxv");
sf_glad_glGetTexParameterfv = (PFNGLGETTEXPARAMETERFVPROC) load(userptr, "glGetTexParameterfv");
sf_glad_glGetTexParameteriv = (PFNGLGETTEXPARAMETERIVPROC) load(userptr, "glGetTexParameteriv");
sf_glad_glGetTexParameterxv = (PFNGLGETTEXPARAMETERXVPROC) load(userptr, "glGetTexParameterxv");
sf_glad_glHint = (PFNGLHINTPROC) load(userptr, "glHint");
sf_glad_glIsBuffer = (PFNGLISBUFFERPROC) load(userptr, "glIsBuffer");
sf_glad_glIsEnabled = (PFNGLISENABLEDPROC) load(userptr, "glIsEnabled");
sf_glad_glIsTexture = (PFNGLISTEXTUREPROC) load(userptr, "glIsTexture");
sf_glad_glLightModelf = (PFNGLLIGHTMODELFPROC) load(userptr, "glLightModelf");
sf_glad_glLightModelfv = (PFNGLLIGHTMODELFVPROC) load(userptr, "glLightModelfv");
sf_glad_glLightModelx = (PFNGLLIGHTMODELXPROC) load(userptr, "glLightModelx");
sf_glad_glLightModelxv = (PFNGLLIGHTMODELXVPROC) load(userptr, "glLightModelxv");
sf_glad_glLightf = (PFNGLLIGHTFPROC) load(userptr, "glLightf");
sf_glad_glLightfv = (PFNGLLIGHTFVPROC) load(userptr, "glLightfv");
sf_glad_glLightx = (PFNGLLIGHTXPROC) load(userptr, "glLightx");
sf_glad_glLightxv = (PFNGLLIGHTXVPROC) load(userptr, "glLightxv");
sf_glad_glLineWidth = (PFNGLLINEWIDTHPROC) load(userptr, "glLineWidth");
sf_glad_glLineWidthx = (PFNGLLINEWIDTHXPROC) load(userptr, "glLineWidthx");
sf_glad_glLoadIdentity = (PFNGLLOADIDENTITYPROC) load(userptr, "glLoadIdentity");
sf_glad_glLoadMatrixf = (PFNGLLOADMATRIXFPROC) load(userptr, "glLoadMatrixf");
sf_glad_glLoadMatrixx = (PFNGLLOADMATRIXXPROC) load(userptr, "glLoadMatrixx");
sf_glad_glLogicOp = (PFNGLLOGICOPPROC) load(userptr, "glLogicOp");
sf_glad_glMaterialf = (PFNGLMATERIALFPROC) load(userptr, "glMaterialf");
sf_glad_glMaterialfv = (PFNGLMATERIALFVPROC) load(userptr, "glMaterialfv");
sf_glad_glMaterialx = (PFNGLMATERIALXPROC) load(userptr, "glMaterialx");
sf_glad_glMaterialxv = (PFNGLMATERIALXVPROC) load(userptr, "glMaterialxv");
sf_glad_glMatrixMode = (PFNGLMATRIXMODEPROC) load(userptr, "glMatrixMode");
sf_glad_glMultMatrixf = (PFNGLMULTMATRIXFPROC) load(userptr, "glMultMatrixf");
sf_glad_glMultMatrixx = (PFNGLMULTMATRIXXPROC) load(userptr, "glMultMatrixx");
sf_glad_glMultiTexCoord4f = (PFNGLMULTITEXCOORD4FPROC) load(userptr, "glMultiTexCoord4f");
sf_glad_glMultiTexCoord4x = (PFNGLMULTITEXCOORD4XPROC) load(userptr, "glMultiTexCoord4x");
sf_glad_glNormal3f = (PFNGLNORMAL3FPROC) load(userptr, "glNormal3f");
sf_glad_glNormal3x = (PFNGLNORMAL3XPROC) load(userptr, "glNormal3x");
sf_glad_glNormalPointer = (PFNGLNORMALPOINTERPROC) load(userptr, "glNormalPointer");
sf_glad_glOrthof = (PFNGLORTHOFPROC) load(userptr, "glOrthof");
sf_glad_glOrthox = (PFNGLORTHOXPROC) load(userptr, "glOrthox");
sf_glad_glPixelStorei = (PFNGLPIXELSTOREIPROC) load(userptr, "glPixelStorei");
sf_glad_glPointParameterf = (PFNGLPOINTPARAMETERFPROC) load(userptr, "glPointParameterf");
sf_glad_glPointParameterfv = (PFNGLPOINTPARAMETERFVPROC) load(userptr, "glPointParameterfv");
sf_glad_glPointParameterx = (PFNGLPOINTPARAMETERXPROC) load(userptr, "glPointParameterx");
sf_glad_glPointParameterxv = (PFNGLPOINTPARAMETERXVPROC) load(userptr, "glPointParameterxv");
sf_glad_glPointSize = (PFNGLPOINTSIZEPROC) load(userptr, "glPointSize");
sf_glad_glPointSizex = (PFNGLPOINTSIZEXPROC) load(userptr, "glPointSizex");
sf_glad_glPolygonOffset = (PFNGLPOLYGONOFFSETPROC) load(userptr, "glPolygonOffset");
sf_glad_glPolygonOffsetx = (PFNGLPOLYGONOFFSETXPROC) load(userptr, "glPolygonOffsetx");
sf_glad_glPopMatrix = (PFNGLPOPMATRIXPROC) load(userptr, "glPopMatrix");
sf_glad_glPushMatrix = (PFNGLPUSHMATRIXPROC) load(userptr, "glPushMatrix");
sf_glad_glReadPixels = (PFNGLREADPIXELSPROC) load(userptr, "glReadPixels");
sf_glad_glRotatef = (PFNGLROTATEFPROC) load(userptr, "glRotatef");
sf_glad_glRotatex = (PFNGLROTATEXPROC) load(userptr, "glRotatex");
sf_glad_glSampleCoverage = (PFNGLSAMPLECOVERAGEPROC) load(userptr, "glSampleCoverage");
sf_glad_glSampleCoveragex = (PFNGLSAMPLECOVERAGEXPROC) load(userptr, "glSampleCoveragex");
sf_glad_glScalef = (PFNGLSCALEFPROC) load(userptr, "glScalef");
sf_glad_glScalex = (PFNGLSCALEXPROC) load(userptr, "glScalex");
sf_glad_glScissor = (PFNGLSCISSORPROC) load(userptr, "glScissor");
sf_glad_glShadeModel = (PFNGLSHADEMODELPROC) load(userptr, "glShadeModel");
sf_glad_glStencilFunc = (PFNGLSTENCILFUNCPROC) load(userptr, "glStencilFunc");
sf_glad_glStencilMask = (PFNGLSTENCILMASKPROC) load(userptr, "glStencilMask");
sf_glad_glStencilOp = (PFNGLSTENCILOPPROC) load(userptr, "glStencilOp");
sf_glad_glTexCoordPointer = (PFNGLTEXCOORDPOINTERPROC) load(userptr, "glTexCoordPointer");
sf_glad_glTexEnvf = (PFNGLTEXENVFPROC) load(userptr, "glTexEnvf");
sf_glad_glTexEnvfv = (PFNGLTEXENVFVPROC) load(userptr, "glTexEnvfv");
sf_glad_glTexEnvi = (PFNGLTEXENVIPROC) load(userptr, "glTexEnvi");
sf_glad_glTexEnviv = (PFNGLTEXENVIVPROC) load(userptr, "glTexEnviv");
sf_glad_glTexEnvx = (PFNGLTEXENVXPROC) load(userptr, "glTexEnvx");
sf_glad_glTexEnvxv = (PFNGLTEXENVXVPROC) load(userptr, "glTexEnvxv");
sf_glad_glTexImage2D = (PFNGLTEXIMAGE2DPROC) load(userptr, "glTexImage2D");
sf_glad_glTexParameterf = (PFNGLTEXPARAMETERFPROC) load(userptr, "glTexParameterf");
sf_glad_glTexParameterfv = (PFNGLTEXPARAMETERFVPROC) load(userptr, "glTexParameterfv");
sf_glad_glTexParameteri = (PFNGLTEXPARAMETERIPROC) load(userptr, "glTexParameteri");
sf_glad_glTexParameteriv = (PFNGLTEXPARAMETERIVPROC) load(userptr, "glTexParameteriv");
sf_glad_glTexParameterx = (PFNGLTEXPARAMETERXPROC) load(userptr, "glTexParameterx");
sf_glad_glTexParameterxv = (PFNGLTEXPARAMETERXVPROC) load(userptr, "glTexParameterxv");
sf_glad_glTexSubImage2D = (PFNGLTEXSUBIMAGE2DPROC) load(userptr, "glTexSubImage2D");
sf_glad_glTranslatef = (PFNGLTRANSLATEFPROC) load(userptr, "glTranslatef");
sf_glad_glTranslatex = (PFNGLTRANSLATEXPROC) load(userptr, "glTranslatex");
sf_glad_glVertexPointer = (PFNGLVERTEXPOINTERPROC) load(userptr, "glVertexPointer");
sf_glad_glViewport = (PFNGLVIEWPORTPROC) load(userptr, "glViewport");
}
static void sf_glad_gl_load_GL_ARB_ES2_compatibility( GLADuserptrloadfunc load, void* userptr) {
if(!SF_GLAD_GL_ARB_ES2_compatibility) return;
sf_glad_glClearDepthf = (PFNGLCLEARDEPTHFPROC) load(userptr, "glClearDepthf");
@ -11147,6 +11294,36 @@ static void sf_glad_gl_load_GL_OES_single_precision( GLADuserptrloadfunc load, v
sf_glad_glGetClipPlanefOES = (PFNGLGETCLIPPLANEFOESPROC) load(userptr, "glGetClipPlanefOES");
sf_glad_glOrthofOES = (PFNGLORTHOFOESPROC) load(userptr, "glOrthofOES");
}
static void sf_glad_gl_load_GL_OES_blend_equation_separate( GLADuserptrloadfunc load, void* userptr) {
if(!SF_GLAD_GL_OES_blend_equation_separate) return;
sf_glad_glBlendEquationSeparateOES = (PFNGLBLENDEQUATIONSEPARATEOESPROC) load(userptr, "glBlendEquationSeparateOES");
}
static void sf_glad_gl_load_GL_OES_blend_func_separate( GLADuserptrloadfunc load, void* userptr) {
if(!SF_GLAD_GL_OES_blend_func_separate) return;
sf_glad_glBlendFuncSeparateOES = (PFNGLBLENDFUNCSEPARATEOESPROC) load(userptr, "glBlendFuncSeparateOES");
}
static void sf_glad_gl_load_GL_OES_blend_subtract( GLADuserptrloadfunc load, void* userptr) {
if(!SF_GLAD_GL_OES_blend_subtract) return;
sf_glad_glBlendEquationOES = (PFNGLBLENDEQUATIONOESPROC) load(userptr, "glBlendEquationOES");
}
static void sf_glad_gl_load_GL_OES_framebuffer_object( GLADuserptrloadfunc load, void* userptr) {
if(!SF_GLAD_GL_OES_framebuffer_object) return;
sf_glad_glBindFramebufferOES = (PFNGLBINDFRAMEBUFFEROESPROC) load(userptr, "glBindFramebufferOES");
sf_glad_glBindRenderbufferOES = (PFNGLBINDRENDERBUFFEROESPROC) load(userptr, "glBindRenderbufferOES");
sf_glad_glCheckFramebufferStatusOES = (PFNGLCHECKFRAMEBUFFERSTATUSOESPROC) load(userptr, "glCheckFramebufferStatusOES");
sf_glad_glDeleteFramebuffersOES = (PFNGLDELETEFRAMEBUFFERSOESPROC) load(userptr, "glDeleteFramebuffersOES");
sf_glad_glDeleteRenderbuffersOES = (PFNGLDELETERENDERBUFFERSOESPROC) load(userptr, "glDeleteRenderbuffersOES");
sf_glad_glFramebufferRenderbufferOES = (PFNGLFRAMEBUFFERRENDERBUFFEROESPROC) load(userptr, "glFramebufferRenderbufferOES");
sf_glad_glFramebufferTexture2DOES = (PFNGLFRAMEBUFFERTEXTURE2DOESPROC) load(userptr, "glFramebufferTexture2DOES");
sf_glad_glGenFramebuffersOES = (PFNGLGENFRAMEBUFFERSOESPROC) load(userptr, "glGenFramebuffersOES");
sf_glad_glGenRenderbuffersOES = (PFNGLGENRENDERBUFFERSOESPROC) load(userptr, "glGenRenderbuffersOES");
sf_glad_glGenerateMipmapOES = (PFNGLGENERATEMIPMAPOESPROC) load(userptr, "glGenerateMipmapOES");
sf_glad_glGetFramebufferAttachmentParameterivOES = (PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVOESPROC) load(userptr, "glGetFramebufferAttachmentParameterivOES");
sf_glad_glGetRenderbufferParameterivOES = (PFNGLGETRENDERBUFFERPARAMETERIVOESPROC) load(userptr, "glGetRenderbufferParameterivOES");
sf_glad_glIsFramebufferOES = (PFNGLISFRAMEBUFFEROESPROC) load(userptr, "glIsFramebufferOES");
sf_glad_glIsRenderbufferOES = (PFNGLISRENDERBUFFEROESPROC) load(userptr, "glIsRenderbufferOES");
sf_glad_glRenderbufferStorageOES = (PFNGLRENDERBUFFERSTORAGEOESPROC) load(userptr, "glRenderbufferStorageOES");
}
static void sf_glad_gl_resolve_aliases(void) {
@ -11978,6 +12155,91 @@ static int gladLoadGL( GLADloadfunc load) {
return gladLoadGLUserPtr( sf_glad_gl_get_proc_from_userptr, GLAD_GNUC_EXTENSION (void*) load);
}
static int sf_glad_gl_find_extensions_gles1( int version) {
const char *exts = NULL;
unsigned int num_exts_i = 0;
char **exts_i = NULL;
if (!sf_glad_gl_get_extensions(version, &exts, &num_exts_i, &exts_i)) return 0;
SF_GLAD_GL_EXT_blend_minmax = sf_glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_blend_minmax");
SF_GLAD_GL_KHR_debug = sf_glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_KHR_debug");
SF_GLAD_GL_OES_single_precision = sf_glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_OES_single_precision");
SF_GLAD_GL_EXT_sRGB = sf_glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_sRGB");
SF_GLAD_GL_OES_blend_equation_separate = sf_glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_OES_blend_equation_separate");
SF_GLAD_GL_OES_blend_func_separate = sf_glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_OES_blend_func_separate");
SF_GLAD_GL_OES_blend_subtract = sf_glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_OES_blend_subtract");
SF_GLAD_GL_OES_depth24 = sf_glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_OES_depth24");
SF_GLAD_GL_OES_depth32 = sf_glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_OES_depth32");
SF_GLAD_GL_OES_framebuffer_object = sf_glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_OES_framebuffer_object");
SF_GLAD_GL_OES_packed_depth_stencil = sf_glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_OES_packed_depth_stencil");
SF_GLAD_GL_OES_texture_npot = sf_glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_OES_texture_npot");
sf_glad_gl_free_extensions(exts_i, num_exts_i);
return 1;
}
static int sf_glad_gl_find_core_gles1(void) {
int i, major, minor;
const char* version;
const char* prefixes[] = {
"OpenGL ES-CM ",
"OpenGL ES-CL ",
"OpenGL ES ",
NULL
};
version = (const char*) sf_glad_glGetString(GL_VERSION);
if (!version) return 0;
for (i = 0; prefixes[i]; i++) {
const size_t length = strlen(prefixes[i]);
if (strncmp(version, prefixes[i], length) == 0) {
version += length;
break;
}
}
GLAD_IMPL_UTIL_SSCANF(version, "%d.%d", &major, &minor);
SF_GLAD_GL_VERSION_ES_CM_1_0 = (major == 1 && minor >= 0) || major > 1;
return GLAD_MAKE_VERSION(major, minor);
}
static int gladLoadGLES1UserPtr( GLADuserptrloadfunc load, void *userptr) {
int version;
sf_glad_glGetString = (PFNGLGETSTRINGPROC) load(userptr, "glGetString");
if(sf_glad_glGetString == NULL) return 0;
if(sf_glad_glGetString(GL_VERSION) == NULL) return 0;
version = sf_glad_gl_find_core_gles1();
sf_glad_gl_load_GL_VERSION_ES_CM_1_0(load, userptr);
if (!sf_glad_gl_find_extensions_gles1(version)) return 0;
sf_glad_gl_load_GL_EXT_blend_minmax(load, userptr);
sf_glad_gl_load_GL_KHR_debug(load, userptr);
sf_glad_gl_load_GL_OES_single_precision(load, userptr);
sf_glad_gl_load_GL_OES_blend_equation_separate(load, userptr);
sf_glad_gl_load_GL_OES_blend_func_separate(load, userptr);
sf_glad_gl_load_GL_OES_blend_subtract(load, userptr);
sf_glad_gl_load_GL_OES_framebuffer_object(load, userptr);
sf_glad_gl_resolve_aliases();
return version;
}
static int gladLoadGLES1( GLADloadfunc load) {
return gladLoadGLES1UserPtr( sf_glad_gl_get_proc_from_userptr, GLAD_GNUC_EXTENSION (void*) load);
}
#ifdef __cplusplus
}
#endif

View File

@ -41,13 +41,13 @@ namespace
bool decode(sf::InputStream& stream, sf::Uint8& value)
{
return stream.read(&value, sizeof(value)) == sizeof(value);
return static_cast<std::size_t>(stream.read(&value, sizeof(value))) == sizeof(value);
}
bool decode(sf::InputStream& stream, sf::Int16& value)
{
unsigned char bytes[sizeof(value)];
if (stream.read(bytes, sizeof(bytes)) != sizeof(bytes))
if (static_cast<std::size_t>(stream.read(bytes, static_cast<sf::Int64>(sizeof(bytes)))) != sizeof(bytes))
return false;
value = static_cast<sf::Uint8>(bytes[0] | (bytes[1] << 8));
@ -58,7 +58,7 @@ namespace
bool decode(sf::InputStream& stream, sf::Uint16& value)
{
unsigned char bytes[sizeof(value)];
if (stream.read(bytes, sizeof(bytes)) != sizeof(bytes))
if (static_cast<std::size_t>(stream.read(bytes, static_cast<sf::Int64>(sizeof(bytes)))) != sizeof(bytes))
return false;
value = static_cast<sf::Uint16>(bytes[0] | (bytes[1] << 8));
@ -69,7 +69,7 @@ namespace
bool decode24bit(sf::InputStream& stream, sf::Uint32& value)
{
unsigned char bytes[3];
if (stream.read(bytes, sizeof(bytes)) != sizeof(bytes))
if (static_cast<std::size_t>(stream.read(bytes, static_cast<sf::Int64>(sizeof(bytes)))) != sizeof(bytes))
return false;
value = static_cast<sf::Uint32>(bytes[0] | (bytes[1] << 8) | (bytes[2] << 16));
@ -80,7 +80,7 @@ namespace
bool decode(sf::InputStream& stream, sf::Uint32& value)
{
unsigned char bytes[sizeof(value)];
if (stream.read(bytes, sizeof(bytes)) != sizeof(bytes))
if (static_cast<std::size_t>(stream.read(bytes, static_cast<sf::Int64>(sizeof(bytes)))) != sizeof(bytes))
return false;
value = static_cast<sf::Uint32>(bytes[0] | (bytes[1] << 8) | (bytes[2] << 16) | (bytes[3] << 24));
@ -225,7 +225,7 @@ bool SoundFileReaderWav::parseHeader(Info& info)
// If we are here, it means that the first part of the header
// (the format) has already been checked
char mainChunk[mainChunkSize];
if (m_stream->read(mainChunk, sizeof(mainChunk)) != sizeof(mainChunk))
if (static_cast<std::size_t>(m_stream->read(mainChunk, static_cast<Int64>(sizeof(mainChunk)))) != sizeof(mainChunk))
return false;
// Parse all the sub-chunks
@ -234,7 +234,7 @@ bool SoundFileReaderWav::parseHeader(Info& info)
{
// Parse the sub-chunk id and size
char subChunkId[4];
if (m_stream->read(subChunkId, sizeof(subChunkId)) != sizeof(subChunkId))
if (static_cast<std::size_t>(m_stream->read(subChunkId, static_cast<Int64>(sizeof(subChunkId)))) != sizeof(subChunkId))
return false;
Uint32 subChunkSize = 0;
if (!decode(*m_stream, subChunkSize))
@ -307,7 +307,7 @@ bool SoundFileReaderWav::parseHeader(Info& info)
// Subformat
char subformat[16];
if (m_stream->read(subformat, sizeof(subformat)) != sizeof(subformat))
if (static_cast<std::size_t>(m_stream->read(subformat, static_cast<Int64>(sizeof(subformat)))) != sizeof(subformat))
return false;
if (std::memcmp(subformat, waveSubformatPcm, sizeof(subformat)) != 0)

View File

@ -85,7 +85,7 @@ bool SoundFileWriterOgg::open(const std::string& filename, unsigned int sampleRa
// Setup the encoder: VBR, automatic bitrate management
// Quality is in range [-1 .. 1], 0.4 gives ~128 kbps for a 44 KHz stereo sound
int status = vorbis_encode_init_vbr(&m_vorbis, channelCount, sampleRate, 0.4f);
int status = vorbis_encode_init_vbr(&m_vorbis, static_cast<long>(channelCount), static_cast<long>(sampleRate), 0.4f);
if (status < 0)
{
err() << "Failed to write ogg/vorbis file \"" << filename << "\" (unsupported bitrate)" << std::endl;

View File

@ -131,7 +131,7 @@ Font::~Font()
#ifdef SFML_SYSTEM_ANDROID
if (m_stream)
delete (priv::ResourceStream*)m_stream;
delete static_cast<priv::ResourceStream*>(m_stream);
#endif
}
@ -195,10 +195,10 @@ bool Font::loadFromFile(const std::string& filename)
#else
if (m_stream)
delete (priv::ResourceStream*)m_stream;
delete static_cast<priv::ResourceStream*>(m_stream);
m_stream = new priv::ResourceStream(filename);
return loadFromStream(*(priv::ResourceStream*)m_stream);
return loadFromStream(*static_cast<priv::ResourceStream*>(m_stream));
#endif
}
@ -659,16 +659,16 @@ Glyph Font::loadGlyph(Uint32 codePoint, unsigned int characterSize, bool bold, f
// Make sure the texture data is positioned in the center
// of the allocated texture rectangle
glyph.textureRect.left += static_cast<int>(padding);
glyph.textureRect.top += static_cast<int>(padding);
glyph.textureRect.left += static_cast<int>(padding);
glyph.textureRect.top += static_cast<int>(padding);
glyph.textureRect.width -= static_cast<int>(2 * padding);
glyph.textureRect.height -= static_cast<int>(2 * padding);
// Compute the glyph's bounding box
glyph.bounds.left = bitmapGlyph->left;
glyph.bounds.top = -bitmapGlyph->top;
glyph.bounds.width = bitmap.width;
glyph.bounds.height = bitmap.rows;
glyph.bounds.left = static_cast<float>( bitmapGlyph->left);
glyph.bounds.top = static_cast<float>(-bitmapGlyph->top);
glyph.bounds.width = static_cast<float>( bitmap.width);
glyph.bounds.height = static_cast<float>( bitmap.rows);
// Resize the pixel buffer to the new size and fill it with transparent white pixels
m_pixelBuffer.resize(width * height * 4);

View File

@ -68,14 +68,14 @@ namespace
}
// Retrieve the maximum number of texture units available
GLint getMaxTextureUnits()
std::size_t getMaxTextureUnits()
{
// TODO: Remove this lock when it becomes unnecessary in C++11
sf::Lock lock(maxTextureUnitsMutex);
static GLint maxUnits = checkMaxTextureUnits();
return maxUnits;
return static_cast<std::size_t>(maxUnits);
}
// Read the contents of a file into an array of char
@ -85,12 +85,12 @@ namespace
if (file)
{
file.seekg(0, std::ios_base::end);
std::streamsize size = file.tellg();
std::ifstream::pos_type size = file.tellg();
if (size > 0)
{
file.seekg(0, std::ios_base::beg);
buffer.resize(static_cast<std::size_t>(size));
file.read(&buffer[0], size);
file.read(&buffer[0], static_cast<std::streamsize>(size));
}
buffer.push_back('\0');
return true;
@ -556,8 +556,7 @@ void Shader::setUniform(const std::string& name, const Texture& texture)
if (it == m_textures.end())
{
// New entry, make sure there are enough texture units
GLint maxUnits = getMaxTextureUnits();
if (m_textures.size() + 1 >= static_cast<std::size_t>(maxUnits))
if (m_textures.size() + 1 >= getMaxTextureUnits())
{
err() << "Impossible to use texture \"" << name << "\" for shader: all available texture units are used" << std::endl;
return;

View File

@ -36,6 +36,7 @@
#include <SFML/System/Err.hpp>
#include <cassert>
#include <cstring>
#include <climits>
namespace
@ -378,7 +379,7 @@ Image Texture::copyToImage() const
if (m_pixelsFlipped)
{
src += srcPitch * (m_size.y - 1);
srcPitch = -srcPitch;
srcPitch = UINT_MAX - srcPitch + 1;
}
for (unsigned int i = 0; i < m_size.y; ++i)

View File

@ -195,7 +195,7 @@ bool VertexBuffer::update(const Vertex* vertices, std::size_t vertexCount, unsig
m_size = vertexCount;
}
glCheck(GLEXT_glBufferSubData(GLEXT_GL_ARRAY_BUFFER, sizeof(Vertex) * offset, static_cast<GLsizeiptrARB>(sizeof(Vertex) * vertexCount), vertices));
glCheck(GLEXT_glBufferSubData(GLEXT_GL_ARRAY_BUFFER, static_cast<GLintptrARB>(sizeof(Vertex) * offset), static_cast<GLsizeiptrARB>(sizeof(Vertex) * vertexCount), vertices));
glCheck(GLEXT_glBindBuffer(GLEXT_GL_ARRAY_BUFFER, 0));

View File

@ -18,7 +18,7 @@ sfml_add_library(sfml-main STATIC SOURCES ${SRC})
if(SFML_OS_ANDROID)
# glad sources
target_include_directories(sfml-main PRIVATE "${PROJECT_SOURCE_DIR}/extlibs/headers/glad/include")
target_include_directories(sfml-main SYSTEM PRIVATE "${PROJECT_SOURCE_DIR}/extlibs/headers/glad/include")
endif()
# overwrite sfml-main suffix for backward compatibility with FindSFML.cmake

View File

@ -161,7 +161,6 @@ void goToFullscreenMode(ANativeActivity* activity)
AWINDOW_FLAG_FULLSCREEN);
// Hide the navigation bar
JavaVM* lJavaVM = activity->vm;
JNIEnv* lJNIEnv = activity->env;
jobject objectActivity = activity->clazz;
@ -216,7 +215,6 @@ void getScreenSizeInPixels(ANativeActivity* activity, int* width, int* height)
// DisplayMetrics dm = new DisplayMetrics();
// getWindowManager().getDefaultDisplay().getMetrics(dm);
JavaVM* lJavaVM = activity->vm;
JNIEnv* lJNIEnv = activity->env;
jobject objectActivity = activity->clazz;
@ -248,6 +246,7 @@ void getScreenSizeInPixels(ANativeActivity* activity, int* width, int* height)
////////////////////////////////////////////////////////////
static void onStart(ANativeActivity* activity)
{
(void) activity;
}
@ -287,6 +286,7 @@ static void onPause(ANativeActivity* activity)
////////////////////////////////////////////////////////////
static void onStop(ANativeActivity* activity)
{
(void) activity;
}
@ -339,6 +339,8 @@ static void onDestroy(ANativeActivity* activity)
////////////////////////////////////////////////////////////
static void onNativeWindowCreated(ANativeActivity* activity, ANativeWindow* window)
{
(void) window;
sf::priv::ActivityStates* states = sf::priv::retrieveStates(activity);
sf::Lock lock(states->mutex);
@ -364,6 +366,8 @@ static void onNativeWindowCreated(ANativeActivity* activity, ANativeWindow* wind
////////////////////////////////////////////////////////////
static void onNativeWindowDestroyed(ANativeActivity* activity, ANativeWindow* window)
{
(void) window;
sf::priv::ActivityStates* states = sf::priv::retrieveStates(activity);
sf::Lock lock(states->mutex);
@ -389,12 +393,16 @@ static void onNativeWindowDestroyed(ANativeActivity* activity, ANativeWindow* wi
////////////////////////////////////////////////////////////
static void onNativeWindowRedrawNeeded(ANativeActivity* activity, ANativeWindow* window)
{
(void) activity;
(void) window;
}
////////////////////////////////////////////////////////////
static void onNativeWindowResized(ANativeActivity* activity, ANativeWindow* window)
{
(void) activity;
(void) window;
}
@ -435,12 +443,16 @@ static void onInputQueueDestroyed(ANativeActivity* activity, AInputQueue* queue)
////////////////////////////////////////////////////////////
static void onWindowFocusChanged(ANativeActivity* activity, int focused)
{
(void) activity;
(void) focused;
}
////////////////////////////////////////////////////////////
static void onContentRectChanged(ANativeActivity* activity, const ARect* rect)
{
(void) rect;
// Retrieve our activity states from the activity instance
sf::priv::ActivityStates* states = sf::priv::retrieveStates(activity);
sf::Lock lock(states->mutex);
@ -450,8 +462,8 @@ static void onContentRectChanged(ANativeActivity* activity, const ARect* rect)
// Send an event to warn people about the window move/resize
sf::Event event;
event.type = sf::Event::Resized;
event.size.width = ANativeWindow_getWidth(states->window);
event.size.height = ANativeWindow_getHeight(states->window);
event.size.width = static_cast<unsigned int>(ANativeWindow_getWidth(states->window));
event.size.height = static_cast<unsigned int>(ANativeWindow_getHeight(states->window));
states->forwardEvent(event);
}
@ -461,12 +473,14 @@ static void onContentRectChanged(ANativeActivity* activity, const ARect* rect)
////////////////////////////////////////////////////////////
static void onConfigurationChanged(ANativeActivity* activity)
{
(void) activity;
}
////////////////////////////////////////////////////////////
static void* onSaveInstanceState(ANativeActivity* activity, size_t* outLen)
{
(void) activity;
*outLen = 0;
return NULL;
@ -476,6 +490,7 @@ static void* onSaveInstanceState(ANativeActivity* activity, size_t* outLen)
////////////////////////////////////////////////////////////
static void onLowMemory(ANativeActivity* activity)
{
(void) activity;
}

View File

@ -46,7 +46,10 @@ extern int main(int argc, char* argv[]);
////////////////////////////////////////////////////////////
int WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, INT)
{
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wpedantic"
return main(__argc, __argv);
#pragma GCC diagnostic pop
}
#endif // SFML_SYSTEM_WINDOWS

View File

@ -549,7 +549,7 @@ Ftp::Response Ftp::DataChannel::open(Ftp::TransferMode mode)
// Extract the current number
while (isdigit(str[index]))
{
data[i] = static_cast<Uint8>(data[i] * 10) + static_cast<Uint8>(str[index] - '0');
data[i] = static_cast<Uint8>(static_cast<Uint8>(data[i] * 10) + static_cast<Uint8>(str[index] - '0'));
index++;
}

View File

@ -198,7 +198,9 @@ void IpAddress::resolve(const std::string& address)
{
if (result)
{
ip = reinterpret_cast<sockaddr_in*>(result->ai_addr)->sin_addr.s_addr;
sockaddr_in sin;
std::memcpy(&sin, result->ai_addr, sizeof(*result->ai_addr));
ip = sin.sin_addr.s_addr;
freeaddrinfo(result);
m_address = ip;
m_valid = true;

View File

@ -178,7 +178,7 @@ Socket::Status TcpSocket::connect(const IpAddress& remoteAddress, unsigned short
time.tv_usec = static_cast<long>(timeout.asMicroseconds() % 1000000);
// Wait for something to write on our socket (which means that the connection request has returned)
if (select(getHandle() + 1, NULL, &selector, NULL, &time) > 0)
if (select(static_cast<int>(getHandle() + 1), NULL, &selector, NULL, &time) > 0)
{
// At this point the connection may have been either accepted or refused.
// To know whether it's a success or a failure, we must check the address of the connected peer
@ -242,13 +242,13 @@ Socket::Status TcpSocket::send(const void* data, std::size_t size, std::size_t&
}
// Loop until every byte has been sent
ssize_t result = 0;
int result = 0;
for (sent = 0; sent < size; sent += static_cast<std::size_t>(result))
{
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wuseless-cast"
// Send a chunk of data
result = ::send(getHandle(), static_cast<const char*>(data) + sent, static_cast<priv::SocketImpl::Size>(size - sent), flags);
result = static_cast<int>(::send(getHandle(), static_cast<const char*>(data) + sent, static_cast<priv::SocketImpl::Size>(size - sent), flags));
#pragma GCC diagnostic pop
// Check for errors
@ -326,16 +326,25 @@ Socket::Status TcpSocket::send(Packet& packet)
std::vector<char> blockToSend(sizeof(packetSize) + size);
// Copy the packet size and data into the block to send
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wnull-dereference" // False positive.
std::memcpy(&blockToSend[0], &packetSize, sizeof(packetSize));
#pragma GCC diagnostic pop
if (size > 0)
std::memcpy(&blockToSend[0] + sizeof(packetSize), data, size);
// These warnings are ignored here for portability, as even on Windows the
// signature of `send` might change depending on whether Win32 or MinGW is
// being used.
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wuseless-cast"
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wsign-conversion"
// Send the data block
std::size_t sent;
Status status = send(&blockToSend[0] + packet.m_sendPos, static_cast<priv::SocketImpl::Size>(blockToSend.size() - packet.m_sendPos), sent);
#pragma GCC diagnostic pop
#pragma GCC diagnostic pop
// In the case of a partial send, record the location to resume from
if (status == Partial)

View File

@ -64,7 +64,7 @@ void SocketImpl::close(SocketHandle sock)
void SocketImpl::setBlocking(SocketHandle sock, bool block)
{
u_long blocking = block ? 0 : 1;
ioctlsocket(sock, FIONBIO, &blocking);
ioctlsocket(sock, static_cast<long>(FIONBIO), &blocking);
}

View File

@ -41,8 +41,8 @@ void sleepImpl(Time time)
// Construct the time to wait
timespec ti;
ti.tv_nsec = (usecs % 1000000) * 1000;
ti.tv_sec = usecs / 1000000;
ti.tv_nsec = static_cast<long>((usecs % 1000000) * 1000);
ti.tv_sec = static_cast<time_t>(usecs / 1000000);
// Wait...
// If nanosleep returns -1, we check errno. If it is EINTR

View File

@ -56,7 +56,7 @@ Time ClockImpl::getCurrentTime()
{
// Calculate inverse of frequency multiplied by 1000000 to prevent overflow in final calculation
// Frequency is constant across the program lifetime
static double inverse = 1000000.0 / getFrequency().QuadPart;
static double inverse = 1000000.0 / static_cast<double>(getFrequency().QuadPart);
// Detect if we are on Windows XP or older
static bool oldWindows = isWindowsXpOrOlder();
@ -80,7 +80,7 @@ Time ClockImpl::getCurrentTime()
}
// Return the current time as microseconds
return sf::microseconds(static_cast<sf::Int64>(time.QuadPart * inverse));
return sf::microseconds(static_cast<sf::Int64>(static_cast<double>(time.QuadPart) * inverse));
}
} // namespace priv

View File

@ -44,7 +44,7 @@ void sleepImpl(Time time)
timeBeginPeriod(tc.wPeriodMin);
// Wait...
::Sleep(time.asMilliseconds());
::Sleep(static_cast<DWORD>(time.asMilliseconds()));
// Reset the timer resolution back to the system default
timeEndPeriod(tc.wPeriodMin);

View File

@ -291,14 +291,14 @@ namespace
{
std::size_t prefixLength = std::strlen(prefix);
if ((std::strlen(version) >= (prefixLength + 3)) &&
(std::strncmp(version, prefix, prefixLength) == 0) &&
std::isdigit(version[prefixLength]) &&
(version[prefixLength + 1] == '.') &&
std::isdigit(version[prefixLength + 2]))
{
major = static_cast<unsigned int>(version[prefixLength] - '0');
minor = static_cast<unsigned int>(version[prefixLength + 2] - '0');
if ((std::strlen(version) >= (prefixLength + 3)) &&
(std::strncmp(version, prefix, prefixLength) == 0) &&
std::isdigit(version[prefixLength]) &&
(version[prefixLength + 1] == '.') &&
std::isdigit(version[prefixLength + 2]))
{
major = static_cast<unsigned int>(version[prefixLength] - '0');
minor = static_cast<unsigned int>(version[prefixLength + 2] - '0');
return true;
}

View File

@ -48,6 +48,7 @@
#include <vector>
#include <string>
#include <cstring>
#include <cassert>
#ifdef SFML_OPENGL_ES
#include <SFML/Window/EglContext.hpp>
@ -81,10 +82,10 @@ namespace
static const unsigned int maxTrialsCount = 5;
// Predicate we use to find key repeat events in processEvent
struct KeyRepeatFinder
{
KeyRepeatFinder(unsigned int initalKeycode, Time initialTime) : keycode(initalKeycode), time(initialTime) {}
// Predicate we use to find key repeat events in processEvent
struct KeyRepeatFinder
{
KeyRepeatFinder(unsigned int initalKeycode, Time initialTime) : keycode(initalKeycode), time(initialTime) {}
// Predicate operator that checks event type, keycode and timestamp
bool operator()(const XEvent& event)
@ -117,11 +118,11 @@ namespace
std::size_t offset = 0;
ssize_t result = 0;
while ((result = read(file, &buffer[offset], 256)) > 0)
{
buffer.resize(buffer.size() + static_cast<std::size_t>(result), 0);
offset += static_cast<std::size_t>(result);
}
while ((result = read(file, &buffer[offset], 256)) > 0)
{
buffer.resize(buffer.size() + static_cast<std::size_t>(result), 0);
offset += static_cast<std::size_t>(result);
}
::close(file);
@ -184,7 +185,10 @@ namespace
return false;
}
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wcast-align"
::Window rootWindow = *reinterpret_cast< ::Window* >(data);
#pragma GCC diagnostic pop
XFree(data);
@ -216,7 +220,10 @@ namespace
return false;
}
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wcast-align"
::Window childWindow = *reinterpret_cast< ::Window* >(data);
#pragma GCC diagnostic pop
XFree(data);
@ -335,7 +342,10 @@ namespace
{
gotFrameExtents = true;
long* extents = reinterpret_cast<long*>(data);
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wcast-align"
long* extents = reinterpret_cast<long*>(data);
#pragma GCC diagnostic pop
xFrameExtent = extents[0]; // Left.
yFrameExtent = extents[2]; // Top.
@ -1056,8 +1066,11 @@ void WindowImplX11::setIcon(unsigned int width, unsigned int height, const Uint8
std::vector<unsigned long> icccmIconPixels(2 + width * height, 0);
unsigned long* ptr = &icccmIconPixels[0];
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wnull-dereference" // False positive.
*ptr++ = width;
*ptr++ = height;
#pragma GCC diagnostic pop
for (std::size_t i = 0; i < width * height; ++i)
{

View File

@ -60,8 +60,8 @@ bool CursorImpl::loadFromPixels(const Uint8* pixels, Vector2u size, Vector2u hot
std::memset(&bitmapHeader, 0, sizeof(BITMAPV5HEADER));
bitmapHeader.bV5Size = sizeof(BITMAPV5HEADER);
bitmapHeader.bV5Width = size.x;
bitmapHeader.bV5Height = -static_cast<int>(size.y); // Negative indicates origin is in upper-left corner
bitmapHeader.bV5Width = static_cast<LONG>(size.x);
bitmapHeader.bV5Height = -static_cast<LONG>(size.y); // Negative indicates origin is in upper-left corner
bitmapHeader.bV5Planes = 1;
bitmapHeader.bV5BitCount = 32;
bitmapHeader.bV5Compression = BI_BITFIELDS;
@ -94,11 +94,11 @@ bool CursorImpl::loadFromPixels(const Uint8* pixels, Vector2u size, Vector2u hot
Uint32* bitmapOffset = bitmapData;
for (std::size_t remaining = size.x * size.y; remaining > 0; --remaining, pixels += 4)
{
*bitmapOffset++ = (pixels[3] << 24) | (pixels[0] << 16) | (pixels[1] << 8) | pixels[2];
*bitmapOffset++ = static_cast<Uint32>((pixels[3] << 24) | (pixels[0] << 16) | (pixels[1] << 8) | pixels[2]);
}
// Create a dummy mask bitmap (it won't be used)
HBITMAP mask = CreateBitmap(size.x, size.y, 1, 1, NULL);
HBITMAP mask = CreateBitmap(static_cast<int>(size.x), static_cast<int>(size.y), 1, 1, NULL);
if (!mask)
{

View File

@ -152,7 +152,7 @@ namespace
if (result != ERROR_SUCCESS)
{
sf::err() << "Unable to open registry for joystick at index " << index << ": " << getErrorString(result) << std::endl;
sf::err() << "Unable to open registry for joystick at index " << index << ": " << getErrorString(static_cast<DWORD>(result)) << std::endl;
return joystickDescription;
}
}
@ -172,7 +172,7 @@ namespace
if (result != ERROR_SUCCESS)
{
sf::err() << "Unable to query registry key for joystick at index " << index << ": " << getErrorString(result) << std::endl;
sf::err() << "Unable to query registry key for joystick at index " << index << ": " << getErrorString(static_cast<DWORD>(result)) << std::endl;
return joystickDescription;
}
@ -184,7 +184,7 @@ namespace
if (result != ERROR_SUCCESS)
{
sf::err() << "Unable to open registry key for joystick at index " << index << ": " << getErrorString(result) << std::endl;
sf::err() << "Unable to open registry key for joystick at index " << index << ": " << getErrorString(static_cast<DWORD>(result)) << std::endl;
return joystickDescription;
}
@ -195,7 +195,7 @@ namespace
if (result != ERROR_SUCCESS)
{
sf::err() << "Unable to query name for joystick at index " << index << ": " << getErrorString(result) << std::endl;
sf::err() << "Unable to query name for joystick at index " << index << ": " << getErrorString(static_cast<DWORD>(result)) << std::endl;
return joystickDescription;
}
@ -365,17 +365,17 @@ JoystickState JoystickImpl::update()
state.connected = true;
// Axes
state.axes[Joystick::X] = (pos.dwXpos - (m_caps.wXmax + m_caps.wXmin) / 2.f) * 200.f / (m_caps.wXmax - m_caps.wXmin);
state.axes[Joystick::Y] = (pos.dwYpos - (m_caps.wYmax + m_caps.wYmin) / 2.f) * 200.f / (m_caps.wYmax - m_caps.wYmin);
state.axes[Joystick::Z] = (pos.dwZpos - (m_caps.wZmax + m_caps.wZmin) / 2.f) * 200.f / (m_caps.wZmax - m_caps.wZmin);
state.axes[Joystick::R] = (pos.dwRpos - (m_caps.wRmax + m_caps.wRmin) / 2.f) * 200.f / (m_caps.wRmax - m_caps.wRmin);
state.axes[Joystick::U] = (pos.dwUpos - (m_caps.wUmax + m_caps.wUmin) / 2.f) * 200.f / (m_caps.wUmax - m_caps.wUmin);
state.axes[Joystick::V] = (pos.dwVpos - (m_caps.wVmax + m_caps.wVmin) / 2.f) * 200.f / (m_caps.wVmax - m_caps.wVmin);
state.axes[Joystick::X] = (static_cast<float>(pos.dwXpos) - static_cast<float>(m_caps.wXmax + m_caps.wXmin) / 2.f) * 200.f / static_cast<float>(m_caps.wXmax - m_caps.wXmin);
state.axes[Joystick::Y] = (static_cast<float>(pos.dwYpos) - static_cast<float>(m_caps.wYmax + m_caps.wYmin) / 2.f) * 200.f / static_cast<float>(m_caps.wYmax - m_caps.wYmin);
state.axes[Joystick::Z] = (static_cast<float>(pos.dwZpos) - static_cast<float>(m_caps.wZmax + m_caps.wZmin) / 2.f) * 200.f / static_cast<float>(m_caps.wZmax - m_caps.wZmin);
state.axes[Joystick::R] = (static_cast<float>(pos.dwRpos) - static_cast<float>(m_caps.wRmax + m_caps.wRmin) / 2.f) * 200.f / static_cast<float>(m_caps.wRmax - m_caps.wRmin);
state.axes[Joystick::U] = (static_cast<float>(pos.dwUpos) - static_cast<float>(m_caps.wUmax + m_caps.wUmin) / 2.f) * 200.f / static_cast<float>(m_caps.wUmax - m_caps.wUmin);
state.axes[Joystick::V] = (static_cast<float>(pos.dwVpos) - static_cast<float>(m_caps.wVmax + m_caps.wVmin) / 2.f) * 200.f / static_cast<float>(m_caps.wVmax - m_caps.wVmin);
// Special case for POV, it is given as an angle
if (pos.dwPOV != 0xFFFF)
{
float angle = pos.dwPOV / 18000.f * 3.141592654f;
float angle = static_cast<float>(pos.dwPOV) / 18000.f * 3.141592654f;
state.axes[Joystick::PovX] = std::sin(angle) * 100;
state.axes[Joystick::PovY] = std::cos(angle) * 100;
}
@ -387,7 +387,7 @@ JoystickState JoystickImpl::update()
// Buttons
for (unsigned int i = 0; i < Joystick::ButtonCount; ++i)
state.buttons[i] = (pos.dwButtons & (1 << i)) != 0;
state.buttons[i] = (pos.dwButtons & (1u << i)) != 0;
}
return state;
@ -404,7 +404,7 @@ void JoystickImpl::initializeDInput()
{
// Try to get the address of the DirectInput8Create entry point
typedef HRESULT(WINAPI *DirectInput8CreateFunc)(HINSTANCE, DWORD, REFIID, LPVOID*, LPUNKNOWN);
DirectInput8CreateFunc directInput8Create = reinterpret_cast<DirectInput8CreateFunc>(GetProcAddress(dinput8dll, "DirectInput8Create"));
DirectInput8CreateFunc directInput8Create = reinterpret_cast<DirectInput8CreateFunc>(reinterpret_cast<void*>(GetProcAddress(dinput8dll, "DirectInput8Create")));
if (directInput8Create)
{
@ -643,7 +643,7 @@ bool JoystickImpl::openDInput(unsigned int index)
for (int i = 0; i < 4; ++i)
{
data[8 * 4 + i].pguid = &guids::GUID_POV;
data[8 * 4 + i].dwOfs = static_cast<DWORD>(DIJOFS_POV(i));
data[8 * 4 + i].dwOfs = static_cast<DWORD>(DIJOFS_POV(static_cast<unsigned int>(i)));
data[8 * 4 + i].dwType = povType;
data[8 * 4 + i].dwFlags = 0;
}

View File

@ -43,7 +43,7 @@ std::vector<VideoMode> VideoModeImpl::getFullscreenModes()
DEVMODE win32Mode;
win32Mode.dmSize = sizeof(win32Mode);
win32Mode.dmDriverExtra = 0;
for (int count = 0; EnumDisplaySettings(NULL, count, &win32Mode); ++count)
for (int count = 0; EnumDisplaySettings(NULL, static_cast<DWORD>(count), &win32Mode); ++count)
{
// Convert to sf::VideoMode
VideoMode mode(win32Mode.dmPelsWidth, win32Mode.dmPelsHeight, win32Mode.dmBitsPerPel);

View File

@ -91,7 +91,7 @@ namespace
template<typename T>
bool loadEntryPoint(T& entryPoint, const char* name)
{
entryPoint = reinterpret_cast<T>(GetProcAddress(library, name));
entryPoint = reinterpret_cast<T>(reinterpret_cast<void*>(GetProcAddress(library, name)));
return (entryPoint != NULL);
}

View File

@ -480,8 +480,8 @@ void WglContext::updateSettingsFromPixelFormat()
if (wglGetPixelFormatAttribivARB(m_deviceContext, format, PFD_MAIN_PLANE, 2, attributes, values) == TRUE)
{
m_settings.depthBits = values[0];
m_settings.stencilBits = values[1];
m_settings.depthBits = static_cast<unsigned int>(values[0]);
m_settings.stencilBits = static_cast<unsigned int>(values[1]);
}
else
{
@ -497,7 +497,7 @@ void WglContext::updateSettingsFromPixelFormat()
if (wglGetPixelFormatAttribivARB(m_deviceContext, format, PFD_MAIN_PLANE, 2, sampleAttributes, sampleValues) == TRUE)
{
m_settings.antialiasingLevel = sampleValues[0] ? sampleValues[1] : 0;
m_settings.antialiasingLevel = static_cast<unsigned int>(sampleValues[0] ? sampleValues[1] : 0);
}
else
{
@ -551,7 +551,7 @@ void WglContext::createSurface(WglContext* shared, unsigned int width, unsigned
{
int attributes[] = {0, 0};
m_pbuffer = wglCreatePbufferARB(shared->m_deviceContext, bestFormat, width, height, attributes);
m_pbuffer = wglCreatePbufferARB(shared->m_deviceContext, bestFormat, static_cast<int>(width), static_cast<int>(height), attributes);
if (m_pbuffer)
{
@ -580,7 +580,7 @@ void WglContext::createSurface(WglContext* shared, unsigned int width, unsigned
// with other contexts and thus wglShareLists would always fail
// Create the hidden window
m_window = CreateWindowA("STATIC", "", WS_POPUP | WS_DISABLED, 0, 0, width, height, NULL, NULL, GetModuleHandle(NULL), NULL);
m_window = CreateWindowA("STATIC", "", WS_POPUP | WS_DISABLED, 0, 0, static_cast<int>(width), static_cast<int>(height), NULL, NULL, GetModuleHandle(NULL), NULL);
ShowWindow(m_window, SW_HIDE);
m_deviceContext = GetDC(m_window);
@ -633,9 +633,9 @@ void WglContext::createContext(WglContext* shared)
if ((m_settings.majorVersion > 1) || ((m_settings.majorVersion == 1) && (m_settings.minorVersion > 1)))
{
attributes.push_back(WGL_CONTEXT_MAJOR_VERSION_ARB);
attributes.push_back(m_settings.majorVersion);
attributes.push_back(static_cast<int>(m_settings.majorVersion));
attributes.push_back(WGL_CONTEXT_MINOR_VERSION_ARB);
attributes.push_back(m_settings.minorVersion);
attributes.push_back(static_cast<int>(m_settings.minorVersion));
}
// Check if setting the profile is supported

View File

@ -86,7 +86,7 @@ namespace
};
typedef HRESULT (WINAPI* SetProcessDpiAwarenessFuncType)(ProcessDpiAwareness);
SetProcessDpiAwarenessFuncType SetProcessDpiAwarenessFunc = reinterpret_cast<SetProcessDpiAwarenessFuncType>(GetProcAddress(shCoreDll, "SetProcessDpiAwareness"));
SetProcessDpiAwarenessFuncType SetProcessDpiAwarenessFunc = reinterpret_cast<SetProcessDpiAwarenessFuncType>(reinterpret_cast<void*>(GetProcAddress(shCoreDll, "SetProcessDpiAwareness")));
if (SetProcessDpiAwarenessFunc)
{
@ -114,7 +114,7 @@ namespace
if (user32Dll)
{
typedef BOOL (WINAPI* SetProcessDPIAwareFuncType)(void);
SetProcessDPIAwareFuncType SetProcessDPIAwareFunc = reinterpret_cast<SetProcessDPIAwareFuncType>(GetProcAddress(user32Dll, "SetProcessDPIAware"));
SetProcessDPIAwareFuncType SetProcessDPIAwareFunc = reinterpret_cast<SetProcessDPIAwareFuncType>(reinterpret_cast<void*>(GetProcAddress(user32Dll, "SetProcessDPIAware")));
if (SetProcessDPIAwareFunc)
{
@ -190,8 +190,8 @@ m_cursorGrabbed (m_fullscreen)
HDC screenDC = GetDC(NULL);
int left = (GetDeviceCaps(screenDC, HORZRES) - static_cast<int>(mode.width)) / 2;
int top = (GetDeviceCaps(screenDC, VERTRES) - static_cast<int>(mode.height)) / 2;
int width = mode.width;
int height = mode.height;
int width = static_cast<int>(mode.width);
int height = static_cast<int>(mode.height);
ReleaseDC(NULL, screenDC);
// Choose the window style according to the Style parameter
@ -333,7 +333,7 @@ Vector2u WindowImplWin32::getSize() const
RECT rect;
GetClientRect(m_handle, &rect);
return Vector2u(rect.right - rect.left, rect.bottom - rect.top);
return Vector2u(static_cast<unsigned int>(rect.right - rect.left), static_cast<unsigned int>(rect.bottom - rect.top));
}
@ -343,7 +343,7 @@ void WindowImplWin32::setSize(const Vector2u& size)
// SetWindowPos wants the total size of the window (including title bar and borders),
// so we have to compute it
RECT rectangle = {0, 0, static_cast<long>(size.x), static_cast<long>(size.y)};
AdjustWindowRect(&rectangle, GetWindowLongPtr(m_handle, GWL_STYLE), false);
AdjustWindowRect(&rectangle, static_cast<DWORD>(GetWindowLongPtr(m_handle, GWL_STYLE)), false);
int width = rectangle.right - rectangle.left;
int height = rectangle.bottom - rectangle.top;
@ -376,13 +376,13 @@ void WindowImplWin32::setIcon(unsigned int width, unsigned int height, const Uin
}
// Create the icon from the pixel array
m_icon = CreateIcon(GetModuleHandleW(NULL), width, height, 1, 32, NULL, &iconPixels[0]);
m_icon = CreateIcon(GetModuleHandleW(NULL), static_cast<int>(width), static_cast<int>(height), 1, 32, NULL, &iconPixels[0]);
// Set it as both big and small icon of the window
if (m_icon)
{
SendMessageW(m_handle, WM_SETICON, ICON_BIG, (LPARAM)m_icon);
SendMessageW(m_handle, WM_SETICON, ICON_SMALL, (LPARAM)m_icon);
SendMessageW(m_handle, WM_SETICON, ICON_BIG, reinterpret_cast<LPARAM>(m_icon));
SendMessageW(m_handle, WM_SETICON, ICON_SMALL, reinterpret_cast<LPARAM>(m_icon));
}
else
{
@ -500,11 +500,11 @@ void WindowImplWin32::switchToFullscreen(const VideoMode& mode)
}
// Make the window flags compatible with fullscreen mode
SetWindowLongPtr(m_handle, GWL_STYLE, WS_POPUP | WS_CLIPCHILDREN | WS_CLIPSIBLINGS);
SetWindowLongPtr(m_handle, GWL_STYLE, static_cast<LONG_PTR>(WS_POPUP) | static_cast<LONG_PTR>(WS_CLIPCHILDREN) | static_cast<LONG_PTR>(WS_CLIPSIBLINGS));
SetWindowLongPtr(m_handle, GWL_EXSTYLE, WS_EX_APPWINDOW);
// Resize the window so that it fits the entire screen
SetWindowPos(m_handle, HWND_TOP, 0, 0, mode.width, mode.height, SWP_FRAMECHANGED);
SetWindowPos(m_handle, HWND_TOP, 0, 0, static_cast<int>(mode.width), static_cast<int>(mode.height), SWP_FRAMECHANGED);
ShowWindow(m_handle, SW_SHOW);
// Set "this" as the current fullscreen window
@ -1131,7 +1131,7 @@ LRESULT CALLBACK WindowImplWin32::globalOnEvent(HWND handle, UINT message, WPARA
if (message == WM_CREATE)
{
// Get WindowImplWin32 instance (it was passed as the last argument of CreateWindow)
LONG_PTR window = (LONG_PTR)reinterpret_cast<CREATESTRUCT*>(lParam)->lpCreateParams;
LONG_PTR window = reinterpret_cast<LONG_PTR>(reinterpret_cast<CREATESTRUCT*>(lParam)->lpCreateParams);
// Set as the "user data" parameter of the window
SetWindowLongPtrW(handle, GWLP_USERDATA, window);