c# - Unity plugin not working in OpenGL 4.1, working with OpenGL 2.1 -


i have question regarding small unity plugin i'm writing.

the plugin takes unity3d texture2d , tries update it, compiled plugin works when running unity3d -force-opengl (to run in opengl 2.1), it's not working when running in normal mode (opengl 4.1). there i'm missing?

the plugin should update internal opengl texture , set it's data. plugin not crash game or anything, texture update when running on 2.1, shows gray texture in 4.1

in unity's own sample they're using glew initialising opengl context (https://bitbucket.org/unity-technologies/graphicsdemos/src/548c5251ddbe82129b2584992a0f50caa4c34c6c/nativerenderingplugin/pluginsource/source/renderapi_openglcorees.cpp?at=default&fileviewer=file-view-default) shouldn't opengl context exist in plugin? there difference between opengl versions regarding that?

i'm running on osx el capitan.

here relevant code snippets:

c plugin code

#include <stdio.h> #include <inttypes.h>  #include <opengl/gl.h> #include <opengl/glu.h>  #include "unity/iunityinterface.h"  #include "debug.c"  void rendertexture (void* texid, int time) {     gluint gltex = (gluint)(size_t)(texid);      int id, i, j;     glubyte img[64 * 64 * 4];      (i = 0; < 64; i++) {         (j = 0; j < 64; j++) {             id = (4 * j) + (4 * 64 * i);             img[id] = (glubyte) time % 255;             img[id + 1] = (glubyte) time % 255;             img[id + 2] = (glubyte) (255 - time) % 255;             img[id + 3] = (glubyte) (255 - time) % 255;         }     }      glbindtexture(gl_texture_2d, gltex);     gltexsubimage2d(gl_texture_2d, 0, 0, 0, 64, 64, gl_rgba, gl_unsigned_byte, img); } 

c# unity code

using unityengine; using system.collections; using system.runtime.interopservices; using system; using system.io;  public class testbehaviour : monobehaviour {      [dllimport("main")]     private static extern void rendertexture (intptr ptrtexture, int time);      texture2d tex;      void start () {         tex = new texture2d (64, 64, textureformat.argb32, false);         tex.apply ();          getcomponent<renderer> ().material.settexture ("_maintex", tex);     }      void update () {         rendertexture (tex.getnativetextureptr (), (int)time.realtimesincestartup * 10);     }  } 

looking @ the docs, seems using -force-opengl unity uses legacy opengl. try -force-glcore , see if different result.


Comments

Popular posts from this blog

asynchronous - C# WinSCP .NET assembly: How to upload multiple files asynchronously -

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -