當前位置: 首頁>>代碼示例>>Java>>正文


Java GLUtils類代碼示例

本文整理匯總了Java中android.opengl.GLUtils的典型用法代碼示例。如果您正苦於以下問題:Java GLUtils類的具體用法?Java GLUtils怎麽用?Java GLUtils使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


GLUtils類屬於android.opengl包,在下文中一共展示了GLUtils類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: makeTexture

import android.opengl.GLUtils; //導入依賴的package包/類
private int makeTexture(Bitmap bmp) {
    //テクスチャメモリの確保
    int[] textureIds=new int[1];
    GLES20.glGenTextures(1,textureIds,0);

    //テクスチャへのビットマップ指定
    GLES20.glActiveTexture(GLES20.GL_TEXTURE0);
    GLES20.glBindTexture(GLES20.GL_TEXTURE_2D,textureIds[0]);
    GLUtils.texImage2D(GL10.GL_TEXTURE_2D,0,bmp,0);

    //テクスチャフィルタの指定
    GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D,
            GLES20.GL_TEXTURE_MIN_FILTER,GLES20.GL_NEAREST);
    GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D,
            GLES20.GL_TEXTURE_MAG_FILTER,GLES20.GL_NEAREST);
    return textureIds[0];
}
 
開發者ID:jphacks,項目名稱:TK_1701,代碼行數:18,代碼來源:TargetObject.java

示例2: setMark

import android.opengl.GLUtils; //導入依賴的package包/類
public WaterMarkFilter setMark(final Bitmap bmp){
    runOnGLThread(new Runnable() {
        @Override
        public void run() {
            if(bmp!=null){
                if(markTextureId==-1){
                    markTextureId=GpuUtils.createTextureID(false);
                }else{
                    GLES20.glBindTexture(GLES20.GL_TEXTURE_2D,markTextureId);
                }
                GLUtils.texImage2D(GLES20.GL_TEXTURE_2D,0,bmp,0);
                bmp.recycle();
            }else{
                if(markTextureId!=-1){
                    GLES20.glDeleteTextures(1,new int[]{markTextureId},0);
                }
            }
        }
    });
    return this;
}
 
開發者ID:aiyaapp,項目名稱:AAVT,代碼行數:22,代碼來源:WaterMarkFilter.java

示例3: loadGLTexture

import android.opengl.GLUtils; //導入依賴的package包/類
/**
 * Loads the texture.
 *
 * @param gl
 */
public void loadGLTexture(GL10 gl) {
    if (mBitmap == null) {
        System.out.println("Texture not loaded yet");
        return;
    }
    int[] textures = new int[1];
    gl.glGenTextures(1, textures, 0);
    mTextureId = textures[0];

    gl.glBindTexture(GL10.GL_TEXTURE_2D, mTextureId);

    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);

    gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_WRAP_S, GL10.GL_CLAMP_TO_EDGE);
    gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_WRAP_T, GL10.GL_REPEAT);

    GLUtils.texImage2D(GL10.GL_TEXTURE_2D, 0, mBitmap, 0);
    gl.glBindTexture(GL10.GL_TEXTURE_2D, 0);

    // release the bitmap
    mBitmap.recycle();

    loaded();
}
 
開發者ID:ondramisar,項目名稱:AdronEngine,代碼行數:31,代碼來源:Texture.java

示例4: attachBitmapToTexture

import android.opengl.GLUtils; //導入依賴的package包/類
private void attachBitmapToTexture(int textureId, Bitmap textureBitmap) {
    GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, textureId);

    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.glTexParameterf(GLES20.GL_TEXTURE_2D,
            GLES20.GL_TEXTURE_WRAP_S, GLES20.GL_CLAMP_TO_EDGE);

    GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D,
            GLES20.GL_TEXTURE_WRAP_T, GLES20.GL_CLAMP_TO_EDGE);

    GLUtils.texImage2D(GLES20.GL_TEXTURE_2D, 0, textureBitmap, 0);
}
 
開發者ID:PacktPublishing,項目名稱:Building-Android-UIs-with-Custom-Views,代碼行數:18,代碼來源:GLDrawer.java

示例5: loadTexture

