Display.h 73 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669
  1. /******************************************************************************
  2. Use 'Display' to handle all display related functions.
  3. Including:
  4. -setting rendering options
  5. -handling basic 2D drawing
  6. /******************************************************************************/
  7. enum ASPECT_MODE : Byte // Aspect Ratio Mode, controls setting the sizes of screen coordinates - D.w and D.h
  8. {
  9. ASPECT_Y , // sets D.h to 1.0, D.w will be proportional to D.h depending on the display aspect and selected resolution
  10. ASPECT_X , // sets D.w to 1.0, D.h will be proportional to D.w depending on the display aspect and selected resolution
  11. ASPECT_SMALLER, // this mode is useful for Mobile devices which can be rotated and changed aspect will not affect the display scale, 1.0 will be set to D.w and D.h will be set proportionally (if width is smaller than height) and 1.0 will be set to D.h and D.w will be set proportionally (if height is smaller than width)
  12. ASPECT_NUM , // number of aspect ratio modes
  13. };
  14. enum BUMP_MODE : Byte // Bump Mapping Mode
  15. {
  16. BUMP_FLAT , // flat
  17. BUMP_NORMAL , // normal
  18. BUMP_PARALLAX, // parallax
  19. BUMP_RELIEF , // relief
  20. BUMP_NUM , // number of bump mapping modes
  21. };
  22. enum AMBIENT_MODE : Byte // Ambient Occlusion Mode
  23. {
  24. AMBIENT_FLAT , // flat
  25. AMBIENT_LOW , // low quality
  26. AMBIENT_MED , // medium quality
  27. AMBIENT_HIGH , // high quality
  28. AMBIENT_ULTRA, // ultra quality
  29. AMBIENT_NUM , // number of ambient modes
  30. };
  31. enum AMBIENT_SOFT_MODE : Byte
  32. {
  33. AMBIENT_SOFT_NUM=6,
  34. };
  35. enum SHADOW_MODE : Byte // Shadowing Mode
  36. {
  37. SHADOW_NONE, // none
  38. SHADOW_MAP , // shadow mapping
  39. SHADOW_NUM , // number of shadowing modes
  40. };
  41. enum SHADOW_SOFT_MODE : Byte
  42. {
  43. SHADOW_SOFT_NUM=6,
  44. };
  45. enum MOTION_MODE : Byte // Motion Blur Mode
  46. {
  47. MOTION_NONE , // none
  48. MOTION_CAMERA , // screen is blurred according to camera velocities only, objects velocities are not taken into account, objects are treated as if they were all stationary (their velocity is zero)
  49. MOTION_CAMERA_OBJECT, // screen is blurred according to camera and object velocities, available only in RT_DEFERRED renderer
  50. MOTION_NUM , // number of motion blur modes
  51. };
  52. enum DILATE_MODE : Byte // Motion Blur Velocity Dilate Mode
  53. {
  54. DILATE_ORTHO , // orthogonal mode is the fastest, but makes diagonal velocities a bit shorter
  55. DILATE_MIXED , // achieves quality and performance between DILATE_ORTHO and DILATE_ORTHO2
  56. DILATE_ORTHO2, // slower than DILATE_ORTHO but handles diagonal velocities better
  57. DILATE_ROUND , // best quality but slowest
  58. DILATE_NUM , // number of dilate modes
  59. };
  60. enum DOF_MODE : Byte // Depth of Field Mode
  61. {
  62. DOF_NONE , // none
  63. DOF_GAUSSIAN, // based on Gaussian Blur, fast but not realistic
  64. DOF_NUM , // number of depth of field modes
  65. };
  66. enum EDGE_DETECT_MODE : Byte // Edge Detect Mode
  67. {
  68. EDGE_DETECT_NONE, // disabled
  69. EDGE_DETECT_THIN, // thin edges
  70. EDGE_DETECT_FAT , // fat smoothed edges (slower)
  71. EDGE_DETECT_NUM , // number of edge detect modes
  72. };
  73. enum EDGE_SOFTEN_MODE : Byte // Edge Softening Mode
  74. {
  75. EDGE_SOFTEN_NONE, // disabled
  76. EDGE_SOFTEN_FXAA, // Fast Approximate Anti Aliasing
  77. #if SUPPORT_MLAA
  78. EDGE_SOFTEN_MLAA, // Morphological Anti Aliasing
  79. #endif
  80. EDGE_SOFTEN_SMAA, // Subpixel Morphological Anti Aliasing
  81. EDGE_SOFTEN_NUM , // number of edge softening modes
  82. };
  83. enum TEXTURE_USAGE : Byte // Information about using additional texture maps in material
  84. {
  85. TEX_USE_DISABLE, // map is always disabled
  86. TEX_USE_SINGLE , // map is enabled for single materials only
  87. TEX_USE_MULTI , // map is enabled for single materials and multiple materials which are blended together
  88. TEX_USE_NUM , // number of texture maps usage modes
  89. };
  90. enum FOV_MODE : Byte // Field of View mode, determines calculating actual fov values
  91. {
  92. FOV_Y , // vertical fov will be taken from given value, horizontal fov will be calculated proportionally
  93. FOV_X , // horizontal fov will be taken from given value, vertical fov will be calculated proportionally
  94. FOV_XY, // both horizontal and vertical fov's will be taken from given value
  95. #if EE_PRIVATE
  96. FOV_ORTHO_Y, // orthogonal, vertical fov will be taken from 'fov', horizontal will be calculated proportionally
  97. FOV_ORTHO_X, // orthogonal, horizontal fov will be taken from 'fov', vertical will be calculated proportionally
  98. FOV_ORTHO , // orthogonal, custom fov will be taken from 'fov'
  99. #endif
  100. };
  101. enum SHADER_MODEL : Byte
  102. {
  103. SM_UNKNOWN, // unknown
  104. SM_GL_ES_2, // (OpenGL ES 2.0 )
  105. SM_GL_ES_3, // (OpenGL ES 3.0 )
  106. SM_GL , // (OpenGL for Desktop)
  107. SM_3 , // Model 3.0 (DirectX 9 )
  108. SM_4 , // Model 4.0 (DirectX 10 )
  109. SM_4_1 , // Model 4.1 (DirectX 10.1 )
  110. SM_5 , // Model 5.0 (DirectX 11 )
  111. };
  112. #if EE_PRIVATE
  113. inline Bool FovPerspective(FOV_MODE mode) {return mode< FOV_ORTHO_Y ;} // if fov mode is perspective
  114. inline Bool FovOrthogonal (FOV_MODE mode) {return mode>=FOV_ORTHO_Y ;} // if fov mode is orthogonal
  115. inline Bool FovHorizontal (FOV_MODE mode) {return mode==FOV_X || mode==FOV_ORTHO_X;} // if fov mode is horizontal
  116. #endif
  117. /******************************************************************************/
  118. struct Display : DisplayState, DisplayDraw // Display Control
  119. {
  120. Bool (*lost )(), // pointer to custom function (may be null) called when display is lost , it must return true on success and false on fail
  121. (*reset)(); // pointer to custom function (may be null) called when display is reset, it must return true on success and false on fail
  122. void (*screen_changed)(Flt old_width, Flt old_height); // pointer to custom function (may be null) called when screen proportions have changed
  123. Flt (*shadow_step)(Int i, Int num); // pointer to custom function (may be null) which allows to manually specify the fraction range of the i-th out of 'num' shadow map splits
  124. Int (*image_load_shrink)(ImageHeader &image_header, C Str &name); // pointer to custom function (may be null) called when 'Image' is being loaded from a File allowing to load the Image as smaller than how it is stored in the File. 'name'=file name of the image. You can use this for example when targeting devices with small amount of RAM and wishing to load the Images as half their size. Inside the function you should return by how many steps the final size should be divided by 2. For example, if an Image is being loaded with its original size = 1024x1024, based on returned value the final size will be adjusted accordingly: return value 0 -> 1024x1024 (original size), return value 1 -> 512x512 (half size), return value 2 -> 256x256 (quarter size), and so on.
  125. void (*set_shader)(); // pointer to custom function (may be null) called when Mesh shaders need to be updated, when changing some display options during application runtime, meshes require to have their shaders updated, Meshes created by using Cache are processed automatically, however manually created meshes need to be processed manually, to do this - create a global function which calls 'Mesh.setShader()' on all manually created meshes and then in 'InitPre' function set 'D.set_shader' to point to that function
  126. // get
  127. C Vec2& size ()C {return _size ;} // get Application Screen Size (in screen coordinates, depends on selected resolution, aspect mode and scale
  128. Flt w ()C {return _size.x ;} // get Application Screen Width (in screen coordinates, depends on selected resolution, aspect mode and scale, usually something near 1.3)
  129. Flt h ()C {return _size.y ;} // get Application Screen Height (in screen coordinates, depends on selected resolution, aspect mode and scale, usually something near 1.0)
  130. C Vec2& size2 ()C {return _size2 ;} // get Application Screen Size *2 (in screen coordinates, depends on selected resolution, aspect mode and scale
  131. Flt w2 ()C {return _size2.x ;} // get Application Screen Width *2 (in screen coordinates, depends on selected resolution, aspect mode and scale, usually something near 2.6)
  132. Flt h2 ()C {return _size2.y ;} // get Application Screen Height*2 (in screen coordinates, depends on selected resolution, aspect mode and scale, usually something near 2.0)
  133. C VecI2& res ()C {return _res ;} // get Application Resolution (in pixels)
  134. Int resW ()C {return _res.x ;} // get Application Resolution Width (in pixels)
  135. Int resH ()C {return _res.y ;} // get Application Resolution Height (in pixels)
  136. C VecI2& render ()C {return _render_res ;} // get Application Rendering Resolution (in pixels), which is Resolution affected by 'density'
  137. Int renderW ()C {return _render_res.x ;} // get Application Rendering Resolution Width (in pixels), which is Resolution affected by 'density'
  138. Int renderH ()C {return _render_res.y ;} // get Application Rendering Resolution Height (in pixels), which is Resolution affected by 'density'
  139. VecI2 screen ()C; // get Main Display Screen (in pixels) at the current moment
  140. Int screenW ()C {return screen().x ;} // get Main Display Screen Width (in pixels) at the current moment
  141. Int screenH ()C {return screen().y ;} // get Main Display Screen Height (in pixels) at the current moment
  142. Int freq ()C {return _freq_got ;} // get Display Screen Frequency (refresh rate)
  143. SHADER_MODEL shaderModel ()C {return _shader_model ;} // get available Shader Model
  144. Str8 shaderModelName()C; // get available Shader Model in text format
  145. Str8 apiName ()C; // get Rendering API in text format
  146. Int maxTexFilter ()C {return _max_tex_filter;} // get maximum available Anisotropic Filtering
  147. Int maxTexSize ()C {return _max_tex_size ;} // get maximum available Texture Size
  148. C Mems<VecI2>& modes ()C {return _modes ;} // get fullscreen display modes, where x=width, y=height (in pixels)
  149. C Str8& deviceName ()C {return _device_name ;} // get GPU device name
  150. Long deviceMemory ()C {return _device_mem ;} // get GPU memory (-1 if unknown)
  151. Bool canDraw ()C {return _can_draw ;} // if drawing graphics is available (this can be false when APP_ALLOW_NO_GPU was enabled and GPU was not found)
  152. Bool smallSize ()C; // if display device is of a small size (phone size)
  153. Flt browserZoom ()C; // get current browser zoom level (1.0=100%, 2.0=200%, etc), this is valid only for the WEB platform (others return 1.0)
  154. // settings
  155. Display& mode (Int w=-1, Int h=-1, Int full=-1 ); // set Display Resolution Mode, -1=keep original value, if the method fails then previous mode is restored, if previous mode can't be restored then Exit is called
  156. Display& toggle( Bool window_size=false); // toggle Fullscreen/Windowed Mode, 'window_size'=if when switching to fullscreen want to set resolution from current window size instead of desktop size
  157. Display& full (Bool full, Bool window_size=false); // set Fullscreen Mode , 'window_size'=if when switching to fullscreen want to set resolution from current window size instead of desktop size
  158. Bool full ( )C {return _full;} // if in Fullscreen Mode (true/false, default=false)
  159. #if EE_PRIVATE
  160. void setSync ( );
  161. Bool densityFast (Byte density );
  162. void densityUpdate ( );
  163. void gammaSet ( );
  164. Bool shaderModelGLES2()C {return GL_ES && shaderModel()==SM_GL_ES_2;} // if shaderModel()==SM_GL_ES_2
  165. Bool notShaderModelGLES2()C {return (!GL_ES) || shaderModel()!=SM_GL_ES_2;} // if shaderModel()!=SM_GL_ES_2
  166. Bool densityUsed ()C {return _density!=127 ;} // get if Density is != 1.0
  167. Bool densityUpsample ()C {return _density> 127 ;} // get if Density is > 1.0
  168. Byte densityByte ()C {return _density ;} // get Density Byte
  169. Bool multiSample ()C {return _samples>1 ;} // get if Multi Sampling is used
  170. Bool highPrecNrmCalcIs()C {return highPrecNrmCalc() && !highPrecNrmRT();}
  171. void aspectRatioEx (Bool force=true, Bool quiet=false);
  172. Int maxShaderMatrixes()C; // max number of matrixes that can be set in shaders
  173. Bool meshStorageSigned()C; // if supports signed storage for mesh vtx components
  174. Bool meshBoneSplit ()C; // if requires usage of Bone Splits for meshes with big amount of bones
  175. Bool hwInstancing ()C; // if hardware instancing is supported
  176. Bool signedNrmRT ()C; // if Normal Render Target is signed
  177. Bool signedVelRT ()C; // if Velocity Render Target is signed
  178. Bool highMonitorPrecision ()C; // if high Monitor Precision
  179. #endif
  180. Rect rect ()C {return Rect(-w(), -h(), w(), h());} // get full screen rectangle
  181. Display& exclusive (Bool exclusive ); Bool exclusive ()C {return _exclusive ;} // get/set if fullscreen mode should be exclusive (true/false , default= true ), this affects only Windows DirectX fullscreen mode, exclusive offers better performance, non-exclusive offers faster Alt+Tab switching
  182. Display& density (Flt density ); Flt density ()C; // get/set Rendering Pixel Density (0..2 , default= 1 ), density affects the number of pixels used during rendering, density=2 makes the rendering use 2x bigger render targets (super sampling) but slower performance, density=0.5 makes the rendering use 2x smaller render targets making the result more blurry but with faster performance, the change is NOT instant, avoid calling real-time
  183. Display& densityFilter (FILTER_TYPE filter ); FILTER_TYPE densityFilter ()C {return _density_filter ;} // get/set Density Filtering (FILTER_TYPE , default=FILTER_CUBIC_FAST (FILTER_LINEAR for Mobile)), density filter affects filtering used when up-scaling the image, this method supports only FILTER_NONE, FILTER_LINEAR, FILTER_CUBIC_FAST and FILTER_CUBIC, the change is instant, you can call it real-time
  184. Display& samples (Byte samples ); Byte samples ()C {return _samples ;} // set/get Sample Count for Multi Sampling AA (1..16 , default= 1 ), multi-sampling for RT_DEFERRED renderer can be enabled only for ShaderModel>=4.1, enabling multi-sampling for ShaderModel<=4.0 disables all depth-based effects, the change is NOT instant, avoid calling real-time
  185. Display& scale (Flt scale ); Flt scale ()C {return _scale ;} // get/set Draw Scale (0..Inf , default= 1 ), changing display scale affects display screen sizes D.w and D.h, the change is NOT instant, avoid calling real-time
  186. Display& aspectMode (ASPECT_MODE mode ); ASPECT_MODE aspectMode ()C {return _aspect_mode ;} // set/get Aspect Mode (ASPECT_MODE , default= ASPECT_Y (ASPECT_SMALLER for Mobile))
  187. Display& aspectRatio (Flt aspect_ratio); Flt aspectRatio ()C {return _aspect_ratio ;} // set/get Display Aspect Ratio (0=autodetect, 4/3, 5/4, 16/9, 16/10, default= 0 )
  188. Display& bumpMode (BUMP_MODE mode ); BUMP_MODE bumpMode ()C {return _bump_mode ;} // set/get Bump Mapping Mode (BUMP_MODE , default= BUMP_PARALLAX (BUMP_FLAT for Mobile)), using this method during application runtime requires setting 'D.set_shader' (please check comments on 'D.set_shader' for more info), the change is NOT instant, avoid calling real-time
  189. Display& gamma (Flt gamma ); Flt gamma ()C {return _gamma ;} // set/get Gamma value (-Inf..Inf , default= 0 ), using gamma modifies hardware color processing and does not reduce rendering performance
  190. Display& monitorPrecision (IMAGE_PRECISION precision ); IMAGE_PRECISION monitorPrecision ()C {return _monitor_prec ;} // set/get Monitor Precision (IMAGE_PRECISION , default=IMAGE_PRECISION_8 ), use this function to specify the exact precision of your Monitor Screen, use IMAGE_PRECISION_8 for 8-bit per-channel (24-bit total) screens, and IMAGE_PRECISION_10 for 10-bit per channel (30-bit total) screens, avoid setting higher precision than what your screen can actually support because instead of getting higher quality results you will get lower quality
  191. Display& highPrecColRT (Bool on ); Bool highPrecColRT ()C {return _hp_col_rt ;} // set/get Color Render Target High Precision (true/false , default= false ), enabling high precision render targets gives higher quality graphics at the cost of slower performance and more memory usage, high precision means that Render Targets are created using a different format, that is more precise but also uses more memory and bandwidth, Color Render Target is used for storing colors in Deferred Renderer , this affects precision of color textures adjusted by material colors, the change is NOT instant, avoid calling real-time
  192. Display& highPrecNrmRT (Bool on ); Bool highPrecNrmRT ()C {return _hp_nrm_rt ;} // set/get Normal Render Target High Precision (true/false , default= false ), enabling high precision render targets gives higher quality graphics at the cost of slower performance and more memory usage, high precision means that Render Targets are created using a different format, that is more precise but also uses more memory and bandwidth, Normal Render Target is used for storing normal vectors in Deferred Renderer , this affects lighting calculations (especially specular) to be more precise, an alternative option to increase the light precision is to use 'highPrecNrmCalc' instead, the change is NOT instant, avoid calling real-time
  193. Display& highPrecLumRT (Bool on ); Bool highPrecLumRT ()C {return _hp_lum_rt ;} // set/get Light Render Target High Precision (true/false , default= false ), enabling high precision render targets gives higher quality graphics at the cost of slower performance and more memory usage, high precision means that Render Targets are created using a different format, that is more precise but also uses more memory and bandwidth, Light Render Target is used for storing light intensity in Deferred Renderer , most importantly it allows to store light intensities with values higher than 1.0 (which is the limit for low precision render targets), the change is NOT instant, avoid calling real-time
  194. Display& litColRTPrecision(IMAGE_PRECISION precision ); IMAGE_PRECISION litColRTPrecision()C {return _lit_col_rt_prec;} // set/get Lit Color Render Target Precision (IMAGE_PRECISION , default=IMAGE_PRECISION_8 ), enabling high precision render targets gives higher quality graphics at the cost of slower performance and more memory usage, high precision means that Render Targets are created using a different format, that is more precise but also uses more memory and bandwidth, Lit Color Render Target is used for storing colors adjusted by light in all Renderers, the change is NOT instant, avoid calling real-time
  195. Display& highPrecNrmCalc (Bool on ); Bool highPrecNrmCalc ()C {return _hp_nrm_calc ;} // set/get Normal Calculation in High Precision (true/false , default= true ), enabling high precision normal calculation gives higher quality graphics at the cost of slower performance , high precision means that the Normal Vector from the Normal Render Target in Deferred Renderer will be reconstructed using more complex calculation, giving more precision but slightly slower performance, this affects lighting calculations (especially specular) to be more precise, this is ignored when 'highPrecNrmRT' is enabled as it's not needed in that case, the change is instant, you can call it real-time
  196. Display& dither (Bool on ); Bool dither ()C {return _dither ;} // set/get Color Dithering (true/false , default= true ), the change is instant, you can call it real-time
  197. Display& sync (Bool sync ); Bool sync ()C {return _sync ;} // set/get Screen Synchronization (true/false , default= true ), the change is NOT instant, avoid calling real-time
  198. Display& maxLights (Byte max_lights ); Byte maxLights ()C {return _max_lights ;} // set/get Maximum Number of Lights (0=unlimited, 1..255 , default= 0 ), this will automatically limit the number of lights on the scene, the change is instant, you can call it real-time
  199. Display& materialBlend (Bool per_pixel ); Bool materialBlend ()C {return _mtrl_blend ;} // set/get Multi Material Blending Quality (true/false , default= true ), false=per vertex, true=per pixel, in order to get correct results, your materials should have a bump map, the change is NOT instant, avoid calling real-time
  200. Display& texFilter (Byte filter ); Byte texFilter ()C {return _tex_filter ;} // set/get Texture Filtering Quality (0..maxTexFilter() , default= 16 (2 for Mobile)), 0=no filtering, 1=linear filtering, 2 and more=anisotropic filtering, the change is NOT instant, avoid calling real-time
  201. Display& texMipFilter (Bool on ); Bool texMipFilter ()C {return _tex_mip_filter ;} // set/get Texture MipMap Filtering (true/false , default= true (false for Mobile)), enables or disables filtering between different mip map levels, the change is NOT instant, avoid calling real-time
  202. Display& texLod (Byte lod ); Byte texLod ()C {return _tex_lod ;} // set/get Texture Lod Level Quality (0..16 , default= 0 ), values bigger than zero indicate lower texture quality (smaller mip maps will be used), but faster rendering, the change is NOT instant, avoid calling real-time
  203. Display& texMacro (Bool use ); Bool texMacro ()C {return _tex_macro ;} // set/get Macro Textures usage (true/false , default= true ), determines usage of additional Macro Textures in Materials, using this method during application runtime requires setting 'D.set_shader' (please check comments on 'D.set_shader' for more info), the change is NOT instant, avoid calling real-time
  204. Display& texDetail (TEXTURE_USAGE usage ); TEXTURE_USAGE texDetail ()C {return _tex_detail ;} // set/get Detail Textures usage (TEXTURE_USAGE , default= TEX_USE_MULTI (TEX_USE_DISABLE for Mobile)), determines usage of additional Detail Textures in Materials, using this method during application runtime requires setting 'D.set_shader' (please check comments on 'D.set_shader' for more info), the change is NOT instant, avoid calling real-time
  205. Display& texReflection (TEXTURE_USAGE usage ); TEXTURE_USAGE texReflection ()C {return _tex_reflect ;} // set/get Reflection Textures usage (TEXTURE_USAGE , default= TEX_USE_MULTI ), determines usage of additional Reflection Textures in Materials, using this method during application runtime requires setting 'D.set_shader' (please check comments on 'D.set_shader' for more info), currently reflection textures do not support 'TEX_USE_MULTI' mode, the change is NOT instant, avoid calling real-time
  206. Display& fontSharpness (Flt value ); Flt fontSharpness ()C {return _font_sharpness ;} // set/get Font Sharpness (-Inf..Inf , default= 0.75 ), specifies Mip Map Texture Bias for the Font Images, value <0 decreases sharpness, value==0 doesn't change sharpness, value>0 increases sharpness, the change is NOT instant, avoid calling real-time
  207. Display& bendLeafs (Bool on ); Bool bendLeafs ()C {return _bend_leafs ;} // set/get Leafs Bending animation (true/false , default= true ), using this method during application runtime requires setting 'D.set_shader' (please check comments on 'D.set_shader' for more info), the change is NOT instant, avoid calling real-time
  208. Display& outlineAffectSky (Bool on ); Bool outlineAffectSky ()C {return _outline_sky ;} // set/get Mesh Outline Sky Affect (true/false , default= false ), if this is enabled then outline will be visible on sky pixels in EDGE_DETECT_FAT mode, enabling this option makes outline effect run slower, the change is instant, you can call it real-time
  209. Display& outlineMode (EDGE_DETECT_MODE mode ); EDGE_DETECT_MODE outlineMode ()C {return _outline_mode ;} // set/get Mesh Outline Mode (EDGE_DETECT_MODE , default= EDGE_DETECT_THIN ), the change is instant, you can call it real-time
  210. Display& edgeDetect (EDGE_DETECT_MODE mode ); EDGE_DETECT_MODE edgeDetect ()C {return _edge_detect ;} // set/get Edge Detect Mode (EDGE_DETECT_MODE , default= EDGE_DETECT_NONE ), the change is instant, you can call it real-time
  211. Display& edgeSoften (EDGE_SOFTEN_MODE mode ); EDGE_SOFTEN_MODE edgeSoften ()C {return _edge_soften ;} // set/get Edge Softening Mode (EDGE_SOFTEN_MODE , default= EDGE_SOFTEN_NONE ), this is fake Anti-Aliasing, it is not used when Multi Sampling is enabled, the change is instant, you can call it real-time
  212. Display& smaaThreshold (Flt threshold ); Flt smaaThreshold ()C {return _smaa_threshold ;} // set/get Edge Softening SMAA Threshold ( 0..1 , default= 0.1 ), this affects SMAA edge softening quality, lower values give better quality, while higher values give better performance, recommended values: 0.05=high quality, 0.1=medium, 0.15=high performance
  213. Display& eyeDistance (Flt dist ); Flt eyeDistance ()C {return _eye_dist ;} // set/get distance between the eyes (-Inf..Inf , default= 0.064 ), interpupillary distance (distance between the eye pupils) used for stereoscopic rendering, the change is instant, you can call it real-time
  214. Display& drawNullMaterials(Bool on ); Bool drawNullMaterials ()C {return _draw_null_mtrl ;} // set/get if draw mesh parts with no material (true/false , default= false ), the change is NOT instant, avoid calling real-time
  215. Display& secondaryOpenGLContexts(Byte contexts ); Int secondaryOpenGLContexts()C; // set/get number of secondary OpenGL contexts to create during application initialization (this does not include the main context for the main thread which is always created), each secondary context allows 1 secondary thread to perform operations on the GPU data, for more information please check the 'ThreadMayUseGPUData' global function, this should be called only in 'InitPre', after that, calls to this method are ignored, this value is used only for OpenGL renderer, for DirectX it is ignored, default=1
  216. Bool canUseGPUDataOnSecondaryThread()C; // get if display supports operating on GPU data on a secondary thread, this is always true for DirectX, for OpenGL it will be true only if secondary OpenGL contexts were successfully created during the display initialization
  217. static Bool created (); // get if display is created, this can be false when the Engine still hasn't finished initializing (before 'Init'), or on Linux if XDisplay is not available and APP_ALLOW_NO_XDISPLAY was specified
  218. // screen fading
  219. Bool fading()C; // if fading is currently enabled
  220. void setFade (Flt seconds, Bool previous_frame=false); // start fading the nearest screen result for the following 'seconds', 'previous_frame'=if use result of previous frame instead of the next frame
  221. void clearFade ( ); // clear any active fading, the change is instant, you can call it real-time
  222. // Color Palette
  223. Display& colorPaletteAllow( Bool on ); Bool colorPaletteAllow()C {return _color_palette_allow;} // set/get if RM_PALETTE/RM_PALETTE1 rendering modes are allowed, disabling them increases rendering performance, default=true (false for Mobile)
  224. Display& colorPalette (C ImagePtr &palette); C ImagePtr& colorPalette ()C {return _color_palette[0] ;} // set/get color palette image that is used during RM_PALETTE rendering mode, palette textures need to have a height of 4 pixels (width can be set freely), where each row represents an intensity color palette for respectively (red, green, blue, alpha) components when rendering in RM_PALETTE mode, default=ImagePtr().get("Img/color palette.img")
  225. Display& colorPalette1 (C ImagePtr &palette); C ImagePtr& colorPalette1 ()C {return _color_palette[1] ;} // set/get color palette image that is used during RM_PALETTE1 rendering mode, palette textures need to have a height of 4 pixels (width can be set freely), where each row represents an intensity color palette for respectively (red, green, blue, alpha) components when rendering in RM_PALETTE1 mode, default=null
  226. // Particles
  227. Display& particlesSoft (Bool on); Bool particlesSoft ()C {return _particles_soft ;} // set/get Particles Softing (true/false, default=true (false for Mobile)), the change is instant, you can call it real-time
  228. Display& particlesSmoothAnim(Bool on); Bool particlesSmoothAnim()C {return _particles_smooth;} // set/get Particles Smooth Animation (true/false, default=true (false for Mobile)), if enabled then particles with animated images will be displayed with better quality by smooth blending between animation frames, the change is instant, you can call it real-time
  229. // Eye Adaptation
  230. Display& eyeAdaptation ( Bool on ); Bool eyeAdaptation ()C {return _eye_adapt ;} // set/get Eye Adaptation usage ( true/false , default=false ), enables automatic screen brightness adjustment, the change is instant, you can call it real-time
  231. Display& eyeAdaptationBrightness( Flt brightness ); Flt eyeAdaptationBrightness()C {return _eye_adapt_brightness;} // set/get Eye Adaptation brightness ( 0..Inf , default= 0.37 ), total scale of lighting, the change is instant, you can call it real-time
  232. Display& eyeAdaptationMaxDark ( Flt max_dark ); Flt eyeAdaptationMaxDark ()C {return _eye_adapt_max_dark ;} // set/get Eye Adaptation maximum darkening ( 0..eyeAdaptationMaxBright, default= 0.5 ), the change is instant, you can call it real-time
  233. Display& eyeAdaptationMaxBright ( Flt max_bright ); Flt eyeAdaptationMaxBright ()C {return _eye_adapt_max_bright;} // set/get Eye Adaptation maximum brightening (eyeAdaptationMaxDark..Inf , default= 2.0 ), the change is instant, you can call it real-time
  234. Display& eyeAdaptationSpeed ( Flt speed ); Flt eyeAdaptationSpeed ()C {return _eye_adapt_speed ;} // set/get Eye Adaptation speed ( 1..Inf , default= 6.5 ), the change is instant, you can call it real-time
  235. Display& eyeAdaptationWeight (C Vec &weight ); C Vec& eyeAdaptationWeight ()C {return _eye_adapt_weight ;} // set/get Eye Adaptation color weight ( (0, 0, 0)..(1, 1, 1) , default=(0.9, 1, 0.7)), the change is instant, you can call it real-time
  236. Display& resetEyeAdaptation ( Flt brightness=1); // reset Eye Adaptation value, eye adaptation changes over time according to screen colors, this method resets the adaptation to its original state, 'brightness'=initial brightness (0..Inf), the change is NOT instant, avoid calling real-time
  237. // Bloom, setting 'original' value to 1 and 'scale' to 0 disables bloom and increases rendering performance, optionally you can disable it with "bloomAllow(false)"
  238. Display& glowAllow (Bool allow ); Bool glowAllow ()C {return _glow_allow ;} // set/get Allow Glow Effect (true/false, default=true (false for Mobile)), this can work only if 'bloomAllow' is enabled, the change is instant, you can call it real-time
  239. Display& bloomAllow (Bool allow ); Bool bloomAllow ()C {return _bloom_allow ;} // set/get Allow Bloom (true/false, default=true (false for Mobile)), the change is instant, you can call it real-time
  240. Display& bloomOriginal(Flt original); Flt bloomOriginal()C {return _bloom_original;} // set/get Bloom Original Color ( 0..Inf , default=1.0 ), the change is instant, you can call it real-time
  241. Display& bloomScale (Flt scale ); Flt bloomScale ()C {return _bloom_scale ;} // set/get Bloom Scale ( 0..Inf , default=0.5 ), the change is instant, you can call it real-time
  242. Display& bloomCut (Flt cut ); Flt bloomCut ()C {return _bloom_cut ;} // set/get Bloom Cutoff ( 0..Inf , default=0.3 ), the change is instant, you can call it real-time
  243. Display& bloomSaturate(Bool saturate); Bool bloomSaturate()C {return _bloom_sat ;} // set/get Bloom Saturation (true/false, default=false ), the change is instant, you can call it real-time, true=faster and saturates the colors, false=slower and preserves original colors
  244. Display& bloomMaximum (Bool on ); Bool bloomMaximum ()C {return _bloom_max ;} // set/get Bloom Maximum Filter (true/false, default=false ), the change is instant, you can call it real-time
  245. Display& bloomHalf (Bool half ); Bool bloomHalf ()C {return _bloom_half ;} // set/get Bloom Half/Quarter (true/false, default=true (false for Mobile)), this specifies whether bloom should be calculated using half or quarter sized render targets (half is more precise but slower, quarter is more blurred), the change is instant, you can call it real-time
  246. Display& bloomBlurs (Byte blurs ); Byte bloomBlurs ()C {return _bloom_blurs ;} // set/get Bloom Number of Blurs ( 0..4 , default=1 ), the change is instant, you can call it real-time
  247. Display& bloomSamples (Bool high ); Bool bloomSamples ()C {return _bloom_samples ;} // set/get Bloom Sample Count (true/false, default=true (false for Mobile)), if set to true then 6 texture reads are performed in the shader, if set to false then 4 texture reads are performed, the change is instant, you can call it real-time
  248. Bool bloomUsed ()C; // if Bloom post process is going to be used
  249. // Ambient Light
  250. #if EE_PRIVATE
  251. Bool aoWant()C;
  252. #endif
  253. Display& ambientMode (AMBIENT_MODE mode ); AMBIENT_MODE ambientMode ()C {return _amb_mode ;} // set/get Ambient Mode (AMBIENT_MODE , default=AMBIENT_FLAT), the change is instant, you can call it real-time
  254. Display& ambientSoft ( Byte soft ); Byte ambientSoft ()C {return _amb_soft ;} // set/get Ambient Softing (0..AMBIENT_SOFT_NUM-1, default= 1), if soften the AO result, the change is instant, you can call it real-time
  255. Display& ambientJitter ( Bool jitter ); Bool ambientJitter ()C {return _amb_jitter ;} // set/get Ambient Jittering (true/false , default= true), jittering enables per pixel randomization of the AO samples, the change is instant, you can call it real-time
  256. Display& ambientNormal ( Bool normal ); Bool ambientNormal ()C {return _amb_normal ;} // set/get Ambient Normal Map Use (true/false , default= true), if include per pixel normal vectors from the render target, the change is instant, you can call it real-time
  257. Display& ambientRes ( Flt scale ); Flt ambientRes ()C; // set/get Ambient Resolution ( 0..1 , default= 0.5), this determines the size of the buffers used for calculating the Ambient Occlusion effect, 1=full size, 0.5=half size, 0.25=quarter size, .., smaller sizes offer faster performance but worse quality, the change is NOT instant, avoid calling real-time
  258. Display& ambientPower ( Flt power ); Flt ambientPower ()C {return _amb_color.max();} // set/get Ambient Power ( 0..2 , default= 0.4), this is equivalent to using 'ambientColor' with RGB components set to the same value, the change is instant, you can call it real-time
  259. Display& ambientColor (C Vec &color ); C Vec& ambientColor ()C {return _amb_color ;} // set/get Ambient Color ( 0..2 , default= 0.4), the change is instant, you can call it real-time
  260. Display& ambientContrast( Flt contrast); Flt ambientContrast()C {return _amb_contrast ;} // set/get Ambient Contrast ( 0..Inf , default= 1.2), the change is instant, you can call it real-time
  261. Display& ambientRange (C Vec2 &range ); C Vec2& ambientRange ()C {return _amb_range ;} // set/get Ambient 2D Range ( 0..Inf , default= 0.3), the change is instant, you can call it real-time
  262. Display& ambientScale ( Flt scale ); Flt ambientScale ()C {return _amb_scale ;} // set/get Ambient 3D Scale ( 0..Inf , default= 2.5), the change is instant, you can call it real-time
  263. Display& ambientBias ( Flt bias ); Flt ambientBias ()C {return _amb_bias ;} // set/get Ambient Bias ( 0..1 , default= 0.3), the change is instant, you can call it real-time
  264. // Night Shade
  265. Display& nightShadeColor(C Vec &color); C Vec& nightShadeColor()C {return _ns_color;} // set/get Night Shade color (0..1, default=0), the change is instant, you can call it real-time, setting color to 0 disables Night Shade effect
  266. // Shadowing
  267. Display& shadowMode (SHADOW_MODE mode ); SHADOW_MODE shadowMode ()C {return _shd_mode ;} // set/get Shadow Mode (SHADOW_MODE , default=SHADOW_MAP (SHADOW_NONE for Mobile)), the change is instant, you can call it real-time
  268. Display& shadowSoft (Byte soft ); Byte shadowSoft ()C {return _shd_soft ;} // set/get Shadow Softing (0..SHADOW_SOFT_NUM-1, default= 0 ), available only in RT_DEFERRED renderer, the change is instant, you can call it real-time
  269. Display& shadowJitter (Bool jitter ); Bool shadowJitter ()C {return _shd_jitter ;} // set/get Shadow Jittering (true/false , default= false ), works best when combined with shadow softing, the change is instant, you can call it real-time
  270. Display& shadowReduceFlicker(Bool reduce ); Bool shadowReduceFlicker()C {return _shd_reduce ;} // set/get Shadow Flickering Decreasing (true/false , default= false ), this option reduces directional light shadow map flickering when rotating the camera, however at the expense of slightly increasing the shadow map blockiness, enable only when the flickering is really disturbing, the change is instant, you can call it real-time
  271. Display& shadowFrac (Flt frac ); Flt shadowFrac ()C {return _shd_frac ;} // set/get Shadow Range Fraction for Directional Lights ( 0..1 , default= 1 ), this option can limit shadowing range to a fraction of the viewport range, the change is instant, you can call it real-time
  272. Display& shadowFade (Flt fade ); Flt shadowFade ()C {return _shd_fade ;} // set/get Shadow Fade Fraction for Directional Lights ( 0..1 , default= 1 ), this option specifies at which part of the shadowing range, shadow fading occurs, the change is instant, you can call it real-time
  273. Display& shadowMapSize (Int map_size); Int shadowMapSize ()C {return _shd_map_size ;} // set/get Shadow Map Size ( 1..Inf , default= 1024 ), this option specifies the size of a single shadow map (in pixels), bigger size results in more precise shadows but smaller performance, the change is NOT instant, avoid calling real-time
  274. Display& shadowMapSizeLocal (Flt frac ); Flt shadowMapSizeLocal ()C {return _shd_map_size_l;} // set/get Shadow Map Size Fraction for Local Lights ( 0..1 , default= 1 ), this option specifies global size factor for computing the size of shadow maps for local lights (point/cone), final size of shadow maps for local lights is calculated using following formula: "shadowMapSize()*shadowMapSizeLocal()" , this means that for shadowMapSizeLocal()==1 full shadowMapSize() is used, for shadowMapSizeLocal()==0.5 half of shadowMapSize() is used, and so on, the change is instant, you can call it real-time
  275. Display& shadowMapSizeCone (Flt factor ); Flt shadowMapSizeCone ()C {return _shd_map_size_c;} // set/get Shadow Map Size Factor for Cone Lights ( 0..2 , default= 1 ), this option specifies global size factor for computing the size of shadow maps for cone lights , final size of shadow maps for cone lights is calculated using following formula: "shadowMapSize()*shadowMapSizeLocal()*shadowMapSizeCone()", this means that for shadowMapSizeCone ()==1 full shadowMapSize() is used, for shadowMapSizeCone ()==0.5 half of shadowMapSize() is used, for shadowMapSizeCone()==2 double of shadowMapSize() is used, the range for shadowMapSizeCone is 0..2, which means that if set to 2, it can double the default shadow quality for all cone lights, the change is instant, you can call it real-time
  276. Display& shadowMapNum (Byte map_num ); Byte shadowMapNum ()C {return _shd_map_num ;} // set/get Number of Shadow Maps for Directional Lights ( 1..6 , default= 6 ), this option specifies the number of shadow maps used when rendering directional lights, the more shadow maps are used the better quality but smaller performance, RT_FORWARD renderer supports only even numbers of maps, the change is instant, you can call it real-time
  277. Display& shadowMapSplit (C Vec2 &factor ); C Vec2& shadowMapSplit ()C {return _shd_map_split ;} // set/get Split Factor used for calculating Map Ranges ( , default= Vec2(2, 1) ), this option affects calculation of shadow map split ranges from the formula "Pow(x, factor.x + factor.y*x)". Ideal value is Vec2(2, 0) - "Pow(x, 2 + 0*x)" which gives equal distribution among near/far splits. However games may prefer better quality closer to the camera, while sacrificing the far quality, in that case it is beneficial to pass bigger values than Vec2(2, 0).
  278. Display& cloudsMapSize (Int map_size); Int cloudsMapSize ()C {return _cld_map_size ;} // set/get Clouds Shadow Map Size ( 1..Inf , default= 128 ), the change is NOT instant, avoid calling real-time
  279. #if EE_PRIVATE
  280. void shadowJitterSet ();
  281. Int shadowMapNumActual ()C;
  282. Int shadowMapSizeActual()C {return _shd_map_size_actual;}
  283. Bool shadowSupported ()C;
  284. #endif
  285. // Motion Blur
  286. Display& motionMode (MOTION_MODE mode ); MOTION_MODE motionMode ()C {return _mtn_mode ;} // set/get Motion Blur Mode (MOTION_MODE, default=MOTION_NONE ), the change is instant, you can call it real-time
  287. Display& motionDilate(DILATE_MODE mode ); DILATE_MODE motionDilate()C {return _mtn_dilate;} // set/get Motion Blur Mode (DILATE_MODE, default=DILATE_ORTHO2), the change is instant, you can call it real-time
  288. Display& motionScale (Flt scale); Flt motionScale ()C {return _mtn_scale ;} // set/get Motion Blur Velocity Scale ( 0..Inf , default= 0.04), the change is instant, you can call it real-time
  289. Display& motionRes (Flt scale); Flt motionRes ()C; // set/get Motion Blur Resolution ( 0..1 , default= 1/3), this determines the size of the buffers used for calculating the Motion Blur effect, 1=full size, 0.5=half size, 0.25=quarter size, .., smaller sizes offer faster performance but worse quality, the change is NOT instant, avoid calling real-time
  290. // Depth of Field
  291. #if EE_PRIVATE
  292. #define EPS_DOF (1.0f/1024)
  293. Bool dofWant()C {return dofMode()!=DOF_NONE && dofIntensity()>EPS_DOF;}
  294. #endif
  295. Display& dofMode (DOF_MODE mode ); DOF_MODE dofMode ()C {return _dof_mode ;} // set/get Depth of Field Mode ( DOF_MODE , default=DOF_NONE), the change is instant, you can call it real-time
  296. Display& dofFocusMode(Bool realistic); Bool dofFocusMode()C {return _dof_foc_mode ;} // set/get Depth of Field Focus Mode (true/false, default= false), this affects how the focus is calculated based on depth, simple mode (realistic=false) operates on 'dofFocus' and 'dofRange' only, while realistic mode (realistic=true) operates on 'dofFocus' only
  297. Display& dofFocus (Flt z ); Flt dofFocus ()C {return _dof_focus ;} // set/get Depth of Field Focus Depth Position ( 0..Inf , default= 0), this is the distance from camera which should be completely focused and not blurred, the change is instant, you can call it real-time
  298. Display& dofRange (Flt range ); Flt dofRange ()C {return _dof_range ;} // set/get Depth of Field Focus Depth Range ( 0..Inf , default= 30), this is the distance from 'dofFocus' (Focus Depth Position) where blurring should be set to maximum, used only in simple focus mode "dofFocusMode==false" (the change is instant, you can call it real-time
  299. Display& dofIntensity(Flt intensity); Flt dofIntensity()C {return _dof_intensity;} // set/get Depth of Field Intensity ( 0..Inf , default= 1), intensity of the depth of field effect, the change is instant, you can call it real-time
  300. // Level of Detail
  301. #if EE_PRIVATE
  302. void lodSetCurrentFactor();
  303. void lodUpdateFactors ();
  304. #endif
  305. Display& lod (Flt general, Flt shadow, Flt mirror); // set Level of Detail factors, the change is instant, you can call it real-time
  306. Display& lodFactor (Flt factor); Flt lodFactor ()C {return _lod_factor ;} // set/get Level of Detail general factor which determines Lod selection, 0..Inf, default=1, it's a scaling factor: values from 0..1 increase details and values from 1..Inf decrease details, the change is instant, you can call it real-time
  307. Display& lodFactorShadow(Flt factor); Flt lodFactorShadow()C {return _lod_factor_shadow;} // set/get Level of Detail shadows factor which is also applied to shadows Lod selection, 0..Inf, defailt=2, it's a scaling factor: values from 0..1 increase details and values from 1..Inf decrease details, the change is instant, you can call it real-time
  308. Display& lodFactorMirror(Flt factor); Flt lodFactorMirror()C {return _lod_factor_mirror;} // set/get Level of Detail mirror factor which is also applied to meshes rendered in mirrors Lod selection, 0..Inf, defailt=2, it's a scaling factor: values from 0..1 increase details and values from 1..Inf decrease details, the change is instant, you can call it real-time
  309. // Tesselation
  310. Display& tesselation (Bool on ); Bool tesselation ()C {return _tesselation ;} // set/get Tesselation (true/false, default=false), Tesselation smoothes the mesh polygons, it is available only on Shader Model>=5.0, the change is NOT instant, avoid calling real-time
  311. Display& tesselationHeightmap(Bool on ); Bool tesselationHeightmap()C {return _tesselation_heightmap;} // set/get Tesselation of Heightmaps (true/false, default=false), the change is NOT instant, avoid calling real-time
  312. Display& tesselationDensity (Flt density); Flt tesselationDensity ()C {return _tesselation_density ;} // set/get Tesselation Density ( 0..Inf , default=60 ), the change is instant, you can call it real-time
  313. #if EE_PRIVATE
  314. Display& tesselationAllow (Bool on ); Bool tesselationAllow ()C {return _tesselation_allow ;} // set/get Tesselation Allow (true/false, default=true ), the change is instant, you can call it real-time
  315. #endif
  316. // Grass
  317. Display& grassRange (Flt range ); Flt grassRange ()C {return _grass_range ;} // set/get Grass Range ( 0..Inf , default=50 ), grass objects above specified range will not be rendered, the change is instant, you can call it real-time
  318. Display& grassDensity(Flt density); Flt grassDensity()C {return _grass_density;} // set/get Grass Density ( 0..1 , default=1 (0.5 for Mobile)), controls the amount of grass objects rendered, the change is instant, you can call it real-time
  319. Display& grassShadow (Bool on ); Bool grassShadow ()C {return _grass_shadow ;} // set/get Grass Shadow Casting (true/false, default=false ), if grass objects should cast shadows, the change is instant, you can call it real-time
  320. Display& grassMirror (Bool on ); Bool grassMirror ()C {return _grass_mirror ;} // set/get Grass Drawing in Mirror (true/false, default=false ), if grass objects should be drawn in mirrors, the change is instant, you can call it real-time
  321. Display& grassUpdate ( ); // update Grass and Leafs bending animation, call this each frame to update the animation, the change is instant, you can call it real-time
  322. // Fur
  323. Display& furStaticGravity (Flt gravity ); Flt furStaticGravity ()C {return _fur_gravity ;} // gravity affecting fur on non-animated meshes which aren't controlled by AnimatedSkeleton (AnimatedSkeleton.fur_* parameters), -Inf..Inf, default=-1 , the change is instant, you can call it real-time
  324. Display& furStaticVelScale(Flt vel_scale); Flt furStaticVelScale()C {return _fur_vel_scale;} // how much does mesh movement affect fur on non-animated meshes which aren't controlled by AnimatedSkeleton (AnimatedSkeleton.fur_* parameters), -Inf..Inf, default=-0.75, the change is instant, you can call it real-time
  325. // Volumetric Lighting
  326. Display& volLight(Bool on ); Bool volLight()C {return _vol_light;} // set/get Volumetric Lighting (true/false, default=false), the change is instant, you can call it real-time
  327. Display& volAdd (Bool on ); Bool volAdd ()C {return _vol_add ;} // set/get Volumetric Apply Mode (true/false, default=false), when true is set, Volumetric Light will be added to the scene, if false is set, Lerp to 1 will be performed, the change is instant, you can call it real-time
  328. Display& volMax (Flt max); Flt volMax ()C {return _vol_max ;} // set/get Volumetric Global Maximum ( 0..Inf , default=1.0 ), the change is instant, you can call it real-time
  329. // Viewport Settings
  330. #if EE_PRIVATE
  331. void setViewFovTan();
  332. void viewUpdate();
  333. void viewReset ();
  334. Display& view (C RectI &rect, Flt from, Flt range, C Vec2 &fov, FOV_MODE fov_mode);
  335. Display& view (C Rect &rect, Flt from, Flt range, C Vec2 &fov, FOV_MODE fov_mode);
  336. Flt viewFromActual()C {return _view_from ;} // get actual viewport near clip plane (this depends on FovMode)
  337. C Vec2 & viewCenter ()C {return _view_center ;} // get viewport center
  338. C Vec2 & viewFovTanGui ()C {return _view_fov_tan_gui ;} // get viewport fov tan, used for point transformation between 3D and VR 'GuiTexture'
  339. C Vec2 & viewFovTanFull()C {return _view_fov_tan_full;} // get viewport fov tan, used for point transformation between 3D and Full Screen
  340. #endif
  341. Display& viewRect (C RectI *rect ); C RectI& viewRectI ()C {return _view_main.recti ;} // set/get viewport rectangle (null for fullscreen), custom viewport rectangle is reset at start of each frame to fullscreen, that's why when used it must be set manually in each frame
  342. Display& viewRect (C Rect &rect ); C Rect & viewRect ()C {return _view_rect ;} // set/get viewport rectangle , custom viewport rectangle is reset at start of each frame to fullscreen, that's why when used it must be set manually in each frame
  343. Display& viewFrom (Flt from ); Flt viewFrom ()C {return _view_main.from ;} // set/get viewport near clip plane , default=0.05
  344. Display& viewRange(Flt range ); Flt viewRange ()C {return _view_main.range ;} // set/get viewport far clip plane , default=100
  345. Display& viewFov (Flt fov, FOV_MODE mode=FOV_Y); Flt viewFov ()C {return _view_fov ;} // set/get viewport field of view, default={DegToRad(70), FOV_Y}
  346. Display& viewFov (C Vec2 &fov ); C Vec2 & viewFovXY ()C {return _view_main.fov ;} // set/get viewport field of view from both horizontal and vertical values
  347. Flt viewFovX ()C {return _view_main.fov.x ;} // get actual horizontal field of view
  348. Flt viewFovY ()C {return _view_main.fov.y ;} // get actual vertical field of view
  349. FOV_MODE viewFovMode ()C {return _view_main.fov_mode;} // get viewport field of view mode, default=FOV_Y
  350. Flt viewQuadDist()C; // get viewport quad max distance from camera
  351. Display& viewForceSquarePixel(Bool square=false); // force pixel aspect ratio to 1, this may be needed for rendering to textures, default rendering should have this disabled, default=false
  352. // Convert Coordinates src.X src.Y dest.X dest.Y
  353. static Vec2 screenToUV (C Vec2 &screen); // from screen (-D.w .. D.w , -D.h .. D.h ) to UV ( 0 .. 1 , 0 .. 1 )
  354. static Rect screenToUV (C Rect &screen); // from screen (-D.w .. D.w , -D.h .. D.h ) to UV ( 0 .. 1 , 0 .. 1 )
  355. static Vec2 screenToPixel (C Vec2 &screen); // from screen (-D.w .. D.w , -D.h .. D.h ) to pixel ( 0 .. D.resW, 0 .. D.resH)
  356. static VecI2 screenToPixelI (C Vec2 &screen); // from screen (-D.w .. D.w , -D.h .. D.h ) to pixel ( 0 .. D.resW, 0 .. D.resH)
  357. static Rect screenToPixel (C Rect &screen); // from screen (-D.w .. D.w , -D.h .. D.h ) to pixel ( 0 .. D.resW, 0 .. D.resH)
  358. static RectI screenToPixelI (C Rect &screen); // from screen (-D.w .. D.w , -D.h .. D.h ) to pixel ( 0 .. D.resW, 0 .. D.resH)
  359. static Vec2 screenToPixelSize (C Vec2 &screen); // from screen size ( 0 .. D.w*2 , 0 .. D.h*2 ) to pixel size ( 0 .. D.resW, 0 .. D.resH), use this function for widths and heights
  360. static Vec2 UVToScreen (C Vec2 &uv ); // from UV ( 0 .. 1 , 0 .. 1 ) to screen (-D.w .. D.w , -D.h .. D.h )
  361. static Vec2 pixelToScreen (C Vec2 &pixel ); // from pixel ( 0 .. D.resW, 0 .. D.resH) to screen (-D.w .. D.w , -D.h .. D.h )
  362. static Vec2 pixelToScreen (C VecI2 &pixel ); // from pixel ( 0 .. D.resW, 0 .. D.resH) to screen (-D.w .. D.w , -D.h .. D.h )
  363. static Rect pixelToScreen (C Rect &pixel ); // from pixel ( 0 .. D.resW, 0 .. D.resH) to screen (-D.w .. D.w , -D.h .. D.h )
  364. static Rect pixelToScreen (C RectI &pixel ); // from pixel ( 0 .. D.resW, 0 .. D.resH) to screen (-D.w .. D.w , -D.h .. D.h )
  365. static Vec2 pixelToScreenSize ( Flt pixel ); // from pixel size ( 0 .. D.resW, 0 .. D.resH) to screen size ( 0 .. D.w*2 , 0 .. D.h*2 ), use this function for widths and heights
  366. static Vec2 pixelToScreenSize (C Vec2 &pixel ); // from pixel size ( 0 .. D.resW, 0 .. D.resH) to screen size ( 0 .. D.w*2 , 0 .. D.h*2 ), use this function for widths and heights
  367. static Vec2 pixelToScreenSize (C VecI2 &pixel ); // from pixel size ( 0 .. D.resW, 0 .. D.resH) to screen size ( 0 .. D.w*2 , 0 .. D.h*2 ), use this function for widths and heights
  368. static Vec2 screenAlignedToPixel (C Vec2 &screen); // get screen space position aligned to nearest pixel
  369. static Vec2 alignScreenToPixelOffset(C Vec2 &screen); // get offset needed for aligning screen space position to nearest pixel
  370. static void alignScreenToPixel ( Vec2 &screen); // align screen space position to nearest pixel
  371. static void alignScreenToPixel ( Rect &screen); // align screen space rectangle so its top-left corner will be aligned to nearest pixel while preserving the rectangle size
  372. C Vec2& pixelToScreenSize ( )C {return _pixel_size;} // get screen size of a single pixel
  373. #if EE_PRIVATE
  374. static void alignScreenXToPixel ( Flt &screen_x); // align screen space x position to nearest pixel
  375. static void alignScreenYToPixel ( Flt &screen_y); // align screen space y position to nearest pixel
  376. static Vec2 windowPixelToScreen (C Vec2 &pixel ); // from pixel ( 0 .. D.resW, 0 .. D.resH) to screen (-D.w .. D.w , -D.h .. D.h ) taking into account System Window -> VR Gui
  377. static Vec2 windowPixelToScreen (C VecI2 &pixel ); // from pixel ( 0 .. D.resW, 0 .. D.resH) to screen (-D.w .. D.w , -D.h .. D.h ) taking into account System Window -> VR Gui
  378. static VecI2 screenToWindowPixelI (C Vec2 &screen ); // from screen (-D.w .. D.w , -D.h .. D.h ) to pixel ( 0 .. D.resW, 0 .. D.resH) taking into account System Window -> VR Gui
  379. static RectI screenToWindowPixelI (C Rect &screen ); // from screen (-D.w .. D.w , -D.h .. D.h ) to pixel ( 0 .. D.resW, 0 .. D.resH) taking into account System Window -> VR Gui
  380. #endif
  381. // Clear Screen
  382. static void clear (C Color &color=TRANSPARENT); // clear screen viewport to 'color' and clear depth buffer
  383. static void clearCol (C Color &color=TRANSPARENT); // clear screen viewport to 'color'
  384. static void clearDepth( ); // clear depth buffer
  385. #if EE_PRIVATE
  386. static void clearDS (Byte s=0 ); // clear depth buffer and stencil (if available)
  387. static void clearStencil(Byte s=0 ); // clear stencil
  388. #if DX9
  389. static void clearCol (Int i, C Color &color ); // clear i-th full (not viewport) RT to 'color'
  390. #else
  391. static void clearCol ( C Vec4 &color ); // clear screen viewport to 'color'
  392. static void clearCol (Int i, C Vec4 &color ); // clear i-th full (not viewport) RT to 'color'
  393. #endif
  394. #endif
  395. // operations
  396. void setShader(C Material *material=null); // manually trigger resetting shaders for all meshes, 'material'=if reset shaders only for meshes having specified material (use null for all meshes)
  397. #if !EE_PRIVATE
  398. private:
  399. #endif
  400. struct ViewportSettings
  401. {
  402. FOV_MODE fov_mode;
  403. Flt from, range, fov;
  404. Rect rect;
  405. void get() ; // get viewport settings from current display settings "T=D"
  406. void set()C; // set viewport settings as current display settings "D=T"
  407. };
  408. struct Viewport
  409. {
  410. // 2D
  411. RectI recti;
  412. Bool full;
  413. // 3D
  414. FOV_MODE fov_mode;
  415. Flt from, range;
  416. Vec2 fov, fov_sin, fov_cos, fov_tan;
  417. #if EE_PRIVATE
  418. Viewport& set3DFrom (C Viewport &src);
  419. Viewport& setRect (C RectI &recti);
  420. Viewport& setFrom (Flt from);
  421. Viewport& setRange (Flt range);
  422. Viewport& setFov (); // this needs to be called after 'setRect'
  423. Viewport& setFov ( C Vec2 &fov, FOV_MODE fov_mode);
  424. Viewport& set (C RectI &recti, Flt from, Flt range, C Vec2 &fov, FOV_MODE fov_mode);
  425. Viewport& setViewport (Bool allow_proj_matrix_update=true);
  426. Viewport& setShader (Flt *offset=null);
  427. Viewport& setProjMatrix(Bool set_frustum);
  428. #endif
  429. };
  430. struct Monitor
  431. {
  432. RectI full, work;
  433. Bool primary;
  434. #if EE_PRIVATE
  435. #if WINDOWS_OLD
  436. Bool set(HMONITOR monitor);
  437. #elif WINDOWS_NEW
  438. void set(C DXGI_OUTPUT_DESC &desc);
  439. #endif
  440. Monitor();
  441. #endif
  442. };
  443. ASPECT_MODE _aspect_mode;
  444. BUMP_MODE _bump_mode;
  445. AMBIENT_MODE _amb_mode;
  446. SHADOW_MODE _shd_mode;
  447. MOTION_MODE _mtn_mode;
  448. DILATE_MODE _mtn_dilate;
  449. DOF_MODE _dof_mode;
  450. EDGE_DETECT_MODE _edge_detect, _outline_mode;
  451. EDGE_SOFTEN_MODE _edge_soften;
  452. TEXTURE_USAGE _tex_detail, _tex_reflect;
  453. SHADER_MODEL _shader_model;
  454. IMAGE_PRECISION _monitor_prec, _lit_col_rt_prec;
  455. FILTER_TYPE _density_filter;
  456. Bool _full, _sync, _exclusive, _hp_col_rt, _hp_nrm_rt, _hp_lum_rt, _hp_nrm_calc, _dither, _bend_leafs, _particles_soft, _particles_smooth, _tex_mip_filter, _tex_macro, _eye_adapt, _bloom_sat, _bloom_max, _bloom_half, _bloom_samples,
  457. _tesselation, _tesselation_heightmap, _tesselation_allow,
  458. _bloom_allow, _glow_allow, _amb_jitter, _amb_normal, _shd_jitter, _shd_reduce, _grass_shadow, _grass_mirror, _vol_light, _vol_add, _dof_foc_mode, _outline_sky, _color_palette_allow,
  459. _gamma_all, _tex_pow2_3d, _tex_pow2_cube, _mrt_const_bit_size, _mrt_post_process, _view_square_pixel, _initialized, _resetting, _began, _no_gpu, _can_draw, _fade_get, _fade_flipped, _allow_stereo, _draw_null_mtrl, _mtrl_blend, _shader_tex_lod;
  460. Byte _tex_pow2, _density, _samples, _max_tex_filter, _max_vtx_attribs, _bloom_blurs, _max_rt,
  461. _amb_soft, _amb_res,
  462. _shd_soft, _shd_map_num,
  463. _mtn_res,
  464. _max_lights,
  465. _tex_filter, _tex_lod;
  466. UShort _gamma_array[3][256];
  467. Int _shd_map_size, _shd_map_size_actual, _cld_map_size, _freq_want, _freq_got, _max_tex_size;
  468. Long _device_mem;
  469. VecI2 _res, _render_res;
  470. Flt _aspect_ratio, _aspect_ratio_want, _pixel_aspect, _gamma, _font_sharpness, _scale,
  471. _amb_contrast, _amb_scale, _amb_bias,
  472. _eye_adapt_brightness, _eye_adapt_max_dark, _eye_adapt_max_bright, _eye_adapt_speed,
  473. _eye_dist,
  474. _shd_frac, _shd_fade, _shd_map_size_l, _shd_map_size_c,
  475. _bloom_original, _bloom_scale, _bloom_cut,
  476. _mtn_scale,
  477. _dof_focus, _dof_range, _dof_intensity,
  478. _vol_max,
  479. _grass_range, _grass_range_sqr, _grass_density,
  480. _lod_factor, _lod_factor_shadow, _lod_factor_mirror, _lod_factors[2][2], _lod_factors_fov[2][2], _lod_fov2, _lod_current_factor,
  481. _tesselation_density,
  482. _fur_gravity, _fur_vel_scale,
  483. _view_fov, _view_from,
  484. _fade_len, _fade_step,
  485. _smaa_threshold;
  486. Vec2 _unscaled_size, _size, _size2, _pixel_size, _pixel_size_2, _pixel_size_inv,
  487. _window_pixel_to_screen_mul, _window_pixel_to_screen_add, _window_pixel_to_screen_scale,
  488. _amb_range, _shd_map_split;
  489. Vec _amb_color, _ns_color, _eye_adapt_weight;
  490. Vec2 _view_center, _view_fov_tan_gui, _view_fov_tan_full;
  491. Rect _view_rect, _view_eye_rect[2];
  492. Viewport _view_main, _view_active;
  493. Str8 _device_name;
  494. ImagePtr _color_palette[2];
  495. Image _color_palette_soft[2];
  496. Mems<VecI2> _modes;
  497. SyncLock _lock;
  498. C Material* _set_shader_material;
  499. Map<Ptr, Monitor> _monitors;
  500. #if EE_PRIVATE
  501. // get
  502. #if DX9
  503. Bool validUsage(UInt usage, D3DRESOURCETYPE res_type, Int image_type);
  504. #endif
  505. // manage
  506. void init ();
  507. void del ();
  508. Bool create ();
  509. void createDevice();
  510. void androidClose();
  511. void androidOpen ();
  512. // operations
  513. enum RESET_RESULT
  514. {
  515. RESET_OK ,
  516. RESET_DEVICE_NOT_CREATED ,
  517. RESET_CUSTOM_LOST_FAILED ,
  518. RESET_CUSTOM_RESET_FAILED ,
  519. RESET_DEVICE_RESET_FAILED ,
  520. RESET_RENDER_TARGET_FAILED,
  521. };
  522. static CChar8* AsText (RESET_RESULT result);
  523. static void ResetFailed(RESET_RESULT New, RESET_RESULT old);
  524. RESET_RESULT ResetTry ();
  525. void Reset ();
  526. RESET_RESULT modeTry (Int w=-1, Int h=-1, Int full=-1); // try setting Display Mode, -1=keep original value
  527. void modeSet (Int w=-1, Int h=-1, Int full=-1); // set Display Mode, -1=keep original value
  528. Bool findMode ();
  529. void getGamma ();
  530. void getCaps ();
  531. void after (Bool resize_callback);
  532. Bool initialized ()C {return _initialized;}
  533. static void end ();
  534. static void begin ();
  535. static Bool flip ();
  536. static void flush ();
  537. static void finish ();
  538. void adjustWindow ();
  539. void screenChanged (Flt old_width, Flt old_height);
  540. void sizeChanged ();
  541. void validateCoords(Int eye=-1);
  542. void fadeUpdate ();
  543. void fadeDraw ();
  544. Bool deferredUnavailable ()C;
  545. Bool deferredMSUnavailable()C;
  546. void monitor(RectI &full, RectI &work, VecI2 &max_normal_win_client_size, VecI2 &maximized_win_client_size, C Monitor *monitor)C;
  547. void curMonitor(RectI &full, RectI &work, VecI2 &max_normal_win_client_size, VecI2 &maximized_win_client_size) ;
  548. void mainMonitor(RectI &full, RectI &work, VecI2 &max_normal_win_client_size, VecI2 &maximized_win_client_size)C;
  549. #endif
  550. Display();
  551. }extern
  552. D; // Main Display Control
  553. /******************************************************************************/
  554. #if EE_PRIVATE
  555. #if DX9
  556. extern IDirect3DDevice9 *D3D;
  557. #elif DX11
  558. extern ID3D11Device *D3D;
  559. extern ID3D11DeviceContext *D3DC;
  560. extern ID3D11DeviceContext1 *D3DC1;
  561. #if WINDOWS_OLD
  562. extern IDXGISwapChain *SwapChain;
  563. extern DXGI_SWAP_CHAIN_DESC SwapChainDesc;
  564. #else
  565. extern IDXGISwapChain1 *SwapChain;
  566. extern DXGI_SWAP_CHAIN_DESC1 SwapChainDesc;
  567. #endif
  568. extern D3D_FEATURE_LEVEL FeatureLevel;
  569. #elif GL
  570. struct GLContext
  571. {
  572. Bool locked;
  573. #if WINDOWS
  574. HGLRC context;
  575. #elif MAC
  576. CGLContextObj context;
  577. #elif LINUX
  578. GLXContext context;
  579. #elif ANDROID
  580. EGLSurface surface;
  581. EGLContext context;
  582. #elif IOS
  583. EAGLContext *context;
  584. #elif WEB
  585. EMSCRIPTEN_WEBGL_CONTEXT_HANDLE context;
  586. #endif
  587. Bool is()C;
  588. GLContext();
  589. ~GLContext() {del();}
  590. void del();
  591. Bool createSecondary();
  592. void lock();
  593. void unlock();
  594. }extern
  595. MainContext;
  596. extern UInt FBO, VAO;
  597. #define VARIABLE_MAX_MATRIX 0 // GeForce 1080 has limit of 1024 uniform Vec4's which means that new GPU's don't support more than required, TODO: this could be done only if DX10+ style constant buffers are implemented for GL
  598. #if VARIABLE_MAX_MATRIX
  599. extern Bool MeshBoneSplit;
  600. #endif
  601. #if LINUX
  602. extern GLXFBConfig GLConfig;
  603. #endif
  604. #endif
  605. Bool SetDisplayMode(Int mode=1); // 0=always off (use at shutdown), 1=if want full and app is active, 2=if want full (use at init)
  606. void RequestDisplayMode(Int w, Int h, Int full);
  607. #if WINDOWS_OLD
  608. IDirect3DDevice9* GetD3D9();
  609. #elif WINDOWS_NEW
  610. extern Flt ScreenScale;
  611. Int DipsToPixels(Flt dips);
  612. Flt PixelsToDips(Int pix );
  613. #elif MAC
  614. extern NSOpenGLContext *OpenGLContext;
  615. #elif LINUX
  616. extern ::Display *XDisplay;
  617. #elif IOS
  618. extern Flt ScreenScale;
  619. #endif
  620. #endif
  621. /******************************************************************************/