Render 2d Texture OpenGL


Last Updated:

  1. Raymond

    Raymond New Member This Topic's Starter

    Joined:
    Oct 2, 2009
    Messages:
    1
    Likes Received:
    0
    Hello,

    This is what I currently have:
    Code (Text):
    1. import java.nio.IntBuffer;
    2.  
    3. import javax.microedition.khronos.opengles.GL10;
    4.  
    5. import com.soulhunt.engine.Device;
    6. import com.soulhunt.engine.State;
    7.  
    8. import android.graphics.Bitmap;
    9. import android.graphics.BitmapFactory;
    10. import android.opengl.GLUtils;
    11. import android.view.MotionEvent;
    12.  
    13. public class DummyState implements State { 
    14.     @Override
    15.     public void Clear(GL10 gl) {
    16.     }
    17.  
    18.     @Override
    19.     public void Init(GL10 gl) {
    20.         gl.glEnableClientState(GL10.GL_TEXTURE_COORD_ARRAY);
    21.         gl.glEnable(GL10.GL_TEXTURE_2D);
    22.         gl.glMatrixMode(GL10.GL_PROJECTION);
    23.         gl.glLoadIdentity();
    24.         Bitmap bmp = BitmapFactory.decodeResource(Device.getDeviceContext().getResources(), R.drawable.icon);
    25.         GLUtils.texImage2D(GL10.GL_TEXTURE_2D, 0, bmp, 0);
    26.         gl.glTexParameterx(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_MIN_FILTER, GL10.GL_LINEAR);
    27.         gl.glTexParameterx(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_MAG_FILTER, GL10.GL_LINEAR);
    28.         bmp.recycle();
    29.     }
    30.  
    31.     @Override
    32.     public void Render(GL10 gl) {
    33.         int texCoords[] = {
    34.             0, 1, 1, 0 
    35.         };
    36.         IntBuffer buf = IntBuffer.allocate(texCoords.length * 4);
    37.         gl.glTexCoordPointer(2, GL10.GL_FIXED, 0, buf);
    38.     }
    39.  
    40.     @Override
    41.     public void TouchEvent(MotionEvent event) {
    42.     }
    43. }
    Problem is it only shows a black background without the texture. Any idea what I need to add or modify?

    Tnx,

    Raymond
     

    Advertisement

Share This Page

Loading...