示例#1
0
 public void WriteLine(string entry, LogLevel severity)
 {
     if (severity >= MinimumLevel)
     {
         RenderProgram.WriteLine(entry);
     }
 }
示例#2
0
        internal void AddGeometry(Vertex[] vertices, RenderProgram renderProgram)
        {
            // Find a batch with matching render programs or create a new one if it does not exist
            GeometryBatch batch = FindBatch(renderProgram) ?? CreateBatch(renderProgram);

            batch.AddVertices(vertices);
        }
示例#3
0
        internal GeometryBatch FindBatch(RenderProgram renderProgram)
        {
            foreach (GeometryBatch batch in Batches)
            {
                if (batch.RenderProgram == renderProgram)
                {
                    return(batch);
                }
            }

            return(null);
        }
示例#4
0
        internal GeometryBatch CreateBatch(RenderProgram renderProgram)
        {
            GeometryBatch newBatch = new GeometryBatch(renderProgram);

            Batches.Add(newBatch);
            SortBatchesByDrawLayer();

            if (BatchesAreHot)
            {
                newBatch.Begin();
            }

            return(newBatch);
        }
示例#5
0
        protected override void OnLoad()
        {
            GL.ClearColor(Color4.CornflowerBlue);

            FadeSettings = FadeSettings.Default();

            _renderProgram = RenderProgram.Create();

            _textureOut = new Texture2D(SizedInternalFormat.Rgba8, _width, _height);
            _textureOut.SetFilter(TextureMinFilter.Nearest, TextureMagFilter.Nearest);
            _textureOut.Bind(TextureUnit.Texture0);

            _agentProgram = AgentProgram.Create(_width, _height, _textureOut, _numberOfAgents, AgentSettings.Default());

            _fadeProgram = FadeProgram.Create(_width, _height, _textureOut, FadeSettings.Default());
        }
示例#6
0
 public void WriteLine()
 {
     RenderProgram.WriteLine();
 }
示例#7
0
 public void WriteLine(string entry)
 {
     RenderProgram.WriteLine(entry);
 }
示例#8
0
 public void Close()
 {
     RenderProgram.Stop();
 }
示例#9
0
        internal static void Draw(IntRect viewport, int shaderProgram, Vertex[] vertices, int length, int vbo,
                                  int posAttribLocation, int colorAttribLocation, int texCoordAttribLocation,
                                  RenderProgram renderProgram, Matrix projection, int textureOverride = -1)
        {
            GL.Viewport(viewport.X, viewport.Y, viewport.Width, viewport.Height);

            GL.BindBuffer(BufferTarget.ArrayBuffer, vbo);
            GL.UseProgram(shaderProgram);
            GL.BindFragDataLocation(shaderProgram, 0, Shader.FragOutName);
            GL.BufferData(BufferTarget.ArrayBuffer, Vertex.SizeInBytes * length, vertices, BufferUsageHint.StaticDraw);

            GL.EnableVertexAttribArray(posAttribLocation);
            GL.VertexAttribPointer(posAttribLocation, 2, VertexAttribPointerType.Float, false, Vertex.SizeInBytes, 0);

            GL.EnableVertexAttribArray(colorAttribLocation);
            GL.VertexAttribPointer(colorAttribLocation, 4, VertexAttribPointerType.Float, false, Vertex.SizeInBytes, 2 * sizeof(float));

            GL.EnableVertexAttribArray(texCoordAttribLocation);
            GL.VertexAttribPointer(texCoordAttribLocation, 2, VertexAttribPointerType.Float, false, Vertex.SizeInBytes, 6 * sizeof(float));

            int uniTrans = GL.GetUniformLocation(shaderProgram, Shader.VertUniTransformName);

            float[] trans = projection.ToMatrix4();
            GL.UniformMatrix4(uniTrans, 1, false, trans);

            GL.Enable(EnableCap.Blend);

            GL.BlendEquationSeparate(
                (BlendEquationMode)renderProgram.BlendMode.ColorEquation,
                (BlendEquationMode)renderProgram.BlendMode.AlphaEquation);

            GL.BlendFuncSeparate(
                (BlendingFactorSrc)renderProgram.BlendMode.ColorSrcFactor, (BlendingFactorDest)renderProgram.BlendMode.ColorDstFactor,
                (BlendingFactorSrc)renderProgram.BlendMode.AlphaSrcFactor, (BlendingFactorDest)renderProgram.BlendMode.AlphaDstFactor);

            int texture = 0;

            if (textureOverride != -1)
            {
                texture = textureOverride;
            }
            else
            {
                if (renderProgram.Texture != null)
                {
                    texture = renderProgram.Texture.Handle;
                }
                else
                {
                    texture = GlobalContent.Get.TextureWhite32x32.Handle;
                }
            }

            GL.Enable(EnableCap.Texture2D);
            GL.ActiveTexture(TextureUnit.Texture0);
            GL.BindTexture(TextureTarget.Texture2D, texture);

            GL.DrawArrays(PrimitiveType.Quads, 0, length);

            GL.Disable(EnableCap.Texture2D);
            GL.Disable(EnableCap.Blend);
            GL.BindTexture(TextureTarget.Texture2D, 0);
            GL.DisableVertexAttribArray(posAttribLocation);
            GL.DisableVertexAttribArray(colorAttribLocation);
            GL.DisableVertexAttribArray(texCoordAttribLocation);
            GL.BindBuffer(BufferTarget.ArrayBuffer, 0);
            GL.UseProgram(0);
        }