import android.opengl.GLUtils; //導入依賴的package包/類
public static int loadTexture(final Bitmap img, final int usedTexId, boolean recyled) {
if(img == null)
	return NO_TEXTURE; 
      int textures[] = new int[1];
      if (usedTexId == NO_TEXTURE) {
          GLES20.glGenTextures(1, textures, 0);
          GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, textures[0]);
          GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D,
                  GLES20.GL_TEXTURE_MAG_FILTER, GLES20.GL_LINEAR);
          GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D,
                  GLES20.GL_TEXTURE_MIN_FILTER, GLES20.GL_LINEAR);
          GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D,
                  GLES20.GL_TEXTURE_WRAP_S, GLES20.GL_CLAMP_TO_EDGE);
          GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D,
                  GLES20.GL_TEXTURE_WRAP_T, GLES20.GL_CLAMP_TO_EDGE);

          GLUtils.texImage2D(GLES20.GL_TEXTURE_2D, 0, img, 0);
      } else {
          GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, usedTexId);
          GLUtils.texSubImage2D(GLES20.GL_TEXTURE_2D, 0, 0, 0, img);
          textures[0] = usedTexId;
      }
      if(recyled)
      	img.recycle();
      return textures[0];
  }
 
開發者ID:smartbeng,項目名稱:PaoMovie,代碼行數:27,代碼來源:OpenGLUtils.java

示例6: initGL

import android.opengl.GLUtils; //導入依賴的package包/類
private void initGL()
{
    egl = (EGL10) EGLContext.getEGL();
    eglDisplay = egl.eglGetDisplay(EGL10.EGL_DEFAULT_DISPLAY);

    int[] version = new int[2];
    egl.eglInitialize(eglDisplay, version);

    EGLConfig eglConfig = chooseEglConfig();
    eglContext = createContext(egl, eglDisplay, eglConfig);

    eglSurface = egl.eglCreateWindowSurface(eglDisplay, eglConfig, texture, null);

    if (eglSurface == null || eglSurface == EGL10.EGL_NO_SURFACE)
    {
        throw new RuntimeException("GL Error: " + GLUtils.getEGLErrorString(egl.eglGetError()));
    }

    if (!egl.eglMakeCurrent(eglDisplay, eglSurface, eglSurface, eglContext))
    {
        throw new RuntimeException("GL Make current error: " + GLUtils.getEGLErrorString(egl.eglGetError()));
    }
}
 
開發者ID:archos-sa,項目名稱:aos-Video,代碼行數:24,代碼來源:TextureSurfaceRenderer.java

示例7: chooseEglConfig

import android.opengl.GLUtils; //導入依賴的package包/類
private EGLConfig chooseEglConfig()
{
    int[] configsCount = new int[1];
    EGLConfig[] configs = new EGLConfig[1];
    int[] configSpec = getConfig();

    if (!egl.eglChooseConfig(eglDisplay, configSpec, configs, 1, configsCount))
    {
        throw new IllegalArgumentException("Failed to choose config: " + GLUtils.getEGLErrorString(egl.eglGetError()));
    }
    else if (configsCount[0] > 0)
    {
        return configs[0];
    }

    return null;
}
 
開發者ID:archos-sa,項目名稱:aos-Video,代碼行數:18,代碼來源:TextureSurfaceRenderer.java

示例8: loadTextures

import android.opengl.GLUtils; //導入依賴的package包/類
private void loadTextures() {
    // Generate textures
    GLES20.glGenTextures(2, mTextures, 0);

    // Load input bitmap
    Bitmap bitmap = BitmapFactory.decodeResource(getResources(),
            R.drawable.puppy);
    mImageWidth = bitmap.getWidth();
    mImageHeight = bitmap.getHeight();
    mTexRenderer.updateTextureSize(mImageWidth, mImageHeight);

    // Upload to texture
    GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, mTextures[0]);
    GLUtils.texImage2D(GLES20.GL_TEXTURE_2D, 0, bitmap, 0);

    // Set texture parameters
    GLToolbox.initTexParams();
}
 
開發者ID:sdrausty,項目名稱:buildAPKsSamples,代碼行數:19,代碼來源:HelloEffects.java

示例9: load

