framebuffer fixes
	
		
			
	
		
	
	
		
	
		
			Some checks failed
		
		
	
	
		
			
				
	
				studiorailgun/Renderer/pipeline/head There was a failure building this commit
				
			
		
		
	
	
				
					
				
			
		
			Some checks failed
		
		
	
	studiorailgun/Renderer/pipeline/head There was a failure building this commit
				
			This commit is contained in:
		
							parent
							
								
									1873b8abad
								
							
						
					
					
						commit
						b863c33253
					
				| @ -125,6 +125,7 @@ public class OpenGLState { | |||||||
|         if(DISABLE_CACHING || this.activeTexture != texture){ |         if(DISABLE_CACHING || this.activeTexture != texture){ | ||||||
|             this.activeTexture = texture; |             this.activeTexture = texture; | ||||||
|             GL40.glActiveTexture(this.activeTexture); |             GL40.glActiveTexture(this.activeTexture); | ||||||
|  |             Globals.renderingEngine.checkError(); | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
| @ -148,6 +149,7 @@ public class OpenGLState { | |||||||
|             unitToPointerMap.put(textureUnit,texturePointer); |             unitToPointerMap.put(textureUnit,texturePointer); | ||||||
|             this.glActiveTexture(textureUnit); |             this.glActiveTexture(textureUnit); | ||||||
|             GL40.glBindTexture(textureType,texturePointer); |             GL40.glBindTexture(textureType,texturePointer); | ||||||
|  |             Globals.renderingEngine.checkError(); | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -330,7 +330,7 @@ public class RenderingEngine { | |||||||
|         defaultFramebuffer = new Framebuffer(0); |         defaultFramebuffer = new Framebuffer(0); | ||||||
|          |          | ||||||
|         //generate framebuffers |         //generate framebuffers | ||||||
|         screenTextureColor = FramebufferUtils.generateScreenTextureColor(openGLState, Globals.userSettings.getRenderResolutionX(), Globals.userSettings.getRenderResolutionY()); |         screenTextureColor = FramebufferUtils.generateScreenTextureColorAlpha(openGLState, Globals.userSettings.getRenderResolutionX(), Globals.userSettings.getRenderResolutionY()); | ||||||
|         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); | ||||||
| @ -368,7 +368,7 @@ public class RenderingEngine { | |||||||
|     static Framebuffer gameImageNormalsFramebuffer; |     static Framebuffer gameImageNormalsFramebuffer; | ||||||
|     static ShaderProgram renderNormalsShader; |     static ShaderProgram renderNormalsShader; | ||||||
|         */ |         */ | ||||||
|         gameImageNormalsTexture = FramebufferUtils.generateScreenTextureColor(openGLState, Globals.userSettings.getRenderResolutionX(), Globals.userSettings.getRenderResolutionY()); |         gameImageNormalsTexture = FramebufferUtils.generateScreenTextureColorAlpha(openGLState, Globals.userSettings.getRenderResolutionX(), Globals.userSettings.getRenderResolutionY()); | ||||||
|         Texture gameImageNormalsDepthTexture = FramebufferUtils.generateScreenTextureDepth(openGLState, Globals.userSettings.getRenderResolutionX(), Globals.userSettings.getRenderResolutionY()); |         Texture gameImageNormalsDepthTexture = FramebufferUtils.generateScreenTextureDepth(openGLState, Globals.userSettings.getRenderResolutionX(), Globals.userSettings.getRenderResolutionY()); | ||||||
|         gameImageNormalsFramebuffer = FramebufferUtils.generateScreenTextureFramebuffer(openGLState, Globals.userSettings.getRenderResolutionX(), Globals.userSettings.getRenderResolutionY(), gameImageNormalsTexture, gameImageNormalsDepthTexture); |         gameImageNormalsFramebuffer = FramebufferUtils.generateScreenTextureFramebuffer(openGLState, Globals.userSettings.getRenderResolutionX(), Globals.userSettings.getRenderResolutionY(), gameImageNormalsTexture, gameImageNormalsDepthTexture); | ||||||
|         renderNormalsShader = ShaderProgram.loadSpecificShader("Shaders/anime/renderNormals.vs", "Shaders/anime/renderNormals.fs"); |         renderNormalsShader = ShaderProgram.loadSpecificShader("Shaders/anime/renderNormals.vs", "Shaders/anime/renderNormals.fs"); | ||||||
|  | |||||||
| @ -211,7 +211,6 @@ public class Framebuffer { | |||||||
|             throw new IllegalStateException("Trying to attach uninitialized image to frame buffer!"); |             throw new IllegalStateException("Trying to attach uninitialized image to frame buffer!"); | ||||||
|         } |         } | ||||||
|         openGLState.glBindFramebuffer(GL40.GL_FRAMEBUFFER, this.framebufferPointer); |         openGLState.glBindFramebuffer(GL40.GL_FRAMEBUFFER, this.framebufferPointer); | ||||||
|         texture.bind(openGLState); //texture must be bound at least once so that the object is created prior to attaching to framebuffer |  | ||||||
|         GL40.glFramebufferTexture2D(GL40.GL_FRAMEBUFFER, GL40.GL_COLOR_ATTACHMENT0 + attachmentNum, GL40.GL_TEXTURE_2D, texture.getTexturePointer(), 0); |         GL40.glFramebufferTexture2D(GL40.GL_FRAMEBUFFER, GL40.GL_COLOR_ATTACHMENT0 + attachmentNum, GL40.GL_TEXTURE_2D, texture.getTexturePointer(), 0); | ||||||
|         Globals.renderingEngine.checkError(); |         Globals.renderingEngine.checkError(); | ||||||
|         openGLState.glBindFramebuffer(GL40.GL_FRAMEBUFFER, 0); |         openGLState.glBindFramebuffer(GL40.GL_FRAMEBUFFER, 0); | ||||||
| @ -225,7 +224,6 @@ public class Framebuffer { | |||||||
|     public void setDepthAttachment(OpenGLState openGLState, Texture depthTexture){ |     public void setDepthAttachment(OpenGLState openGLState, Texture depthTexture){ | ||||||
|         openGLState.glBindFramebuffer(GL40.GL_FRAMEBUFFER, this.framebufferPointer); |         openGLState.glBindFramebuffer(GL40.GL_FRAMEBUFFER, this.framebufferPointer); | ||||||
|         this.depthTexture = depthTexture; |         this.depthTexture = depthTexture; | ||||||
|         depthTexture.bind(openGLState); //texture must be bound at least once so that the object is created prior to attaching to framebuffer |  | ||||||
|         GL40.glFramebufferTexture2D(GL40.GL_FRAMEBUFFER, GL40.GL_DEPTH_ATTACHMENT, GL40.GL_TEXTURE_2D, depthTexture.getTexturePointer(), 0); |         GL40.glFramebufferTexture2D(GL40.GL_FRAMEBUFFER, GL40.GL_DEPTH_ATTACHMENT, GL40.GL_TEXTURE_2D, depthTexture.getTexturePointer(), 0); | ||||||
|         Globals.renderingEngine.checkError(); |         Globals.renderingEngine.checkError(); | ||||||
|         openGLState.glBindFramebuffer(GL40.GL_FRAMEBUFFER, 0); |         openGLState.glBindFramebuffer(GL40.GL_FRAMEBUFFER, 0); | ||||||
|  | |||||||
| @ -46,26 +46,34 @@ public class FramebufferUtils { | |||||||
| 
 | 
 | ||||||
|     public static Texture generateScreenTextureColor(OpenGLState openGLState, int width, int height){ |     public static Texture generateScreenTextureColor(OpenGLState openGLState, int width, int height){ | ||||||
|         Texture texture = new Texture(); |         Texture texture = new Texture(); | ||||||
|         texture.glTexImage2D(openGLState, width, height, GL_RGB, GL_UNSIGNED_BYTE); |         texture.glTexImage2D(openGLState, width, height, GL_RGB, GL40.GL_RGB32F, GL_UNSIGNED_BYTE); | ||||||
|         texture.setMinFilter(openGLState, GL_LINEAR); |         texture.setMinFilter(openGLState, GL_LINEAR); | ||||||
|         texture.setMagFilter(openGLState, GL_LINEAR); |         texture.setMagFilter(openGLState, GL_LINEAR); | ||||||
|         //these make sure the texture actually clamps to the borders of the quad |         //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_S, GL_CLAMP_TO_EDGE); | ||||||
|         texture.setWrap(openGLState, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); |         texture.setWrap(openGLState, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); | ||||||
| 
 | 
 | ||||||
|  |         //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); | ||||||
|  | 
 | ||||||
|         texture.checkStatus(openGLState); |         texture.checkStatus(openGLState); | ||||||
|         return texture; |         return texture; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     public static Texture generateScreenTextureColorAlpha(OpenGLState openGLState, int width, int height){ |     public static Texture generateScreenTextureColorAlpha(OpenGLState openGLState, int width, int height){ | ||||||
|         Texture texture = new Texture(); |         Texture texture = new Texture(); | ||||||
|         texture.glTexImage2D(openGLState, width, height, GL_RGBA, GL_UNSIGNED_BYTE); |         texture.glTexImage2D(openGLState, width, height, GL_RGBA, GL40.GL_RGB32F, GL_UNSIGNED_BYTE); | ||||||
|         texture.setMinFilter(openGLState, GL_LINEAR); |         texture.setMinFilter(openGLState, GL_LINEAR); | ||||||
|         texture.setMagFilter(openGLState, GL_LINEAR); |         texture.setMagFilter(openGLState, GL_LINEAR); | ||||||
|         //these make sure the texture actually clamps to the borders of the quad |         //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_S, GL_CLAMP_TO_EDGE); | ||||||
|         texture.setWrap(openGLState, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); |         texture.setWrap(openGLState, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); | ||||||
| 
 | 
 | ||||||
|  |         //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); | ||||||
|  | 
 | ||||||
|         texture.checkStatus(openGLState); |         texture.checkStatus(openGLState); | ||||||
|         return texture; |         return texture; | ||||||
|     } |     } | ||||||
| @ -74,6 +82,10 @@ public class FramebufferUtils { | |||||||
|         Texture texture = new Texture(); |         Texture texture = new Texture(); | ||||||
|         texture.glTexImage2D(openGLState, width, height, GL_DEPTH_COMPONENT, GL_FLOAT); |         texture.glTexImage2D(openGLState, width, height, GL_DEPTH_COMPONENT, GL_FLOAT); | ||||||
| 
 | 
 | ||||||
|  |         //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); | ||||||
|  | 
 | ||||||
|         texture.checkStatus(openGLState); |         texture.checkStatus(openGLState); | ||||||
|         return texture; |         return texture; | ||||||
|     } |     } | ||||||
|  | |||||||
| @ -34,6 +34,11 @@ public class Texture { | |||||||
|      */ |      */ | ||||||
|     public static final int UNINITIALIZED_TEXTURE = -1; |     public static final int UNINITIALIZED_TEXTURE = -1; | ||||||
| 
 | 
 | ||||||
|  |     /** | ||||||
|  |      * The texture name for the default texture (ie the screen) | ||||||
|  |      */ | ||||||
|  |     public static final int DEFAULT_TEXTURE = 0; | ||||||
|  | 
 | ||||||
|     //the pointer for the texture |     //the pointer for the texture | ||||||
|     int texturePointer = UNINITIALIZED_TEXTURE; |     int texturePointer = UNINITIALIZED_TEXTURE; | ||||||
|     //the width of the texture |     //the width of the texture | ||||||
| @ -254,7 +259,7 @@ public class Texture { | |||||||
|             //buffer the texture information |             //buffer the texture information | ||||||
|             this.pixelFormat = GL_RED; |             this.pixelFormat = GL_RED; | ||||||
|             this.datatype = GL_FLOAT; |             this.datatype = GL_FLOAT; | ||||||
|             GL40.glTexImage2D(GL_TEXTURE_2D, 0, GL_R32F, width, height, 0, GL_RED, GL_FLOAT, buffer); |             this.glTexImage2D(openGlState, width, height, GL_RED, GL_FLOAT); | ||||||
|             //check build status |             //check build status | ||||||
|             String errorMessage = RenderingEngine.getErrorInEnglish(Globals.renderingEngine.getError()); |             String errorMessage = RenderingEngine.getErrorInEnglish(Globals.renderingEngine.getError()); | ||||||
|             if(errorMessage != null){ |             if(errorMessage != null){ | ||||||
| @ -393,6 +398,29 @@ public class Texture { | |||||||
|         Globals.renderingEngine.checkError(); |         Globals.renderingEngine.checkError(); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|  |     /** | ||||||
|  |      * Specifies a 2d image | ||||||
|  |      * @param width The width of the image | ||||||
|  |      * @param height The height of the image | ||||||
|  |      * @param format The format of the pixels (ie GL_RGB, GL_RGBA, etc) | ||||||
|  |      * @param internalformat The specific format type (ie GL_RGB32F, GL_RGBA32F, GL_R8, etc) | ||||||
|  |      * @param datatype The data type of a single component of a pixel (ie GL_BYTE, GL_UNSIGNED_INT, etc) | ||||||
|  |      */ | ||||||
|  |     public void glTexImage2D(OpenGLState openGLState, int width, int height, int format, int internalformat, int datatype){ | ||||||
|  |         //store provided values | ||||||
|  |         this.width = width; | ||||||
|  |         this.height = height; | ||||||
|  |         this.pixelFormat = format; | ||||||
|  |         this.datatype = datatype; | ||||||
|  |         //static values going into call | ||||||
|  |         int level = 0; | ||||||
|  |         int border = 0; //this must be 0 according to docs | ||||||
|  |         openGLState.glBindTexture(GL_TEXTURE_2D,texturePointer); | ||||||
|  |         Globals.renderingEngine.checkError(); | ||||||
|  |         GL40.glTexImage2D(GL_TEXTURE_2D, level, internalformat, width, height, border, format, datatype, MemoryUtil.NULL); | ||||||
|  |         Globals.renderingEngine.checkError(); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|     /** |     /** | ||||||
|      * Specifies a 2d image |      * Specifies a 2d image | ||||||
|      * @param width The width of the image |      * @param width The width of the image | ||||||
| @ -489,6 +517,13 @@ public class Texture { | |||||||
|                         LoggerInterface.loggerRenderer.ERROR("Texture is greater width than environment allows", new IllegalStateException("Texture is greater width than environment allows")); |                         LoggerInterface.loggerRenderer.ERROR("Texture is greater width than environment allows", new IllegalStateException("Texture is greater width than environment allows")); | ||||||
|                     } |                     } | ||||||
|                 } break; |                 } break; | ||||||
|  |                 case GL40.GL_INVALID_ENUM: { | ||||||
|  | 
 | ||||||
|  |                 } break; | ||||||
|  |                 default: { | ||||||
|  |                     String message = "Texture undefined error status! " + errorCode; | ||||||
|  |                     LoggerInterface.loggerRenderer.ERROR(new IllegalStateException(message)); | ||||||
|  |                 } break; | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user