mirror of
https://github.com/love2d/love.git
synced 2026-08-17 11:00:31 +02:00
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:
@@ -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);
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user