Opengl: Use single channel texture as alpha channel to display text

前端 未结 2 732
余生分开走
余生分开走 2021-01-13 23:24

What I\'m trying to do is load a texture into hardware from a single channel data array and use it\'s alpha channel to draw text onto an object. I am using opengl 4.

<
2条回答
  •  一向
    一向 (楼主)
    2021-01-13 23:38

    I think you swapped the "internal format" and "format" parameters of glTexImage2d(). That is, you told it that you want RGBA in the texture object, but only had RED in the file data rather than vice-versa.

    Try to replace your call with the following:

    glTexImage2D(GL_TEXTURE_2D, 0, GL_RED, texture->x, texture->y, 0, GL_RGBA, GL_UNSIGNED_BYTE, reinterpret_cast(full_texture));
    

自定义标题
段落格式
字体
字号
代码语言
提交回复
热议问题