/// <summary> /// Returns false if error. /// </summary> /// <returns></returns> public static void UpdateRgbFrame() { MetaCoreInterop.meta_get_rgb_frame(RawPixelBuffer, _translation, _new_rotation); // The buffer is pre-allocated by constructor. // Check for a difference bool isEqual = true; // Check for a difference in pose (should change with each new RGB frame). for (int i = 0; i < _new_rotation.Length; ++i) { isEqual = _rotation[i] == _new_rotation[i]; if (!isEqual) { break; } } // If the two rotations are not equal, we have a new rgb frame. if (!isEqual) { // Copy new rotation if it's different. for (int i = 0; i < _new_rotation.Length; ++i) { _rotation[i] = _new_rotation[i]; } _rgbTexture.LoadRawTextureData(RawPixelBuffer, _totalBufferSize); _rgbTexture.Apply(); } }
static int _m_LoadRawTextureData(RealStatePtr L) { try { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); UnityEngine.Texture2D gen_to_be_invoked = (UnityEngine.Texture2D)translator.FastGetCSObj(L, 1); int gen_param_count = LuaAPI.lua_gettop(L); if (gen_param_count == 3 && LuaTypes.LUA_TLIGHTUSERDATA == LuaAPI.lua_type(L, 2) && LuaTypes.LUA_TNUMBER == LuaAPI.lua_type(L, 3)) { System.IntPtr _data = LuaAPI.lua_touserdata(L, 2); int _size = LuaAPI.xlua_tointeger(L, 3); gen_to_be_invoked.LoadRawTextureData(_data, _size); return(0); } if (gen_param_count == 2 && (LuaAPI.lua_isnil(L, 2) || LuaAPI.lua_type(L, 2) == LuaTypes.LUA_TSTRING)) { byte[] _data = LuaAPI.lua_tobytes(L, 2); gen_to_be_invoked.LoadRawTextureData(_data); return(0); } } catch (System.Exception gen_e) { return(LuaAPI.luaL_error(L, "c# exception:" + gen_e)); } return(LuaAPI.luaL_error(L, "invalid arguments to UnityEngine.Texture2D.LoadRawTextureData!")); }
/// <summary> /// Render the current slide of pptview.exe into a Unity Texture2D /// NOTE: this method will resize the texture if it's not the correct size/format /// </summary> /// <param name="texture">texture to receive pptview.exe's window pixels</param> public void Render(ref UnityEngine.Texture2D texture) { int width = 0, height = 0; if (!Render(ref lastRenderedPixels, ref width, ref height)) { return; } if (texture.width != width || texture.height != height || texture.format != UnityEngine.TextureFormat.BGRA32) { texture.Resize(width, height, UnityEngine.TextureFormat.BGRA32, false); } // NOTE: this method is ONLY for debugging purposes. If you actually // need to render to a Texture2D faster you should use the new shiny // LoadRawTextureData(IntPtr data, int size) overload! texture.LoadRawTextureData(lastRenderedPixels); texture.Apply(); }