PageRenderTime 54ms CodeModel.GetById 24ms RepoModel.GetById 1ms app.codeStats 0ms

/engine/src/main/java/org/terasology/config/RenderingConfig.java

https://gitlab.com/darithorn/Terasology
Java | 469 lines | 342 code | 102 blank | 25 comment | 1 complexity | 8f55117d1b9d71b4a82d9ccde79acc85 MD5 | raw file
  1. /*
  2. * Copyright 2014 MovingBlocks
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. package org.terasology.config;
  17. import org.lwjgl.opengl.DisplayMode;
  18. import org.lwjgl.opengl.PixelFormat;
  19. import org.terasology.rendering.cameras.PerspectiveCameraSettings;
  20. import org.terasology.rendering.nui.layers.mainMenu.videoSettings.ScreenshotSize;
  21. import org.terasology.rendering.world.viewDistance.ViewDistance;
  22. import java.beans.PropertyChangeListener;
  23. import java.beans.PropertyChangeSupport;
  24. /**
  25. */
  26. public class RenderingConfig {
  27. public static final String VIEW_DISTANCE = "viewDistance";
  28. private PixelFormat pixelFormat;
  29. private int windowPosX;
  30. private int windowPosY;
  31. private int windowWidth;
  32. private int windowHeight;
  33. private boolean fullscreen;
  34. private ViewDistance viewDistance;
  35. private boolean flickeringLight;
  36. private boolean animateGrass;
  37. private boolean animateWater;
  38. private float fieldOfView;
  39. private boolean cameraBobbing;
  40. private boolean renderPlacingBox;
  41. private int blurIntensity;
  42. private boolean reflectiveWater;
  43. private boolean vignette;
  44. private boolean motionBlur;
  45. private boolean ssao;
  46. private boolean filmGrain;
  47. private boolean outline;
  48. private boolean lightShafts;
  49. private boolean eyeAdaptation;
  50. private boolean bloom;
  51. private boolean dynamicShadows;
  52. private boolean oculusVrSupport;
  53. private int maxTextureAtlasResolution;
  54. private int maxChunksUsedForShadowMapping;
  55. private int shadowMapResolution;
  56. private boolean normalMapping;
  57. private boolean parallaxMapping;
  58. private boolean dynamicShadowsPcfFiltering;
  59. private boolean cloudShadows;
  60. private boolean renderNearest;
  61. private int particleEffectLimit;
  62. private int frameLimit;
  63. private int meshLimit;
  64. private boolean inscattering;
  65. private boolean localReflections;
  66. private boolean vSync;
  67. private boolean clampLighting;
  68. private int fboScale;
  69. private boolean dumpShaders;
  70. private ScreenshotSize screenshotSize;
  71. private String screenshotFormat;
  72. private PerspectiveCameraSettings cameraSettings;
  73. private RenderingDebugConfig debug = new RenderingDebugConfig();
  74. private transient PropertyChangeSupport propertyChangeSupport = new PropertyChangeSupport(this);
  75. public PerspectiveCameraSettings getCameraSettings() {
  76. return cameraSettings;
  77. }
  78. public PixelFormat getPixelFormat() {
  79. return pixelFormat;
  80. }
  81. public void setPixelFormat(PixelFormat pixelFormat) {
  82. this.pixelFormat = pixelFormat;
  83. }
  84. public int getWindowPosX() {
  85. return windowPosX;
  86. }
  87. public void setWindowPosX(int posX) {
  88. this.windowPosX = posX;
  89. }
  90. public int getWindowPosY() {
  91. return windowPosY;
  92. }
  93. public void setWindowPosY(int posY) {
  94. this.windowPosY = posY;
  95. }
  96. public int getWindowWidth() {
  97. return windowWidth;
  98. }
  99. public void setWindowWidth(int windowWidth) {
  100. this.windowWidth = windowWidth;
  101. }
  102. public int getWindowHeight() {
  103. return windowHeight;
  104. }
  105. public void setWindowHeight(int windowHeight) {
  106. this.windowHeight = windowHeight;
  107. }
  108. public DisplayMode getDisplayMode() {
  109. return new DisplayMode(windowWidth, windowHeight);
  110. }
  111. public boolean isFullscreen() {
  112. return fullscreen;
  113. }
  114. public void setFullscreen(boolean fullscreen) {
  115. this.fullscreen = fullscreen;
  116. }
  117. public ViewDistance getViewDistance() {
  118. return viewDistance;
  119. }
  120. /**
  121. * Sets the view distance and notifies the property change listeners registered via
  122. * {@link RenderingConfig#subscribe(PropertyChangeListener)} that listen for the property {@link #VIEW_DISTANCE}.
  123. * @param viewDistance the new view distance
  124. */
  125. public void setViewDistance(ViewDistance viewDistance) {
  126. ViewDistance oldValue = this.viewDistance;
  127. this.viewDistance = viewDistance;
  128. propertyChangeSupport.firePropertyChange(VIEW_DISTANCE, oldValue, viewDistance);
  129. }
  130. public boolean isFlickeringLight() {
  131. return flickeringLight;
  132. }
  133. public void setFlickeringLight(boolean flickeringLight) {
  134. this.flickeringLight = flickeringLight;
  135. }
  136. public boolean isAnimateGrass() {
  137. return animateGrass;
  138. }
  139. public void setAnimateGrass(boolean animateGrass) {
  140. this.animateGrass = animateGrass;
  141. }
  142. public boolean isAnimateWater() {
  143. return animateWater;
  144. }
  145. public void setAnimateWater(boolean animateWater) {
  146. this.animateWater = animateWater;
  147. }
  148. public boolean isDynamicShadows() {
  149. return dynamicShadows;
  150. }
  151. public void setDynamicShadows(boolean dynamicShadows) {
  152. this.dynamicShadows = dynamicShadows;
  153. }
  154. public float getFieldOfView() {
  155. return fieldOfView;
  156. }
  157. public void setFieldOfView(float fieldOfView) {
  158. this.fieldOfView = fieldOfView;
  159. }
  160. public boolean isCameraBobbing() {
  161. return cameraBobbing;
  162. }
  163. public void setCameraBobbing(boolean cameraBobbing) {
  164. this.cameraBobbing = cameraBobbing;
  165. }
  166. public boolean isRenderPlacingBox() {
  167. return renderPlacingBox;
  168. }
  169. public void setRenderPlacingBox(boolean renderPlacingBox) {
  170. this.renderPlacingBox = renderPlacingBox;
  171. }
  172. public int getBlurRadius() {
  173. return Math.max(1, blurIntensity);
  174. }
  175. public int getBlurIntensity() {
  176. return blurIntensity;
  177. }
  178. public void setBlurIntensity(int blurIntensity) {
  179. this.blurIntensity = blurIntensity;
  180. }
  181. public boolean isReflectiveWater() {
  182. return reflectiveWater;
  183. }
  184. public void setReflectiveWater(boolean reflectiveWater) {
  185. this.reflectiveWater = reflectiveWater;
  186. }
  187. public boolean isVignette() {
  188. return vignette;
  189. }
  190. public void setVignette(boolean vignette) {
  191. this.vignette = vignette;
  192. }
  193. public boolean isMotionBlur() {
  194. return motionBlur && !isOculusVrSupport();
  195. }
  196. public void setMotionBlur(boolean motionBlur) {
  197. this.motionBlur = motionBlur;
  198. }
  199. public boolean isSsao() {
  200. return ssao;
  201. }
  202. public void setSsao(boolean ssao) {
  203. this.ssao = ssao;
  204. }
  205. public boolean isFilmGrain() {
  206. return filmGrain;
  207. }
  208. public void setFilmGrain(boolean filmGrain) {
  209. this.filmGrain = filmGrain;
  210. }
  211. public boolean isOutline() {
  212. return outline;
  213. }
  214. public void setOutline(boolean outline) {
  215. this.outline = outline;
  216. }
  217. public boolean isLightShafts() {
  218. return lightShafts;
  219. }
  220. public void setLightShafts(boolean lightShafts) {
  221. this.lightShafts = lightShafts;
  222. }
  223. public boolean isEyeAdaptation() {
  224. return eyeAdaptation;
  225. }
  226. public void setEyeAdaptation(boolean eyeAdaptation) {
  227. this.eyeAdaptation = eyeAdaptation;
  228. }
  229. public boolean isBloom() {
  230. return bloom;
  231. }
  232. public void setBloom(boolean bloom) {
  233. this.bloom = bloom;
  234. }
  235. public boolean isOculusVrSupport() {
  236. return oculusVrSupport;
  237. }
  238. public void setOculusVrSupport(boolean oculusVrSupport) {
  239. this.oculusVrSupport = oculusVrSupport;
  240. }
  241. public int getMaxTextureAtlasResolution() {
  242. return maxTextureAtlasResolution;
  243. }
  244. public void setMaxTextureAtlasResolution(int maxTextureAtlasResolution) {
  245. this.maxTextureAtlasResolution = maxTextureAtlasResolution;
  246. }
  247. public int getMaxChunksUsedForShadowMapping() {
  248. return maxChunksUsedForShadowMapping;
  249. }
  250. public void setMaxChunksUsedForShadowMapping(int maxChunksUsedForShadowMapping) {
  251. this.maxChunksUsedForShadowMapping = maxChunksUsedForShadowMapping;
  252. }
  253. public int getShadowMapResolution() {
  254. return shadowMapResolution;
  255. }
  256. public void setShadowMapResolution(int shadowMapResolution) {
  257. this.shadowMapResolution = shadowMapResolution;
  258. }
  259. public boolean isNormalMapping() {
  260. return normalMapping;
  261. }
  262. public void setNormalMapping(boolean normalMapping) {
  263. this.normalMapping = normalMapping;
  264. }
  265. public boolean isParallaxMapping() {
  266. return parallaxMapping;
  267. }
  268. public void setParallaxMapping(boolean parallaxMapping) {
  269. this.parallaxMapping = parallaxMapping;
  270. }
  271. public boolean isDynamicShadowsPcfFiltering() {
  272. return dynamicShadowsPcfFiltering;
  273. }
  274. public void setDynamicShadowsPcfFiltering(boolean dynamicShadowsPcfFiltering) {
  275. this.dynamicShadowsPcfFiltering = dynamicShadowsPcfFiltering;
  276. }
  277. public boolean isCloudShadows() {
  278. return cloudShadows;
  279. }
  280. public void setCloudShadows(boolean cloudShadows) {
  281. this.cloudShadows = cloudShadows;
  282. }
  283. public boolean isLocalReflections() {
  284. return this.localReflections;
  285. }
  286. public void setLocalReflections(boolean localReflections) {
  287. this.localReflections = localReflections;
  288. }
  289. public boolean isInscattering() {
  290. return this.inscattering;
  291. }
  292. public void setInscattering(boolean inscattering) {
  293. this.inscattering = inscattering;
  294. }
  295. public boolean isRenderNearest() {
  296. return renderNearest;
  297. }
  298. public void setRenderNearest(boolean renderNearest) {
  299. this.renderNearest = renderNearest;
  300. }
  301. public int getParticleEffectLimit() {
  302. return particleEffectLimit;
  303. }
  304. public void setParticleEffectLimit(int particleEffectLimit) {
  305. this.particleEffectLimit = particleEffectLimit;
  306. }
  307. public int getMeshLimit() {
  308. return meshLimit;
  309. }
  310. public void setMeshLimit(int meshLimit) {
  311. this.meshLimit = meshLimit;
  312. }
  313. public boolean isVSync() {
  314. return this.vSync;
  315. }
  316. public void setVSync(boolean value) {
  317. this.vSync = value;
  318. }
  319. public RenderingDebugConfig getDebug() {
  320. return debug;
  321. }
  322. public int getFrameLimit() {
  323. return frameLimit;
  324. }
  325. public void setFrameLimit(int frameLimit) {
  326. this.frameLimit = frameLimit;
  327. }
  328. public int getFboScale() {
  329. return fboScale;
  330. }
  331. public void setFboScale(int fboScale) {
  332. this.fboScale = fboScale;
  333. }
  334. public boolean isClampLighting() {
  335. return clampLighting;
  336. }
  337. public void setClampLighting(boolean clampLighting) {
  338. this.clampLighting = clampLighting;
  339. }
  340. public ScreenshotSize getScreenshotSize() {
  341. return screenshotSize;
  342. }
  343. public void setScreenshotSize(ScreenshotSize screenshotSize) {
  344. this.screenshotSize = screenshotSize;
  345. }
  346. public String getScreenshotFormat() {
  347. return screenshotFormat;
  348. }
  349. public void setScreenshotFormat(String screenshotFormat) {
  350. this.screenshotFormat = screenshotFormat;
  351. }
  352. public boolean isDumpShaders() {
  353. return dumpShaders;
  354. }
  355. public void setDumpShaders(boolean dumpShaders) {
  356. this.dumpShaders = dumpShaders;
  357. }
  358. /**
  359. * Subscribe a listener that gets nofified when a property cahnges..
  360. */
  361. public void subscribe(PropertyChangeListener changeListener) {
  362. this.propertyChangeSupport.addPropertyChangeListener(changeListener);
  363. }
  364. public void unsubscribe(PropertyChangeListener changeListener) {
  365. this.propertyChangeSupport.removePropertyChangeListener(changeListener);
  366. }
  367. }