コード例 #1
1
ファイル: eglplatform.cpp プロジェクト: Plombo/micropolis
bool EGLPlatform::initSurface()
{
	// create the surface
#if USE_PBUFFER
	EGLint attribs[] = {
		EGL_WIDTH, width,
		EGL_HEIGHT, height,
		EGL_TEXTURE_FORMAT, EGL_TEXTURE_RGBA,
		EGL_TEXTURE_TARGET, EGL_TEXTURE_2D,
		EGL_NONE
	};
	this->surface = eglCreatePbufferSurface(this->display, this->config, attribs);
#elif USE_PIXMAP
	EGLint attribs[] = {EGL_NONE};
	this->surface = eglCreatePixmapSurface(this->display, this->config, this->pixmap, attribs);
#else
	EGLint attribs[] = {EGL_NONE};
	this->surface = eglCreateWindowSurface(this->display, this->config, this->window, NULL);
#endif
	if(this->surface == EGL_NO_SURFACE)
	{
		printf("Error: EGL surface creation failed (error code: 0x%x)\n", eglGetError());
		return false;
	}
	
	return true;
}
コード例 #2
1
EglContext::EglContext(EglContext* shared) :
m_display (EGL_NO_DISPLAY),
m_context (EGL_NO_CONTEXT),
m_surface (EGL_NO_SURFACE),
m_config  (NULL)
{
    // Get the initialized EGL display
    m_display = getInitializedDisplay();

    // Get the best EGL config matching the default video settings
    m_config = getBestConfig(m_display, VideoMode::getDesktopMode().bitsPerPixel, ContextSettings());
    updateSettings();

    // Note: The EGL specs say that attrib_list can be NULL when passed to eglCreatePbufferSurface,
    // but this is resulting in a segfault. Bug in Android?
    EGLint attrib_list[] = {
        EGL_WIDTH, 1,
        EGL_HEIGHT,1,
        EGL_NONE
    };

    m_surface = eglCheck(eglCreatePbufferSurface(m_display, m_config, attrib_list));

    // Create EGL context
    createContext(shared);
}
コード例 #3
1
ファイル: EGLDisplayOpenVG.cpp プロジェクト: 1833183060/wke
EGLSurface EGLDisplayOpenVG::createPbufferSurface(const IntSize& size, const EGLConfig& config, EGLint* errorCode)
{
    const EGLint attribList[] = {
        EGL_WIDTH, size.width(),
        EGL_HEIGHT, size.height(),
        EGL_NONE
    };
    EGLSurface surface = eglCreatePbufferSurface(m_display, config, attribList);

    if (errorCode)
        *errorCode = eglGetError();
    else
        ASSERT_EGL_NO_ERROR();

    if (surface == EGL_NO_SURFACE)
        return EGL_NO_SURFACE;

    EGLint surfaceConfigId;
    EGLBoolean success = eglGetConfigAttrib(m_display, config, EGL_CONFIG_ID, &surfaceConfigId);
    ASSERT(success == EGL_TRUE);
    ASSERT(surfaceConfigId != EGL_BAD_ATTRIBUTE);

    ASSERT(!m_surfaceConfigIds.contains(surface));
    m_surfaceConfigIds.set(surface, surfaceConfigId);
    return surface;
}
コード例 #4
0
ファイル: glesbox.cpp プロジェクト: buffer8848/glesbox
bool GlesBox::createSurface(uint32_t width, uint32_t height, uint64_t native_windows_id) {
  if (core_->surface_ != nullptr) {
    eglDestroySurface(core_->surface_, core_->surface_);
    core_->surface_ = nullptr;
  }

  // Create a surface
  core_->width_ = width;
  core_->height_ = height;
  EGLint PBufAttribs[] = { 
    EGL_WIDTH, (EGLint)core_->width_,
    EGL_HEIGHT, (EGLint)core_->height_,
    EGL_LARGEST_PBUFFER, EGL_TRUE,
    EGL_NONE
  };
  if (native_windows_id != 0) {//attach on native windows
    EGLNativeWindowType handle = reinterpret_cast<EGLNativeWindowType>(native_windows_id);
    core_->surface_ = eglCreateWindowSurface(core_->display_, core_->config_, handle, NULL);
  }
  else // off-render
    core_->surface_ = eglCreatePbufferSurface(core_->display_, core_->config_, PBufAttribs);

  if (core_->surface_ == EGL_NO_SURFACE) {
    LOGE("eglCreateWindowSurface fail: %d.", eglGetError());
    return false;
  }

  return true;
}
コード例 #5
0
JNIEXPORT jlong JNICALL Java_org_lwjgl_opengles_EGL_neglCreatePbufferSurface(JNIEnv *env, jclass clazz, jlong dpy_ptr, jlong config_ptr, jlong attrib_list) {
    EGLDisplay dpy = (EGLDisplay)(intptr_t)dpy_ptr;
    EGLConfig config = (EGLConfig)(intptr_t)config_ptr;
    const EGLint *attrib_list_address = (EGLint *)(intptr_t)attrib_list;

    return (intptr_t)eglCreatePbufferSurface(dpy, config, attrib_list_address);
}
コード例 #6
0
ファイル: bindtex.c プロジェクト: Distrotech/mesa-demos
static void
make_pbuffer(int width, int height)
{
   static const EGLint config_attribs[] = {
      EGL_RED_SIZE, 8,
      EGL_GREEN_SIZE, 8,
      EGL_BLUE_SIZE, 8,
      EGL_BIND_TO_TEXTURE_RGB, EGL_TRUE,
      EGL_NONE
   };
   EGLint pbuf_attribs[] = {
      EGL_WIDTH, width,
      EGL_HEIGHT, height,
      EGL_TEXTURE_FORMAT, EGL_TEXTURE_RGB,
      EGL_TEXTURE_TARGET, EGL_TEXTURE_2D,
      EGL_NONE
   };
   EGLConfig config;
   EGLint num_configs;

   if (!eglChooseConfig(dpy, config_attribs, &config, 1, &num_configs) ||
       !num_configs) {
      printf("Error: couldn't get an EGL visual config for pbuffer\n");
      exit(1);
   }

   ctx_pbuf = eglCreateContext(dpy, config, EGL_NO_CONTEXT, NULL );
   surf_pbuf = eglCreatePbufferSurface(dpy, config, pbuf_attribs);
   if (surf_pbuf == EGL_NO_SURFACE) {
      printf("failed to allocate pbuffer\n");
      exit(1);
   }
}
コード例 #7
0
static gboolean
make_dummy_surface (ClutterBackendWayland *backend_wayland)
{
  static const EGLint attrs[] = {
    EGL_WIDTH, 1,
    EGL_HEIGHT, 1,
    EGL_RENDERABLE_TYPE, _COGL_RENDERABLE_BIT,
    EGL_NONE };
  EGLint num_configs;

  eglGetConfigs(backend_wayland->edpy,
                &backend_wayland->egl_config, 1, &num_configs);
  if (num_configs < 1)
    return FALSE;

  backend_wayland->egl_surface =
    eglCreatePbufferSurface(backend_wayland->edpy,
                            backend_wayland->egl_config,
                            attrs);

  if (backend_wayland->egl_surface == EGL_NO_SURFACE)
    return FALSE;

  return TRUE;
}
コード例 #8
0
/* EGLSurface eglCreatePbufferSurface ( EGLDisplay dpy, EGLConfig config, const EGLint *attrib_list ) */
static jobject
android_eglCreatePbufferSurface
  (JNIEnv *_env, jobject _this, jobject dpy, jobject config, jintArray attrib_list_ref, jint offset) {
    jint _exception = 0;
    const char * _exceptionType = NULL;
    const char * _exceptionMessage = NULL;
    EGLSurface _returnValue = (EGLSurface) 0;
    EGLDisplay dpy_native = (EGLDisplay) fromEGLHandle(_env, egldisplayGetHandleID, dpy);
    EGLConfig config_native = (EGLConfig) fromEGLHandle(_env, eglconfigGetHandleID, config);
    bool attrib_list_sentinel = false;
    EGLint *attrib_list_base = (EGLint *) 0;
    jint _remaining;
    EGLint *attrib_list = (EGLint *) 0;

    if (!attrib_list_ref) {
        _exception = 1;
        _exceptionType = "java/lang/IllegalArgumentException";
        _exceptionMessage = "attrib_list == null";
        goto exit;
    }
    if (offset < 0) {
        _exception = 1;
        _exceptionType = "java/lang/IllegalArgumentException";
        _exceptionMessage = "offset < 0";
        goto exit;
    }
    _remaining = _env->GetArrayLength(attrib_list_ref) - offset;
    attrib_list_base = (EGLint *)
        _env->GetPrimitiveArrayCritical(attrib_list_ref, (jboolean *)0);
    attrib_list = attrib_list_base + offset;
    attrib_list_sentinel = false;
    for (int i = _remaining - 1; i >= 0; i--)  {
        if (attrib_list[i] == EGL_NONE){
            attrib_list_sentinel = true;
            break;
        }
    }
    if (attrib_list_sentinel == false) {
        _exception = 1;
        _exceptionType = "java/lang/IllegalArgumentException";
        _exceptionMessage = "attrib_list must contain EGL_NONE!";
        goto exit;
    }

    _returnValue = eglCreatePbufferSurface(
        (EGLDisplay)dpy_native,
        (EGLConfig)config_native,
        (EGLint *)attrib_list
    );

exit:
    if (attrib_list_base) {
        _env->ReleasePrimitiveArrayCritical(attrib_list_ref, attrib_list_base,
            JNI_ABORT);
    }
    if (_exception) {
        jniThrowException(_env, _exceptionType, _exceptionMessage);
    }
    return toEGLHandle(_env, eglsurfaceClass, eglsurfaceConstructor, _returnValue);
}
コード例 #9
0
SkANGLEGLContext::SkANGLEGLContext()
    : fContext(EGL_NO_CONTEXT)
    , fDisplay(EGL_NO_DISPLAY)
    , fSurface(EGL_NO_SURFACE) {

    EGLint numConfigs;
    static const EGLint configAttribs[] = {
        EGL_SURFACE_TYPE, EGL_PBUFFER_BIT,
        EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
        EGL_RED_SIZE, 8,
        EGL_GREEN_SIZE, 8,
        EGL_BLUE_SIZE, 8,
        EGL_ALPHA_SIZE, 8,
        EGL_NONE
    };

    fDisplay = GetD3DEGLDisplay(EGL_DEFAULT_DISPLAY);
    if (EGL_NO_DISPLAY == fDisplay) {
        SkDebugf("Could not create EGL display!");
        return;
    }

    EGLint majorVersion;
    EGLint minorVersion;
    eglInitialize(fDisplay, &majorVersion, &minorVersion);

    EGLConfig surfaceConfig;
    eglChooseConfig(fDisplay, configAttribs, &surfaceConfig, 1, &numConfigs);

    static const EGLint contextAttribs[] = {
        EGL_CONTEXT_CLIENT_VERSION, 2,
        EGL_NONE
    };
    fContext = eglCreateContext(fDisplay, surfaceConfig, NULL, contextAttribs);


    static const EGLint surfaceAttribs[] = {
        EGL_WIDTH, 1,
        EGL_HEIGHT, 1,
        EGL_NONE
    };

    fSurface = eglCreatePbufferSurface(fDisplay, surfaceConfig, surfaceAttribs);

    eglMakeCurrent(fDisplay, fSurface, fSurface, fContext);

    SkAutoTUnref<const GrGLInterface> gl(GrGLCreateANGLEInterface());
    if (NULL == gl.get()) {
        SkDebugf("Could not create ANGLE GL interface!\n");
        this->destroyGLContext();
        return;
    }
    if (!gl->validate()) {
        SkDebugf("Could not validate ANGLE GL interface!\n");
        this->destroyGLContext();
        return;
    }

    this->init(gl.detach());
}
コード例 #10
0
PassOwnPtr<GLContextEGL> GLContextEGL::createPbufferContext(EGLContext sharingContext)
{
#if !PLATFORM(JS)
    EGLDisplay display = sharedEGLDisplay();
    if (display == EGL_NO_DISPLAY)
        return nullptr;

    EGLConfig config;
    if (!getEGLConfig(&config, PbufferSurface))
        return nullptr;

    EGLContext context = eglCreateContext(display, config, sharingContext, gContextAttributes);
    if (context == EGL_NO_CONTEXT)
        return nullptr;

    static const int pbufferAttributes[] = { EGL_WIDTH, 1, EGL_HEIGHT, 1, EGL_NONE };
    EGLSurface surface = eglCreatePbufferSurface(display, config, pbufferAttributes);
    if (surface == EGL_NO_SURFACE) {
        eglDestroyContext(display, context);
        return nullptr;
    }

    return adoptPtr(new GLContextEGL(context, surface, PbufferSurface));
#else
    return nullptr;
#endif
}
コード例 #11
0
ファイル: test-compiler.c プロジェクト: Dm47021/freedreno-1
int main(int argc, char *argv[])
{
	GLint width, height;
	EGLint pbuffer_attribute_list[] = {
		EGL_WIDTH, 256,
		EGL_HEIGHT, 256,
		EGL_LARGEST_PBUFFER, EGL_TRUE,
		EGL_NONE
	};
	const EGLint config_attribute_list[] = {
		EGL_RED_SIZE, 8,
		EGL_GREEN_SIZE, 8,
		EGL_BLUE_SIZE, 8,
		EGL_SURFACE_TYPE, EGL_PBUFFER_BIT,
		EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
		EGL_DEPTH_SIZE, 8,
		EGL_NONE
	};
	const EGLint context_attribute_list[] = {
		EGL_CONTEXT_CLIENT_VERSION, 2,
		EGL_NONE
	};
	EGLDisplay display;
	EGLConfig config;
	EGLint num_config;
	EGLContext context;
	EGLSurface surface;
	int i;

	display = get_display();

	/* get an appropriate EGL frame buffer configuration */
	ECHK(eglChooseConfig(display, config_attribute_list, &config, 1, &num_config));
	DEBUG_MSG("num_config: %d", num_config);

	/* create an EGL rendering context */
	ECHK(context = eglCreateContext(display, config, EGL_NO_CONTEXT, context_attribute_list));
	ECHK(surface = eglCreatePbufferSurface(display, config, pbuffer_attribute_list));

	ECHK(eglQuerySurface(display, surface, EGL_WIDTH, &width));
	ECHK(eglQuerySurface(display, surface, EGL_HEIGHT, &height));

	DEBUG_MSG("PBuffer: %dx%d", width, height);

	/* connect the context to the surface */
	ECHK(eglMakeCurrent(display, surface, surface, context));
	GCHK(glFlush());

	for (i = 0; ; i++) {
		if (test_compiler(i)) {
			break;
		}
	}

	ECHK(eglDestroySurface(display, surface));
	ECHK(eglTerminate(display));
}
コード例 #12
0
    /*
     * Sets up EGL.  Creates a 1280x720 pbuffer, which is large enough to
     * cause a rapid and highly visible memory leak if we fail to discard it.
     */
    bool eglSetup() {
        static const EGLint kConfigAttribs[] = {
                EGL_SURFACE_TYPE, EGL_PBUFFER_BIT,
                EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
                EGL_RED_SIZE, 8,
                EGL_GREEN_SIZE, 8,
                EGL_BLUE_SIZE, 8,
                EGL_NONE
        };
        static const EGLint kContextAttribs[] = {
                EGL_CONTEXT_CLIENT_VERSION, 2,
                EGL_NONE
        };
        static const EGLint kPbufferAttribs[] = {
                EGL_WIDTH, 1280,
                EGL_HEIGHT, 720,
                EGL_NONE
        };

        //usleep(25000);

        mEglDisplay = eglGetDisplay(EGL_DEFAULT_DISPLAY);
        if (mEglDisplay == EGL_NO_DISPLAY) {
            ALOGW("eglGetDisplay failed: 0x%x", eglGetError());
            return false;
        }

        EGLint majorVersion, minorVersion;
        if (!eglInitialize(mEglDisplay, &majorVersion, &minorVersion)) {
            ALOGW("eglInitialize failed: 0x%x", eglGetError());
            return false;
        }

        EGLConfig eglConfig;
        EGLint numConfigs = 0;
        if (!eglChooseConfig(mEglDisplay, kConfigAttribs, &eglConfig,
                1, &numConfigs)) {
            ALOGW("eglChooseConfig failed: 0x%x", eglGetError());
            return false;
        }

        mEglSurface = eglCreatePbufferSurface(mEglDisplay, eglConfig,
                kPbufferAttribs);
        if (mEglSurface == EGL_NO_SURFACE) {
            ALOGW("eglCreatePbufferSurface failed: 0x%x", eglGetError());
            return false;
        }

        mEglContext = eglCreateContext(mEglDisplay, eglConfig, EGL_NO_CONTEXT,
                kContextAttribs);
        if (mEglContext == EGL_NO_CONTEXT) {
            ALOGW("eglCreateContext failed: 0x%x", eglGetError());
            return false;
        }

        return true;
    }
