Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/323.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/179.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 无法从GLSurfaceView.Renderer加载纹理/位图_Java_Android_Opengl Es_Bitmap - Fatal编程技术网

Java 无法从GLSurfaceView.Renderer加载纹理/位图

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

我正在尝试将位图图像加载到GLSURFACHEVIEW中,但没有看到任何渲染的内容。不知道为什么!我试了很多,但没有任何线索。我知道OnDrawFrame方法正在被调用(检查),但我看不到对我的GLSurfaceView有任何影响。当我为视图设置背景时,我可以看到背景颜色。请帮忙

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);

当我们在绘制正方形后绘制位图时,它会显示出来(如中所示)。我会详细了解它并让您知道。当我们在绘制完正方形后绘制位图时,它会显示出来(如中所示)。我会详细调查一下,然后告诉你。