From 5bb23bcd6a21db9f346880f67ca7959be5f38021 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Wed, 3 Jun 2015 15:27:11 -0700 Subject: [PATCH 1/3] Switch the Linux build from GLEW to libepoxy. Epoxy is a modern replacement for GLEW that properly supports OpenGL's core profile mode, and fixes many bugs and issues with GLEW. See https://github.com/anholt/libepoxy for more information. --- Makefile | 2 +- glprocs.cc | 7 ------- glprocs.hh | 2 +- 3 files changed, 2 insertions(+), 9 deletions(-) diff --git a/Makefile b/Makefile index c26c7f3..ec80509 100644 --- a/Makefile +++ b/Makefile @@ -49,7 +49,7 @@ LINKFLAGS := -pthread -lAntTweakBar $(shell sdl2-config --libs) $(shell freetype ARCH = $(shell uname -s) ifeq ($(ARCH),Linux) -LINKFLAGS += -lGLEW -lGL +LINKFLAGS += -lepoxy -lGL else ifeq ($(ARCH),Darwin) LINKFLAGS += -framework OpenGL diff --git a/glprocs.cc b/glprocs.cc index 0f3dd52..8d8b1b3 100644 --- a/glprocs.cc +++ b/glprocs.cc @@ -50,11 +50,4 @@ void initGLProcs() { -#ifndef __APPLE__ - GLenum glewInitResult = glewInit(); - if (glewInitResult != GLEW_OK) { - fprintf(stderr, "glewInit(): %s\n", glewGetErrorString(glewInitResult)); - exit(1); - } -#endif } diff --git a/glprocs.hh b/glprocs.hh index 5ff2d8d..fd0bba7 100644 --- a/glprocs.hh +++ b/glprocs.hh @@ -49,7 +49,7 @@ #ifdef __APPLE__ #include #else -#include +#include #endif void initGLProcs(); From f305e9d4f5ed892bbc56fee8bc2afa99cf277f1a Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Wed, 3 Jun 2015 15:35:01 -0700 Subject: [PATCH 2/3] Delete empty initGLProcs() function. This was necessary with GLEW, but isn't necessary with libepoxy. --- Makefile | 1 - glprocs.cc | 53 ----------------------------------------------------- glprocs.hh | 2 -- sdl_main.cc | 6 ------ 4 files changed, 62 deletions(-) delete mode 100644 glprocs.cc diff --git a/Makefile b/Makefile index ec80509..ca5aeee 100644 --- a/Makefile +++ b/Makefile @@ -74,7 +74,6 @@ OFILES=\ solid.o \ cloud.o \ final.o \ - glprocs.o \ myTwEventSDL20.o \ icon.o \ widget.o \ diff --git a/glprocs.cc b/glprocs.cc deleted file mode 100644 index 8d8b1b3..0000000 --- a/glprocs.cc +++ /dev/null @@ -1,53 +0,0 @@ -/* - * This file is part of the Electron Orbital Explorer. The Electron - * Orbital Explorer is distributed under the Simplified BSD License - * (also called the "BSD 2-Clause License"), in hopes that these - * rendering techniques might be used by other programmers in - * applications such as scientific visualization, video gaming, and so - * on. If you find value in this software and use its technologies for - * another purpose, I would love to hear back from you at bjthinks (at) - * gmail (dot) com. If you improve this software and agree to release - * your modifications under the below license, I encourage you to fork - * the development tree on github and push your modifications. The - * Electron Orbital Explorer's development URL is: - * https://github.com/bjthinks/orbital-explorer - * (This paragraph is not part of the software license and may be - * removed.) - * - * Copyright (c) 2013, Brian W. Johnson - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * + Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * + Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#include - -#include "glprocs.hh" - -void initGLProcs() -{ -} diff --git a/glprocs.hh b/glprocs.hh index fd0bba7..e28b1b7 100644 --- a/glprocs.hh +++ b/glprocs.hh @@ -52,6 +52,4 @@ #include #endif -void initGLProcs(); - #endif diff --git a/sdl_main.cc b/sdl_main.cc index 6128efa..338123c 100644 --- a/sdl_main.cc +++ b/sdl_main.cc @@ -128,12 +128,6 @@ static int go() exit(1); } - // - // Get access to OpenGL functions - // - - initGLProcs(); - // // Initialize orbital rendering pipeline // From a2f314924aa1efb23d55628b04dd5cfcd5ecfdb1 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Wed, 3 Jun 2015 15:32:39 -0700 Subject: [PATCH 3/3] Use an OpenGL 3.2 Core Profile context on all platforms (not just Apple). This should work equally well on all platforms. It's also required to run on Linux systems using Mesa-based drivers, which only expose geometry shaders in core profile contexts. --- sdl_main.cc | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/sdl_main.cc b/sdl_main.cc index 338123c..2743557 100644 --- a/sdl_main.cc +++ b/sdl_main.cc @@ -97,13 +97,10 @@ static int go() set_sdl_attr(SDL_GL_MULTISAMPLEBUFFERS, 1); set_sdl_attr(SDL_GL_MULTISAMPLESAMPLES, 4); -#ifdef __APPLE__ - // Apple defaults to an OpenGL 2.1 Compatibility context unless you - // specify otherwise. + // Use an OpenGL 3.2 Core Profile context. set_sdl_attr(SDL_GL_CONTEXT_MAJOR_VERSION, 3); set_sdl_attr(SDL_GL_CONTEXT_MINOR_VERSION, 2); set_sdl_attr(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE); -#endif Viewport viewport(640, 480);