Java 类com.badlogic.gdx.graphics.glutils.MipMapGenerator 实例源码

项目:libgdxcn    文件:GLTexture.java   
public static void uploadImageData (int target, TextureData data, int miplevel) {
    if (data == null) {
        // FIXME: remove texture on target?
        return;
    }

    if (!data.isPrepared()) data.prepare();

    final TextureDataType type = data.getType();
    if (type == TextureDataType.Custom) {
        data.consumeCustomData(target);
        return;
    }

    Pixmap pixmap = data.consumePixmap();
    boolean disposePixmap = data.disposePixmap();
    if (data.getFormat() != pixmap.getFormat()) {
        Pixmap tmp = new Pixmap(pixmap.getWidth(), pixmap.getHeight(), data.getFormat());
        Blending blend = Pixmap.getBlending();
        Pixmap.setBlending(Blending.None);
        tmp.drawPixmap(pixmap, 0, 0, 0, 0, pixmap.getWidth(), pixmap.getHeight());
        Pixmap.setBlending(blend);
        if (data.disposePixmap()) {
            pixmap.dispose();
        }
        pixmap = tmp;
        disposePixmap = true;
    }

    Gdx.gl.glPixelStorei(GL20.GL_UNPACK_ALIGNMENT, 1);
    if (data.useMipMaps()) {
        MipMapGenerator.generateMipMap(target, pixmap, pixmap.getWidth(), pixmap.getHeight());
    } else {
        Gdx.gl.glTexImage2D(target, miplevel, pixmap.getGLInternalFormat(), pixmap.getWidth(), pixmap.getHeight(), 0,
            pixmap.getGLFormat(), pixmap.getGLType(), pixmap.getPixels());
    }
    if (disposePixmap) pixmap.dispose();
}
项目:libgdxcn    文件:MipMapTest.java   
@Override
public void create () {
    camera = new PerspectiveCamera(67, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
    camera.position.set(0, 1.5f, 1.5f);
    camera.lookAt(0, 0, 0);
    camera.update();
    controller = new PerspectiveCamController(camera);

    mesh = new Mesh(true, 4, 4, new VertexAttribute(Usage.Position, 3, ShaderProgram.POSITION_ATTRIBUTE), new VertexAttribute(
        Usage.TextureCoordinates, 2, ShaderProgram.TEXCOORD_ATTRIBUTE));
    mesh.setVertices(new float[] {-1, 0, 1, 0, 1, 1, 0, 1, 1, 1, 1, 0, -1, 1, 0, -1, 0, -1, 0, 0,});
    mesh.setIndices(new short[] {0, 1, 2, 3});

    shader = new ShaderProgram(Gdx.files.internal("data/shaders/flattex-vert.glsl").readString(), Gdx.files.internal(
        "data/shaders/flattex-frag.glsl").readString());
    if (!shader.isCompiled()) throw new GdxRuntimeException("shader error: " + shader.getLog());

    textureHW = new Texture(Gdx.files.internal("data/badlogic.jpg"), Format.RGB565, true);
    MipMapGenerator.setUseHardwareMipMap(false);
    textureSW = new Texture(Gdx.files.internal("data/badlogic.jpg"), Format.RGB565, true);
    currTexture = textureHW;

    createUI();

    multiplexer = new InputMultiplexer();
    Gdx.input.setInputProcessor(multiplexer);
    multiplexer.addProcessor(ui);
    multiplexer.addProcessor(controller);
}
项目:ingress-indonesia-dev    文件:Texture.java   
private void uploadImageData(Pixmap paramPixmap)
{
  if ((enforcePotImages) && (Gdx.gl20 == null) && ((!MathUtils.isPowerOfTwo(this.data.getWidth())) || (!MathUtils.isPowerOfTwo(this.data.getHeight()))))
    throw new GdxRuntimeException("Texture width and height must be powers of two: " + this.data.getWidth() + "x" + this.data.getHeight());
  boolean bool;
  if (this.data.getFormat() != paramPixmap.getFormat())
  {
    Pixmap localPixmap = new Pixmap(paramPixmap.getWidth(), paramPixmap.getHeight(), this.data.getFormat());
    Pixmap.Blending localBlending = Pixmap.getBlending();
    Pixmap.setBlending(Pixmap.Blending.None);
    int i = paramPixmap.getWidth();
    int j = paramPixmap.getHeight();
    localPixmap.drawPixmap(paramPixmap, 0, 0, 0, 0, i, j);
    Pixmap.setBlending(localBlending);
    bool = true;
    paramPixmap = localPixmap;
  }
  while (true)
  {
    Gdx.gl.glBindTexture(3553, this.glHandle);
    Gdx.gl.glPixelStorei(3317, 1);
    if (this.data.useMipMaps())
      MipMapGenerator.generateMipMap(paramPixmap, paramPixmap.getWidth(), paramPixmap.getHeight(), bool);
    do
    {
      return;
      Gdx.gl.glTexImage2D(3553, 0, paramPixmap.getGLInternalFormat(), paramPixmap.getWidth(), paramPixmap.getHeight(), 0, paramPixmap.getGLFormat(), paramPixmap.getGLType(), paramPixmap.getPixels());
    }
    while (!bool);
    paramPixmap.dispose();
    return;
    bool = false;
  }
}