Example #1
0
        public CoordinateSystem()
        {
            // Load shader
            sdr = new GLShader(new string[] { COORDINATE_SYSTEM_SHADER.VS }, new string[] { COORDINATE_SYSTEM_SHADER.FS });
            sdr_colorModeParam = sdr.GetUniformLocation("ColorMode");

            // Load texture
            tex = GLTexture2D.FromFile(Global.EXE_DIR + "arrow.png");
        }
Example #2
0
        public CoordinateSystem()
        {
            // Load shader
            sdr = new GLShader(new string[] {COORDINATE_SYSTEM_SHADER.VS}, new string[] {COORDINATE_SYSTEM_SHADER.FS});
            sdr_colorModeParam = sdr.GetUniformLocation("ColorMode");

            // Load texture
            tex = GLTexture2D.FromFile(Global.EXE_DIR + "arrow.png");
        }
Example #3
0
        public GLTextFont(string filename, Vector2 charsize, GLMesh meshquad)
        {
            this.texture  = GLTexture2D.FromFile(filename);
            this.charsize = charsize;
            this.meshquad = meshquad;

            if (fontshader == null)
            {
                fontshader = new GLShader(new string[] { FONT_SHADER.VS }, new string[] { FONT_SHADER.FS });
                fontshader_coloruniform = fontshader.GetUniformLocation("Color");
            }
        }
Example #4
0
        public GLNumberFont(string filename, FontDefinition fontDefinition, GLMesh meshquad, bool isFixedWidth)
        {
            this.texture    = GLTexture2D.FromFile(filename);
            this.fontdef    = fontDefinition;
            this.meshquad   = meshquad;
            this.fixedwidth = /*isFixedWidth ? fontdef[0][10] / 10 :*/ 0;

            if (fontshader == null)
            {
                fontshader = new GLShader(new string[] { FONT_SHADER.VS }, new string[] { FONT_SHADER.FS });
                fontshader_coloruniform = fontshader.GetUniformLocation("Color");
            }
        }
Example #5
0
        public GLButton(GLTexture2D texture, Rectangle bounds, AnchorStyles anchor = AnchorStyles.Top | AnchorStyles.Left, string actionname = null, string actiondesc = null)
        {
            this.Anchor = anchor;

            this.tex = texture;
            if (actionname != null)
            {
                clickAction = ActionManager.CreateAction(actiondesc == null ? "" : actiondesc, actionname, this, "ClickInternal");
            }

            if (bounds.Width <= 0)
            {
                bounds.Width = tex.width;
            }
            if (bounds.Height <= 0)
            {
                bounds.Height = tex.height;
            }
            this.Bounds = bounds;
        }
Example #6
0
		public GLNumberFont(string filename, FontDefinition fontDefinition, GLMesh meshquad, bool isFixedWidth)
		{
			this.texture = GLTexture2D.FromFile(filename);
			this.fontdef = fontDefinition;
			this.meshquad = meshquad;
			this.fixedwidth = /*isFixedWidth ? fontdef[0][10] / 10 :*/ 0;

			if(fontshader == null)
			{
				fontshader = new GLShader(new string[] { FONT_SHADER.VS }, new string[] { FONT_SHADER.FS });
				fontshader_coloruniform = fontshader.GetUniformLocation("Color");
			}
		}
