Running this line of code:
m_sampler = context->createTextureSamplerFromGLImage( texId, RT_TARGET_GL_TEXTURE_2D );
Produces this error:
+ e {m_message=“Invalid value (Details: Function “_rtTextureSamplerCreateFromGLImage” caught exception: GL error: invalid enumerant
, [10420290])” m_error_code=RT_ERROR_INVALID_VALUE } optix::Exception &
Caught by:
sutilReportError( e.getErrorString().c_str() );
Any idea why this happens? I’m running the same texture code block from the Texture Interpolation sample from OptiX:
GLuint texId = 0;
glGenTextures( 1, &texId );
glBindTexture( GL_TEXTURE_2D, texId );
std::vector<GLfloat> img_data(TEX_HEIGHT*TEX_WIDTH*4);
GLfloat* img = &img_data[0];
for( int j = 0; j < TEX_HEIGHT; j++)
{
for( int i = 0; i < TEX_WIDTH; i++)
{
GLfloat c =((( i & 0x8) == 0) ^(( j & 0x8) == 0)) * 1.0f;
img[ 0 ] = 1.0f;
img[ 1 ] = c;
img[ 2 ] = c;
img[ 3 ] = 1.0f;
img+=4;
}
}
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT );
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT );
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST );
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST );
glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA32F_ARB, TEX_WIDTH, TEX_HEIGHT, 0, GL_RGBA, GL_FLOAT, &img_data[0] );
glBindTexture( GL_TEXTURE_2D, 0 );
// Create a texture sampler with the OpenGL texture as input.
m_sampler = context->createTextureSamplerFromGLImage( texId, RT_TARGET_GL_TEXTURE_2D );
m_sampler->setWrapMode( 0, RT_WRAP_REPEAT );
m_sampler->setWrapMode( 1, RT_WRAP_REPEAT );
m_sampler->setWrapMode( 2, RT_WRAP_REPEAT );
m_sampler->setIndexingMode( RT_TEXTURE_INDEX_NORMALIZED_COORDINATES );
m_sampler->setReadMode( RT_TEXTURE_READ_NORMALIZED_FLOAT );
m_sampler->setMaxAnisotropy( 1.0f );
m_sampler->setFilteringModes( RT_FILTER_LINEAR, RT_FILTER_LINEAR, RT_FILTER_NONE );
context["tex"]->setTextureSampler( m_sampler );