import android.opengl.GLUtils; //導入依賴的package包/類
public int[] load() {
  if (textStreamObject != null) {
    textureId = new int[textStreamObject.getNumFrames()];
    GlUtil.createTextures(textStreamObject.getNumFrames(), textureId, 0);
    GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, textureId[0]);
    GLUtils.texImage2D(GLES20.GL_TEXTURE_2D, 0, textStreamObject.getImageBitmap(), 0);
    textStreamObject.recycle();
  } else if (imageStreamObject != null) {
    textureId = new int[imageStreamObject.getNumFrames()];
    GlUtil.createTextures(imageStreamObject.getNumFrames(), textureId, 0);
    GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, textureId[0]);
    GLUtils.texImage2D(GLES20.GL_TEXTURE_2D, 0, imageStreamObject.getImageBitmap(), 0);
    imageStreamObject.recycle();
  } else if (gifStreamObject != null) {
    textureId = new int[gifStreamObject.getNumFrames()];
    GlUtil.createTextures(gifStreamObject.getNumFrames(), textureId, 0);
    for (int i = 0; i < gifStreamObject.getNumFrames(); i++) {
      GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, textureId[i]);
      GLUtils.texImage2D(GLES20.GL_TEXTURE_2D, 0, gifStreamObject.getGifBitmaps()[i], 0);
    }
    gifStreamObject.recycle();
  } else {
    textureId = new int[] { -1 };
  }
  return textureId;
}
 
開發者ID:pedroSG94,項目名稱:rtmp-rtsp-stream-client-java,代碼行數:27,代碼來源:TextureLoader.java

示例10: createTexture

import android.opengl.GLUtils; //導入依賴的package包/類
/**
 * @param textureTarget Texture類型。
 * 1. 相機用 GLES11Ext.GL_TEXTURE_EXTERNAL_OES
 * 2. 圖片用GLES20.GL_TEXTURE_2D
 * @param minFilter 縮小過濾類型 (1.GL_NEAREST ; 2.GL_LINEAR)
 * @param magFilter 放大過濾類型
 * @param wrapS X方向邊緣環繞
 * @param wrapT Y方向邊緣環繞
 * @return 返回創建的 Texture ID
 */
public static int createTexture(int textureTarget, @Nullable Bitmap bitmap, int minFilter,
        int magFilter, int wrapS, int wrapT) {
    int[] textureHandle = new int[1];

    GLES20.glGenTextures(1, textureHandle, 0);
    GlUtil.checkGlError("glGenTextures");
    GLES20.glBindTexture(textureTarget, textureHandle[0]);
    GlUtil.checkGlError("glBindTexture " + textureHandle[0]);
    GLES20.glTexParameterf(textureTarget, GLES20.GL_TEXTURE_MIN_FILTER, minFilter);
    GLES20.glTexParameterf(textureTarget, GLES20.GL_TEXTURE_MAG_FILTER, magFilter); //線性插值
    GLES20.glTexParameteri(textureTarget, GLES20.GL_TEXTURE_WRAP_S, wrapS);
    GLES20.glTexParameteri(textureTarget, GLES20.GL_TEXTURE_WRAP_T, wrapT);

    if (bitmap != null) {
        GLUtils.texImage2D(GLES20.GL_TEXTURE_2D, 0, bitmap, 0);
    }

    GlUtil.checkGlError("glTexParameter");
    return textureHandle[0];
}
 
開發者ID:hoanganhtuan95ptit,項目名稱:EditPhoto,代碼行數:31,代碼來源:GlUtil.java

示例11: bindBitmap

import android.opengl.GLUtils; //導入依賴的package包/類
/**
 * 將bitmap綁定為紋理
 *
 * @param bitmap
 * @return
 */
public static int bindBitmap(Bitmap bitmap) {
    int[] tex = new int[1];
    GLES20.glGenTextures(1, tex, 0);
    GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, tex[0]);

    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.glTexParameterf(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_WRAP_S,
            GLES20.GL_CLAMP_TO_EDGE);
    GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_WRAP_T,
            GLES20.GL_CLAMP_TO_EDGE);

    GLUtils.texImage2D(GLES20.GL_TEXTURE_2D, 0, bitmap, 0);
    return tex[0];
}
 
開發者ID:uestccokey,項目名稱:EZFilter,代碼行數:24,代碼來源:BitmapUtil.java

