/** Calls flush() * @see #flush() */ public void destroy() { flush(); }
public Texture(final GL gl, final TextureData data) throws GLException { this.texID = 0; this.target = 0; this.imageTarget = 0; updateImage(gl, data); }
@Override public String getTextureLookupFragmentShaderImpl() throws IllegalStateException { if(useBuildInTexLookup) { return ""; } return "\n"+ "vec4 "+textureLookupFunctionName+"(in "+getTextureSampler2DType()+" image, in vec2 texCoord) {\n"+ " return texture2D(image, texCoord);\n"+ "}\n\n"; }
TextureCoords tc = texture.getImageTexCoords(); gl.glTexCoord2f(tc.left(), tc.top()); gl.glVertex2d(left, top); gl.glTexCoord2f(tc.right(), tc.top()); gl.glVertex2d(left + width, top); gl.glTexCoord2f(tc.right(), tc.bottom()); gl.glVertex2d(left + width, top + height); gl.glTexCoord2f(tc.left(), tc.bottom()); gl.glVertex2d(left, top + height);
textures[i].bind(gl2); textures[i].enable(gl2); gl2.glPushMatrix(); gl2.glTranslatef((float)(width/2), (float)(height/2), 0); gl2.glEnd(); gl2.glPopMatrix(); textures[i].disable(gl2); textures[i].bind(gl2); textures[i].enable(gl2); gl2.glPushMatrix(); gl2.glTranslatef((float)(width/2), (float)(height/2), 0); gl2.glEnd(); gl2.glPopMatrix(); textures[i].disable(gl2); texYantra.bind(gl2); texYantra.enable(gl2); gl2.glPushMatrix(); gl2.glTranslatef((float)(width/2), (float)(height/2), 0); texYantra.bind(gl2); texYantra.enable(gl2); gl2.glPushMatrix(); gl2.glTranslatef((float)(width/2), (float)(height/2), 0); gl2.glEnd();
protected void load(GL gl, String fileName) throws GLException, IOException { texture = TextureIO.newTexture(new File(fileName), useMipMap); if(textureMagnificationFilter!=-1) texture.setTexParameteri(gl, GL.GL_TEXTURE_MAG_FILTER, textureMagnificationFilter); if(textureMinificationFilter!=-1) texture.setTexParameteri(gl, GL.GL_TEXTURE_MIN_FILTER, textureMinificationFilter); }
protected void destroyTexFrame(final GL gl, final TextureFrame frame) { frame.getTexture().destroy(gl); }
/** * Creates an OpenGL texture object associated with the given OpenGL * texture target. The texture has * no initial data. This is used, for example, to construct cube * maps out of multiple TextureData objects. * * @param target the OpenGL target type, eg GL.GL_TEXTURE_2D, * GL.GL_TEXTURE_RECTANGLE_ARB */ public static Texture newTexture(final int target) { return new Texture(target); }
/** Sets the texture data. */ public void setBuffer(final Buffer buffer) { this.buffer = buffer; estimatedMemorySize = estimatedMemorySize(buffer); } /** Sets the required byte alignment for the texture data. */
@Override protected final void destroyImpl(final GL gl) { if(null != texData) { texData.destroy(); texData = null; } }
@Override public final String toString() { return "TextureState[unit "+(state[0] - GL.GL_TEXTURE0)+", target "+toHexString(target)+ ": obj "+toHexString(state[1])+ ", filter[mag "+toHexString(state[2])+", min "+toHexString(state[3])+"], "+ ": wrap[s "+toHexString(state[4])+", t "+toHexString(state[5])+"]]"; } }
/** * Updates the actual image dimensions; usually only called from * <code>updateImage</code>. */ private void setImageSize(final int width, final int height, final int target) { imgWidth = width; imgHeight = height; updateTexCoords(); } private void updateTexCoords() {
/** Flushes resources associated with this TextureData by calling Flusher.flush(). */ public void flush() { if (flusher != null) { flusher.flush(); flusher = null; } }
protected void destroyTexFrame(final GL gl, final TextureFrame frame) { frame.getTexture().destroy(gl); }
/** * Updates the entire content area incl. {@link TextureCoords} * of this texture using the data in the given image. * * @throws GLException if any OpenGL-related errors occurred */ public void updateImage(final GL gl, final TextureData data) throws GLException { updateImage(gl, data, 0); }
@Override public String getTextureLookupFragmentShaderImpl() throws IllegalStateException { if(useBuildInTexLookup) { return ""; } return "\n"+ "vec4 "+textureLookupFunctionName+"(in "+getTextureSampler2DType()+" image, in vec2 texCoord) {\n"+ " return texture2D(image, texCoord);\n"+ "}\n\n"; }
/** Sets the texture data. */ public void setBuffer(final Buffer buffer) { this.buffer = buffer; estimatedMemorySize = estimatedMemorySize(buffer); } /** Sets the required byte alignment for the texture data. */
public void destroy(final GL gl) throws GLException { for(int i=frames.size()-1; i>=0; i--) { frames.get(i).getTexture().destroy(gl); } frames.clear(); }
/** * Updates the entire content area incl. {@link TextureCoords} * of this texture using the data in the given image. * * @throws GLException if any OpenGL-related errors occurred */ public void updateImage(final GL gl, final TextureData data) throws GLException { updateImage(gl, data, 0); }