android.opengl.GLUtils#getInternalFormat ( )源码实例Demo

下面列出了android.opengl.GLUtils#getInternalFormat ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: PhotoMovie   文件: UploadedTexture.java
/**
 * Updates the content on GPU's memory.
 *
 * @param canvas
 */
public void updateContent(GLESCanvas canvas) {
    if (!isLoaded()) {
        if (mThrottled && ++sUploadedCount > UPLOAD_LIMIT || canvas == null) {
            return;
        }
        uploadToCanvas(canvas);
    } else if (!mContentValid) {
        Bitmap bitmap = getBitmap();
        int format = GLUtils.getInternalFormat(bitmap);
        int type = GLUtils.getType(bitmap);
        canvas.texSubImage2D(this, mBorder, mBorder, bitmap, format, type);
        freeBitmap();
        mContentValid = true;
    }
}
 
源代码2 项目: android-openGL-canvas   文件: UploadedTexture.java
/**
 * Updates the content on GPU's memory.
 * @param canvas
 */
public void updateContent(GLCanvas canvas) {
    if (!isLoaded()) {
        if (mThrottled && ++sUploadedCount > UPLOAD_LIMIT) {
            return;
        }
        uploadToCanvas(canvas);
    } else if (!mContentValid) {
        Bitmap bitmap = getBitmap();
        int format = GLUtils.getInternalFormat(bitmap);
        int type = GLUtils.getType(bitmap);
        canvas.texSubImage2D(this, mBorder, mBorder, bitmap, format, type);
        freeBitmap();
        mContentValid = true;
    }
}
 
源代码3 项目: Trebuchet   文件: UploadedTexture.java
/**
 * Updates the content on GPU's memory.
 * @param canvas
 */
public void updateContent(GLCanvas canvas) {
    if (!isLoaded()) {
        if (mThrottled && ++sUploadedCount > UPLOAD_LIMIT) {
            return;
        }
        uploadToCanvas(canvas);
    } else if (!mContentValid) {
        Bitmap bitmap = getBitmap();
        int format = GLUtils.getInternalFormat(bitmap);
        int type = GLUtils.getType(bitmap);
        canvas.texSubImage2D(this, mBorder, mBorder, bitmap, format, type);
        freeBitmap();
        mContentValid = true;
    }
}
 
源代码4 项目: TurboLauncher   文件: UploadedTexture.java
/**
 * Updates the content on GPU's memory.
 * @param canvas
 */
public void updateContent(GLCanvas canvas) {
    if (!isLoaded()) {
        if (mThrottled && ++sUploadedCount > UPLOAD_LIMIT) {
            return;
        }
        uploadToCanvas(canvas);
    } else if (!mContentValid) {
        Bitmap bitmap = getBitmap();
        int format = GLUtils.getInternalFormat(bitmap);
        int type = GLUtils.getType(bitmap);
        canvas.texSubImage2D(this, mBorder, mBorder, bitmap, format, type);
        freeBitmap();
        mContentValid = true;
    }
}
 
源代码5 项目: trekarta   文件: AndroidBitmap.java
@Override
public void uploadToTexture(boolean replace) {
    if (mBitmap.isRecycled()) {
        log.error("Attempted to upload recycled bitmap to texture");
        return;
    }
    int format = GLUtils.getInternalFormat(mBitmap);
    int type = GLUtils.getType(mBitmap);

    if (replace)
        GLUtils.texSubImage2D(GLES20.GL_TEXTURE_2D, 0, 0, 0,
                mBitmap, format, type);
    else
        GLUtils.texImage2D(GLES20.GL_TEXTURE_2D, 0, format,
                mBitmap, type, 0);
}
 
源代码6 项目: LB-Launcher   文件: UploadedTexture.java
/**
 * Updates the content on GPU's memory.
 * @param canvas
 */
public void updateContent(GLCanvas canvas) {
    if (!isLoaded()) {
        if (mThrottled && ++sUploadedCount > UPLOAD_LIMIT) {
            return;
        }
        uploadToCanvas(canvas);
    } else if (!mContentValid) {
        Bitmap bitmap = getBitmap();
        int format = GLUtils.getInternalFormat(bitmap);
        int type = GLUtils.getType(bitmap);
        canvas.texSubImage2D(this, mBorder, mBorder, bitmap, format, type);
        freeBitmap();
        mContentValid = true;
    }
}
 
源代码7 项目: document-viewer   文件: UploadedTexture.java
/**
 * Updates the content on GPU's memory.
 *
 * @param canvas
 */
