MeshContainer CompileSnapBuffer() { CreateSnap = true; RenderKind Save = Device.RenderKind; StoredSnapItems.Clear(); StoredSnapItems.Add(null); RegisterLocked = false; Device.RenderKind = RenderKind.SnapBuffer; MeshContainer Result = MeshCreator.CreateMeshes(Device, CompileDraw); Device.RenderKind = Save; RegisterLocked = true; CreateSnap = false; return(Result); }
//public void ReorgSnapBuffer() //{ // if (SnapMesh != null) // for (int i = 0; i < SnapMesh.Progs.Count; i++) // { // Mesh M = SnapMesh.Progs[i] as Mesh; // if (M != null) // { // SnapItem S = M.SnapItem; // M.ObjectNumber = StoredSnapItems.IndexOf(S); // } // SnapBufferDirty = true; // } //} public void RefreshSnapBuffer() { if (!Device.SnapEnable) { return; } // if ((SnapKind == Snap.Static) && (SnapMesh == null)) { SnapMesh = CompileSnapBuffer(); } //GL.Disable(EnableCap.Blend); //if (PickingShader == null) //{ // PickingShader = new GLShader(PickingFragmentShader, PickingVertexShader); // PickingShader.CompileAndLink(); // OpenGlDevice.CheckError(); //} CurrentObjectIndex = PickingShader.GetVarHandle("TheObject"); GLShader Save = Device.Shader; Device.Shader = PickingShader; RenderKind SaveRenderKind = Device.RenderKind; Device.RenderKind = RenderKind.SnapBuffer; if (!RegisterLocked) { StoredSnapItems.Clear(); StoredSnapItems.Add(null); } SnapBuffer.Init((int)Device.ViewPort.Width, (int)Device.ViewPort.Height); SnapBuffer.EnableWriting(); if (SnapMesh != null) { Device.Selector.FastRefresh = true; System.Diagnostics.Stopwatch SW = new System.Diagnostics.Stopwatch(); SW.Start(); SnapMesh.Paint(Device); SW.Stop(); Device.Selector.FastRefresh = false; } else { Device.OnPaint(); } SnapBuffer.DisableWriting(); Device.RenderKind = SaveRenderKind; SnapBufferDirty = false; ObjectBuffer = ReadPickingBuffer(0, 0, (int)Device.ViewPort.Width, (int)Device.ViewPort.Height); // GL.Enable(EnableCap.Blend); Device.Shader = Save; CreateSnapList(); }