private glClearColor ( float red, float green, float blue, float alpha ) : void | ||
red | float | |
green | float | |
blue | float | |
alpha | float | |
리턴 | void |
private void RenderNormally(Scene scene, Rectangle clientRectangle) { var arg = new RenderEventArgs(clientRectangle, this, PickingGeometryType.None); vec4 color = this.ClearColor.ToVec4(); OpenGL.glClearColor(color.x, color.y, color.z, color.w); OpenGL.Clear(OpenGL.GL_COLOR_BUFFER_BIT | OpenGL.GL_DEPTH_BUFFER_BIT | OpenGL.GL_STENCIL_BUFFER_BIT); // render objects. SceneObject obj = scene.RootObject; this.RenderObject(obj, arg); // render regular UI. scene.RootUI.Render(arg); //// render cursor. //UICursor cursor = this.Cursor; //if (cursor != null && cursor.Enabled) //{ // cursor.UpdatePosition(mousePosition); // this.rootCursor.Render(arg); //} }
/// <summary> /// /// </summary> protected override void StateOn() { OpenGL.GetFloat(GetTarget.ColorClearValue, original); OpenGL.glClearColor(clearColor.x, clearColor.y, clearColor.z, alpha); OpenGL.Clear(OpenGL.GL_COLOR_BUFFER_BIT); }
/// <summary> /// 在此Buffer中的图元进行N选1 /// select a primitive geometry(point, line, triangle, quad, polygon) from points/lines/triangles/quads/polygons in this renderer. /// </summary> /// <param name="arg"></param> /// <param name="indexBuffer">indicates the primitive to pick a line from.</param> internal void Render4InnerPicking(RenderEventArgs arg, IndexBuffer indexBuffer) { arg.UsingViewPort.On(); // record clear color var originalClearColor = new float[4]; OpenGL.GetFloat(GetTarget.ColorClearValue, originalClearColor); // 白色意味着没有拾取到任何对象 // white color: nothing picked. OpenGL.glClearColor(1.0f, 1.0f, 1.0f, 1.0f); OpenGL.Clear(OpenGL.GL_COLOR_BUFFER_BIT | OpenGL.GL_DEPTH_BUFFER_BIT | OpenGL.GL_STENCIL_BUFFER_BIT); // restore clear color OpenGL.glClearColor(originalClearColor[0], originalClearColor[1], originalClearColor[2], originalClearColor[3]); this.Render4Picking(arg, indexBuffer); OpenGL.Flush(); arg.UsingViewPort.Off(); //var filename = string.Format("Render4InnerPicking{0:yyyy-MM-dd_HH-mm-ss.ff}.png", DateTime.Now); //Save2PictureHelper.Save2Picture(0, 0, // e.CanvasRect.Width, e.CanvasRect.Height, filename); }
///// <summary> ///// Maybe something is picked because depth buffer is valid. ///// </summary> ///// <param name="pickingRect"></param> ///// <returns></returns> //private static unsafe bool DepthBufferValid(Rectangle pickingRect) //{ // if (pickingRect.Width <= 0 || pickingRect.Height <= 0) { return false; } // bool result = false; // using (var codedColor = new UnmanagedArray<byte>(pickingRect.Width * pickingRect.Height)) // { // OpenGL.ReadPixels(pickingRect.X, pickingRect.Y, pickingRect.Width, pickingRect.Height, // OpenGL.GL_DEPTH_COMPONENT, OpenGL.GL_UNSIGNED_BYTE, codedColor.Header); // var array = (byte*)codedColor.Header.ToPointer(); // for (int i = 0; i < codedColor.Length; i++) // { // if (array[i] < byte.MaxValue) // { // result = true; // break; // } // } // } // return result; //} /// <summary> /// Render all <see cref="PickableRenderer"/>s for color-coded picking. /// </summary> /// <param name="arg"></param> /// <returns></returns> internal List <IPickable> Render4Picking(RenderEventArgs arg) { arg.UsingViewPort.On(); // record clear color var originalClearColor = new float[4]; OpenGL.GetFloat(GetTarget.ColorClearValue, originalClearColor); // white color means nothing picked. OpenGL.glClearColor(1.0f, 1.0f, 1.0f, 1.0f); OpenGL.Clear(OpenGL.GL_COLOR_BUFFER_BIT | OpenGL.GL_DEPTH_BUFFER_BIT | OpenGL.GL_STENCIL_BUFFER_BIT); // restore clear color OpenGL.glClearColor(originalClearColor[0], originalClearColor[1], originalClearColor[2], originalClearColor[3]); uint renderedVertexCount = 0; var pickedRendererList = new List <IPickable>(); RenderPickableObject(this.rootObject, arg, ref renderedVertexCount, pickedRendererList); OpenGL.Flush(); arg.UsingViewPort.Off(); return(pickedRendererList); }
/// <summary> /// render scene in this view port. /// </summary> /// <param name="scene"></param> /// <param name="clientRectangle"></param> /// <param name="pickingGeometryType"></param> public override void Render(Scene scene, System.Drawing.Rectangle clientRectangle, PickingGeometryType pickingGeometryType) { this.On();// limit rendering area. vec4 color = this.ClearColor.ToVec4(); OpenGL.glClearColor(color.x, color.y, color.z, color.w); OpenGL.Clear(OpenGL.GL_COLOR_BUFFER_BIT | OpenGL.GL_DEPTH_BUFFER_BIT | OpenGL.GL_STENCIL_BUFFER_BIT); this.Off();// cancel limitation. }
/// <summary> /// /// </summary> protected virtual void DesignModeRendering() { // Sky blue fore background. //OpenGL.ClearColor(0x87 / 255.0f, 0xce / 255.0f, 0xeb / 255.0f, 0xff / 255.0f); OpenGL.glClearColor(0, 0, 0, 0); // Clear the color and depth buffer. OpenGL.Clear(OpenGL.GL_COLOR_BUFFER_BIT | OpenGL.GL_DEPTH_BUFFER_BIT | OpenGL.GL_STENCIL_BUFFER_BIT); OpenGL.DrawText(10, 10, Color.White, "Courier New",// "Courier New", 25.0f, this.fullname); if (this.RenderTrigger == RenderTrigger.TimerBased) { OpenGL.DrawText(10, this.Height - 20 - 1, Color.Red, "Courier New",// "Courier New", 20.0f, string.Format("FPS: {0}", this.FPS.ToShortString())); } }
private void RenderColorCoded(Scene scene, Rectangle clientRectangle, PickingGeometryType pickingGeometryType) { var color = new vec4(1, 1, 1, 1); OpenGL.glClearColor(color.x, color.y, color.z, color.w); OpenGL.Clear(OpenGL.GL_COLOR_BUFFER_BIT | OpenGL.GL_DEPTH_BUFFER_BIT | OpenGL.GL_STENCIL_BUFFER_BIT); var arg = new RenderEventArgs(clientRectangle, this, pickingGeometryType); // render objects. // Render all PickableRenderers for color-coded picking. List <IPickable> pickableRendererList = scene.Render4Picking(arg); //// render regular UI. //this.RootUI.Render(arg); //// render cursor. //UICursor cursor = this.Cursor; //if (cursor != null && cursor.Enabled) //{ // cursor.UpdatePosition(mousePosition); // this.rootCursor.Render(arg); //} }
/// <summary> /// /// </summary> protected override void StateOff() { OpenGL.glClearColor(original[0], original[1], original[2], original[3]); }