fix build error due to gcc 10

refer to: https://www.linuxfromscratch.org/patches/blfs/svn/freeglut-3.2.1-gcc10_fix-1.patch
This commit is contained in:
linjiaxin 2021-07-30 07:09:21 +00:00 committed by Lin Jiaxin
parent 801ffa413c
commit 431d8dc786
2 changed files with 50 additions and 1 deletions

View File

@ -1,11 +1,12 @@
Name: freeglut
Version: 3.0.0
Release: 10
Release: 11
Summary: A freely licensed alternative to the GLUT library
License: MIT
URL: http://freeglut.sourceforge.net
Source0: https://downloads.sourceforge.net/%{name}/%{name}-%{version}.tar.gz
Source1: https://downloads.sourceforge.net/openglut/openglut-0.6.3-doc.tar.gz
Patch0: gcc-10.patch
BuildRequires: gcc gcc-c++ cmake libXi-devel libICE-devel
BuildRequires: pkgconfig libGLU-devel libXext-devel libXxf86vm-devel
@ -66,5 +67,8 @@ install -p -m 644 doc/man/*.3 $RPM_BUILD_ROOT/%{_mandir}/man3
%doc README doc/*.png doc/*.html
%changelog
* Fri Jul 30 2021 linjiaxin5 <linjiaxin5@huawei.com> - 3.0.0-11
- Fix failure caused by GCC upgrade to 10
* Fri Nov 22 2019 sunguoshuai <sunguoshuai@huawei.com> - 3.0.0-10
- Package init.

45
gcc-10.patch Normal file
View File

@ -0,0 +1,45 @@
--- a/src/fg_gl2.c
+++ b/src/fg_gl2.c
@@ -26,6 +26,20 @@
#include <GL/freeglut.h>
#include "fg_internal.h"
#include "fg_gl2.h"
+
+#ifndef GL_ES_VERSION_2_0
+/* GLES2 has the corresponding entry points built-in, and these fgh-prefixed
+ * names are defined in fg_gl2.h header to reference them, for any other case,
+ * define them as function pointers here.
+ */
+FGH_PFNGLGENBUFFERSPROC fghGenBuffers;
+FGH_PFNGLDELETEBUFFERSPROC fghDeleteBuffers;
+FGH_PFNGLBINDBUFFERPROC fghBindBuffer;
+FGH_PFNGLBUFFERDATAPROC fghBufferData;
+FGH_PFNGLENABLEVERTEXATTRIBARRAYPROC fghEnableVertexAttribArray;
+FGH_PFNGLDISABLEVERTEXATTRIBARRAYPROC fghDisableVertexAttribArray;
+FGH_PFNGLVERTEXATTRIBPOINTERPROC fghVertexAttribPointer;
+#endif
void FGAPIENTRY glutSetVertexAttribCoord3(GLint attrib) {
if (fgStructure.CurrentWindow != NULL)
--- a/src/fg_gl2.h
+++ b/src/fg_gl2.h
@@ -67,13 +67,13 @@
typedef void (APIENTRY *FGH_PFNGLDISABLEVERTEXATTRIBARRAYPROC) (GLuint);
typedef void (APIENTRY *FGH_PFNGLVERTEXATTRIBPOINTERPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid *pointer);
-FGH_PFNGLGENBUFFERSPROC fghGenBuffers;
-FGH_PFNGLDELETEBUFFERSPROC fghDeleteBuffers;
-FGH_PFNGLBINDBUFFERPROC fghBindBuffer;
-FGH_PFNGLBUFFERDATAPROC fghBufferData;
-FGH_PFNGLENABLEVERTEXATTRIBARRAYPROC fghEnableVertexAttribArray;
-FGH_PFNGLDISABLEVERTEXATTRIBARRAYPROC fghDisableVertexAttribArray;
-FGH_PFNGLVERTEXATTRIBPOINTERPROC fghVertexAttribPointer;
+extern FGH_PFNGLGENBUFFERSPROC fghGenBuffers;
+extern FGH_PFNGLDELETEBUFFERSPROC fghDeleteBuffers;
+extern FGH_PFNGLBINDBUFFERPROC fghBindBuffer;
+extern FGH_PFNGLBUFFERDATAPROC fghBufferData;
+extern FGH_PFNGLENABLEVERTEXATTRIBARRAYPROC fghEnableVertexAttribArray;
+extern FGH_PFNGLDISABLEVERTEXATTRIBARRAYPROC fghDisableVertexAttribArray;
+extern FGH_PFNGLVERTEXATTRIBPOINTERPROC fghVertexAttribPointer;
# endif