@Override public Unit onTexture2D(final JCGLTexture2DUsableType t) throws JCGLException { FakeFramebuffers.LOG.debug( "[{}] attach {} at color {}", Integer.valueOf(f_id), t, Integer.valueOf(index)); FakeTextures.checkTexture2D(FakeFramebuffers.this.context, t); final JCGLTextureFormat f = t.textureGetFormat(); JCGLTextureFormats.checkColorRenderableTexture2D(f); return Unit.unit(); }
@Override public void attachDepthTexture2D( final JCGLTexture2DUsableType t) { FakeTextures.checkTexture2D(this.context, t); JCGLTextureFormats.checkDepthOnlyRenderableTexture2D( t.textureGetFormat()); this.depth = t; this.depth_stencil = null; }
@Override public void attachDepthStencilTexture2D(final JCGLTexture2DUsableType t) { FakeTextures.checkTexture2D(this.context, t); JCGLTextureFormats.checkDepthStencilRenderableTexture2D( t.textureGetFormat()); this.depth = null; this.depth_stencil = t; }
@Override public void attachDepthStencilTexture2D(final JCGLTexture2DUsableType t) { LWJGL3Textures.checkTexture2D(this.context, t); JCGLTextureFormats.checkDepthStencilRenderableTexture2D( t.textureGetFormat()); this.depth = null; this.depth_stencil = t; }
@Override public void attachDepthTexture2D( final JCGLTexture2DUsableType t) { LWJGL3Textures.checkTexture2D(this.context, t); JCGLTextureFormats.checkDepthOnlyRenderableTexture2D( t.textureGetFormat()); this.depth = t; this.depth_stencil = null; }
@Override public Unit onTexture2D(final JCGLTexture2DUsableType t) throws JCGLException { if (LWJGL3Framebuffers.LOG.isDebugEnabled()) { LWJGL3Framebuffers.LOG.debug( "[{}] attach color {} {}", Integer.valueOf(f_id), Integer.valueOf(index), t); } LWJGL3Textures.checkTexture2D(c, t); final JCGLTextureFormat f = t.textureGetFormat(); JCGLTextureFormats.checkColorRenderableTexture2D(f); GL30.glFramebufferTexture2D( GL30.GL_DRAW_FRAMEBUFFER, GL30.GL_COLOR_ATTACHMENT0 + index, GL11.GL_TEXTURE_2D, t.getGLName(), 0); return Unit.unit(); }
@Override public Unit onTexture2D( final JCGLTexture2DUsableType t) throws JCGLException { FakeFramebuffers.LOG.debug( "[{}] attach {} at depth", Integer.valueOf(f_id), t); final JCGLTextureFormat f = t.textureGetFormat(); FakeTextures.checkTexture2D(FakeFramebuffers.this.context, t); JCGLTextureFormats.checkDepthOnlyRenderableTexture2D(f); fb.setDepthAttachment(t, JCGLTextureFormats.getDepthBits(f)); return Unit.unit(); } });
@Override public void attachColorTexture2DAt( final JCGLFramebufferColorAttachmentPointType point, final JCGLFramebufferDrawBufferType buffer, final JCGLTexture2DUsableType texture) { NullCheck.notNull(point); FakeFramebuffers.checkColorAttachmentPoint(this.context, point); FakeFramebuffers.checkDrawBuffer(this.context, buffer); FakeTextures.checkTexture2D(this.context, texture); JCGLTextureFormats.checkColorRenderableTexture2D( texture.textureGetFormat()); this.color_attaches.set(point.colorAttachmentPointGetIndex(), texture); this.draw_buffers.put(buffer, point); }
@Override public void attachColorTexture2DAt( final JCGLFramebufferColorAttachmentPointType point, final JCGLFramebufferDrawBufferType buffer, final JCGLTexture2DUsableType texture) { NullCheck.notNull(point); LWJGL3Framebuffers.checkColorAttachmentPoint(this.context, point); LWJGL3Framebuffers.checkDrawBuffer(this.context, buffer); LWJGL3Textures.checkTexture2D(this.context, texture); JCGLTextureFormats.checkColorRenderableTexture2D( texture.textureGetFormat()); this.color_attaches.set(point.colorAttachmentPointGetIndex(), texture); this.draw_buffers.put(buffer, point); }
@Override public Unit onTexture2D(final JCGLTexture2DUsableType t) throws JCGLException { FakeFramebuffers.LOG.debug( "[{}] attach {} at depth+stencil", Integer.valueOf(f_id), t); FakeTextures.checkTexture2D(FakeFramebuffers.this.context, t); final JCGLTextureFormat f = t.textureGetFormat(); JCGLTextureFormats.checkDepthStencilRenderableTexture2D(f); fb.setDepthStencilAttachment( t, JCGLTextureFormats.getDepthBits(f), JCGLTextureFormats.getStencilBits(f)); return Unit.unit(); } });
@Override public Unit onTexture2D( final JCGLTexture2DUsableType t) throws JCGLException { if (LWJGL3Framebuffers.LOG.isDebugEnabled()) { LWJGL3Framebuffers.LOG.debug( "[{}] attach depth {}", Integer.valueOf(f_id), t); } final JCGLTextureFormat f = t.textureGetFormat(); LWJGL3Textures.checkTexture2D(c, t); JCGLTextureFormats.checkDepthOnlyRenderableTexture2D(f); GL30.glFramebufferTexture2D( GL30.GL_DRAW_FRAMEBUFFER, GL30.GL_DEPTH_ATTACHMENT, GL11.GL_TEXTURE_2D, t.getGLName(), 0); fb.setDepthAttachment(t, JCGLTextureFormats.getDepthBits(f)); return Unit.unit(); } });
@Override public Unit onTexture2D(final JCGLTexture2DUsableType t) throws JCGLException { if (LWJGL3Framebuffers.LOG.isDebugEnabled()) { LWJGL3Framebuffers.LOG.debug( "[{}] attach depth+stencil {}", Integer.valueOf(f_id), t); } LWJGL3Textures.checkTexture2D(c, t); final JCGLTextureFormat f = t.textureGetFormat(); JCGLTextureFormats.checkDepthStencilRenderableTexture2D(f); GL30.glFramebufferTexture2D( GL30.GL_DRAW_FRAMEBUFFER, GL30.GL_DEPTH_STENCIL_ATTACHMENT, GL11.GL_TEXTURE_2D, t.getGLName(), 0); fb.setDepthStencilAttachment( t, JCGLTextureFormats.getDepthBits(f), JCGLTextureFormats.getStencilBits(f)); return Unit.unit(); } });
final int bpp = t.textureGetFormat().getBytesPerPixel(); final long size = width * height * (long) bpp;
@Override public ByteBuffer texture2DGetImage( final JCGLTextureUnitType unit, final JCGLTexture2DUsableType texture) throws JCGLException { NullCheck.notNull(texture); NullCheck.notNull(unit); LWJGL3Textures.checkTextureUnit(this.context, unit); LWJGL3Textures.checkTexture2D(this.context, texture); final JCGLTextureFormat format = texture.textureGetFormat(); final LWJGL3TextureSpec spec = LWJGL3TextureSpecs.getTextureSpec(format); final AreaInclusiveUnsignedLType area = texture.textureGetArea(); final long width = area.getRangeX().getInterval(); final long height = area.getRangeY().getInterval(); final ByteBuffer data = ByteBuffer.allocateDirect( (int) (width * height * (long) format.getBytesPerPixel())); data.order(ByteOrder.nativeOrder()); this.texture2DBind(unit, texture); GL11.glGetTexImage( GL11.GL_TEXTURE_2D, 0, spec.getFormat(), spec.getType(), data); return data; }
@Override public JCGLTexture2DUpdateType getTextureUpdate2D( final JCGLTexture2DUsableType t, final JCGLTLTextureDataType data) { final JCGLTexture2DUpdateType u = JCGLTextureUpdates.newUpdateReplacingAll2D(t); final int tw = (int) t.textureGetWidth(); final int th = (int) t.textureGetHeight(); final long dw = data.getWidth(); final long dh = data.getHeight(); RangeCheck.checkGreaterEqualLong( (long) tw, "Texture width", dw, "Data width"); RangeCheck.checkGreaterEqualLong( (long) th, "Texture height", dh, "Data height"); JCGLTLTextureUpdateProvider.populate( t.textureGetFormat(), data, u.getData(), tw, th); return u; }
@Test public final void testTexture() { final JCGLContextType c = this.newGL33Context("main", 24, 8); final JCGLInterfaceGL33Type gi = c.contextGetGL33(); final JCGLTexturesType gt = gi.getTextures(); final JCGLTextureUnitAllocatorType tc = JCGLTextureUnitAllocator.newAllocatorWithStack(32, gt.textureGetUnits()); final R2Texture2DType tt = R2SSAONoiseTexture.newNoiseTexture(gt, tc.getRootContext()); final JCGLTexture2DUsableType t = tt.texture(); Assert.assertEquals(64L, t.textureGetWidth()); Assert.assertEquals(64L, t.textureGetWidth()); Assert.assertEquals( JCGLTextureFormat.TEXTURE_FORMAT_RGB_8_3BPP, t.textureGetFormat()); } }
final long target_width = target_range_x.getInterval(); final int bpp = texture.textureGetFormat().getBytesPerPixel(); FakeTextures.copyBytes( bpp,
t_rgba.texture().textureGetFormat());
t_r.texture().textureGetFormat());
t_ao.texture().textureGetFormat());