Kaynağa Gözat

attempt to clean up opengl mess

Former-commit-id: c316aeb99eedcc97234abc36e905c208961eed63
Alec Jacobson 8 yıl önce
ebeveyn
işleme
0663d656eb
59 değiştirilmiş dosya ile 225 ekleme ve 138 silme
  1. 1 1
      include/igl/opengl/compile_and_link_program.h
  2. 2 1
      include/igl/opengl/compile_shader.cpp
  3. 1 1
      include/igl/opengl/compile_shader.h
  4. 8 8
      include/igl/opengl/create_index_vbo.cpp
  5. 1 3
      include/igl/opengl/create_index_vbo.h
  6. 1 4
      include/igl/opengl/create_mesh_vbo.h
  7. 1 1
      include/igl/opengl/create_shader_program.cpp
  8. 1 3
      include/igl/opengl/create_shader_program.h
  9. 1 4
      include/igl/opengl/create_vector_vbo.h
  10. 1 1
      include/igl/opengl/destroy_shader_program.cpp
  11. 1 2
      include/igl/opengl/destroy_shader_program.h
  12. 44 0
      include/igl/opengl/gl.h
  13. 1 2
      include/igl/opengl/gl_type_size.h
  14. 1 1
      include/igl/opengl/glfw/map_texture.cpp
  15. 17 16
      include/igl/opengl/init_render_to_texture.cpp
  16. 1 1
      include/igl/opengl/init_render_to_texture.h
  17. 1 2
      include/igl/opengl/load_shader.h
  18. 1 2
      include/igl/opengl/print_program_info_log.h
  19. 1 2
      include/igl/opengl/print_shader_info_log.h
  20. 1 2
      include/igl/opengl/report_gl_error.cpp
  21. 4 2
      include/igl/opengl/report_gl_error.h
  22. 1 3
      include/igl/opengl/uniform_type_to_string.h
  23. 1 1
      include/igl/opengl2/RotateWidget.h
  24. 1 1
      include/igl/opengl2/TranslateWidget.h
  25. 1 2
      include/igl/opengl2/draw_beach_ball.cpp
  26. 1 2
      include/igl/opengl2/draw_floor.cpp
  27. 1 2
      include/igl/opengl2/draw_mesh.h
  28. 1 1
      include/igl/opengl2/draw_point.cpp
  29. 2 1
      include/igl/opengl2/draw_rectangular_marquee.cpp
  30. 1 1
      include/igl/opengl2/draw_skeleton_3d.cpp
  31. 1 1
      include/igl/opengl2/draw_skeleton_vector_graphics.cpp
  32. 1 1
      include/igl/opengl2/flare_textures.h.REMOVED.git-id
  33. 24 14
      include/igl/opengl2/gl.h
  34. 30 0
      include/igl/opengl2/glext.h
  35. 30 0
      include/igl/opengl2/glu.h
  36. 1 2
      include/igl/opengl2/lens_flare.h
  37. 1 1
      include/igl/opengl2/model_proj_viewport.cpp
  38. 1 2
      include/igl/opengl2/print_gl_get.h
  39. 2 2
      include/igl/opengl2/project.cpp
  40. 2 2
      include/igl/opengl2/render_to_tga.cpp
  41. 1 1
      include/igl/opengl2/render_to_tga.h
  42. 1 1
      include/igl/opengl2/right_axis.cpp
  43. 1 1
      include/igl/opengl2/shine_textures.h.REMOVED.git-id
  44. 1 1
      include/igl/opengl2/sort_triangles.cpp
  45. 0 3
      include/igl/opengl2/texture_from_tga.cpp
  46. 1 3
      include/igl/opengl2/texture_from_tga.h
  47. 2 3
      include/igl/opengl2/tga.cpp
  48. 2 5
      include/igl/opengl2/tga.h
  49. 1 1
      include/igl/opengl2/unproject.cpp
  50. 1 1
      include/igl/opengl2/unproject_to_zero_plane.cpp
  51. 1 1
      include/igl/opengl2/up_axis.cpp
  52. 1 1
      include/igl/opengl2/view_axis.cpp
  53. 1 1
      include/igl/png/render_to_png.cpp
  54. 1 2
      include/igl/png/render_to_png_async.cpp
  55. 6 5
      include/igl/png/texture_from_file.cpp
  56. 3 3
      include/igl/png/texture_from_file.h
  57. 2 2
      include/igl/png/texture_from_png.cpp
  58. 1 1
      include/igl/png/texture_from_png.h
  59. 4 4
      shared/cmake/CMakeLists.txt

+ 1 - 1
include/igl/opengl/compile_and_link_program.h

@@ -8,7 +8,7 @@
 #ifndef IGL_OPENGL_COMPILE_AND_LINK_PROGRAM_H
 #define IGL_OPENGL_COMPILE_AND_LINK_PROGRAM_H
 #include "../igl_inline.h"
