Exemple #1
0
  public void usingRepeat(boolean repeat) {
    if (repeat) {
      glWrapS = PGL.REPEAT;
      glWrapT = PGL.REPEAT;
      usingRepeat = true;
    } else {
      glWrapS = PGL.CLAMP_TO_EDGE;
      glWrapT = PGL.CLAMP_TO_EDGE;
      usingRepeat = false;
    }

    bind();
    pgl.texParameteri(glTarget, PGL.TEXTURE_WRAP_S, glWrapS);
    pgl.texParameteri(glTarget, PGL.TEXTURE_WRAP_T, glWrapT);
    unbind();
  }
Exemple #2
0
  public void usingMipmaps(boolean mipmaps, int sampling) {
    if (mipmaps) {
      if (glMinFilter != PGL.LINEAR_MIPMAP_NEAREST && glMinFilter != PGL.LINEAR_MIPMAP_LINEAR) {
        if (sampling == POINT) {
          glMagFilter = PGL.NEAREST;
          glMinFilter = PGL.NEAREST;
        } else if (sampling == LINEAR) {
          glMagFilter = PGL.NEAREST;
          glMinFilter = PGL.MIPMAPS_ENABLED ? PGL.LINEAR_MIPMAP_NEAREST : PGL.LINEAR;
        } else if (sampling == BILINEAR) {
          glMagFilter = PGL.LINEAR;
          glMinFilter = PGL.MIPMAPS_ENABLED ? PGL.LINEAR_MIPMAP_NEAREST : PGL.LINEAR;
        } else if (sampling == TRILINEAR) {
          glMagFilter = PGL.LINEAR;
          glMinFilter = PGL.MIPMAPS_ENABLED ? PGL.LINEAR_MIPMAP_LINEAR : PGL.LINEAR;
        } else {
          throw new RuntimeException("Unknown texture filtering mode");
        }
      }

      usingMipmaps = true;
    } else {
      if (glMinFilter == PGL.LINEAR_MIPMAP_NEAREST || glMinFilter == PGL.LINEAR_MIPMAP_LINEAR) {
        glMinFilter = PGL.LINEAR;
      }
      usingMipmaps = false;
    }

    bind();
    pgl.texParameteri(glTarget, PGL.TEXTURE_MIN_FILTER, glMinFilter);
    pgl.texParameteri(glTarget, PGL.TEXTURE_MAG_FILTER, glMagFilter);
    if (usingMipmaps) {
      if (PGraphicsOpenGL.autoMipmapGenSupported) {
        pgl.generateMipmap(glTarget);
      } else {
        // TODO: need manual generation here..
      }
    }
    unbind();
  }