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.

[参考译文] TDA2HG:[OpenGL]-- FBO 中的立方体用法

Guru**** 2539500 points


请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

https://e2e.ti.com/support/processors-group/processors/f/processors-forum/1027878/tda2hg-opengl----the-cube-usage-in-fbo

器件型号:TDA2HG
主题中讨论的其他器件:TDA2

您好:

我对於在 FBO 中使用孵化包的问题有疑问;

下面的简单代码:

   glGenFramebuffers (1、&fboID);
   glBindFramebuffer (gL_framebuffer、fboID);

   格式纹理(1、&cubemapID);
   glBindTexture (GL_纹 理_立方体_地图、立方体 apID);
   对于(unsigned int i = 0;i < 6;+i)
   {
      glTextImage2D (GL_tature_cube_map_positive _X + I、0、GL_RGB、256、256、 0、GL_RGB、GL_unsigned_byte、nulptr);
   }

   glTextParameteri (GL_turete_cube_map、GL_turete_wrap_S、GL_clamp 到_edge);
   glTextParameteri (GL_turete_cube_map、GL_turete_wrap_T、GL_clamp 到_edge);
   GlTextParameteri (GL_turete_cube_map、GL_turete_min_filter、GL_linear_linear);
   GlTextParameteri (GL_turete_cube_map、GL_turete_mag_filter、GL_linear);

   格均匀..  //更新 uniform 变量

   glViewport (0、0、256、256);
   对于(unsigned int i = 0;i < 6;+i)
   {
      glFramebufferTexture2D (GL_framebuffer、GL_color_ATTACHMENT0、GL_tuture_cube_map_positive X + I、cubemapID、0);
      if (glCheckFramebufferStatus (GL_framebuffer)!= GL_framebuffer_complete)
      {
         printf ("glCheckFramebufferStatus error!\n");
      }
      glClear (gL_color_buffer_bit | gL_depte_buffer_bit);

      renderCube ();
   }

当我测试代码时、它在 Windows 上运行良好、

但当我把它移到 tda2平台时,问题是常见的,有时效率是黑色的,或者白色的,或者白色的和黑色的,或者其他颜色的,它每次都会改变。

这是如何实现的? 以及如何解决它?

谢谢

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    您好!

    您能否尝试并查看这是否起作用:

        // Setup texture for cubemap
        glGenTextures(1, &textureCubeMap);
        char buffer0[CUBEMAP_TEX_LEN * CUBEMAP_TEX_LEN * 6];
    
        glBindTexture(GL_TEXTURE_CUBE_MAP, textureCubeMap);
        memset((void *)buffer0, 0x50, CUBEMAP_TEX_LEN*CUBEMAP_TEX_LEN*6);
        for(GLuint i = 0; i < 6; i++)
        {
                glTexImage2D(
                                GL_TEXTURE_CUBE_MAP_POSITIVE_X + i,
                                0, GL_RGBA8, CUBEMAP_TEX_LEN, CUBEMAP_TEX_LEN,
                                0, GL_RGBA, GL_UNSIGNED_BYTE, (char *)buffer0
                            );
        }
    
        glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
        glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
        glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
        glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
        glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE);
    
        // Setup Framebuffer for cubemap
        glGenFramebuffers(1, &fbCubeMap);
        
        
        // Rendering part
        GLint current_fbo;
        glGetIntegerv(GL_FRAMEBUFFER_BINDING, &current_fbo);
        glBindFramebuffer(GL_FRAMEBUFFER, fbCubeMap);
        
        // Render to cubemap
        for (int i = 0; i < 6; i++)
    	{
            glFramebufferTexture2D(GL_FRAMEBUFFER,
    		    GL_COLOR_ATTACHMENT0,
    		    GL_TEXTURE_CUBE_MAP_POSITIVE_X + i,
    		    textureCubeMap,
    		    0);
    	    glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
    	    //.... draw/render to cube map surface
    	}
    	
    	// Bind the original frame buffer
    	glBindFramebuffer(GL_FRAMEBUFFER, current_fbo);
    	
    	// Use cubemap texture
    	glBindTexture(GL_TEXTURE_CUBE_MAP, textureCubeMap);
    
        //... draw to the final framebuffer using cubemap
        // In the shader code, use samplerCube to sample texture
        // e.g:
        // uniform samplerCube skybox;
        // ...
        // vec4 colorval = texture(skybox, direction);
        
    
        
        
    	    
    
    
    
        
    
    
    

    如果仍然不起作用,您是否可以尝试使用 glGetError 检查是否有任何错误?

    此致

    Hemant