public class FrameBuffer
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
int |
height |
int[] |
pixel_buffer |
int |
width |
double[] |
z_buffer |
Constructor and Description |
---|
FrameBuffer(int w,
int h)
Construct a FrameBuffer with the given dimensions.
|
FrameBuffer(java.lang.String inputFileName)
Construct a FrameBuffer from a PPM image file.
|
Modifier and Type | Method and Description |
---|---|
void |
clearFB(java.awt.Color c)
Clear the framebuffer (set a background color)
and clear the framebuffer's z-buffer.
|
void |
clearVP(java.awt.Color c)
Clear the viewport (set a background color)
and clear the viewport's z-buffer.
|
void |
clearzFB()
Clear the framebuffer's z-buffer (the depth buffer).
|
void |
clearzVP()
Clear the viewport's z-buffer (the depth buffer).
|
FrameBuffer |
convertVP2FB()
Convert the viewport into a framebuffer.
|
FrameBuffer |
convertZB2FB()
Convert the z-buffer into a framebuffer that holds
a gray scale color value representing each pixels
"depth".
|
void |
dumpFB2File(java.lang.String filename)
Write the framebuffer to the specified file.
|
void |
dumpPixels2File(int ul_x,
int ul_y,
int lr_x,
int lr_y,
java.lang.String filename)
Write a rectangular sub array of pixels to the specified file.
|
void |
dumpVP2File(java.lang.String filename)
Write the viewport to the specified file.
|
void |
fbTest()
A simple test of the framebuffer.
|
double |
getDepthFB(int x,
int y)
Get the depth of the pixel with coordinates
(x,y) in the framebuffer.
|
double |
getDepthVP(int x,
int y)
Get the depth of the pixel with coordinates
(x,y) relative to the current viewport.
|
int |
getHeightFB()
Get the height of the framebuffer.
|
int |
getHeightVP()
Get the height of the viewport.
|
java.awt.Color |
getPixelFB(int x,
int y)
Get the color of the pixel with coordinates
(x,y) in the framebuffer.
|
java.awt.Color |
getPixelVP(int x,
int y)
Get the color of the pixel with coordinates
(x,y) relative to the current viewport.
|
int |
getWidthFB()
Get the width of the framebuffer.
|
int |
getWidthVP()
Get the width of the viewport.
|
static void |
main(java.lang.String[] args)
A main() method for testing the FrameBuffer class.
|
void |
setPixelFB(int x,
int y,
java.awt.Color c)
Set the color of the pixel with coordinates
(x,y) in the framebuffer.
|
void |
setPixelFB(int x,
int y,
java.awt.Color c,
double z)
Set the color and depth of the pixel with coordinates
(x,y) in the framebuffer.
|
void |
setPixelFB(int x,
int y,
double z)
Set the depth of the pixel with coordinates
(x,y) in the framebuffer.
|
void |
setPixelVP(int x,
int y,
java.awt.Color c)
Set the color of the pixel with coordinates
(x,y) relative to the current viewport.
|
void |
setPixelVP(int x,
int y,
java.awt.Color c,
double z)
Set the color and depth of the pixel with coordinates
(x,y) relative to the current viewport.
|
void |
setPixelVP(int x,
int y,
double z)
Set the depth of the pixel with coordinates
(x,y) relative to the current viewport.
|
void |
setViewport(int vp_ul_x,
int vp_ul_y,
int width,
int height)
Set the coordinates, within the FrameBuffer, of the
viewport's upper-left-hand corner, width, and height.
|
public int width
public int height
public int[] pixel_buffer
public double[] z_buffer
public FrameBuffer(int w, int h)
w
- Width of the FrameBuffer.h
- Height of the FrameBuffer.public FrameBuffer(java.lang.String inputFileName)
inputFileName
- Must name a PPM image file with magic number P6.public int getWidthFB()
public int getHeightFB()
public void clearFB(java.awt.Color c)
public void clearzFB()
public void setViewport(int vp_ul_x, int vp_ul_y, int width, int height)
public int getWidthVP()
public int getHeightVP()
public void clearVP(java.awt.Color c)
public void clearzVP()
public java.awt.Color getPixelFB(int x, int y)
public double getDepthFB(int x, int y)
public void setPixelFB(int x, int y, java.awt.Color c)
public void setPixelFB(int x, int y, double z)
public void setPixelFB(int x, int y, java.awt.Color c, double z)
public java.awt.Color getPixelVP(int x, int y)
public double getDepthVP(int x, int y)
public void setPixelVP(int x, int y, java.awt.Color c)
public void setPixelVP(int x, int y, double z)
public void setPixelVP(int x, int y, java.awt.Color c, double z)
public FrameBuffer convertZB2FB()
public FrameBuffer convertVP2FB()
public void dumpFB2File(java.lang.String filename)
public void dumpVP2File(java.lang.String filename)
public void dumpPixels2File(int ul_x, int ul_y, int lr_x, int lr_y, java.lang.String filename)
public void fbTest()
public static void main(java.lang.String[] args)