leftEyeTexture = (Texture2D) getLeftViewPort().getOutputFrameBuffer().getColorBuffer().getTexture(); rightEyeTexture = (Texture2D) getRightViewPort().getOutputFrameBuffer().getColorBuffer().getTexture(); leftEyeDepth = (Texture2D) getLeftViewPort().getOutputFrameBuffer().getDepthBuffer().getTexture(); rightEyeDepth = (Texture2D) getRightViewPort().getOutputFrameBuffer().getDepthBuffer().getTexture();
for (int i = 0; i < context.boundFB.getNumColorBuffers(); i++) { RenderBuffer rb = context.boundFB.getColorBuffer(i); Texture tex = rb.getTexture(); if (tex != null && tex.getMinFilter().usesMipMapLevels()) { setTexture(0, rb.getTexture()); int textureType = convertTextureType(tex.getType(), tex.getImage().getMultiSamples(), rb.getFace()); glEnable(textureType); glGenerateMipmapEXT(textureType); RenderBuffer rb = fb.getColorBuffer(fb.getTargetIndex()); if (context.boundDrawBuf != rb.getSlot()) { glDrawBuffer(GL_COLOR_ATTACHMENT0_EXT + rb.getSlot()); context.boundDrawBuf = rb.getSlot();
glReadBuffer(GL_COLOR_ATTACHMENT0_EXT + rb.getSlot());
glReadBuffer(GL_COLOR_ATTACHMENT0_EXT + rb.getSlot());
for (int i = 0; i < context.boundFB.getNumColorBuffers(); i++) { RenderBuffer rb = context.boundFB.getColorBuffer(i); Texture tex = rb.getTexture(); if (tex != null && tex.getMinFilter().usesMipMapLevels()) { setTexture(0, rb.getTexture()); int textureType = convertTextureType(tex.getType(), tex.getImage().getMultiSamples(), rb.getFace()); glfbo.glGenerateMipmapEXT(textureType);
Format depthFmt = depthBuf.getFormat(); if (!depthFmt.isDepthFormat()){ return false;
/** * Creates a shared image object from a jME3 render buffer. * The returned image shares the same memory with the jME3 render buffer, changes * in one view are visible in the other view. * <br> * This can be used as an alternative to post processing effects * (e.g. reduce sum operations, needed e.g. for tone mapping). * <br> * <b>Note:</b> The renderbuffer must already been uploaded to the GPU, * i.e. it must be used at least once for drawing. * <p> * Before the returned image can be used, it must be acquried explicitly * by {@link Image#acquireImageForSharingAsync(com.jme3.opencl.CommandQueue) } * and after modifying it, released by {@link Image#releaseImageForSharingAsync(com.jme3.opencl.CommandQueue) } * This is needed so that OpenGL and OpenCL operations do not interfer with each other. * * @param buffer * @param access * @return */ public Image bindRenderBuffer(FrameBuffer.RenderBuffer buffer, MemoryAccess access) { if (buffer.getTexture() == null) { return bindPureRenderBuffer(buffer, access); } else { return bindImage(buffer.getTexture(), access); } } protected abstract Image bindPureRenderBuffer(FrameBuffer.RenderBuffer buffer, MemoryAccess access);
private void printRealRenderBufferInfo(FrameBuffer fb, RenderBuffer rb, String name) { System.out.println("== Renderbuffer " + name + " =="); System.out.println("RB ID: " + rb.getId()); System.out.println("Is proper? " + glIsRenderbufferEXT(rb.getId())); int attachment = convertAttachmentSlot(rb.getSlot()); int type = glGetFramebufferAttachmentParameteriEXT(GL_DRAW_FRAMEBUFFER_EXT, attachment, GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE_EXT); int rbName = glGetFramebufferAttachmentParameteriEXT(GL_DRAW_FRAMEBUFFER_EXT, attachment, GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME_EXT); switch (type) { case GL_NONE: System.out.println("Type: None"); break; case GL_TEXTURE: System.out.println("Type: Texture"); break; case GL_RENDERBUFFER_EXT: System.out.println("Type: Buffer"); System.out.println("RB ID: " + rbName); break; } }
public void updateRenderTexture(FrameBuffer fb, RenderBuffer rb) { Texture tex = rb.getTexture(); Image image = tex.getImage(); if (image.isUpdateNeeded()) { // Check NPOT requirements checkNonPowerOfTwo(tex); updateTexImageData(image, tex.getType(), 0, false); // NOTE: For depth textures, sets nearest/no-mips mode // Required to fix "framebuffer unsupported" // for old NVIDIA drivers! setupTextureParams(0, tex); } if (rb.getLayer() < 0){ glfbo.glFramebufferTexture2DEXT(GLFbo.GL_FRAMEBUFFER_EXT, convertAttachmentSlot(rb.getSlot()), convertTextureType(tex.getType(), image.getMultiSamples(), rb.getFace()), image.getId(), 0); } else { glfbo.glFramebufferTextureLayerEXT(GLFbo.GL_FRAMEBUFFER_EXT, convertAttachmentSlot(rb.getSlot()), image.getId(), 0, rb.getLayer()); } }
/** * Add a color texture to use for this framebuffer. * If MRT is enabled, then each subsequently added texture can be * rendered to through a shader that writes to the array <code>gl_FragData</code>. * If MRT is not enabled, then the index set with {@link FrameBuffer#setTargetIndex(int) } * is rendered to by the shader. * * @param tex The cube-map texture to add. * @param face The face of the cube-map to render to. */ public void addColorTexture(TextureCubeMap tex, TextureCubeMap.Face face) { if (id != -1) throw new UnsupportedOperationException("FrameBuffer already initialized."); Image img = tex.getImage(); checkSetTexture(tex, false); RenderBuffer colorBuf = new RenderBuffer(); colorBuf.slot = colorBufs.size(); colorBuf.tex = tex; colorBuf.format = img.getFormat(); colorBuf.face = face.ordinal(); colorBufs.add(colorBuf); }
/** * Add a color texture to use for this framebuffer. * If MRT is enabled, then each subsequently added texture can be * rendered to through a shader that writes to the array <code>gl_FragData</code>. * If MRT is not enabled, then the index set with {@link FrameBuffer#setTargetIndex(int) } * is rendered to by the shader. * * @param tex The texture to add. * @see #addColorBuffer(com.jme3.texture.Image.Format) */ public void addColorTexture(Texture2D tex) { if (id != -1) throw new UnsupportedOperationException("FrameBuffer already initialized."); Image img = tex.getImage(); checkSetTexture(tex, false); RenderBuffer colorBuf = new RenderBuffer(); colorBuf.slot = colorBufs.size(); colorBuf.tex = tex; colorBuf.format = img.getFormat(); colorBufs.add(colorBuf); }
/** * Add a color texture array to use for this framebuffer. * If MRT is enabled, then each subsequently added texture can be * rendered to through a shader that writes to the array <code>gl_FragData</code>. * If MRT is not enabled, then the index set with {@link FrameBuffer#setTargetIndex(int) } * is rendered to by the shader. * * @param tex The texture array to add. */ public void addColorTexture(TextureArray tex, int layer) { if (id != -1) throw new UnsupportedOperationException("FrameBuffer already initialized."); Image img = tex.getImage(); checkSetTexture(tex, false); RenderBuffer colorBuf = new RenderBuffer(); colorBuf.slot = colorBufs.size(); colorBuf.tex = tex; colorBuf.format = img.getFormat(); colorBuf.layer = layer; colorBufs.add(colorBuf); }
/** * Add a color buffer without a texture bound to it. * If MRT is enabled, then each subsequently added texture or buffer can be * rendered to through a shader that writes to the array <code>gl_FragData</code>. * If MRT is not enabled, then the index set with {@link FrameBuffer#setTargetIndex(int) } * is rendered to by the shader. * * @param format the format of the color buffer * @see #addColorTexture(com.jme3.texture.Texture2D) */ public void addColorBuffer(Image.Format format){ if (id != -1) throw new UnsupportedOperationException("FrameBuffer already initialized."); if (format.isDepthFormat()) throw new IllegalArgumentException("Color buffer format must be color/luminance."); RenderBuffer colorBuf = new RenderBuffer(); colorBuf.slot = colorBufs.size(); colorBuf.format = format; colorBufs.add(colorBuf); }
/** * Add a color texture to use for this framebuffer. * If MRT is enabled, then each subsequently added texture can be * rendered to through a shader that writes to the array <code>gl_FragData</code>. * If MRT is not enabled, then the index set with {@link FrameBuffer#setTargetIndex(int) } * is rendered to by the shader. * * @param tex The texture to add. */ public void addColorTexture(Texture2D tex) { if (id != -1) throw new UnsupportedOperationException("FrameBuffer already initialized."); Image img = tex.getImage(); checkSetTexture(tex, false); RenderBuffer colorBuf = new RenderBuffer(); colorBuf.slot = colorBufs.size(); colorBuf.tex = tex; colorBuf.format = img.getFormat(); colorBufs.add(colorBuf); }