@Override public void init(GLAutoDrawable glAutoDrawable) { GL2 gl = (GL2) glAutoDrawable.getGL(); texture = GLUtils.createTexture(gl, getClass().getResourceAsStream(textureResourcePath)); h = texture.getHeight(); w = texture.getWidth(); }
/** A GL2 context MUST be current. */ @Override public void mount(GL gl) { try { load(gl, file); } catch (Exception e) { throw new RuntimeException(e); } coords = texture.getImageTexCoords(); halfWidth = texture.getWidth() / 2; halfHeight = texture.getHeight() / 2; }
/** A GL2 context MUST be current. */ @Override public void mount(GL gl) { try { load(gl, image); } catch (Exception e) { throw new RuntimeException(e); } coords = texture.getImageTexCoords(); halfWidth = texture.getWidth() / 2; halfHeight = texture.getHeight() / 2; }
@Override public boolean drawImage(Image img, int dx1, int dy1, int dx2, int dy2, int sx1, int sy1, int sx2, int sy2, Color bgcolor, ImageObserver observer) { Texture texture = getTexture(img, observer); if (texture == null) { return false; } float height = texture.getHeight(); float width = texture.getWidth(); begin(texture, null, bgcolor); applyTexture(texture, dx1, dy1, dx2, dy2, sx1 / width, sy1 / height, sx2 / width, sy2 / height); end(texture); return true; }
@Override public boolean drawImage(Image img, int dx1, int dy1, int dx2, int dy2, int sx1, int sy1, int sx2, int sy2, Color bgcolor, ImageObserver observer) { Texture texture = getTexture(img, observer); if (texture == null) { return false; } float height = texture.getHeight(); float width = texture.getWidth(); begin(texture, null, bgcolor); applyTexture(texture, dx1, dy1, dx2, dy2, sx1 / width, sy1 / height, sx2 / width, sy2 / height); end(texture); return true; }
protected void applyTexture(Texture texture) { int width = texture.getWidth(); int height = texture.getHeight(); TextureCoords coords = texture.getImageTexCoords(); applyTexture(texture, 0, 0, width, height, coords.left(), coords.top(), coords.right(), coords.bottom()); }
private void bindTexture(Texture tex, int glType) { assert (tex != null); assert (currdraw == id); boolean size = checkSize(tex.getWidth(), tex.getHeight()); assert (size); assert ((tex.getTarget() == GL.GL_TEXTURE_2D || tex.getTarget() == GL2GL3.GL_TEXTURE_RECTANGLE)); assert (id != 0); gc.getGL().glFramebufferTexture2D(GL.GL_FRAMEBUFFER, glType, GL.GL_TEXTURE_2D, tex.getTextureObject(null), 0); }
protected void applyTexture(Texture texture) { int width = texture.getWidth(); int height = texture.getHeight(); TextureCoords coords = texture.getImageTexCoords(); applyTexture(texture, 0, 0, width, height, coords.left(), coords.top(), coords.right(), coords.bottom()); }