mirror of
https://github.com/MistWeatherMedia/WeatherSTAR-3000-Java.git
synced 2026-11-28 14:38:08 -08:00
Add files via upload
This commit is contained in:
1 parent
800569688a
commit
746f9debdd
42 files changed
+7691
No files matched your search
@@ -0,0 +1,46 @@
|
||||
package renderer;
|
||||
|
||||
import static org.lwjgl.opengl.GL30.glGenFramebuffers;
|
||||
import static org.lwjgl.opengl.GL30.GL_FRAMEBUFFER;
|
||||
import static org.lwjgl.opengl.GL30.glBindFramebuffer;
|
||||
import static org.lwjgl.opengl.GL30.*;
|
||||
|
||||
public class FrameBuffer {
|
||||
private int fboID = 0;
|
||||
private Texture texture = null;
|
||||
|
||||
public FrameBuffer(int width, int height) {
|
||||
fboID = glGenFramebuffers();
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, fboID);
|
||||
|
||||
this.texture = new Texture(width, height);
|
||||
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, this.texture.getId(), 0);
|
||||
|
||||
int rboID = glGenRenderbuffers();
|
||||
glBindRenderbuffer(GL_RENDERBUFFER, rboID);
|
||||
glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT32, width, height);
|
||||
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, rboID);
|
||||
|
||||
if (glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE) {
|
||||
assert false : "Error: Framebuffer is not complete";
|
||||
}
|
||||
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, 0);
|
||||
}
|
||||
|
||||
public void bind() {
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, fboID);
|
||||
}
|
||||
|
||||
public void unbind() {
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, 0);
|
||||
}
|
||||
|
||||
public int getFboID() {
|
||||
return fboID;
|
||||
}
|
||||
|
||||
public int getTextureId() {
|
||||
return texture.getId();
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user