Hello,
I'll get an java.lang.IllegalArgumentException: unhandled entity class interface de.jreality.shader.TextShader when I'll try following:
Appearance ap = new Appearance();
ap.setAttribute(CommonAttributes.VERTEX_DRAW,false);
ap.setAttribute(CommonAttributes.EDGE_DRAW, true);
ap.setAttribute(CommonAttributes.TUBES_DRAW, false);
ap.setAttribute(CommonAttributes.FACE_DRAW, false);
ap.setAttribute(CommonAttributes.TUBE_RADIUS, 2.0);
sgc.setGeometry(indexLineFactory.getIndexedLineSet());
DefaultGeometryShader dgs =
ShaderUtility.createDefaultGeometryShader(ap,true);
DefaultLineShader dls =
(DefaultLineShader) dgs.createLineShader("default");
--> DefaultTextShader dts =
(DefaultTextShader) dls.createTextShader("default");
--> Line causing the exception
Is there a workaround for this?
Exception when creating DefaultTextShader
This appears to be a bug. If you are using the svn repository to get jReality, you can update; the current version of the ShaderUtility class fixes this problem.
If you are not using the svn repository source, then you can work around the problem by replacing the line causing the exception with the following:
If you are using default shaders it appears that the get...() methods are equivalent to the create..("default") variants. Since no one has written a non-default text shader, the code written here uses the get() variant, so the bug with the create() version went unnoticed.
If you have further questions please post, the team member who knows best returns from vacation next week and can answer in more detail.
If you are not using the svn repository source, then you can work around the problem by replacing the line causing the exception with the following:
Code: Select all
DefaultTextShader = (DefaultTextShader) dls.getTextShader();
If you have further questions please post, the team member who knows best returns from vacation next week and can answer in more detail.
jReality core developer
So far I am using the latest downloadable release. I might switch to svn repository at some stage.
Thank you for the workaround solution. I will try this. In the meantime I found this alternative solution as well by using
ap.setAttribute("lineShader.textShader.alignment",..
ap.setAttribute("lineShader.textShader.scale",..
...
Thank you for the workaround solution. I will try this. In the meantime I found this alternative solution as well by using
ap.setAttribute("lineShader.textShader.alignment",..
ap.setAttribute("lineShader.textShader.scale",..
...
Yes, that works too. I didn't want to frighten you with the direct writing of shader attributes in case you are more comfortable with the shader interfaces, but it's quite useful to know how to write the attributes directly in case, as here, something with the shader interfaces doesn't work correctly.
Note: As a general rule it's safer to use the attributes as they are defined in the class CommonAttributes rather than using the strings directly in case the definitions in CommonAttributes would ever change (which is admittedly unlikely). For example CommonAttributes.TEXT_SHADER is safer than "textShader".
Note: As a general rule it's safer to use the attributes as they are defined in the class CommonAttributes rather than using the strings directly in case the definitions in CommonAttributes would ever change (which is admittedly unlikely). For example CommonAttributes.TEXT_SHADER is safer than "textShader".
jReality core developer