Closed wchristian closed 7 years ago
The bindings for glTexImage* require a pointer as the data argument not a packed string. You don't show code but did you use pack_ptr()?
@devel-chm I tried this, but was rewarded only with a segfault:
pack_ptr my $null, 8;
glTexImage2D GL_TEXTURE_2D, 0, GL_RGBA, $dim[0], $dim[1], 0, GL_RGBA, GL_FLOAT, $null;
@devel-chm Also this part is not true as far as i can tell: "require a pointer as the data argument not a packed string"
This call works just fine, with $img being an OpenGL::Image object:
glTexImage2D GL_TEXTURE_2D, $mip_lod, $ifmt, $w, $h, $border, $fmt, $type, $img->GetBlob;
I had to change it from ->Ptr to that to make it work.
This doesn't work either:
my $null = pack 'P', undef;
glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA, $dim[0], $dim[1], 0, GL_RGBA, GL_FLOAT, $null );
pack_ptr() has the same usage as xs_buffer. The usage would be more like this:
my $null;
glTexImage2D(GL_TEXTURE_2D,0,GL_RGBA,$dim[0],$dim[1],0,GL_RGBA,GL_FLOAT,pack_ptr($null,8);
Still segfaults.
Also, i have to reiterate:
I was doing this before:
glTexImage2D_c GL_TEXTURE_2D, $mip_lod, $ifmt, $w, $h, $border, $fmt, $type, $img->Ptr; # OpenGL::Image
In order to get that to work with the bare glTexImage2D, i was forced to do this:
glTexImage2D GL_TEXTURE_2D, $mip_lod, $ifmt, $w, $h, $border, $fmt, $type, $img->GetBlob; # OpenGL::Image
As such, i am quite confident that whatever the API is, taking pointers is not a thing it does.
Sorry, my confusion---between the way things should be handled and the way they are currently handled in the XS bindings. Basically, all pointers are treated as a pointer to a string which is why you cannot have a null pointer. If you did, the string would not be valid.
The fix is to use better type mapping so that the perl call arguments are correct for the underlying C calls.
@devel-chm So if i understand you right, my initial understanding of the situation is correct and you must change the XS for those (and maybe other) functions because the current implementation cannot accept null pointers from the Perl world. Correct?
I believe that is correct. -chm
On Fri, Jan 13, 2017 at 12:54 PM, Christian Walde (Mithaldu) < notifications@github.com> wrote:
@devel-chm https://github.com/devel-chm So if i understand you right, my initial understanding of the situation is correct and you must change the XS for those (and maybe other) functions because the current implementation cannot accept null pointers from the Perl world. Correct?
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/devel-chm/OpenGL-Modern/issues/15#issuecomment-272502753, or mute the thread https://github.com/notifications/unsubscribe-auth/AAwNedxf-Id-yyC8XC5n1W3IGJeE5ESGks5rR7pMgaJpZM4LiupR .
This should be resolved with commit 0fbe33eedf24c7516152f647afd52d7f79066436 The values for the pointer can be gotten with pack('P', $string_data). See Helper.pm for updates on usage.
These issues should be resolved with OpenGL::Modern version 0.01_04 with the generic CPTR bindings named 'glTexImage1D_c'. Please re-open if needed. Thanks.
As far as i can tell with the current definition of the XS functions for those it is not possible to pass null pointers to them.
undef
immediately generates an error, "\0" is not seen as null pointer.