[vtkusers] TEXTURE_BUFFER fails : pure OpenGL vs vtkgl ?
Butterfly
ninarock at list.ru
Tue May 19 12:36:39 EDT 2015
Hi, I have a very unpleasant bug and absolutely no idea what am I doing
wrong... I try to use Buffer Texture
<https://www.opengl.org/wiki/Buffer_Texture> - a functionality that is
available in OpenGL since 2006 (so, quite old and reliable). I need to do
exactly this because I want to generate data on the CUDA side, and there is
no other way (that I know of) except of using buffers. In the simplified
example below (without CUDA) I generate simple data and try to connect the
texture to the buffer. * vtkgl::TexBufferEXT fails with
System.AccessViolationException...*
GLuint bufferObject;
GLuint _texname;
glGenTextures(1, &_texname);
vtkgl::ActiveTexture(vtkgl::TEXTURE0+_texname);
glBindTexture(vtkgl::TEXTURE_BUFFER_EXT, _texname);
vtkgl::GenBuffers(1, &bufferObject);
vtkgl::BindBuffer(vtkgl::TEXTURE_BUFFER_EXT, bufferObject);
int nWidth = 8;
int nHeight = 4;
vtkgl::BufferData(vtkgl::TEXTURE_BUFFER_EXT,
nWidth*nHeight*sizeof(float), NULL, vtkgl::DYNAMIC_DRAW);
float *test = (float *)vtkgl::MapBuffer(vtkgl::TEXTURE_BUFFER_EXT,
vtkgl::READ_WRITE);
for(int i=0; i<nWidth*nHeight; i++)
test[i] = 0.5;
vtkgl::UnmapBuffer(vtkgl::TEXTURE_BUFFER_EXT);
[fails here]
vtkgl::TexBufferEXT(vtkgl::TEXTURE_BUFFER_EXT, vtkgl::RGBA32F_ARB,
bufferObject);
vtkgl::BindBuffer(vtkgl::TEXTURE_BUFFER_EXT, 0);
I tried to do the same in the "pure OpenGL" project, and it works great (the
code is below)!
GLuint bufferObject;
GLuint _texname;
glGenTextures(1, &_texname);
glActiveTexture(GL_TEXTURE0+_texname);
glBindTexture(GL_TEXTURE_BUFFER_EXT, _texname);
glGenBuffers(1, &bufferObject);
glBindBuffer(GL_TEXTURE_BUFFER_EXT, bufferObject);
int nWidth = 8;
int nHeight = 4;
glBufferData(GL_TEXTURE_BUFFER_EXT, nWidth*nHeight*sizeof(float), NULL,
GL_DYNAMIC_DRAW);
float *test = (float *)glMapBuffer(GL_TEXTURE_BUFFER_EXT,
GL_READ_WRITE);
for(int i=0; i<nWidth*nHeight; i++)
test[i] = 0.5;
glUnmapBuffer(GL_TEXTURE_BUFFER_EXT);
glTexBufferEXT(GL_TEXTURE_BUFFER_EXT, GL_RGBA32F_ARB, bufferObject);
glBindBuffer(GL_TEXTURE_BUFFER_EXT, 0);
Any ideas? I double checked all enum values (like GL_RGBA32F_ARB and
GL_TEXTURE_BUFFER_EXT), they are the same in my both tests. I tried with
various buffer internal types (integer and float, R and RGBA). Nothing helps
:( The same error all the time!
Many thanks in advance!!!
--
View this message in context: http://vtk.1045678.n5.nabble.com/TEXTURE-BUFFER-fails-pure-OpenGL-vs-vtkgl-tp5731938.html
Sent from the VTK - Users mailing list archive at Nabble.com.
More information about the vtkusers
mailing list