Java Code Examples for com.jogamp.opengl.util.texture.Texture#getTextureObject()

The following examples show how to use com.jogamp.opengl.util.texture.Texture#getTextureObject() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CubeTexture.java    From MeteoInfo with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public void init(GLAutoDrawable drawable) {
    final GL2 gl = drawable.getGL().getGL2();
    gl.glShadeModel(GL2.GL_SMOOTH);
    gl.glClearColor(1.0f, 1.0f, 1.0f, 1.0f);
    gl.glClearDepth(1.0f);
    gl.glEnable(GL2.GL_DEPTH_TEST);
    gl.glDepthFunc(GL2.GL_LEQUAL);
    gl.glHint(GL2.GL_PERSPECTIVE_CORRECTION_HINT, GL2.GL_NICEST);
    gl.glEnable(GL2.GL_TEXTURE_2D);
    
    try {
        File im = new File("D:\\Temp\\image\\lenna.jpg ");
        //File im = new File("D:\\Temp\\Map\\GLOBALeb3colshade.jpg");
        BufferedImage image = ImageIO.read(im);
        Texture t = AWTTextureIO.newTexture(gl.getGLProfile(), image, true);
        //Texture t = TextureIO.newTexture(im, true);
        texture = t.getTextureObject(gl);
    } catch (IOException e) {
        e.printStackTrace();
    }
}
 
Example 2
Source File: Plot3DGL.java    From MeteoInfo with GNU Lesser General Public License v3.0 5 votes vote down vote up
private void drawImage(GL2 gl, Graphic graphic) {
    ImageShape ishape = (ImageShape) graphic.getShape();
    BufferedImage image = ishape.getImage();
    Texture texture = AWTTextureIO.newTexture(gl.getGLProfile(), image, true);
    //Texture texture = this.imageCache.get(image);
    int idTexture = texture.getTextureObject();
    List<PointZ> coords = ishape.getCoords();

    gl.glColor3f(1f, 1f, 1f);
    gl.glBindTexture(GL2.GL_TEXTURE_2D, idTexture);

    // Texture parameterization
    gl.glTexParameteri(GL2.GL_TEXTURE_2D, GL2.GL_TEXTURE_MIN_FILTER, GL2.GL_NEAREST);
    gl.glTexParameteri(GL2.GL_TEXTURE_2D, GL2.GL_TEXTURE_MAG_FILTER, GL2.GL_LINEAR);

    // Draw image
    gl.glBegin(GL2.GL_QUADS);
    // Front Face
    //gl.glTexCoord2f(0.0f, 0.0f);
    gl.glTexCoord2f(0.0f, 1.0f);
    gl.glVertex3f(transform_xf((float) coords.get(0).X), transform_yf((float) coords.get(0).Y), transform_zf((float) coords.get(0).Z));
    //gl.glTexCoord2f(1.0f, 0.0f);
    gl.glTexCoord2f(1.0f, 1.0f);
    gl.glVertex3f(transform_xf((float) coords.get(1).X), transform_yf((float) coords.get(1).Y), transform_zf((float) coords.get(1).Z));
    //gl.glTexCoord2f(1.0f, 1.0f);
    gl.glTexCoord2f(1.0f, 0.0f);
    gl.glVertex3f(transform_xf((float) coords.get(2).X), transform_yf((float) coords.get(2).Y), transform_zf((float) coords.get(2).Z));
    //gl.glTexCoord2f(0.0f, 1.0f);
    gl.glTexCoord2f(0.0f, 0.0f);
    gl.glVertex3f(transform_xf((float) coords.get(3).X), transform_yf((float) coords.get(3).Y), transform_zf((float) coords.get(3).Z));
    gl.glEnd();

    // Unbinding the texture
    gl.glBindTexture(GL2.GL_TEXTURE_2D, 0);
}
 
