A single channel R32F texture can be created quite easily (and safely) in Eigen:
glGenTextures(1, &_tex);
glBindTexture(GL_TEXTURE_2D, _tex);
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_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
int rows = 480, cols = 640;
static Eigen::Matrix<float, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor> A(rows,cols);
A.setConstant(rows, cols, 0.0f);
for(int row=0; row<A.rows(); row++)
for(int col=0; col<A.cols(); col++)
A(row,col) = .5f + .5*sin( 10* /*period*/ 2*3.14*row/A.rows() );
glTexImage2D(GL_TEXTURE_2D, 0, GL_R32F, cols, rows, 0, GL_RED, GL_FLOAT, A.data());
The code above generates this image:
A similar approach can be used to generate RGB32F textures:
glGenTextures(1, &_tex);
glBindTexture(GL_TEXTURE_2D, _tex);
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_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
int rows = 480;
int cols = 640;
static Eigen::Matrix<Eigen::Vector3f, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor> A(rows,cols);
for(int row=0; row<A.rows(); row++)
for(int col=0; col<A.cols(); col++)
A(row,col) = vec3(row/((float)A.rows()), col/((float)A.cols()), 0);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB32F, cols, rows, 0, GL_RGB, GL_FLOAT, A.data());
The code above generates this image: :
Everything seems to work well on my machine, however, can this procedure result in any problem? especially considering what is mentioned in the Eigen documentation: http://eigen.tuxfamily.org/dox/TopicCustomizingEigen.html#user_defined_scalars