Skip to content

Commit

Permalink
Linux: update GLEW to 2.2.0, and enable EGL support in GLEW to match …
Browse files Browse the repository at this point in the history
…wxWidgets

On Linux, wxGTK by default attempts to use EGL if it is available on the
system, rather than GLX.  Unfortunately, the ancient version of GLEW that we
packaged in did not support EGL, and even if it did, the configuration was
not set up to enable EGL.  To solve this, we:

  * upgrade GLEW to version 2.2.0, from upstream GitHub

  * modify the Bambu build process to enforce that we use GLEW from the
    built dependency

  * remove the "extra" even older GLEW that was packaged

  * modify GLEW's CMake configuration to enable EGL support when it is
    available on the system (using the same test as wxWidgets uses to decide
    whether to enable EGL support); if EGL isn't available at compile time,
    both GLEW and wxWidgets will fall back on GLX

Note that you probably will have to blow away your CMakeCache for this to
work correctly -- otherwise, you may end up with the system GLEW, if you
have one installed (which is probably not what you want -- on Ubuntu, the
system GLEW is GLX, not EGL).
  • Loading branch information
jwise authored and lanewei120 committed Jan 12, 2023
1 parent fdba596 commit fe13ca0
Show file tree
Hide file tree
Showing 16 changed files with 30,716 additions and 69,536 deletions.
11 changes: 1 addition & 10 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -484,16 +484,7 @@ if (SLIC3R_STATIC AND NOT SLIC3R_STATIC_EXCLUDE_GLEW)
set(GLEW_VERBOSE ON)
endif()

find_package(GLEW)
if (NOT TARGET GLEW::GLEW)
message(STATUS "GLEW not found, using bundled version.")
add_library(glew STATIC ${LIBDIR}/glew/src/glew.c)
set(GLEW_FOUND TRUE)
set(GLEW_INCLUDE_DIRS ${LIBDIR}/glew/include/)
target_compile_definitions(glew PUBLIC GLEW_STATIC)
target_include_directories(glew PUBLIC ${GLEW_INCLUDE_DIRS})
add_library(GLEW::GLEW ALIAS glew)
endif ()
find_package(GLEW REQUIRED)

find_package(glfw3 REQUIRED)

Expand Down
13 changes: 7 additions & 6 deletions cmake/modules/FindGLEW.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -94,19 +94,20 @@ endif()

function(__glew_set_find_library_suffix shared_or_static)
if((UNIX AND NOT APPLE) AND "${shared_or_static}" MATCHES "SHARED")
set(CMAKE_FIND_LIBRARY_SUFFIXES ".so" PARENT_SCOPE)
set(CMAKE_FIND_LIBRARY_SUFFIXES ".so")
elseif((UNIX AND NOT APPLE) AND "${shared_or_static}" MATCHES "STATIC")
set(CMAKE_FIND_LIBRARY_SUFFIXES ".a" PARENT_SCOPE)
set(CMAKE_FIND_LIBRARY_SUFFIXES ".a")
elseif(APPLE AND "${shared_or_static}" MATCHES "SHARED")
set(CMAKE_FIND_LIBRARY_SUFFIXES ".dylib;.so" PARENT_SCOPE)
set(CMAKE_FIND_LIBRARY_SUFFIXES ".dylib;.so")
elseif(APPLE AND "${shared_or_static}" MATCHES "STATIC")
set(CMAKE_FIND_LIBRARY_SUFFIXES ".a" PARENT_SCOPE)
set(CMAKE_FIND_LIBRARY_SUFFIXES ".a")
elseif(WIN32 AND "${shared_or_static}" MATCHES "SHARED")
set(CMAKE_FIND_LIBRARY_SUFFIXES ".lib" PARENT_SCOPE)
set(CMAKE_FIND_LIBRARY_SUFFIXES ".lib")
elseif(WIN32 AND "${shared_or_static}" MATCHES "STATIC")
set(CMAKE_FIND_LIBRARY_SUFFIXES ".lib;.a;.dll.a" PARENT_SCOPE)
set(CMAKE_FIND_LIBRARY_SUFFIXES ".lib;.a;.dll.a")
endif()

set(CMAKE_FIND_LIBRARY_SUFFIXES "${CMAKE_FIND_LIBRARY_SUFFIXES}" PARENT_SCOPE)
if(GLEW_VERBOSE)
message(STATUS "FindGLEW: CMAKE_FIND_LIBRARY_SUFFIXES for ${shared_or_static}: ${CMAKE_FIND_LIBRARY_SUFFIXES}")
endif()
Expand Down
19 changes: 11 additions & 8 deletions deps/GLEW/glew/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,17 @@ project(GLEW)

