Example #1
0
        /// <summary>
        /// copies the backcound to the foreground.
        /// </summary>
        public void CopyFromBackGround()
        {
            // Draw the Texture from Backbuffer by a Polygon Rectangle for the full screen

            xyArray    FP = new xyArray(); FP.data = new xy[] { new xy(0, 0), new xy(0, 1), new xy(1, 1), new xy(1, 0) };
            Matrix     P  = ProjectionMatrix;
            GLShader   S  = Shader;
            RenderKind K  = RenderKind;

            RenderKind = RenderKind.Render;
            Shader     = BackGroundShader;
            Texture T = texture;

            texture = BackBuffer.Texture;
            PushMatrix();
            ModelMatrix = Matrix.Translation(new xyz(0, 0, 1));
            PolygonMode PM = PolygonMode;

            PolygonMode      = PolygonMode.Fill;
            ProjectionMatrix = Bias;

            drawPolyLine(FP);
            ProjectionMatrix = P;
            PopMatrix();

            // Save Back
            RenderKind  = K;
            texture     = T;
            this.Shader = S;
            PolygonMode = PM;
        }
Example #2
0
        /// <summary>
        /// refreshes the back ground for <see cref="ForeGroundDraw"/>.
        /// </summary>
        public void RefreshBackGround()
        {
            Texture  Savet = texture;
            GLShader S     = Shader;

            BackBuffer.BackGround = BackColor;
            if (BackBuffer.FboHandle <= 0)
            {
                BackBuffer.Init((int)ViewPort.Width, (int)ViewPort.Height);
            }

            RenderKind K = RenderKind;

            RenderKind = RenderKind.Render;
            Matrix P = ProjectionMatrix;

            ProjectionMatrix = Matrix.scale(new xyz(1, -1, 1)) * P;

            //--------- Draw scene to Backbuffer
            BackBuffer.EnableWriting();

            OnPaint();

            BackBuffer.DisableWriting();
            texture          = Savet;
            ProjectionMatrix = P;
            RenderKind       = K;
            Shader           = S;
        }
Example #3
0
        /// <summary>
        /// compiles the <see cref="DrawAction"/> draw and returns a meshContainer.
        /// The <b>progs</b> of this is a list of <see cref="Mesh"/>.
        /// This method is called from <see cref="Entity.Compile(OpenGlDevice)"/>.
        /// </summary>
        /// <param name="Device"><see cref="OpenGlDevice"/> in which will be drawn.</param>
        /// <param name="Draw">the <see cref="DrawAction"/>, which is used to produce a <see cref="MeshContainer"/></param>
        /// <returns></returns>
        public static MeshContainer Compile(OpenGlDevice Device, DrawAction Draw)
        {
            Device.PushMatrix();
            MeshListCurrent = new MeshContainer();
            bool Compiling = Entity.Compiling;

            if (Compiling)
            {
                MeshCreator.Push();
            }
            bool SaveCompiling = Entity.Compiling;

            Entity.Compiling = true;
            RenderKind SaveRenderKind = Device.RenderKind;

            Device.RenderKind = RenderKind.Render;
            MeshIndices.Clear();

            Draw(Device);

            Renew();
            Entity.Compiling  = SaveCompiling;
            Device.RenderKind = SaveRenderKind;
            Device.PopMatrix();
            MeshContainer Result = MeshListCurrent;

            if (Compiling)
            {
                MeshCreator.Pop();
            }
            return(Result);
        }
Example #4
0
 public RenderData(Texture tex, BlendMode blend, RenderKind kind, ushort idxStart)
 {
     Texture    = tex;
     BlendMode  = blend;
     RenderKind = kind;
     Index0     = idxStart;
     Index1     = (ushort)(idxStart + 1);
     Index2     = (ushort)(idxStart + 2);
     Index3     = (ushort)(idxStart + 1);
     Index4     = (ushort)(idxStart + 3);
     Index5     = (ushort)(idxStart + 2);
 }
Example #5
0
        /// <summary>
        /// is the main method of this object. See also <see cref="Entity.CompileDraw(OpenGlDevice)"/>.
        /// </summary>
        /// <param name="Device">Device in which it willl be compiled.</param>
        /// <param name="Draw">a event, which holds the drawings.</param>
        public static MeshContainer CreateMeshes(OpenGlDevice Device, DrawAction Draw)
        {
            // sollte nur von compilesnapbuffer aufgerufen werden !!!! und erstellt die triangles
            bool Compiling = Entity.Compiling;

            if (Compiling)
            {
                MeshCreator.Push();
            }
            bool SaveCompiling = Entity.Compiling;

            // Entity.Compiling = true; // Checken braucht es wegen line snap
            if (Selector.StoredSnapItems.Count == 0)
            {
                Selector.StoredSnapItems.Add(null); // braucht es nicht
            }
            MeshListCurrent = new MeshContainer();  // braucht es nicht
            MeshIndices.Clear();                    // braucht es wahrscheinlich  nicht


            RenderKind R = Device.RenderKind;// wieder heraus

            Draw(Device);

            Renew();
            Device.RenderKind = R;
            Entity.Compiling  = SaveCompiling;
            MeshContainer Result = MeshListCurrent;

            //    MeshListCurrent.MySnapItem = new MeshSnapItem(MeshListCurrent);
            Device.RenderKind = RenderKind.SnapBuffer;
            TriangleList TL = new TriangleList();

            for (int i = 0; i < MeshListCurrent.Progs.Count; i++)
            {
                if (MeshListCurrent.Progs[i] is Mesh)
                {
                    Mesh M = MeshListCurrent.Progs[i] as Mesh;
                    M.getTriangles(TL);
                }
            }
            TriangleArrays TA = TL.ToArrays();



            Device.RenderKind = R;
            if (Compiling)
            {
                MeshCreator.Pop();
            }
            return(Result);
        }
 public IObjectRender create(RenderKind kind)
 {
     if (RenderKind.NormalRender == kind)
     {
         return(new NormalObjectRender());
     }
     else if (RenderKind.WireFrameRender == kind)
     {
         return(new WireFrameRender());
     }
     else if (RenderKind.BlueRender == kind)
     {
         return(new BlueRender());
     }
     return(new NormalObjectRender());
 }
