Do not use GLEW on OS X
This commit is contained in:
parent
063ec7dc02
commit
fea0862a35
30
kitty/gl.h
30
kitty/gl.h
@ -6,13 +6,26 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "data-types.h"
|
#include "data-types.h"
|
||||||
|
#ifdef __APPLE__
|
||||||
|
#include <OpenGL/gl3.h>
|
||||||
|
#include <OpenGL/gl3ext.h>
|
||||||
|
#else
|
||||||
#include <GL/glew.h>
|
#include <GL/glew.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#define STRINGIFY(x) #x
|
#define STRINGIFY(x) #x
|
||||||
#define METH(name, argtype) {STRINGIFY(gl##name), (PyCFunction)name, argtype, NULL},
|
#define METH(name, argtype) {STRINGIFY(gl##name), (PyCFunction)name, argtype, NULL},
|
||||||
|
|
||||||
static int _enable_error_checking = 1;
|
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 \
|
#define SET_GL_ERR \
|
||||||
switch(glGetError()) { \
|
switch(glGetError()) { \
|
||||||
case GL_NO_ERROR: break; \
|
case GL_NO_ERROR: break; \
|
||||||
@ -122,6 +135,7 @@ CheckError(PyObject UNUSED *self) {
|
|||||||
|
|
||||||
static PyObject*
|
static PyObject*
|
||||||
_glewInit(PyObject UNUSED *self) {
|
_glewInit(PyObject UNUSED *self) {
|
||||||
|
#ifndef __APPLE__
|
||||||
GLenum err = glewInit();
|
GLenum err = glewInit();
|
||||||
if (err != GLEW_OK) {
|
if (err != GLEW_OK) {
|
||||||
PyErr_Format(PyExc_RuntimeError, "GLEW init failed: %s", glewGetErrorString(err));
|
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");
|
PyErr_SetString(PyExc_RuntimeError, "OpenGL is missing the required ARB_texture_storage extension");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
Py_RETURN_NONE;
|
Py_RETURN_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -432,13 +447,19 @@ TexStorage3D(PyObject UNUSED *self, PyObject *args) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static PyObject*
|
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) {
|
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) {
|
if(!GLEW_ARB_copy_image) {
|
||||||
PyErr_SetString(PyExc_RuntimeError, "OpenGL is missing the required ARB_copy_image extension");
|
PyErr_SetString(PyExc_RuntimeError, "OpenGL is missing the required ARB_copy_image extension");
|
||||||
return NULL;
|
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",
|
if (!PyArg_ParseTuple(args, "IiiiiiIiiiiiIII",
|
||||||
&src, &src_target, &src_level, &srcX, &srcY, &srcZ,
|
&src, &src_target, &src_level, &srcX, &srcY, &srcZ,
|
||||||
&dest, &dest_target, &dest_level, &destX, &destY, &destZ,
|
&dest, &dest_target, &dest_level, &destX, &destY, &destZ,
|
||||||
@ -450,6 +471,7 @@ CopyImageSubData(PyObject UNUSED *self, PyObject *args) {
|
|||||||
CHECK_ERROR;
|
CHECK_ERROR;
|
||||||
Py_RETURN_NONE;
|
Py_RETURN_NONE;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
static PyObject*
|
static PyObject*
|
||||||
copy_image_sub_data(PyObject UNUSED *self, PyObject *args) {
|
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; }
|
if (data == NULL) { PyErr_SetString(PyExc_TypeError, "Not a valid data pointer"); return NULL; }
|
||||||
Py_BEGIN_ALLOW_THREADS;
|
Py_BEGIN_ALLOW_THREADS;
|
||||||
#ifdef glNamedBufferData
|
#ifdef glNamedBufferData
|
||||||
|
#ifdef __APPLE__
|
||||||
|
if(false) {
|
||||||
|
#else
|
||||||
if(GLEW_VERSION_4_5) {
|
if(GLEW_VERSION_4_5) {
|
||||||
|
#endif
|
||||||
glNamedBufferData(target, size, data, usage);
|
glNamedBufferData(target, size, data, usage);
|
||||||
} else {
|
} else {
|
||||||
glBindBuffer(GL_TEXTURE_BUFFER, target); glBufferData(GL_TEXTURE_BUFFER, size, data, usage); glBindBuffer(GL_TEXTURE_BUFFER, 0);
|
glBindBuffer(GL_TEXTURE_BUFFER, target); glBufferData(GL_TEXTURE_BUFFER, size, data, usage); glBindBuffer(GL_TEXTURE_BUFFER, 0);
|
||||||
|
|||||||
9
setup.py
9
setup.py
@ -90,7 +90,7 @@ def init_env(debug=False, asan=False):
|
|||||||
ldflags += shlex.split(os.environ.get('LDFLAGS', ''))
|
ldflags += shlex.split(os.environ.get('LDFLAGS', ''))
|
||||||
|
|
||||||
cflags.append('-pthread')
|
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:
|
try:
|
||||||
ver = subprocess.check_output([PKGCONFIG, 'glew', '--modversion']).decode('utf-8').strip()
|
ver = subprocess.check_output([PKGCONFIG, 'glew', '--modversion']).decode('utf-8').strip()
|
||||||
major = int(re.match(r'\d+', ver).group())
|
major = int(re.match(r'\d+', ver).group())
|
||||||
@ -99,7 +99,8 @@ def init_env(debug=False, asan=False):
|
|||||||
major = 0
|
major = 0
|
||||||
if major < 2:
|
if major < 2:
|
||||||
raise SystemExit('glew >= 2.0.0 is required, found version: ' + ver)
|
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:
|
if isosx:
|
||||||
font_libs = ['-framework', 'CoreText', '-framework', 'CoreGraphics']
|
font_libs = ['-framework', 'CoreText', '-framework', 'CoreGraphics']
|
||||||
else:
|
else:
|
||||||
@ -110,10 +111,12 @@ def init_env(debug=False, asan=False):
|
|||||||
pylib = get_python_flags(cflags)
|
pylib = get_python_flags(cflags)
|
||||||
if isosx:
|
if isosx:
|
||||||
glfw_ldflags = pkg_config('--libs', '--static', 'glfw3') + ['-framework', 'OpenGL']
|
glfw_ldflags = pkg_config('--libs', '--static', 'glfw3') + ['-framework', 'OpenGL']
|
||||||
|
glew_libs = []
|
||||||
else:
|
else:
|
||||||
glfw_ldflags = pkg_config('glfw3', '--libs')
|
glfw_ldflags = pkg_config('glfw3', '--libs')
|
||||||
|
glew_libs = pkg_config('glew', '--libs')
|
||||||
ldpaths = pylib + \
|
ldpaths = pylib + \
|
||||||
pkg_config('glew', '--libs') + font_libs + glfw_ldflags
|
glew_libs + font_libs + glfw_ldflags
|
||||||
|
|
||||||
try:
|
try:
|
||||||
os.mkdir(build_dir)
|
os.mkdir(build_dir)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user