find_package(OpenGL REQUIRED)

add_library(glew src/glew.c)
target_include_directories(glew PRIVATE include/)
target_link_libraries(glew PUBLIC OpenGL::GL)
if(OpenGL_EGL_FOUND)
message(STATUS "building GLEW for EGL (hope that wxWidgets agrees, otherwise you won't have any output!)")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DGLEW_EGL")
endif()

add_library(GLEW src/glew.c)
target_include_directories(GLEW PRIVATE include/)
target_link_libraries(GLEW PUBLIC OpenGL::GL)

if (NOT BUILD_SHARED_LIBS)
target_compile_definitions(glew PUBLIC GLEW_STATIC)
target_compile_definitions(GLEW PUBLIC GLEW_STATIC)
endif ()

include(GNUInstallDirs)
Expand All @@ -18,14 +23,12 @@ install(
${PROJECT_SOURCE_DIR}/include/GL/glew.h
${PROJECT_SOURCE_DIR}/include/GL/wglew.h
${PROJECT_SOURCE_DIR}/include/GL/glxew.h
${PROJECT_SOURCE_DIR}/include/GL/eglew.h
DESTINATION
${CMAKE_INSTALL_INCLUDEDIR}/GL
)

add_library(GLEW INTERFACE)
target_link_libraries(GLEW INTERFACE glew)

