Example #1
2
        public override void Apply(Graphics graphics, Bitmap applyBitmap, Rectangle rect, RenderMode renderMode)
        {
            Rectangle applyRect = ImageHelper.CreateIntersectRectangle(applyBitmap.Size, rect, Invert);

            if (applyRect.Width == 0 || applyRect.Height == 0)
            {
                // nothing to do
                return;
            }
            GraphicsState state = graphics.Save();
            if (Invert)
            {
                graphics.SetClip(applyRect);
                graphics.ExcludeClip(rect);
            }
            ColorMatrix grayscaleMatrix = new ColorMatrix(new[] {
                new[] {.3f, .3f, .3f, 0, 0},
                new[] {.59f, .59f, .59f, 0, 0},
                new[] {.11f, .11f, .11f, 0, 0},
                new float[] {0, 0, 0, 1, 0},
                new float[] {0, 0, 0, 0, 1}
            });
            using (ImageAttributes ia = new ImageAttributes())
            {
                ia.SetColorMatrix(grayscaleMatrix);
                graphics.DrawImage(applyBitmap, applyRect, applyRect.X, applyRect.Y, applyRect.Width, applyRect.Height, GraphicsUnit.Pixel, ia);
            }
            graphics.Restore(state);
        }
Example #2
0
 public unsafe override void Apply(Graphics graphics, Bitmap applyBitmap, Rectangle rect, RenderMode renderMode)
 {
     int blurRadius = GetFieldValueAsInt(FieldType.BLUR_RADIUS);
     double previewQuality = GetFieldValueAsDouble(FieldType.PREVIEW_QUALITY);
     Rectangle applyRect = ImageHelper.CreateIntersectRectangle(applyBitmap.Size, rect, Invert);
     if (applyRect.Width == 0 || applyRect.Height == 0)
     {
         return;
     }
     GraphicsState state = graphics.Save();
     if (Invert)
     {
         graphics.SetClip(applyRect);
         graphics.ExcludeClip(rect);
     }
     if (GDIplus.IsBlurPossible(blurRadius))
     {
         GDIplus.DrawWithBlur(graphics, applyBitmap, applyRect, null, null, blurRadius, false);
     }
     else
     {
         using (IFastBitmap fastBitmap = FastBitmap.CreateCloneOf(applyBitmap, applyRect))
         {
             ImageHelper.ApplyBoxBlur(fastBitmap, blurRadius);
             fastBitmap.DrawTo(graphics, applyRect);
         }
     }
     graphics.Restore(state);
     return;
 }
Example #3
0
		public override void Draw(Graphics graphics, RenderMode rm) {
			int lineThickness = GetFieldValueAsInt(FieldType.LINE_THICKNESS);
			Color lineColor = GetFieldValueAsColor(FieldType.LINE_COLOR);
			bool shadow = GetFieldValueAsBool(FieldType.SHADOW);
			bool lineVisible = (lineThickness > 0 && Colors.IsVisible(lineColor));
			if (lineVisible) {
				graphics.SmoothingMode = SmoothingMode.HighSpeed;
				graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;
				graphics.CompositingQuality = CompositingQuality.HighQuality;
				graphics.PixelOffsetMode = PixelOffsetMode.None;
				//draw shadow first
				if (shadow) {
					int basealpha = 100;
					int alpha = basealpha;
					int steps = 5;
					int currentStep = lineVisible ? 1 : 0;
					while (currentStep <= steps) {
						using (Pen shadowPen = new Pen(Color.FromArgb(alpha, 100, 100, 100), lineThickness)) {
							Rectangle shadowRect = GuiRectangle.GetGuiRectangle(Left + currentStep, Top + currentStep, Width, Height);
							graphics.DrawRectangle(shadowPen, shadowRect);
							currentStep++;
							alpha = alpha - (basealpha / steps);
						}
					}
				}
				Rectangle rect = GuiRectangle.GetGuiRectangle(Left, Top, Width, Height);
				if (lineThickness > 0) {
					using (Pen pen = new Pen(lineColor, lineThickness)) {
						graphics.DrawRectangle(pen, rect);
					}
				}
			}
		}
Example #4
0
		/// <summary>
		/// Implements the Apply code for the Brightness Filet
		/// </summary>
		/// <param name="graphics"></param>
		/// <param name="applyBitmap"></param>
		/// <param name="rect"></param>
		/// <param name="renderMode"></param>
		public override void Apply(Graphics graphics, Bitmap applyBitmap, Rectangle rect, RenderMode renderMode) {
			Rectangle applyRect = ImageHelper.CreateIntersectRectangle(applyBitmap.Size, rect, Invert);

			if (applyRect.Width == 0 || applyRect.Height == 0) {
				// nothing to do
				return;
			}
			GraphicsState state = graphics.Save();
			if (Invert) {
				graphics.SetClip(applyRect);
				graphics.ExcludeClip(rect);
			}
			using (IFastBitmap fastBitmap = FastBitmap.CreateCloneOf(applyBitmap, applyRect)) {
				Color highlightColor = GetFieldValueAsColor(FieldType.FILL_COLOR);
				for (int y = fastBitmap.Top; y < fastBitmap.Bottom; y++) {
					for (int x = fastBitmap.Left; x < fastBitmap.Right; x++) {
						Color color = fastBitmap.GetColorAt(x, y);
						color = Color.FromArgb(color.A, Math.Min(highlightColor.R, color.R), Math.Min(highlightColor.G, color.G), Math.Min(highlightColor.B, color.B));
						fastBitmap.SetColorAt(x, y, color);
					}
				}
				fastBitmap.DrawTo(graphics, applyRect.Location);
			}
			graphics.Restore(state);
		}
