public static void EndFrame() { GLRecycleBin.AddTextureToDeleteList(InitialColorBuffer); InitialColorBuffer = IntPtr.Zero; GLRecycleBin.AddTextureToDeleteList(InitialDepthBuffer); InitialDepthBuffer = IntPtr.Zero; }
public static IDisposable BeginFrame(Rhino.Display.DisplayPipeline display, List <GLShaderComponentBase> components) { // check to see if any components use _colorBuffer or _depthBuffer bool usesInitialColorBuffer = false; bool usesInitialDepthBuffer = false; foreach (var component in components) { if (!usesInitialColorBuffer && component._model.TryGetUniformType("_colorBuffer", out string dataType, out int arrayLength)) { usesInitialColorBuffer = true; } if (!usesInitialDepthBuffer && component._model.TryGetUniformType("_depthBuffer", out dataType, out arrayLength)) { usesInitialDepthBuffer = true; } } if (usesInitialColorBuffer) { IntPtr texture2dPtr = Rhino7NativeMethods.RhTexture2dCreate(); Rhino7NativeMethods.RhTexture2dCapture(display, texture2dPtr, Rhino7NativeMethods.CaptureFormat.kRGBA); InitialColorBuffer = texture2dPtr; } if (usesInitialDepthBuffer) { IntPtr texture2dPtr = Rhino7NativeMethods.RhTexture2dCreate(); Rhino7NativeMethods.RhTexture2dCapture(display, texture2dPtr, Rhino7NativeMethods.CaptureFormat.kDEPTH24); InitialDepthBuffer = texture2dPtr; } foreach (var texture in _componentSamplers.Values) { GLRecycleBin.AddTextureToDeleteList(texture); } _componentSamplers.Clear(); // figure out list of per component depth and color textures that need to be created/retrieved foreach (var component in components) { string[] samplers = component._model.GetUniformsAndAttributes(0).GetComponentSamplers(); foreach (var sampler in samplers) { _componentSamplers[sampler.ToLowerInvariant()] = IntPtr.Zero; } } return(new PerFrameLifetimeObject()); }