Something odd happening to graphics/CUDA memory

I am trying to do my initialization in

BOOL CMyyPlugIn::OnLoadPlugIn()

So I set up my calls to initialize openGL and CUDA for my plugin to save on loading times (rather then do it in the cmd itself)

Then in the command I access the global variable from plugin via

CMyPlugIn thePluginGlobal = MyPlugIn();
thePluginGlobal.getMyVariable().Render();

Which works. I tested returning a dummy ID value to see if the object has been intialized and set and its what I expect.
But the GPU/CUDA memory seems to crash when I run something on it

Any reason why that would have gotten corrupted?

(The init works fine if in the cmd itself, but wastes 2 secs everytime its run. I am trying to set the GPU initialization in the onload plugin to avoid having to setup the GPU buffers and CUDA everytime)

Quickly looking at that code snippet, I see you are creating a new instance of your plugin class. You want to change the code to

CMyPlugIn& thePluginGlobal = …

Tried that, but that did not clear it up.

Its almost like Rhino is corrupting my buffers.

glBindBuffer(GL_ARRAY_BUFFER, colorbuffer);
float *ptr = (float*)glMapBufferARB(GL_ARRAY_BUFFER_ARB, GL_READ_WRITE_ARB);
ptr[index] = ptr[index + 4] = ptr[index+8] = pColor.r;
glUnmapBufferARB(GL_ARRAY_BUFFER_ARB); // release pointer to mapping buffer
glBindBuffer(GL_ARRAY_BUFFER, 0);

since this code is where its throwing up when I call it inside Rhino

I’m not sure if Rhino is doing something to the buffers underneath somehow?

Update the issue is with Rhino I lose my GLcontext somehow and cannot see to get it bcck for GLFW so glew cannot be re initialized on the 2nd run?

I’m confused. Rhino uses OpenGL (already) and as a plug-in developer you can play in its pipeline by implementing a conduit. What are you trying to do that you cannot do in a Rhino conduit?

If the init function works in your command, why not just keep a bool around to set that you’ve called init once? I’m having a hard time understanding exactly what it is that you are trying to do.