This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Linux/TDA2PXEVM: [OpenGL] how to load picture into texture

Part Number: TDA2PXEVM


Tool/software: Linux

Hi:

  we are now succeed to render the AVM( around view monitor) with 4 camera via the sgxfrmcpy plugin,

then we try to render the car model by using DevIL to decode the JPG and load into OpenGL, sample code as following,
For glBindTexture, which target should we use GL_TEXTURE_2D or GL_TEXTURE_EXTERNAL_OES.
when go through the TI source code, GL_TEXTURE_2D is chosen, but in my case, it doesn't show the picture.
Any help is appciated!


			/* Convert image to RGBA */
			ilConvertImage(IL_RGBA, IL_UNSIGNED_BYTE); 

			/* Create and load textures to OpenGL */
			glBindTexture(GL_TEXTURE_2D, textureIds[i]); 
            eglCheckGlError("glBindTexture");
			glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); 
			glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
			glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, ilGetInteger(IL_IMAGE_WIDTH),
				ilGetInteger(IL_IMAGE_HEIGHT), 0, GL_RGBA, GL_UNSIGNED_BYTE,
				ilGetData());
              eglCheckGlError("glTexImage2D");



  • Hi,
    You can refer create_texture() function in this source file on how to create a RGB texture and attach to GL.

    git.ti.com/.../display-kmscube.c

    gbm_bo_import() is required first for RGB textures.

    Hope this helps.
  • Hi :
    I'v update the question, please have a look.
    we are working on the VisionSDK 3.04. under \vision_sdk\links_fw\src\hlos\system\system_gl_egl_utils.c
    there is no gbm related.
  • Hi,
    Adding RGB texture with Pixmap is not supported for wayland/weston is the backend. Graphics driver won't support this feature yet. I am not sure of the alternative.

    This feature of RGB texture is created only with gbm backend currently in graphics driver hence kmscube backend works for this fine.

    Thanks
    Ramprasad
  • Hi:
    The VisionSDK has the usecase for 3D surround view, and how it can draw the picture?
  • Hello :
    can you involve other expert?
    Thanks....
  • Hello:
    Any update?
  • Hello all:
    we are using SgxRender1x1 sample to show the JPG picture, see the code as following (if use camera texture, then it will show camera image corrtectly).





    static const GLfloat gSgxRender1x1_triangleVertices_fullscreen[] = {
            -1.0f, 1.0f, 0.0f,
            -1.0f, -1.0f, 0.0f,
            1.0f, -1.0f, 0.0f,
            1.0f, 1.0f, 0.0f
     };
    
    
    GLuint *textureIds ;
    
    
    
    int SgxRenderAVM_setup(SgxRenderAVM_Obj *pObj)
    {
        SgxRender1x1_setup(&pObj->render1x1Obj);
    
    
      int numTextures = 1;
      
         // init il, multi init is ok
         ilInit();
         
         /* create and fill array with DevIL texture ids */
         ILuint* imageIds = new ILuint[numTextures];
         ilGenImages(numTextures, imageIds); 
      
         /* create and fill array with GL texture ids */
         textureIds = new GLuint[numTextures];
         glGenTextures(numTextures, textureIds); /* Texture name generation */
             eglCheckGlError("glGenTextures");
         printf("numTextures %d \n",numTextures);
      
      
         /* get iterator */
      
      
             ilBindImage(imageIds[0]); /* Binding of DevIL image name */
             ilEnable(IL_ORIGIN_SET);
             ilOriginFunc(IL_ORIGIN_LOWER_LEFT); 
             ILboolean success = ilLoadImage((ILstring)"/opt/vision_sdk/avm_qt_app_res/cs11/LK.JPG");
             if (success) 
             {
                 /* Convert image to RGBA */
                 ilConvertImage(IL_RGBA, IL_UNSIGNED_BYTE); 
      
                 /* Create and load textures to OpenGL */
                 glBindTexture(GL_TEXTURE_EXTERNAL_OES, textureIds[0]); 
                 eglCheckGlError("glBindTexture");
                 glTexParameteri(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_MAG_FILTER, GL_NEAREST); 
                 glTexParameteri(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
                 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, ilGetInteger(IL_IMAGE_WIDTH),
                     ilGetInteger(IL_IMAGE_HEIGHT), 0, GL_RGBA, GL_UNSIGNED_BYTE,
                     ilGetData());
                   eglCheckGlError("glTexImage2D");
                   printf("load ok \n");
               }else
                {
    
                      printf("failed to load jpg file to texture \n");
    
    
                }
    
    
      return 0;
    }
    
    
    
    
    
    void SgxRenderAVM_renderFrame(SgxRenderAVM_Obj *pObj, System_EglWindowObj *pEglWindowObj, GLuint texYuv[], UInt16 numTex )
    {
        UTILS_assert(numTex==4);
        printf(" textureIds[0] %d \n", textureIds[0]);
         SgxRender1x1_renderFrame1x1(&pObj->render1x1Obj, pEglWindowObj, gSgxRender1x1_triangleVertices_fullscreen,  textureIds[0]);



    and which target here should we use
    GL_TEXTURE_2D or
    GL_TEXTURE_EXTERNAL_OES?
    Any suggestion....

  • HI,
    Currently there is no support for attaching RGB texture. Only NV12 and YUYV are supported.
    Can you check if NV12 be used since jpeg decoder output can be NV12?

    Ramprasad
  • Ramprasad said:
    Can you check if NV12 be used since jpeg decoder output can be NV12?

    How to load the NV12 to texture? with glTexImage2D(), seem no format with NV12?

    (we can convert JPEG to NV12 on PC site.)

  • Hi:
    We can convert the JPG to LUMINANCE which only have Y data, and the glTexImage2D() also support LUMINANCE .
    so did TI support this? or only nv12?
  • Hi:
    and if only support NV12 which internalformat is for glTexImage2D()?
  • reopen to continue the discussion that how to convert ARGB to UV12 to load into texture if possible, please see the following discussion.
  • Hi ,

    UV12 format is not supported by SGX. Can you provide details of this format?

    Ram

  • Hello:

    1. we're working on visionSDK 3.05 that using SGX to render surround view.
    2. we want to show the car picture which is RGB format, as discussed above that RGB is not supported to be attached to GL texture.
    3. and we just wounder how we can attach RGB to texture, on other hand, which format right now, does TI support to attach texure by glTexImage2D().

  • Hi,
    Attaching RGB texture with wayland display is not supported yet by PVR drivers. TI doesn't have plan to add this now.
    TI will update if this feature is available in future.

    Thanks
    Ramprasad
  • HI Ramprasad:
    we've been told that.
    For now, any other color format can be attach to texture by glTexImage2D?
    Or on other hand, Any other way to attach the picture by OpenGl based on VisionSDK3.05?
  • Closing the thread as this was answered in a duplicate thread
    e2e.ti.com/.../763784