Package org.mt4j.util.opengl

Examples of org.mt4j.util.opengl.GLTexture


//      ts.shrinkFilter = SHRINKAGE_FILTER.Trilinear; //For better quality
      ts.expansionFilter = EXPANSION_FILTER.Bilinear;
      ts.wrappingHorizontal = WRAP_MODE.CLAMP_TO_EDGE;
      ts.wrappingVertical = WRAP_MODE.CLAMP_TO_EDGE;
    
      textureToRenderTo = new GLTexture(mtApp, ts);
//      textureToRenderTo = new MTTexture(mtApp, rectC.width, rectC.height, ts); //This would also init the gl texture
      textureToRenderTo.width = rectC.width; //So that tex coords of shape get scaled correctly
      textureToRenderTo.height = rectC.height;
     
      if (!mtApp.isRenderThreadCurrent()){
View Full Code Here


    //Create the earth
    earth = new MTSphere(pa, "earth", 40, 40, 80, TextureMode.Projected); //TextureMode.Polar);
    earth.setLight(light);
    earth.setMaterial(material);
    earth.rotateX(earth.getCenterPointRelativeToParent(), -90);
    earth.setTexture(new GLTexture(pa,imagesPath + "worldMap.jpg", new GLTextureSettings(TEXTURE_TARGET.TEXTURE_2D, SHRINKAGE_FILTER.Trilinear, EXPANSION_FILTER.Bilinear, WRAP_MODE.CLAMP_TO_EDGE, WRAP_MODE.CLAMP_TO_EDGE)));
        earth.generateAndUseDisplayLists();
        earth.setPositionGlobal(new Vector3D(pa.width/2f, pa.height/2f, 250)); //earth.setPositionGlobal(new Vector3D(200, 200, 250));
        //Animate earth rotation
        new Animation("rotation animation", new MultiPurposeInterpolator(0,360, 17000, 0, 1, -1) , earth).addAnimationListener(new IAnimationListener(){
          public void processAnimationEvent(AnimationEvent ae) {
            earth.rotateY(earth.getCenterPointLocal(), ae.getCurrentStepDelta(), TransformSpace.LOCAL);
          }}).start();
       
        //Put planets in a group that can be manipulated by gestures
        //so the rotation of the planets doesent get changed by the gestures
    MTComponent group = new MTComponent(mtApplication);
    group.setComposite(true); //This makes the group "consume" all picking and gestures of the children
    group.registerInputProcessor(new DragProcessor(mtApplication));
    group.addGestureListener(DragProcessor.class, new DefaultDragAction());
    group.addGestureListener(DragProcessor.class, new InertiaDragAction(80, 0.8f, 10));
    group.registerInputProcessor(new RotateProcessor(mtApplication));
    group.addGestureListener(RotateProcessor.class, new DefaultRotateAction());
    //Scale the earth from the center. Else it might get distorted
    group.registerInputProcessor(new ScaleProcessor(mtApplication));
    group.addGestureListener(ScaleProcessor.class, new IGestureEventListener() {
      public boolean processGestureEvent(MTGestureEvent ge) {
        ScaleEvent se = (ScaleEvent)ge;
        earth.scaleGlobal(se.getScaleFactorX(), se.getScaleFactorY(), se.getScaleFactorX(), earth.getCenterPointGlobal());
        return false;
      }
    });
    this.getCanvas().addChild(group);
        group.addChild(earth);
       
        //Create the moon
        final MTSphere moonSphere = new MTSphere(pa, "moon", 35, 35, 25, TextureMode.Polar);
         moonSphere.setMaterial(material);
        moonSphere.translate(new Vector3D(earth.getRadius() + moonSphere.getRadius() + 50, 0,0));
        moonSphere.setTexture(new GLTexture(pa, imagesPath + "moonmap1k.jpg", new GLTextureSettings(TEXTURE_TARGET.RECTANGULAR, SHRINKAGE_FILTER.Trilinear, EXPANSION_FILTER.Bilinear, WRAP_MODE.CLAMP_TO_EDGE, WRAP_MODE.CLAMP_TO_EDGE)));
        moonSphere.generateAndUseDisplayLists();
        moonSphere.unregisterAllInputProcessors();
        //Rotate the moon around the earth
        new Animation("moon animation", new MultiPurposeInterpolator(0,360, 12000, 0, 1, -1) , moonSphere).addAnimationListener(new IAnimationListener(){
          public void processAnimationEvent(AnimationEvent ae) {
View Full Code Here

    this.init(p, horizontalTileCount, horizontalTileCount);
  }
 
  private void init(PImage p, int horizontalTileCount, int verticalTileCount){
    if (MT4jSettings.getInstance().isOpenGlMode() && !(p instanceof GLTexture)){
      GLTexture tex = new GLTexture(app, p);
      this.image = tex;
    }else{
      this.image = p;
    }
   
View Full Code Here

      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());
View Full Code Here

        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

   
    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

  //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

    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

//          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

              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

TOP

Related Classes of org.mt4j.util.opengl.GLTexture

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.