-#include "OpenGL_convenience.h"
+#include "gl.h"
 namespace igl
 {
   namespace opengl

+ 2 - 1
include/igl/opengl/compile_shader.cpp

@@ -9,7 +9,8 @@
 #include "report_gl_error.h"
 #include <iostream>
 
-IGL_INLINE GLuint igl::opengl::compile_shader(const GLint type, const char * str)
+IGL_INLINE GLuint igl::opengl::compile_shader(
+  const GLint type, const char * str)
 {
   GLuint id = glCreateShader(type);
   report_gl_error("glCreateShader: ");

+ 1 - 1
include/igl/opengl/compile_shader.h

@@ -7,8 +7,8 @@
 // obtain one at http://mozilla.org/MPL/2.0/.
 #ifndef IGL_OPENGL_COMPILE_SHADER_H
 #define IGL_OPENGL_COMPILE_SHADER_H
-#include "OpenGL_convenience.h"
 #include "../igl_inline.h"
+#include "gl.h"
 namespace igl
 {
   namespace opengl

+ 8 - 8
include/igl/opengl/create_index_vbo.cpp

@@ -13,32 +13,32 @@ IGL_INLINE void igl::opengl::create_index_vbo(
   GLuint & F_vbo_id)
 {
   // Generate Buffers
-  glGenBuffersARB(1,&F_vbo_id);
+  glGenBuffers(1,&F_vbo_id);
   // Bind Buffers
-  glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB,F_vbo_id);
+  glBindBuffer(GL_ELEMENT_ARRAY_BUFFER,F_vbo_id);
   // Copy data to buffers
   // We expect a matrix with each vertex position on a row, we then want to
   // pass this data to OpenGL reading across rows (row-major)
   if(F.Options & Eigen::RowMajor)
   {
-    glBufferDataARB(
-      GL_ELEMENT_ARRAY_BUFFER_ARB,
+    glBufferData(
+      GL_ELEMENT_ARRAY_BUFFER,
       sizeof(int)*F.size(),
       F.data(),
-      GL_STATIC_DRAW_ARB);
+      GL_STATIC_DRAW);
   }else
   {
     // Create temporary copy of transpose
     Eigen::MatrixXi FT = F.transpose();
     // If its column major then we need to temporarily store a transpose
-    glBufferDataARB(
-      GL_ELEMENT_ARRAY_BUFFER_ARB,
+    glBufferData(
+      GL_ELEMENT_ARRAY_BUFFER,
       sizeof(int)*F.size(),
       FT.data(),
       GL_STATIC_DRAW);
   }
   // bind with 0, so, switch back to normal pointer operation
-  glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, 0);
+  glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
 }
 
 #ifdef IGL_STATIC_LIBRARY

+ 1 - 3
include/igl/opengl/create_index_vbo.h

@@ -8,10 +8,8 @@
 #ifndef IGL_OPENGL_CREATE_INDEX_VBO_H
 #define IGL_OPENGL_CREATE_INDEX_VBO_H
 #include "../igl_inline.h"
-// NOTE: It wouldn't be so hard to template this using Eigen's templates
-
+#include "gl.h"
 #include <Eigen/Core>
-#include "OpenGL_convenience.h"
 
 // Create a VBO (Vertex Buffer Object) for a list of indices:
 // GL_ELEMENT_ARRAY_BUFFER_ARB for the triangle indices (F)

+ 1 - 4
include/igl/opengl/create_mesh_vbo.h

@@ -8,12 +8,9 @@
 #ifndef IGL_OPENGL_CREATE_MESH_VBO_H
 #define IGL_OPENGL_CREATE_MESH_VBO_H
 #include "../igl_inline.h"
-// NOTE: It wouldn't be so hard to template this using Eigen's templates
-
+#include "gl.h"
 #include <Eigen/Core>
 
-#include "OpenGL_convenience.h"
-
 // Create a VBO (Vertex Buffer Object) for a mesh. Actually two VBOs: one 
 // GL_ARRAY_BUFFER for the vertex positions (V) and one
 // GL_ELEMENT_ARRAY_BUFFER for the triangle indices (F)

+ 1 - 1
include/igl/opengl/create_shader_program.cpp

@@ -40,7 +40,7 @@ IGL_INLINE bool igl::opengl::create_shader_program(
   if(geom_source != "")
   {
     // load vertex shader
-    g = igl::opengl::load_shader(geom_source.c_str(),GL_GEOMETRY_SHADER_EXT);
+    g = igl::opengl::load_shader(geom_source.c_str(),GL_GEOMETRY_SHADER);
     if(g == 0)
     {
       cerr<<"geometry shader failed to compile."<<endl;

+ 1 - 3
include/igl/opengl/create_shader_program.h

@@ -7,13 +7,11 @@
 // obtain one at http://mozilla.org/MPL/2.0/.
 #ifndef IGL_OPENGL_CREATE_SHADER_PROGRAM_H
 #define IGL_OPENGL_CREATE_SHADER_PROGRAM_H
-
 #include "../igl_inline.h"
+#include "gl.h"
 #include <string>
 #include <map>
 
-#include "OpenGL_convenience.h"
-
 namespace igl
 {
   namespace opengl

+ 1 - 4
include/igl/opengl/create_vector_vbo.h

@@ -8,12 +8,9 @@
 #ifndef IGL_OPENGL_CREATE_VECTOR_VBO_H
 #define IGL_OPENGL_CREATE_VECTOR_VBO_H
 #include "../igl_inline.h"
-// NOTE: It wouldn't be so hard to template this using Eigen's templates
-
+#include "gl.h"
 #include <Eigen/Core>
 
-#include "OpenGL_convenience.h"
-
 // Create a VBO (Vertex Buffer Object) for a list of vectors:
 // GL_ARRAY_BUFFER for the vectors (V)
 namespace igl

+ 1 - 1
include/igl/opengl/destroy_shader_program.cpp

@@ -6,8 +6,8 @@
 // v. 2.0. If a copy of the MPL was not distributed with this file, You can 
 // obtain one at http://mozilla.org/MPL/2.0/.
 #include "destroy_shader_program.h"
-#include <cstdio>
 #include "report_gl_error.h"
+#include <cstdio>
 
 IGL_INLINE bool igl::opengl::destroy_shader_program(const GLuint id)
 {

+ 1 - 2
include/igl/opengl/destroy_shader_program.h

@@ -8,8 +8,7 @@
 #ifndef IGL_OPENGL_DESTROY_SHADER_PROGRAM_H
 #define IGL_OPENGL_DESTROY_SHADER_PROGRAM_H
 #include "../igl_inline.h"
-
-#include "OpenGL_convenience.h"
+#include "gl.h"
 
 namespace igl
 {

+ 44 - 0
include/igl/opengl/gl.h

@@ -0,0 +1,44 @@
+// This file is part of libigl, a simple c++ geometry processing library.
+// 
+// Copyright (C) 2013, 2017 Alec Jacobson <alecjacobson@gmail.com>
+// 
+// This Source Code Form is subject to the terms of the Mozilla Public License 
+// v. 2.0. If a copy of the MPL was not distributed with this file, You can 
+// obtain one at http://mozilla.org/MPL/2.0/.
+#ifndef IGL_OPENGL_GL_H
+#define IGL_OPENGL_GL_H
+
+#ifdef IGL_OPENGL2_GL_H
+#  error "igl/opengl2/gl.h already included"
+#endif
+
+// Always use this:
+//     #include "gl.h"
+// Instead of:
+//     #include <OpenGL/gl3.h>
+// or 
+//     #include <GL/gl.h>
+//
+
+// For now this includes glu, glew and glext (perhaps these should be
+// separated)
+#ifdef _WIN32
+#    define NOMINMAX
+#    include <Windows.h>
+#    undef DrawText
+#    undef NOMINMAX
+#endif
+
+#ifndef __APPLE__
+#  define GLEW_STATIC
+#  include <GL/glew.h>
+#endif
+
+#ifdef __APPLE__
+#  include <OpenGL/gl3.h>
+#  define __gl_h_ /* Prevent inclusion of the old gl.h */
+#else
+#  include <GL/gl.h>
+#endif
+
+#endif

+ 1 - 2
include/igl/opengl/gl_type_size.h

@@ -8,8 +8,7 @@
 #ifndef IGL_OPENGL_GL_TYPE_SIZE_H
 #define IGL_OPENGL_GL_TYPE_SIZE_H
 #include "../igl_inline.h"
-
-#include "OpenGL_convenience.h"
+#include "gl.h"
 
 namespace igl
 {

+ 1 - 1
include/igl/opengl/glfw/map_texture.cpp

@@ -1,6 +1,6 @@
 #include "map_texture.h"
 #include "../create_shader_program.h"
-#include "../OpenGL_convenience.h"
+#include "../gl.h"
 
 #define GLFW_INCLUDE_GLU
 #include <GLFW/glfw3.h>

+ 17 - 16
include/igl/opengl/init_render_to_texture.cpp

@@ -6,6 +6,7 @@
 // v. 2.0. If a copy of the MPL was not distributed with this file, You can
 // obtain one at http://mozilla.org/MPL/2.0/.
 #include "init_render_to_texture.h"
+#include "gl.h"
 #include <cassert>
 
 IGL_INLINE void igl::opengl::init_render_to_texture(
@@ -18,35 +19,35 @@ IGL_INLINE void igl::opengl::init_render_to_texture(
   using namespace std;
   // Delete if already exists
   glDeleteTextures(1,&tex_id);
-  glDeleteFramebuffersEXT(1,&fbo_id);
-  glDeleteFramebuffersEXT(1,&dfbo_id);
+  glDeleteFramebuffers(1,&fbo_id);
+  glDeleteFramebuffers(1,&dfbo_id);
   // http://www.opengl.org/wiki/Framebuffer_Object_Examples#Quick_example.2C_render_to_texture_.282D.29
   glGenTextures(1, &tex_id);
   glBindTexture(GL_TEXTURE_2D, tex_id);
-  glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
-  glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
+  glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
+  glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
   glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
   glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
   //NULL means reserve texture memory, but texels are undefined
-  glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA32F_ARB, width, height, 0, GL_BGRA, GL_FLOAT, NULL);
+  glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA32F, width, height, 0, GL_BGRA, GL_FLOAT, NULL);
   glBindTexture(GL_TEXTURE_2D, 0);
-  glGenFramebuffersEXT(1, &fbo_id);
-  glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fbo_id);
+  glGenFramebuffers(1, &fbo_id);
+  glBindFramebuffer(GL_FRAMEBUFFER, fbo_id);
   //Attach 2D texture to this FBO
-  glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, tex_id, 0);
+  glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, tex_id, 0);
 
-  glGenRenderbuffersEXT(1, &dfbo_id);
-  glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, dfbo_id);
-  glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_DEPTH_COMPONENT24, width, height);
+  glGenRenderbuffers(1, &dfbo_id);
+  glBindRenderbuffer(GL_RENDERBUFFER, dfbo_id);
+  glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT24, width, height);
   //Attach depth buffer to FBO (for this example it's not really needed, but if
   //drawing a 3D scene it would be necessary to attach something)
-  glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, dfbo_id);
+  glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, dfbo_id);
 
   //Does the GPU support current FBO configuration?
   GLenum status;
-  status = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT);
-  assert(status == GL_FRAMEBUFFER_COMPLETE_EXT);
+  status = glCheckFramebufferStatus(GL_FRAMEBUFFER);
+  assert(status == GL_FRAMEBUFFER_COMPLETE);
   // Unbind to clean up
