Package com.sun.opengl.util.texture

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


        gl.glActiveTexture(GL.GL_TEXTURE0);
        gl.glClientActiveTexture(GL.GL_TEXTURE0);

        /* Texture */
        try {
          Texture texture = core.getTextureID(gl);
          if (texture != null) {
            gl.glBindTexture(GL.GL_TEXTURE_2D, texture.getTextureObject());
          }
        } catch (IOException e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
        }
       
//        bindTexture(core);

//        if (Global.RELATIVETRANSFORM) {
//        /* Transform */
//        gl.glPushMatrix();
//        gl.glTranslatef(hcore.vertexorigin.x, hcore.vertexorigin.y, hcore.vertexorigin.z);
//        gl.glScalef(hcore.vertexscale, hcore.vertexscale, hcore.vertexscale);
//        }

        Point3D vertexarray[] = hcore.vertexarray;
        Point2D texcoordarray[] = hcore.texcoordarray;

        float heightblendvalue = node.getInterpolationCounter();
        Point3D vertex[] = hcore.getInterpolationVertexArray(heightblendvalue); // vertexarray;
        int vertex_i = 0;
        Point2D texcoord[] = texcoordarray;
        int texcoord_i = 0;

        /* Initialize texture units */
        gl.glActiveTexture(GL.GL_TEXTURE0);
        gl.glClientActiveTexture(GL.GL_TEXTURE0);
        gl.glEnableClientState(GL.GL_VERTEX_ARRAY);
        gl.glEnableClientState(GL.GL_NORMAL_ARRAY);
        gl.glEnableClientState(GL.GL_TEXTURE_COORD_ARRAY);
        gl.glTexEnvi(GL.GL_TEXTURE_ENV, GL.GL_TEXTURE_ENV_MODE, GL.GL_REPLACE);
        gl.glEnable(GL.GL_COLOR_MATERIAL);
        gl.glColor4f(1.f, 1.f, 1.f, 1.f);

        /* Set second texture only if the user wants multitexturing */
        if (Global.cacheUseMultiTexturing) {
          gl.glActiveTexture(GL.GL_TEXTURE1);
          gl.glClientActiveTexture(GL.GL_TEXTURE1);
          gl.glEnable(GL.GL_TEXTURE_2D);
          gl.glEnableClientState(GL.GL_TEXTURE_COORD_ARRAY);

          Texture interpolationtextureID = null;
          try {
            interpolationtextureID = core.getInterpolationTextureID(gl);
          } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
          }
          if (interpolationtextureID == null) {
            blendvalue = 0;
          }
          else {
            gl.glColor4f(blendvalue, blendvalue, blendvalue, 1.f);
            gl.glEnable(GL.GL_TEXTURE_2D);
            interpolationtextureID.bind();
          }
        }
        else {
          blendvalue = 0;
        }
View Full Code Here


            int cleanLayer = shift == 1 ? 0 : 2;

            for (String str : _texsActive[cleanLayer].keySet()) {
                _texProc.freeTexture(str);
                Texture t = _texsActive[cleanLayer].get(str);
                if (isLoaded(t)) {
                    t.bind();
                    t.dispose();
                }
            }
            _texsActive[cleanLayer].clear();
            System.gc();

            if (shift == 1) {
                _texsActive[0] = _texsActive[1];
                _texsActive[1] = _texsActive[2];
                _texsActive[2] = new HashMap<String, Texture>();
                preload(_cacheRect, lvl + 1);
            } else if (shift == -1) {
                _texsActive[2] = _texsActive[1];
                _texsActive[1] = _texsActive[0];
                _texsActive[0] = new HashMap<String, Texture>();
                preload(_cacheRect, _lvl - 1);
            } else {
                System.out.println("RELOAD ALL CACHE!");
                for (int i = 0; i < 3; i++) {
                    for (String str : _texsActive[i].keySet()) {
                        _texProc.freeTexture(str);
                        Texture t = _texsActive[i].get(str);
                        if (isLoaded(t)) {
                            t.bind();
                            t.dispose();
                        }
                    }
                    _texsActive[i].clear();
                    System.gc();
                    preload(_cacheRect, _lvl - 1 + i);
View Full Code Here

        texStore = new TexturesStorage();
    }

    public Texture getMapTexture(String gpath) throws Exception {
        if(texStore==null)return null;
        Texture tex = null;
        HashMap<String, Texture> lay = null;

        for (HashMap<String, Texture> hm : _texsActive) {
            if (tex == null) {
                tex = hm.get(gpath);
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();
            gl.glDisable(GL.GL_TEXTURE);
        }
        boolean drawRects = false;
View Full Code Here

                        / viewPort.getViewWorldHeight());
    }

    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();
            gl.glDisable(GL.GL_TEXTURE);
        }
        boolean drawRects = false;
View Full Code Here

  * @param fileName relative filename from execution point
  * @return a texture binded to the OpenGL context
  */
  public static Texture load(String fileName){
    Texture text = null;
    try{
      text = TextureIO.newTexture(new File(fileName), true);
      text.setTexParameteri(GL.GL_TEXTURE_MAG_FILTER, GL.GL_NEAREST);
      text.setTexParameteri(GL.GL_TEXTURE_MIN_FILTER, GL.GL_NEAREST);
      //text.setTexParameteri(GL.GL_TEXTURE_MIN_FILTER, GL.GL_LINEAR_MIPMAP_NEAREST);
    }catch(Exception e){         
      try {
        System.out.println(fileName);
        text = TextureIO.newTexture(new File("resources/Images/Error.JPG"), true);
        text.setTexParameteri(GL.GL_TEXTURE_MAG_FILTER, GL.GL_NEAREST);
        text.setTexParameteri(GL.GL_TEXTURE_MIN_FILTER, GL.GL_NEAREST)
      } catch (Exception e1) {       
        System.out.println(e1.getMessage());
      }
     
   
View Full Code Here

TOP

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

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.