本文整理汇总了Java中android.opengl.ETC1Util.ETC1Texture方法的典型用法代码示例。如果您正苦于以下问题:Java ETC1Util.ETC1Texture方法的具体用法?Java ETC1Util.ETC1Texture怎么用?Java ETC1Util.ETC1Texture使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.opengl.ETC1Util
的用法示例。
在下文中一共展示了ETC1Util.ETC1Texture方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setResourceIds
import android.opengl.ETC1Util; //导入方法依赖的package包/类
public void setResourceIds(int[] resourceIds) {
ByteBuffer[] mipmapChain = new ByteBuffer[resourceIds.length];
Resources resources = TextureManager.getInstance().getContext().getResources();
int mip_0_width = 1, mip_0_height = 1;
try {
for (int i = 0, length = resourceIds.length; i < length; i++) {
ETC1Util.ETC1Texture texture = ETC1Util.createTexture(resources.openRawResource(resourceIds[i]));
mipmapChain[i] = texture.getData();
if (i == 0) {
mip_0_width = texture.getWidth();
mip_0_height = texture.getHeight();
}
}
setWidth(mip_0_width);
setHeight(mip_0_height);
setCompressionFormat(ETC1.ETC1_RGB8_OES);
} catch (IOException e) {
RajLog.e(e.getMessage());
e.printStackTrace();
}
mByteBuffers = mipmapChain;
}
示例2: setInputStream
import android.opengl.ETC1Util; //导入方法依赖的package包/类
public void setInputStream(InputStream compressedTexture, Bitmap fallbackTexture) {
ETC1Util.ETC1Texture texture = null;
try {
texture = ETC1Util.createTexture(compressedTexture);
} catch (IOException e) {
RajLog.e("addEtc1Texture: " + e.getMessage());
} finally {
if (texture == null) {
setBitmap(fallbackTexture);
if (RajLog.isDebugEnabled())
RajLog.d("Falling back to uncompressed texture");
} else {
setByteBuffer(texture.getData());
setWidth(texture.getWidth());
setHeight(texture.getHeight());
if (RajLog.isDebugEnabled())
RajLog.d("ETC1 texture load successful");
}
}
}
示例3: load
import android.opengl.ETC1Util; //导入方法依赖的package包/类
public void load(GL10 gl) {
int width = 128;
int height = 128;
Buffer image = createImage(width, height);
ETC1Util.ETC1Texture etc1Texture = ETC1Util.compressTexture(image, width, height, 3, 3 * width);
if (USE_STREAM_IO) {
// Test the ETC1Util APIs for reading and writing compressed textures to I/O streams.
try {
ByteArrayOutputStream bos = new ByteArrayOutputStream();
ETC1Util.writeTexture(etc1Texture, bos);
ByteArrayInputStream bis = new ByteArrayInputStream(bos.toByteArray());
ETC1Util.loadTexture(GLES10.GL_TEXTURE_2D, 0, 0,
GLES10.GL_RGB, GLES10.GL_UNSIGNED_SHORT_5_6_5, bis);
} catch (IOException e) {
Log.w(TAG, "Could not load texture: " + e);
}
} else {
ETC1Util.loadTexture(GLES10.GL_TEXTURE_2D, 0, 0,
GLES10.GL_RGB, GLES10.GL_UNSIGNED_SHORT_5_6_5, etc1Texture);
}
}
示例4: addEtc1Texture
import android.opengl.ETC1Util; //导入方法依赖的package包/类
public TextureInfo addEtc1Texture(InputStream compressedTex, Bitmap fallbackTex, TextureType textureType) {
ETC1Util.ETC1Texture texture = null;
TextureInfo textureInfo = null;
try {
texture = ETC1Util.createTexture(compressedTex);
} catch (IOException e) {
Log.e("addEtc1Texture", e.getMessage());
} finally {
if (texture == null) {
textureInfo = addTexture(fallbackTex);
Log.d("ETC1", "Falling back to uncompressed texture");
} else {
textureInfo = addEtc1Texture(texture.getData(), texture.getWidth(), texture.getHeight(), textureType);
Log.d("ETC1", "ETC1 texture load successful");
}
}
return textureInfo;
}
示例5: setResourceIds
import android.opengl.ETC1Util; //导入方法依赖的package包/类
public void setResourceIds(int[] resourceIds)
{
ByteBuffer[] mipmapChain = new ByteBuffer[resourceIds.length];
Resources resources = TextureManager.getInstance().getContext().getResources();
int mip_0_width = 1, mip_0_height = 1;
try {
for (int i = 0, length = resourceIds.length; i < length; i++) {
ETC1Util.ETC1Texture texture = ETC1Util.createTexture(resources.openRawResource(resourceIds[i]));
mipmapChain[i] = texture.getData();
if (i == 0) {
mip_0_width = texture.getWidth();
mip_0_height = texture.getHeight();
}
}
setWidth(mip_0_width);
setHeight(mip_0_height);
setCompressionFormat(ETC1.ETC1_RGB8_OES);
} catch (IOException e) {
RajLog.e(e.getMessage());
e.printStackTrace();
}
mByteBuffers = mipmapChain;
}
示例6: setInputStream
import android.opengl.ETC1Util; //导入方法依赖的package包/类
public void setInputStream(InputStream compressedTexture, Bitmap fallbackTexture)
{
ETC1Util.ETC1Texture texture = null;
try {
texture = ETC1Util.createTexture(compressedTexture);
} catch (IOException e) {
Log.e("addEtc1Texture", e.getMessage());
} finally {
if (texture == null) {
setBitmap(fallbackTexture);
Log.d("ETC1", "Falling back to uncompressed texture");
} else {
setByteBuffer(texture.getData());
setWidth(texture.getWidth());
setHeight(texture.getHeight());
Log.d("ETC1", "ETC1 texture load successful");
}
}
}
示例7: addEtc1Texture
import android.opengl.ETC1Util; //导入方法依赖的package包/类
public TextureInfo addEtc1Texture(InputStream compressedTex, Bitmap fallbackTex, TextureType textureType) {
ETC1Util.ETC1Texture texture = null;
TextureInfo textureInfo = null;
try {
texture = ETC1Util.createTexture(compressedTex);
} catch (IOException e) {
Log.e("addEtc1Texture", e.getMessage());
} finally {
if (texture == null) {
textureInfo = addTexture(fallbackTex);
Log.d("ETC1", "Falling back to uncompressed texture");
} else {
textureInfo = addEtc1Texture(texture.getData(), texture.getWidth(), texture.getHeight(), textureType);
Log.d("ETC1", "ETC1 texture load successful");
}
}
return textureInfo;
}
示例8: loadTexture
import android.opengl.ETC1Util; //导入方法依赖的package包/类
private void loadTexture(Context context, Render.DrawGroup drawGroup) {
if (drawGroup.texture != null) {
int resource = TEXTURES.get(drawGroup.texture.toLowerCase());
InputStream is = context.getResources().openRawResource(resource);
try {
ETC1Util.ETC1Texture tex = ETC1Util.createTexture(is);
is.close();
drawGroup.loadedCompressedDiffuseTexture = tex;
} catch (IOException e) {
Log.e("Body", "Loading texture: " + e);
}
} else {
int[] color = { Color.rgb(
(int)(drawGroup.diffuseColor[0] * 255 + 0.5),
(int)(drawGroup.diffuseColor[1] * 255 + 0.5),
(int)(drawGroup.diffuseColor[2] * 255 + 0.5))
};
Bitmap bitmap = Bitmap.createBitmap(color, 1, 1, Bitmap.Config.RGB_565);
drawGroup.loadedDiffuseTexture = bitmap;
}
}
示例9: setResourceId
import android.opengl.ETC1Util; //导入方法依赖的package包/类
public void setResourceId(int resourceId) {
mResourceId = resourceId;
Resources resources = TextureManager.getInstance().getContext().getResources();
try {
ETC1Util.ETC1Texture texture = ETC1Util.createTexture(resources.openRawResource(resourceId));
mByteBuffers = new ByteBuffer[]{texture.getData()};
setWidth(texture.getWidth());
setHeight(texture.getHeight());
setCompressionFormat(ETC1.ETC1_RGB8_OES);
} catch (IOException e) {
RajLog.e(e.getMessage());
e.printStackTrace();
}
}
示例10: setResourceId
import android.opengl.ETC1Util; //导入方法依赖的package包/类
public void setResourceId(int resourceId) {
mResourceId = resourceId;
Resources resources = TextureManager.getInstance().getContext().getResources();
try {
ETC1Util.ETC1Texture texture = ETC1Util.createTexture(resources.openRawResource(resourceId));
mByteBuffers = new ByteBuffer[] { texture.getData() };
setWidth(texture.getWidth());
setHeight(texture.getHeight());
setCompressionFormat(ETC1.ETC1_RGB8_OES);
} catch (IOException e) {
RajLog.e(e.getMessage());
e.printStackTrace();
}
}
示例11: loadTexture
import android.opengl.ETC1Util; //导入方法依赖的package包/类
public static int loadTexture(ETC1Util.ETC1Texture etc1Texture) {
// Note that unlike the js version, this does not cache textures. There
// was just one cache hit.
int tex = genTex();
GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, tex);
ETC1Util.loadTexture(
GLES20.GL_TEXTURE_2D, 0, 0, GLES20.GL_RGB,
GLES20.GL_UNSIGNED_SHORT_5_6_5, etc1Texture);
return tex;
}