本文整理匯總了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];
}
示例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];
}
示例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();
}
示例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;
}
示例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);
}
示例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]);
}
示例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;
}
示例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);
}
示例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");
}
示例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;
}
示例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");
}
示例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;
}
示例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];
}
示例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();
}
}
示例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];
}