Example #5
0
        void IRenderable.Render(OpenGL gl, RenderMode renderMode)
        {
            if (positionBuffer != null && colorBuffer != null && radiusBuffer != null)
            {
                if (this.shaderProgram == null)
                {
                    this.shaderProgram = InitShader(gl, renderMode);
                }
                if (this.vertexArrayObject == null)
                {
                    CreateVertexArrayObject(gl, renderMode);
                }

                BeforeRendering(gl, renderMode);

                if (this.RenderGrid && this.vertexArrayObject != null)
                {
                    gl.Enable(OpenGL.GL_BLEND);
                    gl.BlendFunc(SharpGL.Enumerations.BlendingSourceFactor.SourceAlpha, SharpGL.Enumerations.BlendingDestinationFactor.OneMinusSourceAlpha);

                    gl.BindVertexArray(this.vertexArrayObject[0]);
                    gl.DrawArrays(OpenGL.GL_POINTS, 0, count);
                    gl.BindVertexArray(0);

                    gl.Disable(OpenGL.GL_BLEND);
                }

                AfterRendering(gl, renderMode);
            }
        }
 public void Init(RenderMode renderMode)
 {
     if (renderMode == RenderMode.Render2D)
     {
         GL.MatrixMode(MatrixMode.Projection);
         var aspectRatio = (float)form.ClientSize.Width / form.ClientSize.Height;
         GL.LoadIdentity();
         GL.Scale(1, aspectRatio, 1);
         GL.MatrixMode(MatrixMode.Modelview);
     }
     else
     {
         GL.Enable(EnableCap.DepthTest);
         GL.ShadeModel(ShadingModel.Smooth);
         GL.Enable(EnableCap.Lighting);
         GL.Light(LightName.Light0, LightParameter.Ambient, new[] { .2f, .2f, .2f, 1.0f });
         GL.Light(LightName.Light0, LightParameter.Diffuse, new[] { 1, 1, 1, 1.0f });
         GL.Light(LightName.Light0, LightParameter.Position,
             new[] { Common.LightPosition.x, Common.LightPosition.y, Common.LightPosition.z });
         GL.Enable(EnableCap.Light0);
         GL.MatrixMode(MatrixMode.Projection);
         Common.ProjectionMatrix = Matrix4.CreatePerspectiveFieldOfView(Common.FieldOfView,
             form.ClientSize.Width / (float)form.ClientSize.Height, Common.NearPlane, Common.FarPlane);
         GL.LoadMatrix(ref Common.ProjectionMatrix);
         GL.MatrixMode(MatrixMode.Modelview);
         Common.ViewMatrix = Matrix4.LookAt(Common.CameraPosition.x, Common.CameraPosition.y,
             Common.CameraPosition.z, 0, 0, 4, 0, 0, 1);
         GL.LoadMatrix(ref Common.ViewMatrix);
     }
 }
        public override void Apply(Graphics graphics, Bitmap applyBitmap, Rectangle rect, RenderMode renderMode)
        {
            Rectangle applyRect = ImageHelper.CreateIntersectRectangle(applyBitmap.Size, rect, Invert);

            if (applyRect.Width == 0 || applyRect.Height == 0)
            {
                // nothing to do
                return;
            }
            int magnificationFactor = GetFieldValueAsInt(FieldType.MAGNIFICATION_FACTOR);
            GraphicsState state = graphics.Save();
            if (Invert)
            {
                graphics.SetClip(applyRect);
                graphics.ExcludeClip(rect);
            }
            graphics.SmoothingMode = SmoothingMode.None;
            graphics.InterpolationMode = InterpolationMode.NearestNeighbor;
            graphics.CompositingQuality = CompositingQuality.HighQuality;
            graphics.PixelOffsetMode = PixelOffsetMode.None;
            int halfWidth = rect.Width / 2;
            int halfHeight = rect.Height / 2;
            int newWidth = rect.Width / magnificationFactor;
            int newHeight = rect.Height / magnificationFactor;
            Rectangle source = new Rectangle(rect.X + halfWidth - (newWidth / 2), rect.Y + halfHeight - (newHeight / 2), newWidth, newHeight);
            graphics.DrawImage(applyBitmap, rect, source, GraphicsUnit.Pixel);
            graphics.Restore(state);
        }
Example #8
0
        /// <summary>
        /// Render to the provided instance of OpenGL.
        /// </summary>
        /// <param name="gl">The OpenGL instance.</param>
        /// <param name="renderMode">The render mode.</param>
        public override void Render(OpenGL gl, RenderMode renderMode)
        {
            //	Create the evaluator.
            gl.Map1(OpenGL.GL_MAP1_VERTEX_3,//	Use and produce 3D points.
                0,								//	Low order value of 'u'.
                1,								//	High order value of 'u'.
                3,								//	Size (bytes) of a control point.
                ControlPoints.Width,			//	Order (i.e degree plus one).
                ControlPoints.ToFloatArray());	//	The control points.

            //	Enable the type of evaluator we wish to use.
            gl.Enable(OpenGL.GL_MAP1_VERTEX_3);

            //	Beging drawing a line strip.
            gl.Begin(OpenGL.GL_LINE_STRIP);

            //	Now draw it.
            for (int i = 0; i <= segments; i++)
                gl.EvalCoord1((float)i / segments);

            gl.End();

            //	Draw the control points.
            ControlPoints.Draw(gl, DrawControlPoints, DrawControlGrid);
        }
Example #9
0
      public Tile(Image image, TileCoordinate tile, RenderMode mode)
      {
         this.tile = tile;
         if(image != null)
         {
            this.mode = mode;

            switch(mode)
            {
               case RenderMode.GDI:
               {
                  using(Bitmap bitmap = new Bitmap(image))
                  {
                     this.ptrHbitmap = bitmap.GetHbitmap();
                  }
               }
               break;

               case RenderMode.GDI_PLUS:
               {
                  this.image = image;
               }
               break;
            }
         }
      }
Example #10
0
		public static Canvas GetCanvas(RenderMode renderMode) {
			Canvas canvas = null;

			Canvas[] sceneCanvases = GameObject.FindObjectsOfType<Canvas>();
			for (int i = 0; i < sceneCanvases.Length; i++) {
				if (sceneCanvases[i].renderMode == renderMode) {
					canvas = sceneCanvases[i];
					break;
				}
			}

			if (canvas == null) {
				GameObject canvasGO = new GameObject("Canvas");
				canvasGO.layer = LayerMask.NameToLayer("UI");
				canvasGO.AddComponent<GraphicRaycaster>();
				canvas = canvasGO.GetComponent<Canvas>();
				canvas.renderMode = renderMode;

				if (GameObject.FindObjectOfType<EventSystem>() == null) {
					GameObject eventSystemGO = new GameObject("EventSystem");
					eventSystemGO.AddComponent<EventSystem>();
#if !UNITY_EDITOR && (UNITY_ANDROID || UNITY_IPHONE)
					eventSystemGO.AddComponent<TouchInputModule>();
#else
					eventSystemGO.AddComponent<StandaloneInputModule>();
#endif
				}
			}

			return canvas;
		}
