获取异常:致命的异常:GLThread没有CONFIGS匹配configSpec [英] Getting Exception: FATAL EXCEPTION: GLThread No configs match configSpec

查看:1057
本文介绍了获取异常:致命的异常:GLThread没有CONFIGS匹配configSpec的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的是低于code的多重采样,使边缘光滑。低于code为工作的一些手机和其他移动我得到异常'不匹配CONFIGS configSpec

请帮我解决这个问题。

先谢谢了。

 包com.amplimesh.renderer;进口javax.microedition.khronos.egl.EGL10;
进口javax.microedition.khronos.egl.EGLConfig;
进口javax.microedition.khronos.egl.EGLDisplay;进口android.opengl.GLSurfaceView;
进口android.util.Log;//这个类展示了如何使用多重采样。要使用此功能,来电
// myGLSurfaceView.setEGLConfigChooser(新MultisampleConfigChooser());
//调用setRenderer()之前。多重采样可能会放缓
//你的应用程序 - 衡量绩效仔细决定是否大大
//改善视觉质量是值得的成本。
公共类MultisampleConfigChooser实现GLSurfaceView.EGLConfigChooser {
    静态私有最终字符串kTag =GDC11;
    @覆盖
    公共EGLConfig chooseConfig(EGL10 EGL,EGLDisplay显示器){
        mValue =新INT [1];        //尝试先找到一个正常的多重采样配置。
        INT [] = configSpec {
                EGL10.EGL_RED_SIZE,5,
                EGL10.EGL_GREEN_SIZE,6,
                EGL10.EGL_BLUE_SIZE,5,
                EGL10.EGL_DEPTH_SIZE,16,
                //要求setEGLContextClientVersion(2)被称为上的视图。
                EGL10.EGL_RENDERABLE_TYPE,4 / * * EGL_OPENGL_ES2_BIT /,
                EGL10.EGL_SAMPLE_BUFFERS,1 / * *真/,
                EGL10.EGL_SAMPLES,2,
                EGL10.EGL_NONE
        };        如果(!egl.eglChooseConfig(显示器,configSpec,NULL,0,
                mValue)){
            抛出新抛出:IllegalArgumentException(eglChooseConfig失败);
        }
        INT numConfigs = mValue [0];        如果(numConfigs&下; = 0){
            //不正常的多级配置被发现。尝试创建一个
            // converage多重采样配置,nVidia的Tegra2的。
            //见EGL_NV_coverage_sample文档。            最终诠释EGL_COVERAGE_BUFFERS_NV = 0x30E0;
            最终诠释EGL_COVERAGE_SAMPLES_NV = 0x30E1;            configSpec = INT新[] {
                    EGL10.EGL_RED_SIZE,5,
                    EGL10.EGL_GREEN_SIZE,6,
                    EGL10.EGL_BLUE_SIZE,5,
                    EGL10.EGL_DEPTH_SIZE,16,
                    EGL10.EGL_RENDERABLE_TYPE,4 / * * EGL_OPENGL_ES2_BIT /,
                    EGL_COVERAGE_BUFFERS_NV,1 / * *真/,
                    EGL_COVERAGE_SAMPLES_NV,2,//总是5在Tegra 2的做法
                    EGL10.EGL_NONE
            };            如果(!egl.eglChooseConfig(显示器,configSpec,NULL,0,
                    mValue)){
                抛出新抛出:IllegalArgumentException(第二eglChooseConfig失败);
            }
            numConfigs = mValue [0];            如果(numConfigs&下; = 0){
                //放弃,尝试没有多重采样。
                configSpec = INT新[] {
                        EGL10.EGL_RED_SIZE,5,
                        EGL10.EGL_GREEN_SIZE,6,
                        EGL10.EGL_BLUE_SIZE,5,
                        EGL10.EGL_DEPTH_SIZE,16,
                        EGL10.EGL_RENDERABLE_TYPE,4 / * * EGL_OPENGL_ES2_BIT /,
                        EGL10.EGL_NONE
                };                如果(!egl.eglChooseConfig(显示器,configSpec,NULL,0,
                        mValue)){
                    抛出新抛出:IllegalArgumentException(第三eglChooseConfig失败);
                }
                numConfigs = mValue [0];                如果(numConfigs&下; = 0){
                    抛出新抛出:IllegalArgumentException(不匹配CONFIGS configSpec);
                }
            }其他{
                mUsesCoverageAa = TRUE;
            }
        }        //获取所有匹配的配置。
        EGLConfig [] = CONFIGS新EGLConfig [numConfigs]
        如果(!egl.eglChooseConfig(显示器,configSpec,CONFIGS,numConfigs,
                mValue)){
            抛出新抛出:IllegalArgumentException(数据eglChooseConfig失败);
        }        //注意! eglChooseConfigs返回高位深度CONFIGS
        //首先:尽管我们要求RGB565配置,RGB888
        //配置被认为是更好,首先返回。
        //你需要明确由过滤返回eglChooseConfig数据!
        INT指数= -1;
        的for(int i = 0; I< configs.length ++我){
            如果(findConfigAttrib(EGL,显示,CONFIGS [Ⅰ],EGL10.EGL_RED_SIZE,0)== 5){
                指数= I;
                打破;
            }
        }
        如果(指数== -1){
            Log.w(kTag,没找到理智的配置,先使用);
        }
        EGLConfig配置= configs.length> 0? CONFIGS [指数]:空;
        如果(配置== NULL){
            抛出新抛出:IllegalArgumentException(不配置选择);
        }
        返回配置;
    }    私人诠释findConfigAttrib(EGL10 EGL,EGLDisplay显示,
            EGLConfig配置,诠释属性,诠释设置defaultValue){
        如果(egl.eglGetConfigAttrib(显示器,配置,属性,mValue)){
            返回mValue [0];
        }
        返回设置defaultValue;
    }    公共布尔usesCoverageAa(){
        返回mUsesCoverageAa;
    }    私人诠释[] mValue;
    私人布尔mUsesCoverageAa;
}


