rj-action-library/Runtime/Rendering/Objects/RDProgram.cs

56 lines
1.1 KiB
C#
Raw Normal View History

2025-04-26 20:04:11 +00:00
using Godot;
using Godot.Collections;
namespace Rokojori
{
public class RDProgram
{
2025-04-29 19:46:45 +00:00
protected RDContext _context;
public RDContext context => _context;
public RDProgram( RDContext context )
{
_context = context;
}
2025-04-26 20:04:11 +00:00
public enum Type
{
VertexFragment,
Compute
}
protected Type _type;
public Type type => _type;
protected RDShader _shader;
2025-04-29 19:46:45 +00:00
public RDShader shader => _shader;
2025-04-26 20:04:11 +00:00
protected RDPipeline _pipeline;
2025-04-29 19:46:45 +00:00
public RDPipeline pipeline => _pipeline;
public static RDProgram FromPath( RDContext context, string path )
{
var p = new RDProgram( context );
p._shader = RDShader.FromPath( context, path );
if ( p._shader == null || ! p._shader.rid.IsValid )
{
context.Error( "Invalid shader", path );
return null;
}
p._pipeline = RDPipeline.Create( context, p._shader );
if ( p._pipeline == null || ! p._pipeline.rid.IsValid )
{
context.Error( "Invalid pipeline", path );
return null;
}
return p;
}
2025-04-26 20:04:11 +00:00
}
}