All Downloads are FREE. Search and download functionalities are using the official Maven repository.

se.llbit.chunky.renderer.Renderer Maven / Gradle / Ivy

There is a newer version: 1.4.5
Show newest version
/*
 * Copyright (c) 2016 Jesper Öqvist 
 *
 * This file is part of Chunky.
 *
 * Chunky is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * Chunky is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * You should have received a copy of the GNU General Public License
 * along with Chunky.  If not, see .
 */
package se.llbit.chunky.renderer;

import se.llbit.chunky.renderer.scene.Scene;
import se.llbit.chunky.resources.BitmapImage;
import se.llbit.util.TaskTracker;

import java.util.function.BiConsumer;
import java.util.function.Consumer;

/**
 * A renderer renders to a buffered image which is displayed by a render canvas.
 *
 * @author Jesper Öqvist 
 */
public interface Renderer {
  void setSceneProvider(SceneProvider sceneProvider);

  void setCanvas(Repaintable canvas);

  /**
   * Instructs the renderer to change its CPU load.
   */
  void setCPULoad(int loadPercent);

  /**
   * Instructs the renderer to use the specified number of worker threads.
   */
  void setNumThreads(int numThreads);

  /**
   * Set a listener for render completion.
   *
   * @param listener a listener which is passed the total rendering
   * time and average samples per second.
   */
  void setOnRenderCompleted(BiConsumer listener);

  /**
   * Set a listener for frame completion.
   *
   * @param listener a listener which is called when a frame completes
   * with the current scene and the current samples per pixel.
   */
  void setOnFrameCompleted(BiConsumer listener);

  void setSnapshotControl(SnapshotControl callback);

  void setRenderTask(TaskTracker.Task task);

  void addRenderListener(RenderStatusListener listener);

  void removeRenderListener(RenderStatusListener listener);

  void withBufferedImage(Consumer bitmap);

  interface SampleBufferConsumer {
    void accept(double[] samples, int width, int height);
  }

  void addSceneStatusListener(SceneStatusListener listener);

  void removeSceneStatusListener(SceneStatusListener listener);

  RenderStatus getRenderStatus();

  /**
   * Start up the renderer.
   *
   * 

This should start all worker threads used by the renderer. */ void start(); /** * Wait for the renderer to terminate. This should only be done * in headless rendering, otherwise the renderer will not automatically * shut down after the render completes. * @throws InterruptedException */ void join() throws InterruptedException; void withSampleBufferProtected(SampleBufferConsumer consumer); /** * Shut down the renderer. * *

This should interrupt all worker threads used by the renderer. */ void shutdown(); }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy