|
@@ -1,14 +1,15 @@
|
|
|
|
+#ifdef IGL_OPENGL_4
|
|
|
|
+
|
|
#include "map_texture.h"
|
|
#include "map_texture.h"
|
|
#include "background_window.h"
|
|
#include "background_window.h"
|
|
#include "../create_shader_program.h"
|
|
#include "../create_shader_program.h"
|
|
-#include "../gl.h"
|
|
|
|
|
|
|
|
-#define GLFW_INCLUDE_GLU
|
|
|
|
|
|
+#include "../gl.h"
|
|
#include <GLFW/glfw3.h>
|
|
#include <GLFW/glfw3.h>
|
|
|
|
|
|
#include <iostream>
|
|
#include <iostream>
|
|
#include <string>
|
|
#include <string>
|
|
-
|
|
|
|
|
|
+
|
|
template <typename DerivedV, typename DerivedF, typename DerivedU>
|
|
template <typename DerivedV, typename DerivedF, typename DerivedU>
|
|
IGL_INLINE bool igl::opengl::glfw::map_texture(
|
|
IGL_INLINE bool igl::opengl::glfw::map_texture(
|
|
const Eigen::MatrixBase<DerivedV> & _V,
|
|
const Eigen::MatrixBase<DerivedV> & _V,
|
|
@@ -26,7 +27,7 @@ IGL_INLINE bool igl::opengl::glfw::map_texture(
|
|
return map_texture(_V,_F,_U,in_data,w,h,nc,out_data,out_w,out_h,out_nc);
|
|
return map_texture(_V,_F,_U,in_data,w,h,nc,out_data,out_w,out_h,out_nc);
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
|
|
|
|
+
|
|
template <typename DerivedV, typename DerivedF, typename DerivedU>
|
|
template <typename DerivedV, typename DerivedF, typename DerivedU>
|
|
IGL_INLINE bool igl::opengl::glfw::map_texture(
|
|
IGL_INLINE bool igl::opengl::glfw::map_texture(
|
|
const Eigen::MatrixBase<DerivedV> & _V,
|
|
const Eigen::MatrixBase<DerivedV> & _V,
|
|
@@ -47,7 +48,7 @@ IGL_INLINE bool igl::opengl::glfw::map_texture(
|
|
glfwTerminate();
|
|
glfwTerminate();
|
|
return false;
|
|
return false;
|
|
};
|
|
};
|
|
- // Force inputs to be RowMajor at the cost of a copy
|
|
|
|
|
|
+ // Force inputs to be RowMajor at the cost of a copy
|
|
Eigen::Matrix<
|
|
Eigen::Matrix<
|
|
double,
|
|
double,
|
|
DerivedV::RowsAtCompileTime,
|
|
DerivedV::RowsAtCompileTime,
|
|
@@ -71,7 +72,7 @@ IGL_INLINE bool igl::opengl::glfw::map_texture(
|
|
}
|
|
}
|
|
|
|
|
|
// Compile each shader
|
|
// Compile each shader
|
|
- std::string vertex_shader = dim == 2 ?
|
|
|
|
|
|
+ std::string vertex_shader = dim == 2 ?
|
|
R"(
|
|
R"(
|
|
#version 330 core
|
|
#version 330 core
|
|
layout(location = 0) in vec2 position;
|
|
layout(location = 0) in vec2 position;
|
|
@@ -106,7 +107,7 @@ void main()
|
|
color = texture(tex,tex_coord_f).rgb;
|
|
color = texture(tex,tex_coord_f).rgb;
|
|
}
|
|
}
|
|
)";
|
|
)";
|
|
- GLuint prog_id =
|
|
|
|
|
|
+ GLuint prog_id =
|
|
igl::opengl::create_shader_program(vertex_shader,fragment_shader,{});
|
|
igl::opengl::create_shader_program(vertex_shader,fragment_shader,{});
|
|
glUniform1i(glGetUniformLocation(prog_id, "tex"),0);
|
|
glUniform1i(glGetUniformLocation(prog_id, "tex"),0);
|
|
// Generate and attach buffers to vertex array
|
|
// Generate and attach buffers to vertex array
|
|
@@ -129,7 +130,7 @@ void main()
|
|
glBufferData(GL_ARRAY_BUFFER, sizeof(double)*V.size(), V.data(), GL_STATIC_DRAW);
|
|
glBufferData(GL_ARRAY_BUFFER, sizeof(double)*V.size(), V.data(), GL_STATIC_DRAW);
|
|
glVertexAttribLPointer(1, V.cols(), GL_DOUBLE, V.cols() * sizeof(GLdouble), (GLvoid*)0);
|
|
glVertexAttribLPointer(1, V.cols(), GL_DOUBLE, V.cols() * sizeof(GLdouble), (GLvoid*)0);
|
|
glBindVertexArray(0);
|
|
glBindVertexArray(0);
|
|
- glBindBuffer(GL_ARRAY_BUFFER, 0);
|
|
|
|
|
|
+ glBindBuffer(GL_ARRAY_BUFFER, 0);
|
|
glBindVertexArray(0);
|
|
glBindVertexArray(0);
|
|
// Prepare texture
|
|
// Prepare texture
|
|
GLuint in_tex;
|
|
GLuint in_tex;
|
|
@@ -162,7 +163,7 @@ void main()
|
|
GLenum bufs[1] = {GL_COLOR_ATTACHMENT0};
|
|
GLenum bufs[1] = {GL_COLOR_ATTACHMENT0};
|
|
glDrawBuffers(1, bufs);
|
|
glDrawBuffers(1, bufs);
|
|
}
|
|
}
|
|
- if(glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE)
|
|
|
|
|
|
+ if(glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE)
|
|
{
|
|
{
|
|
fail("framebuffer setup failed.");
|
|
fail("framebuffer setup failed.");
|
|
}
|
|
}
|
|
@@ -206,3 +207,5 @@ void main()
|
|
// generated by autoexplicit.sh
|
|
// generated by autoexplicit.sh
|
|
template bool igl::opengl::glfw::map_texture<Eigen::Matrix<double, -1, -1, 1, -1, -1>, Eigen::Matrix<int, -1, 3, 1, -1, 3>, Eigen::Matrix<double, -1, -1, 1, -1, -1> >(Eigen::MatrixBase<Eigen::Matrix<double, -1, -1, 1, -1, -1> > const&, Eigen::MatrixBase<Eigen::Matrix<int, -1, 3, 1, -1, 3> > const&, Eigen::MatrixBase<Eigen::Matrix<double, -1, -1, 1, -1, -1> > const&, unsigned char const*, int, int, int, std::vector<unsigned char, std::allocator<unsigned char> >&);
|
|
template bool igl::opengl::glfw::map_texture<Eigen::Matrix<double, -1, -1, 1, -1, -1>, Eigen::Matrix<int, -1, 3, 1, -1, 3>, Eigen::Matrix<double, -1, -1, 1, -1, -1> >(Eigen::MatrixBase<Eigen::Matrix<double, -1, -1, 1, -1, -1> > const&, Eigen::MatrixBase<Eigen::Matrix<int, -1, 3, 1, -1, 3> > const&, Eigen::MatrixBase<Eigen::Matrix<double, -1, -1, 1, -1, -1> > const&, unsigned char const*, int, int, int, std::vector<unsigned char, std::allocator<unsigned char> >&);
|
|
#endif
|
|
#endif
|
|
|
|
+
|
|
|
|
+#endif // IGL_OPENGL_4
|