gosu / ashton

Special graphical effects and other extensions for the Ruby/Gosu game library (⚠️ unmaintained)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Shaders should support multitexturing

bil-bas opened this issue · comments

reported by amimeyet_

Trying to use texture unit 1 to perform shader-based stencilling, finds that the texcoords don't vary and the texture is always black. Not sure what the issue is, but I thought it worthwhile simplifying this for users with an api like:

Shader#multitexture(1, texture, :mask)

which will do something like:

shader[:mask] = 1
@textures[1..-1].each_with_index do |image, i|
   glActiveTexture [GL_TEXTURE0, GL_TEXTURE1, GL_TEXTURE2, GL_TEXTURE3][i]
   glBindTexture GL_TEXTURE_2D, @textures[1].id
end

 glActiveTexture GL_TEXTURE0     

Perhaps also use a default vertex shader based on how many texture units are required (or just have 2 in the default one is probably reasonable, since requiring more than that is unlikely).

Right, so that is done.