Example #7
0
		public GLTextFont2(Font font)
		{
			if(fontshader == null)
			{
				fontshader = new GLShader(new string[] { FONT_SHADER.VS }, new string[] { FONT_SHADER.FS });
				fontshader_coloruniform = fontshader.GetUniformLocation("Color");
			}

			/*string charmap = "";
			for(int i = 0; i < 255; ++i)
				if(!char.IsControl((char)i))
				charmap += (char)i;

			Bitmap bmp = new Bitmap(1, 1);
			Graphics gfx = Graphics.FromImage(bmp);
			Size charmapSize = gfx.MeasureString(charmap, font, 1024).ToSize();
			bmp = new Bitmap(charmapSize.Width, charmapSize.Height);
			gfx = Graphics.FromImage(bmp);
			gfx.DrawString(charmap, font, Brushes.White, new RectangleF(0.0f, 0.0f, (float)charmapSize.Width, (float)charmapSize.Height));
			gfx.Flush();
			bmp.Save("charmap.png");*/

			int x = CHARMAP_PADDING, y = CHARMAP_PADDING, lineMaxHeight = 0;
			lineHeight = 0;
			Bitmap bmp = new Bitmap(1, 1);
			Graphics gfx = Graphics.FromImage(bmp);
			for(int i = 0; i < 255; ++i)
				if(!char.IsControl((char)i))
				{
					Size charmapSize = gfx.MeasureString(new string((char)i, 1), font).ToSize();
					charmapSize.Width += CHARMAP_CHAR_SIZE_INFLATE;
					charmapSize.Height += CHARMAP_CHAR_SIZE_INFLATE;
					charBounds[i] = new Rectangle(x, y, charmapSize.Width, charmapSize.Height);
					x += charmapSize.Width + CHARMAP_CHAR_DIST_INFLATE;
					lineMaxHeight = Math.Max(lineMaxHeight, charmapSize.Height);

					if(x > 1024)
					{
						y += lineMaxHeight + CHARMAP_CHAR_DIST_INFLATE;
						x = CHARMAP_PADDING + charmapSize.Width + CHARMAP_CHAR_DIST_INFLATE;
						lineHeight = Math.Max(lineHeight, lineMaxHeight);
						lineMaxHeight = charmapSize.Height;
						charBounds[i].X = CHARMAP_PADDING;
						charBounds[i].Y += lineMaxHeight;
					}
				}
				else
					charBounds[i] = Rectangle.Empty;
			lineHeight = Math.Max(lineHeight, lineMaxHeight);

			blankWidth = (int)Math.Ceiling(gfx.MeasureString(" ", font).Width);

			#if !DEBUG_GLFONT
				#if SAVE_AND_LOAD_CHARMAPS
				string bmp_filename = "charmap_" + font.FontFamily.Name.Replace(" ", "") + "_" + font.Size + ".png";
				if(System.IO.File.Exists(bmp_filename))
					bmp = (Bitmap)Bitmap.FromFile(bmp_filename);
				else
				#endif
			{
			#endif
				bmp = new Bitmap(1024, y + lineMaxHeight);
				gfx = Graphics.FromImage(bmp);
				#if DEBUG_GLFONT
				gfx.Clear(Color.Black);
				#endif
				gfx.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias; // Do not use ClearType
				for(int i = 0; i < 255; ++i)
					if(!char.IsControl((char)i))
						gfx.DrawString(new string((char)i, 1), font, Brushes.White, new RectangleF((float)charBounds[i].X - 1, (float)charBounds[i].Y - 2, (float)charBounds[i].Width, (float)charBounds[i].Height));
				gfx.Flush();
			#if DEBUG_GLFONT
					#if SAVE_AND_LOAD_CHARMAPS
					bmp.Save("charmap_" + font.FontFamily.Name.Replace(" ", "") + "_" + font.Size + "_debug.png");
					#endif
			#else
					#if SAVE_AND_LOAD_CHARMAPS
					bmp.Save("charmap_" + font.FontFamily.Name.Replace(" ", "") + "_" + font.Size + ".png");
					#endif
				}
			#endif

			texture = new GLTexture2D("font", new GdiBitmap(bmp));
		}
Example #8
0
		public GLTextFont(string filename, Vector2 charsize, GLMesh meshquad)
		{
			this.texture = GLTexture2D.FromFile(filename);
			this.charsize = charsize;
			this.meshquad = meshquad;

			if(fontshader == null)
			{
				fontshader = new GLShader(new string[] { FONT_SHADER.VS }, new string[] { FONT_SHADER.FS });
				fontshader_coloruniform = fontshader.GetUniformLocation("Color");
			}
		}
