X-Git-Url: http://www2.svjatoslav.eu/gitweb/?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Feu%2Fsvjatoslav%2Fsixth%2Fe3d%2Fgui%2FRenderingContext.java;h=63ff0d9abb88fd6fd05b0cdfe36d64a5bce6f43e;hb=324c5f8de858634643f8dd201cfcd99faa23af17;hp=c5c42f602a578d16a7a910ae60e365cfc1189f7f;hpb=a38bc412f8c6ae6c8fdf9466ae9b2073c2a73614;p=sixth-3d.git diff --git a/src/main/java/eu/svjatoslav/sixth/e3d/gui/RenderingContext.java b/src/main/java/eu/svjatoslav/sixth/e3d/gui/RenderingContext.java index c5c42f6..63ff0d9 100644 --- a/src/main/java/eu/svjatoslav/sixth/e3d/gui/RenderingContext.java +++ b/src/main/java/eu/svjatoslav/sixth/e3d/gui/RenderingContext.java @@ -1,5 +1,5 @@ /* - * Sixth 3D engine. Author: Svjatoslav Agejenko. + * Sixth 3D engine. Author: Svjatoslav Agejenko. * This project is released under Creative Commons Zero (CC0) license. */ package eu.svjatoslav.sixth.e3d.gui; @@ -13,13 +13,32 @@ import java.awt.image.BufferedImage; import java.awt.image.DataBufferByte; import java.awt.image.WritableRaster; +/** + * Rendering context that contains all the information that is needed to render the scene. + */ + public class RenderingContext { public static final int bufferedImageType = BufferedImage.TYPE_4BYTE_ABGR; + public final Graphics2D graphics; + + /** + * Pixels of the rendering area. + * Each pixel is represented by 4 bytes: alpha, blue, green, red. + */ public final byte[] pixels; + + /** + * Width of the rendering area in pixels. + */ public final int width; + + /** + * Height of the rendering area in pixels. + */ public final int height; + /** * Center of the screen in screen space (pixels). * This is the point where (0,0) coordinate of the world space is rendered. @@ -41,12 +60,6 @@ public class RenderingContext { * UI component that mouse is currently hovering over. */ private MouseInteractionController objectPreviouslyUnderMouseCursor; - - public void prepareForNewFrameRendering(){ - mouseEvent = null; - currentObjectUnderMouseCursor = null; - } - /** * Mouse click event that needs to be processed. * This event is processed only once per frame. @@ -56,29 +69,11 @@ public class RenderingContext { * This field is set to null after the event is processed. */ private MouseEvent mouseEvent; - - public void setMouseEvent(MouseEvent mouseEvent) { - this.mouseEvent = mouseEvent; - } - - public MouseEvent getMouseEvent() { - return mouseEvent; - } - /** * UI component that mouse is currently hovering over. */ private MouseInteractionController currentObjectUnderMouseCursor; - /** - * Called when given object was detected under mouse cursor, while processing {@link #mouseEvent}. - * Because objects are rendered back to front. The last method caller will set the top-most object, if - * there are multiple objects under mouse cursor. - */ - public void setCurrentObjectUnderMouseCursor(MouseInteractionController currentObjectUnderMouseCursor) { - this.currentObjectUnderMouseCursor = currentObjectUnderMouseCursor; - } - public RenderingContext(final int width, final int height) { this.width = width; this.height = height; @@ -96,6 +91,28 @@ public class RenderingContext { graphics.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON); } + public void prepareForNewFrameRendering() { + mouseEvent = null; + currentObjectUnderMouseCursor = null; + } + + public MouseEvent getMouseEvent() { + return mouseEvent; + } + + public void setMouseEvent(MouseEvent mouseEvent) { + this.mouseEvent = mouseEvent; + } + + /** + * Called when given object was detected under mouse cursor, while processing {@link #mouseEvent}. + * Because objects are rendered back to front. The last method caller will set the top-most object, if + * there are multiple objects under mouse cursor. + */ + public void setCurrentObjectUnderMouseCursor(MouseInteractionController currentObjectUnderMouseCursor) { + this.currentObjectUnderMouseCursor = currentObjectUnderMouseCursor; + } + /** * @return true if view update is needed as a consequence of this mouse event. */