Use GlProgramFactory to modify a array of Vector

On 07/10/2015 at 08:34, xxxxxxxx wrote:

User Information:
Cinema 4D Version:   R16 
Platform:   Windows  ;   
Language(s) :     C++  ;

Hi, while looking for a good way to draw points in C4D's viewport i found the c4d_gl.cpp which contains some very intresting stuff but is not documented. With the expample file _gl_test_object.cpp
_ inside the sdk folder i managed to draw my points and every thing was fine.

Now im trying use the GlFactory class as a dynamic way of modifying huge Vector arrays with dierct C++ code this is very easy and also very fast with a GlFactory. Have a look inside the gl_test_object.cpp in you sdk folder  in Line 227 if you add the Red  vec4 and compile the Points will be Transformed by the vec4 in the Viewport.

> _....
> pFactory->HeaderFinished();
> pFactory->AddLine(VertexProgram, "oposition = (transmatrix * vec4(,    _
> 1.0))+ vec4(12.0,120.0,2.0,1.0);");
> _pFactory- >AddLine(VertexProgram, "ocolor = vec4(icolor.rgb, 1.0);");
> pFactory->AddLine(VertexProgram, "onormal = vec4(, 1.0);");
> _
My question is how do i get the fransformed data back .
I know it can be displayed with DrawSubBuffer , I also tried to this after Drawing.

> void* pData = pBuffer- >MapBuffer(bd, m_pSubBuffer, VBReadOnly) // Map the buffer
> _Vector32* pvData = (Vector32* )pData;
>  GePrint(String::VectorToString(pvData[0]));  // Print the 1st Point pos in the buffer
>  GePrint(String::VectorToString(g_pvParticlePoint[0])); // Print the 1st Orginal point
> _
But the Points are still the same.  How  can i get the GlProgramFactory programm  modifying a the Buffer?Where are the points stored that the GlProgramFactory programm  has modifyed??
If this isn't Possible is there a other way to to access the compiler used by the GlProgramFactor to compile a cpp file to dll and load it back in.
I hope you can understand my problem and help me.

Regards Caradhras

> _
> _

On 08/10/2015 at 02:03, xxxxxxxx wrote:


as you mentioned, the OpenGL Factory classes are currently not documented and not meant to be used by third party developers. Currently no further support can be given.

The code you write is GLSL, what you create are Vertex and Fragment shaders and the compiler used is the GLSL compiler in your graphic card driver. This has nothing to do with C++ or DLLs.

Best wishes,

On 09/10/2015 at 07:01, xxxxxxxx wrote:

it is actually not modifying the buffer
so this line:

_oposition = (transmatrix * vec4(,     _
_1.0))+ vec4(12.0,120.0,2.0,1.0);

_is modifying the oposition, the iposition (your buffer) is not touched!!

what you want requires CUDA or OpenCL, and can be done easily away from OpenGL.
there is an old attempt that I made using CUDA and Cinema4D GLSL,

On 15/10/2015 at 14:06, xxxxxxxx wrote:

Ok thanks for the help i will try to to implement cuda myself :).