diff --git a/0001-fixed-a-minor-bug-in-the-UNIX-X11-cursor-code-causin.patch b/0001-fixed-a-minor-bug-in-the-UNIX-X11-cursor-code-causin.patch new file mode 100644 index 0000000000000000000000000000000000000000..27a7cc14f8d15bdf373adcc8f19f1cb8c670b0ca --- /dev/null +++ b/0001-fixed-a-minor-bug-in-the-UNIX-X11-cursor-code-causin.patch @@ -0,0 +1,97 @@ +From bc5a65610a0df72d44f409a2e921a35e6d362db8 Mon Sep 17 00:00:00 2001 +From: John Tsiombikas +Date: Sat, 28 Feb 2015 04:15:13 +0000 +Subject: [PATCH] - fixed a minor bug in the UNIX/X11 cursor code, causing an X + error and abort due to a stale cursor cache, when the application (which + calls glutSetCursor), uses glutLeaveMainLoop to close the connection to the + X server, and then re-initializes freeglut and starts over with a new + connection. + +git-svn-id: svn+ssh://svn.code.sf.net/p/freeglut/code/trunk/freeglut/freeglut@1749 7f0cb862-5218-0410-a997-914c9d46530a +--- + src/x11/fg_cursor_x11.c | 53 ++++++++++++++++++++++++----------------- + 1 file changed, 31 insertions(+), 22 deletions(-) + +diff --git a/src/x11/fg_cursor_x11.c b/src/x11/fg_cursor_x11.c +index 6d889f25..9d15900b 100644 +--- a/src/x11/fg_cursor_x11.c ++++ b/src/x11/fg_cursor_x11.c +@@ -61,6 +61,7 @@ struct tag_cursorCacheEntry { + unsigned int cursorShape; /* an XC_foo value */ + Cursor cachedCursor; /* None if the corresponding cursor has + not been created yet */ ++ Display *dpy; /* display used to allocate this cursor */ + }; + + /* +@@ -68,26 +69,26 @@ struct tag_cursorCacheEntry { + * the "normal" GLUT_CURSOR_* values start a 0 and are consecutive. + */ + static cursorCacheEntry cursorCache[] = { +- { XC_arrow, None }, /* GLUT_CURSOR_RIGHT_ARROW */ +- { XC_top_left_arrow, None }, /* GLUT_CURSOR_LEFT_ARROW */ +- { XC_hand1, None }, /* GLUT_CURSOR_INFO */ +- { XC_pirate, None }, /* GLUT_CURSOR_DESTROY */ +- { XC_question_arrow, None }, /* GLUT_CURSOR_HELP */ +- { XC_exchange, None }, /* GLUT_CURSOR_CYCLE */ +- { XC_spraycan, None }, /* GLUT_CURSOR_SPRAY */ +- { XC_watch, None }, /* GLUT_CURSOR_WAIT */ +- { XC_xterm, None }, /* GLUT_CURSOR_TEXT */ +- { XC_crosshair, None }, /* GLUT_CURSOR_CROSSHAIR */ +- { XC_sb_v_double_arrow, None }, /* GLUT_CURSOR_UP_DOWN */ +- { XC_sb_h_double_arrow, None }, /* GLUT_CURSOR_LEFT_RIGHT */ +- { XC_top_side, None }, /* GLUT_CURSOR_TOP_SIDE */ +- { XC_bottom_side, None }, /* GLUT_CURSOR_BOTTOM_SIDE */ +- { XC_left_side, None }, /* GLUT_CURSOR_LEFT_SIDE */ +- { XC_right_side, None }, /* GLUT_CURSOR_RIGHT_SIDE */ +- { XC_top_left_corner, None }, /* GLUT_CURSOR_TOP_LEFT_CORNER */ +- { XC_top_right_corner, None }, /* GLUT_CURSOR_TOP_RIGHT_CORNER */ +- { XC_bottom_right_corner, None }, /* GLUT_CURSOR_BOTTOM_RIGHT_CORNER */ +- { XC_bottom_left_corner, None } /* GLUT_CURSOR_BOTTOM_LEFT_CORNER */ ++ { XC_arrow, None, 0 }, /* GLUT_CURSOR_RIGHT_ARROW */ ++ { XC_top_left_arrow, None, 0 }, /* GLUT_CURSOR_LEFT_ARROW */ ++ { XC_hand1, None, 0 }, /* GLUT_CURSOR_INFO */ ++ { XC_pirate, None, 0 }, /* GLUT_CURSOR_DESTROY */ ++ { XC_question_arrow, None, 0 }, /* GLUT_CURSOR_HELP */ ++ { XC_exchange, None, 0 }, /* GLUT_CURSOR_CYCLE */ ++ { XC_spraycan, None, 0 }, /* GLUT_CURSOR_SPRAY */ ++ { XC_watch, None, 0 }, /* GLUT_CURSOR_WAIT */ ++ { XC_xterm, None, 0 }, /* GLUT_CURSOR_TEXT */ ++ { XC_crosshair, None, 0 }, /* GLUT_CURSOR_CROSSHAIR */ ++ { XC_sb_v_double_arrow, None, 0 }, /* GLUT_CURSOR_UP_DOWN */ ++ { XC_sb_h_double_arrow, None, 0 }, /* GLUT_CURSOR_LEFT_RIGHT */ ++ { XC_top_side, None, 0 }, /* GLUT_CURSOR_TOP_SIDE */ ++ { XC_bottom_side, None, 0 }, /* GLUT_CURSOR_BOTTOM_SIDE */ ++ { XC_left_side, None, 0 }, /* GLUT_CURSOR_LEFT_SIDE */ ++ { XC_right_side, None, 0 }, /* GLUT_CURSOR_RIGHT_SIDE */ ++ { XC_top_left_corner, None, 0 }, /* GLUT_CURSOR_TOP_LEFT_CORNER */ ++ { XC_top_right_corner, None, 0 }, /* GLUT_CURSOR_TOP_RIGHT_CORNER */ ++ { XC_bottom_right_corner, None, 0 }, /* GLUT_CURSOR_BOTTOM_RIGHT_CORNER */ ++ { XC_bottom_left_corner, None, 0 } /* GLUT_CURSOR_BOTTOM_LEFT_CORNER */ + }; + + void fgPlatformSetCursor ( SFG_Window *window, int cursorID ) +@@ -104,10 +105,18 @@ void fgPlatformSetCursor ( SFG_Window *window, int cursorID ) + if( ( cursorIDToUse >= 0 ) && + ( cursorIDToUse < sizeof( cursorCache ) / sizeof( cursorCache[0] ) ) ) { + cursorCacheEntry *entry = &cursorCache[ cursorIDToUse ]; +- if( entry->cachedCursor == None ) { ++ ++ /* the second clause forces an invalidation of the cached cursor, if it was ++ * created through a different display connection. ++ * This can only happen, in the extremely rare case where the user program calls the ++ * freeglut extension glutLeaveMainLoop, and then re-initializes freeglut and ++ * starts over. ++ */ ++ if( entry->cachedCursor == None || entry->dpy != fgDisplay.pDisplay.Display ) { + entry->cachedCursor = + XCreateFontCursor( fgDisplay.pDisplay.Display, entry->cursorShape ); +- } ++ entry->dpy = fgDisplay.pDisplay.Display; ++ } + cursor = entry->cachedCursor; + } else { + switch( cursorIDToUse ) +-- +2.27.0 + diff --git a/fix-crash-when-calling-primitive-drawing-functions-w.patch b/fix-crash-when-calling-primitive-drawing-functions-w.patch new file mode 100644 index 0000000000000000000000000000000000000000..f7bcce034e777efbc5300b5f34d37892781cf801 --- /dev/null +++ b/fix-crash-when-calling-primitive-drawing-functions-w.patch @@ -0,0 +1,71 @@ +From 5293dd930619aa472daeda11468fd4475d4d2078 Mon Sep 17 00:00:00 2001 +From: John Tsiombikas +Date: Wed, 22 Dec 2021 22:01:02 +0000 +Subject: [PATCH] fix crash when calling primitive drawing functions without + creating a window (bug report #255) + +git-svn-id: svn+ssh://svn.code.sf.net/p/freeglut/code/trunk/freeglut/freeglut@1868 7f0cb862-5218-0410-a997-914c9d46530a +--- + src/fg_geometry.c | 24 ++++++++++++++++-------- + 1 file changed, 16 insertions(+), 8 deletions(-) + +diff --git a/src/fg_geometry.c b/src/fg_geometry.c +index e41f01db..f5af1665 100644 +--- a/src/fg_geometry.c ++++ b/src/fg_geometry.c +@@ -134,8 +134,10 @@ void fghDrawGeometryWire(GLfloat *vertices, GLfloat *normals, GLsizei numVertice + GLushort *vertIdxs2, GLsizei numParts2, GLsizei numVertPerPart2 + ) + { +- GLint attribute_v_coord = fgStructure.CurrentWindow->Window.attribute_v_coord; +- GLint attribute_v_normal = fgStructure.CurrentWindow->Window.attribute_v_normal; ++ SFG_Window *win = fgStructure.CurrentWindow; ++ ++ GLint attribute_v_coord = win ? win->Window.attribute_v_coord : -1; ++ GLint attribute_v_normal = win ? win->Window.attribute_v_normal : -1; + + if (fgState.HasOpenGL20 && (attribute_v_coord != -1 || attribute_v_normal != -1)) + /* User requested a 2.0 draw */ +@@ -178,11 +180,17 @@ void fghDrawGeometryWire(GLfloat *vertices, GLfloat *normals, GLsizei numVertice + void fghDrawGeometrySolid(GLfloat *vertices, GLfloat *normals, GLfloat *textcs, GLsizei numVertices, + GLushort *vertIdxs, GLsizei numParts, GLsizei numVertIdxsPerPart) + { +- GLint attribute_v_coord = fgStructure.CurrentWindow->Window.attribute_v_coord; +- GLint attribute_v_normal = fgStructure.CurrentWindow->Window.attribute_v_normal; +- GLint attribute_v_texture = fgStructure.CurrentWindow->Window.attribute_v_texture; ++ GLint attribute_v_coord, attribute_v_normal, attribute_v_texture; ++ SFG_Window *win = fgStructure.CurrentWindow; ++ if(win) { ++ attribute_v_coord = win->Window.attribute_v_coord; ++ attribute_v_normal = win->Window.attribute_v_normal; ++ attribute_v_texture = win->Window.attribute_v_texture; ++ } else { ++ attribute_v_coord = attribute_v_normal = attribute_v_texture = -1; ++ } + +- if (fgStructure.CurrentWindow->State.VisualizeNormals) ++ if (win && win->State.VisualizeNormals) + /* generate normals for each vertex to be drawn as well */ + fghGenerateNormalVisualization(vertices, normals, numVertices); + +@@ -193,7 +201,7 @@ void fghDrawGeometrySolid(GLfloat *vertices, GLfloat *normals, GLfloat *textcs, + vertIdxs, numParts, numVertIdxsPerPart, + attribute_v_coord, attribute_v_normal, attribute_v_texture); + +- if (fgStructure.CurrentWindow->State.VisualizeNormals) ++ if (win && win->State.VisualizeNormals) + /* draw normals for each vertex as well */ + fghDrawNormalVisualization20(attribute_v_coord); + } +@@ -202,7 +210,7 @@ void fghDrawGeometrySolid(GLfloat *vertices, GLfloat *normals, GLfloat *textcs, + fghDrawGeometrySolid11(vertices, normals, textcs, numVertices, + vertIdxs, numParts, numVertIdxsPerPart); + +- if (fgStructure.CurrentWindow->State.VisualizeNormals) ++ if (win && win->State.VisualizeNormals) + /* draw normals for each vertex as well */ + fghDrawNormalVisualization11(); + } +-- +2.27.0 + diff --git a/freeglut.spec b/freeglut.spec index 73ad4150a8c2c5f3526a78cc3ccdfc16aebf6b98..8c6a36d286203d30c4a5a57dc11f211911b20b4b 100644 --- a/freeglut.spec +++ b/freeglut.spec @@ -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: 0001-fix-crash-when-calling-primitive-drawing-functions-w.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 Nov 22 2023 fandehui - 3.0.0-11 +- fix crash when calling primitive drawing functions without creating a window (bug report #255) + * Fri Nov 22 2019 sunguoshuai - 3.0.0-10 - Package init.