Esempio n. 1
0
        public void Draw(StateSetGL stateSetGL)
        {
            stateSetGL.BackfaceCulling = BackfaceCulling;
            stateSetGL.ShaderPointSize = ShaderPointSize;
            stateSetGL.ZBufferTest     = ZBufferTest;
            stateSetGL.Shader          = Shader;

            BindTextures();
            ActivateBuffers();

            var vao = Vao;

            if (ReferenceEquals(null, vao))
            {
                if (1 == InstanceCount)
                {
                    GL.DrawArrays(PrimitiveType.Quads, 0, 4);                     //todo: make this general -> mesh with only vertex count? particle system, sprites
                }
                else
                {
                    GL.DrawArrays(PrimitiveType.Points, 0, InstanceCount);
                }
            }
            else
            {
                Vao.Draw(InstanceCount);
            }

            DeactivateBuffers();
            UnbindTextures();
        }
Esempio n. 2
0
        /// <summary>
        /// Draws the specified context.
        /// </summary>
        /// <param name="context">The context.</param>
        public void Draw(IRenderContext context)
        {
            context.RenderState.Set(new ShaderPointSize(ShaderPointSize));
            context.RenderState.Set(new DepthTest(ZBufferTest));
            context.RenderState.Set(new FaceCullingModeState(BackfaceCulling ? FaceCullingMode.BACK_SIDE : FaceCullingMode.NONE));
            context.RenderState.Set(new ActiveShader(ShaderProgram));

            BindTextures();
            ActivateBuffers();

            var vao = Vao;

            if (vao is null)
            {
                if (1 == InstanceCount)
                {
                    GL.DrawArrays(PrimitiveType.Quads, 0, 4);                     //TODO: make this general -> mesh with only vertex count? particle system, sprites
                }
                else
                {
                    GL.DrawArrays(PrimitiveType.Points, 0, InstanceCount);
                }
            }
            else
            {
                Vao.Draw(InstanceCount);
            }

            DeactivateBuffers();
            UnbindTextures();
        }
Esempio n. 3
0
        /// <summary>
        /// Draws the specified context.
        /// </summary>
        /// <param name="context">The context.</param>
        public void Draw(IRenderContext context)
        {
            var stateManager = context.StateManager;

            context.RenderState.Set(new BoolState <IShaderPointSizeState>(ShaderPointSize));
            context.RenderState.Set(new BoolState <IDepthState>(ZBufferTest));
            context.RenderState.Set(new BoolState <IBackfaceCullingState>(BackfaceCulling));

            stateManager.Get <StateActiveShaderGL, StateActiveShaderGL>().ShaderProgram = ShaderProgram;

            BindTextures();
            ActivateBuffers();

            var vao = Vao;

            if (vao is null)
            {
                if (1 == InstanceCount)
                {
                    GL.DrawArrays(PrimitiveType.Quads, 0, 4); //TODO: make this general -> mesh with only vertex count? particle system, sprites
                }
                else
                {
                    context.DrawPoints(InstanceCount);
                }
            }
            else
            {
                Vao.Draw(InstanceCount);
            }

            DeactivateBuffers();
            UnbindTextures();
        }