Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re^3: Graphics: OpenGL in Perl/Tk ... with GLUT

by NERDVANA (Deacon)
on Jan 07, 2023 at 05:29 UTC ( [id://11149400]=note: print w/replies, xml ) Need Help??


in reply to Re^2: Graphics: OpenGL in Perl/Tk ... with GLUT
in thread Graphics: OpenGL in Perl/Tk ... with GLUT

The CPAN testers matrix for OpenGL::Sandbox can be misleading because it can use either OpenGL or OpenGL::Modern, and when it uses OpenGL it skips some of the tests because (for example) buffer objects aren't available from the OpenGL module.

I just checked with my current install of 5.36, and t/35 and t/36 are both crashing. I'll take a look at it. If you aren't using new stuff it won't matter for you.

I agree that OpenGL::Modern is less friendly. The author took a more "exactly the same as the C API" approach, and while that makes it easier to port C code to Perl, I doubt anyone wants to write C code in Perl if Perl isn't adding "friendly" wrappers. That was sort of why I made the OpenGL::Sandbox. If you look at the source code of the shadertoy script, it is massively simpler than the corresponding C code, and a lot safer than manipulating raw pointers in Perl.

The downside of modern / shaders is that I never wrote a Font module for it. So, the only way to get text is to use ::V1 and the matrix stack and all that.

  • Comment on Re^3: Graphics: OpenGL in Perl/Tk ... with GLUT

Replies are listed 'Best First'.
Re^4: Graphics: OpenGL in Perl/Tk ... with GLUT
by haj (Vicar) on Jan 07, 2023 at 11:21 UTC

    Thanks for the clarification regarding the Sandbox tests!

    I don't mind a "exactly the same as the C API" approach, but this then needs some explanation of how to deal with interfaces which expect a pointer to a C array like e.g. glSelectBuffer. OpenGL populates this C array, and I need a way to examine the results.

    I guess OpenGL::Modern can be used together with OpenGL::Array in the same way as it is used with OpenGL, but I have little motivation to try it.

    Also, I should mention that my focus isn't on shaders. While I know that they can provide amazing effects, I am happy with the "basic" stuff which is in plain old OpenGL. What I'm after is interaction with drawn shapes. Tk::Canvas provides this: I can add callbacks to individual polygons and tag them appropriately so that all primitives which make a complex shape have the same tag. Only this approach is getting painfully slow if I have tens of thousands of primitives. OpenGL has a different approach for this: Normal rendering is done without any callbacks. After a mouse click, I can re-render a tiny part part of the scene (e.g. a 5x5 pixel area around the point where the click happened) and OpenGL will tell me what objects were on the way.

    Plus, of course, most of the drawing is done by the GPU (which is, btw, the part also done by Tk::Zinc). This gives amazing speed, which is why I don't want to try the two-step approach of interactivity (i.e. redraw a tiny area after a mouse click) in plain Tk.

Re^4: Graphics: OpenGL in Perl/Tk ... with GLUT
by haj (Vicar) on Jan 07, 2023 at 11:46 UTC
    buffer objects aren't available from the OpenGL module

    But they are (as an "extension)! I did some research before starting with OpenGL and found the wikipedia article Perl_OpenGL. I got the POGL Sample Test App linked from there working. Understanding that code, on the other hand, took some time, and I would have surrendered, but then I found the ancient guide.

    The example does not work with OpenGL::Modern which no longer provides glGenBuffersARB_p.

      Well, glGenBuffersARB_p is gone in OpenGL::Modern because any OpenGL in the last (15 years?) has glGenBuffers which is the same thing by its now-official name, and I don't know if new OpenGLs would acknowledge the name glGenBuffersARB. But, thanks for pointing that out, because maybe I could check for it to provide buffer Perl objects when using using the original OpenGL module. But, what uses buffer objects in 1.4? Are all the rest of OpenGL 2's APIs provided as optional extensions on 1.4?

        Yeah, I understand why glGenBuffersARB_p (and the other ARB stuff) is gone in OpenGL::Modern.

        As of your question about the availability of OpenGL 2: I simply don't know. The OpenGL docs have a long list of interfaces, about 100 of them with ARB in their names, indicating registered extensions. Is that complete with regard to OpenGL 2? I've no idea.

        I have only just started to examine OpenGL, which was quite a journey. The Perl modules' documentation does not give much insight, and all the external links from the Wikipedia page Perl OpenGL are stale. I know that I'm currently using ancient interfaces, following an ancient guide. but hey, this stuff still works!

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11149400]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (2)
As of 2024-04-26 03:40 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found