Exemplo n.º 1
0
        public BitmapCache(Renderer renderer)
        {
            this.renderer = renderer;
            // Create cache set
            for (int i = 0; i < bitmapCount; i++) {
                Renderer.Texture tex = renderer.MakeTexture(BitmapSize, BitmapSize);

                for(int x = 0; x < fragmentsPerBitmap; x++) {
                    for(int y = 0; y < fragmentsPerBitmap; y++) {
                        caches.AddLast(new BitmapCacheItem(tex,
                                                           x * Fragment.BitmapSize,
                                                           y * Fragment.BitmapSize));
                    }
                }
            }
        }
Exemplo n.º 2
0
        public void RenderLoop()
        {
            while(!this.IsDisposed) {
                Graphics graphics = CreateGraphics();
                restartRenderLoop = false;
                if (CurrentFractalSingleton.Instance.Compiles) {
                    if (dataGenerator == null) {
                        dataGenerator = new OpenGlRenderer(CurrentFractalSingleton.Instance, graphics, ClientRectangle);
                    }
                    dataGenerator.Fractal = CurrentFractalSingleton.Instance;
                    dataGenerator.TargetRenderTime = TimeSpan.FromSeconds(1d / FPS);
                    dataGenerator.UserThreadAction += delegate {
                        Application.DoEvents();
                        if (this.IsDisposed || restartRenderLoop) {
                            dataGenerator.Abort();
                        }
                    };

                    while (!dataGenerator.Aborted && (dataGenerator.mouseButtons != MouseButtons.None || dataGenerator.Fractal.View.Rotating)) {
                        UpdateMotion();
                        dataGenerator.Render();
                        Text = String.Format("{0:F0} fps; {1} fragments; {2:F3} ms/frag",
                                             dataGenerator.FPS,
                                             dataGenerator.NumberOfFragmentsRendered,
                                             dataGenerator.ActualRenderTime.TotalMilliseconds / dataGenerator.NumberOfFragmentsRendered);
                    }

                    dataGenerator.HighQualityRender();
                } else {
                    graphics.Clear(Color.White);
                }
                while(!restartRenderLoop && !this.IsDisposed) {
                    Application.DoEvents();
                    Thread.Sleep(10);
                }
            }
        }
Exemplo n.º 3
0
 public BitmapCacheItem(Renderer.Texture texture, int x, int y)
 {
     this.texture = texture;
     this.x = x;
     this.y = y;
 }