Get the App
SLTechnology News&Howtos  ›  Development  › 

How to implement multiple textures in Qt

Shulou Source: shulou.com Published: 2022-06-02 11:11:35 10月05日 Update

This article is about how Qt implements multiple textures. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.

Multiple textures can be passed to shader. The following image shows the superposition of two textures.

The definition in shader is as follows:

Uniform sampler2D main () {gl_FragColor = texture2D (U_SubTexture, M_coord) * 0.8 + texture2D (U_MainTexture, M_coord) * 0.2;}

Parameter transfer in CUP

/ / transfer 0 texture unit OpenGLCore- > glActiveTexture (GL_TEXTURE0); OpenGLCore- > glBindTexture (GL_TEXTURE_2D, m_Texture); OpenGLCore- > glUniform1i (m_TextureLocation, 0); / / pass texture unit 1 OpenGLCore- > glActiveTexture (GL_TEXTURE1); OpenGLCore- > glBindTexture (GL_TEXTURE_2D, m_Texture2); OpenGLCore- > glUniform1i (m_Texture2Location, 1). Thank you for reading! This is the end of this article on "how to achieve multiple textures in Qt". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, you can share it for more people to see!

Tags: Texture content unit more article good practical following picture two parameter multiple effect article look knowledge reference superposition help related Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Technology Docker Redmi Huawei Linux