Example 3
Source File: Plot3DGL.java    From MeteoInfo with GNU Lesser General Public License v3.0 5 votes vote down vote up
private void drawImage(GL2 gl) throws IOException {
        File im = new File("D:\\Temp\\image\\lenna.jpg ");
        BufferedImage image = ImageIO.read(im);
        Texture t = AWTTextureIO.newTexture(gl.getGLProfile(), image, true);
        //Texture t = TextureIO.newTexture(im, true);
        //Texture t = this.imageCache.get(image);
        int idTexture = t.getTextureObject(gl);

        gl.glColor3f(1f, 1f, 1f);
        gl.glBindTexture(GL2.GL_TEXTURE_2D, idTexture);

//        // Texture parameterization
//        gl.glTexParameteri(GL2.GL_TEXTURE_2D, GL2.GL_TEXTURE_MIN_FILTER, GL2.GL_LINEAR_MIPMAP_LINEAR);
//        gl.glTexParameteri(GL2.GL_TEXTURE_2D, GL2.GL_TEXTURE_MAG_FILTER, GL2.GL_LINEAR);
        // Draw image
        gl.glBegin(GL2.GL_QUADS);
        // Front Face
        gl.glTexCoord2f(0.0f, 0.0f);
        gl.glVertex3f(-1.0f, -1.0f, 1.0f);
        gl.glTexCoord2f(1.0f, 0.0f);
        gl.glVertex3f(1.0f, -1.0f, 1.0f);
        gl.glTexCoord2f(1.0f, 1.0f);
        gl.glVertex3f(1.0f, 1.0f, 1.0f);
        gl.glTexCoord2f(0.0f, 1.0f);
        gl.glVertex3f(-1.0f, 1.0f, 1.0f);
        gl.glEnd();

        // Unbinding the texture
        gl.glBindTexture(GL2.GL_TEXTURE_2D, 0);
    }
 
Example 4
Source File: Plot3DGL.java    From MeteoInfo with GNU Lesser General Public License v3.0 4 votes vote down vote up
private void drawTexture(GL2 gl, Graphic graphic) {
    TextureShape ishape = (TextureShape) graphic.getShape();
    Texture texture = ishape.getTexture();
    if (texture == null) {
        try {
            ishape.loadTexture();
            texture = ishape.getTexture();
        } catch (IOException ex) {
            Logger.getLogger(Plot3DGL.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
    if (texture == null) {
        return;
    }

    int idTexture = texture.getTextureObject();
    List<PointZ> coords = ishape.getCoords();

    gl.glColor3f(1f, 1f, 1f);
    gl.glBindTexture(GL2.GL_TEXTURE_2D, idTexture);

    // Texture parameterization
    //gl.glTexParameteri(GL2.GL_TEXTURE_2D, GL2.GL_TEXTURE_MIN_FILTER, GL2.GL_NEAREST);
    gl.glTexParameteri(GL2.GL_TEXTURE_2D, GL2.GL_TEXTURE_MIN_FILTER, GL2.GL_LINEAR_MIPMAP_LINEAR);
    gl.glTexParameteri(GL2.GL_TEXTURE_2D, GL2.GL_TEXTURE_MAG_FILTER, GL2.GL_LINEAR);

    // Draw image
    gl.glBegin(GL2.GL_QUADS);
    // Front Face
    gl.glTexCoord2f(0.0f, 0.0f);
    //gl.glTexCoord2f(0.0f, 1.0f);
    gl.glVertex3f(transform_xf((float) coords.get(0).X), transform_yf((float) coords.get(0).Y), transform_zf((float) coords.get(0).Z));
    gl.glTexCoord2f(1.0f, 0.0f);
    //gl.glTexCoord2f(1.0f, 1.0f);
    gl.glVertex3f(transform_xf((float) coords.get(1).X), transform_yf((float) coords.get(1).Y), transform_zf((float) coords.get(1).Z));
    gl.glTexCoord2f(1.0f, 1.0f);
    //gl.glTexCoord2f(1.0f, 0.0f);
    gl.glVertex3f(transform_xf((float) coords.get(2).X), transform_yf((float) coords.get(2).Y), transform_zf((float) coords.get(2).Z));
    gl.glTexCoord2f(0.0f, 1.0f);
    //gl.glTexCoord2f(0.0f, 0.0f);
    gl.glVertex3f(transform_xf((float) coords.get(3).X), transform_yf((float) coords.get(3).Y), transform_zf((float) coords.get(3).Z));
    gl.glEnd();

    // Unbinding the texture
    gl.glBindTexture(GL2.GL_TEXTURE_2D, 0);
}
 
Example 5
Source File: OpenGL.java    From gama with GNU General Public License v3.0 4 votes vote down vote up
public int getTextureId(final GamaImageFile file, final boolean useCache) {
	final Texture r = textureCache.getTexture(file.getFile(null), file.isAnimated(), useCache);
	if (r == null) { return NO_TEXTURE; }
	return r.getTextureObject();
}
 
Example 6
Source File: OpenGL.java    From gama with GNU General Public License v3.0 4 votes vote down vote up
public int getTextureId(final BufferedImage img) {
	final Texture r = textureCache.getTexture(img);
	if (r == null) { return NO_TEXTURE; }
	return r.getTextureObject();
}