Example usage for org.lwjgl.opengl GL30 glFramebufferTexture2D

List of usage examples for org.lwjgl.opengl GL30 glFramebufferTexture2D

Introduction

In this page you can find the example usage for org.lwjgl.opengl GL30 glFramebufferTexture2D.

Prototype

public static void glFramebufferTexture2D(@NativeType("GLenum") int target,
        @NativeType("GLenum") int attachment, @NativeType("GLenum") int textarget,
        @NativeType("GLuint") int texture, @NativeType("GLint") int level) 

Source Link

Document

Attaches a level of a 2D texture object as a logical buffer to the currently bound framebuffer object.

Usage

From source file:com.xrbpowered.gl.res.buffers.OffscreenBuffers.java

License:Open Source License

protected void create(int w, int h, boolean depthBuffer, boolean hdr) {
    colorTexId = GL11.glGenTextures();//  w  ww .j  ava2 s.c o m
    GL11.glBindTexture(GL11.GL_TEXTURE_2D, colorTexId);
    GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, hdr ? GL30.GL_RGB16F : GL11.GL_RGB, w, h, 0, GL11.GL_RGB,
            GL11.GL_UNSIGNED_BYTE, (ByteBuffer) null);
    GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, GL12.GL_CLAMP_TO_EDGE);
    GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T, GL12.GL_CLAMP_TO_EDGE);
    GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR);
    GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_LINEAR);
    GL11.glBindTexture(GL11.GL_TEXTURE_2D, 0);
    GL30.glFramebufferTexture2D(GL30.GL_FRAMEBUFFER, GL30.GL_COLOR_ATTACHMENT0, GL11.GL_TEXTURE_2D, colorTexId,
            0);

    depthTexId = 0;
    if (depthBuffer) {
        depthTexId = GL11.glGenTextures();
        GL11.glBindTexture(GL11.GL_TEXTURE_2D, depthTexId);
        GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, GL14.GL_DEPTH_COMPONENT16, w, h, 0, GL11.GL_DEPTH_COMPONENT,
                GL11.GL_FLOAT, (ByteBuffer) null);
        GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, GL12.GL_CLAMP_TO_EDGE);
        GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T, GL12.GL_CLAMP_TO_EDGE);
        GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_NEAREST);
        GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_NEAREST);
        GL11.glBindTexture(GL11.GL_TEXTURE_2D, 0);
        GL30.glFramebufferTexture2D(GL30.GL_FRAMEBUFFER, GL30.GL_DEPTH_ATTACHMENT, GL11.GL_TEXTURE_2D,
                depthTexId, 0);
    }
    checkStatus();
    GL30.glBindFramebuffer(GL30.GL_FRAMEBUFFER, 0);
}

From source file:cuchaz.jfxgl.prism.JFXGLContext.java

License:Open Source License

@Override
public int createFBO(int texId) {

    int id = GL30.glGenFramebuffers();
    bindFBO(id);/*from w  ww. j ava  2  s  . c om*/

    if (texId != 0) {

        GL30.glFramebufferTexture2D(GL30.GL_FRAMEBUFFER, GL30.GL_COLOR_ATTACHMENT0, GL11.GL_TEXTURE_2D, texId,
                0);

        // check for FBO errors
        String err = getFramebufferError();
        if (err != null) {
            System.err.println("Error creating framebuffer object with texture " + texId + ": " + err);
            return 0;
        }

        // remove garbage from newly-allocated buffers
        createFBOState.backup();
        clearBuffers(Color.TRANSPARENT, true, false, true);
        createFBOState.restore();
    }

    return id;
}

From source file:cuchaz.jfxgl.prism.OffscreenBuffer.java

License:Open Source License

public boolean resize(int width, int height) {

    if (this.width == width && this.height == height) {
        return false;
    }/*from  w  w  w  . ja v a2 s.c  o  m*/

    this.width = width;
    this.height = height;

    // resize the texture
    if (texId != 0) {
        context.deleteTexture(texId);
    }
    texId = context.createTexture(width, height);

    // update the framebuf
    if (fboId == 0) {
        fboId = GL30.glGenFramebuffers();
    }
    GL30.glBindFramebuffer(GL30.GL_FRAMEBUFFER, fboId);
    GL30.glFramebufferTexture2D(GL30.GL_FRAMEBUFFER, GL30.GL_COLOR_ATTACHMENT0, GL11.GL_TEXTURE_2D, texId, 0);

    // remove the old quad
    quadDirty = true;

    return true;
}

