Perl-GPU / OpenGL-Modern

Perl OpenGL bindings for modern OpenGL 3.1-4.x
7 stars 5 forks source link

Support various ways for Perl code to use OpenGL (C pointers, packed strings, ndarrays, etc) #47

Open devel-chm opened 7 years ago

devel-chm commented 7 years ago

See the recent post to the POGL developers list for the initial discussion. The idea is that rather than 1-off implementations of OpenGL bindings for each type of possible array/pointer-ish object (OpenGL::Array, PDL, ...) we would implement a role to implement and require the needed functionality.

The implementation for an argument would then be something like this:

    sub glRoutine ($data_arg) {
        die "No bindings for data arg" unless $data_arg->does(OpenGL::Modern::Role::DataArg);
        # now we can use the role to implement the bindings
        &glRoutine_xs($data_arg->size,,$data_arg->ptr);
    }
mohawk2 commented 1 month ago

My summary of that discussion: some sort of polymorphism where a "class" of using code knows how to unwrap its data for OpenGL use, with an interface role providing the cue that that using code can do so.

My feeling is that there may be some value to this, but an alternative is for this distro to provide facilities for other Perl code to make their own bindings into OpenGL, by making available:

This is effectively the approach taken by the PDL bindings, which knows much better how to scale up OpenGL stuff (using broadcasting) than a thing done once per small-scale "thing" (single Perl array/vector). The way forward would be to let a hundred flowers bloom, and then identify what they have in common. Having worked with the PDL POGL bindings, and created a PDL OpenCV binding, my suspicion is that what will be in common will most usefully be the above.

With that in mind, this issue is too vague to really be actionable, but the link to the discussion is useful, so it should stay open for now.