
function love.load()
-- Define vertices of the triangle
vertices = {
{-0.5, -0.5},
{0.5, -0.5},
{0.0, 0.5}
}
------------------------------------------------------------
-- Load the shader
shaderCode = [[
// Vertex shader
attribute vec4 position;
void main() {
gl_Position = position;
}
// Fragment shader
precision mediump float;
void main() {
gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0); // Red color
}
]]
shader = love.graphics.newShader(shaderCode)
-----------------------------------------------------------
-- Create a Mesh with position attribute
mesh = love.graphics.newMesh(vertices, "triangles")
mesh:setVertexAttribute("position", vertices, "float", 2) -- Set vertex attribute
end
function love.draw()
-- Set the shader
love.graphics.setShader(shader)
-- Draw the mesh
love.graphics.draw(mesh)
-- Reset shader
love.graphics.setShader()
end