public void Render(Matrix4 Mvp) { var textureObject = TextureObjectSingleton.GetSingleTextureByName(TextureName); var shaderObj = ShaderObjectSingleton.GetByName(ShaderName); GL.UseProgram(shaderObj.ProgramId); Bind(); GL.UniformMatrix4(shaderObj.MatrixShaderLocation, false, ref Mvp); GL.BindTexture(TextureTarget.Texture2D, textureObject.TextureId); GL.DrawElements(PrimitiveType.Triangles, Indices.Length, DrawElementsType.UnsignedInt, 0); GL.BindTexture(TextureTarget.Texture2D, -1); }
public static void RenderString(Matrix4 baseMvp, double x, double y, string text, double size = GameEngineConstants.TEXT_DEFAULT_HEIGHT) { Matrix4 glyphMatrix = Matrix4.CreateTranslation((float)x, (float)y, 0) * baseMvp; for (int i = 0; i < text.Length; ++i) { RenderFromCorner( TextureObjectSingleton.GetSpriteTextureByName("font"), glyphMatrix, "texture", size, CorrectIndex(text[i]) ); float xPosition = (float)(size - (GameEngineConstants.TEXT_KERNING / GameEngineConstants.TEXT_DEFAULT_HEIGHT * size)); glyphMatrix = Matrix4.CreateTranslation(xPosition, 0, 0) * glyphMatrix; } }