Java 无法从GLSurfaceView.Renderer加载纹理/位图
我正在尝试将位图图像加载到GLSURFACHEVIEW中,但没有看到任何渲染的内容。不知道为什么!我试了很多,但没有任何线索。我知道OnDrawFrame方法正在被调用(检查),但我看不到对我的GLSurfaceView有任何影响。当我为视图设置背景时,我可以看到背景颜色。请帮忙Java 无法从GLSurfaceView.Renderer加载纹理/位图,java,android,opengl-es,bitmap,Java,Android,Opengl Es,Bitmap,我正在尝试将位图图像加载到GLSURFACHEVIEW中,但没有看到任何渲染的内容。不知道为什么!我试了很多,但没有任何线索。我知道OnDrawFrame方法正在被调用(检查),但我看不到对我的GLSurfaceView有任何影响。当我为视图设置背景时,我可以看到背景颜色。请帮忙 class ClearRenderer implements GLSurfaceView.Renderer { int[] textureIds = null; public ClearRendere
class ClearRenderer implements GLSurfaceView.Renderer {
int[] textureIds = null;
public ClearRenderer()
{
}
public void onSurfaceCreated(GL10 gl, EGLConfig config) {
gl.glEnable(GL10.GL_TEXTURE_2D);
if(textureIds == null) {
textureIds = new int[1];
gl.glGenTextures( 1, textureIds, 0 );
}
}
public void onSurfaceChanged(GL10 gl, int w, int h) {
//gl.glViewport(0, 0, w, h);
}
public void onDrawFrame(final GL10 gl) {
Bitmap solidColorBitmap = Bitmap.createBitmap(400, 400, Config.ARGB_8888);
solidColorBitmap.eraseColor(android.graphics.Color.GREEN);
gl.glActiveTexture(textureIds[0]);
gl.glBindTexture( GL10.GL_TEXTURE_2D, textureIds[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);
// Use the Android GLUtils to specify a two-dimensional texture image from our bitmap
GLUtils.texImage2D( GL10.GL_TEXTURE_2D, 0, solidColorBitmap, 2 );
}
}
class MainMonitor extends GLSurfaceView {
ClearRenderer render = new ClearRenderer();
public MainMonitor(Context context) {
super(context);
this.setRenderer(render);
this.setWillNotDraw(false);
}
}
这就是我从活动中添加GLSURFACHEVIEW的方式。(topLayout具有其他布局)。我知道problemView在顶部-当我设置背景颜色时,我可以看到1000x1000的青色补丁
problemView = new MainMonitor(this);
((GLSurfaceView) problemView ).requestRender();
problemView .setLayoutParams(new FrameLayout.LayoutParams(1000, 1000,1));
//problemView .setBackgroundColor(Color.CYAN);
topLayout.addView(problemView);
setContentView(topLayout);
当我们在绘制正方形后绘制位图时,它会显示出来(如中所示)。我会详细了解它并让您知道。当我们在绘制完正方形后绘制位图时,它会显示出来(如中所示)。我会详细调查一下,然后告诉你。