当前位置: 首页>>代码示例>>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;未经允许,请勿转载。