@Override public Unit onTexture2D(final JCGLTexture2DUsableType t) throws JCGLException { LOG.debug( "[{}] attach {} at color {}", Integer.valueOf(f_id), t, Integer.valueOf(index)); FakeTextures.checkTexture2D(FakeFramebuffers.this.context, t); final JCGLTextureFormat f = t.format(); JCGLTextureFormats.checkColorRenderableTexture2D(f); return Unit.unit(); }
@Override public void attachDepthTexture2D( final JCGLTexture2DUsableType t) { LWJGL3Textures.checkTexture2D(this.context, t); JCGLTextureFormats.checkDepthOnlyRenderableTexture2D( t.format()); this.depth = t; this.depth_stencil = null; }
@Override public void attachDepthStencilTexture2D(final JCGLTexture2DUsableType t) { LWJGL3Textures.checkTexture2D(this.context, t); JCGLTextureFormats.checkDepthStencilRenderableTexture2D( t.format()); this.depth = null; this.depth_stencil = t; }
@Override public void attachDepthTexture2D( final JCGLTexture2DUsableType t) { FakeTextures.checkTexture2D(this.context, t); JCGLTextureFormats.checkDepthOnlyRenderableTexture2D( t.format()); this.depth = t; this.depth_stencil = null; }
@Override public void attachDepthStencilTexture2D(final JCGLTexture2DUsableType t) { FakeTextures.checkTexture2D(this.context, t); JCGLTextureFormats.checkDepthStencilRenderableTexture2D( t.format()); this.depth = null; this.depth_stencil = t; }
@Override public Unit onTexture2D(final JCGLTexture2DUsableType t) throws JCGLException { if (LOG.isDebugEnabled()) { LOG.debug( "[{}] attach color {} {}", Integer.valueOf(f_id), Integer.valueOf(index), t); } LWJGL3Textures.checkTexture2D(c, t); final JCGLTextureFormat f = t.format(); JCGLTextureFormats.checkColorRenderableTexture2D(f); GL30.glFramebufferTexture2D( GL30.GL_DRAW_FRAMEBUFFER, GL30.GL_COLOR_ATTACHMENT0 + index, GL11.GL_TEXTURE_2D, t.glName(), 0); return Unit.unit(); }
final int bpp = t.format().getBytesPerPixel(); final long size = width * height * (long) bpp;
@Override public Unit onTexture2D( final JCGLTexture2DUsableType t) throws JCGLException { LOG.debug( "[{}] attach {} at depth", Integer.valueOf(f_id), t); final JCGLTextureFormat f = t.format(); FakeTextures.checkTexture2D(FakeFramebuffers.this.context, t); JCGLTextureFormats.checkDepthOnlyRenderableTexture2D(f); fb.setDepthAttachment(t, JCGLTextureFormats.depthBits(f)); return Unit.unit(); } });
@Override public void attachColorTexture2DAt( final JCGLFramebufferColorAttachmentPointType point, final JCGLFramebufferDrawBufferType buffer, final JCGLTexture2DUsableType texture) { NullCheck.notNull(point, "Point"); checkColorAttachmentPoint(this.context, point); checkDrawBuffer(this.context, buffer); FakeTextures.checkTexture2D(this.context, texture); JCGLTextureFormats.checkColorRenderableTexture2D( texture.format()); this.color_attaches.set(point.colorAttachmentPointIndex(), texture); this.draw_buffers.put(buffer, point); }
@Override public void attachColorTexture2DAt( final JCGLFramebufferColorAttachmentPointType point, final JCGLFramebufferDrawBufferType buffer, final JCGLTexture2DUsableType texture) { NullCheck.notNull(point, "Point"); checkColorAttachmentPoint(this.context, point); checkDrawBuffer(this.context, buffer); LWJGL3Textures.checkTexture2D(this.context, texture); JCGLTextureFormats.checkColorRenderableTexture2D( texture.format()); this.color_attaches.set(point.colorAttachmentPointIndex(), texture); this.draw_buffers.put(buffer, point); }
@Override public Unit onTexture2D(final JCGLTexture2DUsableType t) throws JCGLException { LOG.debug( "[{}] attach {} at depth+stencil", Integer.valueOf(f_id), t); FakeTextures.checkTexture2D(FakeFramebuffers.this.context, t); final JCGLTextureFormat f = t.format(); JCGLTextureFormats.checkDepthStencilRenderableTexture2D(f); fb.setDepthStencilAttachment( t, JCGLTextureFormats.depthBits(f), JCGLTextureFormats.stencilBits(f)); return Unit.unit(); } });
@Override public Unit onTexture2D( final JCGLTexture2DUsableType t) throws JCGLException { if (LOG.isDebugEnabled()) { LOG.debug( "[{}] attach depth {}", Integer.valueOf(f_id), t); } final JCGLTextureFormat f = t.format(); LWJGL3Textures.checkTexture2D(c, t); JCGLTextureFormats.checkDepthOnlyRenderableTexture2D(f); GL30.glFramebufferTexture2D( GL30.GL_DRAW_FRAMEBUFFER, GL30.GL_DEPTH_ATTACHMENT, GL11.GL_TEXTURE_2D, t.glName(), 0); fb.setDepthAttachment(t, JCGLTextureFormats.depthBits(f)); return Unit.unit(); } });
@Override public Unit onTexture2D(final JCGLTexture2DUsableType t) throws JCGLException { if (LOG.isDebugEnabled()) { LOG.debug( "[{}] attach depth+stencil {}", Integer.valueOf(f_id), t); } LWJGL3Textures.checkTexture2D(c, t); final JCGLTextureFormat f = t.format(); JCGLTextureFormats.checkDepthStencilRenderableTexture2D(f); GL30.glFramebufferTexture2D( GL30.GL_DRAW_FRAMEBUFFER, GL30.GL_DEPTH_STENCIL_ATTACHMENT, GL11.GL_TEXTURE_2D, t.glName(), 0); fb.setDepthStencilAttachment( t, JCGLTextureFormats.depthBits(f), JCGLTextureFormats.stencilBits(f)); return Unit.unit(); } });
@Override public ByteBuffer texture2DGetImage( final JCGLTextureUnitType unit, final JCGLTexture2DUsableType texture) throws JCGLException { NullCheck.notNull(texture, "Texture"); NullCheck.notNull(unit, "Unit"); checkTextureUnit(this.context, unit); checkTexture2D(this.context, texture); final JCGLTextureFormat format = texture.format(); final LWJGL3TextureSpec spec = LWJGL3TextureSpecs.getTextureSpec(format); final AreaL area = AreaSizesL.area(texture.size()); final long width = area.width(); final long height = area.height(); final long data_size = width * height * (long) format.getBytesPerPixel(); final ByteBuffer data = ByteBuffer.allocateDirect(Math.toIntExact(data_size)); 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 createTextureUpdate2D( final JCGLTexture2DUsableType t, final JCGLTLTextureDataType data) { final JCGLTexture2DUpdateType u = JCGLTextureUpdates.newUpdateReplacingAll2D(t); final int tw = (int) t.width(); final int th = (int) t.height(); final long dw = data.width(); final long dh = data.height(); RangeCheck.checkGreaterEqualLong( (long) tw, "Texture width", dw, "Data width"); RangeCheck.checkGreaterEqualLong( (long) th, "Texture height", dh, "Data height"); populate( t.format(), data, u.data(), tw, th); return u; }
final int height = Math.toIntExact(update_area.height()); final JCGLTextureFormat format = texture.format(); final LWJGL3TextureSpec spec = LWJGL3TextureSpecs.getTextureSpec(format); final ByteBuffer buffer = data.data();
final int bpp = texture.format().getBytesPerPixel(); copyBytes( bpp,