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"); }
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"); }
public static void CreateCommonShaders() { sdrTextured = new GLShader(new string[] { TEXTURED_SHADER.VS }, new string[] { TEXTURED_SHADER.FS }); sdrTextured.Bind(); sdrTextured_colorUniform = sdrTextured.GetUniformLocation("Color"); GL.Uniform4(sdrTextured_colorUniform, OpenTK.Graphics.Color4.White); sdrSolidColor = new GLShader(new string[] { SOLID_COLOR_SHADER.VS }, new string[] { SOLID_COLOR_SHADER.FS }); sdrSolidColor.Bind(); sdrSolidColor_colorUniform = sdrSolidColor.GetUniformLocation("Color"); GL.Uniform4(sdrSolidColor_colorUniform, OpenTK.Graphics.Color4.White); sdrDashedLine = new GLShader(new string[] { DASHED_LINE_SHADER.VS }, new string[] { DASHED_LINE_SHADER.FS }); sdrDashedLine.Bind(); sdrDashedLine_colorUniform = sdrDashedLine.GetUniformLocation("Color"); sdrDashedLine_lengthUniform = sdrDashedLine.GetUniformLocation("Length"); GL.Uniform4(sdrDashedLine_colorUniform, OpenTK.Graphics.Color4.White); }
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"); } }
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"); } }
public void Load(Cinema.CinemaArgument[] arguments, Dictionary <string, HashSet <object> > valuerange) { this.arguments = arguments; // Create selection array and populate it with the default values selection = new Selection(arguments.Length, valuerange.Count, images); for (int i = 0; i < arguments.Length; ++i) { if (arguments[i].defaultValue != null) { selection[i].Add(Array.IndexOf(arguments[i].values, arguments[i].defaultValue)); } } // Load shader sdrColored = new GLShader(new string[] { ARGUMENT_INDEX_SHADER.VS }, new string[] { ARGUMENT_INDEX_SHADER.FS }); sdrColored_colorParam = sdrColored.GetUniformLocation("Color"); sdrColored.Bind(); meshSelection = new GLMesh(new Vector3[] { new Vector3(0.0f, -0.1f, 0.0f), new Vector3(0.0f, 1.15f, 0.0f) }, null, null, null, null, null, PrimitiveType.Lines); // Create track bars for each argument foreach (Cinema.CinemaArgument argument in arguments) { TrackBar newtrackbar = new TrackBar(argument.values.Length, meshSelection); newtrackbar.label = argument.label; trackbars.Add(newtrackbar); } // Create track bars for meta data value foreach (KeyValuePair <string, HashSet <object> > range in valuerange) { TrackBar newtrackbar = new TrackBar(range.Value.Count, meshSelection); newtrackbar.label = range.Key; trackbars.Add(newtrackbar); } argumentLabelBounds = new Rectangle[arguments.Length]; }
public void Load(Cinema.CinemaArgument[] arguments, Dictionary<string, HashSet<object>> valuerange) { this.arguments = arguments; // Create selection array and populate it with the default values selection = new Selection(arguments.Length, valuerange.Count, images); for(int i = 0; i < arguments.Length; ++i) { if(arguments[i].defaultValue != null) selection[i].Add(Array.IndexOf(arguments[i].values, arguments[i].defaultValue)); } // Load shader sdrColored = new GLShader(new string[] {ARGUMENT_INDEX_SHADER.VS}, new string[] {ARGUMENT_INDEX_SHADER.FS}); sdrColored_colorParam = sdrColored.GetUniformLocation("Color"); sdrColored.Bind(); meshSelection = new GLMesh(new Vector3[] {new Vector3(0.0f, -0.1f, 0.0f), new Vector3(0.0f, 1.15f, 0.0f)}, null, null, null, null, null, PrimitiveType.Lines); // Create track bars for each argument foreach(Cinema.CinemaArgument argument in arguments) { TrackBar newtrackbar = new TrackBar(argument.values.Length, meshSelection); newtrackbar.label = argument.label; trackbars.Add(newtrackbar); } // Create track bars for meta data value foreach(KeyValuePair<string, HashSet<object>> range in valuerange) { TrackBar newtrackbar = new TrackBar(range.Value.Count, meshSelection); newtrackbar.label = range.Key; trackbars.Add(newtrackbar); } argumentLabelBounds = new Rectangle[arguments.Length]; }
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"); } }
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)); }
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"); } }
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)); }