本文整理汇总了C++中ContextPtr::GetNativeContext方法的典型用法代码示例。如果您正苦于以下问题:C++ ContextPtr::GetNativeContext方法的具体用法?C++ ContextPtr::GetNativeContext怎么用?C++ ContextPtr::GetNativeContext使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ContextPtr
的用法示例。
在下文中一共展示了ContextPtr::GetNativeContext方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: eglQueryContext
// Get the attribute value for the specified rendering context.
EGLBoolean eglQueryContext(EGLDisplay dpy, EGLContext ctx, EGLint attribute,
EGLint* value) {
EGL_API_ENTRY("%p, %p, 0x%x, %p", dpy, ctx, attribute, value);
EglDisplayImpl* display = EglDisplayImpl::GetDisplay(dpy);
if (display == NULL || display->IsInitialized() == false) {
SetError(EGL_BAD_DISPLAY);
return EGL_FALSE;
}
ContextPtr context = display->GetContexts().Get(ctx);
if (context == NULL) {
SetError(EGL_BAD_CONTEXT);
return EGL_FALSE;
}
switch (attribute) {
case EGL_CONFIG_ID:
return display->GetConfigAttribute(context->config, attribute, value);
case EGL_CONTEXT_CLIENT_TYPE:
*value = EGL_OPENGL_ES_API;
return EGL_TRUE;
case EGL_CONTEXT_CLIENT_VERSION:
*value = context->GetVersion();
return EGL_TRUE;
case EGL_RENDER_BUFFER:
if (context->GetSurface() == NULL)
*value = EGL_NONE;
else
*value = EGL_BACK_BUFFER; // single buffer not supported
return EGL_TRUE;
case EGL_ARC_UNDERLYING_CONTEXT: {
NativeContext* native = context->GetNativeContext();
*value = reinterpret_cast<EGLint>(Native::GetUnderlyingContext(native));
return EGL_TRUE;
}
default:
ALOGE("Unsupported attribute: %x", attribute);
SetError(EGL_BAD_ATTRIBUTE);
return EGL_FALSE;
}
}
示例2: Initialize
void EglDisplayImpl::Initialize() {
Mutex::Autolock mutex(&lock_);
if (initialized_) {
return;
}
window_ = Native::CreateNativeWindow();
LOG_ALWAYS_FATAL_IF(!window_, "Could not create native window.");
EGLConfig cfg = NULL;
for (ConfigSet::iterator it = configs_.begin(); it != configs_.end(); ++it) {
const EGLint r = it->GetValue(EGL_RED_SIZE);
const EGLint g = it->GetValue(EGL_GREEN_SIZE);
const EGLint b = it->GetValue(EGL_BLUE_SIZE);
if (r > 0 && g > 0 && b > 0) {
cfg = it->GetKey();
break;
}
}
EGLint err = 0;
global_context_ = EglContextImpl::Create(kDefaultDisplay, cfg, NULL, 2, &err);
// Bind the window surface here in order for the compositor to be associated
// with the correct context. (The compositor associates itself to the first
// surface that is bound.)
ContextPtr ctx = contexts_.Get(global_context_);
Native::BindNativeWindow(window_, ctx->GetNativeContext());
// Force the GlesContext owned by the global context to be initialized at
// least once.
EglThreadInfo& info = EglThreadInfo::GetInstance();
info.SetCurrentContext(ctx);
ctx->GetGlesContext()->OnMakeCurrent();
info.SetCurrentContext(ContextPtr());
initialized_ = true;
}