Merge pull request #894 from wolsen/bug/878

Fix transparency display issue
This commit is contained in:
Joe Pfeiffer 2021-06-22 15:10:22 -06:00 committed by GitHub
commit dcc3c43bc3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 2 deletions

View File

@ -101,15 +101,23 @@ public class RealisticRenderer extends RocketRenderer {
render(gl, geom, Surface.EDGES, app, false, alpha);
}
protected float[] convertColor(Appearance a, float alpha) {
float[] color = new float[4];
convertColor(a.getPaint(), color);
return color;
}
private void render(GL2 gl, Geometry g, Surface which, Appearance a, boolean decals, float alpha) {
final Decal t = a.getTexture();
final Texture tex = textures.getTexture(t);
gl.glLightModeli(GL2.GL_LIGHT_MODEL_COLOR_CONTROL, GL2.GL_SEPARATE_SPECULAR_COLOR);
float[] convertedColor = this.convertColor(a, alpha);
for (int i=0; i < convertedColor.length; i++) {
color[i] = convertedColor[i];
}
convertColor(a.getPaint(), color);
color[3] = alpha;//re-set to "alpha" so that Unfinished renderer will show interior parts.
gl.glMaterialfv(GL.GL_FRONT, GLLightingFunc.GL_DIFFUSE, color, 0);
gl.glMaterialfv(GL.GL_FRONT, GLLightingFunc.GL_AMBIENT, color, 0);
@ -149,6 +157,7 @@ public class RealisticRenderer extends RocketRenderer {
gl.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA);
gl.glEnable(GL.GL_BLEND);
gl.glEnable(GL2.GL_COLOR_MATERIAL);
gl.glDepthFunc(GL.GL_LEQUAL);
gl.glMatrixMode(GLMatrixFunc.GL_MODELVIEW);
@ -167,6 +176,7 @@ public class RealisticRenderer extends RocketRenderer {
gl.glPopMatrix();
gl.glMatrixMode(GLMatrixFunc.GL_MODELVIEW);
gl.glDisable(GL2.GL_COLOR_MATERIAL);
tex.disable(gl);
}

View File

@ -21,4 +21,12 @@ public class UnfinishedRenderer extends RealisticRenderer {
protected Appearance getAppearance(RocketComponent c) {
return DefaultAppearance.getDefaultAppearance(c);
}
@Override
protected float[] convertColor(final Appearance a, float alpha) {
float[] color = new float[4];
convertColor(a.getPaint(), color);
color[3] = alpha;//re-set to "alpha" so that Unfinished renderer will show interior parts.
return color;
}
}