-  glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, 0);
-  glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
+  glBindRenderbuffer(GL_RENDERBUFFER, 0);
+  glBindFramebuffer(GL_FRAMEBUFFER, 0);
 }

+ 1 - 1
include/igl/opengl/init_render_to_texture.h

@@ -8,7 +8,7 @@
 #ifndef IGL_OPENGL_INIT_RENDER_TO_TEXTURE_H
 #define IGL_OPENGL_INIT_RENDER_TO_TEXTURE_H
 #include "../igl_inline.h"
-#include "OpenGL_convenience.h"
+#include "gl.h"
 #include <cstdlib>
 namespace igl
 {

+ 1 - 2
include/igl/opengl/load_shader.h

@@ -8,8 +8,7 @@
 #ifndef IGL_OPENGL_LOAD_SHADER_H 
 #define IGL_OPENGL_LOAD_SHADER_H
 #include "../igl_inline.h" 
-
-#include "OpenGL_convenience.h"
+#include "gl.h"
 
 namespace igl
 {

+ 1 - 2
include/igl/opengl/print_program_info_log.h

@@ -8,8 +8,7 @@
 #ifndef IGL_OPENGL_PRINT_PROGRAM_INFO_LOG_H
 #define IGL_OPENGL_PRINT_PROGRAM_INFO_LOG_H
 #include "../igl_inline.h"
-
-#include "OpenGL_convenience.h"
+#include "gl.h"
 
 namespace igl
 {

+ 1 - 2
include/igl/opengl/print_shader_info_log.h

@@ -8,8 +8,7 @@
 #ifndef IGL_OPENGL_PRINT_SHADER_INFO_LOG_H
 #define IGL_OPENGL_PRINT_SHADER_INFO_LOG_H
 #include "../igl_inline.h"
-
-#include "OpenGL_convenience.h"
+#include "gl.h"
 
 namespace igl
 {

+ 1 - 2
include/igl/opengl/report_gl_error.cpp

@@ -6,9 +6,8 @@
 // v. 2.0. If a copy of the MPL was not distributed with this file, You can 
 // obtain one at http://mozilla.org/MPL/2.0/.
 #include "report_gl_error.h"
-
-#include <cstdio>
 #include "../verbose.h"
+#include <cstdio>
 
 IGL_INLINE GLenum igl::opengl::report_gl_error(const std::string id)
 {

+ 4 - 2
include/igl/opengl/report_gl_error.h

@@ -9,8 +9,10 @@
 #define IGL_OPENGL_REPORT_GL_ERROR_H
 #include "../igl_inline.h"
 
-#include "OpenGL_convenience.h"
-
+// Hack to allow both opengl/ and opengl2 to use this (we shouldn't allow this)
+#ifndef __gl_h_ 
+#  include "gl.h"
+#endif
 #include <string>
 
 namespace igl

+ 1 - 3
include/igl/opengl/uniform_type_to_string.h

@@ -8,11 +8,9 @@
 #ifndef IGL_OPENGL_UNIFORM_TYPE_TO_STRING_H
 #define IGL_OPENGL_UNIFORM_TYPE_TO_STRING_H
 #include "../igl_inline.h"
-
+#include "gl.h"
 #include <string>
 
-#include "OpenGL_convenience.h"
-
 namespace igl
 {
   namespace opengl

+ 1 - 1
include/igl/opengl2/RotateWidget.h

@@ -7,10 +7,10 @@
 // obtain one at http://mozilla.org/MPL/2.0/.
 #ifndef IGL_OPENGL2_ROTATE_WIDGET_H
 #define IGL_OPENGL2_ROTATE_WIDGET_H
+#include "../material_colors.h"
 #include <Eigen/Geometry>
 #include <Eigen/Core>
 #include <vector>
-#include "../material_colors.h"
 
 namespace igl
 {

+ 1 - 1
include/igl/opengl2/TranslateWidget.h

@@ -7,10 +7,10 @@
 // obtain one at http://mozilla.org/MPL/2.0/.
 #ifndef IGL_OPENGL2_TRANSLATE_WIDGET_H
 #define IGL_OPENGL2_TRANSLATE_WIDGET_H
+#include "../material_colors.h"
 #include <Eigen/Geometry>
 #include <Eigen/Core>
 #include <vector>
-#include "../material_colors.h"
 
 namespace igl
 {

+ 1 - 2
include/igl/opengl2/draw_beach_ball.cpp

@@ -6,8 +6,7 @@
 // v. 2.0. If a copy of the MPL was not distributed with this file, You can 
 // obtain one at http://mozilla.org/MPL/2.0/.
 #include "draw_beach_ball.h"
-
-#include "../opengl/OpenGL_convenience.h"
+#include "gl.h"
 
 // I'm not sure why windows would need it this way:
 // http://lists.cairographics.org/archives/cairo/2008-January/012722.html

+ 1 - 2
include/igl/opengl2/draw_floor.cpp

@@ -6,8 +6,7 @@
 // v. 2.0. If a copy of the MPL was not distributed with this file, You can 
 // obtain one at http://mozilla.org/MPL/2.0/.
 #include "draw_floor.h"
-
-#include "../opengl/OpenGL_convenience.h"
+#include "gl.h"
 
 IGL_INLINE void igl::opengl2::draw_floor(const float * colorA, const float * colorB,
   const int GridSizeX,

+ 1 - 2
include/igl/opengl2/draw_mesh.h

@@ -8,10 +8,9 @@
 #ifndef IGL_OPENGL2_DRAW_MESH_H
 #define IGL_OPENGL2_DRAW_MESH_H
 #include "../igl_inline.h"
-
+#include "gl.h"
 #include <Eigen/Dense>
 
-#include "../opengl/OpenGL_convenience.h"
 
 namespace igl
 {

+ 1 - 1
include/igl/opengl2/draw_point.cpp

@@ -8,7 +8,7 @@
 #include "draw_point.h"
 
 // Implementation
-#include "../opengl/OpenGL_convenience.h"
+#include "gl.h"
 
 #include <cassert>
 #include <cmath>

+ 2 - 1
include/igl/opengl2/draw_rectangular_marquee.cpp

@@ -8,7 +8,8 @@
 
 
 #include "draw_rectangular_marquee.h"
-#include "../opengl/OpenGL_convenience.h"
+#include "gl.h"
+#include "glu.h"
 #include "../material_colors.h"
 
 IGL_INLINE void igl::opengl2::draw_rectangular_marquee(

+ 1 - 1
include/igl/opengl2/draw_skeleton_3d.cpp

@@ -9,7 +9,7 @@
 #include "draw_skeleton_3d.h"
 #include "../PI.h"
 #include "../material_colors.h"
-#include "../opengl/OpenGL_convenience.h"
+#include "gl.h"
 #include <Eigen/Geometry>
 #include <iostream>
 

+ 1 - 1
include/igl/opengl2/draw_skeleton_vector_graphics.cpp

@@ -7,7 +7,7 @@
 // obtain one at http://mozilla.org/MPL/2.0/.
 #include "draw_skeleton_vector_graphics.h"
 #include "draw_point.h"
-#include "../opengl/OpenGL_convenience.h"
+#include "gl.h"
 #include "../material_colors.h"
 
 IGL_INLINE void igl::opengl2::draw_skeleton_vector_graphics(

+ 1 - 1
include/igl/opengl2/flare_textures.h.REMOVED.git-id

@@ -1 +1 @@
-57faa756ea367a1d56414b6b9726f893eb10d5bc
+0455195ebe076c34d28e9bfa34e2e0ec6b117571

+ 24 - 14
include/igl/opengl/OpenGL_convenience.h → include/igl/opengl2/gl.h

@@ -5,30 +5,40 @@
 // This Source Code Form is subject to the terms of the Mozilla Public License 
 // v. 2.0. If a copy of the MPL was not distributed with this file, You can 
 // obtain one at http://mozilla.org/MPL/2.0/.
-#ifndef IGL_OPENGL_OPENGL_CONVENIENCE_H
-#define IGL_OPENGL_OPENGL_CONVENIENCE_H
+#ifndef IGL_OPENGL2_GL_H
+#define IGL_OPENGL2_GL_H
+
+#ifdef IGL_OPENGL_GL_H
+#  error "igl/opengl/gl.h already included"
+#endif
 
 // Always use this:
-//     #include "OpenGL_convenience.h"
-// Convenience includer for opengl.
+//     #include "gl.h"
+// Instead of:
+//     #include <OpenGL/gl.h>
+// or 
+//     #include <GL/gl.h>
+//
 
 // For now this includes glu, glew and glext (perhaps these should be
 // separated)
-#if __APPLE__
-#  include <OpenGL/gl.h>
-#  include <OpenGL/glu.h>
-#  include <OpenGL/glext.h>
-#elif defined(_WIN32)
+#ifdef _WIN32
 #    define NOMINMAX
 #    include <Windows.h>
+#    undef DrawText
 #    undef NOMINMAX
-#    include <GL/glew.h>
-#    include <GL/gl.h>
+#endif
+
+#ifndef __APPLE__
+#  define GLEW_STATIC
+#  include <GL/glew.h>
+#endif
+
+#ifdef __APPLE__
+#  include <OpenGL/gl.h>
+#  define __gl_h_ /* Prevent inclusion of the old gl.h */
 #else
-#  define GL_GLEXT_PROTOTYPES
 #  include <GL/gl.h>
-#  include <GL/glext.h>
-#  include <GL/glu.h>
 #endif
 
 #endif

+ 30 - 0
include/igl/opengl2/glext.h

@@ -0,0 +1,30 @@
+// This file is part of libigl, a simple c++ geometry processing library.
+// 
+// Copyright (C) 2017 Alec Jacobson <alecjacobson@gmail.com>
+// 
+// This Source Code Form is subject to the terms of the Mozilla Public License 
+// v. 2.0. If a copy of the MPL was not distributed with this file, You can 
+// obtain one at http://mozilla.org/MPL/2.0/.
+#ifndef IGL_OPENGL_GLEXT_H
+#define IGL_OPENGL_GLEXT_H
+
+#ifdef IGL_OPENGL2_GLEXT_H
+#  error "igl/opengl2/glext.h already included"
+#endif
+
+// Always use this:
+//     #include "gl.h"
+// Instead of:
+//     #include <OpenGL/glext.h>
+// or 
+//     #include <GL/glext.h>
+//
+
+#ifdef __APPLE__
+#  include <OpenGL/glext.h>
+#else
+#  include <GL/glext.h>
+#endif
+
+#endif
+

+ 30 - 0
include/igl/opengl2/glu.h

@@ -0,0 +1,30 @@
+// This file is part of libigl, a simple c++ geometry processing library.
+// 
+// Copyright (C) 2017 Alec Jacobson <alecjacobson@gmail.com>
+// 
+// This Source Code Form is subject to the terms of the Mozilla Public License 
+// v. 2.0. If a copy of the MPL was not distributed with this file, You can 
+// obtain one at http://mozilla.org/MPL/2.0/.
+#ifndef IGL_OPENGL2_GLU_H
+#define IGL_OPENGL2_GLU_H
+
+#ifdef IGL_OPENGL_GLU_H
+#  error "igl/opengl/glu.h already included"
+#endif
+
+// Always use this:
+//     #include "glu.h"
+// Instead of:
+//     #include <OpenGL/glu.h>
+// or 
+//     #include <GL/glu.h>
+//
+
+#ifdef __APPLE__
+#  include <OpenGL/glu.h>
+#else
+#  include <GL/glu.h>
+#endif
+
+#endif
+

+ 1 - 2
include/igl/opengl2/lens_flare.h

@@ -8,10 +8,9 @@
 #ifndef IGL_OPENGL2_LENS_FLARE_H
 #define IGL_OPENGL2_LENS_FLARE_H
 
-#include "../opengl/OpenGL_convenience.h"
 #include "../igl_inline.h"
+#include "gl.h"
 #include <Eigen/Core>
-
 #include <vector>
 
 namespace igl

+ 1 - 1
include/igl/opengl2/model_proj_viewport.cpp

@@ -6,7 +6,7 @@
 // v. 2.0. If a copy of the MPL was not distributed with this file, You can
 // obtain one at http://mozilla.org/MPL/2.0/.
 #include "model_proj_viewport.h"
-#include "../opengl/OpenGL_convenience.h"
+#include "gl.h"
 
 template <typename Derivedmodel, typename Derivedproj, typename Derivedviewport>
 IGL_INLINE void igl::opengl2::model_proj_viewport(

+ 1 - 2
include/igl/opengl2/print_gl_get.h

@@ -7,10 +7,9 @@
 // obtain one at http://mozilla.org/MPL/2.0/.
 #ifndef IGL_OPENGL2_PRINT_GL_GET_H
 #define IGL_OPENGL2_PRINT_GL_GET_H
+#include "gl.h"
 #include "../igl_inline.h"
 
-#include "../opengl/OpenGL_convenience.h"
-
 namespace igl
 {
   namespace opengl2

+ 2 - 2
include/igl/opengl2/project.cpp

@@ -7,8 +7,8 @@
 // obtain one at http://mozilla.org/MPL/2.0/.
 #include "project.h"
 #include "../project.h"
-#include "../opengl/report_gl_error.h"
-#include "../opengl/OpenGL_convenience.h"
+#include "gl.h"
+#include "glu.h"
 #include <iostream>
 
 IGL_INLINE int igl::opengl2::project(

+ 2 - 2
include/igl/opengl/render_to_tga.cpp → include/igl/opengl2/render_to_tga.cpp

@@ -8,7 +8,7 @@
 #include "render_to_tga.h"
 #include "tga.h"
 
-#include "OpenGL_convenience.h"
+#include "gl.h"
 
 #include <cstdlib>
 
@@ -58,7 +58,7 @@ IGL_INLINE bool igl::opengl::render_to_tga(
   genericImage->pixels = pixels;
   // CMAP is not supported, but we need to put something here
   genericImage->cmapEntries = 0;
-  genericImage->cmapFormat = GL_BGR_EXT;  // XXX fix me
+  genericImage->cmapFormat = GL_BGR;
   genericImage->cmap = cmap;
 
   // write pixels to tga file

+ 1 - 1
include/igl/opengl/render_to_tga.h → include/igl/opengl2/render_to_tga.h

@@ -8,8 +8,8 @@
 #ifndef IGL_OPENGL_RENDER_TO_TGA_H
 #define IGL_OPENGL_RENDER_TO_TGA_H
 #include "../igl_inline.h"
-
 #include <string>
+
 namespace igl
 {
   namespace opengl

+ 1 - 1
include/igl/opengl2/right_axis.cpp

@@ -6,7 +6,7 @@
 // v. 2.0. If a copy of the MPL was not distributed with this file, You can 
 // obtain one at http://mozilla.org/MPL/2.0/.
 #include "right_axis.h"
-#include "../opengl/OpenGL_convenience.h"
+#include "gl.h"
 
 IGL_INLINE void igl::opengl2::right_axis(double * x, double * y, double * z)
 {

+ 1 - 1
include/igl/opengl2/shine_textures.h.REMOVED.git-id

@@ -1 +1 @@
-bebb4012ae2ef7792e1788730fe4bf6252c87174
+05001989d8ff527cd57823f435ec025540ebf18e

+ 1 - 1
include/igl/opengl2/sort_triangles.cpp

@@ -8,7 +8,7 @@
 #include "sort_triangles.h"
 #include "project.h"
 #include "../sort_triangles.h"
-#include "../opengl/OpenGL_convenience.h"
+#include "gl.h"
 #include "../sort.h"
 #include "../slice.h"
 #include "../barycenter.h"

+ 0 - 3
include/igl/opengl/texture_from_tga.cpp → include/igl/opengl2/texture_from_tga.cpp

@@ -6,9 +6,7 @@
 // v. 2.0. If a copy of the MPL was not distributed with this file, You can 
 // obtain one at http://mozilla.org/MPL/2.0/.
 #include "texture_from_tga.h"
-
 #include "tga.h"
-#include "report_gl_error.h"
 #include <cstring>
 
 IGL_INLINE bool igl::opengl::texture_from_tga(const std::string tga_file, GLuint & id)
@@ -56,7 +54,6 @@ IGL_INLINE bool igl::opengl::texture_from_tga(const std::string tga_file, GLuint
     img->format == GL_BGR))
   {
     glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
-    igl::opengl::report_gl_error();
   }
 
   // Load texture

+ 1 - 3
include/igl/opengl/texture_from_tga.h → include/igl/opengl2/texture_from_tga.h

@@ -8,9 +8,7 @@
 #ifndef IGL_OPENGL_TEXTURE_FROM_TGA_H
 #define IGL_OPENGL_TEXTURE_FROM_TGA_H
 #include "../igl_inline.h"
-
-#include "OpenGL_convenience.h"
-
+#include "gl.h"
 #include <string>
 
 namespace igl

+ 2 - 3
include/igl/opengl/tga.cpp → include/igl/opengl2/tga.cpp

@@ -40,14 +40,13 @@
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  */
 
+#include "tga.h"
+#include "glext.h"
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 #include <assert.h>
 
-#include "tga.h"
-
-
 static char error[256];
 static unsigned int _verbose = 0;
 static int totbytes = 0;

+ 2 - 5
include/igl/opengl/tga.h → include/igl/opengl2/tga.h

@@ -8,18 +8,15 @@
 #ifndef IGL_OPENGL_TGA_H
 #define IGL_OPENGL_TGA_H
 #include "../igl_inline.h"
-// See license in tga.cpp
 
+#include "gl.h"
+// See license in tga.cpp
 /* tga.h - interface for TrueVision (TGA) image file loader */
-
 #include <stdio.h>
-
 #ifdef _WIN32
 #include <windows.h>
 #endif
 
-#include "OpenGL_convenience.h"
-
 namespace igl
 {
 namespace opengl

+ 1 - 1
include/igl/opengl2/unproject.cpp

@@ -8,7 +8,7 @@
 #include "unproject.h"
 #include "model_proj_viewport.h"
 #include "../unproject.h"
-#include "../opengl/OpenGL_convenience.h"
+#include "gl.h"
 
 #include <Eigen/Dense>
 #include <Eigen/LU>

+ 1 - 1
include/igl/opengl2/unproject_to_zero_plane.cpp

@@ -7,7 +7,7 @@
 // obtain one at http://mozilla.org/MPL/2.0/.
 #include "unproject_to_zero_plane.h"
 
-#include "../opengl/OpenGL_convenience.h"
+#include "gl.h"
 
 #include "project.h"
 #include "unproject.h"

+ 1 - 1
include/igl/opengl2/up_axis.cpp

@@ -6,7 +6,7 @@
 // v. 2.0. If a copy of the MPL was not distributed with this file, You can 
 // obtain one at http://mozilla.org/MPL/2.0/.
 #include "up_axis.h"
-#include "../opengl/OpenGL_convenience.h"
+#include "gl.h"
 
 IGL_INLINE void igl::opengl2::up_axis(double * x, double * y, double * z)
 {

+ 1 - 1
include/igl/opengl2/view_axis.cpp

@@ -6,7 +6,7 @@
 // v. 2.0. If a copy of the MPL was not distributed with this file, You can 
 // obtain one at http://mozilla.org/MPL/2.0/.
 #include "view_axis.h"
-#include "../opengl/OpenGL_convenience.h"
+#include "gl.h"
 
 IGL_INLINE void igl::opengl2::view_axis(double * x, double * y, double * z)
 {

+ 1 - 1
include/igl/png/render_to_png.cpp

@@ -8,7 +8,7 @@
 #include "render_to_png.h"
 #include <stb_image_write.h>
 
-#include "../opengl/OpenGL_convenience.h"
+#include "../opengl/gl.h"
 
 IGL_INLINE bool igl::png::render_to_png(
   const std::string png_file,

+ 1 - 2
include/igl/png/render_to_png_async.cpp

@@ -6,10 +6,9 @@
 // v. 2.0. If a copy of the MPL was not distributed with this file, You can
 // obtain one at http://mozilla.org/MPL/2.0/.
 #include "render_to_png_async.h"
+#include "../opengl/gl.h"
 #include <stb_image_write.h>
 
-#include "../opengl/OpenGL_convenience.h"
-
 static IGL_INLINE bool render_to_png_async_helper(
   unsigned char * img, int width, int height,
   const std::string png_file,

+ 6 - 5
include/igl/png/texture_from_file.cpp

@@ -11,7 +11,7 @@
 #include "../STR.h"
 #include "../pathinfo.h"
 #include "../opengl/report_gl_error.h"
-#include "../opengl/texture_from_tga.h"
+//#include "../opengl2/texture_from_tga.h"
 #include <string>
 #include <algorithm>
 #include <iostream>
@@ -25,10 +25,11 @@ IGL_INLINE bool igl::png::texture_from_file(const std::string filename, GLuint &
   pathinfo(filename,d,b,ext,f);
   // Convert extension to lower case
   transform(ext.begin(), ext.end(), ext.begin(), ::tolower);
-  if(ext == "tga")
-  {
-    return texture_from_tga(filename,id);
-  }else if(ext == "png")
+  //if(ext == "tga")
+  //{
+  //  return texture_from_tga(filename,id);
+  //}else 
+  if(ext == "png")
   {
     return texture_from_png(filename,id);
   }else

+ 3 - 3
include/igl/png/texture_from_file.h

@@ -8,7 +8,7 @@
 #ifndef IGL_PNG_TEXTURE_FROM_FILE_H
 #define IGL_PNG_TEXTURE_FROM_FILE_H
 #include "../igl_inline.h"
-#include "../opengl/OpenGL_convenience.h"
+#include "../opengl/gl.h"
 
 #include <string>
 
@@ -17,8 +17,8 @@ namespace igl
   namespace png
   {
     // Read an image from an image file and use it as a texture. Officially,
-    // only .tga and .png are supported. Any filetype read by ImageMagick's
-    // `convert` will work via an unsafe system call.
+    // only <del>.tga and</del> .png are supported. Any filetype read by
+    // ImageMagick's `convert` will work via an unsafe system call.
     //
     // Input:
     //  filename  path to image file

+ 2 - 2
include/igl/png/texture_from_png.cpp

@@ -26,8 +26,8 @@ IGL_INLINE bool igl::png::texture_from_png(const std::string png_file, const boo
   
   glGenTextures(1, &id);
   glBindTexture(GL_TEXTURE_2D, id);
-  glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
-  glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
+  glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
+  glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
   glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
   glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
   glTexImage2D(

+ 1 - 1
include/igl/png/texture_from_png.h

@@ -11,7 +11,7 @@
 #include <Eigen/Core>
 #include <string>
 
-#include "../opengl/OpenGL_convenience.h"
+#include "../opengl/gl.h"
 
 namespace igl
 {

+ 4 - 4
shared/cmake/CMakeLists.txt

@@ -308,6 +308,10 @@ else()
 endif()
 
 ### Compile the opengl parts ###
+set(GLFW_BUILD_EXAMPLES OFF CACHE BOOL " " FORCE)
+set(GLFW_BUILD_TESTS OFF CACHE BOOL " " FORCE)
+set(GLFW_BUILD_DOCS OFF CACHE BOOL " " FORCE)
+set(GLFW_BUILD_INSTALL OFF CACHE BOOL " " FORCE)
 if(LIBIGL_WITH_OPENGL)
   find_package(OpenGL REQUIRED)
 
@@ -339,10 +343,6 @@ if(LIBIGL_WITH_OPENGL)
     set(LIBIGL_OPENGL_GLFW_EXTRA_LIBRARIES "glfw" ${GLFW_LIBRARIES})
     if(LIBIGL_USE_STATIC_LIBRARY)
       CompileIGL_Module("opengl/glfw" "")
-      set(GLFW_BUILD_EXAMPLES OFF CACHE BOOL " " FORCE)
-      set(GLFW_BUILD_TESTS OFF CACHE BOOL " " FORCE)
-      set(GLFW_BUILD_DOCS OFF CACHE BOOL " " FORCE)
-      set(GLFW_BUILD_INSTALL OFF CACHE BOOL " " FORCE)
       target_include_directories(igl_opengl_glfw PRIVATE ${GLFW_INCLUDE_DIRS})
       target_include_directories(igl_opengl_glfw PRIVATE ${OPENGL_INCLUDE_DIR})
       if(NOT APPLE)