Here’s my FBO class (sorry for the code dumb, thought it was necessary):
package ecumene.opengl.frame;
import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.GL30;
import org.lwjgl.opengl.Util;
import ecumene.EcuException;
import ecumene.opengl.texture.Texture;
/**
* Framebuffer Objects are OpenGL Objects, which allow for the creation of user-defined Framebuffers. With them,
* one can render to non-Default Framebuffer locations, and thus render without disturbing the main screen.
*
* @see IFrameBuffer
*
* @author Ecumene
*/
public class Frame implements IFrame {
private int frame;
private Texture parent;
public Frame() {
frame = GL30.glGenFramebuffers();
Util.checkGLError();
}
@Override
public void bind() {
GL30.glBindFramebuffer(GL30.GL_FRAMEBUFFER, frame);
Util.checkGLError();
}
@Override
public void begin(int width, int height) {
if(frame == 0) throw new EcuException("FBO was destroyed");
GL11.glViewport(0, 0, width, height);
GL30.glBindFramebuffer(GL30.GL_FRAMEBUFFER, frame);
Util.checkGLError();
}
@Override
public void end(int width, int height) {
if(frame == 0) return;
GL11.glViewport(0, 0, width, height);
GL30.glBindFramebuffer(GL30.GL_FRAMEBUFFER, 0);
Util.checkGLError();
}
@Override
public void bufferTexture(Texture texture, int attachment) {
this.parent = texture;
bind();
texture.bind();
GL30.glFramebufferTexture2D(GL30.GL_FRAMEBUFFER, attachment, texture.getTarget(), texture.getID(), 0);
bindNone();
Util.checkGLError();
}
@Override
public int getStatus() {
bind();
int status = GL30.glCheckFramebufferStatus(frame);
bindNone();
Util.checkGLError();
return status;
}
@Override
public void destroy() {
bindNone();
GL30.glDeleteFramebuffers(frame);
frame = 0;
Util.checkGLError();
}
/** @return The FBO's texture object */
public Texture getTexture(){
return parent;
}
protected static void bindNone(){
GL30.glBindFramebuffer(GL30.GL_FRAMEBUFFER, 0);
}
}
I’m initializing it like this:
frame = new Frame();
frame.bufferTexture(new Texture(GL11.GL_TEXTURE_2D), EXTFramebufferObject.GL_COLOR_ATTACHMENT0_EXT);
Then I never use it again. But the weird thing is, [icode]frame.getStatus()[/icode] is causing a ‘invalid enum (1280)’ error. And when I remove that line, and use the begin() method, it says that a glUniform call is causing an invalid operation error… I’m checking for OpenGL errors in the begin(), so it should be throwing the error there, right?
I’m still very new to the frame buffer object stuff. Thanks in advance!