MCPcopy Create free account
hub / github.com/carlonluca/pot / getEGLImage

Method getEGLImage

piomxtextures_src/openmaxiltextureloader.cpp:478–517  ·  view source on GitHub ↗

------------------------------------------------------------------------------ | OpenMAXILTextureLoader::getEGLImage +-----------------------------------------------------------------------------*/

Source from the content-addressed store, hash-verified

476| OpenMAXILTextureLoader::getEGLImage
477+-----------------------------------------------------------------------------*/
478inline
479EGLImageKHR OpenMAXILTextureLoader::getEGLImage(
480 OMX_U32 width,
481 OMX_U32 height,
482 EGLDisplay eglDisplay,
483 EGLContext eglContext,
484 GLuint& texture
485 )
486{
487 EGLint attr[] = { EGL_GL_TEXTURE_LEVEL_KHR, 0, EGL_NONE};
488
489 glGenTextures(1, &texture);
490 glBindTexture(GL_TEXTURE_2D, texture);
491 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
492 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
493 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
494 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
495
496 GLubyte* pixel = new GLubyte[width*height*4];
497 memset(pixel, 0x0f, sizeof(GLubyte)*width*height*4); // to have a grey texture
498 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, pixel);
499
500 EGLImageKHR eglImage = eglCreateImageKHR(
501 eglDisplay,
502 eglContext,
503 EGL_GL_TEXTURE_2D_KHR,
504 (EGLClientBuffer)texture,
505 attr
506 );
507 LOG_VERBOSE(LOG_TAG, "EGLImage: %x.", (unsigned int)eglImage);
508 LOG_VERBOSE(LOG_TAG, "Client buffer: %x.", texture);
509 EGLint eglErr = eglGetError();
510 if(eglErr != EGL_SUCCESS) {
511 LOG_ERROR(LOG_TAG, "Failed to create KHR image: %d.", eglErr);
512 return 0;
513 }
514
515 LOG_VERBOSE(LOG_TAG, "Successfully created KHR image: %x.", (unsigned int)eglImage);
516 return eglImage;
517}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected