# More and Faster: glInterleavedArrays glDrawArrays

**URL:** <https://discourse.processing.org/t/more-and-faster-glinterleavedarrays-gldrawarrays/5044>\
**Category:** Coding Questions\
**Created:** [October 30, 2018, 8:12pm UTC](https://discourse.processing.org/t/more-and-faster-glinterleavedarrays-gldrawarrays/5044 "2018-10-30T20:12:27Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![TPMoyer](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/tpmoyer/32/2138_2.png) [@TPMoyer](https://discourse.processing.org/u/TPMoyer)\
**Post date:** [October 30, 2018, 8:12pm UTC](https://discourse.processing.org/t/more-and-faster-glinterleavedarrays-gldrawarrays/5044/1 "2018-10-30T20:12:27Z")

</div>

Anyone have pointers as to how I might move toward being able to use the array functions from openGL (glInterleavedArrays and glDrawArrays) within processing? Am ok if this involves my needing to develop a library. Google searches on processing “glInterleavedArrays” returned nothing.

Initial application space is converting my present capability to show CNC tool paths. This is a full 3D slider\<==\>time pseudo VCR of the developing trenches in the material as the bit passes through. Current code is in C++. Used the glInterleavedArrays and glDrawArrays techniques to avoid calls to methods for every point in the fairly extensive TRIANGLE\_STRIP’s.

My Background: Started as a course III. Wrote a 3D fly-thru openGL C++ app for all 100K wires in an IBM mainframe. Wanted to do web stuff so wrote [http://www.webgltutorials.appspot.com/WebGLTutorial06](http://www.webgltutorials.appspot.com/WebGLTutorial06) in java and javascript with full homebrew GL\_Shaders. Think processing hits the sweet spot on GUI, adaptability, community, platform access, and extendability.

Hope to help.

---

<div class="post-metadata">

**Author:** ![jeremydouglass](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jeremydouglass/32/20_2.png) [@jeremydouglass](https://discourse.processing.org/u/jeremydouglass)\
**Post date:** [October 31, 2018, 6:10pm UTC](https://discourse.processing.org/t/more-and-faster-glinterleavedarrays-gldrawarrays/5044/2 "2018-10-31T18:10:19Z")

</div>

@TPMoyer – this sounds great. You should also post a hello in [Please Introduce Yourself](https://discourse.processing.org/t/please-introduce-yourself/15/127)

IANA expert in openGL, but we do have a few on the forum – for example, I believe @gohai is quite experienced with this and has written Processing + openGL libraries. Hopefully someone can suggest starting points.

---

<div class="post-metadata">

**Author:** ![gohai](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/gohai/32/25_2.png) [@gohai](https://discourse.processing.org/u/gohai)\
**Post date:** [October 31, 2018, 10:50pm UTC](https://discourse.processing.org/t/more-and-faster-glinterleavedarrays-gldrawarrays/5044/3 "2018-10-31T22:50:33Z")

</div>

I wish I knew anything about GL - I am just an occational _plumber_.

I would suggest looking directly at the source code of Processing’s P2D/P3D renderer, to see if it provides access to what you want to use. You find the files [here](https://github.com/processing/processing/tree/master/core/src/processing/opengl). Compiling and runnig a modified version is also surprisingly easy, as you only need a recent `JDK` and `ant` installed (the a link in the Readme on Processing’s Github project has more information about that).

The linked P2D/P3D renderer makes use of the JOGL library, which makes it possible to call the GL C API from within Java. So you could attempt to add missing functionality by adding the necessary methods or classes in P2D/P3D.

---

<div class="post-metadata">

**Author:** ![neilcsmith](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/neilcsmith/32/144_2.png) [@neilcsmith](https://discourse.processing.org/u/neilcsmith)\
**Post date:** [November 1, 2018, 8:47am UTC](https://discourse.processing.org/t/more-and-faster-glinterleavedarrays-gldrawarrays/5044/4 "2018-11-01T08:47:00Z")

</div>

`beginPGL` probably gives access to the required functionality, but if not you can directly access JOGL from it - see [https://github.com/processing/processing/wiki/Advanced-OpenGL](https://github.com/processing/processing/wiki/Advanced-OpenGL)

It’s quite easy to extend the P2D/P3D renderers to add additional functionality without having to fork core Processing.

It’s also worth looking at PShape with the GL renderers, or at least the code of.

---

<div class="post-metadata">

**Author:** ![TPMoyer](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/tpmoyer/32/2138_2.png) [@TPMoyer](https://discourse.processing.org/u/TPMoyer)\
**Post date:** [June 6, 2019, 1:29am UTC](https://discourse.processing.org/t/more-and-faster-glinterleavedarrays-gldrawarrays/5044/5 "2019-06-06T01:29:46Z")

</div>

Good pointers!  
Got this up and working by riffing off the examples/Demos/Graphics/LowLevelGLVboInterleaved.  
Shared this as github [https://github.com/TPMoyer/Processing3-using-low-level-OpenGL-VBO](http://FastLowLevelOpenGLVbo).

Did not need to recompile the Processing source.

The prior example showed how to use the beginPGL structures to  
invoke shaders,  
set up both the to-be-drawn data and the shader variables  
push data to the GPU  
launch a single method DrawArrays() call to roll through all the data.

```
How might one nominate a sketch for inclusion in the distributed examples? 

```

The present code should enable substantially faster rendering than the prior published example. It avoids the needless re-calculation and of the dataset for each Draw(), and avoids the needless data movement from the CPU to the GPU for each Draw().

---

<div class="post-metadata">

**Author:** ![jeremydouglass](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jeremydouglass/32/20_2.png) [@jeremydouglass](https://discourse.processing.org/u/jeremydouglass)\
**Post date:** [June 6, 2019, 1:33pm UTC](https://discourse.processing.org/t/more-and-faster-glinterleavedarrays-gldrawarrays/5044/6 "2019-06-06T13:33:35Z")

</div>

Regarding distributed examples, I _believe_ you can just put the sketch in a pull request to the examples repository.

- [https://github.com/processing/processing-docs/tree/master/content](https://github.com/processing/processing-docs/tree/master/content)

I believe this (with the xml index) is used to build both the examples in PDE and the examples on the website.