コード例 #13
0
void EglManager::createPBufferSurface() {
    LOG_ALWAYS_FATAL_IF(mEglDisplay == EGL_NO_DISPLAY,
                        "usePBufferSurface() called on uninitialized GlobalContext!");

    if (mPBufferSurface == EGL_NO_SURFACE) {
        EGLint attribs[] = {EGL_WIDTH, 1, EGL_HEIGHT, 1, EGL_NONE};
        mPBufferSurface = eglCreatePbufferSurface(mEglDisplay, mEglConfig, attribs);
    }
}
コード例 #14
0
void * PthreadMain (void * param)
{
	Logger::Info("[PthreadMain] param = %p", param);

	Thread * t = (Thread*)param;

	if(t->needCopyContext)
    {
    	EGLConfig localConfig;
    	bool ret = GetConfig(Thread::currentDisplay, localConfig);
		Logger::Info("[PthreadMain] GetConfig returned = %d", ret);

    	if(ret)
    	{
        	EGLint contextAttrs[] = { EGL_CONTEXT_CLIENT_VERSION, 2, EGL_NONE };
        	t->localContext = eglCreateContext(t->currentDisplay, localConfig, t->currentContext, contextAttrs);
//        	t->localContext = eglCreateContext(t->currentDisplay, localConfig, EGL_NO_CONTEXT, contextAttrs);
    	}

    	if(t->localContext == EGL_NO_CONTEXT)
    	{
    		Logger::Error("[PthreadMain] Can't create local context");
    	}

    	GLint surfAttribs[] =
    	{
    			EGL_HEIGHT, 768,
    			EGL_WIDTH, 1024,
    			EGL_NONE
    	};

        
    	EGLSurface readSurface = eglCreatePbufferSurface(t->currentDisplay, localConfig, surfAttribs);
//    	EGLSurface drawSurface = eglCreatePbufferSurface(t->currentDisplay, localConfig, surfAttribs);

        //TODO: set context
//		bool ret2 = eglMakeCurrent(t->currentDisplay, t->currentDrawSurface, t->currentReadSurface, t->localContext);
		bool ret2 = eglMakeCurrent(t->currentDisplay, readSurface, readSurface, t->localContext);
		Logger::Info("[PthreadMain] set eglMakeCurrent returned = %d", ret2);
    }

	t->state = Thread::STATE_RUNNING;
	t->msg(t);

    if(t->needCopyContext)
	{
        //TODO: Restore context
		bool ret = eglMakeCurrent(t->currentDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
		Logger::Info("[PthreadMain] restore eglMakeCurrent returned = %d", ret);
	}

	t->state = Thread::STATE_ENDED;
	t->Release();

	pthread_exit(0);
}
コード例 #15
0
ファイル: xeglgears.c プロジェクト: aosm/X11apps
static EGLBoolean
egl_manager_create_pbuffer(struct egl_manager *eman, const EGLint *attrib_list)
{
   eman->pbuf = eglCreatePbufferSurface(eman->dpy, eman->conf, attrib_list);
   if (eman->pbuf == EGL_NO_SURFACE) {
      printf("eglCreatePbufferSurface() failed\n");
      return EGL_FALSE;
   }

   return EGL_TRUE;
}
コード例 #16
0
WEAK int halide_opengl_create_context(void *user_context) {
    if (eglGetCurrentContext() != EGL_NO_CONTEXT)
        return 0;

    EGLDisplay display = eglGetDisplay(EGL_DEFAULT_DISPLAY);
    if (display == EGL_NO_DISPLAY || !eglInitialize(display, 0, 0)) {
        error(user_context) << "Could not initialize EGL display: " << eglGetError();
        return 1;
    }

    EGLint attribs[] = {
        EGL_SURFACE_TYPE, EGL_PBUFFER_BIT,
        EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
        EGL_RED_SIZE, 8,
        EGL_GREEN_SIZE, 8,
        EGL_BLUE_SIZE, 8,
        EGL_ALPHA_SIZE, 8,
        EGL_NONE,
    };
    EGLConfig config;
    int numconfig;
    eglChooseConfig(display, attribs, &config, 1, &numconfig);
    if (numconfig != 1) {
        error(user_context) << "eglChooseConfig(): config not found: "
                            << eglGetError() << " - " << numconfig;
        return -1;
    }

    EGLint context_attribs[] = {
        EGL_CONTEXT_CLIENT_VERSION, 2,
        EGL_NONE
    };
    EGLContext context = eglCreateContext(display, config, EGL_NO_CONTEXT,
                                          context_attribs);
    if (context == EGL_NO_CONTEXT) {
        error(user_context) << "Error: eglCreateContext failed: " << eglGetError();
        return -1;
    }

    EGLint surface_attribs[] = {
        EGL_WIDTH, 1,
        EGL_HEIGHT, 1,
        EGL_NONE
    };
    EGLSurface surface = eglCreatePbufferSurface(display, config,  surface_attribs);
    if (surface == EGL_NO_SURFACE) {
        error(user_context) << "Error: Could not create EGL window surface: " << eglGetError();
        return -1;
    }

    eglMakeCurrent(display, surface, surface, context);
    return 0;
}
コード例 #17
0
ファイル: tex2vgimage.c プロジェクト: eviom/mesademos
static EGLBoolean egl_init(EGLmanager *eglman)
{
    EGLint pbuffer_attrib[] =
    {
        EGL_WIDTH,  128,
        EGL_HEIGHT, 128,
        EGL_NONE
    };

    // Check extension support
    if (check_ext(eglman) != EGL_TRUE)
    {
        return EGL_FALSE;
    }

    // Create GL context
    eglBindAPI(EGL_OPENGL_ES_API);
    eglman->es_ctx = eglCreateContext(eglman->dpy, eglman->conf, NULL, NULL);
    if (eglman->es_ctx == EGL_NO_CONTEXT ||
            eglGetError() != EGL_SUCCESS)
    {
        return EGL_FALSE;
    }

    // Create VG context
    eglBindAPI(EGL_OPENVG_API);
    eglman->vg_ctx = eglCreateContext(eglman->dpy, eglman->conf, NULL, NULL);
    if (eglman->vg_ctx == EGL_NO_CONTEXT ||
            eglGetError() != EGL_SUCCESS)
    {
        return EGL_FALSE;
    }

    // Create window surface
    eglman->win_surface = eglCreateWindowSurface(eglman->dpy, eglman->conf, eglman->xwin, NULL);
    if (eglman->win_surface == EGL_NO_SURFACE ||
            eglGetError() != EGL_SUCCESS)
    {
        return EGL_FALSE;
    }

    // Create pbuffer surface
    eglman->pbuf_surface = eglCreatePbufferSurface(eglman->dpy, eglman->conf, pbuffer_attrib);
    if (eglman->pbuf_surface == EGL_NO_SURFACE ||
            eglGetError() != EGL_SUCCESS)
    {

        return EGL_FALSE;
    }

    return EGL_TRUE;
}
コード例 #18
0
ファイル: GLHelper.cpp プロジェクト: kstv/BlackCode-Fuse
void GLHelper::CreatePBufferSurfaceAndMakeCurrent()
{
    // create pbuffer surface, this allows us to upload resources and then switch to an
    // eglwindowsurface when the java Surface is ready
    EGLint pbufferAttribs[] = { EGL_WIDTH, 1, EGL_HEIGHT, 1, EGL_NONE };

    _eglPBufferSurface = eglCreatePbufferSurface(_eglDisplay, _eglPBufferConfig, pbufferAttribs);
    if (_eglPBufferSurface == EGL_FALSE)
    {
        Xli::Error->WriteLine((Xli::String)"Unable to make EGL pbuffer surface");
        XLI_THROW("Unable to make EGL pbuffer surface");
    }
    MakeCurrent(_eglPBufferContext, _eglPBufferSurface);
}
コード例 #19
0
ファイル: vginfo.c プロジェクト: shirro/gpustuff
int main(void)
{
	EGLDisplay display;
	EGLContext context;
	EGLConfig config;
	EGLSurface surface;

	EGLBoolean result;
	EGLint num_config;

	static const EGLint attribute_list[] =
	{
		EGL_RED_SIZE, 8,
		EGL_GREEN_SIZE, 8,
		EGL_BLUE_SIZE, 8,
		EGL_ALPHA_SIZE, 8,
		EGL_SURFACE_TYPE, EGL_WINDOW_BIT,
		EGL_NONE
	};

	display = eglGetDisplay(EGL_DEFAULT_DISPLAY);
	result = eglInitialize(display, NULL, NULL);
	assert(result != EGL_FALSE);

	eglBindAPI(EGL_OPENVG_API);

	result = eglChooseConfig(display, attribute_list, &config, 1, &num_config);
	assert(result != EGL_FALSE);

	context = eglCreateContext(display, config, NULL, NULL);
	assert(context != EGL_NO_CONTEXT);

	surface = eglCreatePbufferSurface(display, config, NULL);

	eglMakeCurrent(display, surface, surface, context);

	display_info("Vendor", VG_VENDOR);
	display_info("Renderer", VG_RENDERER);
	display_info("Version", VG_VERSION);
	display_info("Extensions", VG_EXTENSIONS);


	eglMakeCurrent(display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
	eglDestroyContext(display, context);
	eglTerminate(display);
	eglReleaseThread();

	return 0;

}
コード例 #20
0
static jint jni_eglCreatePbufferSurface(JNIEnv *_env, jobject _this, jobject display,
        jobject config, jintArray attrib_list) {
    if (display == NULL || config == NULL
        || !validAttribList(_env, attrib_list)) {
        jniThrowException(_env, "java/lang/IllegalArgumentException", NULL);
        return JNI_FALSE;
    }
    EGLDisplay dpy = getDisplay(_env, display);
    EGLConfig  cnf = getConfig(_env, config);
    jint* base = beginNativeAttribList(_env, attrib_list);
    EGLSurface sur = eglCreatePbufferSurface(dpy, cnf, base);
    endNativeAttributeList(_env, attrib_list, base);
    return (jint)sur;
}
コード例 #21
0
/* Test that eglCreatePbufferSurface succeeds if given an EGLConfig with
 * EGL_PBUFFER_BIT.
 *
 * From the EGL_MESA_platform_surfaceless spec (v1):
 *
 *   The surfaceless platform imposes no platform-specific restrictions on the
 *   creation of pbuffers, as eglCreatePbufferSurface has no native surface
 *   parameter. [...] Specifically, if the EGLDisplay advertises an EGLConfig
 *   whose EGL_SURFACE_TYPE attribute contains EGL_PBUFFER_BIT, then the
 *   EGLDisplay permits the creation of pbuffers.
 */
static enum piglit_result
test_create_pbuffer(void *test_data)
{
	EGLDisplay dpy = EGL_NO_DISPLAY;
	EGLConfig config = EGL_NO_CONFIG_KHR;
	EGLint num_configs = 9999;
	EGLSurface surf;

	const EGLint config_attrs[] = {
		EGL_SURFACE_TYPE,	EGL_PBUFFER_BIT,

		EGL_RED_SIZE,		EGL_DONT_CARE,
		EGL_GREEN_SIZE,		EGL_DONT_CARE,
		EGL_BLUE_SIZE,		EGL_DONT_CARE,
		EGL_ALPHA_SIZE,		EGL_DONT_CARE,
		EGL_DEPTH_SIZE, 	EGL_DONT_CARE,
		EGL_STENCIL_SIZE, 	EGL_DONT_CARE,

		/* This is a bitmask that selects the rendering API (such as
		 * EGL_OPENGL_BIT and EGL_OPENGL_ES2_BIT). Accept any API,
		 * because we don't care.
		 */
		EGL_RENDERABLE_TYPE, 	~0,

		EGL_NONE,
	};

	test_setup(&dpy);

	if (!eglChooseConfig(dpy, config_attrs, &config, 1, &num_configs)) {
		printf("eglChooseConfig failed\n");
		return PIGLIT_FAIL;
	}

	if (num_configs == 0) {
		printf("found no EGLConfig with EGL_PBUFFER_BIT... skip\n");
		return PIGLIT_SKIP;
	}

	surf = eglCreatePbufferSurface(dpy, config, /*attribs*/ NULL);
	if (!surf) {
		printf("eglCreatePbufferSurface failed\n");
		return PIGLIT_FAIL;
	}

	eglDestroySurface(dpy, surf);
	eglTerminate(dpy);
	return PIGLIT_PASS;
}
コード例 #22
0
ファイル: test-caps.c プロジェクト: Dm47021/freedreno-1
void test_caps(void)
{
	GLint width, height;
	EGLint pbuffer_attribute_list[] = {
		EGL_WIDTH, 256,
		EGL_HEIGHT, 256,
		EGL_LARGEST_PBUFFER, EGL_TRUE,
		EGL_NONE
	};
	EGLSurface surface;
	int i;

	RD_START("caps", "");

	ECHK(surface = eglCreatePbufferSurface(display, config, pbuffer_attribute_list));

	ECHK(eglQuerySurface(display, surface, EGL_WIDTH, &width));
	ECHK(eglQuerySurface(display, surface, EGL_HEIGHT, &height));

	DEBUG_MSG("PBuffer: %dx%d", width, height);

	/* connect the context to the surface */
	ECHK(eglMakeCurrent(display, surface, surface, context));
	GCHK(glFlush());

	printf("EGL Version %s\n", eglQueryString(display, EGL_VERSION));
	printf("EGL Vendor %s\n", eglQueryString(display, EGL_VENDOR));
	printf("EGL Extensions %s\n", eglQueryString(display, EGL_EXTENSIONS));
	printf("GL Version %s\n", glGetString(GL_VERSION));
	printf("GL extensions: %s\n", glGetString(GL_EXTENSIONS));

	for (i = 0; i < ARRAY_SIZE(int_params); i++) {
		GLint val[4] = {};
		GLenum err;

		glGetIntegerv(int_params[i].pname, val);

		err = glGetError();
		if (err != GL_NO_ERROR) {
			printf("no %s: %s\n", int_params[i].name, glStrError(err));
		} else {
			printf("%s: %d %d %d %d\n", int_params[i].name,
					val[0], val[1], val[2], val[3]);
		}
	}

	RD_END();
}
コード例 #23
0
ファイル: x11.c プロジェクト: destenson/keybase--client
uintptr_t
surfaceCreate() {
	static const EGLint ctx_attribs[] = {
		EGL_CONTEXT_CLIENT_VERSION, 3,
		EGL_NONE
	};
	EGLContext ctx = eglCreateContext(e_dpy, e_config, EGL_NO_CONTEXT, ctx_attribs);
	if (!ctx) {
		fprintf(stderr, "surface eglCreateContext failed: %s\n", eglGetErrorStr());
		return 0;
	}

	static const EGLint cfg_attribs[] = {
		EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
		EGL_SURFACE_TYPE, EGL_PBUFFER_BIT,
		EGL_BLUE_SIZE, 8,
		EGL_GREEN_SIZE, 8,
		EGL_RED_SIZE, 8,
		EGL_DEPTH_SIZE, 16,
		EGL_CONFIG_CAVEAT, EGL_NONE,
		EGL_NONE
	};
	EGLConfig cfg;
	EGLint num_configs;
	if (!eglChooseConfig(e_dpy, cfg_attribs, &cfg, 1, &num_configs)) {
		fprintf(stderr, "gldriver: surface eglChooseConfig failed: %s\n", eglGetErrorStr());
		return 0;
	}

	// TODO: use the size of the monitor as a bound for texture size.
	static const EGLint attribs[] = {
		EGL_WIDTH, 4096,
		EGL_HEIGHT, 3072,
		EGL_NONE
	};
	EGLSurface surface = eglCreatePbufferSurface(e_dpy, cfg, attribs);
	if (!surface) {
		fprintf(stderr, "gldriver: surface eglCreatePbufferSurface failed: %s\n", eglGetErrorStr());
		return 0;
	}

	if (!eglMakeCurrent(e_dpy, surface, surface, ctx)) {
		fprintf(stderr, "gldriver: surface eglMakeCurrent failed: %s\n", eglGetErrorStr());
		return 0;
	}

	return (uintptr_t)surface;
}
コード例 #24
0
const GrGLInterface* SkANGLEGLContext::createGLContext() {

    fDisplay = eglGetDisplay(EGL_DEFAULT_DISPLAY);

    EGLint majorVersion;
    EGLint minorVersion;
    eglInitialize(fDisplay, &majorVersion, &minorVersion);

    EGLint numConfigs;
    static const EGLint configAttribs[] = {
        EGL_SURFACE_TYPE, EGL_PBUFFER_BIT,
        EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
        EGL_RED_SIZE, 8,
        EGL_GREEN_SIZE, 8,
        EGL_BLUE_SIZE, 8,
        EGL_ALPHA_SIZE, 8,
        EGL_NONE
    };

    EGLConfig surfaceConfig;
    eglChooseConfig(fDisplay, configAttribs, &surfaceConfig, 1, &numConfigs);

    static const EGLint contextAttribs[] = {
        EGL_CONTEXT_CLIENT_VERSION, 2,
        EGL_NONE
    };
    fContext = eglCreateContext(fDisplay, surfaceConfig, NULL, contextAttribs);


    static const EGLint surfaceAttribs[] = {
            EGL_WIDTH, 1,
            EGL_HEIGHT, 1,
            EGL_NONE
        };
    fSurface = eglCreatePbufferSurface(fDisplay, surfaceConfig, surfaceAttribs);

    eglMakeCurrent(fDisplay, fSurface, fSurface, fContext);

    const GrGLInterface* interface = GrGLCreateANGLEInterface();
    if (NULL == interface) {
        SkDebugf("Could not create ANGLE GL interface!\n");
        this->destroyGLContext();
        return NULL;
    }

    return interface;
}
コード例 #25
0
EGLSurface QEGLPlatformContext::createTemporaryOffscreenSurface()
{
    // Make the context current to ensure the GL version query works. This needs a surface too.
    const EGLint pbufferAttributes[] = {
        EGL_WIDTH, 1,
        EGL_HEIGHT, 1,
        EGL_LARGEST_PBUFFER, EGL_FALSE,
        EGL_NONE
    };

    // Cannot just pass m_eglConfig because it may not be suitable for pbuffers. Instead,
    // do what QEGLPbuffer would do: request a config with the same attributes but with
    // PBUFFER_BIT set.
    EGLConfig config = q_configFromGLFormat(m_eglDisplay, m_format, false, EGL_PBUFFER_BIT);

    return eglCreatePbufferSurface(m_eglDisplay, config, pbufferAttributes);
}
コード例 #26
0
ファイル: AndroidEGL.cpp プロジェクト: 1vanK/AHRUnrealEngine
/* Can be called from any thread */
EGLBoolean AndroidEGL::SetCurrentContext(EGLContext InContext, EGLSurface InSurface)
{
	//context can be null.so can surface from PlatformNULLContextSetup
	EGLBoolean Result = EGL_FALSE;
	EGLContext CurrentContext = GetCurrentContext();

	// activate the context
	if( CurrentContext != InContext)
	{
		if (CurrentContext !=EGL_NO_CONTEXT )
		{
			glFlush();
		}
		if(InContext == EGL_NO_CONTEXT && InSurface == EGL_NO_SURFACE)
		{
			ResetDisplay();
		}
		else
		{
			//if we have a valid context, and no surface then create a tiny pbuffer and use that temporarily
			EGLSurface Surface = InSurface;
			if (!bSupportsKHRSurfacelessContext && InContext != EGL_NO_CONTEXT && InSurface == EGL_NO_SURFACE)
			{
				checkf(PImplData->auxSurface == EGL_NO_SURFACE, TEXT("ERROR: PImplData->auxSurface already in use. PBuffer surface leak!"));
				EGLint PBufferAttribs[] =
				{
					EGL_WIDTH, 1,
					EGL_HEIGHT, 1,
					EGL_TEXTURE_TARGET, EGL_NO_TEXTURE,
					EGL_TEXTURE_FORMAT, EGL_NO_TEXTURE,
					EGL_NONE
				};
				PImplData->auxSurface = eglCreatePbufferSurface(PImplData->eglDisplay, PImplData->eglConfigParam, PBufferAttribs);
				if (PImplData->auxSurface == EGL_NO_SURFACE)
				{
					checkf(PImplData->auxSurface != EGL_NO_SURFACE, TEXT("eglCreatePbufferSurface error : 0x%x"), eglGetError());
				}
				Surface = PImplData->auxSurface;
			}

			Result = eglMakeCurrent(PImplData->eglDisplay, Surface, Surface, InContext);
			checkf(Result == EGL_TRUE, TEXT("ERROR: SetCurrentSharedContext eglMakeCurrent failed : 0x%x"), eglGetError());
		}
	}
	return Result;
}
コード例 #27
0
bool GraphicsContext3DInternal::createContext(bool createEGLContext)
{
    LOGWEBGL("createContext()");

    if (createEGLContext) {
        const EGLint context_attribs[] = {
            EGL_CONTEXT_CLIENT_VERSION, 2,
            EGL_NONE };
        const EGLint surface_attribs[] = {
            EGL_WIDTH, 1,
            EGL_HEIGHT, 1,
            EGL_NONE };
        m_surface = eglCreatePbufferSurface(m_dpy, m_config, surface_attribs);
        EGLContext context = EGL_NO_CONTEXT;
#if USE(SHARED_TEXTURE_WEBGL)
        context = TilesManager::instance()->getEglContext();
#endif
        m_context = eglCreateContext(m_dpy, m_config, context, context_attribs);
    }
    if (m_context == EGL_NO_CONTEXT) {
        deleteContext(createEGLContext);
        return false;
    }

    makeContextCurrent();
    for (int i = 0; i < NUM_BUFFERS; i++) {
        FBO* tmp = FBO::createFBO(m_dpy, m_width > 0 ? m_width : 1, m_height > 0 ? m_height : 1, m_attrs);
        if (tmp == 0) {
            LOGWEBGL("Failed to create FBO");
            deleteContext(createEGLContext);
            return false;
        }
        m_fbo[i] = tmp;
        //[CAPPFIX_WEB_WEBGL] - Handle FBO creation failure
        m_nfbo++;
        //[CAPPFIX_WEB_WEBGL_END]
        m_freeBuffers.append(tmp);
    }

    m_currentFBO = dequeueBuffer();
    m_boundFBO = m_currentFBO->fbo();
    m_frontFBO = 0;
    glBindFramebuffer(GL_FRAMEBUFFER, m_boundFBO);

    return true;
}
void MakeCurrentPerfCase::createPBuffer (void)
{
	const EGLint	width	= 256;
	const EGLint	height	= 256;

	const EGLint attribList[] = {
		EGL_WIDTH,	width,
		EGL_HEIGHT, height,
		EGL_NONE
	};

	EGLDisplay	display	= m_eglTestCtx.getDisplay().getEGLDisplay();
	EGLSurface	surface = eglCreatePbufferSurface(display, m_config, attribList);

	TCU_CHECK_EGL_MSG("eglCreatePbufferSurface()");

	m_surfaces.push_back(surface);
}
コード例 #29
0
SurfaceGL2D::SurfaceGL2D(QPainter* painter)
{
    m_qpainter = painter;
    eglBindAPI(EGL_OPENGL_ES_API);
    ASSERT_EGL_NO_ERROR();
    m_eglDisplay = eglGetDisplay(EGL_DEFAULT_DISPLAY);
    eglInitialize(m_eglDisplay, 0, 0);
    ASSERT_EGL_NO_ERROR();
    getEGLConfig(&m_eglConfig, PbufferSurface);
    const EGLint attribList[] = {
        EGL_WIDTH, m_qpainter->device()->width(),
        EGL_HEIGHT, m_qpainter->device()->height(),
        EGL_NONE
    };
    ASSERT_EGL_NO_ERROR();
    m_eglSurface = eglCreatePbufferSurface(m_eglDisplay, m_eglConfig, attribList);
    ASSERT_EGL_NO_ERROR();
}
コード例 #30
0
ファイル: main.c プロジェクト: farosis/gfx
void RenderTargetInit(void)
{
  int fd = open("/dev/dri/renderD128", O_RDWR);
  assert(fd >= 0);

  struct gbm_device *gbm = gbm_create_device(fd);
  assert(gbm != NULL);

  EGLDisplay display;
  assert((display = eglGetDisplay(gbm)) != EGL_NO_DISPLAY);

  EGLint majorVersion;
  EGLint minorVersion;
  assert(eglInitialize(display, &majorVersion, &minorVersion) == EGL_TRUE);

  EGLConfig config;
  EGLint numConfigs;
  const EGLint configAttribs[] = {
    EGL_SURFACE_TYPE, EGL_PBUFFER_BIT,
    EGL_RED_SIZE, 8,
    EGL_GREEN_SIZE, 8,
    EGL_BLUE_SIZE, 8,
    EGL_DEPTH_SIZE, 24,
    EGL_NONE
  };
  assert(eglChooseConfig(display, configAttribs, &config, 1, &numConfigs) == EGL_TRUE);

  EGLSurface surface;
  EGLint attribList[] = {
    EGL_WIDTH, 0,
    EGL_HEIGHT, 0,
    EGL_NONE
  };
  surface = eglCreatePbufferSurface(display, config, attribList);

  EGLContext context;
  const EGLint contextAttribs[] = {
    EGL_CONTEXT_CLIENT_VERSION, 2,
    EGL_NONE
  };
  assert((context = eglCreateContext(display, config, EGL_NO_CONTEXT, contextAttribs)) != EGL_NO_CONTEXT);

  assert(eglMakeCurrent(display, surface, surface, context) == EGL_TRUE);
}