Examples of GLTexture


Examples of org.mt4j.util.opengl.GLTexture

        this.getGeometryInfo().updateTextureBuffer(this.isUseVBOs());
    }
   
    if (MT4jSettings.getInstance().isOpenGlMode()){
      GLTextureSettings g = new GLTextureSettings(TEXTURE_TARGET.TEXTURE_2D, SHRINKAGE_FILTER.BilinearNoMipMaps, EXPANSION_FILTER.Bilinear, WRAP_MODE.REPEAT, WRAP_MODE.REPEAT);
      GLTexture tex;
      if (pot){
        tex = new GLTexture(mtApp, bgImage, g);
      }else{
        if (tiled){
          g.target = TEXTURE_TARGET.RECTANGULAR;
          //Because NPOT texture with GL_REPEAT isnt supported -> use mipMapping -> gluBuild2Dmipmapds strechtes the texture to POT size
//          g.shrinkFilter = SHRINKAGE_FILTER.BilinearNearestMipMap;
          g.shrinkFilter = SHRINKAGE_FILTER.Trilinear;
          tex = new GLTexture(mtApp, bgImage, g);
        }else{
          g.target = TEXTURE_TARGET.RECTANGULAR;
          tex = new GLTexture(mtApp, bgImage, g);
        }
      }
      this.setTexture(tex);
    }else{
      this.setTexture(bgImage);
View Full Code Here

Examples of org.mt4j.util.opengl.GLTexture

   
    if (MT4jSettings.getInstance().isOpenGlMode()){
      //Set the texture to be non-repeating but clamping to the border to avoid artefacts
      PImage tex = this.getTexture();
      if (tex instanceof GLTexture) {
        GLTexture glTex = (GLTexture) tex;
//        glTex.setWrap(GL.GL_CLAMP, GL.GL_CLAMP);
//        glTex.setWrap(GL.GL_CLAMP_TO_EDGE, GL.GL_CLAMP_TO_EDGE);
       
        glTex.setWrapMode(WRAP_MODE.CLAMP_TO_EDGE, WRAP_MODE.CLAMP_TO_EDGE);
       
//        glTex.setFilter(SHRINKAGE_FILTER.Trilinear, EXPANSION_FILTER.Bilinear);
        glTex.setFilter(SHRINKAGE_FILTER.BilinearNoMipMaps, EXPANSION_FILTER.Bilinear);
//        glTex.setFilter(SHRINKAGE_FILTER.NearestNeighborNoMipMaps, EXPANSION_FILTER.NearestNeighbor);
//        glTex.setFilter(SHRINKAGE_FILTER.BilinearNoMipMaps, EXPANSION_FILTER.NearestNeighbor);
      }
    }
  }
View Full Code Here

Examples of org.mt4j.util.opengl.GLTexture

  //FIXME TEST
  public void setTextureFiltered(boolean scalable) {
    if (MT4jSettings.getInstance().isOpenGlMode()){
      PImage tex = this.getTexture();
      if (tex instanceof GLTexture) {
        GLTexture glTex = (GLTexture) tex;
        //FIXME normally we would use GL_LINEAR as magnification filter but sometimes
        //small text is too filtered and smudged so we use NEAREST -> but this makes
        //scaled text very ugly and pixelated..
        if (scalable){
//          glTex.setFilter(GL.GL_LINEAR, GL.GL_LINEAR);
          glTex.setFilter(SHRINKAGE_FILTER.BilinearNoMipMaps, EXPANSION_FILTER.Bilinear);
        }else{
//          glTex.setFilter(GL.GL_LINEAR, GL.GL_NEAREST);
          glTex.setFilter(SHRINKAGE_FILTER.BilinearNoMipMaps, EXPANSION_FILTER.NearestNeighbor);
        }
      }
    }
  }
View Full Code Here