Example #11
0
        private static void Generate(string xamlFile, string outputFile, RenderMode renderMode, string desiredNamespace, string defaultAssembly)
        {
            string xaml = string.Empty;
            using (TextReader tr = File.OpenText(xamlFile))
            {
                xaml = tr.ReadToEnd();
            }

            if (!string.IsNullOrEmpty(defaultAssembly))
                xaml = Regex.Replace(xaml,
                    @"xmlns(:\w+)?=\""clr-namespace:([.\w]+)(;assembly=)?\""",
                    $@"xmlns$1=""clr-namespace:$2;assembly=" + defaultAssembly + '"');

            UserInterfaceGenerator generator = new UserInterfaceGenerator();
            string generatedCode = string.Empty;
            try
            {
                generatedCode = generator.GenerateCode(xamlFile, xaml, renderMode, desiredNamespace);
            }
            catch (Exception ex)
            {
                generatedCode = "#error " + ex.Message;
                throw;
            }
            finally
            {
                using (StreamWriter outfile = new StreamWriter(outputFile))
                {
                    outfile.Write(generatedCode);
                }
            }
            }
Example #12
0
 public ActivityButton()
 {
     this.Image = new Uri("pack://application:,,,/Images/activity.PNG");
     this.Text = "Default";
     this.RenderMode = RenderMode.ImageAndText;
     this.VerticalAlignment = System.Windows.VerticalAlignment.Center;
 }
Example #13
0
		/// <summary>
		/// This allows another container to draw an ellipse
		/// </summary>
		/// <param name="caller"></param>
		/// <param name="graphics"></param>
		/// <param name="renderMode"></param>
		public static void DrawEllipse(Rectangle rect, Graphics graphics, RenderMode renderMode, int lineThickness, Color lineColor, Color fillColor, bool shadow) {

			bool lineVisible = (lineThickness > 0 && Colors.IsVisible(lineColor));
			// draw shadow before anything else
			if (shadow && (lineVisible || Colors.IsVisible(fillColor))) {
				int basealpha = 100;
				int alpha = basealpha;
				int steps = 5;
				int currentStep = lineVisible ? 1 : 0;
				while (currentStep <= steps) {
					using (Pen shadowPen = new Pen(Color.FromArgb(alpha, 100, 100, 100))) {
						shadowPen.Width = lineVisible ? lineThickness : 1;
						Rectangle shadowRect = GuiRectangle.GetGuiRectangle(rect.Left + currentStep, rect.Top + currentStep, rect.Width, rect.Height);
						graphics.DrawEllipse(shadowPen, shadowRect);
						currentStep++;
						alpha = alpha - basealpha / steps;
					}
				}
			}
			//draw the original shape
			if (Colors.IsVisible(fillColor)) {
				using (Brush brush = new SolidBrush(fillColor)) {
					graphics.FillEllipse(brush, rect);
				}
			}
			if (lineVisible) {
				using (Pen pen = new Pen(lineColor, lineThickness)) {
					graphics.DrawEllipse(pen, rect);
				}
			}
		}
Example #14
0
 public ActivityButton(Uri img, string text)
 {
     this.Image = img;
     this.Text = text;
     this.RenderMode = RenderMode.ImageAndText;
     this.VerticalAlignment = System.Windows.VerticalAlignment.Center;
 }
 public override void Draw(Graphics g, RenderMode rm)
 {
     Rectangle rect = GuiRectangle.GetGuiRectangle(this.Left, this.Top, this.Width, this.Height);
     g.FillRectangle(GetBrush(rect), rect);
     Pen pen = new Pen(foreColor) { Width = thickness };
     g.DrawRectangle(pen, rect);
 }
 public override void Draw(Graphics g, RenderMode rm)
 {
     g.TextRenderingHint = TextRenderingHint.AntiAliasGridFit;
     Rectangle rect = GuiRectangle.GetGuiRectangle(this.Left, this.Top, this.Width, this.Height);
     if (Selected && rm.Equals(RenderMode.EDIT)) DrawSelectionBorder(g, rect);
     Brush fontBrush = new SolidBrush(foreColor);
     g.DrawString(childLabel.Text, childLabel.Font, fontBrush, rect);
 }
 public override void Draw(Graphics g, RenderMode rm)
 {
     g.SmoothingMode = SmoothingMode.HighQuality;
     Rectangle rect = GuiRectangle.GetGuiRectangle(this.Left, this.Top, this.Width, this.Height);
     g.FillEllipse(GetBrush(rect), rect);
     Pen pen = new Pen(foreColor) { Width = thickness };
     g.DrawEllipse(pen, rect);
 }
Example #18
0
        /// <summary>
        /// Render to the provided instance of OpenGL.
        /// </summary>
        /// <param name="gl">The OpenGL instance.</param>
        /// <param name="renderMode">The render mode.</param>
        public override void Render(OpenGL gl, RenderMode renderMode)
        {
            //  Call the base.
            base.Render(gl, renderMode);

            //	Draw a quadric with the current settings.
            gl.Cylinder(glQuadric, baseRadius, topRadius, height, slices, stacks);
        }
Example #19
0
 /// <summary>
 /// Render to the provided instance of OpenGL.
 /// </summary>
 /// <param name="gl">The OpenGL instance.</param>
 /// <param name="renderMode">The render mode.</param>
 public virtual void Render(OpenGL gl, RenderMode renderMode)
 {
     //	Set the quadric properties.
     gl.QuadricDrawStyle(glQuadric, (uint)drawStyle);
     gl.QuadricOrientation(glQuadric, (int)orientation);
     gl.QuadricNormals(glQuadric, (uint)normals);
     gl.QuadricTexture(glQuadric, textureCoords ? 1 : 0);
 }
Example #20
0
        /// <summary>
        /// Render to the provided instance of OpenGL.
        /// </summary>
        /// <param name="gl">The OpenGL instance.</param>
        /// <param name="renderMode">The render mode.</param>
        public override void Render(OpenGL gl, RenderMode renderMode)
        {
            //  Call the base.
            base.Render(gl, renderMode);

            //	Draw a sphere with the current settings.
            gl.Sphere(glQuadric, radius, slices, stacks);
        }
Example #21
0
		public override void Draw(Graphics graphics, RenderMode rm) {
			if (icon != null) {
				graphics.SmoothingMode = SmoothingMode.HighQuality;
				graphics.InterpolationMode = InterpolationMode.NearestNeighbor;
				graphics.CompositingQuality = CompositingQuality.Default;
				graphics.PixelOffsetMode = PixelOffsetMode.HighQuality;
				graphics.DrawIcon(icon, Bounds);
			}
		}
Example #22
0
		public override void Reset()
		{
			cursorTexture = null;
			hotSpot = new FsmVector2 { UseVariable = true };

			renderMode = RenderMode.Auto;
			lockMode = CurState.None;
			hideCursor = true;
		}
Example #23
0
        /// <summary>
        /// Render to the provided instance of OpenGL.
        /// </summary>
        /// <param name="gl">The OpenGL instance.</param>
        /// <param name="renderMode">The render mode.</param>
        public override void Render(OpenGL gl, RenderMode renderMode)
        {
            //  Call the base.
            base.Render(gl, renderMode);

            //	Draw a quadric with the current settings.
            gl.PartialDisk(glQuadric, innerRadius, outerRadius,
                slices, loops, startAngle, sweepAngle);
        }
Example #24
0
		public override void Draw(Graphics graphics, RenderMode rm) {
			int lineThickness = GetFieldValueAsInt(FieldType.LINE_THICKNESS);
			Color lineColor = GetFieldValueAsColor(FieldType.LINE_COLOR);
			Color fillColor = GetFieldValueAsColor(FieldType.FILL_COLOR);
			bool shadow = GetFieldValueAsBool(FieldType.SHADOW);
			Rectangle rect = GuiRectangle.GetGuiRectangle(Left, Top, Width, Height);

			DrawRectangle(rect, graphics, rm, lineThickness, lineColor, fillColor, shadow);
		}
Example #25
0
		public override void Draw(Graphics graphics, RenderMode rm) {
			if (cursor == null) {
				return;
			}
			graphics.SmoothingMode = SmoothingMode.HighQuality;
			graphics.InterpolationMode = InterpolationMode.NearestNeighbor;
			graphics.CompositingQuality = CompositingQuality.Default;
			graphics.PixelOffsetMode = PixelOffsetMode.None;
			cursor.DrawStretched(graphics, Bounds);
		}
 /// <summary>
 /// Initializes a new instance of the <see cref="PdfContentWriter"/> class
 /// for creating a content stream of the specified form.
 /// </summary>
 public PdfContentWriter(DocumentRenderingContext context, XForm form, RenderMode renderMode) // , XGraphics gfx, XGraphicsPdfPageOptions options)
 {
   this.context = context;
   this.form = form;
   this.contentStreamDictionary = form;
   this.renderMode = renderMode;
   //this.colorMode = page.document.Options.ColorMode;
   //this.options = options;
   this.content = new StringBuilder();
   this.graphicsState = new PdfGraphicsState(this);
 }
Example #27
0
 public void m000236(RenderMode p0)
 {
     RenderState renderState = c000074.GetGraphicsDevice().RenderState;
     SamplerState state2 = c000074.GetGraphicsDevice().SamplerStates[0];
     renderState.CullMode = CullMode.CullCounterClockwiseFace;
     renderState.DepthBufferFunction = CompareFunction.Less;
     renderState.DepthBufferEnable = true;
     renderState.DepthBufferWriteEnable = true;
     state2.AddressU = TextureAddressMode.Wrap;
     state2.AddressV = TextureAddressMode.Wrap;
 }
 public unsafe override void Apply(Graphics graphics, Bitmap applyBitmap, Rectangle rect, RenderMode renderMode)
 {
     int blurRadius = GetFieldValueAsInt(FieldType.BLUR_RADIUS);
     double previewQuality = GetFieldValueAsDouble(FieldType.PREVIEW_QUALITY);
     Rectangle applyRect = ImageHelper.CreateIntersectRectangle(applyBitmap.Size, rect, Invert);
     using (Bitmap blurImage = ImageHelper.CreateBlur(applyBitmap, applyRect, renderMode == RenderMode.EXPORT, blurRadius, previewQuality, Invert, parent.Bounds)) {
         if (blurImage != null) {
             graphics.DrawImageUnscaled(blurImage, applyRect.Location);
         }
     }
     return;
 }
Example #29
0
    public static Canvas CreateNewCanvas(string name, RenderMode renderMode = RenderMode.ScreenSpaceOverlay)
    {
        Canvas canvas = new GameObject(name).AddComponent<Canvas>();

        canvas.gameObject.AddComponent<CanvasScaler>().uiScaleMode = CanvasScaler.ScaleMode.ScaleWithScreenSize;
        canvas.gameObject.GetComponent<CanvasScaler>().referenceResolution = new Vector2(1920, 1080);
        canvas.renderMode = renderMode;
        canvas.worldCamera = Camera.main;
        canvas.planeDistance = 5;

        return canvas;
    }
Example #30
0
        private static bool RenderStatesDiffer(RenderState oldRenderState, RenderState newRenderState, RenderMode flag)
        {
            bool oldRenderStateNull = (oldRenderState == null);
            bool newFlag = ((newRenderState.RenderMode & flag) != 0);

            if (oldRenderStateNull)
                return true;

            bool oldFlag = ((oldRenderState.RenderMode & flag) != 0);

            return oldFlag != newFlag;
        }
Example #31
0
        protected void BeforeRendering(OpenGL gl, RenderMode renderMode)
        {
            IScientificCamera camera = this.camera;

            if (camera != null)
            {
                if (camera.CameraType == CameraTypes.Perspecitive)
                {
                    IPerspectiveViewCamera perspective = camera;
                    this.projectionMatrix = perspective.GetProjectionMat4();
                    this.viewMatrix       = perspective.GetViewMat4();
                }
                else if (camera.CameraType == CameraTypes.Ortho)
                {
                    IOrthoViewCamera ortho = camera;
                    this.projectionMatrix = ortho.GetProjectionMat4();
                    this.viewMatrix       = ortho.GetViewMat4();
                }
                else
                {
                    throw new NotImplementedException();
                }
            }

            modelMatrix = mat4.identity();
            ShaderProgram shaderProgram = this.shaderProgram;

            //  Bind the shader, set the matrices.
            shaderProgram.Bind(gl);
            shaderProgram.SetUniformMatrix4(gl, "projectionMatrix", projectionMatrix.to_array());
            shaderProgram.SetUniformMatrix4(gl, "viewMatrix", viewMatrix.to_array());
            shaderProgram.SetUniformMatrix4(gl, "modelMatrix", modelMatrix.to_array());

            //gl.Enable(OpenGL.GL_POLYGON_SMOOTH);
            //gl.Hint(OpenGL.GL_POLYGON_SMOOTH_HINT, OpenGL.GL_NICEST);

            this.texture.Bind(gl);
            shaderProgram.SetUniform1(gl, "tex", this.texture.TextureName);
            shaderProgram.SetUniform1(gl, "brightness", this.Brightness);
        }
        public override void Draw(Graphics g, RenderMode rm)
        {
            int   lineThickness = GetFieldValueAsInt(FieldType.LINE_THICKNESS);
            Color lineColor     = GetFieldValueAsColor(FieldType.LINE_COLOR);
            bool  shadow        = GetFieldValueAsBool(FieldType.SHADOW);
            bool  lineVisible   = (lineThickness > 0 && Colors.IsVisible(lineColor));

            if (shadow && lineVisible)
            {
                //draw shadow first
                int basealpha   = 100;
                int alpha       = basealpha;
                int steps       = 5;
                int currentStep = lineVisible ? 1 : 0;
                while (currentStep <= steps)
                {
                    using (Pen shadowPen = new Pen(Color.FromArgb(alpha, 100, 100, 100))) {
                        shadowPen.Width = lineVisible ? lineThickness : 1;
                        Rectangle shadowRect = GuiRectangle.GetGuiRectangle(
                            this.Left + currentStep,
                            this.Top + currentStep,
                            this.Width,
                            this.Height);
                        g.DrawRectangle(shadowPen, shadowRect);
                        currentStep++;
                        alpha = alpha - (basealpha / steps);
                    }
                }
            }

            Rectangle rect = GuiRectangle.GetGuiRectangle(this.Left, this.Top, this.Width, this.Height);

            using (Pen pen = new Pen(lineColor)) {
                pen.Width = lineThickness;
                if (pen.Width > 0)
                {
                    g.DrawRectangle(pen, rect);
                }
            }
        }
Example #33
0
        private uint _showTrisCount;                         //测试数据,记录当前显示的三角形数

        public SoftRendererDemo()
        {
            //VectorMatrixTestCase.Test();
            InitializeComponent();
            try
            {
                System.Drawing.Image img = System.Drawing.Image.FromFile("../../Texture/texture.jpg");
                _texture = new Bitmap(img, 256, 256);
            }
            catch (Exception)
            {
                _texture = new Bitmap(256, 256);
                initTexture();
            }
            //
            _currentMode       = RenderMode.Textured;
            _lightMode         = LightMode.On;
            _textureFilterMode = TextureFilterMode.Bilinear;
            //
            _frameBuff    = new Bitmap(this.MaximumSize.Width, this.MaximumSize.Height);
            _frameG       = Graphics.FromImage(_frameBuff);
            _zBuff        = new float[this.MaximumSize.Height, this.MaximumSize.Width];
            _ambientColor = new RenderData.Color(1f, 1f, 1f);

            _mesh = new Mesh(CubeTestData.pointList, CubeTestData.indexs, CubeTestData.uvs, CubeTestData.vertColors, CubeTestData.norlmas, QuadTestData.mat);
            //_mesh = new Mesh(QuadTestData.pointList, QuadTestData.indexs, QuadTestData.uvs, QuadTestData.vertColors, QuadTestData.norlmas, QuadTestData.mat); //打开注释可以切换mesh

            //定义光照
            _light = new Light(new Vector3D(50, 0, 0), new RenderData.Color(1, 1, 1));
            //定义相机
            _camera = new Camera(new Vector3D(0, 0, 0, 1), new Vector3D(0, 0, 1, 1), new Vector3D(0, 1, 0, 0), (float)System.Math.PI / 4, this.MaximumSize.Width / (float)this.MaximumSize.Height, 1f, 500f);

            System.Timers.Timer mainTimer = new System.Timers.Timer(1000 / 60f);

            mainTimer.Elapsed  += new ElapsedEventHandler(Tick);
            mainTimer.AutoReset = true;
            mainTimer.Enabled   = true;
            mainTimer.Start();
            //
        }
        public override void Draw(Graphics graphics, RenderMode rm)
        {
            graphics.SmoothingMode      = SmoothingMode.HighQuality;
            graphics.InterpolationMode  = InterpolationMode.HighQualityBilinear;
            graphics.CompositingQuality = CompositingQuality.HighQuality;
            graphics.PixelOffsetMode    = PixelOffsetMode.None;

            int   lineThickness = GetFieldValueAsInt(FieldType.LINE_THICKNESS);
            Color lineColor     = GetFieldValueAsColor(FieldType.LINE_COLOR);
            bool  shadow        = GetFieldValueAsBool(FieldType.SHADOW);

            if (lineThickness > 0)
            {
                if (shadow)
                {
                    //draw shadow first
                    int basealpha   = 100;
                    int alpha       = basealpha;
                    int steps       = 5;
                    int currentStep = 1;
                    while (currentStep <= steps)
                    {
                        using (Pen shadowCapPen = new Pen(Color.FromArgb(alpha, 100, 100, 100), lineThickness)) {
                            graphics.DrawLine(shadowCapPen,
                                              Left + currentStep,
                                              Top + currentStep,
                                              Left + currentStep + Width,
                                              Top + currentStep + Height);

                            currentStep++;
                            alpha = alpha - (basealpha / steps);
                        }
                    }
                }

                using (Pen pen = new Pen(lineColor, lineThickness)) {
                    graphics.DrawLine(pen, Left, Top, Left + Width, Top + Height);
                }
            }
        }
Example #35
0
        /// <summary>
        /// This allows another container to draw an ellipse
        /// </summary>
        /// <param name="caller"></param>
        /// <param name="graphics"></param>
        /// <param name="renderMode"></param>
        public static void DrawEllipse(Rectangle rect, Graphics graphics, RenderMode renderMode, int lineThickness, Color lineColor, Color fillColor, bool shadow)
        {
            bool lineVisible = (lineThickness > 0 && Colors.IsVisible(lineColor));

            // draw shadow before anything else
            if (shadow && (lineVisible || Colors.IsVisible(fillColor)))
            {
                int basealpha   = 100;
                int alpha       = basealpha;
                int steps       = 5;
                int currentStep = lineVisible ? 1 : 0;
                while (currentStep <= steps)
                {
                    using (Pen shadowPen = new Pen(Color.FromArgb(alpha, 100, 100, 100)))
                    {
                        shadowPen.Width = lineVisible ? lineThickness : 1;
                        Rectangle shadowRect = GuiRectangle.GetGuiRectangle(rect.Left + currentStep, rect.Top + currentStep, rect.Width, rect.Height);
                        graphics.DrawEllipse(shadowPen, shadowRect);
                        currentStep++;
                        alpha = alpha - basealpha / steps;
                    }
                }
            }
            //draw the original shape
            if (Colors.IsVisible(fillColor))
            {
                using (Brush brush = new SolidBrush(fillColor))
                {
                    graphics.FillEllipse(brush, rect);
                }
            }
            if (lineVisible)
            {
                using (Pen pen = new Pen(lineColor, lineThickness))
                {
                    graphics.DrawEllipse(pen, rect);
                }
            }
        }
        public override void OnInspectorGUI()
        {
            VolumeRenderedObject volrendObj = (VolumeRenderedObject)target;

            RenderMode oldRenderMode = volrendObj.GetRenderMode();
            RenderMode newRenderMode = (RenderMode)EditorGUILayout.EnumPopup("Render mode", oldRenderMode);

            if (newRenderMode == RenderMode.IsosurfaceRendering)
            {
                Material mat    = volrendObj.GetComponent <MeshRenderer>().sharedMaterial; // TODO
                float    minVal = mat.GetFloat("_MinVal");
                float    maxVal = mat.GetFloat("_MaxVal");
                EditorGUILayout.MinMaxSlider("Visible value range", ref minVal, ref maxVal, 0.0f, 1.0f);
                mat.SetFloat("_MinVal", minVal);
                mat.SetFloat("_MaxVal", maxVal);
            }

            if (newRenderMode != oldRenderMode)
            {
                volrendObj.SetRenderMode(newRenderMode);
            }
        }
Example #37
0
 public WrapperStructPose(PoseMode poseMode,
                          Point <int> netInputSize,
                          Point <int> outputSize,
                          ScaleMode keyPointScale,
                          int gpuNumber,
                          int gpuNumberStart,
                          int scalesNumber,
                          float scaleGap,
                          RenderMode renderMode,
                          PoseModel poseModel,
                          bool blendOriginalFrame,
                          float alphaKeyPoint,
                          float alphaHeatMap,
                          int defaultPartToRender,
                          string modelFolder,
                          IEnumerable <HeatMapType> heatMapTypes,
                          ScaleMode heatMapScale,
                          bool addPartCandidates) :
     this(poseMode,
          netInputSize,
          outputSize,
          keyPointScale,
          gpuNumber,
          gpuNumberStart,
          scalesNumber,
          scaleGap,
          renderMode,
          poseModel,
          blendOriginalFrame,
          alphaKeyPoint,
          alphaHeatMap,
          defaultPartToRender,
          modelFolder,
          heatMapTypes,
          heatMapScale,
          addPartCandidates,
          0.05f)
 {
 }
Example #38
0
            protected override void OnRenderNext(RegExpr defaultTokenWs, RegExpr parent,
                                                 StringBuilder pattern, ref RenderMode mode)
            {
                base.OnRenderNext(defaultTokenWs, parent, pattern, ref mode);
                var tokenWs = GetTokenWhitespace(defaultTokenWs);

                if (NeedsWhitespaceGroup(tokenWs, mode))
                {
                    pattern.Append(")");
                }
                if (Expr != null)
                {
                    if (!mode.HasFlag(RenderMode.Assert) && !string.IsNullOrEmpty(Id))
                    {
                        pattern.AppendFormat("(?<{0}>", CaptureId);
                    }
                    else
                    {
                        pattern.Append("(?:");
                    }
                }
            }
Example #39
0
        /// <summary>
        ///     This allows another container to draw an ellipse
        /// </summary>
        /// <param name="rect"></param>
        /// <param name="graphics"></param>
        /// <param name="renderMode"></param>
        /// <param name="lineThickness"></param>
        /// <param name="lineColor"></param>
        /// <param name="fillColor"></param>
        /// <param name="shadow"></param>
        public static void DrawEllipse(NativeRect rect, Graphics graphics, RenderMode renderMode, int lineThickness, Color lineColor, Color fillColor, bool shadow)
        {
            var lineVisible = lineThickness > 0 && Colors.IsVisible(lineColor);

            // draw shadow before anything else
            if (shadow && (lineVisible || Colors.IsVisible(fillColor)))
            {
                var basealpha   = 100;
                var alpha       = basealpha;
                var steps       = 5;
                var currentStep = lineVisible ? 1 : 0;
                while (currentStep <= steps)
                {
                    using (var shadowPen = new Pen(Color.FromArgb(alpha, 100, 100, 100)))
                    {
                        shadowPen.Width = lineVisible ? lineThickness : 1;
                        var shadowRect = new NativeRect(rect.Left + currentStep, rect.Top + currentStep, rect.Width, rect.Height).Normalize();
                        graphics.DrawEllipse(shadowPen, shadowRect);
                        currentStep++;
                        alpha = alpha - basealpha / steps;
                    }
                }
            }
            //draw the original shape
            if (Colors.IsVisible(fillColor))
            {
                using (Brush brush = new SolidBrush(fillColor))
                {
                    graphics.FillEllipse(brush, rect);
                }
            }
            if (lineVisible)
            {
                using (var pen = new Pen(lineColor, lineThickness))
                {
                    graphics.DrawEllipse(pen, rect);
                }
            }
        }
Example #40
0
        public Canvas GetCanvasByMode(RenderMode mode, bool createIsNot = true)
        {
            Canvas c = mCanvas[(int)mode];

            if (c == null && createIsNot)
            {
                GameObject obj = new GameObject();
                c = obj.AddComponent <Canvas>();
                c.sortingOrder = MaxSortOrder + 1;
                obj.name       = "Canvas_s" + mode.ToString();
                obj.AddComponent <CanvasScaler>();
                obj.AddComponent <GraphicRaycaster>();
                obj.transform.SetParent(transform);
                obj.layer    = LayerMask.NameToLayer("UI");
                c.renderMode = mode;
                //if(RenderMode.ScreenSpaceOverlay == mode)
                //{
                //    mDarkMask = getDarkMask(c);
                //}
                if (RenderMode.ScreenSpaceCamera == mode)
                {
                    //GameObject cameraObj = new GameObject();
                    Camera _camera = obj.AddComponent <Camera>();
                    _camera.clearFlags    = CameraClearFlags.Depth;
                    _camera.nearClipPlane = 0.1f;
                    _camera.farClipPlane  = 200f;
                    //_camera.name = "SSCamera";
                    _camera.cullingMask  = 1 << LayerMask.NameToLayer("UI");
                    _camera.orthographic = true;
                    //_camera.transform.LookAt(_camera.transform.position + Vector3.forward, Vector3.up);
                    //cameraObj.transform.SetParent(obj.transform, false);
                    c.worldCamera = _camera;
                    mDarkMask     = _getDarkMask(c);
                }
                SetCanvasByMode(c);
                //mCanvas[(int)mode] = c;
            }
            return(c);
        }
Example #41
0
        protected override void OnRenderEnd(RegExpr defaultTokenWs, RegExpr parent,
                                            StringBuilder pattern, ref RenderMode mode, Stack <Token> tokenStack)
        {
            base.OnRenderEnd(defaultTokenWs, parent, pattern, ref mode, tokenStack);

            if (ExprNeedsGroup)
            {
                pattern.Append(")");
            }

            if (AtLeast == 0 && AtMost == 1)
            {
                pattern.Append("?");
            }
            else if (AtLeast == 0 && AtMost == int.MaxValue)
            {
                pattern.Append("*");
            }
            else if (AtLeast == 1 && AtMost == int.MaxValue)
            {
                pattern.Append("+");
            }
            else if (AtLeast == AtMost)
            {
                pattern.AppendFormat("{{{0}}}", AtLeast);
            }
            else if (AtMost == int.MaxValue)
            {
                pattern.AppendFormat("{{{0},}}", AtLeast);
            }
            else if (AtLeast == 0)
            {
                pattern.AppendFormat("{{,{0}}}", AtMost);
            }
            else
            {
                pattern.AppendFormat("{{{0},{1}}}", AtLeast, AtMost);
            }
        }
        private List <List <Linker.Container> > GetNodes(RenderMode mode, int depth)
        {
            switch (mode)
            {
            case RenderMode.SIBLINGS:
                return(GetAllSiblings(depth));

            case RenderMode.LEVELS:
                if (depth == 1)
                {
                    List <List <Linker.Container> > list = new List <List <Linker.Container> >();
                    list.Add(GetNextLevel());
                    return(list);
                }
                return(GetAllLevels(depth));

            default:
                Debug.Log("Wrong mode.");
                break;
            }
            return(null);
        }
Example #43
0
        void HandleRotate(RenderMode renderMode, Canvas canvas)
        {
            isDirty = true;
            Vector2 direction = Input.mousePosition - transform.position;

            if (renderMode == RenderMode.ScreenSpaceCamera)
            {
                direction = (Vector2)Input.mousePosition - RectTransformUtility.WorldToScreenPoint(canvas.worldCamera, transform.position);
            }

            var angle = Mathf.Atan2(direction.y, direction.x) * Mathf.Rad2Deg;

            var handleDir   = rotateHandle.transform.localPosition;
            var handleAngle = Mathf.Atan2(handleDir.y, handleDir.x) * Mathf.Rad2Deg;

            transform.rotation = Quaternion.AngleAxis(angle - handleAngle, Vector3.forward);

            if (OnRotate != null)
            {
                OnRotate();
            }
        }
Example #44
0
 public virtual void DrawContent(Graphics graphics, Bitmap bmp, RenderMode renderMode, Rectangle clipRectangle)
 {
     if (Children.Count > 0)
     {
         if (Status != EditStatus.IDLE)
         {
             DrawSelectionBorder(graphics, Bounds);
         }
         else
         {
             if (clipRectangle.Width != 0 && clipRectangle.Height != 0)
             {
                 foreach (IFilter filter in Filters)
                 {
                     if (filter.Invert)
                     {
                         filter.Apply(graphics, bmp, Bounds, renderMode);
                     }
                     else
                     {
                         Rectangle drawingRect = new Rectangle(Bounds.Location, Bounds.Size);
                         drawingRect.Intersect(clipRectangle);
                         if (filter is MagnifierFilter)
                         {
                             // quick&dirty bugfix, because MagnifierFilter behaves differently when drawn only partially
                             // what we should actually do to resolve this is add a better magnifier which is not that special
                             filter.Apply(graphics, bmp, Bounds, renderMode);
                         }
                         else
                         {
                             filter.Apply(graphics, bmp, drawingRect, renderMode);
                         }
                     }
                 }
             }
         }
     }
     Draw(graphics, renderMode);
 }
Example #45
0
        public override void Draw(Graphics g, RenderMode rm)
        {
            if (_parent == null)
            {
                return;
            }
            using (Brush cropBrush = new SolidBrush(Color.FromArgb(100, 150, 150, 100))) {
                Rectangle cropRectangle = GuiRectangle.GetGuiRectangle(Left, Top, Width, Height);
                Rectangle selectionRect = new Rectangle(cropRectangle.Left - 1, cropRectangle.Top - 1, cropRectangle.Width + 1, cropRectangle.Height + 1);

                DrawSelectionBorder(g, selectionRect);

                // top
                g.FillRectangle(cropBrush, new Rectangle(0, 0, _parent.Width, cropRectangle.Top));
                // left
                g.FillRectangle(cropBrush, new Rectangle(0, cropRectangle.Top, cropRectangle.Left, cropRectangle.Height));
                // right
                g.FillRectangle(cropBrush, new Rectangle(cropRectangle.Left + cropRectangle.Width, cropRectangle.Top, _parent.Width - (cropRectangle.Left + cropRectangle.Width), cropRectangle.Height));
                // bottom
                g.FillRectangle(cropBrush, new Rectangle(0, cropRectangle.Top + cropRectangle.Height, _parent.Width, _parent.Height - (cropRectangle.Top + cropRectangle.Height)));
            }
        }
Example #46
0
        public override void Render(RenderTarget rt, RenderMode renderMode = RenderMode.BASE)
        {
            // Simulate
            float dt = world.delta;

            simulator.Update(dt);

            Material m   = GetMaterial(renderMode);
            Texture  tex = m.mainTexture;

            IntRect  subRect = new IntRect(0, 0, (int)tex.Size.X, (int)tex.Size.Y);
            Vector2f scale   = new Vector2f(1, 1);

            foreach (Particle p in simulator.particles)
            {
                _batch.DrawCentered(p.position, subRect, p.color, scale);
            }

            _batch.Display(rt, new RenderStates(tex));

            _batch.Flush();
        }
Example #47
0
        // Use this for initialization
        public void Awake()
        {
            instance = this;
            if (!canvas)
            {
                canvas = GetComponentInParent <Canvas>();
                canvas = canvas.rootCanvas;
            }

            _guiCamera     = canvas.worldCamera;
            guiMode        = canvas.renderMode;
            _rectTransform = GetComponent <RectTransform>();
            SetNewDefaultPivot(_rectTransform.pivot);
            canvasRectTransform = canvas.GetComponent <RectTransform>();
            _layoutGroup        = GetComponentInChildren <LayoutGroup>();

            _text = GetComponentInChildren <Text>();

            _inside = false;

            this.gameObject.SetActive(false);
        }
Example #48
0
        public override void Draw(Graphics graphics, RenderMode rm)
        {
            int   lineThickness = GetFieldValueAsInt(FieldType.LINE_THICKNESS);
            Color lineColor     = GetFieldValueAsColor(FieldType.LINE_COLOR);
            bool  shadow        = GetFieldValueAsBool(FieldType.SHADOW);
            bool  lineVisible   = lineThickness > 0 && Colors.IsVisible(lineColor);

            if (lineVisible)
            {
                graphics.SmoothingMode      = SmoothingMode.HighSpeed;
                graphics.InterpolationMode  = InterpolationMode.HighQualityBicubic;
                graphics.CompositingQuality = CompositingQuality.HighQuality;
                graphics.PixelOffsetMode    = PixelOffsetMode.None;
                //draw shadow first
                if (shadow)
                {
                    int basealpha   = 100;
                    int alpha       = basealpha;
                    int steps       = 5;
                    int currentStep = lineVisible ? 1 : 0;
                    while (currentStep <= steps)
                    {
                        using (Pen shadowPen = new Pen(Color.FromArgb(alpha, 100, 100, 100), lineThickness)) {
                            Rectangle shadowRect = GuiRectangle.GetGuiRectangle(Left + currentStep, Top + currentStep, Width, Height);
                            graphics.DrawRectangle(shadowPen, shadowRect);
                            currentStep++;
                            alpha = alpha - basealpha / steps;
                        }
                    }
                }
                Rectangle rect = GuiRectangle.GetGuiRectangle(Left, Top, Width, Height);
                if (lineThickness > 0)
                {
                    using (Pen pen = new Pen(lineColor, lineThickness)) {
                        graphics.DrawRectangle(pen, rect);
                    }
                }
            }
        }
        /// <summary>
        /// Render model with legacy opengl(glVertex() ...).
        /// </summary>
        /// <param name="model"></param>
        /// <param name="gl"></param>
        /// <param name="renderMode"></param>
        public static void RenderLegacyOpenGL(this ScientificModel model, OpenGL gl, RenderMode renderMode)
        {
            if (model == null)
            {
                return;
            }
            if (model.VertexCount <= 0)
            {
                return;
            }

            float[] positions = model.Positions;
            float[] colors    = model.Colors;

            gl.Begin(model.Mode);
            for (int i = 0; i < model.VertexCount; i++)
            {
                gl.Color(colors[i * 3], colors[i * 3 + 1], colors[i * 3 + 2]);
                gl.Vertex(positions[i * 3], positions[i * 3 + 1], positions[i * 3 + 2]);
            }
            gl.End();
        }
Example #50
0
        protected override IEnumerable <RegExpr> OnRender(RegExpr defaultTokenWs, RegExpr parent,
                                                          StringBuilder pattern, ref RenderMode mode)
        {
            base.OnRender(defaultTokenWs, parent, pattern, ref mode);

            if (mode.HasFlag(RenderMode.Assert))
            {
                throw new NestedAssertException();
            }

            switch (Context)
            {
            case AssertLook.Ahead:
                if (Negative)
                {
                    pattern.Append("(?!");
                }
                else
                {
                    pattern.Append("(?=");
                }
                break;

            case AssertLook.Behind:
                if (Negative)
                {
                    pattern.Append("(?<!");
                }
                else
                {
                    pattern.Append("(?<=");
                }
                break;
            }

            mode |= RenderMode.Assert;
            return(Items(Expr));
        }
Example #51
0
        // This updates the settings from configuration
        public void UpdateConfiguration()
        {
            // Lookup settings
            SpriteInfo ti = General.Map.Data.GetSpriteInfo(tileindex);

            //mxd. Calculate size
            var   sprite = General.Map.Data.GetImageData(tileindex);
            float xratio = RepeatX * ((FlatAligned && TrueCentered) ? 0.2f : 0.25f);

            size      = Math.Max((int)(sprite.Width * xratio) / 2, MINIMUM_SIZE);
            fixedsize = ti.FixedSize;

            // Color valid?
            if ((ti.Color >= 0) && (ti.Color < ColorCollection.SpriteColorsCount))
            {
                // Apply color
                color = General.Colors.Colors[ti.Color + General.Colors.SpriteColorsOffset];
            }
            else
            {
                // Unknown thing color
                color = General.Colors.Colors[General.Colors.SpriteColorsOffset];
            }

            //mxd. Update display mode
            if (CheckFlag(General.Map.FormatInterface.SpriteFlags.WallAligned))
            {
                displaymode = RenderMode.WALL;
            }
            else if (CheckFlag(General.Map.FormatInterface.SpriteFlags.FlatAligned))
            {
                displaymode = RenderMode.FLAT;
            }
            else
            {
                displaymode = RenderMode.BILLBOARD;
            }
        }
Example #52
0
        private ShaderProgram InitShader(OpenGL gl, RenderMode renderMode)
        {
            String vertexShaderSource   = ManifestResourceLoader.LoadTextFile(@"Grids.PointGrid.vert");
            String fragmentShaderSource = ManifestResourceLoader.LoadTextFile(@"Grids.PointGrid.frag");

            var shaderProgram = new ShaderProgram();

            shaderProgram.Create(gl, vertexShaderSource, fragmentShaderSource, null);

            {
                int location = shaderProgram.GetAttributeLocation(gl, in_Position);
                if (location < 0)
                {
                    throw new ArgumentException();
                }
                this.ATTRIB_INDEX_POSITION = (uint)location;
            }
            {
                int location = shaderProgram.GetAttributeLocation(gl, in_uv);
                if (location < 0)
                {
                    throw new ArgumentException();
                }
                this.ATTRIB_INDEX_POSITION = (uint)location;
            }
            {
                int location = shaderProgram.GetAttributeLocation(gl, in_radius);
                if (location < 0)
                {
                    throw new ArgumentException();
                }
                this.ATTRIB_INDEX_POSITION = (uint)location;
            }

            shaderProgram.AssertValid(gl);

            return(shaderProgram);
        }
Example #53
0
        private void CreateVertexArrayObject(OpenGL gl, RenderMode renderMode)
        {
            if (this.positionBuffer == null || this.colorBuffer == null || this.radiusBuffer == null)
            {
                return;
            }

            this.vertexArrayObject = new uint[1];
            gl.GenVertexArrays(1, this.vertexArrayObject);
            gl.BindVertexArray(this.vertexArrayObject[0]);

            // prepare positions
            {
                int location = shaderProgram.GetAttributeLocation(gl, in_Position);
                ATTRIB_INDEX_POSITION = (uint)location;
                gl.BindBuffer(OpenGL.GL_ARRAY_BUFFER, positionBuffer[0]);
                gl.VertexAttribPointer(ATTRIB_INDEX_POSITION, 3, OpenGL.GL_FLOAT, false, 0, IntPtr.Zero);
                gl.EnableVertexAttribArray(ATTRIB_INDEX_POSITION);
            }
            // prepare colors
            {
                int location = shaderProgram.GetAttributeLocation(gl, in_uv);
                ATTRIB_INDEX_UV = (uint)location;
                gl.BindBuffer(OpenGL.GL_ARRAY_BUFFER, colorBuffer[0]);
                gl.VertexAttribPointer(ATTRIB_INDEX_UV, 1, OpenGL.GL_FLOAT, false, 0, IntPtr.Zero);
                gl.EnableVertexAttribArray(ATTRIB_INDEX_UV);
            }
            // prepare radius
            {
                int location = shaderProgram.GetAttributeLocation(gl, in_radius);
                ATTRIB_INDEX_RADIUS = (uint)location;
                gl.BindBuffer(OpenGL.GL_ARRAY_BUFFER, radiusBuffer[0]);
                gl.VertexAttribPointer(ATTRIB_INDEX_RADIUS, 1, OpenGL.GL_FLOAT, false, 0, IntPtr.Zero);
                gl.EnableVertexAttribArray(ATTRIB_INDEX_RADIUS);
            }

            gl.BindVertexArray(0);
        }
Example #54
0
 public WrapperStructPose(PoseMode poseMode,
                          Point <int> netInputSize,
                          Point <int> outputSize,
                          ScaleMode keyPointScale,
                          int gpuNumber,
                          int gpuNumberStart,
                          int scalesNumber,
                          float scaleGap,
                          RenderMode renderMode,
                          PoseModel poseModel) :
     this(poseMode,
          netInputSize,
          outputSize,
          keyPointScale,
          gpuNumber,
          gpuNumberStart,
          scalesNumber,
          scaleGap,
          renderMode,
          poseModel,
          true)
 {
 }
        /// <summary>
        /// Updates timer and render mode
        /// </summary>
        void Update()
        {
            if (!IsSwitchingModes())
            {
                _timer = _secondsBetweenModes;
                _switchTooltip.gameObject.SetActive(false);
                return;
            }

            _timer -= Time.deltaTime;
            if (_timer > 0)
            {
                _switchTooltip.gameObject.SetActive(true);
                UpdateSwitchTooltip();
                return;
            }

            _timer = _secondsBetweenModes;
            _mode  = GetNextRenderMode();

            UpdateHandMeshingBehavior();
            UpdateStatusText();
        }
Example #56
0
        /// <summary>
        /// Override the parent, calculate the label number, than draw
        /// </summary>
        /// <param name="graphics"></param>
        /// <param name="rm"></param>
        public override void Draw(Graphics graphics, RenderMode rm)
        {
            graphics.SmoothingMode      = SmoothingMode.HighQuality;
            graphics.InterpolationMode  = InterpolationMode.HighQualityBicubic;
            graphics.CompositingQuality = CompositingQuality.HighQuality;
            graphics.PixelOffsetMode    = PixelOffsetMode.None;
            graphics.TextRenderingHint  = TextRenderingHint.AntiAliasGridFit;
            string    text          = ((Surface)Parent).CountStepLabels(this).ToString();
            Rectangle rect          = GuiRectangle.GetGuiRectangle(Left, Top, Width, Height);
            Color     fillColor     = GetFieldValueAsColor(FieldType.FILL_COLOR);
            Color     lineColor     = GetFieldValueAsColor(FieldType.LINE_COLOR);
            Color     textColor     = GetFieldValueAsColor(FieldType.TEXT_COLOR);
            int       lineThickness = GetFieldValueAsInt(FieldType.LINE_THICKNESS);
            bool      shadow        = GetFieldValueAsBool(FieldType.SHADOW);

            EllipseContainer.DrawEllipse(rect, graphics, rm, lineThickness, lineColor, fillColor, shadow);

            using (FontFamily fam = new FontFamily(FontFamily.GenericSansSerif.Name)) {
                using (Font font = new Font(fam, fontSize, FontStyle.Bold, GraphicsUnit.Pixel)) {
                    TextContainer.DrawText(graphics, rect, 0, textColor, false, _stringFormat, text, font);
                }
            }
        }
Example #57
0
        /// <summary>
        /// Render to the provided instance of OpenGL.
        /// </summary>
        /// <param name="gl">The OpenGL instance.</param>
        /// <param name="renderMode">The render mode.</param>
        public override void Render(OpenGL gl, RenderMode renderMode)
        {
            //  Call the base.
            base.Render(gl, renderMode);

            //	Begin drawing a NURBS curve.
            gl.BeginCurve(nurbsRenderer);

            //	Draw the curve.
            gl.NurbsCurve(nurbsRenderer,                        //	The internal nurbs object.
                          knots.Length,                         //	Number of knots.
                          knots,                                //	The knots themselves.
                          3,                                    //	The size of a vertex.
                          ControlPoints.ToFloatArray(),         //	The control points.
                          ControlPoints.Width,                  //	The order, i.e degree + 1.
                          OpenGL.GL_MAP1_VERTEX_3);             //	Type of data to generate.

            //	End the curve.
            gl.EndCurve(nurbsRenderer);

            //	Draw the control points.
            ControlPoints.Draw(gl, DrawControlPoints, DrawControlGrid);
        }
Example #58
0
        private void SwitchVideoRendererButton(RenderMode mode)
        {
            switch (mode)
            {
            case RenderMode.NORMAL:
                normalButton.SetEnable();
                _180Button.SetDisable();
                _360Button.SetDisable();
                break;

            case RenderMode._180:
                normalButton.SetDisable();
                _180Button.SetEnable();
                _360Button.SetDisable();
                break;

            case RenderMode._360:
                normalButton.SetDisable();
                _180Button.SetDisable();
                _360Button.SetEnable();
                break;
            }
        }
        void IRenderable.Render(OpenGL gl, RenderMode renderMode)
        {
            if (this.shaderProgram == null)
            {
                this.shaderProgram = InitShader(gl, renderMode);
            }
            if (this.matrixVertexArrayObject == null)
            {
                CreateVertexArrayObject(gl, renderMode);
            }
            if (this.fractionVertexArrayObject == null)
            {
                CreateFractionVertexArrayObject(gl, renderMode);
            }

            BeforeRendering(gl, renderMode);

            DoRenderMatrix(gl, renderMode);

            DoRenderFraction(gl, renderMode);

            AfterRendering(gl, renderMode);
        }
Example #60
0
        // Use this for initialization
        public void Awake()
        {
            var _canvas = GetComponentInParent <Canvas>();

            _guiCamera     = _canvas.worldCamera;
            _guiMode       = _canvas.renderMode;
            _rectTransform = GetComponent <RectTransform>();

            _text = GetComponentInChildren <Text>();

            _inside = false;

            //size of the screen
            // screenWidth = Screen.width;
            // screenHeight = Screen.height;

            xShift = 0f;
            YShift = -30f;

            // _xShifted = _yShifted = false;

            this.gameObject.SetActive(false);
        }