How to use GL_REPEAT to repeat only a selection of a texture atlas? (OpenGL)

前端 未结 6 1764
臣服心动
臣服心动 2021-02-12 19:00

How can I repeat a selection of a texture atlas?

For example, my sprite (selection) is within the texture coordinates:

GLfloat textureC         


        
6条回答
  •  闹比i
    闹比i (楼主)
    2021-02-12 19:30

    None of the texture wrap modes support the kind of operation you are looking for, i.e. they all map to the full [0,1] range, not some arbitrary subset. You basically have two choices: Either create a new texture that only has the sprite you need from the existing texture or write a GLSL pixel program to map the texture coordinates appropriately.

提交回复
热议问题