Examples of org.mt4j.util.opengl.GLTexture

    int usedTextureID = -1;
    if (useTexture
      && texture != null
      && texture instanceof GLTexture) //Bad for performance?
    {
      GLTexture tex = (GLTexture)texture;
      textureTarget = tex.getTextureTarget();
     
      //tells opengl which texture to reference in following calls from now on!
      //the first parameter is eigher GL.GL_TEXTURE_2D or ..1D
      gl.glEnable(textureTarget);
      usedTextureID = tex.getTextureID();
      gl.glBindTexture(textureTarget, tex.getTextureID());
     
      gl.glEnableClientState(GL.GL_TEXTURE_COORD_ARRAY);
      gl.glTexCoordPointer(2, GL.GL_FLOAT, 0, tbuff);
      textureDrawn = true;
    }
View Full Code Here

Examples of org.mt4j.util.opengl.GLTexture

//          GradientPanel gradPanel = new GradientPanel(size, size, r, offsets, colors, (float)c.getX(), (float)c.getY(), (float)f.getX(), (float)f.getY());
            GradientPanel gradPanel = new GradientPanel(bBoxWidth, bBoxHeight, r, offsets, colors, (float)c.getX(), (float)c.getY(), (float)f.getX(), (float)f.getY(), awtCycleMethod);
            swingTex = new SwingTextureRenderer(app, gradPanel);
            swingTex.scheduleRefresh();
            rectangle = new MTRectangle(new Vertex(boundsVecs[0]), bBoxWidth, bBoxHeight, pa);
            final GLTexture tex = swingTex.getTextureToRenderTo();
            rectangle.setName("Swing texture rendering");
            rectangle.setTexture(tex);
            rectangle.setNoStroke(true);
            rectangle.setPickable(false);
View Full Code Here

Examples of org.mt4j.util.opengl.GLTexture

              PImage alphaMap = p.d;
              if (alphaMap.width == tex.width && alphaMap.height == tex.height){
                tex.mask(alphaMap);
                 
                  if (tex instanceof GLTexture) {
                    GLTexture glTex = (GLTexture) tex;
//                glTex.putPixelsIntoTexture(tex);
                    glTex.loadGLTexture(tex);
              }
              }else{
                //System.out.println("Alpha map isnt the same size as the texture for material: " + matName);
              }
            }
View Full Code Here

Examples of org.mt4j.util.opengl.GLTexture

                    }
                   
                    if (MT4jSettings.getInstance().isOpenGlMode()){
                      PImage img = pa.loadImage(basePath + tFile);
                    if (Tools3D.isPowerOfTwoDimension(img)){
                      texture = new GLTexture(pa, img, new GLTextureSettings(TEXTURE_TARGET.TEXTURE_2D, SHRINKAGE_FILTER.Trilinear, EXPANSION_FILTER.Bilinear, WRAP_MODE.REPEAT, WRAP_MODE.REPEAT));
                    }else{
                      texture = new GLTexture(pa, img, new GLTextureSettings(TEXTURE_TARGET.RECTANGULAR, SHRINKAGE_FILTER.Trilinear, EXPANSION_FILTER.Bilinear, WRAP_MODE.REPEAT, WRAP_MODE.REPEAT));
//                      ((GLTexture)texture).setFilter(SHRINKAGE_FILTER.BilinearNoMipMaps, EXPANSION_FILTER.Bilinear);
                    }
                    }else{
                      texture = pa.loadImage(basePath + tFile);
                    }
                    textureCache.put(tFile, texture);
                }else{
                  System.out.println("Trying to load obj texture from: " + basePath + tFile);
                    if (MT4jSettings.getInstance().isOpenGlMode()){
                      PImage img = pa.loadImage(basePath + tFile);
                    if (Tools3D.isPowerOfTwoDimension(img)){
                      texture = new GLTexture(pa, img, new GLTextureSettings(TEXTURE_TARGET.TEXTURE_2D, SHRINKAGE_FILTER.Trilinear, EXPANSION_FILTER.Bilinear, WRAP_MODE.REPEAT, WRAP_MODE.REPEAT));
                    }else{
                      texture = new GLTexture(pa, img, new GLTextureSettings(TEXTURE_TARGET.RECTANGULAR, SHRINKAGE_FILTER.Trilinear, EXPANSION_FILTER.Bilinear, WRAP_MODE.REPEAT, WRAP_MODE.REPEAT));
//                      ((GLTexture)texture).setFilter(SHRINKAGE_FILTER.BilinearNoMipMaps, EXPANSION_FILTER.Bilinear);
                    }
                    }else{
                      texture = pa.loadImage(basePath + tFile);
                    }
                    textureCache.put(tFile, texture);
                }
              }
             
