• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps Render 2d Texture OpenGL

Raymond

Lurker
Hello,

This is what I currently have:
Code:
import java.nio.IntBuffer;

import javax.microedition.khronos.opengles.GL10;

import com.soulhunt.engine.Device;
import com.soulhunt.engine.State;

import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.opengl.GLUtils;
import android.view.MotionEvent;

public class DummyState implements State {	
	@Override
	public void Clear(GL10 gl) {
	}

	@Override
	public void Init(GL10 gl) {
		gl.glEnableClientState(GL10.GL_TEXTURE_COORD_ARRAY);
	    gl.glEnable(GL10.GL_TEXTURE_2D);
	    gl.glMatrixMode(GL10.GL_PROJECTION);
	    gl.glLoadIdentity();
		Bitmap bmp = BitmapFactory.decodeResource(Device.getDeviceContext().getResources(), R.drawable.icon);
		GLUtils.texImage2D(GL10.GL_TEXTURE_2D, 0, bmp, 0);
		gl.glTexParameterx(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_MIN_FILTER, GL10.GL_LINEAR);
		gl.glTexParameterx(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_MAG_FILTER, GL10.GL_LINEAR);
		bmp.recycle();
	}

	@Override
	public void Render(GL10 gl) {
		int texCoords[] = {
			0, 1, 1, 0	
		};
		IntBuffer buf = IntBuffer.allocate(texCoords.length * 4);
		gl.glTexCoordPointer(2, GL10.GL_FIXED, 0, buf);
	}

	@Override
	public void TouchEvent(MotionEvent event) {
	}
}

Problem is it only shows a black background without the texture. Any idea what I need to add or modify?

Tnx,

Raymond
 
Back
Top Bottom