From source file:de.ikosa.mars.viewer.glviewer.engine.GLRenderer2Stage.java

License:Open Source License

public GLRenderer2Stage(GLScene scene, GLResources resourceManager, GLCamera camera, int width, int height) {
    this.scene = scene;
    this.camera = camera;
    this.width = width;
    this.height = height;

    // setup opengl
    GL11.glViewport(0, 0, width, height);

    // setup framebuffer
    fbAId = GL30.glGenFramebuffers();//from  w ww .j a v a 2s .  c o  m
    GL30.glBindFramebuffer(GL30.GL_FRAMEBUFFER, fbAId);

    // color buffer
    fbATexId = GLTextureBuilder.createEmptyTexture("FB", width, height, (byte) 0, (byte) 0, (byte) 0, (byte) 0)
            .getTextureId();
    GL30.glFramebufferTexture2D(GL30.GL_FRAMEBUFFER, GL30.GL_COLOR_ATTACHMENT0, GL11.GL_TEXTURE_2D, fbATexId,
            0);

    // create depth buffer
    dbATexId = GLTextureBuilder.createEmptyTexture("DB", width, height, 0.0f).getTextureId();
    GL30.glFramebufferTexture2D(GL30.GL_FRAMEBUFFER, GL30.GL_DEPTH_ATTACHMENT, GL11.GL_TEXTURE_2D, dbATexId, 0);

    int status = GL30.glCheckFramebufferStatus(GL30.GL_FRAMEBUFFER);

    if (status != GL30.GL_FRAMEBUFFER_COMPLETE) {
        ML.f(String.format("Cannot set up framebuffer: %x", status));
    }

    // setup framebuffer B
    fbBId = GL30.glGenFramebuffers();
    GL30.glBindFramebuffer(GL30.GL_FRAMEBUFFER, fbBId);

    // color buffer
    fbBTexId = GLTextureBuilder.createEmptyTexture("FB", width, height, (byte) 0, (byte) 0, (byte) 0, (byte) 0)
            .getTextureId();
    GL30.glFramebufferTexture2D(GL30.GL_FRAMEBUFFER, GL30.GL_COLOR_ATTACHMENT0, GL11.GL_TEXTURE_2D, fbBTexId,
            0);

    status = GL30.glCheckFramebufferStatus(GL30.GL_FRAMEBUFFER);

    if (status != GL30.GL_FRAMEBUFFER_COMPLETE) {
        ML.f(String.format("Cannot set up framebuffer: %x", status));
    }

    ssqScene = new GLSSQScene(resourceManager, resourceManager.getShader("post"), new GLTexture("FB", fbATexId),
            new GLTexture("DB", dbATexId), resourceManager.getShader("post2"), new GLTexture("FB2", fbBTexId));
}

From source file:eu.over9000.veya.rendering.Shadow.java

License:Open Source License

public void init() {
    depthMap = GL11.glGenTextures();//from w  ww  .  j  a  va 2s.  co m
    GL11.glBindTexture(GL11.GL_TEXTURE_2D, depthMap);
    GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, GL11.GL_DEPTH_COMPONENT, SHADOW_WIDTH, SHADOW_HEIGHT, 0,
            GL11.GL_DEPTH_COMPONENT, GL11.GL_FLOAT, (ByteBuffer) null);
    GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_NEAREST);
    GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_NEAREST);
    GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, GL13.GL_CLAMP_TO_BORDER);
    GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T, GL13.GL_CLAMP_TO_BORDER);

    shadowFBO = GL30.glGenFramebuffers();
    GL30.glBindFramebuffer(GL30.GL_FRAMEBUFFER, shadowFBO);
    GL30.glFramebufferTexture2D(GL30.GL_FRAMEBUFFER, GL30.GL_DEPTH_ATTACHMENT, GL11.GL_TEXTURE_2D, depthMap, 0);
    GL11.glDrawBuffer(GL11.GL_NONE);
    GL11.glReadBuffer(GL11.GL_NONE);
    GL30.glBindFramebuffer(GL30.GL_FRAMEBUFFER, 0);
}

