当前位置: 首页>>代码示例>>Java>>正文


Java GLUtils.texImage2D方法代码示例

本文整理汇总了Java中android.opengl.GLUtils.texImage2D方法的典型用法代码示例。如果您正苦于以下问题:Java GLUtils.texImage2D方法的具体用法?Java GLUtils.texImage2D怎么用?Java GLUtils.texImage2D使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.opengl.GLUtils的用法示例。


在下文中一共展示了GLUtils.texImage2D方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: 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

示例2: 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:TobiasLee,项目名称:FilterPlayer,代码行数:27,代码来源:OpenGlUtils.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: createBmpTexture

import android.opengl.GLUtils; //导入方法依赖的package包/类
public int createBmpTexture(GL10 gl, Bitmap bitmap)	{
    int nNextAvailableId = mtextureMgr.getFirstUninitTextureId();
    if (nNextAvailableId >= 0)	{	// -1 means no available texture id.
     //...and bind it to our array
     gl.glBindTexture(GL10.GL_TEXTURE_2D, mtextureMgr.mtextures[nNextAvailableId]);
	
     //Create Nearest Filtered Texture
     gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_MIN_FILTER, GL10.GL_NEAREST);
     gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_MAG_FILTER, GL10.GL_LINEAR);
	
     //Different possible texture parameters, e.g. GL10.GL_CLAMP_TO_EDGE
     //gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_WRAP_S, GL10.GL_REPEAT);
     //gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_WRAP_T, GL10.GL_REPEAT);
	
     //Use the Android GLUtils to specify a two-dimensional texture image from our bitmap
     GLUtils.texImage2D(GL10.GL_TEXTURE_2D, 0, bitmap, 0);
     mtextureMgr.markTextureIdUsed(nNextAvailableId);
    }
    return nNextAvailableId;
}
 
开发者ID:woshiwpa,项目名称:SmartMath,代码行数:21,代码来源:OGLChart.java

示例5: 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

示例6: 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

示例7: 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

示例8: setPicture

import android.opengl.GLUtils; //导入方法依赖的package包/类
public void setPicture(Bitmap bitmap) {
    int width = bitmap.getWidth();
    int height = bitmap.getHeight();
    float widthFactor, heightFactor;
    if (width > height) {
        widthFactor = width / (float) height;
        heightFactor = 1;
    } else { // height >= width
        widthFactor = 1;
        heightFactor = height / (float) width;
    }
    setVertexData(widthFactor, heightFactor);

    GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, mGLTexture[0]);
    GLUtils.texImage2D(GLES20.GL_TEXTURE_2D, 0, bitmap, 0);
    GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, 0);
}
 
开发者ID:chartsai,项目名称:GLESDemo,代码行数:18,代码来源:PixelatedTexture.java

示例9: textureInThread

import android.opengl.GLUtils; //导入方法依赖的package包/类
private void textureInThread(int textureId, MD360Program program, Bitmap bitmap) {
    notNull(bitmap, "bitmap can't be null!");

    if (isEmpty(textureId)) return;

    GLES20.glActiveTexture(GLES20.GL_TEXTURE0);
    glCheck("MD360BitmapTexture glActiveTexture");

    // Bind to the texture in OpenGL
    GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, textureId);
    glCheck("MD360BitmapTexture glBindTexture");

    // Set filtering
    GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_MIN_FILTER, GLES20.GL_NEAREST);
    GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_MAG_FILTER, GLES20.GL_NEAREST);
    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);

    // Load the bitmap into the bound texture.
    GLUtils.texImage2D(GLES20.GL_TEXTURE_2D, 0, bitmap, 0);
    glCheck("MD360BitmapTexture texImage2D");

    GLES20.glUniform1i(program.getTextureUniformHandle(), 0);
    glCheck("MD360BitmapTexture textureInThread");
}
 
开发者ID:ashqal,项目名称:MD360Player4Android,代码行数:26,代码来源:MD360BitmapTexture.java

示例10: loadBitmap

import android.opengl.GLUtils; //导入方法依赖的package包/类
/** Bitmapからテクスチャを読み込む */
public void loadBitmap(final Bitmap bitmap) {
	final int width = bitmap.getWidth();
	final int height = bitmap.getHeight();
	if ((width > mTexWidth) || (height > mTexHeight)) {
		mWidth = width;
		mHeight = height;
		releaseFrameBuffer();
		createFrameBuffer(width, height);
	}
	GLES20.glBindTexture(TEX_TARGET, mFBOTextureName);
	GLUtils.texImage2D(TEX_TARGET, 0, bitmap, 0);
	GLES20.glBindTexture(TEX_TARGET, 0);
	// initialize texture matrix
	Matrix.setIdentityM(mTexMatrix, 0);
	mTexMatrix[0] = width / (float)mTexWidth;
	mTexMatrix[5] = height / (float)mTexHeight;
}
 
开发者ID:saki4510t,项目名称:libcommon,代码行数:19,代码来源:TextureOffscreen.java

示例11: textureInThread