public void updateContent(final GLCanvas canvas) {
    if (!isLoaded()) {
        if (mThrottled && ++sUploadedCount > UPLOAD_LIMIT) {
            return;
        }
        uploadToCanvas(canvas);
    } else if (!mContentValid) {
        final Bitmap bitmap = getBitmap();
        final int format = GLUtils.getInternalFormat(bitmap);
        final int type = GLUtils.getType(bitmap);
        canvas.getGLInstance().glBindTexture(GL10.GL_TEXTURE_2D, mId);
        GLUtils.texSubImage2D(GL10.GL_TEXTURE_2D, 0, 0, 0, bitmap, format, type);
        freeBitmap();
        mContentValid = true;
    }
}
 
源代码8 项目: Tanks   文件: FileTextureSource.java
private int loadTexture()
{
  ResultRunnable<Integer> runnable = new ResultRunnable<Integer>()
  {
    @Override
    protected Integer onRun()
    {
      try
      {
        String fileName = getTextureFileName(name);
        InputStream stream = GameContext.context.getAssets().open(fileName);
        Bitmap bitmap = BitmapFactory.decodeStream(stream);
        stream.close();

        int type = GLUtils.getType(bitmap);
        int format = GLUtils.getInternalFormat(bitmap);
        int error;

        int[] textures = new int[1];

        GLES20.glGenTextures(1, textures, 0);
        if ((error = GLES20.glGetError()) != GLES20.GL_NO_ERROR)
          throw new GLException(error);

        GLES20.glActiveTexture(GLES20.GL_TEXTURE0);
        if ((error = GLES20.glGetError()) != GLES20.GL_NO_ERROR)
          throw new GLException(error);

        GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, textures[0]);
        if ((error = GLES20.glGetError()) != GLES20.GL_NO_ERROR)
          throw new GLException(error);

        GLUtils.texImage2D(GLES20.GL_TEXTURE_2D, 0, format, bitmap, type, 0);
        if ((error = GLES20.glGetError()) != GLES20.GL_NO_ERROR)
          throw new GLException(error);

        GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_MIN_FILTER, GLES20.GL_LINEAR);
        GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_MAG_FILTER, GLES20.GL_LINEAR);

        GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_WRAP_S, GLES20.GL_REPEAT);
        GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_WRAP_T, GLES20.GL_REPEAT);

        if (generateMipmap)
        {
          GLES20.glGenerateMipmap(GLES20.GL_TEXTURE_2D);
          if ((error = GLES20.glGetError()) != GLES20.GL_NO_ERROR)
            throw new GLException(error, Integer.toString(error));
        }

        bitmap.recycle();
        return textures[0];
      }
      catch(Exception e)
      {
        throw new RuntimeException(e);
      }
    }
  };

  GameContext.glThread.sendEvent(runnable);
  return runnable.getResult();
}
 
源代码9 项目: document-viewer   文件: UploadedTexture.java
private void uploadToCanvas(final GLCanvas canvas) {
    final GL11 gl = canvas.getGLInstance();

    final Bitmap bitmap = getBitmap();
    if (bitmap != null) {
        try {
            final int bWidth = bitmap.getWidth();
            final int bHeight = bitmap.getHeight();
            final int texWidth = getTextureWidth();
            final int texHeight = getTextureHeight();

            // Upload the bitmap to a new texture.
            GLId.glGenTextures(1, sTextureId, 0);
            gl.glBindTexture(GL10.GL_TEXTURE_2D, sTextureId[0]);
            gl.glTexParameteri(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_WRAP_S, GL10.GL_CLAMP_TO_EDGE);
            gl.glTexParameteri(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_WRAP_T, GL10.GL_CLAMP_TO_EDGE);
            gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_MIN_FILTER, GL10.GL_LINEAR);
            gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_MAG_FILTER, GL10.GL_LINEAR);

            if (bWidth == texWidth && bHeight == texHeight) {
                GLUtils.texImage2D(GL10.GL_TEXTURE_2D, 0, bitmap, 0);
            } else {
                final int format = GLUtils.getInternalFormat(bitmap);
                final int type = GLUtils.getType(bitmap);

                gl.glTexImage2D(GL10.GL_TEXTURE_2D, 0, format, texWidth, texHeight, 0, format, type, null);
                GLUtils.texSubImage2D(GL10.GL_TEXTURE_2D, 0, 0, 0, bitmap, format, type);
            }
        } finally {
            freeBitmap();
        }
        // Update texture state.
        setAssociatedCanvas(canvas);
        mId = sTextureId[0];
        mState = STATE_LOADED;
        mContentValid = true;
    } else {
        mState = STATE_ERROR;
        throw new RuntimeException("Texture load fail, no bitmap");
    }
}