From source file:ion2d.INGrabber.java

License:Open Source License

/**
 * Grabs an image of the display and attachs it to the specified texture
 * @param INTexture2D texture//from www  .  j  a  v  a2 s.c om
 * @throws Exception
 */
public void grab(INTexture2D texture) throws Exception {
    GL11.glGetInteger(GL30.GL_FRAMEBUFFER_BINDING, this.oldBufferObject);

    GL30.glBindFramebuffer(GL30.GL_FRAMEBUFFER, this.bufferObject.get(0));

    GL30.glFramebufferTexture2D(GL30.GL_FRAMEBUFFER, GL30.GL_COLOR_ATTACHMENT0, GL11.GL_TEXTURE_2D,
            texture.getId(), 0);

    int status = GL30.glCheckFramebufferStatus(GL30.GL_FRAMEBUFFER);

    if (status != GL30.GL_FRAMEBUFFER_COMPLETE) {
        throw new Exception("Frame Grabber could not attach texture to framebuffer");
    }

    GL30.glBindFramebuffer(GL30.GL_FRAMEBUFFER, this.oldBufferObject.get(0));
}

From source file:kubex.gui.DepthPeelingLiquidRenderer.java

License:Creative Commons License

/**
 * Resources had been initcialized on KubexGame class, but here they are propperly configured.
 *///from   w  w w . j  a va  2s.  c o m
@Override
public void initResources(int layersTex, int currentNormalTex) {
    for (int i = 0; i < this.layersFbos.length; i++) {
        this.layersFbos[i] = glGenFramebuffers();
        glBindFramebuffer(GL_FRAMEBUFFER, this.layersFbos[i]);
        GL30.glFramebufferTextureLayer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, layersTex, 0, i); //assign one layer of the texture array to each layer fbo

        IntBuffer drawBuffers = null;

        if (i == 0) { //The first layer will render the normal of the water to a texture, too.
            drawBuffers = BufferUtils.createIntBuffer(1);
            GL30.glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, currentNormalTex,
                    0);

            drawBuffers.put(GL_COLOR_ATTACHMENT0);
            drawBuffers.flip();
        } else {
            drawBuffers = BufferUtils.createIntBuffer(0);
        }

        GL20.glDrawBuffers(drawBuffers);

    }
}

From source file:kubex.KubexGame.java

License:Creative Commons License

/**
 * Inits the game resources (Images, pools, shaders, objects, etc.)
 *//*from   w  ww.ja  va  2s.c  o  m*/
