diff --git a/docs/src/progress/renderertodo.md b/docs/src/progress/renderertodo.md index d39fab00..6f039249 100644 --- a/docs/src/progress/renderertodo.md +++ b/docs/src/progress/renderertodo.md @@ -1891,6 +1891,7 @@ Convert Mesh.java to only use GL45 Material and Mesh cleanup work Texture class cleanup work OS data wrapper +Renderer code cleanup diff --git a/src/main/java/electrosphere/renderer/buffer/HomogenousInstancedArray.java b/src/main/java/electrosphere/renderer/buffer/HomogenousInstancedArray.java index 9950b558..450bf5aa 100644 --- a/src/main/java/electrosphere/renderer/buffer/HomogenousInstancedArray.java +++ b/src/main/java/electrosphere/renderer/buffer/HomogenousInstancedArray.java @@ -13,17 +13,31 @@ import electrosphere.renderer.RenderPipelineState; import electrosphere.renderer.buffer.HomogenousUniformBuffer.HomogenousBufferTypes; public class HomogenousInstancedArray { - //The type of this buffer - HomogenousBufferTypes type; - //The pointer for this buffer - int bufferPointer = -1; - //the bind point in the instance shader program for this buffer - int capacity = -1; - //attribute index for a regular buffer - int attributeIndex; - //attribute indices for a matrix buffer - int[] matrixAttributeIndices; + /** + * The type of this buffer + */ + private HomogenousBufferTypes type; + + /** + * The pointer for this buffer + */ + private int bufferPointer = -1; + + /** + * the bind point in the instance shader program for this buffer + */ + private int capacity = -1; + + /** + * attribute index for a regular buffer + */ + private int attributeIndex; + + /** + * attribute indices for a matrix buffer + */ + private int[] matrixAttributeIndices; /** * Constructor diff --git a/src/main/java/electrosphere/renderer/buffer/HomogenousUniformBuffer.java b/src/main/java/electrosphere/renderer/buffer/HomogenousUniformBuffer.java index 09302dda..ac873c00 100644 --- a/src/main/java/electrosphere/renderer/buffer/HomogenousUniformBuffer.java +++ b/src/main/java/electrosphere/renderer/buffer/HomogenousUniformBuffer.java @@ -33,15 +33,25 @@ public class HomogenousUniformBuffer { DOUBLE, } - //The type of this buffer - HomogenousBufferTypes type; + /** + * The type of this buffer + */ + private HomogenousBufferTypes type; - //The pointer for this buffer - int bufferPointer = -1; - //the bind point in the instance shader program for this buffer - int capacity = -1; - //uniform name - String uniformName; + /** + * The pointer for this buffer + */ + private int bufferPointer = -1; + + /** + * the bind point in the instance shader program for this buffer + */ + private int capacity = -1; + + /** + * uniform name + */ + private String uniformName; /** * Constructor diff --git a/src/main/java/electrosphere/renderer/buffer/ShaderAttribute.java b/src/main/java/electrosphere/renderer/buffer/ShaderAttribute.java index 6606d9e8..39819d7b 100644 --- a/src/main/java/electrosphere/renderer/buffer/ShaderAttribute.java +++ b/src/main/java/electrosphere/renderer/buffer/ShaderAttribute.java @@ -10,20 +10,25 @@ import electrosphere.renderer.buffer.HomogenousUniformBuffer.HomogenousBufferTyp */ public class ShaderAttribute { - //for single data types that map 1-1 with attributes (float, vec3, vec4, etc) - int attributeIndex = -1; - //for multi-attribute index types (mat4f, mat4d, etc) - int[] attributeIndices; + /** + * for single data types that map 1-1 with attributes (float, vec3, vec4, etc) + */ + private int attributeIndex = -1; + + /** + * for multi-attribute index types (mat4f, mat4d, etc) + */ + private int[] attributeIndices; /** * The name of the attribute */ - String name; + private String name; /** * The type of the attribute */ - HomogenousBufferTypes type; + private HomogenousBufferTypes type; /** diff --git a/src/main/java/electrosphere/renderer/buffer/ShaderStorageBuffer.java b/src/main/java/electrosphere/renderer/buffer/ShaderStorageBuffer.java index cb4b7680..8685d109 100644 --- a/src/main/java/electrosphere/renderer/buffer/ShaderStorageBuffer.java +++ b/src/main/java/electrosphere/renderer/buffer/ShaderStorageBuffer.java @@ -18,12 +18,12 @@ public class ShaderStorageBuffer implements UniformBlockBinding { /** * The id for the buffer */ - int id; + private int id; /** * The java buffer associated with the SSBO */ - ByteBuffer buffer; + private ByteBuffer buffer; /** * Constructor diff --git a/src/main/java/electrosphere/renderer/framebuffer/Framebuffer.java b/src/main/java/electrosphere/renderer/framebuffer/Framebuffer.java index dc54fd71..47f41ad8 100644 --- a/src/main/java/electrosphere/renderer/framebuffer/Framebuffer.java +++ b/src/main/java/electrosphere/renderer/framebuffer/Framebuffer.java @@ -14,13 +14,8 @@ import java.util.Map; import java.util.concurrent.TimeUnit; import org.lwjgl.BufferUtils; -import org.lwjgl.opengl.GL40; import org.lwjgl.opengl.GL45; -import static org.lwjgl.opengl.GL11.GL_NONE; -import static org.lwjgl.opengl.GL11.GL_TEXTURE; -import static org.lwjgl.opengl.GL30.GL_FRAMEBUFFER; - /** * Framebuffer object */ @@ -31,22 +26,36 @@ public class Framebuffer { */ public static final int DEFAULT_FRAMEBUFFER_POINTER = 0; - //the pointer to the framebuffer - int framebufferPointer; - //the mipmap level - int mipMap = -1; - //the map of attachment point to texture object - Map attachTextureMap = new HashMap(); - //attached texture - Texture texture; - //the depth texture for the framebuffer - Texture depthTexture; + /** + * the pointer to the framebuffer + */ + private int framebufferPointer; + + /** + * the mipmap level + */ + private int mipMap = -1; + + /** + * the map of attachment point to texture object + */ + private Map attachTextureMap = new HashMap(); + + /** + * attached texture + */ + private Texture texture; + + /** + * the depth texture for the framebuffer + */ + private Texture depthTexture; /** * Creates a framebuffer */ public Framebuffer(){ - this.framebufferPointer = GL40.glGenFramebuffers(); + this.framebufferPointer = GL45.glGenFramebuffers(); Globals.renderingEngine.checkError(); } @@ -87,7 +96,7 @@ public class Framebuffer { * @param openGLState The opengl state */ public void bind(OpenGLState openGLState){ - openGLState.glBindFramebuffer(GL40.GL_FRAMEBUFFER, this.framebufferPointer); + openGLState.glBindFramebuffer(GL45.GL_FRAMEBUFFER, this.framebufferPointer); } /** @@ -98,7 +107,7 @@ public class Framebuffer { if(this.framebufferPointer == DEFAULT_FRAMEBUFFER_POINTER){ throw new Error("Pointer is the default framebuffer!"); } - return GL45.glCheckNamedFramebufferStatus(this.framebufferPointer,GL40.GL_FRAMEBUFFER) == GL40.GL_FRAMEBUFFER_COMPLETE; + return GL45.glCheckNamedFramebufferStatus(this.framebufferPointer,GL45.GL_FRAMEBUFFER) == GL45.GL_FRAMEBUFFER_COMPLETE; } @@ -109,13 +118,13 @@ public class Framebuffer { */ public void shouldBeComplete(OpenGLState openGLState) throws Exception{ if(!this.isComplete(openGLState)){ - int colorAttach0 = GL45.glGetFramebufferAttachmentParameteri(GL_FRAMEBUFFER, GL45.GL_COLOR_ATTACHMENT0, GL45.GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE); + int colorAttach0 = GL45.glGetFramebufferAttachmentParameteri(GL45.GL_FRAMEBUFFER, GL45.GL_COLOR_ATTACHMENT0, GL45.GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE); String attach0Type = ""; switch(colorAttach0){ - case GL_NONE: { + case GL45.GL_NONE: { attach0Type = "GL_NONE"; } break; - case GL_TEXTURE: { + case GL45.GL_TEXTURE: { attach0Type = " GL_TEXTURE"; } break; } @@ -150,14 +159,14 @@ public class Framebuffer { * Frees the framebuffer */ public void free(){ - GL40.glDeleteFramebuffers(framebufferPointer); + GL45.glDeleteFramebuffers(framebufferPointer); } /** * Blocks the thread until the framebuffer has compiled */ public void blockUntilCompiled(){ - while(GL45.glCheckNamedFramebufferStatus(this.framebufferPointer,GL40.GL_FRAMEBUFFER) != GL40.GL_FRAMEBUFFER_UNDEFINED){ + while(GL45.glCheckNamedFramebufferStatus(this.framebufferPointer,GL45.GL_FRAMEBUFFER) != GL45.GL_FRAMEBUFFER_UNDEFINED){ try { TimeUnit.MILLISECONDS.sleep(1); } catch (InterruptedException ex) { @@ -171,26 +180,26 @@ public class Framebuffer { * @return The status */ public String getStatus(){ - switch(GL45.glCheckNamedFramebufferStatus(this.framebufferPointer,GL40.GL_FRAMEBUFFER)){ - case GL40.GL_FRAMEBUFFER_UNDEFINED: { + switch(GL45.glCheckNamedFramebufferStatus(this.framebufferPointer,GL45.GL_FRAMEBUFFER)){ + case GL45.GL_FRAMEBUFFER_UNDEFINED: { return "The specified framebuffer is the default read or draw framebuffer, but the default framebuffer does not exist."; } - case GL40.GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT: { + case GL45.GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT: { return "Any of the framebuffer attachment points are framebuffer incomplete."; } - case GL40.GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT: { + case GL45.GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT: { return "The framebuffer does not have at least one image attached to it."; } - case GL40.GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER: { + case GL45.GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER: { return "The value of GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE is GL_NONE for any color attachment point(s) named by GL_DRAW_BUFFERi."; } - case GL40.GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER: { + case GL45.GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER: { return "GL_READ_BUFFER is not GL_NONE and the value of GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE is GL_NONE for the color attachment point named by GL_READ_BUFFER."; } - case GL40.GL_FRAMEBUFFER_UNSUPPORTED: { + case GL45.GL_FRAMEBUFFER_UNSUPPORTED: { return "The combination of internal formats of the attached images violates an implementation-dependent set of restrictions."; } - case GL40.GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE: { + case GL45.GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE: { return "The value of GL_RENDERBUFFER_SAMPLES is not the same for all attached renderbuffers; if the value of GL_TEXTURE_SAMPLES is the not same for all attached textures; or, if the attached images are a mix of renderbuffers and textures, the value of GL_RENDERBUFFER_SAMPLES does not match the value of GL_TEXTURE_SAMPLES."; } case 0: { @@ -235,19 +244,19 @@ public class Framebuffer { if(texture.getTexturePointer() == Texture.UNINITIALIZED_TEXTURE){ throw new IllegalStateException("Trying to attach uninitialized image to frame buffer!"); } - if(!GL40.glIsTexture(texture.getTexturePointer())){ + if(!GL45.glIsTexture(texture.getTexturePointer())){ throw new IllegalStateException("Tried to attach incomplete texture to framebuffer!"); } - openGLState.glBindFramebuffer(GL40.GL_FRAMEBUFFER, this.framebufferPointer); - GL40.glFramebufferTexture2D(GL40.GL_FRAMEBUFFER, GL40.GL_COLOR_ATTACHMENT0 + attachmentNum, GL40.GL_TEXTURE_2D, texture.getTexturePointer(), 0); + openGLState.glBindFramebuffer(GL45.GL_FRAMEBUFFER, this.framebufferPointer); + GL45.glFramebufferTexture2D(GL45.GL_FRAMEBUFFER, GL45.GL_COLOR_ATTACHMENT0 + attachmentNum, GL45.GL_TEXTURE_2D, texture.getTexturePointer(), 0); Globals.renderingEngine.checkError(); // check the attachment slot - int colorAttach0 = GL45.glGetFramebufferAttachmentParameteri(GL40.GL_FRAMEBUFFER, GL45.GL_COLOR_ATTACHMENT0 + attachmentNum, GL45.GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE); + int colorAttach0 = GL45.glGetFramebufferAttachmentParameteri(GL45.GL_FRAMEBUFFER, GL45.GL_COLOR_ATTACHMENT0 + attachmentNum, GL45.GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE); switch(colorAttach0){ - case GL_NONE: { + case GL45.GL_NONE: { throw new Error("Failed to attach!"); } - case GL_TEXTURE: { + case GL45.GL_TEXTURE: { } break; } Globals.renderingEngine.defaultFramebuffer.bind(openGLState); @@ -265,12 +274,12 @@ public class Framebuffer { if(depthTexture.getTexturePointer() == Texture.UNINITIALIZED_TEXTURE){ throw new IllegalStateException("Trying to attach uninitialized image to frame buffer!"); } - if(!GL40.glIsTexture(depthTexture.getTexturePointer())){ + if(!GL45.glIsTexture(depthTexture.getTexturePointer())){ throw new IllegalStateException("Tried to attach incomplete texture to framebuffer!"); } this.depthTexture = depthTexture; - openGLState.glBindFramebuffer(GL40.GL_FRAMEBUFFER, this.framebufferPointer); - GL40.glFramebufferTexture2D(GL40.GL_FRAMEBUFFER, GL40.GL_DEPTH_ATTACHMENT, GL40.GL_TEXTURE_2D, this.depthTexture.getTexturePointer(), 0); + openGLState.glBindFramebuffer(GL45.GL_FRAMEBUFFER, this.framebufferPointer); + GL45.glFramebufferTexture2D(GL45.GL_FRAMEBUFFER, GL45.GL_DEPTH_ATTACHMENT, GL45.GL_TEXTURE_2D, this.depthTexture.getTexturePointer(), 0); Globals.renderingEngine.checkError(); Globals.renderingEngine.defaultFramebuffer.bind(openGLState); } @@ -286,20 +295,20 @@ public class Framebuffer { int height = openGLState.getViewport().y; //the formats we want opengl to return with - int pixelFormat = GL40.GL_RGBA; - int type = GL40.GL_UNSIGNED_BYTE; + int pixelFormat = GL45.GL_RGBA; + int type = GL45.GL_UNSIGNED_BYTE; this.bind(openGLState); if(this.framebufferPointer == Framebuffer.DEFAULT_FRAMEBUFFER_POINTER){ //this is the default framebuffer, read from backbuffer because it is default - GL40.glReadBuffer(GL40.GL_BACK); + GL45.glReadBuffer(GL45.GL_BACK); //set viewport openGLState.glViewport(Globals.WINDOW_WIDTH, Globals.WINDOW_HEIGHT); } else if(attachTextureMap.containsKey(0)){ //this is NOT the default framebuffer, read from the first color attachment - GL40.glReadBuffer(GL40.GL_COLOR_ATTACHMENT0); + GL45.glReadBuffer(GL45.GL_COLOR_ATTACHMENT0); //set viewport Texture texture = attachTextureMap.get(0); @@ -326,7 +335,7 @@ public class Framebuffer { if(buffer == null || buffer.limit() < bufferSize){ throw new Error("Failed to create buffer!"); } - GL40.glReadPixels(offsetX, offsetY, width, height, pixelFormat, type, buffer); + GL45.glReadPixels(offsetX, offsetY, width, height, pixelFormat, type, buffer); Globals.renderingEngine.checkError(); //convert to a buffered images rVal = new BufferedImage(width,height,BufferedImage.TYPE_INT_ARGB); @@ -337,7 +346,7 @@ public class Framebuffer { int green = buffer.get(i + 1) & 0xFF; int blue = buffer.get(i + 2) & 0xFF; int alpha = 255; - if(pixelFormat == GL40.GL_RGBA){ + if(pixelFormat == GL45.GL_RGBA){ alpha = buffer.get(i + 3) & 0xFF; } rVal.setRGB(x, height - (y + 1), (alpha << 24) | (red << 16) | (green << 8) | blue); @@ -358,10 +367,10 @@ public class Framebuffer { private static int pixelFormatToBytes(int format, int type){ int multiplier = 1; switch(format){ - case GL40.GL_RGBA: { + case GL45.GL_RGBA: { multiplier = 4; } break; - case GL40.GL_RGB: { + case GL45.GL_RGB: { multiplier = 3; } break; default: { diff --git a/src/main/java/electrosphere/renderer/framebuffer/FramebufferUtils.java b/src/main/java/electrosphere/renderer/framebuffer/FramebufferUtils.java index 0dab34cc..5d8f7003 100644 --- a/src/main/java/electrosphere/renderer/framebuffer/FramebufferUtils.java +++ b/src/main/java/electrosphere/renderer/framebuffer/FramebufferUtils.java @@ -8,38 +8,8 @@ import electrosphere.renderer.texture.Texture; import java.nio.IntBuffer; import org.lwjgl.BufferUtils; -import org.lwjgl.opengl.GL40; import org.lwjgl.opengl.GL45; -import static org.lwjgl.opengl.GL11.GL_DEPTH_COMPONENT; -import static org.lwjgl.opengl.GL11.GL_FLOAT; -import static org.lwjgl.opengl.GL11.GL_LINEAR; -import static org.lwjgl.opengl.GL11.GL_NEAREST; -import static org.lwjgl.opengl.GL11.GL_NONE; -import static org.lwjgl.opengl.GL11.GL_RED; -import static org.lwjgl.opengl.GL11.GL_RGB; -import static org.lwjgl.opengl.GL11.GL_RGBA; -import static org.lwjgl.opengl.GL11.GL_SHORT; -import static org.lwjgl.opengl.GL11.GL_TEXTURE_WRAP_S; -import static org.lwjgl.opengl.GL11.GL_TEXTURE_WRAP_T; -import static org.lwjgl.opengl.GL11.GL_UNSIGNED_BYTE; -import static org.lwjgl.opengl.GL12.GL_CLAMP_TO_EDGE; -import static org.lwjgl.opengl.GL13.GL_CLAMP_TO_BORDER; -import static org.lwjgl.opengl.GL30.GL_COLOR_ATTACHMENT0; -import static org.lwjgl.opengl.GL30.GL_COLOR_ATTACHMENT1; -import static org.lwjgl.opengl.GL30.GL_DEPTH24_STENCIL8; -import static org.lwjgl.opengl.GL30.GL_DEPTH_STENCIL_ATTACHMENT; -import static org.lwjgl.opengl.GL30.GL_FRAMEBUFFER; -import static org.lwjgl.opengl.GL30.GL_RENDERBUFFER; -import static org.lwjgl.opengl.GL30.GL_HALF_FLOAT; -import static org.lwjgl.opengl.GL30.glBindRenderbuffer; -import static org.lwjgl.opengl.GL30.glFramebufferRenderbuffer; -import static org.lwjgl.opengl.GL30.glGenRenderbuffers; -import static org.lwjgl.opengl.GL30.glRenderbufferStorage; -import static org.lwjgl.opengl.GL45.glNamedFramebufferDrawBuffer; -import static org.lwjgl.opengl.GL45.glNamedFramebufferDrawBuffers; -import static org.lwjgl.opengl.GL45.glNamedFramebufferReadBuffer; - /** * Utilities for framebuffer creation */ @@ -48,17 +18,17 @@ public class FramebufferUtils { public static Texture generateScreenTextureColor(OpenGLState openGLState, int width, int height){ Texture texture = new Texture(); texture.bind(openGLState); - texture.glTexImage2D(openGLState, width, height, GL_RGB, GL45.GL_UNSIGNED_INT); - texture.setMinFilter(openGLState, GL_LINEAR); - texture.setMagFilter(openGLState, GL_LINEAR); + texture.glTexImage2D(openGLState, width, height, GL45.GL_RGB, GL45.GL_UNSIGNED_INT); + texture.setMinFilter(openGLState, GL45.GL_LINEAR); + texture.setMagFilter(openGLState, GL45.GL_LINEAR); //these make sure the texture actually clamps to the borders of the quad - texture.setWrap(openGLState, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); - texture.setWrap(openGLState, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); + texture.setWrap(openGLState, GL45.GL_TEXTURE_WRAP_S, GL45.GL_CLAMP_TO_EDGE); + texture.setWrap(openGLState, GL45.GL_TEXTURE_WRAP_T, GL45.GL_CLAMP_TO_EDGE); texture.setBorderColor(openGLState, new float[]{0,0,0,1}); //guarantees that the texture object has actually been created (calling gen buffers does not guarantee object creation) texture.bind(openGLState); - openGLState.glBindTexture(GL40.GL_TEXTURE_2D, Texture.DEFAULT_TEXTURE); + openGLState.glBindTexture(GL45.GL_TEXTURE_2D, Texture.DEFAULT_TEXTURE); texture.checkStatus(openGLState); return texture; @@ -67,17 +37,17 @@ public class FramebufferUtils { public static Texture generateScreenTextureColorAlpha(OpenGLState openGLState, int width, int height){ Texture texture = new Texture(); texture.bind(openGLState); - texture.glTexImage2D(openGLState, width, height, GL_RGBA, GL45.GL_UNSIGNED_INT); - texture.setMinFilter(openGLState, GL_LINEAR); - texture.setMagFilter(openGLState, GL_LINEAR); + texture.glTexImage2D(openGLState, width, height, GL45.GL_RGBA, GL45.GL_UNSIGNED_INT); + texture.setMinFilter(openGLState, GL45.GL_LINEAR); + texture.setMagFilter(openGLState, GL45.GL_LINEAR); //these make sure the texture actually clamps to the borders of the quad - texture.setWrap(openGLState, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); - texture.setWrap(openGLState, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); + texture.setWrap(openGLState, GL45.GL_TEXTURE_WRAP_S, GL45.GL_CLAMP_TO_EDGE); + texture.setWrap(openGLState, GL45.GL_TEXTURE_WRAP_T, GL45.GL_CLAMP_TO_EDGE); texture.setBorderColor(openGLState, new float[]{0,0,0,1}); //guarantees that the texture object has actually been created (calling gen buffers does not guarantee object creation) texture.bind(openGLState); - openGLState.glBindTextureUnitForce(GL45.GL_TEXTURE0, Texture.DEFAULT_TEXTURE, GL40.GL_TEXTURE_2D); + openGLState.glBindTextureUnitForce(GL45.GL_TEXTURE0, Texture.DEFAULT_TEXTURE, GL45.GL_TEXTURE_2D); texture.checkStatus(openGLState); return texture; @@ -86,18 +56,18 @@ public class FramebufferUtils { public static Texture generateScreenTextureDepth(OpenGLState openGLState, int width, int height){ Texture texture = new Texture(); texture.bind(openGLState); - texture.glTexImage2D(openGLState, width, height, GL_DEPTH_COMPONENT, GL_FLOAT); + texture.glTexImage2D(openGLState, width, height, GL45.GL_DEPTH_COMPONENT, GL45.GL_FLOAT); - texture.setMinFilter(openGLState, GL_LINEAR); - texture.setMagFilter(openGLState, GL_LINEAR); + texture.setMinFilter(openGLState, GL45.GL_LINEAR); + texture.setMagFilter(openGLState, GL45.GL_LINEAR); //these make sure the texture actually clamps to the borders of the quad - texture.setWrap(openGLState, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); - texture.setWrap(openGLState, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); + texture.setWrap(openGLState, GL45.GL_TEXTURE_WRAP_S, GL45.GL_CLAMP_TO_EDGE); + texture.setWrap(openGLState, GL45.GL_TEXTURE_WRAP_T, GL45.GL_CLAMP_TO_EDGE); texture.setBorderColor(openGLState, new float[]{0,0,0,1}); //guarantees that the texture object has actually been created (calling gen buffers does not guarantee object creation) texture.bind(openGLState); - openGLState.glBindTextureUnitForce(GL45.GL_TEXTURE0, Texture.DEFAULT_TEXTURE, GL40.GL_TEXTURE_2D); + openGLState.glBindTextureUnitForce(GL45.GL_TEXTURE0, Texture.DEFAULT_TEXTURE, GL45.GL_TEXTURE_2D); texture.checkStatus(openGLState); return texture; @@ -132,24 +102,24 @@ public class FramebufferUtils { buffer.bind(openGLState); //texture Texture texture = new Texture(); - texture.glTexImage2D(openGLState, Globals.WINDOW_WIDTH, Globals.WINDOW_HEIGHT, GL_RGB, GL_UNSIGNED_BYTE); - texture.setMinFilter(openGLState, GL_LINEAR); - texture.setMagFilter(openGLState, GL_LINEAR); + texture.glTexImage2D(openGLState, Globals.WINDOW_WIDTH, Globals.WINDOW_HEIGHT, GL45.GL_RGB, GL45.GL_UNSIGNED_BYTE); + texture.setMinFilter(openGLState, GL45.GL_LINEAR); + texture.setMagFilter(openGLState, GL45.GL_LINEAR); //these make sure the texture actually clamps to the borders of the quad - texture.setWrap(openGLState, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); - texture.setWrap(openGLState, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); + texture.setWrap(openGLState, GL45.GL_TEXTURE_WRAP_S, GL45.GL_CLAMP_TO_EDGE); + texture.setWrap(openGLState, GL45.GL_TEXTURE_WRAP_T, GL45.GL_CLAMP_TO_EDGE); texture.checkStatus(openGLState); //bind texture to fbo buffer.setMipMapLevel(0); buffer.attachTexture(openGLState,texture); //renderbuffer - int renderBuffer = glGenRenderbuffers(); - glBindRenderbuffer(GL_RENDERBUFFER, renderBuffer); + int renderBuffer = GL45.glGenRenderbuffers(); + GL45.glBindRenderbuffer(GL45.GL_RENDERBUFFER, renderBuffer); Globals.renderingEngine.checkError(); - glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH24_STENCIL8, Globals.WINDOW_WIDTH, Globals.WINDOW_HEIGHT); + GL45.glRenderbufferStorage(GL45.GL_RENDERBUFFER, GL45.GL_DEPTH24_STENCIL8, Globals.WINDOW_WIDTH, Globals.WINDOW_HEIGHT); Globals.renderingEngine.checkError(); //bind rbo to fbo - glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_RENDERBUFFER, renderBuffer); + GL45.glFramebufferRenderbuffer(GL45.GL_FRAMEBUFFER, GL45.GL_DEPTH_STENCIL_ATTACHMENT, GL45.GL_RENDERBUFFER, renderBuffer); Globals.renderingEngine.checkError(); //check make sure compiled buffer.shouldBeComplete(openGLState); @@ -170,25 +140,25 @@ public class FramebufferUtils { buffer.bind(openGLState); //texture Texture texture = new Texture(); - texture.glTexImage2D(openGLState, width, height, GL_RGBA, GL_UNSIGNED_BYTE); - texture.setMinFilter(openGLState, GL_LINEAR); - texture.setMagFilter(openGLState, GL_LINEAR); + texture.glTexImage2D(openGLState, width, height, GL45.GL_RGBA, GL45.GL_UNSIGNED_BYTE); + texture.setMinFilter(openGLState, GL45.GL_LINEAR); + texture.setMagFilter(openGLState, GL45.GL_LINEAR); //these make sure the texture actually clamps to the borders of the quad - texture.setWrap(openGLState, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); - texture.setWrap(openGLState, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); + texture.setWrap(openGLState, GL45.GL_TEXTURE_WRAP_S, GL45.GL_CLAMP_TO_EDGE); + texture.setWrap(openGLState, GL45.GL_TEXTURE_WRAP_T, GL45.GL_CLAMP_TO_EDGE); texture.checkStatus(openGLState); //bind texture to fbo buffer.setMipMapLevel(0); buffer.attachTexture(openGLState,texture); //renderbuffer - int renderBuffer = glGenRenderbuffers(); - GL40.glBindRenderbuffer(GL_RENDERBUFFER, renderBuffer); + int renderBuffer = GL45.glGenRenderbuffers(); + GL45.glBindRenderbuffer(GL45.GL_RENDERBUFFER, renderBuffer); Globals.renderingEngine.checkError(); - GL40.glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH24_STENCIL8, width, height); + GL45.glRenderbufferStorage(GL45.GL_RENDERBUFFER, GL45.GL_DEPTH24_STENCIL8, width, height); Globals.renderingEngine.checkError(); //bind rbo to fbo buffer.bind(openGLState); - GL40.glFramebufferRenderbuffer(GL40.GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_RENDERBUFFER, renderBuffer); + GL45.glFramebufferRenderbuffer(GL45.GL_FRAMEBUFFER, GL45.GL_DEPTH_STENCIL_ATTACHMENT, GL45.GL_RENDERBUFFER, renderBuffer); Globals.renderingEngine.checkError(); //check make sure compiled buffer.shouldBeComplete(openGLState); @@ -204,7 +174,7 @@ public class FramebufferUtils { public static Renderbuffer generateScreensizeStencilDepthRenderbuffer(OpenGLState openGLState){ Renderbuffer buffer = new Renderbuffer(); buffer.bind(); - glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH24_STENCIL8, Globals.WINDOW_WIDTH, Globals.WINDOW_HEIGHT); + GL45.glRenderbufferStorage(GL45.GL_RENDERBUFFER, GL45.GL_DEPTH24_STENCIL8, Globals.WINDOW_WIDTH, Globals.WINDOW_HEIGHT); Globals.renderingEngine.checkError(); return buffer; } @@ -217,20 +187,20 @@ public class FramebufferUtils { //texture Texture texture = new Texture(); - texture.glTexImage2D(openGLState, ShadowMapPipeline.SHADOW_MAP_RESOLUTION, ShadowMapPipeline.SHADOW_MAP_RESOLUTION, GL_DEPTH_COMPONENT, GL_FLOAT); - texture.setMinFilter(openGLState, GL_NEAREST); - texture.setMagFilter(openGLState, GL_NEAREST); - texture.setWrap(openGLState, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_BORDER); - texture.setWrap(openGLState, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_BORDER); + texture.glTexImage2D(openGLState, ShadowMapPipeline.SHADOW_MAP_RESOLUTION, ShadowMapPipeline.SHADOW_MAP_RESOLUTION, GL45.GL_DEPTH_COMPONENT, GL45.GL_FLOAT); + texture.setMinFilter(openGLState, GL45.GL_NEAREST); + texture.setMagFilter(openGLState, GL45.GL_NEAREST); + texture.setWrap(openGLState, GL45.GL_TEXTURE_WRAP_S, GL45.GL_CLAMP_TO_BORDER); + texture.setWrap(openGLState, GL45.GL_TEXTURE_WRAP_T, GL45.GL_CLAMP_TO_BORDER); texture.setBorderColor(openGLState, new float[]{ 1.0f, 1.0f, 1.0f, 1.0f }); texture.checkStatus(openGLState); //bind texture to fbo buffer.setMipMapLevel(0); buffer.setDepthAttachment(openGLState,texture); - glNamedFramebufferDrawBuffer(buffer.getFramebufferPointer(), GL_NONE); + GL45.glNamedFramebufferDrawBuffer(buffer.getFramebufferPointer(), GL45.GL_NONE); Globals.renderingEngine.checkError(); - glNamedFramebufferReadBuffer(buffer.getFramebufferPointer(), GL_NONE); + GL45.glNamedFramebufferReadBuffer(buffer.getFramebufferPointer(), GL45.GL_NONE); Globals.renderingEngine.checkError(); @@ -244,11 +214,11 @@ public class FramebufferUtils { public static Texture generateDepthBufferTexture(OpenGLState openGLState, int width, int height){ Texture texture = new Texture(); - texture.glTexImage2D(openGLState, width, height, GL_DEPTH_COMPONENT, GL_SHORT); - texture.setMinFilter(openGLState, GL_NEAREST); - texture.setMagFilter(openGLState, GL_NEAREST); - texture.setWrap(openGLState, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_BORDER); - texture.setWrap(openGLState, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_BORDER); + texture.glTexImage2D(openGLState, width, height, GL45.GL_DEPTH_COMPONENT, GL45.GL_SHORT); + texture.setMinFilter(openGLState, GL45.GL_NEAREST); + texture.setMagFilter(openGLState, GL45.GL_NEAREST); + texture.setWrap(openGLState, GL45.GL_TEXTURE_WRAP_S, GL45.GL_CLAMP_TO_BORDER); + texture.setWrap(openGLState, GL45.GL_TEXTURE_WRAP_T, GL45.GL_CLAMP_TO_BORDER); texture.setBorderColor(openGLState, new float[]{ 1.0f, 1.0f, 1.0f, 1.0f }); texture.checkStatus(openGLState); return texture; @@ -262,9 +232,9 @@ public class FramebufferUtils { //bind texture to fbo buffer.setMipMapLevel(0); buffer.setDepthAttachment(openGLState,texture); - glNamedFramebufferDrawBuffer(buffer.getFramebufferPointer(), GL_NONE); + GL45.glNamedFramebufferDrawBuffer(buffer.getFramebufferPointer(), GL45.GL_NONE); Globals.renderingEngine.checkError(); - glNamedFramebufferReadBuffer(buffer.getFramebufferPointer(), GL_NONE); + GL45.glNamedFramebufferReadBuffer(buffer.getFramebufferPointer(), GL45.GL_NONE); Globals.renderingEngine.checkError(); @@ -277,18 +247,18 @@ public class FramebufferUtils { public static Texture generateOITAccumulatorTexture(OpenGLState openGLState, int width, int height){ Texture texture = new Texture(); - texture.setMinFilter(openGLState, GL_LINEAR); - texture.setMagFilter(openGLState, GL_LINEAR); - texture.glTexImage2D(openGLState, width, height, GL_RGBA, GL_HALF_FLOAT); + texture.setMinFilter(openGLState, GL45.GL_LINEAR); + texture.setMagFilter(openGLState, GL45.GL_LINEAR); + texture.glTexImage2D(openGLState, width, height, GL45.GL_RGBA, GL45.GL_HALF_FLOAT); texture.checkStatus(openGLState); return texture; } public static Texture generateOITRevealageTexture(OpenGLState openGLState, int width, int height){ Texture texture = new Texture(); - texture.setMinFilter(openGLState, GL_LINEAR); - texture.setMagFilter(openGLState, GL_LINEAR); - texture.glTexImage2D(openGLState, width, height, GL_RED, GL_FLOAT); + texture.setMinFilter(openGLState, GL45.GL_LINEAR); + texture.setMagFilter(openGLState, GL45.GL_LINEAR); + texture.glTexImage2D(openGLState, width, height, GL45.GL_RED, GL45.GL_FLOAT); texture.checkStatus(openGLState); return texture; } @@ -307,10 +277,10 @@ public class FramebufferUtils { // const GLenum transparentDrawBuffers[] = { GL_COLOR_ATTACHMENT0, GL_COLOR_ATTACHMENT1 }; // glDrawBuffers(2, transparentDrawBuffers); IntBuffer drawBuffers = BufferUtils.createIntBuffer(2); - drawBuffers.put(GL_COLOR_ATTACHMENT0); - drawBuffers.put(GL_COLOR_ATTACHMENT1); + drawBuffers.put(GL45.GL_COLOR_ATTACHMENT0); + drawBuffers.put(GL45.GL_COLOR_ATTACHMENT1); drawBuffers.flip(); - glNamedFramebufferDrawBuffers(buffer.getFramebufferPointer(),drawBuffers); + GL45.glNamedFramebufferDrawBuffers(buffer.getFramebufferPointer(),drawBuffers); Globals.renderingEngine.checkError(); //check make sure compiled diff --git a/src/main/java/electrosphere/renderer/framebuffer/Renderbuffer.java b/src/main/java/electrosphere/renderer/framebuffer/Renderbuffer.java index 9ccfe88d..c90a8164 100644 --- a/src/main/java/electrosphere/renderer/framebuffer/Renderbuffer.java +++ b/src/main/java/electrosphere/renderer/framebuffer/Renderbuffer.java @@ -1,29 +1,42 @@ package electrosphere.renderer.framebuffer; -import static org.lwjgl.opengl.GL30.GL_RENDERBUFFER; -import static org.lwjgl.opengl.GL30.glBindRenderbuffer; -import static org.lwjgl.opengl.GL30.glDeleteRenderbuffers; -import static org.lwjgl.opengl.GL30.glGenRenderbuffers; +import org.lwjgl.opengl.GL45; /** * A renderbuffer */ public class Renderbuffer { + /** + * The pointer for the renderbuffer + */ int renderbuffer; + /** + * Constructor + */ public Renderbuffer(){ - renderbuffer = glGenRenderbuffers(); + renderbuffer = GL45.glGenRenderbuffers(); } + /** + * Binds the renderbuffer + */ public void bind(){ - glBindRenderbuffer(GL_RENDERBUFFER, renderbuffer); + GL45.glBindRenderbuffer(GL45.GL_RENDERBUFFER, renderbuffer); } + /** + * Gets the render buffer id + * @return + */ public int getFramebufferID(){ return renderbuffer; } + /** + * Frees the render buffer + */ public void free(){ - glDeleteRenderbuffers(renderbuffer); + GL45.glDeleteRenderbuffers(renderbuffer); } } diff --git a/src/main/java/electrosphere/renderer/light/DirectionalLight.java b/src/main/java/electrosphere/renderer/light/DirectionalLight.java index 1b1863df..e7836bff 100644 --- a/src/main/java/electrosphere/renderer/light/DirectionalLight.java +++ b/src/main/java/electrosphere/renderer/light/DirectionalLight.java @@ -7,34 +7,63 @@ import org.joml.Vector3f; */ public class DirectionalLight { - //the direction of the light as a uniform vector - Vector3f direction; + /** + * the direction of the light as a uniform vector + */ + private Vector3f direction; - //the color - Vector3f color; + /** + * the color + */ + private Vector3f color; + /** + * Sets the direection of the directional light + * @param direction The direction + */ public void setDirection(Vector3f direction) { this.direction = direction; } + /** + * Sets the color of the light + * @param color The color + */ public void setColor(Vector3f color) { this.color = color; } + /** + * Gets the direction of the light + * @return The direction + */ public Vector3f getDirection() { return direction; } + /** + * Gets the color of the light + * @return The color + */ public Vector3f getColor() { return color; } + /** + * Constructor + * @param direction The direction of the light + */ public DirectionalLight(Vector3f direction){ this.direction = direction; color = new Vector3f(1.0f); this.direction.normalize(); } + /** + * Constructor + * @param direction The direction of the light + * @param color The color of the light + */ public DirectionalLight(Vector3f direction, Vector3f color){ this.direction = direction; this.color = new Vector3f(color); diff --git a/src/main/java/electrosphere/renderer/light/LightManager.java b/src/main/java/electrosphere/renderer/light/LightManager.java index 10c598d7..fab710e8 100644 --- a/src/main/java/electrosphere/renderer/light/LightManager.java +++ b/src/main/java/electrosphere/renderer/light/LightManager.java @@ -111,12 +111,12 @@ public class LightManager { } Totals to 436 bytes */ - ShaderStorageBuffer clusterGridSSBO; + private ShaderStorageBuffer clusterGridSSBO; /** * The map of all entities to point lights */ - Map entityPointLightMap; + private Map entityPointLightMap; /** * The buffer of all point light data @@ -133,7 +133,7 @@ public class LightManager { */ - ShaderStorageBuffer pointLightSSBO; + private ShaderStorageBuffer pointLightSSBO; /** @@ -144,12 +144,12 @@ public class LightManager { vec3 color; //12 bytes }; */ - ShaderStorageBuffer dirLightSSBO; + private ShaderStorageBuffer dirLightSSBO; /** * The directional light */ - DirectionalLight directionalLight; + private DirectionalLight directionalLight; /** * Constructor diff --git a/src/main/java/electrosphere/renderer/light/PointLight.java b/src/main/java/electrosphere/renderer/light/PointLight.java index 061f218e..790dcbbf 100644 --- a/src/main/java/electrosphere/renderer/light/PointLight.java +++ b/src/main/java/electrosphere/renderer/light/PointLight.java @@ -8,61 +8,137 @@ import electrosphere.data.entity.common.light.PointLightDescription; * Data about a point light */ public class PointLight { - Vector3f position; - float constant; - float linear; - float quadratic; - float radius; - Vector3f color; + /** + * The position of the point light + */ + private Vector3f position; + + /** + * The falloff constant of the point light + */ + private float constant; + + /** + * The linear constant of the point light + */ + private float linear; + + /** + * The quadratic constant of the point light + */ + private float quadratic; + + /** + * The radius of the point light + */ + private float radius; + + /** + * The color of the point light + */ + private Vector3f color; + + /** + * Sets the position of the point light + * @param position The position + */ public void setPosition(Vector3f position) { this.position = position; } + /** + * Sets the constant of the falloff + * @param constant The constant + */ public void setConstant(float constant) { this.constant = constant; } + /** + * Sets the linear constant of the falloff + * @param linear The linear constant + */ public void setLinear(float linear) { this.linear = linear; } + /** + * Sets the quadratic of the falloff + * @param quadratic The quadratic constant + */ public void setQuadratic(float quadratic) { this.quadratic = quadratic; } + /** + * Sets the radius of the point light + * @param radius The radius + */ public void setRadius(float radius){ this.radius = radius; } + /** + * Sets the color of the point light + * @param color The color + */ public void setColor(Vector3f color){ this.color = color; } + /** + * Gets the position of the point light + * @return The position + */ public Vector3f getPosition() { return position; } + /** + * Gets the constant of the point light + * @return The constant + */ public float getConstant() { return constant; } + /** + * Gets the linear constant of the point light + * @return The linear constant + */ public float getLinear() { return linear; } + /** + * Gets the quadratic constant of the point light + * @return The quadratic constant + */ public float getQuadratic() { return quadratic; } + /** + * Gets the color of the point light + * @return The color + */ public Vector3f getColor(){ return color; } + /** + * Gets the radius of the point light + * @return The radius + */ public float getRadius(){ return radius; } + /** + * Constructs a point light + * @param position The position of the light + */ protected PointLight(Vector3f position){ this.position = position; radius = 1; @@ -72,6 +148,11 @@ public class PointLight { color = new Vector3f(1.0f); } + /** + * Constructor + * @param position The position of the point light + * @param color The color of the point light + */ protected PointLight(Vector3f position, Vector3f color){ this.position = position; radius = 1; diff --git a/src/main/java/electrosphere/renderer/light/SpotLight.java b/src/main/java/electrosphere/renderer/light/SpotLight.java deleted file mode 100644 index 6b903b66..00000000 --- a/src/main/java/electrosphere/renderer/light/SpotLight.java +++ /dev/null @@ -1,137 +0,0 @@ -package electrosphere.renderer.light; - -import org.joml.Vector3f; - -/** - * Data about a spotlight - */ -public class SpotLight { - Vector3f position; - Vector3f direction; - float cutOff; - float outerCutOff; - - float constant; - float linear; - float quadratic; - - Vector3f ambient; - Vector3f diffuse; - Vector3f specular; - - public void setPosition(Vector3f position) { - this.position = position; - } - - public void setDirection(Vector3f direction) { - this.direction = direction; - } - - public void setCutOff(float cutOff) { - this.cutOff = cutOff; - } - - public void setOuterCutOff(float outerCutOff) { - this.outerCutOff = outerCutOff; - } - - public void setConstant(float constant) { - this.constant = constant; - } - - public void setLinear(float linear) { - this.linear = linear; - } - - public void setQuadratic(float quadratic) { - this.quadratic = quadratic; - } - - public void setAmbient(Vector3f ambient) { - this.ambient = ambient; - } - - public void setDiffuse(Vector3f diffuse) { - this.diffuse = diffuse; - } - - public void setSpecular(Vector3f specular) { - this.specular = specular; - } - - public Vector3f getPosition() { - return position; - } - - public Vector3f getDirection() { - return direction; - } - - public float getCutOff() { - return cutOff; - } - - public float getOuterCutOff() { - return outerCutOff; - } - - public float getConstant() { - return constant; - } - - public float getLinear() { - return linear; - } - - public float getQuadratic() { - return quadratic; - } - - public Vector3f getAmbient() { - return ambient; - } - - public Vector3f getDiffuse() { - return diffuse; - } - - public Vector3f getSpecular() { - return specular; - } - - - - public SpotLight(Vector3f position, Vector3f direction){ - this.position = position; - this.direction = direction; - cutOff = (float)Math.toRadians(12.5f); - outerCutOff = (float)Math.toRadians(15.0f); - constant = 1.0f; - linear = 0.01f; - quadratic = 0.01f; - ambient = new Vector3f(0.05f, 0.05f, 0.05f); - diffuse = new Vector3f(0.8f, 0.8f, 0.8f); - specular = new Vector3f(1.0f, 1.0f, 1.0f); - this.position.normalize(); - this.direction.normalize(); - ambient.normalize(); - diffuse.normalize(); - specular.normalize(); - } - - public SpotLight(Vector3f position, Vector3f direction, Vector3f color){ - this.position = position; - this.direction = direction; - constant = 1.0f; - linear = 0.01f; - quadratic = 0.01f; - ambient = new Vector3f(color.x * 0.05f, color.y * 0.05f, color.z * 0.05f); - diffuse = new Vector3f(color.x * 0.8f, color.y * 0.8f, color.z * 0.8f); - specular = new Vector3f(color.x, color.y, color.z); - this.position.normalize(); - this.direction.normalize(); - ambient.normalize(); - diffuse.normalize(); - specular.normalize(); - } -} \ No newline at end of file diff --git a/src/main/java/electrosphere/renderer/loading/ModelLoader.java b/src/main/java/electrosphere/renderer/loading/ModelLoader.java index 4b8d8516..aa03fce4 100644 --- a/src/main/java/electrosphere/renderer/loading/ModelLoader.java +++ b/src/main/java/electrosphere/renderer/loading/ModelLoader.java @@ -66,7 +66,7 @@ public class ModelLoader { * @param localTextureMap The local texture map * @param m The model */ - static void attemptAddTexturesFromPathname(String path, TextureMap localTextureMap, Model m){ + private static void attemptAddTexturesFromPathname(String path, TextureMap localTextureMap, Model m){ LoggerInterface.loggerRenderer.DEBUG("Load textures for " + path); diff --git a/src/main/java/electrosphere/renderer/model/Material.java b/src/main/java/electrosphere/renderer/model/Material.java index 93f13b74..cf3de0f0 100644 --- a/src/main/java/electrosphere/renderer/model/Material.java +++ b/src/main/java/electrosphere/renderer/model/Material.java @@ -28,33 +28,33 @@ public class Material { /** * The path of the diffuse texture when using texture lookups */ - String diffuse; + private String diffuse; /** * The path of the specular texture when using texture lookups */ - String specular; + private String specular; /** * Tracks whether this material has transparency or not */ - boolean hasTransparency = false; + public boolean hasTransparency = false; /** * Sets whether this material should get its texture pointers from the assetManager by looking up diffuse and specular paths * or whether it should have a manually set texturePointer and not look up while binding */ - boolean usesFetch = true; + private boolean usesFetch = true; /** * texture pointer for the specular */ - int texturePointer; + private int texturePointer; /** * texture pointer for the normal */ - int normalPointer; + private int normalPointer; /** * A material that contains textures diff --git a/src/main/java/electrosphere/renderer/texture/Texture.java b/src/main/java/electrosphere/renderer/texture/Texture.java index 8f2bfb3b..756a1f4e 100644 --- a/src/main/java/electrosphere/renderer/texture/Texture.java +++ b/src/main/java/electrosphere/renderer/texture/Texture.java @@ -40,28 +40,55 @@ public class Texture { */ public static final int DEFAULT_TEXTURE = 0; - //the pointer for the texture - int texturePointer = UNINITIALIZED_TEXTURE; - //the width of the texture - int width = -1; - //the height of the texture - int height = -1; - //whether the texture has transparency or not - boolean hasTransparency; - //the path to the texture - String path = ""; - //the border color - float[] borderColor = null; + /** + * the pointer for the texture + */ + private int texturePointer = UNINITIALIZED_TEXTURE; - //the min and max filter - int minFilter = -1; - int maxFilter = -1; + /** + * the width of the texture + */ + private int width = -1; - //the pixel format (ie RGB, ARGB, etc) - int pixelFormat = -1; + /** + * the height of the texture + */ + private int height = -1; - //the data type of a single component of a pixel (IE UNSIGNED_INT, BYTE, etc) - int datatype = -1; + /** + * whether the texture has transparency or not + */ + private boolean hasTransparency; + + /** + * the path to the texture + */ + private String path = ""; + + /** + * the border color + */ + private float[] borderColor = null; + + /** + * The min filter + */ + private int minFilter = -1; + + /** + * The max filter + */ + private int maxFilter = -1; + + /** + * the pixel format (ie RGB, ARGB, etc) + */ + private int pixelFormat = -1; + + /** + * the data type of a single component of a pixel (IE UNSIGNED_INT, BYTE, etc) + */ + private int datatype = -1; /** * Creates a texture with a new opengl texture object @@ -370,7 +397,7 @@ public class Texture { this.borderColor = borderColor; openGlState.glBindTexture(GL45.GL_TEXTURE_2D,texturePointer); Globals.renderingEngine.checkError(); - GL45.glTexParameterfv(GL45.GL_TEXTURE_2D, GL45.GL_TEXTURE_BORDER_COLOR, borderColor); + GL45.glTexParameterfv(GL45.GL_TEXTURE_2D, GL45.GL_TEXTURE_BORDER_COLOR, this.borderColor); Globals.renderingEngine.checkError(); } @@ -382,7 +409,7 @@ public class Texture { this.minFilter = minFilter; openGlState.glBindTexture(GL45.GL_TEXTURE_2D,texturePointer); Globals.renderingEngine.checkError(); - GL45.glTexParameteri(GL45.GL_TEXTURE_2D, GL45.GL_TEXTURE_MIN_FILTER, minFilter); + GL45.glTexParameteri(GL45.GL_TEXTURE_2D, GL45.GL_TEXTURE_MIN_FILTER, this.minFilter); Globals.renderingEngine.checkError(); } @@ -394,7 +421,7 @@ public class Texture { this.maxFilter = maxFilter; openGlState.glBindTexture(GL45.GL_TEXTURE_2D,texturePointer); Globals.renderingEngine.checkError(); - GL45.glTexParameteri(GL45.GL_TEXTURE_2D, GL45.GL_TEXTURE_MAG_FILTER, maxFilter); + GL45.glTexParameteri(GL45.GL_TEXTURE_2D, GL45.GL_TEXTURE_MAG_FILTER, this.maxFilter); Globals.renderingEngine.checkError(); } diff --git a/src/main/java/electrosphere/renderer/texture/TextureAtlas.java b/src/main/java/electrosphere/renderer/texture/TextureAtlas.java index bd620daa..35535272 100644 --- a/src/main/java/electrosphere/renderer/texture/TextureAtlas.java +++ b/src/main/java/electrosphere/renderer/texture/TextureAtlas.java @@ -9,21 +9,35 @@ import java.util.Map; public class TextureAtlas { - //A map of texture path -> coordinates in the atlas texture for its texture - Map pathCoordMap = new HashMap(); + /** + * A map of texture path -> coordinates in the atlas texture for its texture + */ + private Map pathCoordMap = new HashMap(); - //the actual texture - Texture specular; + /** + * the actual texture + */ + private Texture specular; - //the normal texture - Texture normal; + /** + * the normal texture + */ + private Texture normal; - //the width in pixels of a single texture in the atlas + /** + * the width in pixels of a single texture in the atlas + */ public static final int ATLAS_ELEMENT_DIM = 64; - //the width in pixels of the whole atlas texture + + /** + * the width in pixels of the whole atlas texture + */ public static final int ATLAS_DIM = 1024; - //number of textures per row in the atlas + + /** + * number of textures per row in the atlas + */ public static final int ELEMENTS_PER_ROW = ATLAS_DIM / ATLAS_ELEMENT_DIM; /**