|
目前想到的解决办法……
- public class GlAttribModel implements AutoCloseable {
- boolean alpha = GL11.glGetBoolean(GL11.GL_ALPHA_TEST);
- boolean blend = GL11.glGetBoolean(GL11.GL_BLEND);
- boolean depth = GL11.glGetBoolean(GL11.GL_DEPTH_TEST);
- boolean lighting = GL11.glGetBoolean(GL11.GL_LIGHTING);
- boolean[] light = new boolean[]{
- GL11.glGetBoolean(GL11.GL_LIGHT0),
- GL11.glGetBoolean(GL11.GL_LIGHT1),
- GL11.glGetBoolean(GL11.GL_LIGHT2),
- GL11.glGetBoolean(GL11.GL_LIGHT3),
- GL11.glGetBoolean(GL11.GL_LIGHT4),
- GL11.glGetBoolean(GL11.GL_LIGHT5),
- GL11.glGetBoolean(GL11.GL_LIGHT6),
- GL11.glGetBoolean(GL11.GL_LIGHT7)
- };
- public void apply() {
- if (alpha) {GlStateManager.enableAlpha();} else {GlStateManager.disableAlpha();}
- if (blend) {GlStateManager.enableBlend();} else {GlStateManager.disableBlend();}
- if (depth) {GlStateManager.enableDepth();} else {GlStateManager.disableDepth();}
- if (lighting) {GlStateManager.enableLighting();} else {GlStateManager.disableLighting();}
- for (int i = 0; i < 8; i++)
- if (light[i]) {GlStateManager.enableLight(i);} else {GlStateManager.disableLight(i);}
- }
- @Override public void close() {apply();}
- }
复制代码 |
|