Pass the context from your engine to your renderer. Then, here's some sample code to load the asset. i.e. resourceID is your R.drawable.xxx bitmap. I have this inside a texture atlas class I made, so a few things might not be completely contained in the method. For example the options I might use to load the bitmap would include inscaled = false, but whatever works for you. I also modified this to remove my error handling for instance.
/**
* Load the resource and push it to the gpu memory, setup default values
* @param gl
* @param context
* @param resourceID
* @return glTextureID
*
*/
public int loadFromContext(GL10 gl, Context context, int resourceID) {
mResourceID = resourceID;
Bitmap bmp = BitmapFactory.decodeResource(context.getResources(), resourceID, sBitmapOptions);
sourceWidth = bmp.getWidth();
sourceHeight = bmp.getHeight();
gl.glGenTextures(1, mGLTextures, 0);
mGLTextureID = mGLTextures[0];
// bind and set min and mag scaling to bilinear
gl.glBindTexture(GL10.GL_TEXTURE_2D, mGLTextureID);
gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_MIN_FILTER, GL10.GL_LINEAR);
gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_MAG_FILTER, GL10.GL_LINEAR);
// repeat by default
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);
// upload bmp to video memory
GLUtils.texImage2D(GL10.GL_TEXTURE_2D, 0, bmp, 0);
// check error
int error = gl.glGetError();
if (error != GL10.GL_NO_ERROR) {
// cleanup
bmp.recycle();
bmp = null;
mLoaded = false;
// error handling here
} else {
// unbind.
gl.glBindTexture(GL10.GL_TEXTURE_2D, 0);
bmp.recycle();
bmp = null;
mLoaded = true;
mDirty = true;
}
return mGLTextureID;
}