thread-safe deleting elements
All checks were successful
studiorailgun/Renderer/pipeline/head This commit looks good
All checks were successful
studiorailgun/Renderer/pipeline/head This commit looks good
This commit is contained in:
parent
467c42bfe8
commit
f09bb23abc
@ -501,7 +501,8 @@ public class Globals {
|
||||
|
||||
//
|
||||
//Register all signals
|
||||
Globals.signalSystem.registerService(SignalType.APPLY_YOGA, Globals.elementService);
|
||||
Globals.signalSystem.registerService(SignalType.YOGA_APPLY, Globals.elementService);
|
||||
Globals.signalSystem.registerService(SignalType.YOGA_DESTROY, Globals.elementService);
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -442,8 +442,9 @@ public class Main {
|
||||
// S H U T D O W N
|
||||
//
|
||||
//Terminate the program.
|
||||
if(!Globals.HEADLESS && Globals.RUN_CLIENT){
|
||||
if(Globals.RUN_CLIENT){
|
||||
glfwTerminate();
|
||||
Globals.renderingEngine.clearGlobalState();
|
||||
}
|
||||
//used to signal threads to stop
|
||||
Globals.threadManager.close();
|
||||
|
||||
@ -20,7 +20,8 @@ public class Signal {
|
||||
//
|
||||
//UI
|
||||
//
|
||||
APPLY_YOGA,
|
||||
YOGA_APPLY,
|
||||
YOGA_DESTROY,
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -67,8 +67,15 @@ public class SignalServiceImpl implements SignalService {
|
||||
* Handles all signals provided to the main thread
|
||||
*/
|
||||
public void handleAllSignals(){
|
||||
//
|
||||
//fully copy to this thread
|
||||
this.threadLock.acquireUninterruptibly();
|
||||
for(Signal signal : signals){
|
||||
List<Signal> toHandle = new LinkedList<Signal>(signals);
|
||||
signals.clear();
|
||||
this.threadLock.release();
|
||||
//
|
||||
//handle signals
|
||||
for(Signal signal : toHandle){
|
||||
boolean result = this.handle(signal);
|
||||
if(!result){
|
||||
String message = "Signal provided to service that does not support that signal type!\n" +
|
||||
@ -79,7 +86,6 @@ public class SignalServiceImpl implements SignalService {
|
||||
LoggerInterface.loggerEngine.ERROR(new IllegalStateException(message));
|
||||
}
|
||||
}
|
||||
this.threadLock.release();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -29,7 +29,7 @@ public class WindowUtils {
|
||||
//todo: destroy elements as well
|
||||
mainMenu.clear();
|
||||
mainMenu.addChild(newMenu);
|
||||
Globals.signalSystem.post(SignalType.APPLY_YOGA, mainMenu);
|
||||
Globals.signalSystem.post(SignalType.YOGA_APPLY, mainMenu);
|
||||
Globals.elementService.focusFirstElement();
|
||||
}
|
||||
}
|
||||
@ -52,7 +52,7 @@ public class WindowUtils {
|
||||
Globals.elementService.focusFirstElement();
|
||||
}
|
||||
if(visible){
|
||||
Globals.signalSystem.post(SignalType.APPLY_YOGA,topLevelMenu);
|
||||
Globals.signalSystem.post(SignalType.YOGA_APPLY,topLevelMenu);
|
||||
}
|
||||
}
|
||||
|
||||
@ -164,7 +164,7 @@ public class WindowUtils {
|
||||
Label loadingLabel = new Label(1.0f);
|
||||
loadingLabel.setText("LOADING");
|
||||
loadingWindow.addChild(loadingLabel);
|
||||
Globals.signalSystem.post(SignalType.APPLY_YOGA,loadingWindow);
|
||||
Globals.signalSystem.post(SignalType.YOGA_APPLY,loadingWindow);
|
||||
Globals.elementService.registerWindow(WindowStrings.WINDOW_LOADING, loadingWindow);
|
||||
WindowUtils.recursiveSetVisible(loadingWindow, true);
|
||||
}
|
||||
|
||||
@ -100,7 +100,7 @@ public class MenuGeneratorsInGame {
|
||||
}));
|
||||
}
|
||||
|
||||
Globals.signalSystem.post(SignalType.APPLY_YOGA,rVal);
|
||||
Globals.signalSystem.post(SignalType.YOGA_APPLY,rVal);
|
||||
|
||||
return rVal;
|
||||
}
|
||||
@ -298,7 +298,7 @@ public class MenuGeneratorsInGame {
|
||||
return false;
|
||||
}});
|
||||
|
||||
Globals.signalSystem.post(SignalType.APPLY_YOGA,rVal);
|
||||
Globals.signalSystem.post(SignalType.YOGA_APPLY,rVal);
|
||||
|
||||
return rVal;
|
||||
}
|
||||
@ -363,7 +363,7 @@ public class MenuGeneratorsInGame {
|
||||
}
|
||||
}
|
||||
|
||||
Globals.signalSystem.post(SignalType.APPLY_YOGA,rVal);
|
||||
Globals.signalSystem.post(SignalType.YOGA_APPLY,rVal);
|
||||
|
||||
return rVal;
|
||||
}
|
||||
|
||||
@ -42,7 +42,7 @@ public class MenuGeneratorsInventory {
|
||||
rVal.setParentJustifyContent(YogaJustification.Center);
|
||||
|
||||
//apply yoga so that the screenspace position of the window can be calculated, that allows proper placement of the absolute elements
|
||||
Globals.signalSystem.post(SignalType.APPLY_YOGA,rVal);
|
||||
Globals.signalSystem.post(SignalType.YOGA_APPLY,rVal);
|
||||
|
||||
Div div = Div.createDiv();
|
||||
rVal.addChild(div);
|
||||
|
||||
@ -82,7 +82,7 @@ public class MenuGeneratorsLevelEditor {
|
||||
fillInDefaultContent(scrollable);
|
||||
|
||||
|
||||
Globals.signalSystem.post(SignalType.APPLY_YOGA,mainSidePanel);
|
||||
Globals.signalSystem.post(SignalType.YOGA_APPLY,mainSidePanel);
|
||||
|
||||
return mainSidePanel;
|
||||
}
|
||||
@ -142,7 +142,7 @@ public class MenuGeneratorsLevelEditor {
|
||||
fillInAtmosphericControlContent(scrollable);
|
||||
}));
|
||||
|
||||
Globals.signalSystem.post(SignalType.APPLY_YOGA,mainSidePanel);
|
||||
Globals.signalSystem.post(SignalType.YOGA_APPLY,mainSidePanel);
|
||||
|
||||
}
|
||||
|
||||
@ -172,7 +172,7 @@ public class MenuGeneratorsLevelEditor {
|
||||
}));
|
||||
}
|
||||
|
||||
Globals.signalSystem.post(SignalType.APPLY_YOGA,mainSidePanel);
|
||||
Globals.signalSystem.post(SignalType.YOGA_APPLY,mainSidePanel);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -200,7 +200,7 @@ public class MenuGeneratorsLevelEditor {
|
||||
}));
|
||||
}
|
||||
|
||||
Globals.signalSystem.post(SignalType.APPLY_YOGA,mainSidePanel);
|
||||
Globals.signalSystem.post(SignalType.YOGA_APPLY,mainSidePanel);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -228,7 +228,7 @@ public class MenuGeneratorsLevelEditor {
|
||||
}));
|
||||
}
|
||||
|
||||
Globals.signalSystem.post(SignalType.APPLY_YOGA,mainSidePanel);
|
||||
Globals.signalSystem.post(SignalType.YOGA_APPLY,mainSidePanel);
|
||||
}
|
||||
|
||||
|
||||
@ -257,7 +257,7 @@ public class MenuGeneratorsLevelEditor {
|
||||
}));
|
||||
}
|
||||
|
||||
Globals.signalSystem.post(SignalType.APPLY_YOGA,mainSidePanel);
|
||||
Globals.signalSystem.post(SignalType.YOGA_APPLY,mainSidePanel);
|
||||
}
|
||||
|
||||
|
||||
@ -308,7 +308,7 @@ public class MenuGeneratorsLevelEditor {
|
||||
}
|
||||
}
|
||||
|
||||
Globals.signalSystem.post(SignalType.APPLY_YOGA,mainSidePanel);
|
||||
Globals.signalSystem.post(SignalType.YOGA_APPLY,mainSidePanel);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -385,7 +385,7 @@ public class MenuGeneratorsLevelEditor {
|
||||
scrollable.addChild(zDiv);
|
||||
|
||||
|
||||
Globals.signalSystem.post(SignalType.APPLY_YOGA,mainSidePanel);
|
||||
Globals.signalSystem.post(SignalType.YOGA_APPLY,mainSidePanel);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -94,7 +94,7 @@ public class MenuGeneratorsTerrainEditing {
|
||||
fillInVoxelSelectors(scrollable, searchInput.getText());
|
||||
|
||||
|
||||
Globals.signalSystem.post(SignalType.APPLY_YOGA,rVal);
|
||||
Globals.signalSystem.post(SignalType.YOGA_APPLY,rVal);
|
||||
|
||||
return rVal;
|
||||
}
|
||||
@ -143,7 +143,7 @@ public class MenuGeneratorsTerrainEditing {
|
||||
scrollable.addChild(newButton);
|
||||
}
|
||||
|
||||
Globals.signalSystem.post(SignalType.APPLY_YOGA,rVal);
|
||||
Globals.signalSystem.post(SignalType.YOGA_APPLY,rVal);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -161,6 +161,7 @@ public class OpenGLState {
|
||||
this.framebufferType = framebufferType;
|
||||
this.framebufferPointer = framebufferPointer;
|
||||
GL40.glBindFramebuffer(this.framebufferType,this.framebufferPointer);
|
||||
Globals.renderingEngine.checkError();
|
||||
}
|
||||
}
|
||||
|
||||
@ -182,8 +183,7 @@ public class OpenGLState {
|
||||
activeShader = program;
|
||||
GL40.glUseProgram(activeShader.getShaderId());
|
||||
int glErrorCode = Globals.renderingEngine.getError();
|
||||
//TODO: fix manually ignoring GL_INVALID_VALUE from call
|
||||
if(glErrorCode != 0 && glErrorCode != GL40.GL_INVALID_VALUE){
|
||||
if(glErrorCode != 0){
|
||||
LoggerInterface.loggerRenderer.DEBUG_LOOP(RenderingEngine.getErrorInEnglish(glErrorCode));
|
||||
}
|
||||
Globals.renderingEngine.checkError();
|
||||
|
||||
@ -53,7 +53,6 @@ import static org.lwjgl.opengl.GL20.glUniformMatrix4fv;
|
||||
import static org.lwjgl.opengl.GL20.glUseProgram;
|
||||
import static org.lwjgl.opengl.GL30.GL_FRAMEBUFFER;
|
||||
import static org.lwjgl.opengl.GL30.GL_RENDERBUFFER;
|
||||
import static org.lwjgl.opengl.GL30.glBindFramebuffer;
|
||||
import static org.lwjgl.opengl.GL30.glBindRenderbuffer;
|
||||
import static org.lwjgl.opengl.GL30.glBindVertexArray;
|
||||
import static org.lwjgl.opengl.GL30.glClearBufferfv;
|
||||
@ -335,7 +334,8 @@ public class RenderingEngine {
|
||||
screenTextureDepth = FramebufferUtils.generateScreenTextureDepth(openGLState, Globals.userSettings.getRenderResolutionX(), Globals.userSettings.getRenderResolutionY());
|
||||
screenFramebuffer = FramebufferUtils.generateScreenTextureFramebuffer(openGLState, Globals.userSettings.getRenderResolutionX(), Globals.userSettings.getRenderResolutionY(), screenTextureColor, screenTextureDepth);
|
||||
openGLState.glBindFramebuffer(GL_FRAMEBUFFER, GL_DEFAULT_FRAMEBUFFER);
|
||||
glBindRenderbuffer(GL_RENDERBUFFER, GL_DEFAULT_RENDERBUFFER);
|
||||
// glBindRenderbuffer(GL_RENDERBUFFER, GL_DEFAULT_RENDERBUFFER);
|
||||
Globals.renderingEngine.checkError();
|
||||
|
||||
//
|
||||
//Channel debug program
|
||||
@ -448,6 +448,15 @@ public class RenderingEngine {
|
||||
Globals.viewMatrix.translation(new Vector3f(0.0f,0.0f,-3.0f));
|
||||
}
|
||||
|
||||
/**
|
||||
* Clears global, static state
|
||||
*/
|
||||
public void clearGlobalState(){
|
||||
screenTextureColor = null;
|
||||
screenTextureDepth = null;
|
||||
screenFramebuffer = null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Main function to draw the screen
|
||||
@ -689,25 +698,25 @@ public class RenderingEngine {
|
||||
return null;
|
||||
}
|
||||
case GL11.GL_INVALID_ENUM: {
|
||||
return "An unacceptable value is specified for an enumerated argument. The offending command is ignored and has no other side effect than to set the error flag.";
|
||||
return "GL_INVALID_ENUM";
|
||||
}
|
||||
case GL11.GL_INVALID_VALUE: {
|
||||
return "A numeric argument is out of range. The offending command is ignored and has no other side effect than to set the error flag.";
|
||||
return "GL_INVALID_VALUE";
|
||||
}
|
||||
case GL11.GL_INVALID_OPERATION: {
|
||||
return "The specified operation is not allowed in the current state. The offending command is ignored and has no other side effect than to set the error flag.";
|
||||
return "GL_INVALID_OPERATION";
|
||||
}
|
||||
case GL30.GL_INVALID_FRAMEBUFFER_OPERATION: {
|
||||
return "The framebuffer object is not complete. The offending command is ignored and has no other side effect than to set the error flag. ";
|
||||
return "GL_INVALID_FRAMEBUFFER_OPERATION";
|
||||
}
|
||||
case GL11.GL_OUT_OF_MEMORY: {
|
||||
return "There is not enough memory left to execute the command. The state of the GL is undefined, except for the state of the error flags, after this error is recorded. ";
|
||||
return "GL_OUT_OF_MEMORY";
|
||||
}
|
||||
case GL11.GL_STACK_UNDERFLOW: {
|
||||
return "An attempt has been made to perform an operation that would cause an internal stack to underflow. ";
|
||||
return "GL_STACK_UNDERFLOW";
|
||||
}
|
||||
case GL11.GL_STACK_OVERFLOW: {
|
||||
return "An attempt has been made to perform an operation that would cause an internal stack to overflow. ";
|
||||
return "GL_STACK_OVERFLOW";
|
||||
}
|
||||
default: {
|
||||
return "Un-enum'd error or no error. Code: " + errorCode;
|
||||
|
||||
@ -16,8 +16,6 @@ import java.util.concurrent.TimeUnit;
|
||||
import org.lwjgl.opengl.GL40;
|
||||
import org.lwjgl.system.MemoryUtil;
|
||||
|
||||
import static org.lwjgl.opengl.GL11.GL_TEXTURE_2D;
|
||||
import static org.lwjgl.opengl.GL30.*;
|
||||
import static org.lwjgl.opengl.GL45.glCheckNamedFramebufferStatus;
|
||||
|
||||
/**
|
||||
@ -25,6 +23,11 @@ import static org.lwjgl.opengl.GL45.glCheckNamedFramebufferStatus;
|
||||
*/
|
||||
public class Framebuffer {
|
||||
|
||||
/**
|
||||
* The default framebuffer's pointer
|
||||
*/
|
||||
public static final int DEFAULT_FRAMEBUFFER_POINTER = 0;
|
||||
|
||||
//the pointer to the framebuffer
|
||||
int framebufferPointer;
|
||||
//the mipmap level
|
||||
@ -40,7 +43,8 @@ public class Framebuffer {
|
||||
* Creates a framebuffer
|
||||
*/
|
||||
public Framebuffer(){
|
||||
framebufferPointer = glGenFramebuffers();
|
||||
framebufferPointer = GL40.glGenFramebuffers();
|
||||
Globals.renderingEngine.checkError();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -80,7 +84,7 @@ public class Framebuffer {
|
||||
* @param openGLState The opengl state
|
||||
*/
|
||||
public void bind(OpenGLState openGLState){
|
||||
openGLState.glBindFramebuffer(GL_FRAMEBUFFER, framebufferPointer);
|
||||
openGLState.glBindFramebuffer(GL40.GL_FRAMEBUFFER, framebufferPointer);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -88,7 +92,7 @@ public class Framebuffer {
|
||||
* @return true if compiled correctly, false otherwise
|
||||
*/
|
||||
public boolean isComplete(){
|
||||
return glCheckNamedFramebufferStatus(framebufferPointer,GL_FRAMEBUFFER) == GL_FRAMEBUFFER_COMPLETE;
|
||||
return glCheckNamedFramebufferStatus(framebufferPointer,GL40.GL_FRAMEBUFFER) == GL40.GL_FRAMEBUFFER_COMPLETE;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -96,7 +100,7 @@ public class Framebuffer {
|
||||
* @return true if error, false otherwise
|
||||
*/
|
||||
public boolean isError(){
|
||||
return glCheckNamedFramebufferStatus(framebufferPointer,GL_FRAMEBUFFER) == 0;
|
||||
return glCheckNamedFramebufferStatus(framebufferPointer,GL40.GL_FRAMEBUFFER) == 0;
|
||||
}
|
||||
|
||||
public void checkStatus(){
|
||||
@ -121,14 +125,14 @@ public class Framebuffer {
|
||||
* Frees the framebuffer
|
||||
*/
|
||||
public void free(){
|
||||
glDeleteFramebuffers(framebufferPointer);
|
||||
GL40.glDeleteFramebuffers(framebufferPointer);
|
||||
}
|
||||
|
||||
/**
|
||||
* Blocks the thread until the framebuffer has compiled
|
||||
*/
|
||||
public void blockUntilCompiled(){
|
||||
while(glCheckNamedFramebufferStatus(framebufferPointer,GL_FRAMEBUFFER) != GL_FRAMEBUFFER_UNDEFINED){
|
||||
while(glCheckNamedFramebufferStatus(framebufferPointer,GL40.GL_FRAMEBUFFER) != GL40.GL_FRAMEBUFFER_UNDEFINED){
|
||||
try {
|
||||
TimeUnit.MILLISECONDS.sleep(1);
|
||||
} catch (InterruptedException ex) {
|
||||
@ -142,26 +146,26 @@ public class Framebuffer {
|
||||
* @return The status
|
||||
*/
|
||||
public String getStatus(){
|
||||
switch(glCheckNamedFramebufferStatus(framebufferPointer,GL_FRAMEBUFFER)){
|
||||
case GL_FRAMEBUFFER_UNDEFINED: {
|
||||
switch(glCheckNamedFramebufferStatus(framebufferPointer,GL40.GL_FRAMEBUFFER)){
|
||||
case GL40.GL_FRAMEBUFFER_UNDEFINED: {
|
||||
return "The specified framebuffer is the default read or draw framebuffer, but the default framebuffer does not exist.";
|
||||
}
|
||||
case GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT: {
|
||||
case GL40.GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT: {
|
||||
return "Any of the framebuffer attachment points are framebuffer incomplete.";
|
||||
}
|
||||
case GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT: {
|
||||
case GL40.GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT: {
|
||||
return "The framebuffer does not have at least one image attached to it.";
|
||||
}
|
||||
case GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER: {
|
||||
case GL40.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 GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER: {
|
||||
case GL40.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 GL_FRAMEBUFFER_UNSUPPORTED: {
|
||||
case GL40.GL_FRAMEBUFFER_UNSUPPORTED: {
|
||||
return "The combination of internal formats of the attached images violates an implementation-dependent set of restrictions.";
|
||||
}
|
||||
case GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE: {
|
||||
case GL40.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: {
|
||||
@ -196,12 +200,21 @@ public class Framebuffer {
|
||||
*/
|
||||
public void attachTexture(OpenGLState openGLState, Texture texture, int attachmentNum){
|
||||
this.attachTextureMap.put(attachmentNum,texture);
|
||||
this.texture = texture;
|
||||
if(this.mipMap < 0){
|
||||
LoggerInterface.loggerRenderer.ERROR(new IllegalStateException("Trying to attach a texture to a framebuffer where mipmap hasn't been set."));
|
||||
}
|
||||
this.texture = texture;
|
||||
openGLState.glBindFramebuffer(GL_FRAMEBUFFER, framebufferPointer);
|
||||
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0 + attachmentNum, GL_TEXTURE_2D, texture.getTexturePointer(), this.mipMap);
|
||||
if(this.framebufferPointer == Framebuffer.DEFAULT_FRAMEBUFFER_POINTER){
|
||||
throw new IllegalStateException("Trying to attach image to default frame buffer!");
|
||||
}
|
||||
if(texture.getTexturePointer() == Texture.UNINITIALIZED_TEXTURE){
|
||||
throw new IllegalStateException("Trying to attach uninitialized image to frame buffer!");
|
||||
}
|
||||
openGLState.glBindFramebuffer(GL40.GL_FRAMEBUFFER, this.framebufferPointer);
|
||||
GL40.glFramebufferTexture2D(GL40.GL_FRAMEBUFFER, GL40.GL_COLOR_ATTACHMENT0 + attachmentNum, GL40.GL_TEXTURE_2D, texture.getTexturePointer(), 0);
|
||||
System.out.println(this.framebufferPointer + " " + texture.getTexturePointer());
|
||||
Globals.renderingEngine.checkError();
|
||||
openGLState.glBindFramebuffer(GL40.GL_FRAMEBUFFER, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -210,11 +223,11 @@ public class Framebuffer {
|
||||
* @param texturePointer The depth attachment's pointer
|
||||
*/
|
||||
public void setDepthAttachment(OpenGLState openGLState, Texture depthTexture){
|
||||
openGLState.glBindFramebuffer(GL_FRAMEBUFFER, framebufferPointer);
|
||||
openGLState.glBindFramebuffer(GL40.GL_FRAMEBUFFER, this.framebufferPointer);
|
||||
this.depthTexture = depthTexture;
|
||||
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, depthTexture.getTexturePointer(), this.mipMap);
|
||||
openGLState.glBindFramebuffer(GL_FRAMEBUFFER, 0);
|
||||
checkStatus();
|
||||
GL40.glFramebufferTexture2D(GL40.GL_FRAMEBUFFER, GL40.GL_DEPTH_ATTACHMENT, GL40.GL_TEXTURE_2D, depthTexture.getTexturePointer(), 0);
|
||||
Globals.renderingEngine.checkError();
|
||||
openGLState.glBindFramebuffer(GL40.GL_FRAMEBUFFER, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -2,11 +2,13 @@ package electrosphere.renderer.framebuffer;
|
||||
|
||||
import electrosphere.engine.Globals;
|
||||
import electrosphere.renderer.OpenGLState;
|
||||
import electrosphere.renderer.RenderingEngine;
|
||||
import electrosphere.renderer.texture.Texture;
|
||||
|
||||
import java.nio.IntBuffer;
|
||||
|
||||
import org.lwjgl.BufferUtils;
|
||||
import org.lwjgl.opengl.GL40;
|
||||
|
||||
import static org.lwjgl.opengl.GL11.GL_DEPTH_COMPONENT;
|
||||
import static org.lwjgl.opengl.GL11.GL_FLOAT;
|
||||
@ -134,9 +136,12 @@ public class FramebufferUtils {
|
||||
//renderbuffer
|
||||
int renderBuffer = glGenRenderbuffers();
|
||||
glBindRenderbuffer(GL_RENDERBUFFER, renderBuffer);
|
||||
Globals.renderingEngine.checkError();
|
||||
glRenderbufferStorage(GL_RENDERBUFFER, 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);
|
||||
Globals.renderingEngine.checkError();
|
||||
//check make sure compiled
|
||||
buffer.checkStatus();
|
||||
return buffer;
|
||||
@ -159,12 +164,18 @@ public class FramebufferUtils {
|
||||
buffer.attachTexture(openGLState,texture);
|
||||
//renderbuffer
|
||||
int renderBuffer = glGenRenderbuffers();
|
||||
glBindRenderbuffer(GL_RENDERBUFFER, renderBuffer);
|
||||
glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH24_STENCIL8, width, height);
|
||||
GL40.glBindRenderbuffer(GL_RENDERBUFFER, renderBuffer);
|
||||
Globals.renderingEngine.checkError();
|
||||
GL40.glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH24_STENCIL8, width, height);
|
||||
Globals.renderingEngine.checkError();
|
||||
//bind rbo to fbo
|
||||
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_RENDERBUFFER, renderBuffer);
|
||||
buffer.bind(openGLState);
|
||||
GL40.glFramebufferRenderbuffer(GL40.GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_RENDERBUFFER, renderBuffer);
|
||||
Globals.renderingEngine.checkError();
|
||||
//check make sure compiled
|
||||
buffer.checkStatus();
|
||||
//re-bind default buffer
|
||||
RenderingEngine.defaultFramebuffer.bind(openGLState);
|
||||
return buffer;
|
||||
}
|
||||
|
||||
@ -177,6 +188,7 @@ public class FramebufferUtils {
|
||||
buffer.bind();
|
||||
glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH24_STENCIL8, Globals.WINDOW_WIDTH, Globals.WINDOW_HEIGHT);
|
||||
Globals.renderingEngine.checkError();
|
||||
Globals.renderingEngine.checkError();
|
||||
return buffer;
|
||||
}
|
||||
|
||||
@ -203,7 +215,9 @@ public class FramebufferUtils {
|
||||
buffer.setMipMapLevel(0);
|
||||
buffer.setDepthAttachment(openGLState,texture);
|
||||
glNamedFramebufferDrawBuffer(buffer.getFramebufferPointer(), GL_NONE);
|
||||
Globals.renderingEngine.checkError();
|
||||
glNamedFramebufferReadBuffer(buffer.getFramebufferPointer(), GL_NONE);
|
||||
Globals.renderingEngine.checkError();
|
||||
|
||||
|
||||
|
||||
@ -234,7 +248,9 @@ public class FramebufferUtils {
|
||||
buffer.setMipMapLevel(0);
|
||||
buffer.setDepthAttachment(openGLState,texture);
|
||||
glNamedFramebufferDrawBuffer(buffer.getFramebufferPointer(), GL_NONE);
|
||||
Globals.renderingEngine.checkError();
|
||||
glNamedFramebufferReadBuffer(buffer.getFramebufferPointer(), GL_NONE);
|
||||
Globals.renderingEngine.checkError();
|
||||
|
||||
|
||||
|
||||
@ -279,6 +295,7 @@ public class FramebufferUtils {
|
||||
drawBuffers.put(GL_COLOR_ATTACHMENT1);
|
||||
drawBuffers.flip();
|
||||
glNamedFramebufferDrawBuffers(buffer.getFramebufferPointer(),drawBuffers);
|
||||
Globals.renderingEngine.checkError();
|
||||
|
||||
//check make sure compiled
|
||||
buffer.checkStatus();
|
||||
|
||||
@ -161,8 +161,7 @@ public class LightManager {
|
||||
//get position of lights object in shader
|
||||
int bufferIndex = GL31.glGetUniformBlockIndex(openGLState.getActiveShader().getShaderId(), "Lights");
|
||||
int glErrorCode = Globals.renderingEngine.getError();
|
||||
//TODO: fix manually ignoring GL_INVALID_VALUE from call
|
||||
if(glErrorCode != 0 && glErrorCode != GL40.GL_INVALID_VALUE){
|
||||
if(glErrorCode != 0){
|
||||
LoggerInterface.loggerRenderer.DEBUG_LOOP(RenderingEngine.getErrorInEnglish(glErrorCode));
|
||||
}
|
||||
if(bufferIndex == ShaderProgram.INVALID_UNIFORM_NAME){
|
||||
|
||||
@ -575,6 +575,7 @@ public class ShaderProgram {
|
||||
//Deletes the individual shader objects to free up memory
|
||||
glDeleteShader(rVal.vertexShader);
|
||||
glDeleteShader(rVal.fragmentShader);
|
||||
Globals.renderingEngine.checkError();
|
||||
|
||||
|
||||
|
||||
@ -749,8 +750,7 @@ public class ShaderProgram {
|
||||
//get uniform location
|
||||
int uniformLocation = GL40.glGetUniformLocation(this.getShaderId(), uniformName);
|
||||
int glErrorCode = Globals.renderingEngine.getError();
|
||||
//TODO: fix manually ignoring GL_INVALID_VALUE from call
|
||||
if(glErrorCode != 0 && glErrorCode != GL40.GL_INVALID_VALUE){
|
||||
if(glErrorCode != 0){
|
||||
LoggerInterface.loggerRenderer.DEBUG_LOOP(RenderingEngine.getErrorInEnglish(glErrorCode));
|
||||
LoggerInterface.loggerRenderer.WARNING("Shader id: " + this.getShaderId());
|
||||
}
|
||||
|
||||
@ -29,8 +29,13 @@ import static org.lwjgl.opengl.GL30.*;
|
||||
*/
|
||||
public class Texture {
|
||||
|
||||
/**
|
||||
* Pointer for an uninitialized texture
|
||||
*/
|
||||
public static final int UNINITIALIZED_TEXTURE = -1;
|
||||
|
||||
//the pointer for the texture
|
||||
int texturePointer = -1;
|
||||
int texturePointer = UNINITIALIZED_TEXTURE;
|
||||
//the width of the texture
|
||||
int width = -1;
|
||||
//the height of the texture
|
||||
@ -52,19 +57,12 @@ public class Texture {
|
||||
//the data type of a single component of a pixel (IE UNSIGNED_INT, BYTE, etc)
|
||||
int datatype = -1;
|
||||
|
||||
/**
|
||||
* Constructs a texture from a pointer
|
||||
* @param pointer the pointer
|
||||
*/
|
||||
public Texture(int pointer){
|
||||
this.texturePointer = pointer;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a texture with a new opengl texture object
|
||||
*/
|
||||
public Texture(){
|
||||
this.texturePointer = glGenTextures();
|
||||
this.texturePointer = GL40.glGenTextures();
|
||||
Globals.renderingEngine.checkError();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -72,7 +70,8 @@ public class Texture {
|
||||
* @param bufferedImage The java bufferedimage object
|
||||
*/
|
||||
public Texture(OpenGLState openGlState, BufferedImage bufferedImage){
|
||||
this.texturePointer = glGenTextures();
|
||||
this.texturePointer = GL40.glGenTextures();
|
||||
Globals.renderingEngine.checkError();
|
||||
//bind the new texture
|
||||
openGlState.glBindTexture(GL_TEXTURE_2D, texturePointer);
|
||||
//how are we gonna wrap the texture??
|
||||
@ -154,7 +153,8 @@ public class Texture {
|
||||
if(!Globals.HEADLESS){
|
||||
LoggerInterface.loggerRenderer.DEBUG("Setup texture object");
|
||||
//generate the texture object on gpu
|
||||
this.texturePointer = glGenTextures();
|
||||
this.texturePointer = GL40.glGenTextures();
|
||||
Globals.renderingEngine.checkError();
|
||||
//bind the new texture
|
||||
openGlState.glBindTexture(GL_TEXTURE_2D, texturePointer);
|
||||
//how are we gonna wrap the texture??
|
||||
@ -239,7 +239,8 @@ public class Texture {
|
||||
public Texture(OpenGLState openGlState, ByteBuffer buffer, int width, int height){
|
||||
if(!Globals.HEADLESS){
|
||||
//generate the texture object on gpu
|
||||
this.texturePointer = glGenTextures();
|
||||
this.texturePointer = GL40.glGenTextures();
|
||||
Globals.renderingEngine.checkError();
|
||||
//bind the new texture
|
||||
openGlState.glBindTexture(GL_TEXTURE_2D, texturePointer);
|
||||
//how are we gonna wrap the texture??
|
||||
|
||||
@ -513,11 +513,16 @@ public class ElementService extends SignalServiceImpl {
|
||||
public boolean handle(Signal signal){
|
||||
boolean rVal = false;
|
||||
switch(signal.getType()){
|
||||
case APPLY_YOGA: {
|
||||
case YOGA_APPLY: {
|
||||
Element target = (Element)signal.getData();
|
||||
target.applyYoga(0, 0);
|
||||
rVal = true;
|
||||
} break;
|
||||
case YOGA_DESTROY: {
|
||||
Element target = (Element)signal.getData();
|
||||
target.destroy();
|
||||
rVal = true;
|
||||
} break;
|
||||
default: {
|
||||
} break;
|
||||
}
|
||||
|
||||
@ -4,6 +4,7 @@ import org.joml.Vector3f;
|
||||
import org.lwjgl.util.yoga.Yoga;
|
||||
|
||||
import electrosphere.engine.Globals;
|
||||
import electrosphere.engine.signal.Signal.SignalType;
|
||||
import electrosphere.renderer.OpenGLState;
|
||||
import electrosphere.renderer.RenderPipelineState;
|
||||
import electrosphere.renderer.debug.DebugRendering;
|
||||
@ -76,9 +77,9 @@ public class Label extends StandardContainerElement implements DrawableElement {
|
||||
void generateLetters(){
|
||||
//free children
|
||||
for(Element child : childList){
|
||||
child.destroy();
|
||||
Globals.signalSystem.post(SignalType.YOGA_DESTROY, child);
|
||||
}
|
||||
childList.clear();
|
||||
this.clearChildren();
|
||||
int accumulatingWidth = 0;
|
||||
for(int i = 0; i < text.length(); i++){
|
||||
char toDraw = text.charAt(i);
|
||||
|
||||
@ -5,6 +5,8 @@ import java.util.List;
|
||||
|
||||
import org.lwjgl.util.yoga.Yoga;
|
||||
|
||||
import electrosphere.engine.Globals;
|
||||
import electrosphere.engine.signal.Signal.SignalType;
|
||||
import electrosphere.logger.LoggerInterface;
|
||||
import electrosphere.renderer.ui.elementtypes.ContainerElement;
|
||||
import electrosphere.renderer.ui.elementtypes.DrawableElement;
|
||||
@ -236,7 +238,7 @@ public class StandardContainerElement extends StandardElement implements Contain
|
||||
@Override
|
||||
public void destroy(){
|
||||
for(Element child : childList){
|
||||
child.destroy();
|
||||
Globals.signalSystem.post(SignalType.YOGA_DESTROY, child);
|
||||
}
|
||||
if(this.yogaNode != Element.NULL_YOGA_ELEMENT){
|
||||
Yoga.YGNodeFree(this.yogaNode);
|
||||
|
||||
@ -7,6 +7,7 @@ import org.joml.Vector3f;
|
||||
import org.lwjgl.util.yoga.Yoga;
|
||||
|
||||
import electrosphere.engine.Globals;
|
||||
import electrosphere.engine.signal.Signal.SignalType;
|
||||
import electrosphere.renderer.OpenGLState;
|
||||
import electrosphere.renderer.RenderPipelineState;
|
||||
import electrosphere.renderer.ui.elementtypes.DrawableElement;
|
||||
@ -73,10 +74,9 @@ public class StringCarousel extends StandardContainerElement implements Drawable
|
||||
|
||||
void generateLetters(){
|
||||
for(Element el : getChildren()){
|
||||
Yoga.YGNodeRemoveChild(this.yogaNode,el.getYogaNode());
|
||||
el.destroy();
|
||||
Globals.signalSystem.post(SignalType.YOGA_DESTROY, el);
|
||||
}
|
||||
childList.clear();
|
||||
this.clearChildren();
|
||||
for(int i = 0; i < textCurrent.length(); i++){
|
||||
char toDraw = textCurrent.charAt(i);
|
||||
Vector3f bitMapDimension = this.font.getDimensionOfCharacterDiscrete(toDraw);
|
||||
|
||||
@ -84,7 +84,7 @@ public class TextBox extends StandardDrawableContainerElement {
|
||||
public void setText(String text) {
|
||||
this.text = text;
|
||||
generateLetters();
|
||||
Globals.signalSystem.post(SignalType.APPLY_YOGA,this);
|
||||
Globals.signalSystem.post(SignalType.YOGA_APPLY,this);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -109,9 +109,9 @@ public class TextBox extends StandardDrawableContainerElement {
|
||||
void generateLetters(){
|
||||
//free children
|
||||
for(Element child : childList){
|
||||
child.destroy();
|
||||
Globals.signalSystem.post(SignalType.YOGA_DESTROY, child);
|
||||
}
|
||||
childList.clear();
|
||||
this.clearChildren();
|
||||
String[] words = text.split(" ");
|
||||
for(int i = 0; i < words.length - 1; i++){
|
||||
Word word = Word.createWord(words[i]);
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
package electrosphere.renderer.ui.elements;
|
||||
|
||||
import electrosphere.engine.Globals;
|
||||
import electrosphere.engine.signal.Signal.SignalType;
|
||||
import electrosphere.logger.LoggerInterface;
|
||||
import electrosphere.renderer.OpenGLState;
|
||||
import electrosphere.renderer.RenderPipelineState;
|
||||
@ -99,10 +100,9 @@ public class TextInput extends StandardContainerElement implements DrawableEleme
|
||||
|
||||
void generateLetters(){
|
||||
for(Element el : getChildren()){
|
||||
Yoga.YGNodeRemoveChild(this.yogaNode,el.getYogaNode());
|
||||
el.destroy();
|
||||
Globals.signalSystem.post(SignalType.YOGA_DESTROY, el);
|
||||
}
|
||||
childList.clear();
|
||||
this.clearChildren();
|
||||
for(int i = 0; i < text.length(); i++){
|
||||
char toDraw = text.charAt(i);
|
||||
Vector3f bitMapDimension = this.font.getDimensionOfCharacterDiscrete(toDraw);
|
||||
|
||||
@ -15,6 +15,7 @@ import org.lwjgl.util.yoga.YGNode;
|
||||
import org.lwjgl.util.yoga.Yoga;
|
||||
|
||||
import electrosphere.engine.Globals;
|
||||
import electrosphere.engine.signal.Signal.SignalType;
|
||||
import electrosphere.logger.LoggerInterface;
|
||||
import electrosphere.renderer.OpenGLState;
|
||||
import electrosphere.renderer.RenderPipelineState;
|
||||
@ -170,8 +171,9 @@ public class Window implements DrawableElement, ContainerElement, NavigableEleme
|
||||
*/
|
||||
public void destroy(){
|
||||
for(Element el : getChildren()){
|
||||
el.destroy();
|
||||
Globals.signalSystem.post(SignalType.YOGA_DESTROY, el);
|
||||
}
|
||||
this.clearChildren();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -179,10 +181,9 @@ public class Window implements DrawableElement, ContainerElement, NavigableEleme
|
||||
*/
|
||||
public void clear(){
|
||||
for(Element el : getChildren()){
|
||||
Yoga.YGNodeRemoveChild(this.yogaNode,el.getYogaNode());
|
||||
el.destroy();
|
||||
Globals.signalSystem.post(SignalType.YOGA_DESTROY, el);
|
||||
}
|
||||
getChildren().clear();
|
||||
this.clearChildren();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -78,7 +78,7 @@ public class Word extends StandardDrawableContainerElement {
|
||||
public void setText(String text) {
|
||||
this.text = text;
|
||||
generateLetters();
|
||||
Globals.signalSystem.post(SignalType.APPLY_YOGA,this);
|
||||
Globals.signalSystem.post(SignalType.YOGA_APPLY,this);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -87,9 +87,9 @@ public class Word extends StandardDrawableContainerElement {
|
||||
void generateLetters(){
|
||||
//free children
|
||||
for(Element child : childList){
|
||||
child.destroy();
|
||||
Globals.signalSystem.post(SignalType.YOGA_DESTROY, child);
|
||||
}
|
||||
childList.clear();
|
||||
this.clearChildren();
|
||||
for(int i = 0; i < text.length(); i++){
|
||||
char toDraw = text.charAt(i);
|
||||
|
||||
|
||||
@ -36,7 +36,7 @@ public class SignalSystemTests {
|
||||
|
||||
SignalService service = Mockito.mock(SignalService.class);
|
||||
|
||||
signalSystem.registerService(SignalType.APPLY_YOGA, service);
|
||||
signalSystem.registerService(SignalType.YOGA_APPLY, service);
|
||||
}
|
||||
|
||||
|
||||
@ -46,9 +46,9 @@ public class SignalSystemTests {
|
||||
signalSystem.init();
|
||||
|
||||
SignalService service = Mockito.mock(SignalService.class);
|
||||
signalSystem.registerService(SignalType.APPLY_YOGA, service);
|
||||
signalSystem.registerService(SignalType.YOGA_APPLY, service);
|
||||
|
||||
signalSystem.post(SignalType.APPLY_YOGA);
|
||||
signalSystem.post(SignalType.YOGA_APPLY);
|
||||
|
||||
Mockito.verify(service, Mockito.times(1)).post(signalCaptor.capture());
|
||||
}
|
||||
@ -60,10 +60,10 @@ public class SignalSystemTests {
|
||||
|
||||
SignalService service = Mockito.mock(SignalService.class);
|
||||
SignalService service2 = Mockito.mock(SignalService.class);
|
||||
signalSystem.registerService(SignalType.APPLY_YOGA, service);
|
||||
signalSystem.registerService(SignalType.APPLY_YOGA, service2);
|
||||
signalSystem.registerService(SignalType.YOGA_APPLY, service);
|
||||
signalSystem.registerService(SignalType.YOGA_APPLY, service2);
|
||||
|
||||
signalSystem.post(SignalType.APPLY_YOGA);
|
||||
signalSystem.post(SignalType.YOGA_APPLY);
|
||||
|
||||
Mockito.verify(service, Mockito.times(1)).post(signalCaptor.capture());
|
||||
Mockito.verify(service2, Mockito.times(1)).post(signalCaptor.capture());
|
||||
@ -77,11 +77,11 @@ public class SignalSystemTests {
|
||||
SignalService service = Mockito.mock(SignalService.class);
|
||||
SignalService service2 = Mockito.mock(SignalService.class);
|
||||
SignalService service3 = Mockito.mock(SignalService.class);
|
||||
signalSystem.registerService(SignalType.APPLY_YOGA, service);
|
||||
signalSystem.registerService(SignalType.APPLY_YOGA, service2);
|
||||
signalSystem.registerService(SignalType.YOGA_APPLY, service);
|
||||
signalSystem.registerService(SignalType.YOGA_APPLY, service2);
|
||||
signalSystem.registerService(SignalType.ENGINE_SHUTDOWN, service3);
|
||||
|
||||
signalSystem.post(SignalType.APPLY_YOGA);
|
||||
signalSystem.post(SignalType.YOGA_APPLY);
|
||||
|
||||
Mockito.verify(service, Mockito.times(1)).post(signalCaptor.capture());
|
||||
Mockito.verify(service2, Mockito.times(1)).post(signalCaptor.capture());
|
||||
@ -95,9 +95,9 @@ public class SignalSystemTests {
|
||||
signalSystem.init();
|
||||
|
||||
SignalService service = Mockito.mock(SignalService.class);
|
||||
signalSystem.registerService(SignalType.APPLY_YOGA, service);
|
||||
signalSystem.deregisterService(SignalType.APPLY_YOGA, service);
|
||||
signalSystem.post(SignalType.APPLY_YOGA);
|
||||
signalSystem.registerService(SignalType.YOGA_APPLY, service);
|
||||
signalSystem.deregisterService(SignalType.YOGA_APPLY, service);
|
||||
signalSystem.post(SignalType.YOGA_APPLY);
|
||||
|
||||
Mockito.verify(service, Mockito.never()).post(signalCaptor.capture());
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user