From a759ccd5db6e80648fef1f688b2360b728c9658d Mon Sep 17 00:00:00 2001 From: binary1248 Date: Mon, 19 Apr 2021 04:20:43 +0200 Subject: [PATCH] Enable compiler warnings. --- CMakeLists.txt | 3 + cmake/CompilerOptionsOverride.cmake | 5 + cmake/CompilerWarnings.cmake | 89 ++++++++ cmake/Macros.cmake | 7 + extlibs/headers/glad/include/glad/egl.h | 22 -- extlibs/headers/glad/include/glad/gl.h | 262 ------------------------ extlibs/headers/glad/include/glad/wgl.h | 14 -- src/SFML/Graphics/CMakeLists.txt | 2 +- src/SFML/Window/CMakeLists.txt | 2 +- 9 files changed, 106 insertions(+), 300 deletions(-) create mode 100644 cmake/CompilerOptionsOverride.cmake create mode 100644 cmake/CompilerWarnings.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 7be98732..c10e3ccb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,8 @@ cmake_minimum_required(VERSION 3.7.2) +# customize the compiler options CMake uses to initialize variables with +set(CMAKE_USER_MAKE_RULES_OVERRIDE "${CMAKE_CURRENT_SOURCE_DIR}/cmake/CompilerOptionsOverride.cmake") + # define a macro that helps defining an option macro(sfml_set_option var default type docstring) if(NOT DEFINED ${var}) diff --git a/cmake/CompilerOptionsOverride.cmake b/cmake/CompilerOptionsOverride.cmake new file mode 100644 index 00000000..d53f7f29 --- /dev/null +++ b/cmake/CompilerOptionsOverride.cmake @@ -0,0 +1,5 @@ +if(MSVC) + # remove default warning level from CMAKE_CXX_FLAGS_INIT + string(REGEX REPLACE "/W[0-4]" "" CMAKE_CXX_FLAGS_INIT "${CMAKE_CXX_FLAGS_INIT}") + string(REGEX REPLACE "/W[0-4]" "" CMAKE_C_FLAGS_INIT "${CMAKE_C_FLAGS_INIT}") +endif() diff --git a/cmake/CompilerWarnings.cmake b/cmake/CompilerWarnings.cmake new file mode 100644 index 00000000..05b0334c --- /dev/null +++ b/cmake/CompilerWarnings.cmake @@ -0,0 +1,89 @@ +# from here: +# +# https://github.com/lefticus/cppbestpractices/blob/master/02-Use_the_Tools_Available.md + +# Helper function to enable compiler warnings for a specific set of files +function(set_file_warnings) + option(WARNINGS_AS_ERRORS "Treat compiler warnings as errors" TRUE) + + set(MSVC_WARNINGS + /W4 # Baseline reasonable warnings + /w14242 # 'identifier': conversion from 'type1' to 'type1', possible loss of data + /w14254 # 'operator': conversion from 'type1:field_bits' to 'type2:field_bits', possible loss of data + /w14263 # 'function': member function does not override any base class virtual member function + /w14265 # 'classname': class has virtual functions, but destructor is not virtual instances of this class may not be destructed correctly + /w14287 # 'operator': unsigned/negative constant mismatch + /we4289 # nonstandard extension used: 'variable': loop control variable declared in the for-loop is used outside the for-loop scope + /w14296 # 'operator': expression is always 'boolean_value' + /w14311 # 'variable': pointer truncation from 'type1' to 'type2' + /w14545 # expression before comma evaluates to a function which is missing an argument list + /w14546 # function call before comma missing argument list + /w14547 # 'operator': operator before comma has no effect; expected operator with side-effect + /w14549 # 'operator': operator before comma has no effect; did you intend 'operator'? + /w14555 # expression has no effect; expected expression with side- effect + /w14619 # pragma warning: there is no warning number 'number' + /w14640 # Enable warning on thread un-safe static member initialization + /w14826 # Conversion from 'type1' to 'type_2' is sign-extended. This may cause unexpected runtime behavior. + /w14905 # wide string literal cast to 'LPSTR' + /w14906 # string literal cast to 'LPWSTR' + /w14928 # illegal copy-initialization; more than one user-defined conversion has been implicitly applied + # /permissive- # standards conformance mode for MSVC compiler. Disabled until all out-of-the-box Windows SDKs can successfully build with it. + + # Disables, remove when appropriate + /wd4996 # disable warnings about deprecated functions + ) + + set(CLANG_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. + ) + + if(WARNINGS_AS_ERRORS) + set(CLANG_WARNINGS ${CLANG_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 + -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 + ) + + # Don't enable -Wduplicated-branches for GCC < 8.1 since it will lead to false positives + # https://github.com/gcc-mirror/gcc/commit/6bebae75035889a4844eb4d32a695bebf412bcd7 + if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 8.1) + set(GCC_WARNINGS + ${GCC_WARNINGS} + -Wduplicated-branches # warn if if / else branches have duplicated code + ) + endif() + + if(MSVC) + set(FILE_WARNINGS ${MSVC_WARNINGS}) + elseif(CMAKE_CXX_COMPILER_ID MATCHES ".*Clang") + set(FILE_WARNINGS ${CLANG_WARNINGS}) + elseif(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") + set(FILE_WARNINGS ${GCC_WARNINGS}) + else() + message(AUTHOR_WARNING "No compiler warnings set for '${CMAKE_CXX_COMPILER_ID}' compiler.") + endif() + + foreach(WARNING ${FILE_WARNINGS}) + set_property(SOURCE ${ARGV} APPEND_STRING PROPERTY COMPILE_FLAGS " ${WARNING}") + endforeach() +endfunction() diff --git a/cmake/Macros.cmake b/cmake/Macros.cmake index 4f5c094b..129afe22 100644 --- a/cmake/Macros.cmake +++ b/cmake/Macros.cmake @@ -1,5 +1,8 @@ include(CMakeParseArguments) +# include the compiler warnings helpers +include(${CMAKE_CURRENT_LIST_DIR}/CompilerWarnings.cmake) + # This little macro lets you set any Xcode specific property macro (sfml_set_xcode_property TARGET XCODE_PROPERTY XCODE_VALUE) set_property (TARGET ${TARGET} PROPERTY XCODE_ATTRIBUTE_${XCODE_PROPERTY} ${XCODE_VALUE}) @@ -63,6 +66,8 @@ macro(sfml_add_library target) add_library(${target} ${THIS_SOURCES}) endif() + set_file_warnings(${THIS_SOURCES}) + # define the export symbol of the module string(REPLACE "-" "_" NAME_UPPER "${target}") string(TOUPPER "${NAME_UPPER}" NAME_UPPER) @@ -260,6 +265,8 @@ macro(sfml_add_example target) add_executable(${target} ${target_input}) endif() + set_file_warnings(${target_input}) + # set the debug suffix set_target_properties(${target} PROPERTIES DEBUG_POSTFIX -d) diff --git a/extlibs/headers/glad/include/glad/egl.h b/extlibs/headers/glad/include/glad/egl.h index fe8188ee..e685194d 100644 --- a/extlibs/headers/glad/include/glad/egl.h +++ b/extlibs/headers/glad/include/glad/egl.h @@ -1224,18 +1224,6 @@ static void sf_glad_egl_load_EGL_KHR_reusable_sync( GLADuserptrloadfunc load, vo sf_glad_eglSignalSyncKHR = (PFNEGLSIGNALSYNCKHRPROC) load(userptr, "eglSignalSyncKHR"); } - -static void sf_glad_egl_resolve_aliases(void) { - if (sf_glad_eglClientWaitSync == NULL && sf_glad_eglClientWaitSyncKHR != NULL) sf_glad_eglClientWaitSync = (PFNEGLCLIENTWAITSYNCPROC)sf_glad_eglClientWaitSyncKHR; - if (sf_glad_eglClientWaitSyncKHR == NULL && sf_glad_eglClientWaitSync != NULL) sf_glad_eglClientWaitSyncKHR = (PFNEGLCLIENTWAITSYNCKHRPROC)sf_glad_eglClientWaitSync; - if (sf_glad_eglCreateSync == NULL && sf_glad_eglCreateSync64KHR != NULL) sf_glad_eglCreateSync = (PFNEGLCREATESYNCPROC)sf_glad_eglCreateSync64KHR; - if (sf_glad_eglCreateSync64KHR == NULL && sf_glad_eglCreateSync != NULL) sf_glad_eglCreateSync64KHR = (PFNEGLCREATESYNC64KHRPROC)sf_glad_eglCreateSync; - if (sf_glad_eglDestroyImage == NULL && sf_glad_eglDestroyImageKHR != NULL) sf_glad_eglDestroyImage = (PFNEGLDESTROYIMAGEPROC)sf_glad_eglDestroyImageKHR; - if (sf_glad_eglDestroyImageKHR == NULL && sf_glad_eglDestroyImage != NULL) sf_glad_eglDestroyImageKHR = (PFNEGLDESTROYIMAGEKHRPROC)sf_glad_eglDestroyImage; - if (sf_glad_eglDestroySync == NULL && sf_glad_eglDestroySyncKHR != NULL) sf_glad_eglDestroySync = (PFNEGLDESTROYSYNCPROC)sf_glad_eglDestroySyncKHR; - if (sf_glad_eglDestroySyncKHR == NULL && sf_glad_eglDestroySync != NULL) sf_glad_eglDestroySyncKHR = (PFNEGLDESTROYSYNCKHRPROC)sf_glad_eglDestroySync; -} - static int sf_glad_egl_get_extensions(EGLDisplay display, const char **extensions) { *extensions = eglQueryString(display, EGL_EXTENSIONS); @@ -1262,10 +1250,6 @@ static int sf_glad_egl_has_extension(const char *extensions, const char *ext) { } } -static GLADapiproc sf_glad_egl_get_proc_from_userptr(void *userptr, const char *name) { - return (GLAD_GNUC_EXTENSION (GLADapiproc (*)(const char *name)) userptr)(name); -} - static int sf_glad_egl_find_extensions_egl(EGLDisplay display) { const char *extensions; if (!sf_glad_egl_get_extensions(display, &extensions)) return 0; @@ -1344,12 +1328,6 @@ static int gladLoadEGLUserPtr(EGLDisplay display, GLADuserptrloadfunc load, void return version; } -static int gladLoadEGL(EGLDisplay display, GLADloadfunc load) { - return gladLoadEGLUserPtr(display, sf_glad_egl_get_proc_from_userptr, GLAD_GNUC_EXTENSION (void*) load); -} - - - #ifdef SF_GLAD_EGL #ifndef GLAD_LOADER_LIBRARY_C_ diff --git a/extlibs/headers/glad/include/glad/gl.h b/extlibs/headers/glad/include/glad/gl.h index 6d568509..9394a0a4 100644 --- a/extlibs/headers/glad/include/glad/gl.h +++ b/extlibs/headers/glad/include/glad/gl.h @@ -10128,153 +10128,6 @@ 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"); @@ -11294,36 +11147,6 @@ 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) { @@ -12155,91 +11978,6 @@ 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 diff --git a/extlibs/headers/glad/include/glad/wgl.h b/extlibs/headers/glad/include/glad/wgl.h index 1be9625e..2c443ac8 100644 --- a/extlibs/headers/glad/include/glad/wgl.h +++ b/extlibs/headers/glad/include/glad/wgl.h @@ -488,10 +488,6 @@ static void sf_glad_wgl_load_WGL_EXT_swap_control(GLADuserptrloadfunc load, void sf_glad_wglSwapIntervalEXT = (PFNWGLSWAPINTERVALEXTPROC) load(userptr, "wglSwapIntervalEXT"); } - -static void sf_glad_wgl_resolve_aliases(void) { -} - static int sf_glad_wgl_has_extension(HDC hdc, const char *ext) { const char *terminator; const char *loc; @@ -571,16 +567,6 @@ static int gladLoadWGLUserPtr(HDC hdc, GLADuserptrloadfunc load, void *userptr) static int gladLoadWGL(HDC hdc, GLADloadfunc load) { return gladLoadWGLUserPtr(hdc, sf_glad_wgl_get_proc_from_userptr, GLAD_GNUC_EXTENSION (void*) load); } - - -#ifdef SF_GLAD_WGL - -static int gladLoaderLoadWGL(HDC hdc) { - return gladLoadWGLUserPtr(hdc, sf_glad_wgl_get_proc_from_userptr, GLAD_GNUC_EXTENSION (void*) wglGetProcAddress); -} - - -#endif /* SF_GLAD_WGL */ #endif /* SF_GLAD_WGL_IMPLEMENTATION */ diff --git a/src/SFML/Graphics/CMakeLists.txt b/src/SFML/Graphics/CMakeLists.txt index 96e28481..52385782 100644 --- a/src/SFML/Graphics/CMakeLists.txt +++ b/src/SFML/Graphics/CMakeLists.txt @@ -96,7 +96,7 @@ target_link_libraries(sfml-graphics PUBLIC sfml-window) target_include_directories(sfml-graphics PRIVATE "${PROJECT_SOURCE_DIR}/extlibs/headers/stb_image") # glad sources -target_include_directories(sfml-graphics PRIVATE "${PROJECT_SOURCE_DIR}/extlibs/headers/glad/include") +target_include_directories(sfml-graphics SYSTEM PRIVATE "${PROJECT_SOURCE_DIR}/extlibs/headers/glad/include") # let CMake know about our additional graphics libraries paths if(SFML_OS_WINDOWS) diff --git a/src/SFML/Window/CMakeLists.txt b/src/SFML/Window/CMakeLists.txt index 2fa013fd..5b2852ac 100644 --- a/src/SFML/Window/CMakeLists.txt +++ b/src/SFML/Window/CMakeLists.txt @@ -239,7 +239,7 @@ sfml_add_library(sfml-window target_link_libraries(sfml-window PUBLIC sfml-system) # glad sources -target_include_directories(sfml-window PRIVATE "${PROJECT_SOURCE_DIR}/extlibs/headers/glad/include") +target_include_directories(sfml-window SYSTEM PRIVATE "${PROJECT_SOURCE_DIR}/extlibs/headers/glad/include") # When static linking on macOS, we need to add this flag for objective C to work if ((NOT BUILD_SHARED_LIBS) AND SFML_OS_MACOSX)