Main repository of MikuMikuStudio
Revision | edcba9dc8add6287a25a00d32407c9bf3de4237f (tree) |
---|---|
Zeit | 2013-06-18 11:54:47 |
Autor | iwgeric <iwgeric@75d0...> |
Commiter | iwgeric |
Improve error message when shader uniform is not set
git-svn-id: http://jmonkeyengine.googlecode.com/svn/trunk@10650 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
@@ -323,7 +323,7 @@ public class OGLESShaderRenderer implements Renderer { | ||
323 | 323 | // Allocate buffer for compressed formats. |
324 | 324 | IntBuffer compressedFormats = BufferUtils.createIntBuffer(numCompressedFormats); |
325 | 325 | GLES20.glGetIntegerv(GLES20.GL_COMPRESSED_TEXTURE_FORMATS, compressedFormats); |
326 | - | |
326 | + | |
327 | 327 | // Check for errors after all glGet calls. |
328 | 328 | RendererUtil.checkGLError(); |
329 | 329 |
@@ -333,7 +333,7 @@ public class OGLESShaderRenderer implements Renderer { | ||
333 | 333 | } |
334 | 334 | |
335 | 335 | TextureUtil.loadTextureFeatures(extensions); |
336 | - | |
336 | + | |
337 | 337 | applyRenderState(RenderState.DEFAULT); |
338 | 338 | GLES20.glDisable(GLES20.GL_DITHER); |
339 | 339 | RendererUtil.checkGLError(); |
@@ -459,7 +459,7 @@ public class OGLESShaderRenderer implements Renderer { | ||
459 | 459 | GLES20.glPolygonOffset(state.getPolyOffsetFactor(), |
460 | 460 | state.getPolyOffsetUnits()); |
461 | 461 | RendererUtil.checkGLError(); |
462 | - | |
462 | + | |
463 | 463 | context.polyOffsetEnabled = true; |
464 | 464 | context.polyOffsetFactor = state.getPolyOffsetFactor(); |
465 | 465 | context.polyOffsetUnits = state.getPolyOffsetUnits(); |
@@ -469,7 +469,7 @@ public class OGLESShaderRenderer implements Renderer { | ||
469 | 469 | GLES20.glPolygonOffset(state.getPolyOffsetFactor(), |
470 | 470 | state.getPolyOffsetUnits()); |
471 | 471 | RendererUtil.checkGLError(); |
472 | - | |
472 | + | |
473 | 473 | context.polyOffsetFactor = state.getPolyOffsetFactor(); |
474 | 474 | context.polyOffsetUnits = state.getPolyOffsetUnits(); |
475 | 475 | } |
@@ -478,7 +478,7 @@ public class OGLESShaderRenderer implements Renderer { | ||
478 | 478 | if (context.polyOffsetEnabled) { |
479 | 479 | GLES20.glDisable(GLES20.GL_POLYGON_OFFSET_FILL); |
480 | 480 | RendererUtil.checkGLError(); |
481 | - | |
481 | + | |
482 | 482 | context.polyOffsetEnabled = false; |
483 | 483 | context.polyOffsetFactor = 0; |
484 | 484 | context.polyOffsetUnits = 0; |
@@ -563,7 +563,7 @@ public class OGLESShaderRenderer implements Renderer { | ||
563 | 563 | if (x != vpX || vpY != y || vpW != w || vpH != h) { |
564 | 564 | GLES20.glViewport(x, y, w, h); |
565 | 565 | RendererUtil.checkGLError(); |
566 | - | |
566 | + | |
567 | 567 | vpX = x; |
568 | 568 | vpY = y; |
569 | 569 | vpW = w; |
@@ -621,7 +621,7 @@ public class OGLESShaderRenderer implements Renderer { | ||
621 | 621 | updateNameBuffer(); |
622 | 622 | int loc = GLES20.glGetUniformLocation(shader.getId(), uniform.getName()); |
623 | 623 | RendererUtil.checkGLError(); |
624 | - | |
624 | + | |
625 | 625 | if (loc < 0) { |
626 | 626 | uniform.setLocation(-1); |
627 | 627 | // uniform is not declared in shader |
@@ -635,7 +635,7 @@ public class OGLESShaderRenderer implements Renderer { | ||
635 | 635 | if (context.boundShaderProgram != shaderId) { |
636 | 636 | GLES20.glUseProgram(shaderId); |
637 | 637 | RendererUtil.checkGLError(); |
638 | - | |
638 | + | |
639 | 639 | statistics.onShaderUse(shader, true); |
640 | 640 | boundShader = shader; |
641 | 641 | context.boundShaderProgram = shaderId; |
@@ -653,7 +653,7 @@ public class OGLESShaderRenderer implements Renderer { | ||
653 | 653 | if (context.boundShaderProgram != shaderId) { |
654 | 654 | GLES20.glUseProgram(shaderId); |
655 | 655 | RendererUtil.checkGLError(); |
656 | - | |
656 | + | |
657 | 657 | statistics.onShaderUse(shader, true); |
658 | 658 | boundShader = shader; |
659 | 659 | context.boundShaderProgram = shaderId; |
@@ -678,7 +678,8 @@ public class OGLESShaderRenderer implements Renderer { | ||
678 | 678 | } |
679 | 679 | |
680 | 680 | if (uniform.getVarType() == null) { |
681 | - logger.warning("value is not set yet."); | |
681 | + logger.log(Level.WARNING, "Uniform value is not set yet. Shader: {0}, Uniform: {1}", | |
682 | + new Object[]{shader.toString(), uniform.toString()}); | |
682 | 683 | return; // value not set yet.. |
683 | 684 | } |
684 | 685 |
@@ -805,7 +806,7 @@ public class OGLESShaderRenderer implements Renderer { | ||
805 | 806 | // Create id |
806 | 807 | id = GLES20.glCreateShader(convertShaderType(source.getType())); |
807 | 808 | RendererUtil.checkGLError(); |
808 | - | |
809 | + | |
809 | 810 | if (id <= 0) { |
810 | 811 | throw new RendererException("Invalid ID received when trying to create shader."); |
811 | 812 | } |
@@ -853,7 +854,7 @@ public class OGLESShaderRenderer implements Renderer { | ||
853 | 854 | |
854 | 855 | GLES20.glCompileShader(id); |
855 | 856 | RendererUtil.checkGLError(); |
856 | - | |
857 | + | |
857 | 858 | GLES20.glGetShaderiv(id, GLES20.GL_COMPILE_STATUS, intBuf1); |
858 | 859 | RendererUtil.checkGLError(); |
859 | 860 |
@@ -906,7 +907,7 @@ public class OGLESShaderRenderer implements Renderer { | ||
906 | 907 | if (source.isUpdateNeeded()) { |
907 | 908 | updateShaderSourceData(source); |
908 | 909 | } |
909 | - | |
910 | + | |
910 | 911 | GLES20.glAttachShader(id, source.getId()); |
911 | 912 | RendererUtil.checkGLError(); |
912 | 913 | } |
@@ -914,7 +915,7 @@ public class OGLESShaderRenderer implements Renderer { | ||
914 | 915 | // link shaders to program |
915 | 916 | GLES20.glLinkProgram(id); |
916 | 917 | RendererUtil.checkGLError(); |
917 | - | |
918 | + | |
918 | 919 | GLES20.glGetProgramiv(id, GLES20.GL_LINK_STATUS, intBuf1); |
919 | 920 | RendererUtil.checkGLError(); |
920 | 921 |
@@ -982,10 +983,10 @@ public class OGLESShaderRenderer implements Renderer { | ||
982 | 983 | } |
983 | 984 | |
984 | 985 | source.clearUpdateNeeded(); |
985 | - | |
986 | + | |
986 | 987 | GLES20.glDeleteShader(source.getId()); |
987 | 988 | RendererUtil.checkGLError(); |
988 | - | |
989 | + | |
989 | 990 | source.resetObject(); |
990 | 991 | } |
991 | 992 |
@@ -999,14 +1000,14 @@ public class OGLESShaderRenderer implements Renderer { | ||
999 | 1000 | if (source.getId() != -1) { |
1000 | 1001 | GLES20.glDetachShader(shader.getId(), source.getId()); |
1001 | 1002 | RendererUtil.checkGLError(); |
1002 | - | |
1003 | + | |
1003 | 1004 | deleteShaderSource(source); |
1004 | 1005 | } |
1005 | 1006 | } |
1006 | 1007 | |
1007 | 1008 | GLES20.glDeleteProgram(shader.getId()); |
1008 | 1009 | RendererUtil.checkGLError(); |
1009 | - | |
1010 | + | |
1010 | 1011 | statistics.onDeleteShader(); |
1011 | 1012 | shader.resetObject(); |
1012 | 1013 | } |
@@ -1211,7 +1212,7 @@ public class OGLESShaderRenderer implements Renderer { | ||
1211 | 1212 | if (id == -1) { |
1212 | 1213 | GLES20.glGenRenderbuffers(1, intBuf1); |
1213 | 1214 | RendererUtil.checkGLError(); |
1214 | - | |
1215 | + | |
1215 | 1216 | id = intBuf1.get(0); |
1216 | 1217 | rb.setId(id); |
1217 | 1218 | } |
@@ -1219,7 +1220,7 @@ public class OGLESShaderRenderer implements Renderer { | ||
1219 | 1220 | if (context.boundRB != id) { |
1220 | 1221 | GLES20.glBindRenderbuffer(GLES20.GL_RENDERBUFFER, id); |
1221 | 1222 | RendererUtil.checkGLError(); |
1222 | - | |
1223 | + | |
1223 | 1224 | context.boundRB = id; |
1224 | 1225 | } |
1225 | 1226 |
@@ -1251,7 +1252,7 @@ public class OGLESShaderRenderer implements Renderer { | ||
1251 | 1252 | imageFormat.renderBufferStorageFormat, |
1252 | 1253 | fb.getWidth(), |
1253 | 1254 | fb.getHeight()); |
1254 | - | |
1255 | + | |
1255 | 1256 | RendererUtil.checkGLError(); |
1256 | 1257 | } |
1257 | 1258 | } |
@@ -1284,7 +1285,7 @@ public class OGLESShaderRenderer implements Renderer { | ||
1284 | 1285 | convertTextureType(tex.getType()), |
1285 | 1286 | image.getId(), |
1286 | 1287 | 0); |
1287 | - | |
1288 | + | |
1288 | 1289 | RendererUtil.checkGLError(); |
1289 | 1290 | } |
1290 | 1291 |
@@ -1303,7 +1304,7 @@ public class OGLESShaderRenderer implements Renderer { | ||
1303 | 1304 | convertAttachmentSlot(rb.getSlot()), |
1304 | 1305 | GLES20.GL_RENDERBUFFER, |
1305 | 1306 | rb.getId()); |
1306 | - | |
1307 | + | |
1307 | 1308 | RendererUtil.checkGLError(); |
1308 | 1309 | } |
1309 | 1310 | } |
@@ -1315,7 +1316,7 @@ public class OGLESShaderRenderer implements Renderer { | ||
1315 | 1316 | // create FBO |
1316 | 1317 | GLES20.glGenFramebuffers(1, intBuf1); |
1317 | 1318 | RendererUtil.checkGLError(); |
1318 | - | |
1319 | + | |
1319 | 1320 | id = intBuf1.get(0); |
1320 | 1321 | fb.setId(id); |
1321 | 1322 | objManager.registerObject(fb); |
@@ -1326,7 +1327,7 @@ public class OGLESShaderRenderer implements Renderer { | ||
1326 | 1327 | if (context.boundFBO != id) { |
1327 | 1328 | GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER, id); |
1328 | 1329 | RendererUtil.checkGLError(); |
1329 | - | |
1330 | + | |
1330 | 1331 | // binding an FBO automatically sets draw buf to GL_COLOR_ATTACHMENT0 |
1331 | 1332 | context.boundDrawBuf = 0; |
1332 | 1333 | context.boundFBO = id; |
@@ -1382,7 +1383,7 @@ public class OGLESShaderRenderer implements Renderer { | ||
1382 | 1383 | if (context.boundFBO != 0) { |
1383 | 1384 | GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER, 0); |
1384 | 1385 | RendererUtil.checkGLError(); |
1385 | - | |
1386 | + | |
1386 | 1387 | statistics.onFrameBufferUse(null, true); |
1387 | 1388 | |
1388 | 1389 | context.boundFBO = 0; |
@@ -1414,7 +1415,7 @@ public class OGLESShaderRenderer implements Renderer { | ||
1414 | 1415 | if (context.boundFBO != fb.getId()) { |
1415 | 1416 | GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER, fb.getId()); |
1416 | 1417 | RendererUtil.checkGLError(); |
1417 | - | |
1418 | + | |
1418 | 1419 | statistics.onFrameBufferUse(fb, true); |
1419 | 1420 | |
1420 | 1421 | // update viewport to reflect framebuffer's resolution |
@@ -1464,7 +1465,7 @@ public class OGLESShaderRenderer implements Renderer { | ||
1464 | 1465 | if (context.boundDrawBuf != rb.getSlot()) { |
1465 | 1466 | GLES20.glActiveTexture(convertAttachmentSlot(rb.getSlot())); |
1466 | 1467 | RendererUtil.checkGLError(); |
1467 | - | |
1468 | + | |
1468 | 1469 | context.boundDrawBuf = rb.getSlot(); |
1469 | 1470 | } |
1470 | 1471 | } |
@@ -1514,7 +1515,7 @@ public class OGLESShaderRenderer implements Renderer { | ||
1514 | 1515 | if (context.boundFBO == fb.getId()) { |
1515 | 1516 | GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER, 0); |
1516 | 1517 | RendererUtil.checkGLError(); |
1517 | - | |
1518 | + | |
1518 | 1519 | context.boundFBO = 0; |
1519 | 1520 | } |
1520 | 1521 |
@@ -1528,7 +1529,7 @@ public class OGLESShaderRenderer implements Renderer { | ||
1528 | 1529 | intBuf1.put(0, fb.getId()); |
1529 | 1530 | GLES20.glDeleteFramebuffers(1, intBuf1); |
1530 | 1531 | RendererUtil.checkGLError(); |
1531 | - | |
1532 | + | |
1532 | 1533 | fb.resetObject(); |
1533 | 1534 | |
1534 | 1535 | statistics.onDeleteFrameBuffer(); |
@@ -1638,7 +1639,7 @@ public class OGLESShaderRenderer implements Renderer { | ||
1638 | 1639 | // fall down here is intentional.. |
1639 | 1640 | // case OneDimensional: |
1640 | 1641 | GLES20.glTexParameteri(target, GLES20.GL_TEXTURE_WRAP_S, convertWrapMode(tex.getWrap(WrapAxis.S))); |
1641 | - | |
1642 | + | |
1642 | 1643 | RendererUtil.checkGLError(); |
1643 | 1644 | break; |
1644 | 1645 | default: |
@@ -1670,7 +1671,7 @@ public class OGLESShaderRenderer implements Renderer { | ||
1670 | 1671 | // create texture |
1671 | 1672 | GLES20.glGenTextures(1, intBuf1); |
1672 | 1673 | RendererUtil.checkGLError(); |
1673 | - | |
1674 | + | |
1674 | 1675 | texId = intBuf1.get(0); |
1675 | 1676 | img.setId(texId); |
1676 | 1677 | objManager.registerObject(img); |
@@ -1684,13 +1685,13 @@ public class OGLESShaderRenderer implements Renderer { | ||
1684 | 1685 | if (context.boundTextureUnit != 0) { |
1685 | 1686 | GLES20.glActiveTexture(GLES20.GL_TEXTURE0); |
1686 | 1687 | RendererUtil.checkGLError(); |
1687 | - | |
1688 | + | |
1688 | 1689 | context.boundTextureUnit = 0; |
1689 | 1690 | } |
1690 | 1691 | |
1691 | 1692 | GLES20.glBindTexture(target, texId); |
1692 | 1693 | RendererUtil.checkGLError(); |
1693 | - | |
1694 | + | |
1694 | 1695 | context.boundTextures[0] = img; |
1695 | 1696 | } |
1696 | 1697 |
@@ -1779,7 +1780,7 @@ public class OGLESShaderRenderer implements Renderer { | ||
1779 | 1780 | |
1780 | 1781 | GLES20.glBindTexture(type, texId); |
1781 | 1782 | RendererUtil.checkGLError(); |
1782 | - | |
1783 | + | |
1783 | 1784 | textures[unit] = image; |
1784 | 1785 | |
1785 | 1786 | statistics.onTextureUse(tex.getImage(), true); |
@@ -1818,7 +1819,7 @@ public class OGLESShaderRenderer implements Renderer { | ||
1818 | 1819 | |
1819 | 1820 | GLES20.glDeleteTextures(1, intBuf1); |
1820 | 1821 | RendererUtil.checkGLError(); |
1821 | - | |
1822 | + | |
1822 | 1823 | image.resetObject(); |
1823 | 1824 | |
1824 | 1825 | statistics.onDeleteTexture(); |
@@ -1877,7 +1878,7 @@ public class OGLESShaderRenderer implements Renderer { | ||
1877 | 1878 | // create buffer |
1878 | 1879 | GLES20.glGenBuffers(1, intBuf1); |
1879 | 1880 | RendererUtil.checkGLError(); |
1880 | - | |
1881 | + | |
1881 | 1882 | bufId = intBuf1.get(0); |
1882 | 1883 | vb.setId(bufId); |
1883 | 1884 | objManager.registerObject(vb); |
@@ -1892,7 +1893,7 @@ public class OGLESShaderRenderer implements Renderer { | ||
1892 | 1893 | if (context.boundElementArrayVBO != bufId) { |
1893 | 1894 | GLES20.glBindBuffer(target, bufId); |
1894 | 1895 | RendererUtil.checkGLError(); |
1895 | - | |
1896 | + | |
1896 | 1897 | context.boundElementArrayVBO = bufId; |
1897 | 1898 | } |
1898 | 1899 | } else { |
@@ -1900,7 +1901,7 @@ public class OGLESShaderRenderer implements Renderer { | ||
1900 | 1901 | if (context.boundArrayVBO != bufId) { |
1901 | 1902 | GLES20.glBindBuffer(target, bufId); |
1902 | 1903 | RendererUtil.checkGLError(); |
1903 | - | |
1904 | + | |
1904 | 1905 | context.boundArrayVBO = bufId; |
1905 | 1906 | } |
1906 | 1907 | } |
@@ -1974,7 +1975,7 @@ public class OGLESShaderRenderer implements Renderer { | ||
1974 | 1975 | |
1975 | 1976 | GLES20.glDeleteBuffers(1, intBuf1); |
1976 | 1977 | RendererUtil.checkGLError(); |
1977 | - | |
1978 | + | |
1978 | 1979 | vb.resetObject(); |
1979 | 1980 | } |
1980 | 1981 | } |
@@ -1986,7 +1987,7 @@ public class OGLESShaderRenderer implements Renderer { | ||
1986 | 1987 | |
1987 | 1988 | GLES20.glDisableVertexAttribArray(idx); |
1988 | 1989 | RendererUtil.checkGLError(); |
1989 | - | |
1990 | + | |
1990 | 1991 | context.boundAttribs[idx] = null; |
1991 | 1992 | } |
1992 | 1993 | context.attribIndexList.copyNewToOld(); |
@@ -2046,7 +2047,7 @@ public class OGLESShaderRenderer implements Renderer { | ||
2046 | 2047 | if (context.boundArrayVBO != bufId) { |
2047 | 2048 | GLES20.glBindBuffer(GLES20.GL_ARRAY_BUFFER, bufId); |
2048 | 2049 | RendererUtil.checkGLError(); |
2049 | - | |
2050 | + | |
2050 | 2051 | context.boundArrayVBO = bufId; |
2051 | 2052 | } |
2052 | 2053 |
@@ -2058,7 +2059,7 @@ public class OGLESShaderRenderer implements Renderer { | ||
2058 | 2059 | vb.isNormalized(), |
2059 | 2060 | vb.getStride(), |
2060 | 2061 | 0); |
2061 | - | |
2062 | + | |
2062 | 2063 | RendererUtil.checkGLError(); |
2063 | 2064 | |
2064 | 2065 | attribs[loc] = vb; |
@@ -2102,7 +2103,7 @@ public class OGLESShaderRenderer implements Renderer { | ||
2102 | 2103 | if (context.boundElementArrayVBO != bufId) { |
2103 | 2104 | GLES20.glBindBuffer(GLES20.GL_ELEMENT_ARRAY_BUFFER, bufId); |
2104 | 2105 | RendererUtil.checkGLError(); |
2105 | - | |
2106 | + | |
2106 | 2107 | context.boundElementArrayVBO = bufId; |
2107 | 2108 | } |
2108 | 2109 |
@@ -2333,7 +2334,7 @@ public class OGLESShaderRenderer implements Renderer { | ||
2333 | 2334 | GLES10.glPointSize(mesh.getPointSize()); |
2334 | 2335 | context.pointSize = mesh.getPointSize(); |
2335 | 2336 | } |
2336 | - */ | |
2337 | + */ | |
2337 | 2338 | if (context.lineWidth != mesh.getLineWidth()) { |
2338 | 2339 | GLES20.glLineWidth(mesh.getLineWidth()); |
2339 | 2340 | RendererUtil.checkGLError(); |
@@ -2432,7 +2433,7 @@ public class OGLESShaderRenderer implements Renderer { | ||
2432 | 2433 | |
2433 | 2434 | loc = GLES20.glGetAttribLocation(programId, attributeName); |
2434 | 2435 | RendererUtil.checkGLError(); |
2435 | - | |
2436 | + | |
2436 | 2437 | if (loc < 0) { |
2437 | 2438 | attrib.setLocation(-1); |
2438 | 2439 | return; // not available in shader. |
@@ -2455,7 +2456,7 @@ public class OGLESShaderRenderer implements Renderer { | ||
2455 | 2456 | vb.isNormalized(), |
2456 | 2457 | vb.getStride(), |
2457 | 2458 | avb.getData()); |
2458 | - | |
2459 | + | |
2459 | 2460 | RendererUtil.checkGLError(); |
2460 | 2461 | |
2461 | 2462 | GLES20.glEnableVertexAttribArray(loc); |