Пример #1
0
        public override void RenderScene()
        {
            Vector3 Scale = new Vector3(30, 30, 30);

            //Scale the plane by aspect ratio
            GL.PushMatrix();

            bool useTextures = false;

            if (ActiveTextureMap != null)
            {
                var tex = ActiveTextureMap.GetTexture();

                //Bind texture if not null
                if (tex != null)
                {
                    //Adjust scale via aspect ratio
                    if (Width > Height)
                    {
                        float aspect = (float)tex.Width / (float)tex.Height;
                        Console.WriteLine($"aspect w {aspect}");
                        Scale.X *= aspect;
                    }
                    else
                    {
                        float aspect = (float)tex.Height / (float)tex.Width;
                        Console.WriteLine($"aspect h {aspect}");
                        Scale.Y *= aspect;
                    }

                    if (tex.RenderableTex == null || !tex.RenderableTex.GLInitialized)
                    {
                        tex.LoadOpenGLTexture();
                    }

                    GL.Enable(EnableCap.Texture2D);
                    GL.BindTexture(TextureTarget.Texture2D, tex.RenderableTex.TexID);
                    GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureWrapS, (float)STGenericMatTexture.wrapmode[ActiveTextureMap.WrapModeS]);
                    GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureWrapT, (float)STGenericMatTexture.wrapmode[ActiveTextureMap.WrapModeT]);
                    //     GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureWrapS, (int)STGenericMatTexture.wrapmode[activeTexture.wrapModeS]);
                    //   GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureWrapT, (int)STGenericMatTexture.wrapmode[activeTexture.wrapModeT]);
                    GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMinFilter, (int)STGenericMatTexture.minfilter[ActiveTextureMap.MinFilter]);
                    GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMagFilter, (int)STGenericMatTexture.magfilter[ActiveTextureMap.MagFilter]);

                    useTextures = true;
                }
            }

            GL.Scale(Scale);

            if (useTextures)
            {
                GL.Enable(EnableCap.Texture2D);
                if (Repeat)
                {
                    DrawPlane(50, Color.FromArgb(128, 128, 128));
                    DrawPlane(1, Color.White);
                }
                else
                {
                    DrawPlane(1, Color.White);
                }
            }
            else
            {
                DrawPlane(1, BackgroundColor.Lighten(40));
            }

            GL.Disable(EnableCap.Texture2D);

            PickableUVMap.DrawUVs(PolygonGroupIndex, UvChannelIndex, ActiveObjects, ActiveTextureMap);
            DrawPlane(1, Color.Black, true);

            GL.PopMatrix();
        }
Пример #2
0
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        /// <summary>
        ///  Method: Show Buffer.
        /// </summary>
        /// <param name="dev">        The dev.</param>
        /// <param name="scanner">    The buffer.</param>
        /// <param name="clientSize"> The client Size.</param>
        /// <param name="rowStart">   The top.</param>
        /// <param name="colStart">   The horizontal Percent.</param>
        /// <param name="zoom">       The zoom.</param>
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        public void ShowBuffer(Graphics dev, IScanner scanner, Size clientSize, int rowStart, int colStart, float zoom, Selection selection)
        {
            if (scanner == null || scanner.LineCount == 0)
            {
                return;
            }

            _scanner = scanner;

            if (Math.Abs(_zoom - zoom) > .05)
            {
                _zoom = zoom;
                CreateFonts(EmSize);
            }
            SelectionBackground = BackgroundColor.Lighten(.4);

            tc.SetBackgroundMode(true);

            var inSelect  = false;
            var chkSelect = selection.Length > 0;

            tc.StartDrawing(dev, BackgroundColor, 4, fonts[0]);

            FontSize   = tc.MeasureText("M");
            FontWidth  = FontSize.Width;
            FontHeight = FontSize.Height;
            var rows     = clientSize.Height / FontHeight;
            var cols     = clientSize.Width / FontWidth;
            var leftSkip = colStart;

            // skip lines above view.
            _scanner.MoveToLine(rowStart);

            LeftMargin.X = DrawLineNumbers(scanner.LineNumber, rows, clientSize.Height);
            startPoint.X = LeftMargin.X - leftSkip * FontWidth;
            startPoint.Y = LeftMargin.Y;

            // restrict drawing to just the text part.
            tc.SelectClipRegion(LeftMargin.X - 1, LeftMargin.Y - 1, clientSize.Width, clientSize.Height);

            // todo fix end check here.
            while (!scanner.AtEnd)
            {
                var pos        = scanner.Position;
                var lineOffset = pos - scanner.StartPositionOfLine;

                // handle selection marking
                if (chkSelect)
                {
                    if (!inSelect)
                    {
                        if (pos >= selection.Start)
                        {
                            //  _selStart = new Point(startPoint.X, startPoint.Y);
                            inSelect     = true;
                            tc.BackColor = SelectionBackground;
                            // set background mode correctly for select box.
                            tc.SetBackgroundMode(false);
                        }
                    }
                    else if (pos >= selection.End)
                    {
                        chkSelect = false;
                        tc.SetBackgroundMode(true);
                    }
                }


                var type = scanner.NextToken();

                // handle special cases of Eol and not visible
                if (type == TokenType.Eol)
                {
                    startPoint.X  = LeftMargin.X - leftSkip * FontWidth;
                    startPoint.Y += FontHeight;
                    if (--rows <= 0)
                    {
                        break;
                    }

                    continue;
                }

                // check if visible, skip if not.
                if ((lineOffset + scanner.Token.Length) < leftSkip || lineOffset > cols)
                {
                    continue;
                }


                switch (type)
                {
                case TokenType.WhiteSpace:
                    if (inSelect)
                    {
                        goto default;
                    }

                    startPoint.X += scanner.Token.Length * FontWidth;
                    continue;

                case TokenType.End:     // EOD
                    break;

                //case TokenType.Eol:
                //    startPoint.X = LeftMargin.X;
                //    startPoint.Y += FontHeight;
                //    //int width = lineOffset;
                //    //if (width > RowColSize.Width) RowColSize.Width = width;
                //    --Rows;
                //    continue;


                default:
                    var foreColor = SetFont(type);
                    Draw(foreColor);
                    startPoint.X += FontSize.Width;
                    continue;
                }

                //Rectangle rect = new Rectangle(startPoint, size);
            }
            tc.EndDrawing(dev);

            RowColSize = new Size(_scanner.MaxLineLength, _scanner.LineCount);
        }
Пример #3
0
 public void HighlightCell()
 {
     lblSymbol.BackgroundColor = BackgroundColor.Lighten(2);
 }