I'm trying to update a texture within a plugin using opengl (Windows, Visual C++), since SetPixlels() + Apply() seems to be way too slow for frequent updates.
It all compiles and runs fine, but the data does not make it into the texture, it displays random stuff. In my plugin, glBindTexture( GL_TEXTURE_2D, tex_id ) finishes with glGetError = GL_INVALID_OPERATION, which seems to be the root of the problem.
Does the Windows standard opengl implementation (GL/gl.h) even work well with unity in this way?
Thanks a lot!! Chris.
asked Dec 22 '10 at 01:31 AM
Are you forcing unity to be running in OpenGL mode? Windows defaults to DirectX by default so forcing opengl textures probably won't do a great deal
answered Dec 22 '10 at 02:01 AM
Excellent, that fixed it. Thanks!
Are there any expected side effect of forcing OpenGL like that? Frame rates seem to be similar... haven't tested fully yet.
answered Dec 30 '10 at 12:04 AM
One more note for any onlookers: the bind & update call has to be on the render thread, or it will fail. GL.IssuePluginEvent did the trick for me, and now I have fast streaming alpha video textures with no calls to Texture2D.Apply!
answered Apr 08 '12 at 03:32 AM
Hello! I've been trying to use nativeTextureIDs myself for a while, but they just doesn't seem to work [or, I just can't seem to get them working ;-) ].
I have an educational pro license, and I'm quite familiar with dll development. I modified the GL.IssuePluginEvent example project in order to send a RenderTexture ID to an external dll, while the dll UnityRenderEvent just binds to the texture id and applies the texture to a quad and then to a triangle. What I get is just the "for educational use only" string used as a texture over both the quad and triangle. Is that some limitation of trial/educational pro versions, or am I just forgetting something?
I also tried to randomly change the texture ID, and the result is always the same [and quite funny ;-) ]:
P.S. The very same OpenGL code works with textures sent as Color32 arrays to secondary OpenGL/GLUT window (a different dll), but that was way too slow for my needs (sending RenderTexture on every frame). I tried to use native IDs in that case too, but with no luck (different opengl contexts: didn't work even if I explicitly tried to get the contexts handles).