解决方案

这是一种非常古老的问题,但我发现解决这个(至少在我的情况)。所以,也许会有人能够发现它有用。

问题是,模拟器使用集成显卡,而不是专用的,其中有对OpenGLES 2.0的支持。所以要解决它,我不得不强迫我的模拟器使用独立显卡。只要到您的显卡驱动程序,并迫使他们使用,而不是集成的专用GPU。

在我的情况下,问题解决了:)

I am using the below code for the MultiSampling to make the smooth edge. Below code is working on some mobile and other mobile I am getting exception 'No configs match configSpec.

Please help me to solve this issue.

Thanks in advance.

package com.amplimesh.renderer;

import javax.microedition.khronos.egl.EGL10;
import javax.microedition.khronos.egl.EGLConfig;
import javax.microedition.khronos.egl.EGLDisplay;

import android.opengl.GLSurfaceView;
import android.util.Log;

// This class shows how to use multisampling. To use this, call
//   myGLSurfaceView.setEGLConfigChooser(new MultisampleConfigChooser());
// before calling setRenderer(). Multisampling will probably slow down
// your app -- measure performance carefully and decide if the vastly
// improved visual quality is worth the cost.
public class MultisampleConfigChooser implements GLSurfaceView.EGLConfigChooser {
    static private final String kTag = "GDC11";
    @Override
    public EGLConfig chooseConfig(EGL10 egl, EGLDisplay display) {
        mValue = new int[1];

        // Try to find a normal multisample configuration first.
        int[] configSpec = {
                EGL10.EGL_RED_SIZE, 5,
                EGL10.EGL_GREEN_SIZE, 6,
                EGL10.EGL_BLUE_SIZE, 5,
                EGL10.EGL_DEPTH_SIZE, 16,
                // Requires that setEGLContextClientVersion(2) is called on the view.
                EGL10.EGL_RENDERABLE_TYPE, 4 /* EGL_OPENGL_ES2_BIT */,
                EGL10.EGL_SAMPLE_BUFFERS, 1 /* true */,
                EGL10.EGL_SAMPLES, 2,
                EGL10.EGL_NONE
        };

        if (!egl.eglChooseConfig(display, configSpec, null, 0,
                mValue)) {
            throw new IllegalArgumentException("eglChooseConfig failed");
        }
        int numConfigs = mValue[0];

        if (numConfigs <= 0) {
            // No normal multisampling config was found. Try to create a
            // converage multisampling configuration, for the nVidia Tegra2.
            // See the EGL_NV_coverage_sample documentation.

            final int EGL_COVERAGE_BUFFERS_NV = 0x30E0;
            final int EGL_COVERAGE_SAMPLES_NV = 0x30E1;

            configSpec = new int[]{
                    EGL10.EGL_RED_SIZE, 5,
                    EGL10.EGL_GREEN_SIZE, 6,
                    EGL10.EGL_BLUE_SIZE, 5,
                    EGL10.EGL_DEPTH_SIZE, 16,
                    EGL10.EGL_RENDERABLE_TYPE, 4 /* EGL_OPENGL_ES2_BIT */,
                    EGL_COVERAGE_BUFFERS_NV, 1 /* true */,
                    EGL_COVERAGE_SAMPLES_NV, 2,  // always 5 in practice on tegra 2
                    EGL10.EGL_NONE
            };

            if (!egl.eglChooseConfig(display, configSpec, null, 0,
                    mValue)) {
                throw new IllegalArgumentException("2nd eglChooseConfig failed");
            }
            numConfigs = mValue[0];

            if (numConfigs <= 0) {
                // Give up, try without multisampling.
                configSpec = new int[]{
                        EGL10.EGL_RED_SIZE, 5,
                        EGL10.EGL_GREEN_SIZE, 6,
                        EGL10.EGL_BLUE_SIZE, 5,
                        EGL10.EGL_DEPTH_SIZE, 16,
                        EGL10.EGL_RENDERABLE_TYPE, 4 /* EGL_OPENGL_ES2_BIT */,
                        EGL10.EGL_NONE
                };

                if (!egl.eglChooseConfig(display, configSpec, null, 0,
                        mValue)) {
                    throw new IllegalArgumentException("3rd eglChooseConfig failed");
                }
                numConfigs = mValue[0];

                if (numConfigs <= 0) {
                    throw new IllegalArgumentException("No configs match configSpec");
                }
            } else {
                mUsesCoverageAa = true;
            }
        }

        // Get all matching configurations.
        EGLConfig[] configs = new EGLConfig[numConfigs];
        if (!egl.eglChooseConfig(display, configSpec, configs, numConfigs,
                mValue)) {
            throw new IllegalArgumentException("data eglChooseConfig failed");
        }

        // CAUTION! eglChooseConfigs returns configs with higher bit depth
        // first: Even though we asked for rgb565 configurations, rgb888
        // configurations are considered to be "better" and returned first.
        // You need to explicitly filter the data returned by eglChooseConfig!
        int index = -1;
        for (int i = 0; i < configs.length; ++i) {
            if (findConfigAttrib(egl, display, configs[i], EGL10.EGL_RED_SIZE, 0) == 5) {
                index = i;
                break;
            }
        }
        if (index == -1) {
            Log.w(kTag, "Did not find sane config, using first");
        }
        EGLConfig config = configs.length > 0 ? configs[index] : null;
        if (config == null) {
            throw new IllegalArgumentException("No config chosen");
        }
        return config;
    }

    private int findConfigAttrib(EGL10 egl, EGLDisplay display,
            EGLConfig config, int attribute, int defaultValue) {
        if (egl.eglGetConfigAttrib(display, config, attribute, mValue)) {
            return mValue[0];
        }
        return defaultValue;
    }

    public boolean usesCoverageAa() {
        return mUsesCoverageAa;
    }

    private int[] mValue;
    private boolean mUsesCoverageAa;
}

解决方案

This is kind of very old issue, yet I found solution to this (at least in my case). So maybe someone will be able to find it helpful.

Problem was that emulator was using integrated graphics, instead of dedicated, which had no support for OpenGLES 2.0. So to solve it I had to force my emulator to use dedicated graphics. Just go to your graphics drivers and force them to use dedicated GPU instead of integrated.

In my case problem was solved :)

这篇关于获取异常:致命的异常:GLThread没有CONFIGS匹配configSpec的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