Exemple #1
0
        private OpenGlScreenNormalizedRect GetCurrentDisplayNormalizedRect(double parPosX, double parPosY, double parWidth,
                                                                           double parHeight)
        {
            double x1 = Math.Max(DisplayViewportGlUnitsX1 +
                                 OpenGlUtil.GetNormalizedWidthCoordValue(parPosX * GlobalRescale, WindowWidth),
                                 DisplayViewportGlUnitsX1);

            double x2 = Math.Min(x1 + OpenGlUtil.GetNormalizedWidthCoordValue(parWidth * GlobalRescale, WindowWidth),
                                 DisplayViewportGlUnitsX2);

            double y1 = Math.Min(DisplayViewportGlUnitsY1 -
                                 OpenGlUtil.GetNormalizedHeightCoordValue(parPosY * GlobalRescale, WindowHeight),
                                 DisplayViewportGlUnitsY1);

            double y2 = Math.Max(y1 - OpenGlUtil.GetNormalizedHeightCoordValue(parHeight * GlobalRescale, WindowHeight),
                                 DisplayViewportGlUnitsY2);

            return(new OpenGlScreenNormalizedRect()
            {
                X1 = x1,
                X2 = x2,
                Y1 = y1,
                Y2 = y2
            });
        }
Exemple #2
0
        /// <summary>
        /// Получить информацию о позиции объекта на дисплее, обновляемым с помощью буфера кадров
        /// </summary>
        /// <param name="parPosX">Позиция X</param>
        /// <param name="parPosY">Позиция Y</param>
        /// <param name="parWidth">Ширина</param>
        /// <param name="parHeight">Высота</param>
        /// <returns></returns>
        private OpenGlScreenNormalizedRect GetCurrentViewportNormalizedRect(double parPosX, double parPosY, double parWidth,
                                                                            double parHeight)
        {
            double x1 = Math.Max(-1 + OpenGlUtil.GetNormalizedWidthCoordValue(parPosX, ViewportWidth), -1);
            double x2 = Math.Min(x1 + OpenGlUtil.GetNormalizedWidthCoordValue(parWidth, ViewportWidth), 1);
            double y1 = Math.Min(1 - OpenGlUtil.GetNormalizedHeightCoordValue(parPosY, ViewportHeight), 1);
            double y2 = Math.Max(y1 - OpenGlUtil.GetNormalizedHeightCoordValue(parHeight, ViewportHeight), -1);

            return(new OpenGlScreenNormalizedRect()
            {
                X1 = x1,
                X2 = x2,
                Y1 = y1,
                Y2 = y2
            });
        }