thread-safe deleting elements
All checks were successful
studiorailgun/Renderer/pipeline/head This commit looks good

This commit is contained in:
austin 2024-09-01 22:19:56 -04:00
parent 467c42bfe8
commit f09bb23abc
25 changed files with 165 additions and 108 deletions

View File

@ -501,7 +501,8 @@ public class Globals {
// //
//Register all signals //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);
} }

View File

@ -442,8 +442,9 @@ public class Main {
// S H U T D O W N // S H U T D O W N
// //
//Terminate the program. //Terminate the program.
if(!Globals.HEADLESS && Globals.RUN_CLIENT){ if(Globals.RUN_CLIENT){
glfwTerminate(); glfwTerminate();
Globals.renderingEngine.clearGlobalState();
} }
//used to signal threads to stop //used to signal threads to stop
Globals.threadManager.close(); Globals.threadManager.close();

View File

@ -20,7 +20,8 @@ public class Signal {
// //
//UI //UI
// //
APPLY_YOGA, YOGA_APPLY,
YOGA_DESTROY,
} }

View File

@ -67,8 +67,15 @@ public class SignalServiceImpl implements SignalService {
* Handles all signals provided to the main thread * Handles all signals provided to the main thread
*/ */
public void handleAllSignals(){ public void handleAllSignals(){
//
//fully copy to this thread
this.threadLock.acquireUninterruptibly(); 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); boolean result = this.handle(signal);
if(!result){ if(!result){
String message = "Signal provided to service that does not support that signal type!\n" + 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)); LoggerInterface.loggerEngine.ERROR(new IllegalStateException(message));
} }
} }
this.threadLock.release();
} }
/** /**

View File

@ -29,7 +29,7 @@ public class WindowUtils {
//todo: destroy elements as well //todo: destroy elements as well
mainMenu.clear(); mainMenu.clear();
mainMenu.addChild(newMenu); mainMenu.addChild(newMenu);
Globals.signalSystem.post(SignalType.APPLY_YOGA, mainMenu); Globals.signalSystem.post(SignalType.YOGA_APPLY, mainMenu);
Globals.elementService.focusFirstElement(); Globals.elementService.focusFirstElement();
} }
} }
@ -52,7 +52,7 @@ public class WindowUtils {
Globals.elementService.focusFirstElement(); Globals.elementService.focusFirstElement();
} }
if(visible){ 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); Label loadingLabel = new Label(1.0f);
loadingLabel.setText("LOADING"); loadingLabel.setText("LOADING");
loadingWindow.addChild(loadingLabel); loadingWindow.addChild(loadingLabel);
Globals.signalSystem.post(SignalType.APPLY_YOGA,loadingWindow); Globals.signalSystem.post(SignalType.YOGA_APPLY,loadingWindow);
Globals.elementService.registerWindow(WindowStrings.WINDOW_LOADING, loadingWindow); Globals.elementService.registerWindow(WindowStrings.WINDOW_LOADING, loadingWindow);
WindowUtils.recursiveSetVisible(loadingWindow, true); WindowUtils.recursiveSetVisible(loadingWindow, true);
} }

View File

@ -100,7 +100,7 @@ public class MenuGeneratorsInGame {
})); }));
} }
Globals.signalSystem.post(SignalType.APPLY_YOGA,rVal); Globals.signalSystem.post(SignalType.YOGA_APPLY,rVal);
return rVal; return rVal;
} }
@ -298,7 +298,7 @@ public class MenuGeneratorsInGame {
return false; return false;
}}); }});
Globals.signalSystem.post(SignalType.APPLY_YOGA,rVal); Globals.signalSystem.post(SignalType.YOGA_APPLY,rVal);
return 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; return rVal;
} }

View File

@ -42,7 +42,7 @@ public class MenuGeneratorsInventory {
rVal.setParentJustifyContent(YogaJustification.Center); 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 //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(); Div div = Div.createDiv();
rVal.addChild(div); rVal.addChild(div);

View File

@ -82,7 +82,7 @@ public class MenuGeneratorsLevelEditor {
fillInDefaultContent(scrollable); fillInDefaultContent(scrollable);
Globals.signalSystem.post(SignalType.APPLY_YOGA,mainSidePanel); Globals.signalSystem.post(SignalType.YOGA_APPLY,mainSidePanel);
return mainSidePanel; return mainSidePanel;
} }
@ -142,7 +142,7 @@ public class MenuGeneratorsLevelEditor {
fillInAtmosphericControlContent(scrollable); 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); scrollable.addChild(zDiv);
Globals.signalSystem.post(SignalType.APPLY_YOGA,mainSidePanel); Globals.signalSystem.post(SignalType.YOGA_APPLY,mainSidePanel);
} }

View File

@ -94,7 +94,7 @@ public class MenuGeneratorsTerrainEditing {
fillInVoxelSelectors(scrollable, searchInput.getText()); fillInVoxelSelectors(scrollable, searchInput.getText());
Globals.signalSystem.post(SignalType.APPLY_YOGA,rVal); Globals.signalSystem.post(SignalType.YOGA_APPLY,rVal);
return rVal; return rVal;
} }
@ -143,7 +143,7 @@ public class MenuGeneratorsTerrainEditing {
scrollable.addChild(newButton); scrollable.addChild(newButton);
} }
Globals.signalSystem.post(SignalType.APPLY_YOGA,rVal); Globals.signalSystem.post(SignalType.YOGA_APPLY,rVal);
} }
} }

View File

@ -161,6 +161,7 @@ public class OpenGLState {
this.framebufferType = framebufferType; this.framebufferType = framebufferType;
this.framebufferPointer = framebufferPointer; this.framebufferPointer = framebufferPointer;
GL40.glBindFramebuffer(this.framebufferType,this.framebufferPointer); GL40.glBindFramebuffer(this.framebufferType,this.framebufferPointer);
Globals.renderingEngine.checkError();
} }
} }
@ -182,8 +183,7 @@ public class OpenGLState {
activeShader = program; activeShader = program;
GL40.glUseProgram(activeShader.getShaderId()); GL40.glUseProgram(activeShader.getShaderId());
int glErrorCode = Globals.renderingEngine.getError(); int glErrorCode = Globals.renderingEngine.getError();
//TODO: fix manually ignoring GL_INVALID_VALUE from call if(glErrorCode != 0){
if(glErrorCode != 0 && glErrorCode != GL40.GL_INVALID_VALUE){
LoggerInterface.loggerRenderer.DEBUG_LOOP(RenderingEngine.getErrorInEnglish(glErrorCode)); LoggerInterface.loggerRenderer.DEBUG_LOOP(RenderingEngine.getErrorInEnglish(glErrorCode));
} }
Globals.renderingEngine.checkError(); Globals.renderingEngine.checkError();

View File

@ -53,7 +53,6 @@ import static org.lwjgl.opengl.GL20.glUniformMatrix4fv;
import static org.lwjgl.opengl.GL20.glUseProgram; import static org.lwjgl.opengl.GL20.glUseProgram;
import static org.lwjgl.opengl.GL30.GL_FRAMEBUFFER; import static org.lwjgl.opengl.GL30.GL_FRAMEBUFFER;
import static org.lwjgl.opengl.GL30.GL_RENDERBUFFER; 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.glBindRenderbuffer;
import static org.lwjgl.opengl.GL30.glBindVertexArray; import static org.lwjgl.opengl.GL30.glBindVertexArray;
import static org.lwjgl.opengl.GL30.glClearBufferfv; import static org.lwjgl.opengl.GL30.glClearBufferfv;
@ -335,7 +334,8 @@ public class RenderingEngine {
screenTextureDepth = FramebufferUtils.generateScreenTextureDepth(openGLState, Globals.userSettings.getRenderResolutionX(), Globals.userSettings.getRenderResolutionY()); screenTextureDepth = FramebufferUtils.generateScreenTextureDepth(openGLState, Globals.userSettings.getRenderResolutionX(), Globals.userSettings.getRenderResolutionY());
screenFramebuffer = FramebufferUtils.generateScreenTextureFramebuffer(openGLState, Globals.userSettings.getRenderResolutionX(), Globals.userSettings.getRenderResolutionY(), screenTextureColor, screenTextureDepth); screenFramebuffer = FramebufferUtils.generateScreenTextureFramebuffer(openGLState, Globals.userSettings.getRenderResolutionX(), Globals.userSettings.getRenderResolutionY(), screenTextureColor, screenTextureDepth);
openGLState.glBindFramebuffer(GL_FRAMEBUFFER, GL_DEFAULT_FRAMEBUFFER); 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 //Channel debug program
@ -447,6 +447,15 @@ public class RenderingEngine {
Globals.projectionMatrix.setPerspective(verticalFOV, Globals.aspectRatio, nearClip, Globals.userSettings.getGraphicsViewDistance()); Globals.projectionMatrix.setPerspective(verticalFOV, Globals.aspectRatio, nearClip, Globals.userSettings.getGraphicsViewDistance());
Globals.viewMatrix.translation(new Vector3f(0.0f,0.0f,-3.0f)); Globals.viewMatrix.translation(new Vector3f(0.0f,0.0f,-3.0f));
} }
/**
* Clears global, static state
*/
public void clearGlobalState(){
screenTextureColor = null;
screenTextureDepth = null;
screenFramebuffer = null;
}
/** /**
@ -689,25 +698,25 @@ public class RenderingEngine {
return null; return null;
} }
case GL11.GL_INVALID_ENUM: { 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: { 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: { 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: { 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: { 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: { 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: { 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: { default: {
return "Un-enum'd error or no error. Code: " + errorCode; return "Un-enum'd error or no error. Code: " + errorCode;

View File

@ -16,14 +16,17 @@ import java.util.concurrent.TimeUnit;
import org.lwjgl.opengl.GL40; import org.lwjgl.opengl.GL40;
import org.lwjgl.system.MemoryUtil; 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; import static org.lwjgl.opengl.GL45.glCheckNamedFramebufferStatus;
/** /**
* Framebuffer object * Framebuffer object
*/ */
public class Framebuffer { public class Framebuffer {
/**
* The default framebuffer's pointer
*/
public static final int DEFAULT_FRAMEBUFFER_POINTER = 0;
//the pointer to the framebuffer //the pointer to the framebuffer
int framebufferPointer; int framebufferPointer;
@ -40,7 +43,8 @@ public class Framebuffer {
* Creates a framebuffer * Creates a framebuffer
*/ */
public Framebuffer(){ public Framebuffer(){
framebufferPointer = glGenFramebuffers(); framebufferPointer = GL40.glGenFramebuffers();
Globals.renderingEngine.checkError();
} }
/** /**
@ -80,7 +84,7 @@ public class Framebuffer {
* @param openGLState The opengl state * @param openGLState The opengl state
*/ */
public void bind(OpenGLState openGLState){ 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 * @return true if compiled correctly, false otherwise
*/ */
public boolean isComplete(){ 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 * @return true if error, false otherwise
*/ */
public boolean isError(){ public boolean isError(){
return glCheckNamedFramebufferStatus(framebufferPointer,GL_FRAMEBUFFER) == 0; return glCheckNamedFramebufferStatus(framebufferPointer,GL40.GL_FRAMEBUFFER) == 0;
} }
public void checkStatus(){ public void checkStatus(){
@ -121,14 +125,14 @@ public class Framebuffer {
* Frees the framebuffer * Frees the framebuffer
*/ */
public void free(){ public void free(){
glDeleteFramebuffers(framebufferPointer); GL40.glDeleteFramebuffers(framebufferPointer);
} }
/** /**
* Blocks the thread until the framebuffer has compiled * Blocks the thread until the framebuffer has compiled
*/ */
public void blockUntilCompiled(){ public void blockUntilCompiled(){
while(glCheckNamedFramebufferStatus(framebufferPointer,GL_FRAMEBUFFER) != GL_FRAMEBUFFER_UNDEFINED){ while(glCheckNamedFramebufferStatus(framebufferPointer,GL40.GL_FRAMEBUFFER) != GL40.GL_FRAMEBUFFER_UNDEFINED){
try { try {
TimeUnit.MILLISECONDS.sleep(1); TimeUnit.MILLISECONDS.sleep(1);
} catch (InterruptedException ex) { } catch (InterruptedException ex) {
@ -142,26 +146,26 @@ public class Framebuffer {
* @return The status * @return The status
*/ */
public String getStatus(){ public String getStatus(){
switch(glCheckNamedFramebufferStatus(framebufferPointer,GL_FRAMEBUFFER)){ switch(glCheckNamedFramebufferStatus(framebufferPointer,GL40.GL_FRAMEBUFFER)){
case GL_FRAMEBUFFER_UNDEFINED: { case GL40.GL_FRAMEBUFFER_UNDEFINED: {
return "The specified framebuffer is the default read or draw framebuffer, but the default framebuffer does not exist."; 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."; 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."; 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."; 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."; 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."; 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."; 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: { case 0: {
@ -196,12 +200,21 @@ public class Framebuffer {
*/ */
public void attachTexture(OpenGLState openGLState, Texture texture, int attachmentNum){ public void attachTexture(OpenGLState openGLState, Texture texture, int attachmentNum){
this.attachTextureMap.put(attachmentNum,texture); this.attachTextureMap.put(attachmentNum,texture);
this.texture = texture;
if(this.mipMap < 0){ if(this.mipMap < 0){
LoggerInterface.loggerRenderer.ERROR(new IllegalStateException("Trying to attach a texture to a framebuffer where mipmap hasn't been set.")); LoggerInterface.loggerRenderer.ERROR(new IllegalStateException("Trying to attach a texture to a framebuffer where mipmap hasn't been set."));
} }
this.texture = texture; if(this.framebufferPointer == Framebuffer.DEFAULT_FRAMEBUFFER_POINTER){
openGLState.glBindFramebuffer(GL_FRAMEBUFFER, framebufferPointer); throw new IllegalStateException("Trying to attach image to default frame buffer!");
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0 + attachmentNum, GL_TEXTURE_2D, texture.getTexturePointer(), this.mipMap); }
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 * @param texturePointer The depth attachment's pointer
*/ */
public void setDepthAttachment(OpenGLState openGLState, Texture depthTexture){ public void setDepthAttachment(OpenGLState openGLState, Texture depthTexture){
openGLState.glBindFramebuffer(GL_FRAMEBUFFER, framebufferPointer); openGLState.glBindFramebuffer(GL40.GL_FRAMEBUFFER, this.framebufferPointer);
this.depthTexture = depthTexture; this.depthTexture = depthTexture;
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, depthTexture.getTexturePointer(), this.mipMap); GL40.glFramebufferTexture2D(GL40.GL_FRAMEBUFFER, GL40.GL_DEPTH_ATTACHMENT, GL40.GL_TEXTURE_2D, depthTexture.getTexturePointer(), 0);
openGLState.glBindFramebuffer(GL_FRAMEBUFFER, 0); Globals.renderingEngine.checkError();
checkStatus(); openGLState.glBindFramebuffer(GL40.GL_FRAMEBUFFER, 0);
} }
/** /**

View File

@ -2,11 +2,13 @@ package electrosphere.renderer.framebuffer;
import electrosphere.engine.Globals; import electrosphere.engine.Globals;
import electrosphere.renderer.OpenGLState; import electrosphere.renderer.OpenGLState;
import electrosphere.renderer.RenderingEngine;
import electrosphere.renderer.texture.Texture; import electrosphere.renderer.texture.Texture;
import java.nio.IntBuffer; import java.nio.IntBuffer;
import org.lwjgl.BufferUtils; 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_DEPTH_COMPONENT;
import static org.lwjgl.opengl.GL11.GL_FLOAT; import static org.lwjgl.opengl.GL11.GL_FLOAT;
@ -134,9 +136,12 @@ public class FramebufferUtils {
//renderbuffer //renderbuffer
int renderBuffer = glGenRenderbuffers(); int renderBuffer = glGenRenderbuffers();
glBindRenderbuffer(GL_RENDERBUFFER, renderBuffer); glBindRenderbuffer(GL_RENDERBUFFER, renderBuffer);
Globals.renderingEngine.checkError();
glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH24_STENCIL8, Globals.WINDOW_WIDTH, Globals.WINDOW_HEIGHT); glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH24_STENCIL8, Globals.WINDOW_WIDTH, Globals.WINDOW_HEIGHT);
Globals.renderingEngine.checkError();
//bind rbo to fbo //bind rbo to fbo
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_RENDERBUFFER, renderBuffer); glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_RENDERBUFFER, renderBuffer);
Globals.renderingEngine.checkError();
//check make sure compiled //check make sure compiled
buffer.checkStatus(); buffer.checkStatus();
return buffer; return buffer;
@ -159,12 +164,18 @@ public class FramebufferUtils {
buffer.attachTexture(openGLState,texture); buffer.attachTexture(openGLState,texture);
//renderbuffer //renderbuffer
int renderBuffer = glGenRenderbuffers(); int renderBuffer = glGenRenderbuffers();
glBindRenderbuffer(GL_RENDERBUFFER, renderBuffer); GL40.glBindRenderbuffer(GL_RENDERBUFFER, renderBuffer);
glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH24_STENCIL8, width, height); Globals.renderingEngine.checkError();
GL40.glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH24_STENCIL8, width, height);
Globals.renderingEngine.checkError();
//bind rbo to fbo //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 //check make sure compiled
buffer.checkStatus(); buffer.checkStatus();
//re-bind default buffer
RenderingEngine.defaultFramebuffer.bind(openGLState);
return buffer; return buffer;
} }
@ -177,6 +188,7 @@ public class FramebufferUtils {
buffer.bind(); buffer.bind();
glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH24_STENCIL8, Globals.WINDOW_WIDTH, Globals.WINDOW_HEIGHT); glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH24_STENCIL8, Globals.WINDOW_WIDTH, Globals.WINDOW_HEIGHT);
Globals.renderingEngine.checkError(); Globals.renderingEngine.checkError();
Globals.renderingEngine.checkError();
return buffer; return buffer;
} }
@ -203,7 +215,9 @@ public class FramebufferUtils {
buffer.setMipMapLevel(0); buffer.setMipMapLevel(0);
buffer.setDepthAttachment(openGLState,texture); buffer.setDepthAttachment(openGLState,texture);
glNamedFramebufferDrawBuffer(buffer.getFramebufferPointer(), GL_NONE); glNamedFramebufferDrawBuffer(buffer.getFramebufferPointer(), GL_NONE);
Globals.renderingEngine.checkError();
glNamedFramebufferReadBuffer(buffer.getFramebufferPointer(), GL_NONE); glNamedFramebufferReadBuffer(buffer.getFramebufferPointer(), GL_NONE);
Globals.renderingEngine.checkError();
@ -234,7 +248,9 @@ public class FramebufferUtils {
buffer.setMipMapLevel(0); buffer.setMipMapLevel(0);
buffer.setDepthAttachment(openGLState,texture); buffer.setDepthAttachment(openGLState,texture);
glNamedFramebufferDrawBuffer(buffer.getFramebufferPointer(), GL_NONE); glNamedFramebufferDrawBuffer(buffer.getFramebufferPointer(), GL_NONE);
Globals.renderingEngine.checkError();
glNamedFramebufferReadBuffer(buffer.getFramebufferPointer(), GL_NONE); glNamedFramebufferReadBuffer(buffer.getFramebufferPointer(), GL_NONE);
Globals.renderingEngine.checkError();
@ -279,6 +295,7 @@ public class FramebufferUtils {
drawBuffers.put(GL_COLOR_ATTACHMENT1); drawBuffers.put(GL_COLOR_ATTACHMENT1);
drawBuffers.flip(); drawBuffers.flip();
glNamedFramebufferDrawBuffers(buffer.getFramebufferPointer(),drawBuffers); glNamedFramebufferDrawBuffers(buffer.getFramebufferPointer(),drawBuffers);
Globals.renderingEngine.checkError();
//check make sure compiled //check make sure compiled
buffer.checkStatus(); buffer.checkStatus();

View File

@ -161,8 +161,7 @@ public class LightManager {
//get position of lights object in shader //get position of lights object in shader
int bufferIndex = GL31.glGetUniformBlockIndex(openGLState.getActiveShader().getShaderId(), "Lights"); int bufferIndex = GL31.glGetUniformBlockIndex(openGLState.getActiveShader().getShaderId(), "Lights");
int glErrorCode = Globals.renderingEngine.getError(); int glErrorCode = Globals.renderingEngine.getError();
//TODO: fix manually ignoring GL_INVALID_VALUE from call if(glErrorCode != 0){
if(glErrorCode != 0 && glErrorCode != GL40.GL_INVALID_VALUE){
LoggerInterface.loggerRenderer.DEBUG_LOOP(RenderingEngine.getErrorInEnglish(glErrorCode)); LoggerInterface.loggerRenderer.DEBUG_LOOP(RenderingEngine.getErrorInEnglish(glErrorCode));
} }
if(bufferIndex == ShaderProgram.INVALID_UNIFORM_NAME){ if(bufferIndex == ShaderProgram.INVALID_UNIFORM_NAME){

View File

@ -575,6 +575,7 @@ public class ShaderProgram {
//Deletes the individual shader objects to free up memory //Deletes the individual shader objects to free up memory
glDeleteShader(rVal.vertexShader); glDeleteShader(rVal.vertexShader);
glDeleteShader(rVal.fragmentShader); glDeleteShader(rVal.fragmentShader);
Globals.renderingEngine.checkError();
@ -749,8 +750,7 @@ public class ShaderProgram {
//get uniform location //get uniform location
int uniformLocation = GL40.glGetUniformLocation(this.getShaderId(), uniformName); int uniformLocation = GL40.glGetUniformLocation(this.getShaderId(), uniformName);
int glErrorCode = Globals.renderingEngine.getError(); int glErrorCode = Globals.renderingEngine.getError();
//TODO: fix manually ignoring GL_INVALID_VALUE from call if(glErrorCode != 0){
if(glErrorCode != 0 && glErrorCode != GL40.GL_INVALID_VALUE){
LoggerInterface.loggerRenderer.DEBUG_LOOP(RenderingEngine.getErrorInEnglish(glErrorCode)); LoggerInterface.loggerRenderer.DEBUG_LOOP(RenderingEngine.getErrorInEnglish(glErrorCode));
LoggerInterface.loggerRenderer.WARNING("Shader id: " + this.getShaderId()); LoggerInterface.loggerRenderer.WARNING("Shader id: " + this.getShaderId());
} }

View File

@ -29,8 +29,13 @@ import static org.lwjgl.opengl.GL30.*;
*/ */
public class Texture { public class Texture {
/**
* Pointer for an uninitialized texture
*/
public static final int UNINITIALIZED_TEXTURE = -1;
//the pointer for the texture //the pointer for the texture
int texturePointer = -1; int texturePointer = UNINITIALIZED_TEXTURE;
//the width of the texture //the width of the texture
int width = -1; int width = -1;
//the height of the texture //the height of the texture
@ -51,20 +56,13 @@ public class Texture {
//the data type of a single component of a pixel (IE UNSIGNED_INT, BYTE, etc) //the data type of a single component of a pixel (IE UNSIGNED_INT, BYTE, etc)
int datatype = -1; 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 * Creates a texture with a new opengl texture object
*/ */
public Texture(){ 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 * @param bufferedImage The java bufferedimage object
*/ */
public Texture(OpenGLState openGlState, BufferedImage bufferedImage){ public Texture(OpenGLState openGlState, BufferedImage bufferedImage){
this.texturePointer = glGenTextures(); this.texturePointer = GL40.glGenTextures();
Globals.renderingEngine.checkError();
//bind the new texture //bind the new texture
openGlState.glBindTexture(GL_TEXTURE_2D, texturePointer); openGlState.glBindTexture(GL_TEXTURE_2D, texturePointer);
//how are we gonna wrap the texture?? //how are we gonna wrap the texture??
@ -154,7 +153,8 @@ public class Texture {
if(!Globals.HEADLESS){ if(!Globals.HEADLESS){
LoggerInterface.loggerRenderer.DEBUG("Setup texture object"); LoggerInterface.loggerRenderer.DEBUG("Setup texture object");
//generate the texture object on gpu //generate the texture object on gpu
this.texturePointer = glGenTextures(); this.texturePointer = GL40.glGenTextures();
Globals.renderingEngine.checkError();
//bind the new texture //bind the new texture
openGlState.glBindTexture(GL_TEXTURE_2D, texturePointer); openGlState.glBindTexture(GL_TEXTURE_2D, texturePointer);
//how are we gonna wrap the texture?? //how are we gonna wrap the texture??
@ -239,7 +239,8 @@ public class Texture {
public Texture(OpenGLState openGlState, ByteBuffer buffer, int width, int height){ public Texture(OpenGLState openGlState, ByteBuffer buffer, int width, int height){
if(!Globals.HEADLESS){ if(!Globals.HEADLESS){
//generate the texture object on gpu //generate the texture object on gpu
this.texturePointer = glGenTextures(); this.texturePointer = GL40.glGenTextures();
Globals.renderingEngine.checkError();
//bind the new texture //bind the new texture
openGlState.glBindTexture(GL_TEXTURE_2D, texturePointer); openGlState.glBindTexture(GL_TEXTURE_2D, texturePointer);
//how are we gonna wrap the texture?? //how are we gonna wrap the texture??

View File

@ -513,11 +513,16 @@ public class ElementService extends SignalServiceImpl {
public boolean handle(Signal signal){ public boolean handle(Signal signal){
boolean rVal = false; boolean rVal = false;
switch(signal.getType()){ switch(signal.getType()){
case APPLY_YOGA: { case YOGA_APPLY: {
Element target = (Element)signal.getData(); Element target = (Element)signal.getData();
target.applyYoga(0, 0); target.applyYoga(0, 0);
rVal = true; rVal = true;
} break; } break;
case YOGA_DESTROY: {
Element target = (Element)signal.getData();
target.destroy();
rVal = true;
} break;
default: { default: {
} break; } break;
} }

View File

@ -4,6 +4,7 @@ import org.joml.Vector3f;
import org.lwjgl.util.yoga.Yoga; import org.lwjgl.util.yoga.Yoga;
import electrosphere.engine.Globals; import electrosphere.engine.Globals;
import electrosphere.engine.signal.Signal.SignalType;
import electrosphere.renderer.OpenGLState; import electrosphere.renderer.OpenGLState;
import electrosphere.renderer.RenderPipelineState; import electrosphere.renderer.RenderPipelineState;
import electrosphere.renderer.debug.DebugRendering; import electrosphere.renderer.debug.DebugRendering;
@ -76,9 +77,9 @@ public class Label extends StandardContainerElement implements DrawableElement {
void generateLetters(){ void generateLetters(){
//free children //free children
for(Element child : childList){ for(Element child : childList){
child.destroy(); Globals.signalSystem.post(SignalType.YOGA_DESTROY, child);
} }
childList.clear(); this.clearChildren();
int accumulatingWidth = 0; int accumulatingWidth = 0;
for(int i = 0; i < text.length(); i++){ for(int i = 0; i < text.length(); i++){
char toDraw = text.charAt(i); char toDraw = text.charAt(i);

View File

@ -5,6 +5,8 @@ import java.util.List;
import org.lwjgl.util.yoga.Yoga; import org.lwjgl.util.yoga.Yoga;
import electrosphere.engine.Globals;
import electrosphere.engine.signal.Signal.SignalType;
import electrosphere.logger.LoggerInterface; import electrosphere.logger.LoggerInterface;
import electrosphere.renderer.ui.elementtypes.ContainerElement; import electrosphere.renderer.ui.elementtypes.ContainerElement;
import electrosphere.renderer.ui.elementtypes.DrawableElement; import electrosphere.renderer.ui.elementtypes.DrawableElement;
@ -236,7 +238,7 @@ public class StandardContainerElement extends StandardElement implements Contain
@Override @Override
public void destroy(){ public void destroy(){
for(Element child : childList){ for(Element child : childList){
child.destroy(); Globals.signalSystem.post(SignalType.YOGA_DESTROY, child);
} }
if(this.yogaNode != Element.NULL_YOGA_ELEMENT){ if(this.yogaNode != Element.NULL_YOGA_ELEMENT){
Yoga.YGNodeFree(this.yogaNode); Yoga.YGNodeFree(this.yogaNode);

View File

@ -7,6 +7,7 @@ import org.joml.Vector3f;
import org.lwjgl.util.yoga.Yoga; import org.lwjgl.util.yoga.Yoga;
import electrosphere.engine.Globals; import electrosphere.engine.Globals;
import electrosphere.engine.signal.Signal.SignalType;
import electrosphere.renderer.OpenGLState; import electrosphere.renderer.OpenGLState;
import electrosphere.renderer.RenderPipelineState; import electrosphere.renderer.RenderPipelineState;
import electrosphere.renderer.ui.elementtypes.DrawableElement; import electrosphere.renderer.ui.elementtypes.DrawableElement;
@ -73,10 +74,9 @@ public class StringCarousel extends StandardContainerElement implements Drawable
void generateLetters(){ void generateLetters(){
for(Element el : getChildren()){ for(Element el : getChildren()){
Yoga.YGNodeRemoveChild(this.yogaNode,el.getYogaNode()); Globals.signalSystem.post(SignalType.YOGA_DESTROY, el);
el.destroy();
} }
childList.clear(); this.clearChildren();
for(int i = 0; i < textCurrent.length(); i++){ for(int i = 0; i < textCurrent.length(); i++){
char toDraw = textCurrent.charAt(i); char toDraw = textCurrent.charAt(i);
Vector3f bitMapDimension = this.font.getDimensionOfCharacterDiscrete(toDraw); Vector3f bitMapDimension = this.font.getDimensionOfCharacterDiscrete(toDraw);

View File

@ -84,7 +84,7 @@ public class TextBox extends StandardDrawableContainerElement {
public void setText(String text) { public void setText(String text) {
this.text = text; this.text = text;
generateLetters(); 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(){ void generateLetters(){
//free children //free children
for(Element child : childList){ for(Element child : childList){
child.destroy(); Globals.signalSystem.post(SignalType.YOGA_DESTROY, child);
} }
childList.clear(); this.clearChildren();
String[] words = text.split(" "); String[] words = text.split(" ");
for(int i = 0; i < words.length - 1; i++){ for(int i = 0; i < words.length - 1; i++){
Word word = Word.createWord(words[i]); Word word = Word.createWord(words[i]);

View File

@ -1,6 +1,7 @@
package electrosphere.renderer.ui.elements; package electrosphere.renderer.ui.elements;
import electrosphere.engine.Globals; import electrosphere.engine.Globals;
import electrosphere.engine.signal.Signal.SignalType;
import electrosphere.logger.LoggerInterface; import electrosphere.logger.LoggerInterface;
import electrosphere.renderer.OpenGLState; import electrosphere.renderer.OpenGLState;
import electrosphere.renderer.RenderPipelineState; import electrosphere.renderer.RenderPipelineState;
@ -99,10 +100,9 @@ public class TextInput extends StandardContainerElement implements DrawableEleme
void generateLetters(){ void generateLetters(){
for(Element el : getChildren()){ for(Element el : getChildren()){
Yoga.YGNodeRemoveChild(this.yogaNode,el.getYogaNode()); Globals.signalSystem.post(SignalType.YOGA_DESTROY, el);
el.destroy();
} }
childList.clear(); this.clearChildren();
for(int i = 0; i < text.length(); i++){ for(int i = 0; i < text.length(); i++){
char toDraw = text.charAt(i); char toDraw = text.charAt(i);
Vector3f bitMapDimension = this.font.getDimensionOfCharacterDiscrete(toDraw); Vector3f bitMapDimension = this.font.getDimensionOfCharacterDiscrete(toDraw);

View File

@ -15,6 +15,7 @@ import org.lwjgl.util.yoga.YGNode;
import org.lwjgl.util.yoga.Yoga; import org.lwjgl.util.yoga.Yoga;
import electrosphere.engine.Globals; import electrosphere.engine.Globals;
import electrosphere.engine.signal.Signal.SignalType;
import electrosphere.logger.LoggerInterface; import electrosphere.logger.LoggerInterface;
import electrosphere.renderer.OpenGLState; import electrosphere.renderer.OpenGLState;
import electrosphere.renderer.RenderPipelineState; import electrosphere.renderer.RenderPipelineState;
@ -170,8 +171,9 @@ public class Window implements DrawableElement, ContainerElement, NavigableEleme
*/ */
public void destroy(){ public void destroy(){
for(Element el : getChildren()){ 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(){ public void clear(){
for(Element el : getChildren()){ for(Element el : getChildren()){
Yoga.YGNodeRemoveChild(this.yogaNode,el.getYogaNode()); Globals.signalSystem.post(SignalType.YOGA_DESTROY, el);
el.destroy();
} }
getChildren().clear(); this.clearChildren();
} }
@Override @Override

View File

@ -78,7 +78,7 @@ public class Word extends StandardDrawableContainerElement {
public void setText(String text) { public void setText(String text) {
this.text = text; this.text = text;
generateLetters(); 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(){ void generateLetters(){
//free children //free children
for(Element child : childList){ 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++){ for(int i = 0; i < text.length(); i++){
char toDraw = text.charAt(i); char toDraw = text.charAt(i);

View File

@ -36,7 +36,7 @@ public class SignalSystemTests {
SignalService service = Mockito.mock(SignalService.class); 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(); signalSystem.init();
SignalService service = Mockito.mock(SignalService.class); 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()); Mockito.verify(service, Mockito.times(1)).post(signalCaptor.capture());
} }
@ -60,10 +60,10 @@ public class SignalSystemTests {
SignalService service = Mockito.mock(SignalService.class); SignalService service = Mockito.mock(SignalService.class);
SignalService service2 = Mockito.mock(SignalService.class); SignalService service2 = Mockito.mock(SignalService.class);
signalSystem.registerService(SignalType.APPLY_YOGA, service); signalSystem.registerService(SignalType.YOGA_APPLY, service);
signalSystem.registerService(SignalType.APPLY_YOGA, service2); 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(service, Mockito.times(1)).post(signalCaptor.capture());
Mockito.verify(service2, 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 service = Mockito.mock(SignalService.class);
SignalService service2 = Mockito.mock(SignalService.class); SignalService service2 = Mockito.mock(SignalService.class);
SignalService service3 = Mockito.mock(SignalService.class); SignalService service3 = Mockito.mock(SignalService.class);
signalSystem.registerService(SignalType.APPLY_YOGA, service); signalSystem.registerService(SignalType.YOGA_APPLY, service);
signalSystem.registerService(SignalType.APPLY_YOGA, service2); signalSystem.registerService(SignalType.YOGA_APPLY, service2);
signalSystem.registerService(SignalType.ENGINE_SHUTDOWN, service3); 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(service, Mockito.times(1)).post(signalCaptor.capture());
Mockito.verify(service2, Mockito.times(1)).post(signalCaptor.capture()); Mockito.verify(service2, Mockito.times(1)).post(signalCaptor.capture());
@ -95,9 +95,9 @@ public class SignalSystemTests {
signalSystem.init(); signalSystem.init();
SignalService service = Mockito.mock(SignalService.class); SignalService service = Mockito.mock(SignalService.class);
signalSystem.registerService(SignalType.APPLY_YOGA, service); signalSystem.registerService(SignalType.YOGA_APPLY, service);
signalSystem.deregisterService(SignalType.APPLY_YOGA, service); signalSystem.deregisterService(SignalType.YOGA_APPLY, service);
signalSystem.post(SignalType.APPLY_YOGA); signalSystem.post(SignalType.YOGA_APPLY);
Mockito.verify(service, Mockito.never()).post(signalCaptor.capture()); Mockito.verify(service, Mockito.never()).post(signalCaptor.capture());
} }