Example #7
0
        MeshContainer CompileSnapBuffer()
        {
            CreateSnap = true;
            RenderKind Save = Device.RenderKind;

            StoredSnapItems.Clear();
            StoredSnapItems.Add(null);
            RegisterLocked    = false;
            Device.RenderKind = RenderKind.SnapBuffer;
            MeshContainer Result = MeshCreator.CreateMeshes(Device, CompileDraw);

            Device.RenderKind = Save;
            RegisterLocked    = true;
            CreateSnap        = false;
            return(Result);
        }
Example #8
0
        private void Compiledraw(OpenGlDevice Device)
        {
            RenderKind Save = Device.RenderKind;

            Device.RenderKind = RenderKind.Render;
            PushMatrix();
            ModelMatrix = Matrix.identity;
            Loca L = CompileFont.GlyphInfo[CompileChar].Curves;

            if (L.Count == 0) // blank
            {
                PopMatrix();
                return;
            }
            PolygonMode SavePolygonMode = Device.PolygonMode;

            Device.PolygonMode = PolygonMode.Fill;
            bool Cw = L[0].ClockWise;

            if (Cw)
            {
                drawExtruded(L, 1);
                PushMatrix();
                MulMatrix(Matrix.Translation(new xyz(0, 0, 1)));
                drawPolyPolyCurve(L);
                PopMatrix();
                L.Invert();
                drawPolyPolyCurve(L);
            }
            else
            {
                drawPolyPolyCurve(L);
                L.Invert();
                drawExtruded(L, 1);

                PushMatrix();
                MulMatrix(Matrix.Translation(new xyz(0, 0, 1)));
                drawPolyPolyCurve(L);
                PopMatrix();
            }

            PopMatrix();
            Device.RenderKind  = Save;
            Device.PolygonMode = SavePolygonMode;
        }
Example #9
0
        //public void ReorgSnapBuffer()
        //{
        //    if (SnapMesh != null)
        //        for (int i = 0; i < SnapMesh.Progs.Count; i++)
        //        {
        //            Mesh M = SnapMesh.Progs[i] as Mesh;
        //            if (M != null)
        //            {
        //                SnapItem S = M.SnapItem;
        //                M.ObjectNumber = StoredSnapItems.IndexOf(S);
        //            }
        //            SnapBufferDirty = true;
        //        }
        //}
        public void RefreshSnapBuffer()
        {
            if (!Device.SnapEnable)
            {
                return;
            }
            //    if ((SnapKind == Snap.Static) && (SnapMesh == null))
            {
                SnapMesh = CompileSnapBuffer();
            }


            //GL.Disable(EnableCap.Blend);
            //if (PickingShader == null)
            //{
            //    PickingShader = new GLShader(PickingFragmentShader, PickingVertexShader);
            //    PickingShader.CompileAndLink();

            //    OpenGlDevice.CheckError();


            //}

            CurrentObjectIndex = PickingShader.GetVarHandle("TheObject");



            GLShader Save = Device.Shader;

            Device.Shader = PickingShader;
            RenderKind SaveRenderKind = Device.RenderKind;

            Device.RenderKind = RenderKind.SnapBuffer;
            if (!RegisterLocked)
            {
                StoredSnapItems.Clear();
                StoredSnapItems.Add(null);
            }


            SnapBuffer.Init((int)Device.ViewPort.Width, (int)Device.ViewPort.Height);

            SnapBuffer.EnableWriting();

            if (SnapMesh != null)
            {
                Device.Selector.FastRefresh = true;
                System.Diagnostics.Stopwatch SW = new System.Diagnostics.Stopwatch();
                SW.Start();
                SnapMesh.Paint(Device);
                SW.Stop();
                Device.Selector.FastRefresh = false;
            }
            else
            {
                Device.OnPaint();
            }
            SnapBuffer.DisableWriting();

            Device.RenderKind = SaveRenderKind;
            SnapBufferDirty   = false;
            ObjectBuffer      = ReadPickingBuffer(0, 0, (int)Device.ViewPort.Width, (int)Device.ViewPort.Height);
            // GL.Enable(EnableCap.Blend);
            Device.Shader = Save;
            CreateSnapList();
        }