diff --git a/jme3-core/src/main/java/com/jme3/system/AppSettings.java b/jme3-core/src/main/java/com/jme3/system/AppSettings.java index d06211671..e9a5ca553 100644 --- a/jme3-core/src/main/java/com/jme3/system/AppSettings.java +++ b/jme3-core/src/main/java/com/jme3/system/AppSettings.java @@ -143,6 +143,7 @@ public final class AppSettings extends HashMap { defaults.put("SettingsDialogImage", "/com/jme3/app/Monkey.png"); defaults.put("MinHeight", 0); defaults.put("MinWidth", 0); + defaults.put("GammaCorrection", true); // defaults.put("Icons", null); } @@ -745,6 +746,17 @@ public final class AppSettings extends HashMap { public void setSettingsDialogImage(String path) { putString("SettingsDialogImage", path); } + + /** + * Enables Gamma Correction + * This requires that the GPU supports GL_ARB_framebuffer_sRGB and will + * disabled otherwise. + * @param gammaCorrection + * (Default : true) + */ + public void setGammaCorrection(boolean gammaCorrection) { + putBoolean("GammaCorrection", gammaCorrection); + } /** * Get the framerate. @@ -914,4 +926,8 @@ public final class AppSettings extends HashMap { public String getSettingsDialogImage() { return getString("SettingsDialogImage"); } + + public boolean getGammaCorrection() { + return getBoolean("GammaCorrection"); + } } diff --git a/jme3-desktop/src/main/java/com/jme3/app/SettingsDialog.java b/jme3-desktop/src/main/java/com/jme3/app/SettingsDialog.java index 1b364bc39..84d0f1c15 100644 --- a/jme3-desktop/src/main/java/com/jme3/app/SettingsDialog.java +++ b/jme3-desktop/src/main/java/com/jme3/app/SettingsDialog.java @@ -90,6 +90,7 @@ public final class SettingsDialog extends JFrame { // UI components private JCheckBox vsyncBox = null; + private JCheckBox gammaBox = null; private JCheckBox fullscreenBox = null; private JComboBox displayResCombo = null; private JComboBox colorDepthCombo = null; @@ -355,7 +356,10 @@ public final class SettingsDialog extends JFrame { }); vsyncBox = new JCheckBox(resourceBundle.getString("checkbox.vsync")); vsyncBox.setSelected(source.isVSync()); - + + gammaBox = new JCheckBox(resourceBundle.getString("checkbox.gamma")); + gammaBox.setSelected(source.getGammaCorrection()); + gbc = new GridBagConstraints(); gbc.weightx = 0.5; gbc.gridx = 0; @@ -365,12 +369,19 @@ public final class SettingsDialog extends JFrame { mainPanel.add(fullscreenBox, gbc); gbc = new GridBagConstraints(); gbc.weightx = 0.5; - gbc.insets = new Insets(4, 16, 0, 4); + // gbc.insets = new Insets(4, 16, 0, 4); gbc.gridx = 2; - gbc.gridwidth = 2; + // gbc.gridwidth = 2; gbc.gridy = 1; - gbc.anchor = GridBagConstraints.WEST; + gbc.anchor = GridBagConstraints.EAST; mainPanel.add(vsyncBox, gbc); + gbc = new GridBagConstraints(); + gbc.weightx = 0.5; + gbc.gridx = 3; + gbc.gridy = 1; + gbc.anchor = GridBagConstraints.WEST; + mainPanel.add(gammaBox, gbc); + gbc = new GridBagConstraints(); gbc.insets = new Insets(4, 4, 4, 4); @@ -420,7 +431,7 @@ public final class SettingsDialog extends JFrame { gbc.gridy = 3; gbc.anchor = GridBagConstraints.WEST; mainPanel.add(antialiasCombo, gbc); - + // Set the button action listeners. Cancel disposes without saving, OK // saves. ok.addActionListener(new ActionListener() { @@ -517,6 +528,7 @@ public final class SettingsDialog extends JFrame { String display = (String) displayResCombo.getSelectedItem(); boolean fullscreen = fullscreenBox.isSelected(); boolean vsync = vsyncBox.isSelected(); + boolean gamma = gammaBox.isSelected(); int width = Integer.parseInt(display.substring(0, display.indexOf(" x "))); display = display.substring(display.indexOf(" x ") + 3); @@ -576,6 +588,7 @@ public final class SettingsDialog extends JFrame { source.setFrequency(freq); source.setFullscreen(fullscreen); source.setVSync(vsync); + source.setGammaCorrection(gamma); //source.setRenderer(renderer); source.setSamples(multisample); diff --git a/jme3-desktop/src/main/resources/com/jme3/app/SettingsDialog.properties b/jme3-desktop/src/main/resources/com/jme3/app/SettingsDialog.properties index c27594839..416fd85d2 100644 --- a/jme3-desktop/src/main/resources/com/jme3/app/SettingsDialog.properties +++ b/jme3-desktop/src/main/resources/com/jme3/app/SettingsDialog.properties @@ -5,6 +5,7 @@ button.cancel=Cancel checkbox.fullscreen=Fullscreen? checkbox.vsync=Vsync? +checkbox.gamma=Gamma correction label.resolutions=Screen Resolution label.colordepth=Color Depth