private void initResources() throws IOException {
    //Inits static pools
    FloatBufferPool.init(Chunk.CHUNK_DIMENSION * Chunk.CHUNK_DIMENSION * Chunk.CHUNK_DIMENSION * 2 * 6 * 6, 20);
    ByteArrayPool.init(Chunk.CHUNK_DIMENSION,
            (settings.RENDER_DISTANCE * 2 + 1) * World.HEIGHT * (settings.RENDER_DISTANCE * 2 + 1) * 2);
    glEnable(GL11.GL_CULL_FACE);
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    glEnable(GL11.GL_BLEND);
    glClearColor(0.6f, 0.8f, 1.0f, 0f);

    //Inits shaders
    GL20.glUseProgram(0);
    textManager = new GlobalTextManager();
    this.DVSP = new DepthVoxelShaderProgram(true);
    this.VSP = new TerrainVoxelShaderProgram(true);
    this.HSP = new HudShaderProgram(true);
    this.DTSP = this.settings.SHADOWS_ENABLED ? new DeferredTerrainShaderProgram(true)
            : new DeferredTerrainUnshadowShaderProgram(true);
    this.DRSP = this.settings.REFLECTIONS_ENABLED ? new DeferredReflectionsShaderProgram(true)
            : new DeferredNoReflectionsShaderProgram(true);
    this.DUTSP = this.settings.SHADOWS_ENABLED ? new DeferredUnderwaterTerrainShaderProgram(true)
            : new DeferredUnderwaterUnshadowTerrainShaderProgram(true);
    this.DUFSP = new DeferredUnderwaterFinalShaderProgram(true);

    //Inits essential objects
    this.TM = new TimeManager();
    this.cam = new Camera(CAMERA_NEAR, CAMERA_FAR, 80f, (float) (X_RES * 3 / 4) / Y_RES); //FOV more width than height BY DESIGN, so blocks looks more "plane". Looks nicer that way, i think.
    this.camInvProjEnv = new CameraInverseProjEnvelope(this.cam);
    this.shadowsManager = new ShadowsManager(SHADOW_SPLITS, this.cam);
    this.liquidRenderer = new DepthPeelingLiquidRenderer(LIQUID_LAYERS);

    this.sunCam = new Camera(new Matrix4f());
    this.sunCam.moveTo(0, 5, 0);
    this.sunCam.setPitch(0);

    this.sky = new Sky(cam, this.sunCam);
    File mapRoute = new File(this.settings.MAP_ROUTE);
    mapRoute.mkdir(); //Creates the maps folder
    this.fileManager = new FileManager(mapRoute, settings.RENDER_DISTANCE);
    this.fileManager.getSettingsFromFile(settings); //Reads default settings from settings file.
    this.world = new World(this.VSP, this.cam, this.sunCam, this.shadowsManager, this.sky, fileManager,
            this.settings);
    this.finalDrawManager = new FinalDrawManager(this.world, this.sky, this.shadowsManager, this.liquidRenderer,
            this.camInvProjEnv.getInvProjMatrix(), CAMERA_NEAR, CAMERA_FAR);
    this.hud = new Hud(this.HSP, X_RES, Y_RES);

    //Load textures here
    glActiveTexture(TEXTURE_FETCH[TILES_TEXTURE_LOCATION]);

    //GL_NEAREST for that blocky look
    //loads the tiles textures into a array
    tilesTexture = Util.loadTextureAtlasIntoTextureArray(FileLoader.loadTileImages(), GL11.GL_NEAREST,
            GL11.GL_NEAREST_MIPMAP_LINEAR, true, settings.ANISOTROPIC_FILTERING_ENABLED);

    Util.loadPNGTexture(FileLoader.loadWaterNormalImage(), TEXTURE_FETCH[WATER_NORMAL_TEXTURE_LOCATION]); //loads the water normal texture

    glActiveTexture(GL_TEXTURE0);
    nightDomeTexture = TextureLoader.getTexture("JPG",
            ResourceLoader.getResourceAsStream("images/nightdome.jpg")); //loads the nightdome

    //Without this, text printing using Slick-Utils doesn't work. Seems it still uses some old mode OpenGL.
    GL11.glEnable(GL11.GL_TEXTURE_2D);
    GL11.glShadeModel(GL11.GL_SMOOTH);
    GL11.glDisable(GL11.GL_DEPTH_TEST);
    GL11.glDisable(GL11.GL_LIGHTING);
    GL11.glClearDepth(1);
    GL11.glEnable(GL11.GL_BLEND);
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    GL11.glViewport(0, 0, X_RES, Y_RES);
    GL11.glMatrixMode(GL11.GL_MODELVIEW);
    GL11.glMatrixMode(GL11.GL_PROJECTION);
    GL11.glLoadIdentity();
    GL11.glOrtho(0, X_RES, Y_RES, 0, 1, -1);
    GL11.glMatrixMode(GL11.GL_MODELVIEW);

    //First pass deferred rendering
    this.baseFbo = glGenFramebuffers();
    glBindFramebuffer(GL_FRAMEBUFFER, this.baseFbo);

    int colorTexture = glGenTextures();
    int brightnessNormalsTexture = glGenTextures();

    //Creates and inits the base color texture as a RGB texture
    glActiveTexture(TEXTURE_FETCH[BASEFBO_COLOR_TEXTURE_LOCATION]);
    glBindTexture(GL_TEXTURE_2D, colorTexture);
    glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, X_RES, Y_RES, 0, GL_RGB, GL_UNSIGNED_BYTE, (FloatBuffer) null);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
    GL30.glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, colorTexture, 0);

    //Creates and inits the brightness and normals texture as a RGBA texture
    glActiveTexture(TEXTURE_FETCH[BASEFBO_NORMALS_BRIGHTNESS_TEXTURE_LOCATION]);
    glBindTexture(GL_TEXTURE_2D, brightnessNormalsTexture);
    glTexImage2D(GL_TEXTURE_2D, 0, GL11.GL_RGBA, X_RES, Y_RES, 0, GL11.GL_RGBA, GL_UNSIGNED_BYTE,
            (FloatBuffer) null);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
    GL30.glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT1, GL_TEXTURE_2D, brightnessNormalsTexture,
            0);

    //The depth buffer of this FBO will be a texture, too. This will make depth sorting slower but we will be able to access depth values later.
    int baseFboDepth = glGenTextures();

    glActiveTexture(TEXTURE_FETCH[BASEFBO_DEPTH_TEXTURE_LOCATION]);
    glBindTexture(GL_TEXTURE_2D, baseFboDepth);
    glTexImage2D(GL_TEXTURE_2D, 0, GL14.GL_DEPTH_COMPONENT24, X_RES, Y_RES, 0, GL_DEPTH_COMPONENT,
            GL_UNSIGNED_INT, (FloatBuffer) null);
    System.out.println("ERR" + GL11.glGetError());
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL11.GL_NEAREST);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL11.GL_NEAREST);
    GL30.glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, baseFboDepth, 0); //Set the depth texture as the default render depth target

    IntBuffer drawBuffers = BufferUtils.createIntBuffer(2); //Drawing to 2 textures

    drawBuffers.put(GL_COLOR_ATTACHMENT0);
    drawBuffers.put(GL_COLOR_ATTACHMENT1);

    drawBuffers.flip();
    GL20.glDrawBuffers(drawBuffers);

    //Second pass deferred rendering
    this.deferredFbo = glGenFramebuffers();
    glBindFramebuffer(GL_FRAMEBUFFER, this.deferredFbo);

    int deferredColorTex = glGenTextures();

    //Only uses one texture, a RGBA color texture
    glActiveTexture(TEXTURE_FETCH[DEFERREDFBO_COLOR_TEXTURE_LOCATION]);
    glBindTexture(GL_TEXTURE_2D, deferredColorTex);
    glTexImage2D(GL_TEXTURE_2D, 0, GL11.GL_RGBA, X_RES, Y_RES, 0, GL11.GL_RGBA, GL_UNSIGNED_BYTE,
            (FloatBuffer) null);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
    GL30.glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, deferredColorTex, 0);

    drawBuffers = BufferUtils.createIntBuffer(1);

    drawBuffers.put(GL_COLOR_ATTACHMENT0);

    drawBuffers.flip();
    GL20.glDrawBuffers(drawBuffers);

    //If shadows are enabled, we init each shadow map texture, placed in an array
    if (this.settings.SHADOWS_ENABLED) {

        int shadowTexture = glGenTextures();

        glActiveTexture(TEXTURE_FETCH[SHADOW_TEXTURE_LOCATION]);

        glBindTexture(GL30.GL_TEXTURE_2D_ARRAY, shadowTexture);
        //Creates a texture array to place the shadows in
        GL12.glTexImage3D(GL30.GL_TEXTURE_2D_ARRAY, 0, GL14.GL_DEPTH_COMPONENT16, SHADOW_XRES, SHADOW_YRES,
                this.shadowsManager.getNumberSplits(), 0, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT,
                (FloatBuffer) null);
        System.out.println("ERR" + GL11.glGetError());
        glTexParameteri(GL30.GL_TEXTURE_2D_ARRAY, GL_TEXTURE_MAG_FILTER, GL11.GL_LINEAR); //Needed to do hardware PCF comparisons via shader
        glTexParameteri(GL30.GL_TEXTURE_2D_ARRAY, GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR); //Needed to do hardware PCF comparisons via shader
        glTexParameteri(GL30.GL_TEXTURE_2D_ARRAY, GL14.GL_TEXTURE_COMPARE_MODE, GL_COMPARE_REF_TO_TEXTURE); //Needed to do hardware PCF comparisons via shader

        this.shadowFbos = new int[this.shadowsManager.getNumberSplits()];
        //Creates one framebuffer per shadow map
        for (int i = 0; i < this.shadowsManager.getNumberSplits(); i++) {
            this.shadowFbos[i] = glGenFramebuffers();
            glBindFramebuffer(GL_FRAMEBUFFER, this.shadowFbos[i]);
            GL30.glFramebufferTextureLayer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, shadowTexture, 0, i); //Each framebuffer will have one texture layer (one index of the texture array created before) assigned as render target

            drawBuffers = BufferUtils.createIntBuffer(0);

            GL20.glDrawBuffers(drawBuffers);

        }
    }

    //Liquid layers depth generation. Equal to the shadows depth textures generation.
    int liquidLayers = glGenTextures();

    glActiveTexture(TEXTURE_FETCH[LIQUIDLAYERS_TEXTURE_LOCATION]);
    glBindTexture(GL30.GL_TEXTURE_2D_ARRAY, liquidLayers);
    GL12.glTexImage3D(GL30.GL_TEXTURE_2D_ARRAY, 0, GL14.GL_DEPTH_COMPONENT24, X_RES, Y_RES,
            this.liquidRenderer.getNumLayers(), 0, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT, (FloatBuffer) null);

    glTexParameteri(GL30.GL_TEXTURE_2D_ARRAY, GL_TEXTURE_MAG_FILTER, GL11.GL_NEAREST); //We will compare manually the depth in the shader, we will not perform PCF of any sort in this case
    glTexParameteri(GL30.GL_TEXTURE_2D_ARRAY, GL_TEXTURE_MIN_FILTER, GL11.GL_NEAREST);

    int currentLiquidNormalTex = glGenTextures();

    glActiveTexture(KubexGame.TEXTURE_FETCH[KubexGame.CURRENT_LIQUID_NORMAL_TEXTURE_LOCATION]);
    glBindTexture(GL_TEXTURE_2D, currentLiquidNormalTex);
    glTexImage2D(GL_TEXTURE_2D, 0, GL11.GL_RGB, X_RES, Y_RES, 0, GL11.GL_RGB, GL11.GL_UNSIGNED_BYTE,
            (FloatBuffer) null);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);

    this.liquidRenderer.initResources(liquidLayers, currentLiquidNormalTex);

    //Reset active texture and fbo to the default
    glActiveTexture(GL13.GL_TEXTURE0);
    glBindFramebuffer(GL_FRAMEBUFFER, 0);
}

