projet-rendu/PainterShader.java

31 lines
715 B
Java
Raw Normal View History

2022-04-12 10:08:58 +00:00
import algebra.*;
import java.awt.*;
/**
* Simple shader that just copy the interpolated color to the screen,
* taking the depth of the fragment into acount.
* @author: cdehais
*/
public class PainterShader extends Shader {
DepthBuffer depth;
public PainterShader (GraphicsWrapper screen) {
super (screen);
depth = new DepthBuffer (screen.getWidth (), screen.getHeight ());
}
public void shade (Fragment fragment) {
if (depth.testFragment (fragment)) {
screen.setPixel (fragment.getX (), fragment.getY (), fragment.getColor ());
depth.writeFragment (fragment);
}
}
public void reset () {
depth.clear ();
}
}