Example #9
0
        public GLTextFont2(Font font)
        {
            if (fontshader == null)
            {
                fontshader = new GLShader(new string[] { FONT_SHADER.VS }, new string[] { FONT_SHADER.FS });
                fontshader_coloruniform = fontshader.GetUniformLocation("Color");
            }

            /*string charmap = "";
             * for(int i = 0; i < 255; ++i)
             *      if(!char.IsControl((char)i))
             *      charmap += (char)i;
             *
             * Bitmap bmp = new Bitmap(1, 1);
             * Graphics gfx = Graphics.FromImage(bmp);
             * Size charmapSize = gfx.MeasureString(charmap, font, 1024).ToSize();
             * bmp = new Bitmap(charmapSize.Width, charmapSize.Height);
             * gfx = Graphics.FromImage(bmp);
             * gfx.DrawString(charmap, font, Brushes.White, new RectangleF(0.0f, 0.0f, (float)charmapSize.Width, (float)charmapSize.Height));
             * gfx.Flush();
             * bmp.Save("charmap.png");*/

            int x = CHARMAP_PADDING, y = CHARMAP_PADDING, lineMaxHeight = 0;

            lineHeight = 0;
            Bitmap   bmp = new Bitmap(1, 1);
            Graphics gfx = Graphics.FromImage(bmp);

            for (int i = 0; i < 255; ++i)
            {
                if (!char.IsControl((char)i))
                {
                    Size charmapSize = gfx.MeasureString(new string((char)i, 1), font).ToSize();
                    charmapSize.Width  += CHARMAP_CHAR_SIZE_INFLATE;
                    charmapSize.Height += CHARMAP_CHAR_SIZE_INFLATE;
                    charBounds[i]       = new Rectangle(x, y, charmapSize.Width, charmapSize.Height);
                    x            += charmapSize.Width + CHARMAP_CHAR_DIST_INFLATE;
                    lineMaxHeight = Math.Max(lineMaxHeight, charmapSize.Height);

                    if (x > 1024)
                    {
                        y               += lineMaxHeight + CHARMAP_CHAR_DIST_INFLATE;
                        x                = CHARMAP_PADDING + charmapSize.Width + CHARMAP_CHAR_DIST_INFLATE;
                        lineHeight       = Math.Max(lineHeight, lineMaxHeight);
                        lineMaxHeight    = charmapSize.Height;
                        charBounds[i].X  = CHARMAP_PADDING;
                        charBounds[i].Y += lineMaxHeight;
                    }
                }
                else
                {
                    charBounds[i] = Rectangle.Empty;
                }
            }
            lineHeight = Math.Max(lineHeight, lineMaxHeight);

            blankWidth = (int)Math.Ceiling(gfx.MeasureString(" ", font).Width);

                        #if !DEBUG_GLFONT
                                #if SAVE_AND_LOAD_CHARMAPS
            string bmp_filename = "charmap_" + font.FontFamily.Name.Replace(" ", "") + "_" + font.Size + ".png";
            if (System.IO.File.Exists(bmp_filename))
            {
                bmp = (Bitmap)Bitmap.FromFile(bmp_filename);
            }
            else
                                #endif
            {
                        #endif
            bmp = new Bitmap(1024, y + lineMaxHeight);
            gfx = Graphics.FromImage(bmp);
                                #if DEBUG_GLFONT
            gfx.Clear(Color.Black);
                                #endif
            gfx.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias;                     // Do not use ClearType
            for (int i = 0; i < 255; ++i)
            {
                if (!char.IsControl((char)i))
                {
                    gfx.DrawString(new string((char)i, 1), font, Brushes.White, new RectangleF((float)charBounds[i].X - 1, (float)charBounds[i].Y - 2, (float)charBounds[i].Width, (float)charBounds[i].Height));
                }
            }
            gfx.Flush();
                        #if DEBUG_GLFONT
                                        #if SAVE_AND_LOAD_CHARMAPS
            bmp.Save("charmap_" + font.FontFamily.Name.Replace(" ", "") + "_" + font.Size + "_debug.png");
                                        #endif
                        #else
                                        #if SAVE_AND_LOAD_CHARMAPS
            bmp.Save("charmap_" + font.FontFamily.Name.Replace(" ", "") + "_" + font.Size + ".png");
                                        #endif
        }
                        #endif

            texture = new GLTexture2D("font", new GdiBitmap(bmp));
        }
Example #10
0
            public ColorMapPicker(GLFont font)
            {
                this.font = font;

                // Create textures
                texFlipButton = GLTexture2D.FromFile(Global.EXE_DIR + "flipButton.png", false);
                //cmdFlipButton = new GLButton(Global.EXE_DIR + "flipButton.png", new Rectangle(0, 0, 0, 0), AnchorStyles.Top | AnchorStyles.Left, "FlipColorMap", "Flip highlighted colormap");
            }
Example #11
0
 public GLCursor(string texfilename, Point hotspot)
 {
     this.tex = GLTexture2D.FromFile(texfilename, false);
     this.hotspot = hotspot;
 }
