Wrap two texture over a plane?
How do you wrap two textures over a plane? I think I did it, but the texture is filling the whole object not just the sliver I want it to.
Any help is appreciated ~Aedon
InputStream is = context.getResources().openRawResource(R.drawable.woodtexture1);
InputStream is2 = context.getResources().openRawResource(R.drawable.bandtest);
Bitmap bitmap = null;
Bitmap b2 = null;
try {
//BitmapFactory is an Android graphics utility for images
bitmap = BitmapFactory.decodeStream(is);
b2 = BitmapFactory.decodeStream(is2);
} finally {
//Always clear and close
try {
is.close();
is2.close();
is = null;
is = null;
} catch (IOException e) {}
}
//Generate one texture pointer...
gl.glGenTextures(1, textures, 0);
//...and bind it to our array
gl.glBindTexture(GL10.GL_TEXTURE_2D, textures[0]);
//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);
//Generate one texture pointer...
gl.glGenTextures(1, textures, 0);
//...and bind it to our array
gl.glBindTexture(GL10.GL_TEXTURE_2D, textures[0]);
//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_ONE);
gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_WRAP_T, GL10.GL_ONE);
GLUtils.texImage2D(开发者_开发问答GL10.GL_TEXTURE_2D, 0, bitmap, 0);
GLUtils.texImage2D(GL10.GL_TEXTURE_2D, 0, b2, 0);
I am unsure if this is what you want - but if you want your texture to cover only part of your object, use glTexCoordPointer
to set texture coordinates for your object.
Some examples of your actual draw code would be great, though.
精彩评论