public static void InitializeResources() { if (Freetype6Loaded) { var builderConfig = new QFontBuilderConfiguration(true) { ShadowConfig = { BlurRadius = 2, BlurPasses = 1, Type = ShadowType.Blurred }, TextGenerationRenderHint = TextGenerationRenderHint.ClearTypeGridFit, Characters = CharacterSet.General | CharacterSet.Japanese | CharacterSet.Thai | CharacterSet.Cyrillic }; NormalFont = new QFont("C:\\Windows\\Fonts\\segoeui.ttf", 10, builderConfig); SmallFont = new QFont("C:\\Windows\\Fonts\\segoeui.ttf", 8, builderConfig); MonoFont = new QFont("C:\\Windows\\Fonts\\consola.ttf", 10, builderConfig); TextRenderer = new QFontDrawing(); } UIShader = ProgramFactory.Create <UIShaderProgram>(); UIShader.Use(); UIShader.Opacity.Set(1f); }
public static void RenderElements() { UIShader.Use(); UIShader.Projection.Set(ProjectionMatrix); VAO.Bind(); VBO.Init(OpenTK.Graphics.OpenGL.BufferTarget.ArrayBuffer, VertexList.ToArray()); foreach (var spriteGroup in SpritesToRender.GroupBy(x => x.Texture)) { spriteGroup.Key.Bind(OpenTK.Graphics.OpenGL.TextureUnit.Texture1); UIShader.Texture.BindTexture(OpenTK.Graphics.OpenGL.TextureUnit.Texture1, spriteGroup.Key); foreach (var sprite in spriteGroup) { UIShader.Opacity.Set(sprite.Opacity); VAO.DrawArrays(OpenTK.Graphics.OpenGL.PrimitiveType.Quads, sprite.Offset, sprite.ElemCount); } } if (Freetype6Loaded) { TextRenderer.RefreshBuffers(); TextRenderer.Draw(); TextRenderer.DisableShader(); } }
public static void InitializeResources() { NormalFont = new QFont("C:\\Windows\\Fonts\\segoeui.ttf", 10, new QFontBuilderConfiguration(true)); SmallFont = new QFont("C:\\Windows\\Fonts\\segoeui.ttf", 8, new QFontBuilderConfiguration(true)); MonoFont = new QFont("C:\\Windows\\Fonts\\consola.ttf", 10, new QFontBuilderConfiguration(true)); TextRenderer = new QFontDrawing(); UIShader = ProgramFactory.Create <UIShaderProgram>(); UIShader.Use(); UIShader.Opacity.Set(1f); VAO = new VertexArray(); VBO = new Buffer <VertVT>(); VAO.Bind(); VAO.BindAttribute(UIShader.Position, VBO); VAO.BindAttribute(UIShader.TexCoord, VBO, 12); }