Package com.sun.opengl.util.texture

Examples of com.sun.opengl.util.texture.TextureCoords


    private void drawCell(GL gl, MapGridCellView cell) {
        try {
            Texture t = getTexture(cell);
            t.enable();
            t.bind();
            TextureCoords tc = t.getImageTexCoords();
            gl.glBegin(GL.GL_QUADS);
            gl.glTexCoord2d(tc.left(), tc.top());
            gl.glVertex3d(cell.getX(), cell.getY(), 0);

            gl.glTexCoord2d(tc.right(), tc.top());
            gl.glVertex3d(cell.getX() + cell.getWidth(), cell.getY(), 0);

            gl.glTexCoord2d(tc.right(), tc.bottom());
            gl.glVertex3d(cell.getX() + cell.getWidth(),
                    cell.getY() + cell.getHeight(), 0);

            gl.glTexCoord2d(tc.left(), tc.bottom());
            gl.glVertex3d(cell.getX(), cell.getY() + cell.getHeight(), 0);
            gl.glEnd();
            t.disable();
        } catch (Exception e) {
            e.printStackTrace();
View Full Code Here


    private void drawCell(GL gl, MapGridCellView cell) {
        try {
            Texture t = getTexture(cell);
            t.enable();
            t.bind();
            TextureCoords tc = t.getImageTexCoords();
            gl.glBegin(GL.GL_QUADS);
            gl.glTexCoord2d(tc.left(), tc.top());
            gl.glVertex3d(cell.getX(), cell.getY(), 0);

            gl.glTexCoord2d(tc.right(), tc.top());
            gl.glVertex3d(cell.getX() + cell.getWidth(), cell.getY(), 0);

            gl.glTexCoord2d(tc.right(), tc.bottom());
            gl.glVertex3d(cell.getX() + cell.getWidth(), cell.getY()
                    + cell.getHeight(), 0);

            gl.glTexCoord2d(tc.left(), tc.bottom());
            gl.glVertex3d(cell.getX(), cell.getY() + cell.getHeight(), 0);
            gl.glEnd();
            t.disable();
        } catch (Exception e) {
            e.printStackTrace();
View Full Code Here

    if (!(image instanceof Image)) throw new RuntimeException("Image has not been created by the JOGL Blackspirit Graphics implementation!");
    Image joglImage = (Image)image;
   
    startPrimitive(Primitive.IMAGE, joglImage);
       
    TextureCoords coords = joglImage.texture.getImageTexCoords();
    float texTop = coords.top();
    float texBottom = coords.bottom();
    float texLeft = coords.left();
    float texRight = coords.right();

   
    if(flip == Flip.BOTH || flip == Flip.HORIZONTAL) {
      float temp = texTop;
      texTop = texBottom;
View Full Code Here

    if (!(image instanceof Image)) throw new RuntimeException("Image has not been created by the JOGL Blackspirit Graphics implementation!");
    Image joglImage = (Image)image;

    startPrimitive(Primitive.IMAGE, joglImage);

    TextureCoords coords = joglImage.texture.getImageTexCoords();
    float texTop = coords.top() + (coords.bottom() - coords.top()) / image.getHeight() * subImageY;
    float texBottom = coords.top() + (coords.bottom() - coords.top()) / image.getHeight() * (subImageY + subImageHeight);
    float texLeft = coords.left() + (coords.right() - coords.left()) / image.getWidth() * subImageX;
    float texRight = coords.left() + (coords.right() - coords.left()) / image.getWidth() * (subImageX + subImageWidth);

    if(flip == Flip.BOTH || flip == Flip.HORIZONTAL) {
      float temp = texTop;
      texTop = texBottom;
      texBottom = temp;
View Full Code Here

    Image joglImage = null;

    joglImage = (Image)image;
    startPrimitive(Primitive.TEXTURED_TRIANGLE, joglImage);

    TextureCoords coords = joglImage.texture.getImageTexCoords();
   
    if(useColors) {
      Color4f c;
        for(int i = 0; i < triangles.length; i++) {
        Triangle t = triangles[i];
        if(t == null) continue;

        Vector2f tc1 = t.getTextureCoordinate(0);
        if (tc1 == null) throw new IllegalArgumentException("Texture coordinate for triangle must not be null");
        Vector2f tc2 = t.getTextureCoordinate(1);
        if (tc2 == null) throw new IllegalArgumentException("Texture coordinate for triangle must not be null");
        Vector2f tc3 = t.getTextureCoordinate(2);
        if (tc3 == null) throw new IllegalArgumentException("Texture coordinate for triangle must not be null");
   
        p = t.getPoint(0);
        c = t.getColor(0);
        if(c == null) c = color;
        gl.glColor4f(c.x, c.y, c.z, c.w);
        float texX = coords.left() + (coords.right() - coords.left()) / joglImage.texture.getImageWidth() * tc1.x;
        float texY = coords.top() + (coords.bottom() - coords.top()) / joglImage.texture.getImageHeight() * tc1.y;
        gl.glTexCoord2f(texX, texY);
            gl.glVertex2f(p.x, p.y);
       
            p = t.getPoint(1);
        c = t.getColor(1);
        if(c == null) c = color;
        gl.glColor4f(c.x, c.y, c.z, c.w);
        texX = coords.left() + (coords.right() - coords.left()) / joglImage.texture.getImageWidth() * tc2.x;
        texY = coords.top() + (coords.bottom() - coords.top()) / joglImage.texture.getImageHeight() * tc2.y;
        gl.glTexCoord2f(texX, texY);
            gl.glVertex2f(p.x, p.y);
       
            p = t.getPoint(2);
        c = t.getColor(2);
        if(c == null) c = color;
        gl.glColor4f(c.x, c.y, c.z, c.w);
        texX = coords.left() + (coords.right() - coords.left()) / joglImage.texture.getImageWidth() * tc3.x;
        texY = coords.top() + (coords.bottom() - coords.top()) / joglImage.texture.getImageHeight() * tc3.y;
        gl.glTexCoord2f(texX, texY);
            gl.glVertex2f(p.x, p.y);
   
        }
    } else {
        for(int i = 0; i < triangles.length; i++) {
        Triangle t = triangles[i];
        if(t == null) continue;
 
        Vector2f tc1 = t.getTextureCoordinate(0);
        if (tc1 == null) throw new IllegalArgumentException("Texture coordinate for triangle must not be null");
        Vector2f tc2 = t.getTextureCoordinate(1);
        if (tc2 == null) throw new IllegalArgumentException("Texture coordinate for triangle must not be null");
        Vector2f tc3 = t.getTextureCoordinate(2);
        if (tc3 == null) throw new IllegalArgumentException("Texture coordinate for triangle must not be null");

        p = t.getPoint(0);
        float texX = coords.left() + (coords.right() - coords.left()) / joglImage.texture.getImageWidth() * tc1.x;
        float texY = coords.top() + (coords.bottom() - coords.top()) / joglImage.texture.getImageHeight() * tc1.y;
        gl.glTexCoord2f(texX, texY);
            gl.glVertex2f(p.x, p.y);
       
            p = t.getPoint(1);
        texX = coords.left() + (coords.right() - coords.left()) / joglImage.texture.getImageWidth() * tc2.x;
        texY = coords.top() + (coords.bottom() - coords.top()) / joglImage.texture.getImageHeight() * tc2.y;
        gl.glTexCoord2f(texX, texY);
            gl.glVertex2f(p.x, p.y);
       
            p = t.getPoint(2);
        texX = coords.left() + (coords.right() - coords.left()) / joglImage.texture.getImageWidth() * tc3.x;
        texY = coords.top() + (coords.bottom() - coords.top()) / joglImage.texture.getImageHeight() * tc3.y;
        gl.glTexCoord2f(texX, texY);
            gl.glVertex2f(p.x, p.y);
   
        }
    }
View Full Code Here

    gl.glClear(GL.GL_COLOR_BUFFER_BIT);

    gl.glBegin(GL.GL_TRIANGLE_STRIP);
    gl.glColor4f(1, 1, 1, 1);
   
    TextureCoords coords = image.texture.getImageTexCoords();
       
    gl.glTexCoord2f(coords.left(), coords.top());
        gl.glVertex2f(0, 0);
        gl.glTexCoord2f(coords.right(), coords.top());
        gl.glVertex2f(image.getWidth(), 0);
        gl.glTexCoord2f(coords.left(), coords.bottom());
        gl.glVertex2f(0, image.getHeight());
        gl.glTexCoord2f(coords.right(), coords.bottom());
        gl.glVertex2f(image.getWidth(), image.getHeight());

        gl.glEnd();
       
        gl.glGetIntegerv(GL.GL_PACK_ROW_LENGTH,  rowLength,  0); // save row length
View Full Code Here

TOP

Related Classes of com.sun.opengl.util.texture.TextureCoords

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.