• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ eglGetConfigAttrib函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中eglGetConfigAttrib函数的典型用法代码示例。如果您正苦于以下问题:C++ eglGetConfigAttrib函数的具体用法?C++ eglGetConfigAttrib怎么用?C++ eglGetConfigAttrib使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了eglGetConfigAttrib函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: bcm_host_init

	void GlContext::create(uint32_t _width, uint32_t _height)
	{
#	if BX_PLATFORM_RPI
		bcm_host_init();
#	endif // BX_PLATFORM_RPI

		m_eglLibrary = eglOpen();

		if (NULL == g_platformData.context)
		{
#	if BX_PLATFORM_RPI
			g_platformData.ndt = EGL_DEFAULT_DISPLAY;
#	endif // BX_PLATFORM_RPI

			BX_UNUSED(_width, _height);
			EGLNativeDisplayType ndt = (EGLNativeDisplayType)g_platformData.ndt;
			EGLNativeWindowType  nwh = (EGLNativeWindowType )g_platformData.nwh;

#	if BX_PLATFORM_WINDOWS
			if (NULL == g_platformData.ndt)
			{
				ndt = GetDC( (HWND)g_platformData.nwh);
			}
#	endif // BX_PLATFORM_WINDOWS

			m_display = eglGetDisplay(ndt);
			BGFX_FATAL(m_display != EGL_NO_DISPLAY, Fatal::UnableToInitialize, "Failed to create display %p", m_display);

			EGLint major = 0;
			EGLint minor = 0;
			EGLBoolean success = eglInitialize(m_display, &major, &minor);
			BGFX_FATAL(success && major >= 1 && minor >= 3, Fatal::UnableToInitialize, "Failed to initialize %d.%d", major, minor);

			BX_TRACE("EGL info:");
			const char* clientApis = eglQueryString(m_display, EGL_CLIENT_APIS);
			BX_TRACE("   APIs: %s", clientApis); BX_UNUSED(clientApis);

			const char* vendor = eglQueryString(m_display, EGL_VENDOR);
			BX_TRACE(" Vendor: %s", vendor); BX_UNUSED(vendor);

			const char* version = eglQueryString(m_display, EGL_VERSION);
			BX_TRACE("Version: %s", version); BX_UNUSED(version);

			const char* extensions = eglQueryString(m_display, EGL_EXTENSIONS);
			BX_TRACE("Supported EGL extensions:");
			dumpExtensions(extensions);

			// https://www.khronos.org/registry/EGL/extensions/ANDROID/EGL_ANDROID_recordable.txt
			const bool hasEglAndroidRecordable = !bx::findIdentifierMatch(extensions, "EGL_ANDROID_recordable").isEmpty();

			EGLint attrs[] =
			{
				EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,

#	if BX_PLATFORM_ANDROID
				EGL_DEPTH_SIZE, 16,
#	else
				EGL_DEPTH_SIZE, 24,
#	endif // BX_PLATFORM_
				EGL_STENCIL_SIZE, 8,

				// Android Recordable surface
				hasEglAndroidRecordable ? 0x3142 : EGL_NONE,
				hasEglAndroidRecordable ? 1      : EGL_NONE,

				EGL_NONE
			};

			EGLint numConfig = 0;
			success = eglChooseConfig(m_display, attrs, &m_config, 1, &numConfig);
			BGFX_FATAL(success, Fatal::UnableToInitialize, "eglChooseConfig");

#	if BX_PLATFORM_ANDROID

			EGLint format;
			eglGetConfigAttrib(m_display, m_config, EGL_NATIVE_VISUAL_ID, &format);
			ANativeWindow_setBuffersGeometry( (ANativeWindow*)g_platformData.nwh, _width, _height, format);

#	elif BX_PLATFORM_RPI
			DISPMANX_DISPLAY_HANDLE_T dispmanDisplay = vc_dispmanx_display_open(0);
			DISPMANX_UPDATE_HANDLE_T  dispmanUpdate  = vc_dispmanx_update_start(0);

			VC_RECT_T dstRect = { 0, 0, int32_t(_width),        int32_t(_height)       };
			VC_RECT_T srcRect = { 0, 0, int32_t(_width)  << 16, int32_t(_height) << 16 };

			DISPMANX_ELEMENT_HANDLE_T dispmanElement = vc_dispmanx_element_add(dispmanUpdate
				, dispmanDisplay
				, 0
				, &dstRect
				, 0
				, &srcRect
				, DISPMANX_PROTECTION_NONE
				, NULL
				, NULL
				, DISPMANX_NO_ROTATE
				);

			s_dispmanWindow.element = dispmanElement;
			s_dispmanWindow.width   = _width;
			s_dispmanWindow.height  = _height;
//.........这里部分代码省略.........
开发者ID:Dagarman,项目名称:mame,代码行数:101,代码来源:glcontext_egl.cpp


示例2: g_initGles

void g_initGles()
{
    const EGLint attribs[] = {
        EGL_SURFACE_TYPE, EGL_WINDOW_BIT,
        EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
        EGL_BLUE_SIZE, 8,
        EGL_GREEN_SIZE, 8,
        EGL_RED_SIZE, 8,
        EGL_NONE
    };
    const EGLint attrs[] = {
        EGL_CONTEXT_CLIENT_VERSION, 2,
        EGL_NONE, };
    bwwindow=GetWindow();
    bwdisplay=GetDisplay();
    LOGE("Got bwdisplay %p", bwdisplay);
    LOGE("Got bwwindow %p", bwwindow);
    LOGI("Initializing context");
    
    if (bwdisplay  != EGL_NO_DISPLAY) {
        LOGI("%d", 2222);
        
    }
    if (!eglInitialize(bwdisplay, 0, 0)) {
        LOGI("eglInitialize() returned error %d", eglGetError());
        
    }
    eglBindAPI(EGL_OPENGL_ES_API);
    
    if (!eglChooseConfig(bwdisplay, attribs, &bwconfig, 1, &bwnumConfigs)) {
        LOGI("eglChooseConfig() returned error %d", eglGetError());
        g_destroyGL();
        
    }
    
    if (!eglGetConfigAttrib(bwdisplay, bwconfig, EGL_NATIVE_VISUAL_ID, &bwformat)) {
        LOGI("eglGetConfigAttrib() returned error %d", eglGetError());
        g_destroyGL();
        
    }
    
    ANativeWindow_setBuffersGeometry(bwwindow, 0, 0, bwformat);
    LOGI("**********pgc1************");
    if (!(bwsurface_copy = eglCreateWindowSurface(bwdisplay, bwconfig, bwwindow, 0))) {
        LOGI("eglCreateWindowSurface() returned error %d", eglGetError());
//        g_destroyGL();
        
    }else{
        bwsurface = bwsurface_copy;
    }
    
    LOGI("**********pgc2************");
    if (!(bwcontext_copy = eglCreateContext(bwdisplay, bwconfig, EGL_NO_CONTEXT, attrs))) {
        LOGI("eglCreateContext() returned error %d", eglGetError());
//        g_destroyGL();
    }else{
        bwcontext = bwcontext_copy;
    }
    
    if (!eglMakeCurrent(bwdisplay, bwsurface, bwsurface, bwcontext)) {
        LOGI("eglMakeCurrent() returned error %d", eglGetError());
//        g_destroyGL();
        
    }
    
    if (!eglQuerySurface(bwdisplay, bwsurface, EGL_WIDTH, &bwwidth) ||
        !eglQuerySurface(bwdisplay, bwsurface, EGL_HEIGHT, &bwheight)) {
        LOGI("eglQuerySurface() returned error %d", eglGetError());
//        g_destroyGL();
        
    }
    printGLString("Version", GL_VERSION);
    printGLString("Vendor", GL_VENDOR);
    printGLString("Renderer", GL_RENDERER);
    printGLString("Extensions", GL_EXTENSIONS);
    
    glHint( GL_GENERATE_MIPMAP_HINT, GL_NICEST );
    
    glHint( GL_FRAGMENT_SHADER_DERIVATIVE_HINT_OES, GL_NICEST );
    
    glEnable( GL_DEPTH_TEST );
    glEnable( GL_CULL_FACE  );
    glDisable( GL_DITHER );
    glDepthMask( GL_TRUE );
    glDepthFunc( GL_LESS );
    glDepthRangef( 0.0f, 1.0f );
    glClearDepthf( 1.0f );
    glCullFace ( GL_BACK );
    glFrontFace( GL_CCW  );
    glClearStencil( 0 );
    glStencilMask( 0xFFFFFFFF );
    //绘制三角形
//    setupGraphics(1232,800);
//    if (bwdisplay) {
//        renderFrame();
//        if (!eglSwapBuffers(bwdisplay, bwsurface)) {
//            LOGE("eglSwapBuffers() returned error %d", eglGetError());
//            g_destroyGL();
//        }
//        
//.........这里部分代码省略.........
开发者ID:hgl888,项目名称:nashtest,代码行数:101,代码来源:GlobalPortingFunction.cpp


示例3: switch

	//Changed the constructor to a member function so that the
	//native constructor would be called first. This member
	//function is then called from the native constructor.
    void EGLPBuffer::initEGLPBuffer()
    {

//	These are now initialized in the native constructors.
//	mGLSupport = glsupport;
//        mGlDisplay = mGLSupport->getGLDisplay();
        mEglDrawable = 0;
        ::EGLConfig glConfig = 0;

        bool isFloat = false;
        int bits = 0;

        switch (mFormat)
        {
            case PCT_BYTE:
                bits = 8;
                break;

            case PCT_SHORT:
            case PCT_FLOAT16:
                bits = 16;
                break;

            case PCT_FLOAT32:
                bits = 32;
                break;

            default:
                break;
        }

        if (mFormat == PCT_FLOAT16 || mFormat == PCT_FLOAT32)
        {
            OGRE_EXCEPT(Exception::ERR_NOT_IMPLEMENTED,
                        "No support for Floating point PBuffers",
                        "EGLRenderTexture::initEGLPBuffer");
        }

        EGLint minAttribs[] = {
            EGL_SURFACE_TYPE, EGL_WINDOW_BIT | EGL_PBUFFER_BIT,
            EGL_DEPTH_SIZE, 16,
            EGL_NONE
        };

        EGLint maxAttribs[] = {
            EGL_RED_SIZE, bits,
            EGL_GREEN_SIZE, bits,
            EGL_BLUE_SIZE, bits,
            EGL_ALPHA_SIZE, bits,
            EGL_STENCIL_SIZE, INT_MAX,
            EGL_NONE
        };

        EGLint pBufferAttribs[] = {
			// First we specify the width of the surface...
            EGL_WIDTH, mWidth,
			// ...then the height of the surface...
            EGL_HEIGHT, mHeight,
			/* ... then we specifiy the target for the texture
			that will be created when the pbuffer is created...*/
			EGL_TEXTURE_TARGET, EGL_TEXTURE_2D,
			/*..then the format of the texture that will be created
			when the pBuffer is bound to a texture...*/
            EGL_TEXTURE_FORMAT, EGL_TEXTURE_RGB,
			// The final thing is EGL_NONE which signifies the end.
            EGL_NONE
        };


        glConfig = mGLSupport->selectGLConfig(minAttribs, maxAttribs);

        EGL_CHECK_ERROR;
        mEglDrawable = eglCreatePbufferSurface(mGlDisplay, glConfig, pBufferAttribs);
        EGL_CHECK_ERROR;

        if (!glConfig || !mEglDrawable)
        {
            OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR,
                        "Unable to create Pbuffer",
                        "EGLPBuffer::EGLPBuffer");
        }
        EGLint glConfigID;
        EGLint iWidth, iHeight;

        eglGetConfigAttrib(mGlDisplay, glConfig, EGL_CONFIG_ID, &glConfigID);
        EGL_CHECK_ERROR;
        eglQuerySurface(mGlDisplay, mEglDrawable, EGL_WIDTH, &iWidth);
        EGL_CHECK_ERROR;
        eglQuerySurface(mGlDisplay, mEglDrawable, EGL_HEIGHT, &iHeight);
        EGL_CHECK_ERROR;

        mWidth = iWidth;
        mHeight = iHeight;
        LogManager::getSingleton().logMessage(LML_NORMAL, "EGLPBuffer::create used final dimensions " + StringConverter::toString(mWidth) + " x " + StringConverter::toString(mHeight));
        LogManager::getSingleton().logMessage("EGLPBuffer::create used FBConfigID " + StringConverter::toString(glConfigID));

    }
开发者ID:Strongc,项目名称:game-ui-solution,代码行数:100,代码来源:OgreEGLRenderTexture.cpp


示例4: getConfigAttrib

// Returns the specified attribute of the specified EGLConfig
//
static int getConfigAttrib(EGLConfig config, int attrib)
{
    int value;
    eglGetConfigAttrib(_glfw.egl.display, config, attrib, &value);
    return value;
}
开发者ID:jayschwa,项目名称:glfw,代码行数:8,代码来源:egl_context.c


示例5: eglGetConfigAttrib

VisualID QXlibEglIntegration::getCompatibleVisualId(Display *display, EGLDisplay eglDisplay, EGLConfig config)
{
    VisualID    visualId = 0;
    EGLint      eglValue = 0;

    EGLint configRedSize = 0;
    eglGetConfigAttrib(eglDisplay, config, EGL_RED_SIZE, &configRedSize);

    EGLint configGreenSize = 0;
    eglGetConfigAttrib(eglDisplay, config, EGL_GREEN_SIZE, &configGreenSize);

    EGLint configBlueSize = 0;
    eglGetConfigAttrib(eglDisplay, config, EGL_BLUE_SIZE, &configBlueSize);

    EGLint configAlphaSize = 0;
    eglGetConfigAttrib(eglDisplay, config, EGL_ALPHA_SIZE, &configAlphaSize);

    eglGetConfigAttrib(eglDisplay, config, EGL_CONFIG_ID, &eglValue);
    int configId = eglValue;

    // See if EGL provided a valid VisualID:
    eglGetConfigAttrib(eglDisplay, config, EGL_NATIVE_VISUAL_ID, &eglValue);
    visualId = (VisualID)eglValue;
    if (visualId) {
        // EGL has suggested a visual id, so get the rest of the visual info for that id:
        XVisualInfo visualInfoTemplate;
        memset(&visualInfoTemplate, 0, sizeof(XVisualInfo));
        visualInfoTemplate.visualid = visualId;

        XVisualInfo *chosenVisualInfo;
        int matchingCount = 0;
        chosenVisualInfo = XGetVisualInfo(display, VisualIDMask, &visualInfoTemplate, &matchingCount);
        if (chosenVisualInfo) {
            // Skip size checks if implementation supports non-matching visual
            // and config (QTBUG-9444).
            if (q_hasEglExtension(eglDisplay,"EGL_NV_post_convert_rounding")) {
                XFree(chosenVisualInfo);
                return visualId;
            }

            int visualRedSize = qPopulationCount(chosenVisualInfo->red_mask);
            int visualGreenSize = qPopulationCount(chosenVisualInfo->green_mask);
            int visualBlueSize = qPopulationCount(chosenVisualInfo->blue_mask);
            int visualAlphaSize = chosenVisualInfo->depth == 32 ? 8 : 0;

            const bool visualMatchesConfig = visualRedSize == configRedSize
                && visualGreenSize == configGreenSize
                && visualBlueSize == configBlueSize
                && visualAlphaSize == configAlphaSize;

            // In some cases EGL tends to suggest a 24-bit visual for 8888
            // configs. In such a case we have to fall back to XGetVisualInfo.
            if (!visualMatchesConfig) {
                visualId = 0;
#ifdef QT_DEBUG_X11_VISUAL_SELECTION
                qWarning("Warning: EGL suggested using X Visual ID %d (%d %d %d depth %d) for EGL config %d (%d %d %d %d), but this is incompatible",
                         (int)visualId, visualRedSize, visualGreenSize, visualBlueSize, chosenVisualInfo->depth,
                         configId, configRedSize, configGreenSize, configBlueSize, configAlphaSize);
#endif
            }
        } else {
            qWarning("Warning: EGL suggested using X Visual ID %d for EGL config %d, but that isn't a valid ID",
                     (int)visualId, configId);
            visualId = 0;
        }
        XFree(chosenVisualInfo);
    }
#ifdef QT_DEBUG_X11_VISUAL_SELECTION
    else
        qDebug("EGL did not suggest a VisualID (EGL_NATIVE_VISUAL_ID was zero) for EGLConfig %d", configId);
#endif

    if (visualId) {
#ifdef QT_DEBUG_X11_VISUAL_SELECTION
        if (configAlphaSize > 0)
            qDebug("Using ARGB Visual ID %d provided by EGL for config %d", (int)visualId, configId);
        else
            qDebug("Using Opaque Visual ID %d provided by EGL for config %d", (int)visualId, configId);
#endif
        return visualId;
    }

    // Finally, try to use XGetVisualInfo and only use the bit depths to match on:
    if (!visualId) {
        XVisualInfo visualInfoTemplate;
        memset(&visualInfoTemplate, 0, sizeof(XVisualInfo));
        XVisualInfo *matchingVisuals;
        int matchingCount = 0;

        visualInfoTemplate.depth = configRedSize + configGreenSize + configBlueSize + configAlphaSize;
        matchingVisuals = XGetVisualInfo(display,
                                         VisualDepthMask,
                                         &visualInfoTemplate,
                                         &matchingCount);
        if (!matchingVisuals) {
            // Try again without taking the alpha channel into account:
            visualInfoTemplate.depth = configRedSize + configGreenSize + configBlueSize;
            matchingVisuals = XGetVisualInfo(display,
                                             VisualDepthMask,
                                             &visualInfoTemplate,
//.........这里部分代码省略.........
开发者ID:venkatarajasekhar,项目名称:Qt,代码行数:101,代码来源:qxlibeglintegration.cpp


示例6: InitLocal

static DFBResult
InitLocal( AndroidData *android )
{
     /*
      * Here specify the attributes of the desired configuration.
      * Below, we select an EGLConfig with at least 8 bits per color
      * component compatible with on-screen windows
      */
     const EGLint attribs[] = {
             EGL_SURFACE_TYPE, EGL_WINDOW_BIT,
             EGL_BLUE_SIZE, 8,
             EGL_GREEN_SIZE, 8,
             EGL_RED_SIZE, 8,
             EGL_ALPHA_SIZE, 8,
             EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
             EGL_NATIVE_VISUAL_ID, HAL_PIXEL_FORMAT_RGBA_8888,    // DSPF_ARGB
             EGL_NONE
     };

     static const EGLint ctx_attribs[] = {
          EGL_CONTEXT_CLIENT_VERSION, 2,
          EGL_NONE
     };

     EGLint w, h, dummy, format;
     EGLint numConfigs;
     EGLConfig config;
     EGLSurface surface;
     EGLContext context;

     EGLDisplay display = eglGetDisplay(EGL_DEFAULT_DISPLAY);

     eglInitialize(display, 0, 0);

     /* Here, the application chooses the configuration it desires. In this
      * sample, we have a very simplified selection process, where we pick
      * the first EGLConfig that matches our criteria */
     eglChooseConfig(display, attribs, &config, 1, &numConfigs);

     /* EGL_NATIVE_VISUAL_ID is an attribute of the EGLConfig that is
      * guaranteed to be accepted by ANativeWindow_setBuffersGeometry().
      * As soon as we picked a EGLConfig, we can safely reconfigure the
      * ANativeWindow buffers to match, using EGL_NATIVE_VISUAL_ID. */
     eglGetConfigAttrib(display, config, EGL_NATIVE_VISUAL_ID, &format);

     ANativeWindow_setBuffersGeometry( native_data.app->window, 0, 0, format);

//     ANativeActivity_setWindowFlags( native_data.app->window, AWINDOW_FLAG_FULLSCREEN | AWINDOW_FLAG_KEEP_SCREEN_ON , 0 );

     surface = eglCreateWindowSurface(display, config, native_data.app->window, NULL);
     context = eglCreateContext(display, config, NULL, ctx_attribs);

     if (eglMakeCurrent(display, surface, surface, context) == EGL_FALSE) {
         LOGW("Unable to eglMakeCurrent");
         return -1;
     }

     eglQuerySurface(display, surface, EGL_WIDTH, &w);
     eglQuerySurface(display, surface, EGL_HEIGHT, &h);

     android->dpy = display;
     android->ctx = context;
     android->surface = surface;
     android->shared->screen_size.w = w;
     android->shared->screen_size.h = h;     

     if (strstr(glGetString(GL_RENDERER),"SGX"))
          android->shared->native_pixelformat = HAL_PIXEL_FORMAT_RGBA_8888; //ANativeWindow_getFormat(native_data.app->window);
     else
          android->shared->native_pixelformat = ANativeWindow_getFormat(native_data.app->window);

     // Initialize GL state.
//     glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_FASTEST);
     glEnable(GL_CULL_FACE);
//     glShadeModel(GL_SMOOTH);
     glDisable(GL_DEPTH_TEST);



     // Just fill the screen with a color.
     glClearColor( .5, .5, .5, 1 );
     glClear( GL_COLOR_BUFFER_BIT );

     eglSwapBuffers( android->dpy, android->surface );

     return DFB_OK;
}
开发者ID:lelou6666,项目名称:DirectFB-1.6.3-ab,代码行数:87,代码来源:android_system.c


示例7: eglGetDisplay


//.........这里部分代码省略.........
				{
					// Try lowering the MSAA sample size until we find a supported config
					int sampleCount = samples;
					while (sampleCount)
					{
						Log::GetLog()->Printf(Log::WARNING_CHN,"No EGL config found for depth_size=%d and samples=%d. Trying samples=%d instead.", depthSizes[i], sampleCount, sampleCount / 2);
						sampleCount /= 2;
						eglConfigAttrs[1] = sampleCount > 0 ? 1 : 0;
						eglConfigAttrs[3] = sampleCount;
						if (eglChooseConfig(__eglDisplay, eglConfigAttrs, &__eglConfig, 1, &eglConfigCount) == EGL_TRUE && eglConfigCount > 0)
						{
							validConfig = true;
							break;
						}
					}

					__multiSampling = sampleCount > 0;

					if (validConfig)
						break;
				}
				else
				{
					Log::GetLog()->Printf(Log::WARNING_CHN,"No EGL config found for depth_size=%d.", depthSizes[i]);
				}
			}

			if (!validConfig)
			{
				checkErrorEGL("eglChooseConfig");
				return;
			}else
				Log::GetLog()->Printf(Log::DBG_CHN,"eglChooseConfig");

			__eglContext = eglCreateContext(__eglDisplay, __eglConfig, EGL_NO_CONTEXT, eglContextAttrs);
			if (__eglContext == EGL_NO_CONTEXT)
			{
				checkErrorEGL("eglCreateContext");
				return;
			}
			else
				Log::GetLog()->Printf(Log::DBG_CHN,"eglCreateContext");
		}
		// EGL_NATIVE_VISUAL_ID is an attribute of the EGLConfig that is
		// guaranteed to be accepted by ANativeWindow_setBuffersGeometry().
		// As soon as we picked a EGLConfig, we can safely reconfigure the
		// ANativeWindow buffers to match, using EGL_NATIVE_VISUAL_ID.
		EGLint format;
		eglGetConfigAttrib(__eglDisplay, __eglConfig, EGL_NATIVE_VISUAL_ID, &format);
		Log::GetLog()->Printf(Log::DBG_CHN,"state addr=%d.",OS::state__);
		Log::GetLog()->Printf(Log::DBG_CHN,"wnd addr=%d.",OS::state__->window);
		ANativeWindow_setBuffersGeometry(OS::state__->window, 0, 0, format);
		__eglSurface = eglCreateWindowSurface(__eglDisplay, __eglConfig, OS::state__->window, eglSurfaceAttrs);
		if (__eglSurface == EGL_NO_SURFACE)
		{
			checkErrorEGL("eglCreateWindowSurface");
			return;
		}
		else
			Log::GetLog()->Printf(Log::DBG_CHN,"eglCreateWindowSurface");

		if (eglMakeCurrent(__eglDisplay, __eglSurface, __eglSurface, __eglContext) != EGL_TRUE)
		{
			checkErrorEGL("eglMakeCurrent");
			return;
		}
		else
			Log::GetLog()->Printf(Log::DBG_CHN,"eglMakeCurrent");

		EGLint szx = RenderConfig::GetInstance().back_buffer_sizex_;
		EGLint szy = RenderConfig::GetInstance().back_buffer_sizey_;
		eglQuerySurface(__eglDisplay, __eglSurface, EGL_WIDTH, &szx);
		eglQuerySurface(__eglDisplay, __eglSurface, EGL_HEIGHT, &szy);
		Log::GetLog()->Printf(Log::SYS_CHN, "target device width(%d),heigh(%d)",szx,szy);
		mainwnd->width_ = szx;
		mainwnd->height_ = szy;

		// Set vsync.
		eglSwapInterval(__eglDisplay, 1);

		// Initialize OpenGL ES extensions.
		_loadExtentions();

		if (_checkExtention("GL_OES_vertex_array_object") || _checkExtention("GL_ARB_vertex_array_object"))
		{
			// Disable VAO extension for now.
			glBindVertexArray = (PFNGLBINDVERTEXARRAYOESPROC)eglGetProcAddress("glBindVertexArrayOES");
			glDeleteVertexArrays = (PFNGLDELETEVERTEXARRAYSOESPROC)eglGetProcAddress("glDeleteVertexArrays");
			glGenVertexArrays = (PFNGLGENVERTEXARRAYSOESPROC)eglGetProcAddress("glGenVertexArraysOES");
			glIsVertexArray = (PFNGLISVERTEXARRAYOESPROC)eglGetProcAddress("glIsVertexArrayOES");
			if (glBindVertexArray)
			{
				Log::GetLog()->Printf(Log::SYS_CHN,"using vao");
			}
			
		}
		Log::GetLog()->Printf(Log::SYS_CHN, "gles device created");
		OS::state__->onAppCmd =engine_handle_cmd;
		OS::state__->onInputEvent =engine_handle_input;
	}
开发者ID:Garfield-Chen,项目名称:tng,代码行数:101,代码来源:gles_android.cpp


示例8: engine_init_display

/**
  * Initialize an EGL context for the current display.
  */
static int engine_init_display(struct engine* engine) 
{
  // initialize OpenGL ES and EGL
  
  /*
    * Here specify the attributes of the desired configuration.
    * Below, we select an EGLConfig with at least 8 bits per color
    * component compatible with on-screen windows
    */
  const EGLint attribs[] = 
  {
    EGL_SURFACE_TYPE, EGL_WINDOW_BIT,
    EGL_BLUE_SIZE, 8,
    EGL_GREEN_SIZE, 8,
    EGL_RED_SIZE, 8,
    EGL_NONE
  };
  EGLint w, h, dummy, format;
  EGLint numConfigs;
  EGLConfig config;
  EGLSurface surface;
  EGLContext context;
  
  EGLDisplay display = eglGetDisplay(EGL_DEFAULT_DISPLAY);
  
  eglInitialize(display, 0, 0);
  
  /* Here, the application chooses the configuration it desires. In this
    * sample, we have a very simplified selection process, where we pick
    * the first EGLConfig that matches our criteria */
  eglChooseConfig(display, attribs, &config, 1, &numConfigs);
  
  /* EGL_NATIVE_VISUAL_ID is an attribute of the EGLConfig that is
    * guaranteed to be accepted by ANativeWindow_setBuffersGeometry().
    * As soon as we picked a EGLConfig, we can safely reconfigure the
    * ANativeWindow buffers to match, using EGL_NATIVE_VISUAL_ID. */
  eglGetConfigAttrib(display, config, EGL_NATIVE_VISUAL_ID, &format);
  
  ANativeWindow_setBuffersGeometry(engine->app->window, 0, 0, format);
  
  surface = eglCreateWindowSurface(display, config, engine->app->window, NULL);
  context = eglCreateContext(display, config, NULL, NULL);
  
  if (eglMakeCurrent(display, surface, surface, context) == EGL_FALSE) 
  {
    LOGI("Unable to eglMakeCurrent");
    return -1;
  }
  
  eglQuerySurface(display, surface, EGL_WIDTH, &w);
  eglQuerySurface(display, surface, EGL_HEIGHT, &h);
  
  engine->display = display;
  engine->context = context;
  engine->surface = surface;
  engine->width = w;
  engine->height = h;
  engine->state.angle = 0;
  
  // Initialize GL state.
  glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_FASTEST);
  glEnable(GL_CULL_FACE);
  glShadeModel(GL_SMOOTH);
  glDisable(GL_DEPTH_TEST);
  
  return 0;
}
开发者ID:JamesLinus,项目名称:nui3,代码行数:70,代码来源:my_native_code.cpp


示例9: qgetenv

void QEglFSScreen::createAndSetPlatformContext()
{
    QPlatformWindowFormat platformFormat = QPlatformWindowFormat::defaultFormat();

    platformFormat.setWindowApi(QPlatformWindowFormat::OpenGL);

    QByteArray depthString = qgetenv("QT_QPA_EGLFS_DEPTH");
    if (depthString.toInt() == 16) {
        platformFormat.setDepth(16);
        platformFormat.setRedBufferSize(5);
        platformFormat.setGreenBufferSize(6);
        platformFormat.setBlueBufferSize(5);
        m_depth = 16;
        m_format = QImage::Format_RGB16;
    } else {
        platformFormat.setDepth(32);
        platformFormat.setRedBufferSize(8);
        platformFormat.setGreenBufferSize(8);
        platformFormat.setBlueBufferSize(8);
        m_depth = 32;
        m_format = QImage::Format_RGB32;
    }
    if (!qgetenv("QT_QPA_EGLFS_MULTISAMPLE").isEmpty()) {
        platformFormat.setSampleBuffers(true);
    }


    EGLConfig config = q_configFromQPlatformWindowFormat(m_dpy, platformFormat);

    EGLNativeWindowType eglWindow = 0;
#ifdef Q_OPENKODE
    if (kdInitializeNV() == KD_ENOTINITIALIZED) {
        qFatal("Did not manage to initialize openkode");
    }
    KDWindow *window = kdCreateWindow(m_dpy,config,0);

    kdRealizeWindow(window,&eglWindow);
#endif

    m_surface = eglCreateWindowSurface(m_dpy, config, eglWindow, NULL);
    if (m_surface == EGL_NO_SURFACE) {
        qWarning("Could not create the egl surface: error = 0x%x\n", eglGetError());
        eglTerminate(m_dpy);
        qFatal("EGL error");
    }
    //    qWarning("Created surface %dx%d\n", w, h);

#ifdef QEGL_EXTRA_DEBUG
    qWarning("Configuration %d matches requirements\n", (int)config);

    for (index = 0; attrs[index].attr != -1; ++index) {
        EGLint value;
        if (eglGetConfigAttrib(m_dpy, config, attrs[index].attr, &value)) {
            qWarning("\t%s: %d\n", attrs[index].name, (int)value);
        }
    }
    qWarning("\n");
#endif

    EGLint temp;
    EGLint attribList[32];

    temp = 0;

    attribList[temp++] = EGL_CONTEXT_CLIENT_VERSION;
    attribList[temp++] = 2; // GLES version 2
    attribList[temp++] = EGL_NONE;

    QEGLPlatformContext *platformContext = new QEGLPlatformContext(m_dpy,config,attribList,m_surface,EGL_OPENGL_ES_API);
    m_platformContext = platformContext;

    EGLint w,h;                    // screen size detection
    eglQuerySurface(m_dpy, m_surface, EGL_WIDTH, &w);
    eglQuerySurface(m_dpy, m_surface, EGL_HEIGHT, &h);

    m_geometry = QRect(0,0,w,h);

}
开发者ID:RS102839,项目名称:qt,代码行数:78,代码来源:qeglfsscreen.cpp


示例10: eglGetDisplay

bool SkOSWindow::attach(SkBackEndTypes attachType,
                        int /*msaaSampleCount*/,
                        bool /*deepColor*/
                        AttachmentInfo* info) {
    static const EGLint kEGLContextAttribsForOpenGL[] = {
        EGL_NONE
    };

    static const EGLint kEGLContextAttribsForOpenGLES[] = {
        EGL_CONTEXT_CLIENT_VERSION, 2,
        EGL_NONE
    };

    static const struct {
        const EGLint* fContextAttribs;
        EGLenum fAPI;
        EGLint  fRenderableTypeBit;
    } kAPIs[] = {
        {   // OpenGL
            kEGLContextAttribsForOpenGL,
            EGL_OPENGL_API,
            EGL_OPENGL_BIT,
        },
        {   // OpenGL ES. This seems to work for both ES2 and 3 (when available).
            kEGLContextAttribsForOpenGLES,
            EGL_OPENGL_ES_API,
            EGL_OPENGL_ES2_BIT,
        },
    };

    EGLDisplay display = eglGetDisplay(EGL_DEFAULT_DISPLAY);
    if (EGL_NO_DISPLAY == display) {
        return false;
    }

    EGLint majorVersion;
    EGLint minorVersion;
    if (!eglInitialize(display, &majorVersion, &minorVersion)) {
        return false;
    }

    for (size_t api = 0; api < SK_ARRAY_COUNT(kAPIs); ++api) {
        if (!eglBindAPI(kAPIs[api].fAPI)) {
            continue;
        }
#if 0
        SkDebugf("VENDOR: %s\n", eglQueryString(fDisplay, EGL_VENDOR));
        SkDebugf("APIS: %s\n", eglQueryString(fDisplay, EGL_CLIENT_APIS));
        SkDebugf("VERSION: %s\n", eglQueryString(fDisplay, EGL_VERSION));
        SkDebugf("EXTENSIONS %s\n", eglQueryString(fDisplay, EGL_EXTENSIONS));
#endif

        const EGLint configAttribs[] = {
            EGL_SURFACE_TYPE, EGL_PBUFFER_BIT,
            EGL_RENDERABLE_TYPE, kAPIs[api].fRenderableTypeBit,
            EGL_RED_SIZE, 8,
            EGL_GREEN_SIZE, 8,
            EGL_BLUE_SIZE, 8,
            EGL_ALPHA_SIZE, 8,
            EGL_NONE
        };

        EGLint format;
        EGLint numConfigs;
        EGLConfig config;
        EGLSurface surface;
        EGLContext context;

        /* Here, the application chooses the configuration it desires. In this
         * sample, we have a very simplified selection process, where we pick
         * the first EGLConfig that matches our criteria */
        if (!eglChooseConfig(display, configAttribs, &config, 1, &numConfigs) ||
            numConfigs != 1) {
            continue;
        }

        /* EGL_NATIVE_VISUAL_ID is an attribute of the EGLConfig that is
         * guaranteed to be accepted by ANativeWindow_setBuffersGeometry().
         * As soon as we picked a EGLConfig, we can safely reconfigure the
         * ANativeWindow buffers to match, using EGL_NATIVE_VISUAL_ID. */
        if (!eglGetConfigAttrib(display, config, EGL_NATIVE_VISUAL_ID, &format)) {
            continue;
        }

        ANativeWindow_setBuffersGeometry(fNativeWindow, 0, 0, format);

        surface = eglCreateWindowSurface(display, config, fNativeWindow, nullptr);
        if (EGL_NO_SURFACE == surface) {
            SkDebugf("eglCreateWindowSurface failed.  EGL Error: 0x%08x\n", eglGetError());
            continue;
        }
        context = eglCreateContext(display, config, nullptr, kAPIs[api].fContextAttribs);
        if (EGL_NO_CONTEXT == context) {
            SkDebugf("eglCreateContext failed.  EGL Error: 0x%08x\n", eglGetError());
            eglDestroySurface(display, surface);
            continue;
        }

        if (!eglMakeCurrent(display, surface, surface, context)) {
            SkDebugf("eglMakeCurrent failed.  EGL Error: 0x%08x\n", eglGetError());
//.........这里部分代码省略.........
开发者ID:kyawkyaw,项目名称:skia,代码行数:101,代码来源:SkOSWindow_AndroidNative.cpp


示例11: eglGetDisplay

bool Game::InitDisplay()
{
   /*
   * Here specify the attributes of the desired configuration.
   * Below, we select an EGLConfig with at least 8 bits per color
   * component compatible with on-screen windows
   */
   const EGLint attribs[] =
   {
      EGL_RED_SIZE,        8,
      EGL_GREEN_SIZE,      8,
      EGL_BLUE_SIZE,       8,
      EGL_SURFACE_TYPE,    EGL_WINDOW_BIT,
      EGL_DEPTH_SIZE,      24,
      EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT, //Maybe EGL_CONFORMANT for windows and Android?
      EGL_NONE
   };
   EGLint attrib_list[]= { EGL_RED_SIZE,        8,
                           EGL_GREEN_SIZE,      8,
                           EGL_BLUE_SIZE,       8,
                           EGL_SURFACE_TYPE,    EGL_WINDOW_BIT,
                           EGL_RENDERABLE_TYPE, 0,
                           EGL_NONE};

   EGLint w, h, format;
   EGLint numConfigs;
   EGLConfig config[64];
   EGLSurface surface;
   EGLContext context;

   EGLDisplay display = eglGetDisplay(EGL_DEFAULT_DISPLAY);

   int maj;
   int min;
   eglInitialize(display, &maj, &min);
   Log::Debug("EGLInitialise", "EGL Major:%d Minor:%d", maj, min);

   /* Here, the application chooses the configuration it desires. In this
   * sample, we have a very simplified selection process, where we pick
   * the first EGLConfig that matches our criteria */
   eglChooseConfig(display, attribs, &config[0], 64, &numConfigs);

   for(int i = 0; i < numConfigs; i++)
   {
      int val[1];
      eglGetConfigAttrib(display, config[i], EGL_CONFORMANT, &val[0]);
      Log::Debug("EGLInitialise", "EGL_CONFORMANT: %d", val[0]);
      Log::Debug("EGLInitialise", "GL2: %d", val[0] & EGL_OPENGL_ES2_BIT);
      Log::Debug("EGLInitialise", "GL1: %d", val[0] & EGL_OPENGL_ES_BIT);
   }

   if(numConfigs == 0)
   {
      Log::Error("EGLInitialise", "No EGL configs were returned.");
      return true;
   }

   /* EGL_NATIVE_VISUAL_ID is an attribute of the EGLConfig that is
   * guaranteed to be accepted by ANativeWindow_setBuffersGeometry().
   * As soon as we picked a EGLConfig, we can safely reconfigure the
   * ANativeWindow buffers to match, using EGL_NATIVE_VISUAL_ID. */
   eglGetConfigAttrib(display, config[0], EGL_NATIVE_VISUAL_ID, &format);

#ifdef ANDROID
   ANativeWindow_setBuffersGeometry(mDisplay.app->window, 0, 0, format); //TODO!
   surface = eglCreateWindowSurface(display, config[0], mDisplay.app->window, NULL);
#endif
#ifdef _WIN32
   mDisplay.WindowHandle = create_window(mDisplay.Width, mDisplay.Height);
   surface = EGL_CHECK(eglCreateWindowSurface(display, config[0], (EGLNativeWindowType)mDisplay.WindowHandle, NULL));
#endif
#ifdef __QNX__
   int screen_format = SCREEN_FORMAT_RGBX8888;
   int usage = SCREEN_USAGE_OPENGL_ES2 | SCREEN_USAGE_ROTATION;
   int screen_resolution[2];
   screen_display_mode_t screen_mode;
   int size[2];
   int angle = std::atoi(std::getenv("ORIENTATION"));

   screen_create_window(&mDisplay.qnx_screen_win, mDisplay.qnx_screen_context);
   screen_set_window_property_iv(mDisplay.qnx_screen_win, SCREEN_PROPERTY_FORMAT, &screen_format);
   screen_set_window_property_iv(mDisplay.qnx_screen_win, SCREEN_PROPERTY_USAGE, &usage);
   screen_get_window_property_pv(mDisplay.qnx_screen_win, SCREEN_PROPERTY_DISPLAY, (void **)&mDisplay.qnx_screen_disp);
   screen_get_display_property_iv(mDisplay.qnx_screen_disp, SCREEN_PROPERTY_SIZE, screen_resolution);
   screen_get_display_property_pv(mDisplay.qnx_screen_disp, SCREEN_PROPERTY_MODE, (void**)&screen_mode);
   screen_get_window_property_iv(mDisplay.qnx_screen_win, SCREEN_PROPERTY_BUFFER_SIZE, size);

   int buffer_size[2] = {size[0], size[1]};

   if ((angle == 0) || (angle == 180)) {
       if (((screen_mode.width > screen_mode.height) && (size[0] < size[1])) ||
           ((screen_mode.width < screen_mode.height) && (size[0] > size[1]))) {
               buffer_size[1] = size[0];
               buffer_size[0] = size[1];
       }
   } else if ((angle == 90) || (angle == 270)){
       if (((screen_mode.width > screen_mode.height) && (size[0] > size[1])) ||
           ((screen_mode.width < screen_mode.height && size[0] < size[1]))) {
               buffer_size[1] = size[0];
               buffer_size[0] = size[1];
//.........这里部分代码省略.........
开发者ID:danishcake,项目名称:CrossPlatformDefense,代码行数:101,代码来源:Game.cpp


示例12: startDriver

void
startDriver() {
	x_dpy = XOpenDisplay(NULL);
	if (!x_dpy) {
		fprintf(stderr, "XOpenDisplay failed\n");
		exit(1);
	}
	e_dpy = eglGetDisplay(x_dpy);
	if (!e_dpy) {
		fprintf(stderr, "eglGetDisplay failed: %s\n", eglGetErrorStr());
		exit(1);
	}
	EGLint e_major, e_minor;
	if (!eglInitialize(e_dpy, &e_major, &e_minor)) {
		fprintf(stderr, "eglInitialize failed: %s\n", eglGetErrorStr());
		exit(1);
	}
	if (!eglBindAPI(EGL_OPENGL_ES_API)) {
		fprintf(stderr, "eglBindAPI failed: %s\n", eglGetErrorStr());
		exit(1);
	}

	static const EGLint attribs[] = {
		EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
		EGL_SURFACE_TYPE, EGL_WINDOW_BIT,
		EGL_BLUE_SIZE, 8,
		EGL_GREEN_SIZE, 8,
		EGL_RED_SIZE, 8,
		EGL_DEPTH_SIZE, 16,
		EGL_CONFIG_CAVEAT, EGL_NONE,
		EGL_NONE
	};
	EGLint num_configs;
	if (!eglChooseConfig(e_dpy, attribs, &e_config, 1, &num_configs)) {
		fprintf(stderr, "eglChooseConfig failed: %s\n", eglGetErrorStr());
		exit(1);
	}
	EGLint vid;
	if (!eglGetConfigAttrib(e_dpy, e_config, EGL_NATIVE_VISUAL_ID, &vid)) {
		fprintf(stderr, "eglGetConfigAttrib failed: %s\n", eglGetErrorStr());
		exit(1);
	}

	XVisualInfo visTemplate;
	visTemplate.visualid = vid;
	int num_visuals;
	x_visual_info = XGetVisualInfo(x_dpy, VisualIDMask, &visTemplate, &num_visuals);
	if (!x_visual_info) {
		fprintf(stderr, "XGetVisualInfo failed\n");
		exit(1);
	}

	x_root = RootWindow(x_dpy, DefaultScreen(x_dpy));
	x_colormap = XCreateColormap(x_dpy, x_root, x_visual_info->visual, AllocNone);
	if (!x_colormap) {
		fprintf(stderr, "XCreateColormap failed\n");
		exit(1);
	}

	static const EGLint ctx_attribs[] = {
		EGL_CONTEXT_CLIENT_VERSION, 3,
		EGL_NONE
	};
	e_ctx = eglCreateContext(e_dpy, e_config, EGL_NO_CONTEXT, ctx_attribs);
	if (!e_ctx) {
		fprintf(stderr, "eglCreateContext failed: %s\n", eglGetErrorStr());
		exit(1);
	}

	wm_delete_window = XInternAtom(x_dpy, "WM_DELETE_WINDOW", False);
	wm_protocols = XInternAtom(x_dpy, "WM_PROTOCOLS", False);
	wm_take_focus= XInternAtom(x_dpy, "WM_TAKE_FOCUS", False);

	const int key_lo = 8;
	const int key_hi = 255;
	int keysyms_per_keycode;
	KeySym *keysyms = XGetKeyboardMapping(x_dpy, key_lo, key_hi-key_lo+1, &keysyms_per_keycode);
	if (keysyms_per_keycode < 2) {
		fprintf(stderr, "XGetKeyboardMapping returned too few keysyms per keycode: %d\n", keysyms_per_keycode);
		exit(1);
	}
	int k;
	for (k = key_lo; k <= key_hi; k++) {
		onKeysym(k,
			keysyms[(k-key_lo)*keysyms_per_keycode + 0],
			keysyms[(k-key_lo)*keysyms_per_keycode + 1]);
	}
}
开发者ID:destenson,项目名称:keybase--client,代码行数:88,代码来源:x11.c


示例13: engine_init_display

// EGL初期化
static int engine_init_display(struct engine* engine) {

  EGLint w, h, dummy, format;
  EGLint numConfigs;
  EGLConfig config;
  EGLSurface surface;
  EGLContext context;

  // 有効にするEGLパラメータ
  const EGLint attribs[] = 
    {
      // サーフェイスのタイプを指定(ダブルバッファを利用するのでEGL_WINDOW_BIT)
      EGL_SURFACE_TYPE, EGL_WINDOW_BIT,
      // 青が利用する最小フレームサイズ(単位はbit)
      EGL_BLUE_SIZE,  8,
      // 緑が利用する最小フレームサイズ(単位はbit)
      EGL_GREEN_SIZE, 8,
      // 赤が利用する最小フレームサイズ(単位はbit)
      EGL_RED_SIZE,   8,
      // デプスバッファとして確保するサイズ(単位はbit)
      EGL_DEPTH_SIZE, 16,
      // 終端
      EGL_NONE }; 

  // EGLディスプレイコネクションを取得
  EGLDisplay display = eglGetDisplay(EGL_DEFAULT_DISPLAY);
  // EGLディスプレイコネクション初期化
  eglInitialize(display, 0, 0);
  // 条件に合ったEGLフレームバッファ設定のリストを返す
  eglChooseConfig(display, attribs, &config, 1, &numConfigs);
  // EGLフレームバッファ設定の情報を取得
  eglGetConfigAttrib(display, config, EGL_NATIVE_VISUAL_ID, &format);
  // NativeActivityへバッファを設定
  ANativeWindow_setBuffersGeometry(engine->app->window, 0, 0, format);
  // EGLウィンドウサーフェイスの取得
  surface = eglCreateWindowSurface(display, config, engine->app->window,
                                   NULL);
  // EGLレンダリングコンテキストの取得
  context = eglCreateContext(display, config, NULL, NULL);
  // EGLレンダリングコンテキストをEGLサーフェイスにアタッチする
  if (eglMakeCurrent(display, surface, surface, context) == EGL_FALSE) {
    LOGW("Unable to eglMakeCurrent");
    return -1;
  }

  // 画面解像度取得
  eglQuerySurface(display, surface, EGL_WIDTH, &w);
  eglQuerySurface(display, surface, EGL_HEIGHT, &h);

  // EGL関連データの保存
  engine->display = display;
  engine->context = context;
  engine->surface = surface;

  // 画面解像度の保存
  engine->width = w;
  engine->height = h;

  // 初期値設定
  int j; 
  for (j = 0; j < 3; j++){
    engine->angle[j] = 0;
  }

  // 立方体表示の初期化
  initCube(engine); 

  return 0;
}
开发者ID:fukusyo,项目名称:NDKBook_2nd,代码行数:70,代码来源:main.c


示例14: eglGetPlatformDisplayEXT

bool EGLWindow::initializeGL(OSWindow *osWindow)
{
    PFNEGLGETPLATFORMDISPLAYEXTPROC eglGetPlatformDisplayEXT = reinterpret_cast<PFNEGLGETPLATFORMDISPLAYEXTPROC>(eglGetProcAddress("eglGetPlatformDisplayEXT"));
    if (!eglGetPlatformDisplayEXT)
    {
        return false;
    }

    std::vector<EGLint> displayAttributes;
    displayAttributes.push_back(EGL_PLATFORM_ANGLE_TYPE_ANGLE);
    displayAttributes.push_back(mPlatform.renderer);
    displayAttributes.push_back(EGL_PLATFORM_ANGLE_MAX_VERSION_MAJOR_ANGLE);
    displayAttributes.push_back(mPlatform.majorVersion);
    displayAttributes.push_back(EGL_PLATFORM_ANGLE_MAX_VERSION_MINOR_ANGLE);
    displayAttributes.push_back(mPlatform.minorVersion);

    if (mPlatform.deviceType != EGL_DONT_CARE)
    {
        displayAttributes.push_back(EGL_PLATFORM_ANGLE_DEVICE_TYPE_ANGLE);
        displayAttributes.push_back(mPlatform.deviceType);
    }
    displayAttributes.push_back(EGL_NONE);

    mDisplay = eglGetPlatformDisplayEXT(EGL_PLATFORM_ANGLE_ANGLE, osWindow->getNativeDisplay(), &displayAttributes[0]);
    if (mDisplay == EGL_NO_DISPLAY)
    {
        destroyGL();
        return false;
    }

    EGLint majorVersion, minorVersion;
    if (eglInitialize(mDisplay, &majorVersion, &minorVersion) == EGL_FALSE)
    {
        destroyGL();
        return false;
    }

    eglBindAPI(EGL_OPENGL_ES_API);
    if (eglGetError() != EGL_SUCCESS)
    {
        destroyGL();
        return false;
    }

    const EGLint configAttributes[] =
    {
        EGL_RED_SIZE,       (mRedBits >= 0)     ? mRedBits     : EGL_DONT_CARE,
        EGL_GREEN_SIZE,     (mGreenBits >= 0)   ? mGreenBits   : EGL_DONT_CARE,
        EGL_BLUE_SIZE,      (mBlueBits >= 0)    ? mBlueBits    : EGL_DONT_CARE,
        EGL_ALPHA_SIZE,     (mAlphaBits >= 0)   ? mAlphaBits   : EGL_DONT_CARE,
        EGL_DEPTH_SIZE,     (mDepthBits >= 0)   ? mDepthBits   : EGL_DONT_CARE,
        EGL_STENCIL_SIZE,   (mStencilBits >= 0) ? mStencilBits : EGL_DONT_CARE,
        EGL_SAMPLE_BUFFERS, mMultisample ? 1 : 0,
        EGL_NONE
    };

    EGLint configCount;
    if (!eglChooseConfig(mDisplay, configAttributes, &mConfig, 1, &configCount) || (configCount != 1))
    {
        destroyGL();
        return false;
    }

    eglGetConfigAttrib(mDisplay, mConfig, EGL_RED_SIZE, &mRedBits);
    eglGetConfigAttrib(mDisplay, mConfig, EGL_GREEN_SIZE, &mGreenBits);
    eglGetConfigAttrib(mDisplay, mConfig, EGL_BLUE_SIZE, &mBlueBits);
    eglGetConfigAttrib(mDisplay, mConfig, EGL_ALPHA_SIZE, &mBlueBits);
    eglGetConfigAttrib(mDisplay, mConfig, EGL_DEPTH_SIZE, &mDepthBits);
    eglGetConfigAttrib(mDisplay, mConfig, EGL_STENCIL_SIZE, &mStencilBits);

    std::vector<EGLint> surfaceAttributes;
    if (strstr(eglQueryString(mDisplay, EGL_EXTENSIONS), "EGL_NV_post_sub_buffer") != nullptr)
    {
        surfaceAttributes.push_back(EGL_POST_SUB_BUFFER_SUPPORTED_NV);
        surfaceAttributes.push_back(EGL_TRUE);
    }

    surfaceAttributes.push_back(EGL_NONE);

    mSurface = eglCreateWindowSurface(mDisplay, mConfig, osWindow->getNativeWindow(), &surfaceAttributes[0]);
    if (eglGetError() != EGL_SUCCESS)
    {
        destroyGL();
        return false;
    }
    ASSERT(mSurface != EGL_NO_SURFACE);

    EGLint contextAttibutes[] =
    {
        EGL_CONTEXT_CLIENT_VERSION, mClientVersion,
        EGL_NONE
    };

    mContext = eglCreateContext(mDisplay, mConfig, NULL, contextAttibutes);
    if (eglGetError() != EGL_SUCCESS)
    {
        destroyGL();
        return false;
    }

//.........这里部分代码省略.........
开发者ID:mariospr,项目名称:chromium-browser,代码行数:101,代码来源:EGLWindow.cpp


示例15: ANKI_LOGI


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ eglGetConfigs函数代码示例发布时间:2022-05-30
下一篇:
C++ eglDestroyImageKHR函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap