An OpenGL Shader written in GL Shader Language (GLSL) Much of the complexity of this class stems from the fact that an OpenGL program is linked from a variety of (sometimes optional, sometimes reusable) parts. This class supports all of them. The rest of the complexity comes from the fact that b
| 34 | * Assuming that all goes well shaders take three principle kinds of inputs: vertex attributes (make and set these with aux and v calls in MeshBuilders), uniforms (make and set these with |
| 35 | * calls to Uniform and UniformBundle classes here) and input from earlier shaders. |
| 36 | */ |
| 37 | public class Shader extends BaseScene<Shader.State> implements Scene.Perform, fieldlinker.AsMap, HandlesCompletion, BoxBrowser.HasMarkdownInformation { |
| 38 | |
| 39 | private ShaderIntrospection introspection; |
| 40 | private int modCount; |
| 41 | |
| 42 | @Override |
| 43 | public String generateMarkdown(Box inside, Dict.Prop property) { |
| 44 | if (introspection == null) |
| 45 | return "Shader has not been executed by the graphics system, is it correctly attached to something?"+(lastAccumulatedError==null ? "" : "<br>Errors seen by the linker are:<br><pre style='font-size:75%'>"+lastAccumulatedError+"</pre>"); |
| 46 | |
| 47 | return introspection.getMarkdown(inside); |
| 48 | } |
| 49 | |
| 50 | static public class State extends BaseScene.Modifiable { |
| 51 | int name; |
| 52 | boolean work = true; |
| 53 | boolean valid = false; |
| 54 | } |
| 55 | |
| 56 | public enum Type { |
| 57 | vertex(GL20.GL_VERTEX_SHADER), geometry(GL32.GL_GEOMETRY_SHADER), fragment(GL20.GL_FRAGMENT_SHADER), tessControl(GL40.GL_TESS_CONTROL_SHADER), tessEval(GL40.GL_TESS_EVALUATION_SHADER), compute(GL43.GL_COMPUTE_SHADER); |
| 58 | |
| 59 | public int gl; |
| 60 | |
| 61 | private Type(int gl) { |
| 62 | this.gl = gl; |
| 63 | } |
| 64 | } |
| 65 | |
| 66 | public interface iErrorHandler { |
| 67 | public void beginError(); |
| 68 | |
| 69 | public void errorOnLine(int line, String error); |
| 70 | |
| 71 | public void endError(); |
| 72 | |
| 73 | public void noError(); |
| 74 | } |
| 75 | |
| 76 | public int num_groups_x = 1; |
| 77 | public int num_groups_y = 1; |
| 78 | public int num_groups_z = 1; |
| 79 | |
| 80 | protected iErrorHandler onError = null; |
| 81 | |
| 82 | Map<Type, Source> source = new LinkedHashMap<>(); |
| 83 | |
| 84 | static public class Source { |
| 85 | public Supplier<String> source; |
| 86 | protected final Type type; |
| 87 | protected int status; |
| 88 | public iErrorHandler onError = null; |
| 89 | |
| 90 | |
| 91 | public Source(Supplier<String> source, Type type) { |
| 92 | this.type = type; |
| 93 | this.source = source; |
no outgoing calls
no test coverage detected