Ejemplo n.º 1
0
        public static void End()
        {
            ProjectionStack.End();

            // This resets the texture from font to none.
            GL.BindTexture(TextureTarget.Texture2D, 0);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// When TransformToOrthogProjection is enabled, we need to get the current orthogonal transformation,
        /// the font scale, and ensure that the projection is actually orthogonal
        /// </summary>
        /// <param name="fontScale"></param>
        /// <param name="viewportTransform"></param>
        private static TransformViewport OrthogonalTransform(out float fontScale)
        {
            bool  isOrthog;
            float left, right, bottom, top;

            ProjectionStack.GetCurrentOrthogProjection(out isOrthog, out left, out right, out bottom, out top);

            if (!isOrthog)
            {
                throw new ArgumentOutOfRangeException("Current projection matrix was not Orthogonal. Please ensure that you have set an orthogonal projection before attempting to create a font with the TransformToOrthogProjection flag set to true.");
            }

            var viewportTransform = new TransformViewport(left, top, right - left, bottom - top);

            fontScale = Math.Abs((float)ProjectionStack.CurrentViewport.Value.Height / viewportTransform.Height);
            return(viewportTransform);
        }
Ejemplo n.º 3
0
        public static QFont FromQFontFile(string filePath, float downSampleFactor, QFontLoaderConfiguration loaderConfig = null, ProjectionStack proj = null)
        {
            if (loaderConfig == null)
                loaderConfig = new QFontLoaderConfiguration();

            QFont qfont = new QFont();
            if (proj != null)
                qfont.ProjectionStack = proj;

            TransformViewport? transToVp = null;
            float fontScale = 1f;
            if (loaderConfig.TransformToCurrentOrthogProjection)
                transToVp = qfont.OrthogonalTransform(out fontScale);

            qfont.fontData = Builder.LoadQFontDataFromFile(filePath, downSampleFactor * fontScale, loaderConfig);

            if (loaderConfig.ShadowConfig != null)
                qfont.Options.DropShadowActive = true;
            if (transToVp != null)
                qfont.Options.TransformToViewport = transToVp;

            return qfont;
        }
Ejemplo n.º 4
0
 public static QFont FromQFontFile(string filePath, QFontLoaderConfiguration loaderConfig = null, ProjectionStack proj = null)
 {
     return FromQFontFile(filePath, 1.0f, loaderConfig, proj);
 }
Ejemplo n.º 5
0
 /// <summary>
 /// Pops the last pushed viewport, returning
 /// to the previous viewport in use
 /// </summary>
 public static void PopSoftwareViewport()
 {
     ProjectionStack.PopSoftwareViewport();
 }
Ejemplo n.º 6
0
 /// <summary>
 /// Use a new viewport. This is more efficient
 /// than calling ForceViewportRefresh() or InvalidateViewport()
 /// </summary>
 /// <param name="viewport"></param>
 public static void PushSoftwareViewport(Viewport viewport)
 {
     ProjectionStack.PushSoftwareViewport(viewport);
 }
Ejemplo n.º 7
0
 /// <summary>
 /// Forces the current viewport used by QFont to be read
 /// from "hardware"
 /// </summary>
 public static void ForceViewportRefresh()
 {
     ProjectionStack.UpdateCurrentViewportFromHardware();
 }
Ejemplo n.º 8
0
 /// <summary>
 /// Invalidates the internally cached viewport, causing it to be
 /// reread the next time it is required. This should be called
 /// if the viewport and text is to be rendered to the new
 /// viewport.
 /// </summary>
 public static void InvalidateViewport()
 {
     ProjectionStack.InvalidateViewport();
 }
Ejemplo n.º 9
0
 public static void End()
 {
     ProjectionStack.End();
 }
Ejemplo n.º 10
0
        /*
         * public void Begin()
         * {
         *  ProjectionStack.Begin();
         * }
         *
         * public void End()
         * {
         *  ProjectionStack.End();
         * }*/


        public static void Begin()
        {
            ProjectionStack.Begin();
        }