示例12: loadTexture

import android.opengl.GLUtils; //導入依賴的package包/類
public static int loadTexture(final Bitmap img, final int usedTexId, final boolean recycle) {
    int textures[] = new int[1];
    if (usedTexId == NO_TEXTURE) {
        GLES20.glGenTextures(1, textures, 0);
        GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, textures[0]);
        GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D,
                GLES20.GL_TEXTURE_MAG_FILTER, GLES20.GL_LINEAR);
        GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D,
                GLES20.GL_TEXTURE_MIN_FILTER, GLES20.GL_LINEAR);
        GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D,
                GLES20.GL_TEXTURE_WRAP_S, GLES20.GL_CLAMP_TO_EDGE);
        GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D,
                GLES20.GL_TEXTURE_WRAP_T, GLES20.GL_CLAMP_TO_EDGE);

        GLUtils.texImage2D(GLES20.GL_TEXTURE_2D, 0, img, 0);
    } else {
        GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, usedTexId);
        GLUtils.texSubImage2D(GLES20.GL_TEXTURE_2D, 0, 0, 0, img);
        textures[0] = usedTexId;
    }
    if (recycle) {
        img.recycle();
    }
    return textures[0];
}
 
開發者ID:vipycm,項目名稱:mao-android,代碼行數:26,代碼來源:OpenGlUtils.java

示例13: loadTexture

import android.opengl.GLUtils; //導入依賴的package包/類
public static int loadTexture(Bitmap bitmap, boolean recycle) {
    if (bitmap == null) {
        return 0;
    }
    int textures[] = new int[1];
    GLES20.glGenTextures(1, textures, 0);
    GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, textures[0]);
    GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_MAG_FILTER, GLES20.GL_LINEAR);
    GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_MIN_FILTER, GLES20.GL_LINEAR);
    GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_WRAP_S, GLES20.GL_CLAMP_TO_EDGE);
    GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_WRAP_T, GLES20.GL_CLAMP_TO_EDGE);
    GLUtils.texImage2D(GLES20.GL_TEXTURE_2D, 0, bitmap, 0);
    if (recycle) {
        bitmap.recycle();
    }
    return textures[0];
}
 
開發者ID:vipycm,項目名稱:mao-android,代碼行數:18,代碼來源:OpenGLUtils.java

示例14: loadTexture

import android.opengl.GLUtils; //導入依賴的package包/類
@Override
public int[] loadTexture(Vfs vfs, String filePath) {
    InputStream inputStream = vfs.getInputStream(filePath);
    if (inputStream == null) {
        throw new GLTextureNotFoundException(filePath);
    }
    Bitmap bitmap = BitmapFactory.decodeStream(inputStream);
    int width = bitmap.getWidth();
    int height = bitmap.getHeight();
    if (Context.isUsePack() && (!isPOT(width) || !isPOT(height))) {
        throw new RuntimeException("Texture size is not power of two: " + filePath);
    }
    GLUtils.texImage2D(GL_TEXTURE_2D, 0, bitmap, 0);
    bitmap.recycle();
    return new int[]{width, height};
}
 
開發者ID:dmitrykolesnikovich,項目名稱:featurea,代碼行數:17,代碼來源:OpenGLImpl.java

示例15: run

import android.opengl.GLUtils; //導入依賴的package包/類
public void run() {
    Bitmap bitmap;
    try {
        bitmap = captureView(view);
    }
    catch (Exception e) {
        return;
    }
    if (yflip) {
        Matrix matrix = new Matrix();
        matrix.postScale(1, -1);
        boolean hasAlpha = bitmap.hasAlpha();
        bitmap = Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(), bitmap.getHeight(), matrix, true);
        bitmap.setHasAlpha(hasAlpha);
    }
    int[] textures = new int[1];
    glGenTextures(1, textures, 0);
    glBindTexture(GL_TEXTURE_2D, textures[0]);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
    GLUtils.texImage2D(GL_TEXTURE_2D, 0, bitmap, 0);
    this.attachTexture(textures[0]);
}
 
開發者ID:gre,項目名稱:react-native-webgl-view-shot,代碼行數:24,代碼來源:RNWebGLTextureView.java


注:本文中的android.opengl.GLUtils類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。