/// <summary> Called before Render (normally by RenderList::Render) to set up data for the render. /// currentstate may be null, meaning, don't apply /// RenderState may be null, meaning don't change</summary> public void Bind(GLRenderState currentstate, IGLProgramShader shader, GLMatrixCalc matrixcalc) { if (currentstate != null && RenderState != null) // if either null, it means the last render state applied is the same as our render state, so no need to apply { currentstate.ApplyState(RenderState); // else go to this state } VertexArray?.Bind(); // give the VA a chance to bind to GL RenderData?.Bind(this, shader, matrixcalc); // optional render data supplied by the user to bind ElementBuffer?.BindElement(); // if we have an element buffer, give it a chance to bind IndirectBuffer?.BindIndirect(); // if we have an indirect buffer, give it a chance to bind ParameterBuffer?.BindParameter(); // if we have a parameter buffer, give it a chance to bind }
/// <summary> Called by WinFormControl, this sets up the initial render state </summary> static public GLRenderState Start() { var startstate = new GLRenderState() // Set the default state we want to be in at start (some state defaults are at bottom) { FrontFace = FrontFaceDirection.Ccw, CullFace = true, PolygonModeFrontAndBack = PolygonMode.Fill, PatchSize = 1, PointSize = 1, PointSprite = false, PointSmooth = true, PolygonSmooth = false, LineWidth = 1, LineSmooth = true, }; var curstate = new GLRenderState() // set to be purposely not default constructor state and the above state { // to make all get set. PrimitiveRestart = 1, ClipDistanceEnable = 1, DepthTest = false, DepthFunctionMode = DepthFunction.Never, WriteDepthBuffer = false, DepthClamp = true, BlendEnable = false, BlendSourceRGB = BlendingFactorSrc.ConstantAlpha, BlendSourceA = BlendingFactorSrc.ConstantAlpha, BlendDestRGB = BlendingFactorDest.ConstantAlpha, BlendDestA = BlendingFactorDest.ConstantAlpha, BlendEquationA = BlendEquationMode.Min, BlendEquationRGB = BlendEquationMode.Min, ColorMasking = 0, Discard = true, }; curstate.ApplyState(startstate); // from curstate, apply state return(startstate); }