Removed void effects(…) pixel shader prototype. Added void effect(). Allows calling love.graphics.draw with textures of different types with a custom shader without having an extra sampler2D.

effect() takes no arguments and returns nothing, you are responsible for assigning a value to either love_PixelColor or love_Canvases[n] in the function. You can declare ‘MainTex’, which will be whatever texture is used with any Drawable drawn with love.graphics.draw. You can also declare ‘VaryingColor’ and ‘VaryingTexCoord’, which are passed down from the vertex shader by love automatically. love_PixelCoord is also available.

--HG--
branch : minor
This commit is contained in:
Alex Szpakowski
2017-02-25 17:52:27 -04:00
parent f3f6b10ac8
commit ff8358a979
5 changed files with 47 additions and 24 deletions
+1 -4
View File
@@ -134,10 +134,7 @@ void Mesh::drawInstanced(love::graphics::Graphics *gfx, const love::Matrix4 &m,
gl.useVertexAttribArrays(enabledattribs, instancedattribs);
if (texture.get())
gl.bindTextureToUnit(texture, 0, false);
else
gl.bindTextureToUnit(TEXTURE_2D, gl.getDefaultTexture(TEXTURE_2D), 0, false);
gl.bindTextureToUnit(texture, 0, false);
Graphics::TempTransform transform(gfx, m);
+19 -2
View File
@@ -867,8 +867,25 @@ void OpenGL::bindTextureToUnit(TextureType target, GLuint texture, int textureun
void OpenGL::bindTextureToUnit(Texture *texture, int textureunit, bool restoreprev)
{
GLuint handle = texture != nullptr ? (GLuint) texture->getHandle() : getDefaultTexture(TEXTURE_2D);
TextureType textype = texture != nullptr ? texture->getTextureType() : TEXTURE_2D;
TextureType textype = TEXTURE_2D;
GLuint handle = 0;
if (texture != nullptr)
{
textype = texture->getTextureType();
handle = (GLuint) texture->getHandle();
}
else
{
if (textureunit == 0 && Shader::current != nullptr)
{
TextureType shadertex = Shader::current->getMainTextureType();
if (shadertex != TEXTURE_MAX_ENUM)
textype = shadertex;
}
handle = getDefaultTexture(textype);
}
bindTextureToUnit(textype, handle, textureunit, restoreprev);
}