From source file:me.thehutch.fusion.engine.render.opengl.gl30.OpenGL30FrameBuffer.java

License:Open Source License

@Override
public void attachTexture(int point, Texture texture) {
    // Bind the frame buffer
    GL30.glBindFramebuffer(GL_FRAMEBUFFER, fbo);
    // Bind the texture to the frame buffer
    GL30.glFramebufferTexture2D(GL_FRAMEBUFFER, point, GL_TEXTURE_2D, texture.getId(), 0);
    // Add the attachment to the outputs if it is a colour type
    if (isColourAttachment(point)) {
        this.outputBuffers.add(point);
    }/*  w  ww . ja  va  2 s . c  o m*/
    // Update the output buffers
    updateOutputBuffers();
    // Check to see if the frame buffer is complete
    if (GL30.glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE) {
        throw new IllegalStateException("Unable to complete frame buffer!");
    }
    // Unbind the frame buffer
    GL30.glBindFramebuffer(GL_FRAMEBUFFER, 0);

    // Check for errors
    RenderUtil.checkGLError();
}

From source file:net.smert.frameworkgl.opengl.helpers.FrameBufferObjectHelper.java

License:Apache License

public void attachTexture(int attachment, int textureID) {
    GL30.glFramebufferTexture2D(GL30.GL_FRAMEBUFFER, attachment, textureTarget, textureID, 0);
}