(C++) How to apply a texture to a Plane from an in-memory array

The title pretty much sais it all. I am trying to create a textured flat plane, however since I am computing the results I am trying to directly apply the texture from the array without the need for a bitmap.

Unfortunately I am not finding the examples I need. From what I understand the way to do it is to create a ON_Material, assign the texture via an ON_Texture object, and then add the material to a ON_Brep object.

Is it possible to create a texture without requiring a bitmap?
And how would I then assign that texture to the brep?
(I’m sure there’s an example that I missed somewhere, but most examples I could find are written in C#)


@andy, can you help with this?

hello @dale @andy

We found a temporary workaround by creating a mesh and assigning the colors to the vertices, but that solution clearly isn’t ideal.
Could you point me to some examples / documentation explaining how to assign a texture? And do you have some idea as to how we could assign that from an array?


I have added example code to the SampleRdkAddRdkMaterials sample. The code is in CSampleRdkAddRdkMaterials::RunCommand() as an optional block surrounded by {{{ }}}. The example uses a ‘Dib Texture’ which allows you to set up a texture from any pixels you want without using a bitmap file.


1 Like