예제 #1
0
        public void RenderCurrent(int instanceCount)
        {
            IBufferRange indexBufferRange     = Effective.Mesh.IndexBufferRange(Effective.MeshMode);
            ProgramGL1   requested_ProgramGL1 = (ProgramGL1)Requested.Program;
            bool         usePerInstance       = requested_ProgramGL1.FixedFunctionProgram.UsePerInstance;

            Timers.DrawCalls.Begin();
            for (int i = 0; i < instanceCount; ++i)
            {
                SetFrame(i);

                if (usePerInstance == true)
                {
                    Timers.ProgramSwitch.Begin();
                    Effective.Program.Use(i);
                    Timers.ProgramSwitch.End();
                }

                GL.DrawElements(
                    indexBufferRange.BeginMode,
                    (int)indexBufferRange.Count,
                    indexBufferRange.DrawElementsTypeGL,
                    (IntPtr)(indexBufferRange.OffsetBytes)
                    );
            }
            Timers.DrawCalls.End();
        }
예제 #2
0
        public void RenderInstancedPrepare()
        {
            Timers.MaterialSwitch.Begin();
            if (Effective.Material != Requested.Material)
            {
                Requested.Material.Use();
                Effective.Material = Requested.Material;
            }
            Timers.MaterialSwitch.End();

            Timers.ProgramSwitch.Begin();
            if (Effective.Program != Requested.Program)
            {
                ProgramGL1 requested_ProgramGL1 = (ProgramGL1)Requested.Program;
                if (requested_ProgramGL1.FixedFunctionProgram.UsePerInstance == false)
                {
                    Requested.Program.Use(0);
                    Effective.Program = Requested.Program;
                }
            }
            Timers.ProgramSwitch.End();

            Timers.AttributeSetup.Begin();
            BindAttributesAndCheckForUpdates();
            Timers.AttributeSetup.End();
        }
예제 #3
0
        public void UpdateMaterialProgramVertexStream(int instance)
        {
            Timers.MaterialSwitch.Begin();
            if (Effective.Material != Requested.Material)
            {
                Requested.Material.Use();
                Effective.Material = Requested.Material;
            }
            Timers.MaterialSwitch.End();

            Timers.ProgramSwitch.Begin();
            if (
                (Effective.Program != Requested.Program) ||
                modelsDirty
                )
            {
                ProgramGL1 program = (ProgramGL1)Requested.Program;

                Requested.Program.Use(instance);
                Effective.Program = Requested.Program;
                modelsDirty       = false;
            }
            Timers.ProgramSwitch.End();

            Timers.AttributeSetup.Begin();
            BindAttributesAndCheckForUpdates();
            Timers.AttributeSetup.End();
        }