opengl error checking fixes
This commit is contained in:
parent
29299a7781
commit
0db8734f44
@ -16,6 +16,11 @@
|
|||||||
"Green Grass"
|
"Green Grass"
|
||||||
],
|
],
|
||||||
"texture" : "/Textures/Ground/GrassTileable256.png"
|
"texture" : "/Textures/Ground/GrassTileable256.png"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id" : 3,
|
||||||
|
"name" : "baguette",
|
||||||
|
"texture" : "/Textures/Ground/baguette256.png"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
@ -1,3 +1,3 @@
|
|||||||
#maven.buildNumber.plugin properties file
|
#maven.buildNumber.plugin properties file
|
||||||
#Wed Jul 03 14:07:21 EDT 2024
|
#Wed Jul 03 15:06:42 EDT 2024
|
||||||
buildNumber=147
|
buildNumber=149
|
||||||
|
|||||||
@ -62,7 +62,9 @@ public class InitialAssetLoading implements Runnable {
|
|||||||
int offY = iterator / VoxelTextureAtlas.ELEMENTS_PER_ROW;
|
int offY = iterator / VoxelTextureAtlas.ELEMENTS_PER_ROW;
|
||||||
try {
|
try {
|
||||||
BufferedImage newType = ImageIO.read(FileUtils.getAssetFile(type.getTexture()));
|
BufferedImage newType = ImageIO.read(FileUtils.getAssetFile(type.getTexture()));
|
||||||
graphics.drawImage(newType, iterator * VoxelTextureAtlas.ATLAS_ELEMENT_DIM * offX, VoxelTextureAtlas.ATLAS_DIM - VoxelTextureAtlas.ATLAS_ELEMENT_DIM - iterator * VoxelTextureAtlas.ATLAS_ELEMENT_DIM * offY, null);
|
int drawX = VoxelTextureAtlas.ATLAS_ELEMENT_DIM * offX;
|
||||||
|
int drawY = VoxelTextureAtlas.ATLAS_DIM - VoxelTextureAtlas.ATLAS_ELEMENT_DIM - VoxelTextureAtlas.ATLAS_ELEMENT_DIM * offY;
|
||||||
|
graphics.drawImage(newType, drawX, drawY, null);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
LoggerInterface.loggerRenderer.ERROR("Texture atlas failed to find texture " + type.getTexture(), e);
|
LoggerInterface.loggerRenderer.ERROR("Texture atlas failed to find texture " + type.getTexture(), e);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -462,6 +462,7 @@ public class RenderingEngine {
|
|||||||
|
|
||||||
//Update light buffer
|
//Update light buffer
|
||||||
lightManager.updateData();
|
lightManager.updateData();
|
||||||
|
checkError();
|
||||||
|
|
||||||
|
|
||||||
//Render content to the game framebuffer
|
//Render content to the game framebuffer
|
||||||
@ -471,11 +472,17 @@ public class RenderingEngine {
|
|||||||
} else {
|
} else {
|
||||||
mainContentNoOITPipeline.render(openGLState, renderPipelineState);
|
mainContentNoOITPipeline.render(openGLState, renderPipelineState);
|
||||||
}
|
}
|
||||||
|
checkError();
|
||||||
debugContentPipeline.render(openGLState, renderPipelineState);
|
debugContentPipeline.render(openGLState, renderPipelineState);
|
||||||
|
checkError();
|
||||||
normalsForOutlinePipeline.render(openGLState, renderPipelineState);
|
normalsForOutlinePipeline.render(openGLState, renderPipelineState);
|
||||||
|
checkError();
|
||||||
firstPersonItemsPipeline.render(openGLState, renderPipelineState);
|
firstPersonItemsPipeline.render(openGLState, renderPipelineState);
|
||||||
|
checkError();
|
||||||
postProcessingPipeline.render(openGLState, renderPipelineState);
|
postProcessingPipeline.render(openGLState, renderPipelineState);
|
||||||
|
checkError();
|
||||||
compositePipeline.render(openGLState, renderPipelineState);
|
compositePipeline.render(openGLState, renderPipelineState);
|
||||||
|
checkError();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -490,10 +497,12 @@ public class RenderingEngine {
|
|||||||
//Render the game framebuffer texture to a quad
|
//Render the game framebuffer texture to a quad
|
||||||
if(Globals.RENDER_FLAG_RENDER_SCREEN_FRAMEBUFFER){
|
if(Globals.RENDER_FLAG_RENDER_SCREEN_FRAMEBUFFER){
|
||||||
renderScreenPipeline.render(openGLState, renderPipelineState);
|
renderScreenPipeline.render(openGLState, renderPipelineState);
|
||||||
|
checkError();
|
||||||
}
|
}
|
||||||
|
|
||||||
//render ui
|
//render ui
|
||||||
uiPipeline.render(openGLState, renderPipelineState);
|
uiPipeline.render(openGLState, renderPipelineState);
|
||||||
|
checkError();
|
||||||
|
|
||||||
//Render boundaries of ui elements
|
//Render boundaries of ui elements
|
||||||
if(Globals.RENDER_FLAG_RENDER_UI_BOUNDS){
|
if(Globals.RENDER_FLAG_RENDER_UI_BOUNDS){
|
||||||
@ -504,6 +513,7 @@ public class RenderingEngine {
|
|||||||
* Render imgui
|
* Render imgui
|
||||||
*/
|
*/
|
||||||
imGuiPipeline.render(openGLState, renderPipelineState);
|
imGuiPipeline.render(openGLState, renderPipelineState);
|
||||||
|
checkError();
|
||||||
|
|
||||||
|
|
||||||
//check for errors
|
//check for errors
|
||||||
@ -511,7 +521,6 @@ public class RenderingEngine {
|
|||||||
|
|
||||||
//check and call events and swap the buffers
|
//check and call events and swap the buffers
|
||||||
LoggerInterface.loggerRenderer.DEBUG_LOOP("Swap buffers");
|
LoggerInterface.loggerRenderer.DEBUG_LOOP("Swap buffers");
|
||||||
openGLState.glBindFramebuffer(GL_FRAMEBUFFER,0);
|
|
||||||
glfwSwapBuffers(Globals.window);
|
glfwSwapBuffers(Globals.window);
|
||||||
glfwPollEvents();
|
glfwPollEvents();
|
||||||
checkError();
|
checkError();
|
||||||
|
|||||||
@ -12,6 +12,8 @@ import org.lwjgl.opengl.GL31;
|
|||||||
|
|
||||||
import electrosphere.engine.Globals;
|
import electrosphere.engine.Globals;
|
||||||
import electrosphere.entity.types.camera.CameraEntityUtils;
|
import electrosphere.entity.types.camera.CameraEntityUtils;
|
||||||
|
import electrosphere.logger.LoggerInterface;
|
||||||
|
import electrosphere.renderer.shader.ShaderProgram;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Manages the light sources in the engine
|
* Manages the light sources in the engine
|
||||||
@ -155,11 +157,16 @@ public class LightManager {
|
|||||||
public void bindBuffer(int shaderIndex){
|
public void bindBuffer(int shaderIndex){
|
||||||
//get position of lights object in shader
|
//get position of lights object in shader
|
||||||
int bufferIndex = GL31.glGetUniformBlockIndex(shaderIndex, "Lights");
|
int bufferIndex = GL31.glGetUniformBlockIndex(shaderIndex, "Lights");
|
||||||
//bind that position to the slot '2'
|
if(bufferIndex == ShaderProgram.INVALID_UNIFORM_NAME){
|
||||||
GL31.glUniformBlockBinding(shaderIndex, bufferIndex, BIND_POINT);
|
LoggerInterface.loggerRenderer.INFO("Tried to buffer light manager to shader that does not have it active.");
|
||||||
//bind our buffer to slot '2' as well
|
} else {
|
||||||
GL31.glBindBufferBase(GL_UNIFORM_BUFFER, BIND_POINT, uboIndex);
|
//bind that position to the slot '2'
|
||||||
|
GL31.glUniformBlockBinding(shaderIndex, bufferIndex, BIND_POINT);
|
||||||
|
//bind our buffer to slot '2' as well
|
||||||
|
GL31.glBindBufferBase(GL_UNIFORM_BUFFER, BIND_POINT, uboIndex);
|
||||||
|
}
|
||||||
//alternatively if want to use range, do glBindBufferRange(GL_UNIFORM_BUFFER, 2, uboExampleBlock, 0, 152);
|
//alternatively if want to use range, do glBindBufferRange(GL_UNIFORM_BUFFER, 2, uboExampleBlock, 0, 152);
|
||||||
|
Globals.renderingEngine.checkError();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -5,11 +5,7 @@ import electrosphere.renderer.OpenGLState;
|
|||||||
import electrosphere.renderer.texture.Texture;
|
import electrosphere.renderer.texture.Texture;
|
||||||
import org.lwjgl.assimp.AIMaterial;
|
import org.lwjgl.assimp.AIMaterial;
|
||||||
import static org.lwjgl.opengl.GL11.GL_TEXTURE_2D;
|
import static org.lwjgl.opengl.GL11.GL_TEXTURE_2D;
|
||||||
import static org.lwjgl.opengl.GL11.glBindTexture;
|
|
||||||
import static org.lwjgl.opengl.GL13.GL_TEXTURE0;
|
import static org.lwjgl.opengl.GL13.GL_TEXTURE0;
|
||||||
import static org.lwjgl.opengl.GL13.glActiveTexture;
|
|
||||||
import static org.lwjgl.opengl.GL20.glGetUniformLocation;
|
|
||||||
import static org.lwjgl.opengl.GL20.glUniform1i;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@ -91,16 +87,17 @@ public class Material {
|
|||||||
Texture diffuseTexture = Globals.assetManager.fetchTexture(diffuse);
|
Texture diffuseTexture = Globals.assetManager.fetchTexture(diffuse);
|
||||||
if(diffuseTexture != null){
|
if(diffuseTexture != null){
|
||||||
diffuseTexture.bind(openGLState,0);
|
diffuseTexture.bind(openGLState,0);
|
||||||
glUniform1i(glGetUniformLocation(Globals.renderingEngine.getOpenGLState().getActiveShader().getShaderId(), "material.diffuse"), 0);
|
openGLState.getActiveShader().setUniform(openGLState, "material.diffuse", 0);
|
||||||
}
|
}
|
||||||
Texture specularTexture = Globals.assetManager.fetchTexture(specular);
|
Texture specularTexture = Globals.assetManager.fetchTexture(specular);
|
||||||
if(specularTexture != null){
|
if(specularTexture != null){
|
||||||
specularTexture.bind(openGLState,1);
|
specularTexture.bind(openGLState,1);
|
||||||
glUniform1i(glGetUniformLocation(Globals.renderingEngine.getOpenGLState().getActiveShader().getShaderId(), "material.specular"), 1);
|
openGLState.getActiveShader().setUniform(openGLState, "material.specular", 1);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
openGLState.glBindTextureUnit(GL_TEXTURE0, texturePointer, GL_TEXTURE_2D);
|
openGLState.glBindTextureUnit(GL_TEXTURE0, texturePointer, GL_TEXTURE_2D);
|
||||||
}
|
}
|
||||||
|
Globals.renderingEngine.checkError();
|
||||||
}
|
}
|
||||||
public void apply_material(OpenGLState openGLState, int diffuse_channel, int specular_channel){
|
public void apply_material(OpenGLState openGLState, int diffuse_channel, int specular_channel){
|
||||||
Texture diffuseTexture = Globals.assetManager.fetchTexture(diffuse);
|
Texture diffuseTexture = Globals.assetManager.fetchTexture(diffuse);
|
||||||
@ -111,6 +108,7 @@ public class Material {
|
|||||||
if(specularTexture != null){
|
if(specularTexture != null){
|
||||||
specularTexture.bind(openGLState,specular_channel);
|
specularTexture.bind(openGLState,specular_channel);
|
||||||
}
|
}
|
||||||
|
Globals.renderingEngine.checkError();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isTransparent(){
|
public boolean isTransparent(){
|
||||||
|
|||||||
@ -4,7 +4,6 @@ import electrosphere.engine.Globals;
|
|||||||
import electrosphere.entity.types.camera.CameraEntityUtils;
|
import electrosphere.entity.types.camera.CameraEntityUtils;
|
||||||
import electrosphere.renderer.OpenGLState;
|
import electrosphere.renderer.OpenGLState;
|
||||||
import electrosphere.renderer.RenderPipelineState;
|
import electrosphere.renderer.RenderPipelineState;
|
||||||
import electrosphere.renderer.RenderPipelineState.SelectedShaderEnum;
|
|
||||||
import electrosphere.renderer.actor.ActorTextureMask;
|
import electrosphere.renderer.actor.ActorTextureMask;
|
||||||
import electrosphere.renderer.actor.instance.InstanceData;
|
import electrosphere.renderer.actor.instance.InstanceData;
|
||||||
import electrosphere.renderer.buffer.HomogenousInstancedArray;
|
import electrosphere.renderer.buffer.HomogenousInstancedArray;
|
||||||
@ -28,8 +27,6 @@ import org.lwjgl.BufferUtils;
|
|||||||
import org.lwjgl.opengl.GL11;
|
import org.lwjgl.opengl.GL11;
|
||||||
import org.lwjgl.opengl.GL15;
|
import org.lwjgl.opengl.GL15;
|
||||||
|
|
||||||
import org.lwjgl.opengl.GL20;
|
|
||||||
|
|
||||||
import static org.lwjgl.opengl.GL11.GL_FLOAT;
|
import static org.lwjgl.opengl.GL11.GL_FLOAT;
|
||||||
import static org.lwjgl.opengl.GL11.GL_INT;
|
import static org.lwjgl.opengl.GL11.GL_INT;
|
||||||
import static org.lwjgl.opengl.GL11.GL_TEXTURE_2D;
|
import static org.lwjgl.opengl.GL11.GL_TEXTURE_2D;
|
||||||
@ -50,7 +47,6 @@ import static org.lwjgl.opengl.GL20.glUniformMatrix4fv;
|
|||||||
import static org.lwjgl.opengl.GL20.glVertexAttribPointer;
|
import static org.lwjgl.opengl.GL20.glVertexAttribPointer;
|
||||||
import static org.lwjgl.opengl.GL30.glBindVertexArray;
|
import static org.lwjgl.opengl.GL30.glBindVertexArray;
|
||||||
import static org.lwjgl.opengl.GL30.glGenVertexArrays;
|
import static org.lwjgl.opengl.GL30.glGenVertexArrays;
|
||||||
import static org.lwjgl.opengl.GL40.*;
|
|
||||||
|
|
||||||
import org.lwjgl.opengl.GL45;
|
import org.lwjgl.opengl.GL45;
|
||||||
import org.lwjgl.system.MemoryStack;
|
import org.lwjgl.system.MemoryStack;
|
||||||
@ -365,6 +361,7 @@ public class Mesh {
|
|||||||
selectedProgram = shader;
|
selectedProgram = shader;
|
||||||
}
|
}
|
||||||
openGLState.setActiveShader(renderPipelineState, selectedProgram);
|
openGLState.setActiveShader(renderPipelineState, selectedProgram);
|
||||||
|
Globals.renderingEngine.checkError();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(renderPipelineState.getUseLight()){
|
if(renderPipelineState.getUseLight()){
|
||||||
@ -376,20 +373,23 @@ public class Mesh {
|
|||||||
LightManager lightManager = Globals.renderingEngine.getLightManager();
|
LightManager lightManager = Globals.renderingEngine.getLightManager();
|
||||||
lightManager.bindBuffer(openGLState.getActiveShader().getShaderId());
|
lightManager.bindBuffer(openGLState.getActiveShader().getShaderId());
|
||||||
}
|
}
|
||||||
|
Globals.renderingEngine.checkError();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(renderPipelineState.getUseMaterial() && textureMask == null){
|
if(renderPipelineState.getUseMaterial() && textureMask == null){
|
||||||
|
Globals.renderingEngine.checkError();
|
||||||
if(material == null){
|
if(material == null){
|
||||||
Globals.materialDefault.apply_material(openGLState,0,1);
|
Globals.materialDefault.apply_material(openGLState,0,1);
|
||||||
GL20.glUniform1i(glGetUniformLocation(openGLState.getActiveShader().getShaderId(), "hasTransparency"), 0);
|
openGLState.getActiveShader().setUniform(openGLState, "hasTransparency", 0);
|
||||||
} else {
|
} else {
|
||||||
material.apply_material(openGLState);
|
material.apply_material(openGLState);
|
||||||
if(material.hasTransparency){
|
if(material.hasTransparency){
|
||||||
GL20.glUniform1i(glGetUniformLocation(openGLState.getActiveShader().getShaderId(), "hasTransparency"), 1);
|
openGLState.getActiveShader().setUniform(openGLState, "hasTransparency", 1);
|
||||||
} else {
|
} else {
|
||||||
GL20.glUniform1i(glGetUniformLocation(openGLState.getActiveShader().getShaderId(), "hasTransparency"), 0);
|
openGLState.getActiveShader().setUniform(openGLState, "hasTransparency", 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Globals.renderingEngine.checkError();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -415,12 +415,14 @@ public class Mesh {
|
|||||||
// glUniform1i(glGetUniformLocation(Globals.renderingEngine.getActiveShader().shaderProgram, "groundTextures[" + j + "]"),6+j);
|
// glUniform1i(glGetUniformLocation(Globals.renderingEngine.getActiveShader().shaderProgram, "groundTextures[" + j + "]"),6+j);
|
||||||
// }
|
// }
|
||||||
// glActiveTexture(GL_TEXTURE0);
|
// glActiveTexture(GL_TEXTURE0);
|
||||||
|
Globals.renderingEngine.checkError();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(renderPipelineState.getUseShadowMap()){
|
if(renderPipelineState.getUseShadowMap()){
|
||||||
openGLState.glActiveTexture(GL_TEXTURE3);
|
openGLState.glActiveTexture(GL_TEXTURE3);
|
||||||
openGLState.glBindTexture(GL_TEXTURE_2D, Globals.shadowMapTextureLoc);
|
openGLState.glBindTexture(GL_TEXTURE_2D, Globals.shadowMapTextureLoc);
|
||||||
glUniform1i(glGetUniformLocation(openGLState.getActiveShader().getShaderId(), "shadowMap"), 3);
|
glUniform1i(glGetUniformLocation(openGLState.getActiveShader().getShaderId(), "shadowMap"), 3);
|
||||||
|
Globals.renderingEngine.checkError();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -462,6 +464,7 @@ public class Mesh {
|
|||||||
} else {
|
} else {
|
||||||
glUniform1i(glGetUniformLocation(openGLState.getActiveShader().getShaderId(), "hasBones"), 0);
|
glUniform1i(glGetUniformLocation(openGLState.getActiveShader().getShaderId(), "hasBones"), 0);
|
||||||
}
|
}
|
||||||
|
Globals.renderingEngine.checkError();
|
||||||
|
|
||||||
|
|
||||||
if(renderPipelineState.getBufferStandardUniforms()){
|
if(renderPipelineState.getBufferStandardUniforms()){
|
||||||
@ -477,10 +480,12 @@ public class Mesh {
|
|||||||
glUniform1i(glGetUniformLocation(openGLState.getActiveShader().getShaderId(), "frame"), (int)Globals.timekeeper.getNumberOfRenderFramesElapsed());
|
glUniform1i(glGetUniformLocation(openGLState.getActiveShader().getShaderId(), "frame"), (int)Globals.timekeeper.getNumberOfRenderFramesElapsed());
|
||||||
glUniform1f(glGetUniformLocation(openGLState.getActiveShader().getShaderId(), "time"), (float)Globals.timekeeper.getCurrentRendererTime());
|
glUniform1f(glGetUniformLocation(openGLState.getActiveShader().getShaderId(), "time"), (float)Globals.timekeeper.getCurrentRendererTime());
|
||||||
}
|
}
|
||||||
|
Globals.renderingEngine.checkError();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(renderPipelineState.getBufferNonStandardUniforms()){
|
if(renderPipelineState.getBufferNonStandardUniforms()){
|
||||||
bufferAllUniforms(openGLState);
|
bufferAllUniforms(openGLState);
|
||||||
|
Globals.renderingEngine.checkError();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(renderPipelineState.getInstanced()){
|
if(renderPipelineState.getInstanced()){
|
||||||
@ -490,6 +495,7 @@ public class Mesh {
|
|||||||
Map<ShaderAttribute,HomogenousInstancedArray> glBufferMap = instanceData.getGlBufferMap();
|
Map<ShaderAttribute,HomogenousInstancedArray> glBufferMap = instanceData.getGlBufferMap();
|
||||||
bufferInstanceData(renderPipelineState, buffers, glBufferMap);
|
bufferInstanceData(renderPipelineState, buffers, glBufferMap);
|
||||||
renderPipelineState.setInstanceCount(instanceData.getDrawCount());
|
renderPipelineState.setInstanceCount(instanceData.getDrawCount());
|
||||||
|
Globals.renderingEngine.checkError();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -503,6 +509,7 @@ public class Mesh {
|
|||||||
GL11.glDrawArrays(GL_TRIANGLES, 0, elementCount);
|
GL11.glDrawArrays(GL_TRIANGLES, 0, elementCount);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Globals.renderingEngine.checkError();
|
||||||
glBindVertexArray(0);
|
glBindVertexArray(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -38,6 +38,7 @@ import org.lwjgl.opengl.GL40;
|
|||||||
|
|
||||||
import electrosphere.engine.Globals;
|
import electrosphere.engine.Globals;
|
||||||
import electrosphere.logger.LoggerInterface;
|
import electrosphere.logger.LoggerInterface;
|
||||||
|
import electrosphere.renderer.OpenGLState;
|
||||||
import electrosphere.util.FileUtils;
|
import electrosphere.util.FileUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -763,6 +764,23 @@ public class ShaderProgram {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//returned if the uniform isn't found
|
||||||
|
public static final int INVALID_UNIFORM_NAME = -1;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tries to set a uniform
|
||||||
|
* @param uniformName The name of the uniform
|
||||||
|
* @param value The value to set the uniform to
|
||||||
|
*/
|
||||||
|
public void setUniform(OpenGLState openGLState, String uniformName, Object value){
|
||||||
|
int uniformLocation = glGetUniformLocation(this.getShaderId(), uniformName);
|
||||||
|
if(uniformLocation == INVALID_UNIFORM_NAME){
|
||||||
|
LoggerInterface.loggerRenderer.INFO("Searched for uniform in a shader that does not contain it. Uniform name: \"" + uniformName + "\"");
|
||||||
|
} else {
|
||||||
|
setUniform(uniformLocation, value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the id of the shader
|
* Gets the id of the shader
|
||||||
|
|||||||
@ -26,7 +26,7 @@ import static org.lwjgl.opengl.GL30.*;
|
|||||||
public class Texture {
|
public class Texture {
|
||||||
|
|
||||||
//the pointer for the texture
|
//the pointer for the texture
|
||||||
int texturePointer;
|
int texturePointer = -1;
|
||||||
//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
|
||||||
@ -133,7 +133,7 @@ public class Texture {
|
|||||||
//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){
|
||||||
LoggerInterface.loggerRenderer.WARNING("Texture Constructor[from bufferedimage]: " + errorMessage);
|
LoggerInterface.loggerRenderer.ERROR(new IllegalStateException("Texture Constructor[from bufferedimage]: " + errorMessage));
|
||||||
}
|
}
|
||||||
glBindTexture(GL_TEXTURE_2D, 0);
|
glBindTexture(GL_TEXTURE_2D, 0);
|
||||||
}
|
}
|
||||||
@ -238,7 +238,7 @@ public class Texture {
|
|||||||
//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){
|
||||||
LoggerInterface.loggerRenderer.WARNING("Texture Constructor[from bufferedimage]: " + errorMessage);
|
LoggerInterface.loggerRenderer.ERROR(new IllegalStateException("Texture Constructor[from bufferedimage]: " + errorMessage));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -270,7 +270,7 @@ public class Texture {
|
|||||||
//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){
|
||||||
LoggerInterface.loggerRenderer.WARNING("Texture Constructor[from bytebuffer]: " + errorMessage);
|
LoggerInterface.loggerRenderer.ERROR(new IllegalStateException("Texture Constructor[from bytebuffer]: " + errorMessage));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -280,12 +280,15 @@ public class Texture {
|
|||||||
* @param openGLState The opengl state
|
* @param openGLState The opengl state
|
||||||
*/
|
*/
|
||||||
public void bind(OpenGLState openGLState){
|
public void bind(OpenGLState openGLState){
|
||||||
|
if(texturePointer == -1){
|
||||||
|
LoggerInterface.loggerRenderer.ERROR(new IllegalStateException("Tring to bind a texture object that has not been initialized yet"));
|
||||||
|
}
|
||||||
if(texturePointer == 0){
|
if(texturePointer == 0){
|
||||||
LoggerInterface.loggerRenderer.ERROR(new IllegalStateException("Trying to bind texture object that has texturepointer of 0"));
|
LoggerInterface.loggerRenderer.ERROR(new IllegalStateException("Trying to bind texture object that has texturepointer of 0"));
|
||||||
}
|
}
|
||||||
// openGLState.glActiveTexture(GL_TEXTURE0);
|
// openGLState.glActiveTexture(GL_TEXTURE0);
|
||||||
// openGLState.glBindTexture(GL_TEXTURE_2D, texturePointer);
|
// openGLState.glBindTexture(GL_TEXTURE_2D, texturePointer);
|
||||||
openGLState.glBindTextureUnit(GL_TEXTURE0,texturePointer,GL_TEXTURE_2D);
|
openGLState.glBindTextureUnit(GL_TEXTURE0,this.texturePointer,GL_TEXTURE_2D);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -294,7 +297,13 @@ public class Texture {
|
|||||||
* @param attrib_val The texture unit number
|
* @param attrib_val The texture unit number
|
||||||
*/
|
*/
|
||||||
public void bind(OpenGLState openGLState, int attrib_val){
|
public void bind(OpenGLState openGLState, int attrib_val){
|
||||||
openGLState.glBindTextureUnit(GL_TEXTURE0 + attrib_val,texturePointer,GL_TEXTURE_2D);
|
if(texturePointer == -1){
|
||||||
|
LoggerInterface.loggerRenderer.ERROR(new IllegalStateException("Tring to bind a texture object that has not been initialized yet"));
|
||||||
|
}
|
||||||
|
if(texturePointer == 0){
|
||||||
|
LoggerInterface.loggerRenderer.ERROR(new IllegalStateException("Trying to bind texture object that has texturepointer of 0"));
|
||||||
|
}
|
||||||
|
openGLState.glBindTextureUnit(GL_TEXTURE0 + attrib_val,this.texturePointer,GL_TEXTURE_2D);
|
||||||
// openGLState.glActiveTexture(GL_TEXTURE0 + attrib_val);
|
// openGLState.glActiveTexture(GL_TEXTURE0 + attrib_val);
|
||||||
// openGLState.glBindTexture(GL_TEXTURE_2D, texturePointer);
|
// openGLState.glBindTexture(GL_TEXTURE_2D, texturePointer);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user