import android.opengl.GLUtils; //导入方法依赖的package包/类
private void textureInThread(int textureId, MD360Program program, Bitmap bitmap, int face) {
    notNull(bitmap, "bitmap can't be null!");

    if (isEmpty(textureId)) return;

    GLES20.glActiveTexture(GLES20.GL_TEXTURE0);
    glCheck("MD360BitmapTexture glActiveTexture");

    // Bind to the texture in OpenGL
    GLES20.glBindTexture(GLES20.GL_TEXTURE_CUBE_MAP, textureId);
    glCheck("MD360BitmapTexture glBindTexture");

    // Set filtering
    GLES20.glTexParameteri(GLES20.GL_TEXTURE_CUBE_MAP, GLES20.GL_TEXTURE_MAG_FILTER, GLES20.GL_LINEAR);
    GLES20.glTexParameteri(GLES20.GL_TEXTURE_CUBE_MAP, GLES20.GL_TEXTURE_MIN_FILTER, GLES20.GL_LINEAR);
    GLES20.glTexParameteri(GLES20.GL_TEXTURE_CUBE_MAP, GLES20.GL_TEXTURE_WRAP_S, GLES20.GL_CLAMP_TO_EDGE);
    GLES20.glTexParameteri(GLES20.GL_TEXTURE_CUBE_MAP, GLES20.GL_TEXTURE_WRAP_T, GLES20.GL_CLAMP_TO_EDGE);

    // Load the bitmap into the bound texture.
    GLUtils.texImage2D(CUBE_TARGETS[face], 0, bitmap, 0);
    glCheck("MD360BitmapTexture texImage2D");

    // Set shader texture variable to texture 0
    GLES20.glUniform1i(program.getTextureUniformHandle(), 0);
    glCheck("MD360BitmapTexture textureInThread");
}
 
开发者ID:ashqal,项目名称:MD360Player4Android,代码行数:27,代码来源:MD360CubemapTexture.java

示例12: uploadTextureAndReturnId

import android.opengl.GLUtils; //导入方法依赖的package包/类
/**
 * Used by TextureManager
 */
int uploadTextureAndReturnId(Bitmap $bitmap, boolean $generateMipMap) /*package-private*/
{
	int glTextureId;
	
	int[] a = new int[1];
	_gl.glGenTextures(1, a, 0); // create a 'texture name' and put it in array element 0
	glTextureId = a[0];
	_gl.glBindTexture(GL10.GL_TEXTURE_2D, glTextureId);
	
	if($generateMipMap && _gl instanceof GL11) {
		_gl.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_GENERATE_MIPMAP, GL11.GL_TRUE);
	} else {
		_gl.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_GENERATE_MIPMAP, GL11.GL_FALSE);
	}

	// 'upload' to gpu
	GLUtils.texImage2D(GL10.GL_TEXTURE_2D, 0, $bitmap, 0);
	
	return glTextureId;
}
 
开发者ID:davrempe,项目名称:cardboardAR-lib,代码行数:24,代码来源:MyRenderer.java

示例13: loadTexture

import android.opengl.GLUtils; //导入方法依赖的package包/类
public static int loadTexture(final Context context, final int resourceId)
{
	final int[] textureHandle = new int[1];
	
	GLES20.glGenTextures(1, textureHandle, 0);
	
	if (textureHandle[0] != 0)
	{
		final BitmapFactory.Options options = new BitmapFactory.Options();
		options.inScaled = false;	// No pre-scaling

		// Read in the resource
		final Bitmap bitmap = BitmapFactory.decodeResource(context.getResources(), resourceId, options);
					
		// Bind to the texture in OpenGL
		GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, textureHandle[0]);
		
		// Set filtering
		GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_MIN_FILTER, GLES20.GL_NEAREST);
		GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_MAG_FILTER, GLES20.GL_NEAREST);
		
		// Load the bitmap into the bound texture.
		GLUtils.texImage2D(GLES20.GL_TEXTURE_2D, 0, bitmap, 0);
		
		// Recycle the bitmap, since its data has been loaded into OpenGL.
		bitmap.recycle();						
	}
	
	if (textureHandle[0] == 0)
	{
		throw new RuntimeException("Error loading texture.");
	}
	
	return textureHandle[0];
}
 
开发者ID:biezhihua,项目名称:Android_OpenGL_Demo,代码行数:36,代码来源:TextureHelper.java

示例14: updateTexture

import android.opengl.GLUtils; //导入方法依赖的package包/类
public static void updateTexture(int texture, Bitmap img, boolean recycle) {
    GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, texture);
    GLUtils.texImage2D(GLES20.GL_TEXTURE_2D, 0, img, 0);
    GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, 0);

    if (recycle) {
        img.recycle();
    }
}
 
开发者ID:lzmlsfe,项目名称:19porn,代码行数:10,代码来源:OpenGlUtils.java

示例15: loadTexture

import android.opengl.GLUtils; //导入方法依赖的package包/类
private int loadTexture(int resId) {
    final int[] textureIds = new int[1];
    GLES20.glGenTextures(1, textureIds, 0);

    if (textureIds[0] == 0) return -1;

    // do not scale the bitmap depending on screen density
    final BitmapFactory.Options options = new BitmapFactory.Options();
    options.inScaled = false;

    final Bitmap textureBitmap = BitmapFactory.decodeResource(getResources(), resId, options);
    GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, textureIds[0]);

    GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D,
            GLES20.GL_TEXTURE_MIN_FILTER, GLES20.GL_NEAREST);

    GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D,
            GLES20.GL_TEXTURE_MAG_FILTER, GLES20.GL_NEAREST);

    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);
    textureBitmap.recycle();

    return textureIds[0];
}
 
开发者ID:PacktPublishing,项目名称:Building-Android-UIs-with-Custom-Views,代码行数:31,代码来源:GLDrawer.java


注:本文中的android.opengl.GLUtils.texImage2D方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。