Closed aganm closed 3 years ago
Hey, you can set up an additional texture with GPU_SetShaderImage: https://github.com/grimfang4/sdl-gpu/blob/642cdce6cfcb90d57b1444887020e1fdf77f70e3/include/SDL_gpu.h#L1997
You will need to be using a custom shader that samples from each texture appropriately. You can send in additional texture coordinates, if needed, using the attribute system (e.g. GPU_SetAttributeSource).
There is an example of using GPU_SetShaderImage in the tests/multitexture program and an example of using attributes in the tests/shader-attributes program.
I'm using GPU_TriangleBatch but it only takes 1 GPU_Image as argument. https://github.com/grimfang4/sdl-gpu/blob/642cdce6cfcb90d57b1444887020e1fdf77f70e3/include/SDL_gpu.h#L1645
Right now I have to call it for every different texture I want to use, but this is very slow.
Is there another function that lets me pass more than 1 GPU_Image in a single call? I am thinking of a function that would take a pointer to an array of GPU_Image, and the vertex data would have a texture index.