Example #12
0
            // pos = 0.0f ... 1.0f
            private void drawSplitter(float pos, GLTexture2D tex)
            {
                Vector3 vpos = Vector3.Transform(new Vector3(2.0f * pos - 1.0f, -1.0f, 0.0f), transform);
                vpos.X *= (float)Bounds.Width / (float)BackbufferSize.Width;
                //vpos.X += (float)Bounds.Left / (float)BackbufferSize.Width;

                vpos.Y *= (float)Bounds.Height / (float)BackbufferSize.Height;
                vpos.Y -= (float)Bounds.Top / (float)BackbufferSize.Height;

                Matrix4 mattrans;
                mattrans = Matrix4.Identity;
                mattrans *= Matrix4.CreateTranslation(-0.5f, 0.3f, 0.0f);
                mattrans *= Matrix4.CreateScale((float)tex.width / (float)BackbufferSize.Width, (float)tex.height / (float)BackbufferSize.Height, 1.0f);
                mattrans *= Matrix4.CreateTranslation(vpos);
                Common.sdrTextured.Bind(mattrans);

                Common.meshQuad.Bind(Common.sdrTextured, tex);
                Common.meshQuad.Draw();
            }
Example #13
0
            public InputSection(ColorTableManager colorTableMgr, GLFont font)
            {
                this.colorTableMgr = colorTableMgr;
                this.font = font;

                InsertSplitterPinAction = ActionManager.CreateAction("Insert splitter pin", this, "InsertSplitterPin");
                InsertNestedPinAction = ActionManager.CreateAction("Insert nesting pin", this, "InsertNestedPin");
                MovePinAction = ActionManager.CreateAction("Move pin", this, "MovePin");
                RemovePinAction = ActionManager.CreateAction("Remove pin", this, "RemovePin");
                SetSectionColormapAction = ActionManager.CreateAction("Set colormap of section", this, "SetSectionColormap");
                ResetColorTableAction = ActionManager.CreateAction("Reset colormap", this, "ResetColorTable");

                // Create colormap
                colormapTexture = new GLTexture1D("colormap", new byte[4 * FINAL_COLORMAP_SIZE], FINAL_COLORMAP_SIZE, PixelFormat.Rgba, false);

                // Create histogram grid as line list mesh
                List<Vector3> positions = new List<Vector3>();
                /*positions.AddRange(new Vector3[] {
                    // Outline
                    new Vector3(0.0f, 0.0f, 0.0f), new Vector3(0.0f, 0.5f, 0.0f),
                    new Vector3(0.0f, 0.5f, 0.0f), new Vector3(1.0f, 0.5f, 0.0f),
                    new Vector3(1.0f, 0.5f, 0.0f), new Vector3(1.0f, 0.0f, 0.0f),
                    new Vector3(1.0f, 0.0f, 0.0f), new Vector3(0.0f, 0.0f, 0.0f)
                });*/
                for(int i = 0; i <= 10; ++i)
                {
                    float y = (float)i / 10.0f * 0.9f + 0.1f;
                    positions.Add(new Vector3(0.0f, y, 0.0f));
                    positions.Add(new Vector3(1.0f, y, 0.0f));
                }
                for(int i = 0; i <= 10; ++i)
                {
                    float x = (float)i / 10.0f;
                    positions.Add(new Vector3(x, 0.1f, 0.0f));
                    positions.Add(new Vector3(x, 1.0f, 0.0f));
                }
                meshLines = new GLMesh(positions.ToArray(), null, null, null, null, null, PrimitiveType.Lines);

                // Create textures
                texSplitter = GLTexture2D.FromFile(Global.EXE_DIR + "splitter.png", false);
                texInterjectorLeft = GLTexture2D.FromFile(Global.EXE_DIR + "interjectorLeft.png", false);
                texInterjectorRight = GLTexture2D.FromFile(Global.EXE_DIR + "interjectorRight.png", false);

                // Create number font
                //font = new GLNumberFont("HelveticaNeue_12.png", new FontDefinition(new int[] {0, 14, 26, 39, 53, 67, 80, 93, 106, 120, 133}, new int[] {0, 19}), Common.meshQuad, true);
                //font = new GLNumberFont("HelveticaNeue_16.png", new FontDefinition(new int[] {0, 18, 34, 53, 71, 89, 106, 124, 142, 160, 178}, new int[] {0, 25}), true);
                //font = new GLTextFont("fntDefault.png", new Vector2(19.0f, 32.0f), Common.meshQuad);
            }