本文整理匯總了Java中android.opengl.GLUtils.texSubImage2D方法的典型用法代碼示例。如果您正苦於以下問題:Java GLUtils.texSubImage2D方法的具體用法?Java GLUtils.texSubImage2D怎麽用?Java GLUtils.texSubImage2D使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.opengl.GLUtils
的用法示例。
在下文中一共展示了GLUtils.texSubImage2D方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: 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];
}
示例2: 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];
}
示例3: 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];
}
示例4: loadTexture
import android.opengl.GLUtils; //導入方法依賴的package包/類
public static int loadTexture(Bitmap img, int usedTexId, boolean recycle) {
int[] textures = new int[1];
if(usedTexId == -1) {
GLES20.glGenTextures(1, textures, 0);
GLES20.glBindTexture(3553, textures[0]);
GLES20.glTexParameterf(3553, 10240, 9729.0F);
GLES20.glTexParameterf(3553, 10241, 9729.0F);
GLES20.glTexParameterf(3553, 10242, 33071.0F);
GLES20.glTexParameterf(3553, 10243, 33071.0F);
GLUtils.texImage2D(3553, 0, img, 0);
} else {
GLES20.glBindTexture(3553, usedTexId);
GLUtils.texSubImage2D(3553, 0, 0, 0, img);
textures[0] = usedTexId;
}
if(recycle) {
img.recycle();
}
return textures[0];
}
示例5: 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();
}
GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, 0);
return textures[0];
}
示例6: loadTexture
import android.opengl.GLUtils; //導入方法依賴的package包/類
public static int loadTexture(Bitmap paramBitmap, int paramInt, boolean paramBoolean)
{
int[] arrayOfInt = new int[1];
if (paramInt == -1)
{
GLES20.glGenTextures(1, arrayOfInt, 0);
GLES20.glBindTexture(3553, arrayOfInt[0]);
GLES20.glTexParameterf(3553, 10240, 9729.0F);
GLES20.glTexParameterf(3553, 10241, 9729.0F);
GLES20.glTexParameterf(3553, 10242, 33071.0F);
GLES20.glTexParameterf(3553, 10243, 33071.0F);
GLUtils.texImage2D(3553, 0, paramBitmap, 0);
}
else
{
GLES20.glBindTexture(3553, paramInt);
GLUtils.texSubImage2D(3553, 0, 0, 0, paramBitmap);
arrayOfInt[0] = paramInt;
}
if (paramBoolean) {
paramBitmap.recycle();
}
return arrayOfInt[0];
}
示例7: loadTextureWithOldTexId
import android.opengl.GLUtils; //導入方法依賴的package包/類
public static int loadTextureWithOldTexId(final Bitmap img, final int usedTexId) {
int textures[] = new int[1];
if (usedTexId == GLEtc.NO_TEXTURE) {
return getTextureFromBitmap(img,null);
} else {
GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, usedTexId);
GLUtils.texSubImage2D(GLES20.GL_TEXTURE_2D, 0, 0, 0, img);
textures[0] = usedTexId;
}
return textures[0];
}
示例8: texSubImage2D
import android.opengl.GLUtils; //導入方法依賴的package包/類
@Override
public void texSubImage2D(BasicTexture texture, int xOffset, int yOffset, Bitmap bitmap,
int format, int type) {
GLES20.glBindTexture(GL_TARGET, texture.getId());
checkError();
GLUtils.texSubImage2D(GL_TARGET, 0, xOffset, yOffset, bitmap, format, type);
}
示例9: texSubImage2D
import android.opengl.GLUtils; //導入方法依賴的package包/類
@Override
public void texSubImage2D(BasicTexture texture, int xOffset, int yOffset, Bitmap bitmap,
int format, int type) {
int target = texture.getTarget();
GLES20.glBindTexture(target, texture.getId());
checkError();
GLUtils.texSubImage2D(target, 0, xOffset, yOffset, bitmap, format, type);
}
示例10: loadTexture
import android.opengl.GLUtils; //導入方法依賴的package包/類
public static int loadTexture(final @NonNull Bitmap image, final int usedTexId, final boolean recycle)
{
if(image == null)
throw new NullPointerException("loadTexture can't be used with a null Bitmap");
if(image.isRecycled())
throw new IllegalArgumentException("bitmap is recycled");
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, image, 0);
}
else
{
GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, usedTexId);
GLUtils.texSubImage2D(GLES20.GL_TEXTURE_2D, 0, 0, 0, image);
textures[0] = usedTexId;
}
if(recycle)
image.recycle();
return textures[0];
}
示例11: loadTexture2
import android.opengl.GLUtils; //導入方法依賴的package包/類
public static int loadTexture2(final Bitmap bitmap) {
final int[] textureHandle = new int[1];
glGenTextures(1, textureHandle, 0);
if (textureHandle[0] != 0) {
// Bind to the texture in OpenGL
glBindTexture(GL_TEXTURE_2D, textureHandle[0]);
// Set filtering
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
// Load the bitmap into the bound texture.
GLUtils.texSubImage2D(GL_TEXTURE_2D, 0, 0, 0, bitmap);
// Buffer byteBuffer = ByteBuffer.allocate(bitmap.getByteCount());
// bitmap.copyPixelsToBuffer(byteBuffer);
// glTexImage2D(GL_TEXTURE_2D, 0, GLES20.GL_RGB, bitmap.getWidth(), bitmap.getHeight(),
// 0, GLES20.GL_RGB, GLES20.GL_UNSIGNED_BYTE, byteBuffer);
// Recycle the bitmap, since its data has been loaded into OpenGL.
bitmap.recycle();
} else {
throw new RuntimeException("Error loading texture.");
}
return textureHandle[0];
}
示例12: texSubImage2D
import android.opengl.GLUtils; //導入方法依賴的package包/類
@Override
public void texSubImage2D(BasicTexture texture, int xOffset, int yOffset, Bitmap bitmap,
int format, int type) {
int target = texture.getTarget();
GLES20.glBindTexture(target, texture.getId());
checkError();
GLUtils.texSubImage2D(target, 0, xOffset, yOffset, bitmap, format, type);
}
示例13: replace
import android.opengl.GLUtils; //導入方法依賴的package包/類
void replace() throws TextureException
{
if(mCompressedTexture != null)
{
mCompressedTexture.replace();
setWidth(mCompressedTexture.getWidth());
setHeight(mCompressedTexture.getHeight());
setTextureId(mCompressedTexture.getTextureId());
setUniformHandle(mCompressedTexture.getUniformHandle());
return;
}
if (mBitmap == null && (mByteBuffer == null || mByteBuffer.limit() == 0))
throw new TextureException("Texture could not be replaced because there is no Bitmap or ByteBuffer set.");
GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, mTextureId);
if (mBitmap != null)
{
int bitmapFormat = mBitmap.getConfig() == Config.ARGB_8888 ? GLES20.GL_RGBA : GLES20.GL_RGB;
if(mBitmap.getWidth() != mWidth || mBitmap.getHeight() != mHeight)
throw new TextureException("Texture could not be updated because the texture size is different from the original.");
if(bitmapFormat != mBitmapFormat)
throw new TextureException("Texture could not be updated because the bitmap format is different from the original");
GLUtils.texSubImage2D(GLES20.GL_TEXTURE_2D, 0, 0, 0, mBitmap, mBitmapFormat, GLES20.GL_UNSIGNED_BYTE);
} else if(mByteBuffer != null) {
if (mWidth == 0 || mHeight == 0 || mBitmapFormat == 0)
throw new TextureException(
"Could not update ByteBuffer texture. One or more of the following properties haven't been set: width, height or bitmap format");
GLES20.glTexSubImage2D(GLES20.GL_TEXTURE_2D, 0, 0, 0, mWidth, mHeight, mBitmapFormat, GLES20.GL_UNSIGNED_BYTE, mByteBuffer);
}
if (mMipmap)
GLES20.glGenerateMipmap(GLES20.GL_TEXTURE_2D);
GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, 0);
}
示例14: setFrameRate
import android.opengl.GLUtils; //導入方法依賴的package包/類
public void setFrameRate(int fps) {
mBitmap.eraseColor(0x00000000);
String text = createFpsText(fps);
mCanvas.drawText(text, mBitmapWidth / 2, mBitmapHeight - mTextPaint.descent(), mTextPaint);
GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, mTextures[0]);
GLUtils.texSubImage2D(GLES20.GL_TEXTURE_2D, 0, 0, 0, mBitmap);
}
示例15: setupTextures
import android.opengl.GLUtils; //導入方法依賴的package包/類
private void setupTextures(TextureAtlas atlas) {
int[] names = new int[1];
glGenTextures(1, names, 0);
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, names[0]);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
GLUtils.texImage2D(GL_TEXTURE_2D, 0, Bitmap.createBitmap(atlas.getWidth(), atlas.getHeight(),
Bitmap.Config.ARGB_8888), 0);
List<TextureAtlas.Region> regions = atlas.getRegions();
textureCoordsCacheArray = new float[regions.size() * 8];
final int k = 8;
float atlasWidth = atlas.getWidth();
float atlasHeight = atlas.getHeight();
for (int i = 0; i < regions.size(); i++) {
TextureAtlas.Region r = regions.get(i);
GLUtils.texSubImage2D(GL_TEXTURE_2D, 0, r.x, r.y, r.bitmap);
float x0 = r.x / atlasWidth;
float y0 = r.y / atlasHeight;
float x1 = x0 + r.bitmap.getWidth() / atlasWidth;
float y1 = y0 + r.bitmap.getHeight() / atlasHeight;
List<Float> coords = Arrays.asList(x0, y0, x0, y1, x1, y1, x1, y0);
if (r.cwRotated) {
Collections.rotate(coords, 2);
}
for (int j = 0; j < coords.size(); j++) {
textureCoordsCacheArray[i * k + j] = coords.get(j);
}
}
}