コード例 #1
0
ファイル: Renderer.cs プロジェクト: dsrbecky/Fractals
        public void Render()
        {
            DateTime startTime = HighPrecisionTimer.Now;

            while(data.Size < fractal.View.BoundingBoxSize * 2) {
                data.ExtendRoot();
            }

            Matrix rotation = new Matrix();
            rotation.Rotate((float)fractal.View.CurrentAngle);

            graphics.CompositingQuality = CompositingQuality.HighSpeed;
            graphics.InterpolationMode = InterpolationMode.Bilinear;
            graphics.SmoothingMode = SmoothingMode.HighSpeed;
            graphics.ResetTransform();
            graphics.MultiplyTransform(rotation, MatrixOrder.Append);
            // From [-1,1] to [0,w]
            graphics.TranslateTransform(1, 1, MatrixOrder.Append);
            graphics.ScaleTransform(renderRectangle.Width / 2, renderRectangle.Height / 2, MatrixOrder.Append);

            RectangleD renderArea = new RectangleD((-fractal.View.Xpos + -data.Size / 2) * fractal.View.Xzoom,
                                                   (-fractal.View.Ypos + -data.Size / 2) * fractal.View.Xzoom,
                                                   fractal.View.Xzoom * data.Size,
                                                   fractal.View.Xzoom * data.Size);

            pixelSize = Math.Min(2d / renderRectangle.Width, 2d / renderRectangle.Height);

            RenderOperation root = new RenderOperation(null, data.Root, data.Area, renderArea, rotation);
            renderSet = new RenderSet(root, (int)numberOfFragmentsToRender);
            Render(renderSet.RenderOperations);

            numberOfFragmentsRendered = renderSet.Count;

            actualRenderTime = HighPrecisionTimer.Now - startTime;
            double timeFraction = (double)actualRenderTime.Ticks / (double)targetRenderTime.Ticks;
            double optimalCount = (double)numberOfFragmentsToRender / timeFraction;
            numberOfFragmentsToRender = numberOfFragmentsToRender * (1 - convergance) + optimalCount * convergance;
            numberOfFragmentsToRender = Math.Max(16d, numberOfFragmentsToRender);
        }
コード例 #2
0
ファイル: Renderer.cs プロジェクト: dsrbecky/Fractals
 protected virtual void Draw(Texture tex, RectangleF src, RectangleD dest)
 {
     graphics.DrawImage(tex.Bitmap,
                        new PointF[] {dest.LeftTopCornerF,
                                      dest.RightTopCornerF,
                                      dest.LeftBottomCornerF},
                        src,
                        GraphicsUnit.Pixel);
 }
コード例 #3
0
ファイル: OpenGlRenderer.cs プロジェクト: dsrbecky/Fractals
        protected override void Draw(Texture tex, RectangleF src, RectangleD dest)
        {
            base.Draw(tex, src, dest);

            Gl.glMatrixMode(Gl.GL_MODELVIEW);
            Gl.glLoadIdentity();
            Gl.glRotated(Fractal.View.CurrentAngle, 0, 0, 1);

            Gl.glBindTexture(Gl.GL_TEXTURE_2D, tex.TextureName);

            Gl.glBegin(Gl.GL_QUADS);
            {
                int texSize = BitmapCache.BitmapSize;

                Gl.glTexCoord2f(src.Left / texSize, src.Top / texSize);
                Gl.glVertex2d(dest.X, dest.Y);

                Gl.glTexCoord2f((src.Left) / texSize, (src.Top + src.Height) / texSize);
                Gl.glVertex2d(dest.X + dest.Width, dest.Y);

                Gl.glTexCoord2f((src.Left + src.Width) / texSize, (src.Top + src.Height) / texSize);
                Gl.glVertex2d(dest.X + dest.Width, dest.Y + dest.Height);

                Gl.glTexCoord2f((src.Left + src.Width) / texSize, src.Top / texSize);
                Gl.glVertex2d(dest.X, dest.Y + dest.Height);
            }
            Gl.glEnd();

            Gl.glFlush();
        }