//              RgbFile f;
//              if (fromUrl) {
//                f = new RgbFile(new URL(basePath + tFile).openStream());
//              } else {
//                f = new RgbFile(new FileInputStream(basePath + tFile));
//              }
//              BufferedImage bi = f.getImage();

              boolean luminance = suffix.equals("int") || suffix.equals("inta");
              boolean alpha = suffix.equals("inta") || suffix.equals("rgba");
              cur.transparent = alpha;

              String s = null;
              if (luminance && alpha) s = "LUM8_ALPHA8";
              else if (luminance) s = "LUMINANCE";
              else if (alpha) s = "RGBA";
              else s = "RGB";

//              t = new TextureLoader(bi, s, TextureLoader.GENERATE_MIPMAP);
            } else {
//              tFile.toLowerCase();
//              tFile.toLowerCase(Locale.ENGLISH);
//              basePath.toLowerCase();
             
              PImage cachedImage = textureCache.get(tFile);
              if (cachedImage != null){
                texture = cachedImage;
                //System.out.println("->Loaded texture from CACHE : \"" + tFile + "\"");
              }else{
                File textureFile = new File(basePath + tFile);
                if (textureFile.exists()){
                  boolean success = textureFile.renameTo(new File(basePath + tFile));
                    if (!success) {
                        // File was not successfully renamed
                      System.out.println("failed to RENAME file: " + textureFile.getAbsolutePath());
                    }
                   
                    if (MT4jSettings.getInstance().isOpenGlMode()){
                      PImage img = pa.loadImage(basePath + tFile);
                    if (Tools3D.isPowerOfTwoDimension(img)){
                      texture = new GLTexture(pa, img, new GLTextureSettings(TEXTURE_TARGET.TEXTURE_2D, SHRINKAGE_FILTER.Trilinear, EXPANSION_FILTER.Bilinear, WRAP_MODE.REPEAT, WRAP_MODE.REPEAT));
                    }else{
                      texture = new GLTexture(pa, img, new GLTextureSettings(TEXTURE_TARGET.RECTANGULAR, SHRINKAGE_FILTER.Trilinear, EXPANSION_FILTER.Bilinear, WRAP_MODE.REPEAT, WRAP_MODE.REPEAT));
//                      ((GLTexture)texture).setFilter(SHRINKAGE_FILTER.BilinearNoMipMaps, EXPANSION_FILTER.Bilinear);
                    }
                    }else{
                      texture = pa.loadImage(basePath + tFile);
                    }
                    textureCache.put(tFile, texture);
                }else{
                  System.out.println("Trying to load obj texture from: " + basePath + tFile);
                    if (MT4jSettings.getInstance().isOpenGlMode()){
                      PImage img = pa.loadImage(basePath + tFile);
                    if (Tools3D.isPowerOfTwoDimension(img)){
                      texture = new GLTexture(pa, img, new GLTextureSettings(TEXTURE_TARGET.TEXTURE_2D, SHRINKAGE_FILTER.Trilinear, EXPANSION_FILTER.Bilinear, WRAP_MODE.REPEAT, WRAP_MODE.REPEAT));
                    }else{
                      texture = new GLTexture(pa, img, new GLTextureSettings(TEXTURE_TARGET.RECTANGULAR, SHRINKAGE_FILTER.Trilinear, EXPANSION_FILTER.Bilinear, WRAP_MODE.REPEAT, WRAP_MODE.REPEAT));
//                      ((GLTexture)texture).setFilter(SHRINKAGE_FILTER.BilinearNoMipMaps, EXPANSION_FILTER.Bilinear);
                    }
                    }else{
                      texture = pa.loadImage(basePath + tFile);
                    }
View Full Code Here

Examples of org.mt4j.util.opengl.GLTexture

                }
                PImage texture = null;
                if (MT4jSettings.getInstance().isOpenGlMode()){ //TODO check if render thread
                  PImage img = pa.loadImage(texturePath);
                  if (Tools3D.isPowerOfTwoDimension(img)){
                    texture = new GLTexture(pa, img, new GLTextureSettings(TEXTURE_TARGET.TEXTURE_2D, SHRINKAGE_FILTER.Trilinear, EXPANSION_FILTER.Bilinear, WRAP_MODE.REPEAT, WRAP_MODE.REPEAT));
                  }else{
                    texture = new GLTexture(pa, img, new GLTextureSettings(TEXTURE_TARGET.RECTANGULAR, SHRINKAGE_FILTER.Trilinear, EXPANSION_FILTER.Bilinear, WRAP_MODE.REPEAT, WRAP_MODE.REPEAT));
                    // ((GLTexture)texture).setFilter(SHRINKAGE_FILTER.BilinearNoMipMaps, EXPANSION_FILTER.Bilinear);
                  }
                }else{
                  texture     = pa.loadImage(texturePath);
                }
                mesh.setTexture(texture);
                mesh.setTextureEnabled(true);

                textureCache.put(materialName, texture);
                if (debug)
                  logger.debug("->Loaded material texture: \"" + materialName + "\"");
                break;
              }
              if (j+1==suffix.length){
                logger.error("Couldnt load material texture: \"" + materialName + "\"");
              }
            }
          }else{//Probably loading from jar file
            PImage texture = null;
            String[] suffix = new String[]{"jpg", "JPG", "tga" , "TGA", "bmp", "BMP", "png", "PNG", "tiff", "TIFF"};
            for (String suffixString : suffix) {
              String modelFolder  = pathToModel.substring(0, pathToModel.lastIndexOf(MTApplication.separator));
              String texturePath   = modelFolder + MTApplication.separator + materialName + "." +  suffixString;
              if (MT4jSettings.getInstance().isOpenGlMode()){
                PImage img = pa.loadImage(texturePath);
                if (Tools3D.isPowerOfTwoDimension(img)){
                  texture = new GLTexture(pa, img, new GLTextureSettings(TEXTURE_TARGET.TEXTURE_2D, SHRINKAGE_FILTER.Trilinear, EXPANSION_FILTER.Bilinear, WRAP_MODE.REPEAT, WRAP_MODE.REPEAT));
                }else{
                  texture = new GLTexture(pa, img, new GLTextureSettings(TEXTURE_TARGET.RECTANGULAR, SHRINKAGE_FILTER.Trilinear, EXPANSION_FILTER.Bilinear, WRAP_MODE.REPEAT, WRAP_MODE.REPEAT));
                  // ((GLTexture)texture).setFilter(SHRINKAGE_FILTER.BilinearNoMipMaps, EXPANSION_FILTER.Bilinear);
                }
              }else{
                texture = pa.loadImage(texturePath);
              }
View Full Code Here

Examples of org.mt4j.util.opengl.GLTexture

    //Create FBO
//    this.fbo = new GLFBO(pa, pa.width, pa.height);
    this.fbo = new GLFBO(pa, fboWidth, fboHeight);
   
    //Attach texture to FBO to draw into
    GLTexture tex = fbo.addNewTexture();
   
    //Invert y texture coord (FBO texture is flipped)
    Vertex[] v = this.getVerticesLocal();
    for (int i = 0; i < v.length; i++) {
      Vertex vertex = v[i];
View Full Code Here

Examples of org.mt4j.util.opengl.GLTexture

      boolean textureDrawn = false;
      if (this.isTextureEnabled()
        && this.getTexture() != null
        && this.getTexture() instanceof GLTexture) //Bad for performance?
      {
        GLTexture tex = (GLTexture)this.getTexture();
        textureTarget = tex.getTextureTarget();
       
        //tells opengl which texture to reference in following calls from now on!
        //the first parameter is eigher GL.GL_TEXTURE_2D or ..1D
        gl.glEnable(textureTarget);
        gl.glBindTexture(textureTarget, tex.getTextureID());
        gl.glEnableClientState(GL.GL_TEXTURE_COORD_ARRAY);
       
        if (this.isUseVBOs()){//Texture
          gl.glBindBuffer(GL.GL_ARRAY_BUFFER, this.getGeometryInfo().getVBOTextureName());
          gl.glTexCoordPointer(2, GL.GL_FLOAT, 0, 0);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.