From 9206ee9c7a03bc9213caaa499e2dc303268e55d2 Mon Sep 17 00:00:00 2001
From: Clouds <Clouds.Flowing@gmail.com>
Date: Tue, 30 Jan 2018 01:31:42 +0800
Subject: [PATCH] fix opengl runtime to use OpenGL/gl3.h for macOS (#833)

* fix opengl to OpenGL/gl3.h for APPLE

* use glfw3 to include gl.h header
---
 src/runtime/opengl/opengl_common.h      | 4 +++-
 src/runtime/opengl/opengl_device_api.cc | 2 ++
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/src/runtime/opengl/opengl_common.h b/src/runtime/opengl/opengl_common.h
index 661c987e4..0d247edfa 100644
--- a/src/runtime/opengl/opengl_common.h
+++ b/src/runtime/opengl/opengl_common.h
@@ -11,7 +11,9 @@
 #include <tvm/runtime/packed_func.h>
 #include <tvm/runtime/device_api.h>
 #include <dmlc/logging.h>
-#include <GL/gl.h>
+#if defined(__APPLE__)
+#define GLFW_INCLUDE_GLCOREARB
+#endif
 #include <GLFW/glfw3.h>
 #include <string>
 #include <tuple>
diff --git a/src/runtime/opengl/opengl_device_api.cc b/src/runtime/opengl/opengl_device_api.cc
index df2947db6..5f629fcf1 100644
--- a/src/runtime/opengl/opengl_device_api.cc
+++ b/src/runtime/opengl/opengl_device_api.cc
@@ -27,10 +27,12 @@ static const char* GLGetErrorString(GLenum error) {
       return "GL_INVALID_VALUE";
     case GL_INVALID_OPERATION:
       return "GL_INVALID_OPERATION";
+#if !defined(__APPLE__)
     case GL_STACK_OVERFLOW:
       return "GL_STACK_OVERFLOW";
     case GL_STACK_UNDERFLOW:
       return "GL_STACK_UNDERFLOW";
+#endif
     case GL_OUT_OF_MEMORY:
       return "GL_OUT_OF_MEMORY";
     default:
-- 
GitLab