From fea0862a35032c26547b89909051d3df83bada1b Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Thu, 12 Jan 2017 00:50:44 +0530 Subject: [PATCH] Do not use GLEW on OS X --- kitty/gl.h | 30 ++++++++++++++++++++++++++++-- setup.py | 9 ++++++--- 2 files changed, 34 insertions(+), 5 deletions(-) diff --git a/kitty/gl.h b/kitty/gl.h index dee085985..80f03b62e 100644 --- a/kitty/gl.h +++ b/kitty/gl.h @@ -6,13 +6,26 @@ */ #include "data-types.h" +#ifdef __APPLE__ +#include +#include +#else #include +#endif #define STRINGIFY(x) #x #define METH(name, argtype) {STRINGIFY(gl##name), (PyCFunction)name, argtype, NULL}, static int _enable_error_checking = 1; +#ifndef GL_STACK_UNDERFLOW +#define GL_STACK_UNDERFLOW 0x0504 +#endif + +#ifndef GL_STACK_OVERFLOW +#define GL_STACK_OVERFLOW 0x0503 +#endif + #define SET_GL_ERR \ switch(glGetError()) { \ case GL_NO_ERROR: break; \ @@ -122,6 +135,7 @@ CheckError(PyObject UNUSED *self) { static PyObject* _glewInit(PyObject UNUSED *self) { +#ifndef __APPLE__ GLenum err = glewInit(); if (err != GLEW_OK) { PyErr_Format(PyExc_RuntimeError, "GLEW init failed: %s", glewGetErrorString(err)); @@ -131,6 +145,7 @@ _glewInit(PyObject UNUSED *self) { PyErr_SetString(PyExc_RuntimeError, "OpenGL is missing the required ARB_texture_storage extension"); return NULL; } +#endif Py_RETURN_NONE; } @@ -432,13 +447,19 @@ TexStorage3D(PyObject UNUSED *self, PyObject *args) { } static PyObject* +#if defined(__APPLE__) && !defined(glCopyImageSubData) +CopyImageSubData(PyObject UNUSED *self, UNUSED PyObject *args) { + PyErr_SetString(PyExc_RuntimeError, "OpenGL is missing the required ARB_copy_image extension"); + return NULL; +} +#else CopyImageSubData(PyObject UNUSED *self, PyObject *args) { - int src_target, src_level, srcX, srcY, srcZ, dest_target, dest_level, destX, destY, destZ; - unsigned int src, dest, width, height, depth; if(!GLEW_ARB_copy_image) { PyErr_SetString(PyExc_RuntimeError, "OpenGL is missing the required ARB_copy_image extension"); return NULL; } + int src_target, src_level, srcX, srcY, srcZ, dest_target, dest_level, destX, destY, destZ; + unsigned int src, dest, width, height, depth; if (!PyArg_ParseTuple(args, "IiiiiiIiiiiiIII", &src, &src_target, &src_level, &srcX, &srcY, &srcZ, &dest, &dest_target, &dest_level, &destX, &destY, &destZ, @@ -450,6 +471,7 @@ CopyImageSubData(PyObject UNUSED *self, PyObject *args) { CHECK_ERROR; Py_RETURN_NONE; } +#endif static PyObject* copy_image_sub_data(PyObject UNUSED *self, PyObject *args) { @@ -511,7 +533,11 @@ NamedBufferData(PyObject UNUSED *self, PyObject *args) { if (data == NULL) { PyErr_SetString(PyExc_TypeError, "Not a valid data pointer"); return NULL; } Py_BEGIN_ALLOW_THREADS; #ifdef glNamedBufferData +#ifdef __APPLE__ + if(false) { +#else if(GLEW_VERSION_4_5) { +#endif glNamedBufferData(target, size, data, usage); } else { glBindBuffer(GL_TEXTURE_BUFFER, target); glBufferData(GL_TEXTURE_BUFFER, size, data, usage); glBindBuffer(GL_TEXTURE_BUFFER, 0); diff --git a/setup.py b/setup.py index 92e90eae7..ea2a63958 100755 --- a/setup.py +++ b/setup.py @@ -90,7 +90,7 @@ def init_env(debug=False, asan=False): ldflags += shlex.split(os.environ.get('LDFLAGS', '')) cflags.append('-pthread') - if not is_travis and subprocess.Popen([PKGCONFIG, 'glew', '--atleast-version=2']).wait() != 0: + if not is_travis and not isosx and subprocess.Popen([PKGCONFIG, 'glew', '--atleast-version=2']).wait() != 0: try: ver = subprocess.check_output([PKGCONFIG, 'glew', '--modversion']).decode('utf-8').strip() major = int(re.match(r'\d+', ver).group()) @@ -99,7 +99,8 @@ def init_env(debug=False, asan=False): major = 0 if major < 2: raise SystemExit('glew >= 2.0.0 is required, found version: ' + ver) - cflags.extend(pkg_config('glew', '--cflags-only-I')) + if not isosx: + cflags.extend(pkg_config('glew', '--cflags-only-I')) if isosx: font_libs = ['-framework', 'CoreText', '-framework', 'CoreGraphics'] else: @@ -110,10 +111,12 @@ def init_env(debug=False, asan=False): pylib = get_python_flags(cflags) if isosx: glfw_ldflags = pkg_config('--libs', '--static', 'glfw3') + ['-framework', 'OpenGL'] + glew_libs = [] else: glfw_ldflags = pkg_config('glfw3', '--libs') + glew_libs = pkg_config('glew', '--libs') ldpaths = pylib + \ - pkg_config('glew', '--libs') + font_libs + glfw_ldflags + glew_libs + font_libs + glfw_ldflags try: os.mkdir(build_dir)