public override void OnApplyTemplate() { base.OnApplyTemplate(); if (Template != null) { openGLControl = Template.FindName("Viewport_3D", this) as OpenGLControl; hwndHostElement = Template.FindName("Ether_Viewport", this) as Control_Ether_HwndHost; sceneWindow = Template.FindName("SceneWindow", this) as Grid; //TODO: Reference by name if (CommandArguments.TryGetArgument("ether")) { sceneWindow.Children.RemoveAt(1); return; } sceneWindow.Children.RemoveAt(2); CompositionTarget.Rendering += (sender, args) => openGLControl.DoRender(); shaderErrorLabel = Template.FindName("Shader_Compiler_Error", this) as TextBlock; Hierarchy.FocusChangedEvent += o => cameraFocusPoint = o.Transform.Position; } }
/// <summary> /// 渲染 /// </summary> private void Render() { while (true) { var gl = openGLControl.OpenGL; gl.MakeCurrent(); gl.Begin(OpenGL.GL_TRIANGLES); gl.Color(1.0f, 0, 0); gl.Vertex(-1.0f, -1, z); gl.Color(0, 1.0f, 0); gl.Vertex(1.0f, -1, z); gl.Color(0, 0, 1.0f); gl.Vertex(0, 1.0f, z); gl.End(); openGLControl.Invoke(new MethodInvoker(() => { openGLControl.DoRender(); })); Thread.Sleep(10); } }
public void DoRender() { openGLControl.DoRender(); }
public void Render(byte[] outRgbArray = null) { OutputRrbArray = outRgbArray; OpenGLControl.DoRender(); Application.DoEvents(); }