()
| 109 | boolean good = false; |
| 110 | Set<Integer> attachedTo = new LinkedHashSet<>(); |
| 111 | } |
| 112 | |
| 113 | protected boolean clean() { |
| 114 | State s = GraphicsContext.get(this, () -> { |
| 115 | State state = new State(); |
| 116 | state.source = source.get(); |
| 117 | return state; |
| 118 | }); |
| 119 | |
| 120 | if (!s.source.equals(this.source.get())) { |
| 121 | |
| 122 | System.out.println(" shader ("+type+") needs recompilation in context "+GraphicsContext.getContext()+" detatching from "+s.attachedTo); |
| 123 | |
| 124 | for (Integer ii : s.attachedTo) |
| 125 | GL20.glDetachShader(ii, s.name); |
| 126 | s.attachedTo.clear(); |
| 127 | GL20.glDeleteShader(s.name); |
| 128 | |
| 129 | s = new State(); |
| 130 | s.source = source.get(); |
| 131 | GraphicsContext.put(this, s); |
| 132 | } |
| 133 | |
| 134 | final State finalS = s; |
| 135 | Log.log("graphics.trace", () -> " shader name " + finalS.name); |
| 136 | |
| 137 | if (s.name == -1) { |
| 138 | try { |
| 139 | |
| 140 | // System.out.println(" recompiling shader in context :"+GraphicsContext.getContext()); |
| 141 | |
| 142 | Log.log("graphics.trace", () -> " creating shader"); |
| 143 | s.name = GL20.glCreateShader(type.gl); |
| 144 | GL20.glShaderSource(s.name, s.source); |
| 145 | |
| 146 | // System.out.println(" shader source is "+s.source+" for name "+s.name); |
| 147 | |
| 148 | GL20.glCompileShader(s.name); |
| 149 | status = GL20.glGetShaderi(s.name, GL20.GL_COMPILE_STATUS); |
| 150 | Log.log("graphics.trace", () -> " shader compile status" + status); |
| 151 | |
| 152 | if (status == 0) { |
| 153 | String ret = GL20.glGetShaderInfoLog(s.name, 10000); |
| 154 | Log.log("graphics.error", () -> type + " program failed to compile"); |
| 155 | Log.log("graphics.error", () -> " log is <" + ret + ">"); |
| 156 | Log.log("graphics.error", () -> " shader source is <" + source + ">, reporting to <" + onError + ">"); |
| 157 | if (onError != null) { |
| 158 | onError.beginError(); |
| 159 | String log = ret; |
| 160 | String[] lines = log.split("\n"); |
| 161 | for (String ll : lines) { |
| 162 | try { |
| 163 | String[] ss = ll.split(":"); |
| 164 | if (ss.length > 2) { |
| 165 | int ii = Integer.parseInt(ss[2])-1; |
| 166 | onError.errorOnLine(ii, ll); |
| 167 | break; |
| 168 | } |
nothing calls this directly
no test coverage detected