install(TARGETS glew GLEW
install(TARGETS GLEW GLEW
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
Expand Down
138 changes: 100 additions & 38 deletions deps/GLEW/glew/README.md
Original file line number Diff line number Diff line change
@@ -1,78 +1,129 @@
THIS IS NOT THE COMPLETE GLEW DISTRIBUTION. ONLY FILES NEEDED FOR COMPILING GLEW INTO SLIC3R WERE PUT INTO THE SLIC3R SOURCE DISTRIBUTION.

A CMAKE CONFIG EXPORT IS ADDED TO ENABLE FIND PACKAGE TO FIND DEBUG BUILD ON MSVC

# GLEW - The OpenGL Extension Wrangler Library

The OpenGL Extension Wrangler Library (GLEW) is a cross-platform open-source C/C++ extension loading library. GLEW provides efficient run-time mechanisms for determining which OpenGL extensions are supported on the target platform. OpenGL core and extension functionality is exposed in a single header file. GLEW has been tested on a variety of operating systems, including Windows, Linux, Mac OS X, FreeBSD, Irix, and Solaris.

![](http://glew.sourceforge.net/glew.png)

http://glew.sourceforge.net/

https://github.com.cnpmjs.org/nigels-com/glew
https://github.com/nigels-com/glew

[![Build Status](https://travis-ci.org/nigels-com/glew.svg?branch=master)](https://travis-ci.org/nigels-com/glew)
[![Gitter](https://badges.gitter.im/nigels-com/glew.svg)](https://gitter.im/nigels-com/glew?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge)
[![Download](https://img.shields.io/sourceforge/dm/glew.svg)](https://sourceforge.net/projects/glew/files/latest/download)

## Table of Contents

* [Downloads](#downloads)
* [Recent snapshots](#recent-snapshots)
* [Build](#build)
* [Linux and Mac](#linux-and-mac)
* [Using GNU Make](#using-gnu-make)
* [Install build tools](#install-build-tools)
* [Build](#build-1)
* [Linux EGL](#linux-egl)
* [Linux OSMesa](#linux-osmesa)
* [Linux mingw-w64](#linux-mingw-w64)
* [Using cmake](#using-cmake)
* [Install build tools](#install-build-tools-1)
* [Build](#build-2)
* [Windows](#windows)
* [Visual Studio](#visual-studio)
* [MSYS/Mingw](#msysmingw)
* [MSYS2/Mingw-w64](#msys2mingw-w64)
* [glewinfo](#glewinfo)
* [Code Generation](#code-generation)
* [Authors](#authors)
* [Contributions](#contributions)
* [Copyright and Licensing](#copyright-and-licensing)

## Downloads

Current release is [2.0.0](https://sourceforge.net/projects/glew/files/glew/2.0.0/).
Current release is [2.1.0](https://sourceforge.net/projects/glew/files/glew/2.1.0/).
[(Change Log)](http://glew.sourceforge.net/log.html)

Sources available as
[ZIP](https://sourceforge.net/projects/glew/files/glew/2.0.0/glew-2.0.0.zip/download) or
[TGZ](https://sourceforge.net/projects/glew/files/glew/2.0.0/glew-2.0.0.tgz/download).
Sources available as
[ZIP](https://sourceforge.net/projects/glew/files/glew/2.1.0/glew-2.1.0.zip/download) or
[TGZ](https://sourceforge.net/projects/glew/files/glew/2.1.0/glew-2.1.0.tgz/download).

Windows binaries for [32-bit and 64-bit](https://sourceforge.net/projects/glew/files/glew/2.0.0/glew-2.0.0-win32.zip/download).
Windows binaries for [32-bit and 64-bit](https://sourceforge.net/projects/glew/files/glew/2.1.0/glew-2.1.0-win32.zip/download).

### Recent snapshots

Snapshots may contain new features, bug-fixes or new OpenGL extensions ahead of tested, official releases.

[glew-20160708.tgz](http://sourceforge.net/projects/glew/files/glew/snapshots/glew-20160708.tgz/download)
*GLEW 2.0.0 RC: Core context, EGL support, no MX*
[glew-20200115.tgz](https://sourceforge.net/projects/glew/files/glew/snapshots/glew-20200115.tgz/download) *GLEW 2.2.0 RC3: fixes*

[glew-20160402.tgz](http://sourceforge.net/projects/glew/files/glew/snapshots/glew-20160402.tgz/download)
*GLEW 2.0.0 RC: Core context, EGL support, no MX*
[glew-20190928.tgz](https://sourceforge.net/projects/glew/files/glew/snapshots/glew-20190928.tgz/download) *GLEW 2.2.0 RC2: New extensions, bug fixes*

## Build

From a downloaded tarball or zip archive:
It is highly recommended to build from a tgz or zip release snapshot.
The code generation workflow is a complex brew of gnu make, perl and python, that works best on Linux or Mac.
The code generation is known to work on Windows using [MSYS2](https://www.msys2.org/).
For most end-users of GLEW the official releases are the best choice, with first class support.

### Linux and Mac

#### Using GNU Make

GNU make is the primary build system for GLEW, historically.
It includes targets for building the sources and headers, for maintenance purposes.

##### Install build tools

Debian/Ubuntu/Mint: `$ sudo apt-get install build-essential libxmu-dev libxi-dev libgl-dev libosmesa-dev git`
Debian/Ubuntu/Mint: `$ sudo apt-get install build-essential libxmu-dev libxi-dev libgl-dev`

RedHat/CentOS/Fedora: `$ sudo yum install libXmu-devel libXi-devel libGL-devel`

RedHat/CentOS/Fedora: `$ sudo yum install libXmu-devel libXi-devel libGL-devel git`
FreeBSD: `# pkg install xorg lang/gcc git cmake gmake bash python perl5`

##### Build

$ make
$ sudo make install
$ make clean

Targets: `all, glew.lib, glew.bin, clean, install, uninstall`
Targets: `all, glew.lib (sub-targets: glew.lib.shared, glew.lib.static), glew.bin, clean, install, uninstall`

Variables: `SYSTEM=linux-clang, GLEW_DEST=/usr/local, STRIP=`

_Note: you may need to call `make` in the **auto** folder first_

##### Linux EGL

$ sudo apt install libegl1-mesa-dev
$ make SYSTEM=linux-egl

##### Linux OSMesa

$ sudo apt install libosmesa-dev
$ make SYSTEM=linux-osmesa

##### Linux mingw-w64

$ sudo apt install mingw-w64
$ make SYSTEM=linux-mingw32
$ make SYSTEM=linux-mingw64

#### Using cmake

The cmake build is mostly contributer maintained.
Due to the multitude of use cases this is maintained on a _best effort_ basis.
Pull requests are welcome.

*CMake 2.8.12 or higher is required.*

##### Install build tools

Debian/Ubuntu/Mint: `$ sudo apt-get install build-essential libXmu-dev libXi-dev libgl-dev git cmake`
Debian/Ubuntu/Mint: `$ sudo apt-get install build-essential libxmu-dev libxi-dev libgl-dev cmake git`

RedHat/CentOS/Fedora: `$ sudo yum install libXmu-devel libXi-devel libGL-devel git cmake`
RedHat/CentOS/Fedora: `$ sudo yum install libXmu-devel libXi-devel libGL-devel cmake git`

##### Build

$ cd build
$ cmake ./cmake
$ cmake ./cmake
$ make -j4

| Target | Description |
Expand All @@ -96,9 +147,9 @@ RedHat/CentOS/Fedora: `$ sudo yum install libXmu-devel libXi-devel libGL-devel g

#### Visual Studio

Use the provided Visual Studio project file in build/vc12/
Use the provided Visual Studio project file in build/vc15/

Projects for vc6 and vc10 are also provided
Projects for vc6, vc10, vc12 and vc14 are also provided

#### MSYS/Mingw

Expand All @@ -118,7 +169,7 @@ Available from [Msys2](http://msys2.github.io/) and/or [Mingw-w64](http://mingw-

Requirements: bash, make, gcc

$ pacman -S gcc make mingw-w64-i686-gcc mingw-w64-x86_64-gcc
$ pacman -S gcc make mingw-w64-i686-gcc mingw-w64-x86_64-gcc
$ make
$ make install
$ make install.all
Expand All @@ -128,8 +179,8 @@ Alternative toolchain: `SYSTEM=msys, SYSTEM=msys-win32, SYSTEM=msys-win64`
## glewinfo

`glewinfo` is a command-line tool useful for inspecting the capabilities of an
OpenGL implementation and GLEW support for that. Please include the output of
`glewinfo` with bug reports, as appropriate.
OpenGL implementation and GLEW support for that. Please include `glewinfo.txt`
with bug reports, as appropriate.

---------------------------
GLEW Extension Info
Expand All @@ -149,12 +200,12 @@ OpenGL implementation and GLEW support for that. Please include the output of
glDrawRangeElements: OK
glTexImage3D: OK
glTexSubImage3D: OK

...

## Code Generation

A Unix or Mac environment is neded for building GLEW from scratch to
A Unix or Mac environment is needed for building GLEW from scratch to
include new extensions, or customize the code generation. The extension
data is regenerated from the top level source directory with:

Expand All @@ -165,32 +216,43 @@ download a pre-generated (unsupported) snapshot:

https://sourceforge.net/projects/glew/files/glew/snapshots/

Travis-built snapshots are also available:

https://glew.s3.amazonaws.com/index.html

## Authors

GLEW is currently maintained by [Nigel Stewart](https://github.com.cnpmjs.org/nigels-com)
GLEW is currently maintained by [Nigel Stewart](https://github.com/nigels-com)
with bug fixes, new OpenGL extension support and new releases.

GLEW was developed by [Milan Ikits](http://www.cs.utah.edu/~ikits/)
and [Marcelo Magallon](http://wwwvis.informatik.uni-stuttgart.de/~magallon/).
Aaron Lefohn, Joe Kniss, and Chris Wyman were the first users and also
assisted with the design and debugging process.
assisted with the design and debugging process.

The acronym GLEW originates from Aaron Lefohn.
Pasi Kärkkäinen identified and fixed several problems with
GLX and SDL. Nate Robins created the `wglinfo` utility, to
which modifications were made by Michael Wimmer.
which modifications were made by Michael Wimmer.

## Contributions

GLEW welcomes community contributions. Typically these are co-ordinated
via [Issues](https://github.com/nigels-com/glew/issues) or
[Pull Requests](https://github.com/nigels-com/glew/pulls) in the
GitHub web interface.

Be sure to mention platform and compiler toolchain details when filing
a bug report. The output of `glewinfo` can be quite useful for discussion
also.

Generally GLEW is usually released once a year, around the time of the Siggraph
computer graphics conference. If you're not using the current release
version of GLEW, be sure to check if the issue or bug is fixed there.

## Copyright and Licensing

GLEW is originally derived from the EXTGL project by Lev Povalahev.
The source code is licensed under the
[Modified BSD License](http://glew.sourceforge.net/glew.txt), the
The source code is licensed under the
[Modified BSD License](http://glew.sourceforge.net/glew.txt), the
[Mesa 3-D License](http://glew.sourceforge.net/mesa.txt) (MIT) and the
[Khronos License](http://glew.sourceforge.net/khronos.txt) (MIT).

The automatic code generation scripts are released under the
The automatic code generation scripts are released under the
[GNU GPL](http://glew.sourceforge.net/gpl.txt).
2 changes: 1 addition & 1 deletion deps/GLEW/glew/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.13.0
2.2.0
Loading

0 comments on commit fe13ca0

Please sign in to comment.