From 790e55bf0c251593041e923bb82e4f863b930ea0 Mon Sep 17 00:00:00 2001 From: Isilin Date: Sat, 13 Apr 2019 13:53:22 +0200 Subject: [PATCH] Purging DirectX libraries (3D, sound, input). --- .gitlab-ci.yml | 12 +- code/CMakeModules/ConfigureChecks.cmake | 12 - code/CMakeModules/Find3dsMaxSDK.cmake | 3 - code/CMakeModules/FindDSound.cmake | 36 - code/CMakeModules/FindDirectXSDK.cmake | 69 - code/CMakeModules/FindMySQL.cmake | 8 +- code/CMakeModules/nel.cmake | 27 +- code/config.h.cmake | 3 - code/nel/include/nel/3d/bloom_effect.h | 3 +- code/nel/include/nel/3d/driver.h | 9 +- code/nel/include/nel/3d/driver_user.h | 2 - code/nel/include/nel/3d/dru.h | 35 - code/nel/include/nel/3d/material.h | 5 +- code/nel/include/nel/3d/nelu.h | 4 +- code/nel/include/nel/3d/program.h | 64 +- code/nel/include/nel/3d/ps_attrib_maker.h | 2 +- code/nel/include/nel/3d/texture.h | 2 +- code/nel/include/nel/3d/u_driver.h | 10 +- code/nel/include/nel/3d/vertex_buffer.h | 23 +- .../nel/include/nel/3d/vertex_program_parse.h | 12 +- code/nel/include/nel/sound/driver/buffer.h | 25 +- .../include/nel/sound/driver/sound_driver.h | 36 +- code/nel/include/nel/sound/driver/source.h | 232 +- code/nel/include/nel/sound/u_audio_mixer.h | 36 +- code/nel/samples/3d/cegui/main.cpp | 17 +- code/nel/samples/3d/font/main.cpp | 2 +- .../samples/3d/nel_qt/graphics_viewport.cpp | 40 +- .../nel/samples/3d/nel_qt/graphics_viewport.h | 6 +- code/nel/samples/3d/nel_qt/nel_qt_default.cfg | 80 +- code/nel/samples/sound/sound_sources/main.cpp | 2 - .../samples/sound/stream_file/stream_file.cpp | 22 +- .../stream_ogg_vorbis/stream_ogg_vorbis.cpp | 20 +- code/nel/src/3d/coarse_mesh_manager.cpp | 2 +- code/nel/src/3d/driver/CMakeLists.txt | 6 - .../nel/src/3d/driver/direct3d/CMakeLists.txt | 24 - .../3d/driver/direct3d/driver_direct3d.cpp | 4062 ----------------- .../3d/driver/direct3d/driver_direct3d.def | 3 - .../src/3d/driver/direct3d/driver_direct3d.h | 2883 ------------ .../driver/direct3d/driver_direct3d_index.cpp | 515 --- .../direct3d/driver_direct3d_inputs.cpp | 475 -- .../driver/direct3d/driver_direct3d_light.cpp | 213 - .../direct3d/driver_direct3d_material.cpp | 2041 --------- .../direct3d/driver_direct3d_matrix.cpp | 445 -- .../driver_direct3d_pixel_program.cpp | 157 - .../direct3d/driver_direct3d_profile.cpp | 358 -- .../direct3d/driver_direct3d_render.cpp | 468 -- .../direct3d/driver_direct3d_shader.cpp | 4011 ---------------- .../direct3d/driver_direct3d_texture.cpp | 1229 ----- .../direct3d/driver_direct3d_uniform.cpp | 246 - .../direct3d/driver_direct3d_vertex.cpp | 943 ---- .../driver_direct3d_vertex_program.cpp | 439 -- code/nel/src/3d/driver/direct3d/resources.rc | 37 - .../src/3d/driver/direct3d/stddirect3d.cpp | 17 - code/nel/src/3d/driver/direct3d/stddirect3d.h | 72 - code/nel/src/3d/driver/opengl/EGL/eglext.h | 10 - .../src/3d/driver/opengl/driver_opengl.cpp | 4 +- code/nel/src/3d/driver/opengl/driver_opengl.h | 23 +- .../3d/driver/opengl/driver_opengl_inputs.cpp | 4 - code/nel/src/3d/driver_user.cpp | 17 +- code/nel/src/3d/dru.cpp | 61 - code/nel/src/3d/fxaa.cpp | 8 - code/nel/src/3d/landscapevb_info.cpp | 1 - code/nel/src/3d/light.cpp | 2 +- code/nel/src/3d/lod_character_manager.cpp | 1 - code/nel/src/3d/material.cpp | 2 - code/nel/src/3d/mesh_morpher.cpp | 12 - code/nel/src/3d/meshvp_wind_tree.cpp | 29 +- code/nel/src/3d/nelu.cpp | 13 +- code/nel/src/3d/noise_3d.cpp | 5 - code/nel/src/3d/ps_mesh.cpp | 1 - code/nel/src/3d/ps_quad.cpp | 1 - code/nel/src/3d/render_trav.cpp | 1 - code/nel/src/3d/shadow_map_manager.cpp | 2 - code/nel/src/3d/vegetable_manager.cpp | 8 +- code/nel/src/3d/vegetable_shape.cpp | 1 - code/nel/src/sound/audio_decoder_vorbis.cpp | 23 +- code/nel/src/sound/audio_mixer_user.cpp | 12 +- code/nel/src/sound/clustered_sound.cpp | 10 +- code/nel/src/sound/driver/CMakeLists.txt | 8 - .../src/sound/driver/dsound/CMakeLists.txt | 21 - .../src/sound/driver/dsound/buffer_dsound.cpp | 271 -- .../src/sound/driver/dsound/buffer_dsound.h | 102 - .../src/sound/driver/dsound/driver_dsound.def | 4 - .../sound/driver/dsound/listener_dsound.cpp | 376 -- .../src/sound/driver/dsound/listener_dsound.h | 132 - code/nel/src/sound/driver/dsound/resources.rc | 37 - .../driver/dsound/sound_driver_dsound.cpp | 1110 ----- .../sound/driver/dsound/sound_driver_dsound.h | 214 - .../src/sound/driver/dsound/source_dsound.cpp | 3200 ------------- .../src/sound/driver/dsound/source_dsound.h | 517 --- .../nel/src/sound/driver/dsound/stddsound.cpp | 17 - code/nel/src/sound/driver/dsound/stddsound.h | 58 - .../src/sound/driver/fmod/listener_fmod.cpp | 2 - .../nel/src/sound/driver/fmod/listener_fmod.h | 3 +- .../sound/driver/fmod/sound_driver_fmod.cpp | 11 +- .../src/sound/driver/fmod/sound_driver_fmod.h | 8 +- .../nel/src/sound/driver/fmod/source_fmod.cpp | 32 +- code/nel/src/sound/driver/fmod/source_fmod.h | 60 +- .../sound/driver/openal/sound_driver_al.cpp | 50 +- .../nel/src/sound/driver/openal/source_al.cpp | 30 +- code/nel/src/sound/driver/openal/source_al.h | 34 +- code/nel/src/sound/driver/sound_driver.cpp | 56 +- .../src/sound/driver/xaudio2/CMakeLists.txt | 48 - .../sound/driver/xaudio2/adpcm_xaudio2.cpp | 200 - .../src/sound/driver/xaudio2/adpcm_xaudio2.h | 115 - .../sound/driver/xaudio2/buffer_xaudio2.cpp | 200 - .../src/sound/driver/xaudio2/buffer_xaudio2.h | 118 - .../sound/driver/xaudio2/driver_xaudio2.def | 5 - .../sound/driver/xaudio2/effect_xaudio2.cpp | 188 - .../src/sound/driver/xaudio2/effect_xaudio2.h | 78 - .../sound/driver/xaudio2/listener_xaudio2.cpp | 181 - .../sound/driver/xaudio2/listener_xaudio2.h | 110 - .../nel/src/sound/driver/xaudio2/resources.rc | 37 - .../driver/xaudio2/sound_driver_xaudio2.cpp | 544 --- .../driver/xaudio2/sound_driver_xaudio2.h | 191 - .../sound/driver/xaudio2/source_xaudio2.cpp | 1167 ----- .../src/sound/driver/xaudio2/source_xaudio2.h | 305 -- .../src/sound/driver/xaudio2/stdxaudio2.cpp | 17 - .../nel/src/sound/driver/xaudio2/stdxaudio2.h | 126 - code/nel/src/sound/simple_source.cpp | 20 +- code/nel/src/sound/stream_source.cpp | 46 +- code/nel/tools/3d/crash_log_analyser/main.cpp | 35 +- code/nel/tools/3d/ligo/plugin_max/script.cpp | 117 +- .../tools/3d/object_viewer/object_viewer.cfg | 4 +- .../tools/3d/object_viewer/object_viewer.cpp | 264 +- .../tools/3d/object_viewer/object_viewer.h | 39 +- .../3d/object_viewer_widget/src/interfaces.h | 11 +- .../src/object_viewer_widget.cpp | 15 +- .../src/object_viewer_widget.h | 8 +- code/nel/tools/3d/zviewer/zviewer.cpp | 2 +- .../tools/sound/build_sound/build_sound.cpp | 3 +- code/ryzom/client/client_default.cfg | 2 +- code/ryzom/client/src/bug_report/StdAfx.h | 1 - .../client/src/bug_report/bug_reportDlg.cpp | 9 +- code/ryzom/client/src/client_cfg.cpp | 3 - code/ryzom/client/src/client_cfg.h | 6 +- code/ryzom/client/src/init.cpp | 9 +- code/ryzom/client/src/init_main_loop.cpp | 5 - .../client/src/landscape_poly_drawer.cpp | 9 +- code/ryzom/client/src/main_loop.cpp | 139 +- code/ryzom/client/src/seven_zip/LzFind.cpp | 93 +- code/ryzom/client/src/seven_zip/LzFind.h | 9 +- code/ryzom/client/src/seven_zip/LzmaEnc.cpp | 62 +- code/ryzom/client/src/sound_manager.cpp | 8 +- .../ryzom/tools/client/client_config/StdAfx.h | 1 - .../tools/client/client_config/cfg_file.cpp | 29 +- .../client/client_config/client_config.cpp | 14 +- .../client/client_config/client_config.rc | 57 +- .../client/client_config/client_configDlg.cpp | 59 +- .../client/client_config/client_configDlg.h | 4 +- .../tools/client/client_config/database.cpp | 4 +- .../tools/client/client_config/database.h | 3 +- .../client/client_config/display_dlg.cpp | 115 +- .../tools/client/client_config/display_dlg.h | 18 +- .../display_information_d3d_dlg.cpp | 73 - .../display_information_d3d_dlg.h | 66 - .../tools/client/client_config/resource.h | 10 +- .../src/client_config_dialog.cpp | 15 - .../src/display_settings_widget.cpp | 59 +- .../src/display_settings_widget.h | 3 +- .../src/sound_settings_widget.cpp | 20 +- .../src/sys_info_d3d_widget.cpp | 36 - .../src/sys_info_d3d_widget.h | 35 - .../client/client_config_qt/src/system.cpp | 33 - .../client/client_config_qt/src/system.h | 15 - .../translations/ryzom_configuration_de.ts | 58 - .../translations/ryzom_configuration_es.ts | 57 - .../translations/ryzom_configuration_fr.ts | 57 - .../translations/ryzom_configuration_hu.ts | 84 - .../translations/ryzom_configuration_ru.ts | 53 - .../ui/client_config_dialog.ui | 5 - .../ui/display_settings_widget.ui | 14 - .../ui/sound_settings_widget.ui | 14 - .../ui/sys_info_d3d_widget.ui | 156 - .../screenshot_islands.cpp | 2 +- .../data/georges_editor_default.cfg | 76 +- .../georges_editor_qt/src/configuration.cpp | 22 +- .../src/objectviewer_dialog.cpp | 3 +- .../georges_plugin_sound/CMakeLists.txt | 2 +- .../georges_plugin_sound/sound_plugin.h | 14 +- .../install/world_editor_plugin.cfg | 10 +- .../sound_plugin.cpp | 22 +- .../packed_world_builder.cpp | 2 +- .../ryzom/tools/translation/translated/de.uxt | 5 - .../ryzom/tools/translation/translated/en.uxt | 5 - .../ryzom/tools/translation/translated/es.uxt | 5 - .../ryzom/tools/translation/translated/fr.uxt | 5 - .../ryzom/tools/translation/translated/ru.uxt | 5 - .../ryzom/tools/translation/translated/wk.uxt | 14 +- code/ryzom/tools/translation/work/wk.uxt | 63 +- code/snowballs2/CMakePackaging.txt | 3 +- code/snowballs2/client/client.cfg.in | 4 +- .../client/src/snowballs_client.cpp | 13 +- code/snowballs2/client/src/sound.cpp | 11 +- .../object_viewer/graphics_settings_page.ui | 5 - .../plugins/object_viewer/object_viewer.cpp | 10 +- .../src/plugins/object_viewer/object_viewer.h | 14 +- .../object_viewer/sound_settings_page.ui | 10 - .../src/translations/object_viewer_qt_de.ts | 15 - .../src/translations/object_viewer_qt_en.ts | 15 - .../src/translations/object_viewer_qt_fr.ts | 15 - .../src/translations/object_viewer_qt_ru.ts | 23 +- dist/debian/jessie/debian/client_default.cfg | 62 +- dist/debian/precise/debian/client_default.cfg | 62 +- dist/debian/trusty/debian/client_default.cfg | 62 +- dist/debian/utopic/debian/client_default.cfg | 62 +- dist/debian/vivid/debian/client_default.cfg | 62 +- dist/debian/xenial/debian/client_default.cfg | 62 +- dist/debian/yaketty/debian/client_default.cfg | 62 +- dist/debian/zesty/debian/client_default.cfg | 62 +- dist/nsis/ryzom_setup.nsi | 8 +- 211 files changed, 1346 insertions(+), 31376 deletions(-) delete mode 100644 code/CMakeModules/FindDSound.cmake delete mode 100644 code/CMakeModules/FindDirectXSDK.cmake delete mode 100644 code/nel/src/3d/driver/direct3d/CMakeLists.txt delete mode 100644 code/nel/src/3d/driver/direct3d/driver_direct3d.cpp delete mode 100644 code/nel/src/3d/driver/direct3d/driver_direct3d.def delete mode 100644 code/nel/src/3d/driver/direct3d/driver_direct3d.h delete mode 100644 code/nel/src/3d/driver/direct3d/driver_direct3d_index.cpp delete mode 100644 code/nel/src/3d/driver/direct3d/driver_direct3d_inputs.cpp delete mode 100644 code/nel/src/3d/driver/direct3d/driver_direct3d_light.cpp delete mode 100644 code/nel/src/3d/driver/direct3d/driver_direct3d_material.cpp delete mode 100644 code/nel/src/3d/driver/direct3d/driver_direct3d_matrix.cpp delete mode 100644 code/nel/src/3d/driver/direct3d/driver_direct3d_pixel_program.cpp delete mode 100644 code/nel/src/3d/driver/direct3d/driver_direct3d_profile.cpp delete mode 100644 code/nel/src/3d/driver/direct3d/driver_direct3d_render.cpp delete mode 100644 code/nel/src/3d/driver/direct3d/driver_direct3d_shader.cpp delete mode 100644 code/nel/src/3d/driver/direct3d/driver_direct3d_texture.cpp delete mode 100644 code/nel/src/3d/driver/direct3d/driver_direct3d_uniform.cpp delete mode 100644 code/nel/src/3d/driver/direct3d/driver_direct3d_vertex.cpp delete mode 100644 code/nel/src/3d/driver/direct3d/driver_direct3d_vertex_program.cpp delete mode 100644 code/nel/src/3d/driver/direct3d/resources.rc delete mode 100644 code/nel/src/3d/driver/direct3d/stddirect3d.cpp delete mode 100644 code/nel/src/3d/driver/direct3d/stddirect3d.h delete mode 100644 code/nel/src/sound/driver/dsound/CMakeLists.txt delete mode 100644 code/nel/src/sound/driver/dsound/buffer_dsound.cpp delete mode 100644 code/nel/src/sound/driver/dsound/buffer_dsound.h delete mode 100644 code/nel/src/sound/driver/dsound/driver_dsound.def delete mode 100644 code/nel/src/sound/driver/dsound/listener_dsound.cpp delete mode 100644 code/nel/src/sound/driver/dsound/listener_dsound.h delete mode 100644 code/nel/src/sound/driver/dsound/resources.rc delete mode 100644 code/nel/src/sound/driver/dsound/sound_driver_dsound.cpp delete mode 100644 code/nel/src/sound/driver/dsound/sound_driver_dsound.h delete mode 100644 code/nel/src/sound/driver/dsound/source_dsound.cpp delete mode 100644 code/nel/src/sound/driver/dsound/source_dsound.h delete mode 100644 code/nel/src/sound/driver/dsound/stddsound.cpp delete mode 100644 code/nel/src/sound/driver/dsound/stddsound.h delete mode 100644 code/nel/src/sound/driver/xaudio2/CMakeLists.txt delete mode 100644 code/nel/src/sound/driver/xaudio2/adpcm_xaudio2.cpp delete mode 100644 code/nel/src/sound/driver/xaudio2/adpcm_xaudio2.h delete mode 100644 code/nel/src/sound/driver/xaudio2/buffer_xaudio2.cpp delete mode 100644 code/nel/src/sound/driver/xaudio2/buffer_xaudio2.h delete mode 100644 code/nel/src/sound/driver/xaudio2/driver_xaudio2.def delete mode 100644 code/nel/src/sound/driver/xaudio2/effect_xaudio2.cpp delete mode 100644 code/nel/src/sound/driver/xaudio2/effect_xaudio2.h delete mode 100644 code/nel/src/sound/driver/xaudio2/listener_xaudio2.cpp delete mode 100644 code/nel/src/sound/driver/xaudio2/listener_xaudio2.h delete mode 100644 code/nel/src/sound/driver/xaudio2/resources.rc delete mode 100644 code/nel/src/sound/driver/xaudio2/sound_driver_xaudio2.cpp delete mode 100644 code/nel/src/sound/driver/xaudio2/sound_driver_xaudio2.h delete mode 100644 code/nel/src/sound/driver/xaudio2/source_xaudio2.cpp delete mode 100644 code/nel/src/sound/driver/xaudio2/source_xaudio2.h delete mode 100644 code/nel/src/sound/driver/xaudio2/stdxaudio2.cpp delete mode 100644 code/nel/src/sound/driver/xaudio2/stdxaudio2.h delete mode 100644 code/ryzom/tools/client/client_config/display_information_d3d_dlg.cpp delete mode 100644 code/ryzom/tools/client/client_config/display_information_d3d_dlg.h delete mode 100644 code/ryzom/tools/client/client_config_qt/src/sys_info_d3d_widget.cpp delete mode 100644 code/ryzom/tools/client/client_config_qt/src/sys_info_d3d_widget.h delete mode 100644 code/ryzom/tools/client/client_config_qt/ui/sys_info_d3d_widget.ui diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 7366425c8..8313aad7a 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -22,7 +22,7 @@ # gitlab-runner exec docker --timeout=3600 'Linux client debian_amd64_strech build' # gitlab-runner exec docker --timeout=3600 'Linux client_static debian_amd64_strech build' # gitlab-runner exec docker --kubernetes-memory-limit='10g' --timeout=3600 'Linux client build' -# gitlab-runner exec docker --kubernetes-memory-limit='10g' --timeout=3600 'Linux client archlinux build' +# gitlab-runner exec docker --kubernetes-memory-limit='10g' --timeout=3600 'Linux client archlinux build' # gitlab-runner exec docker --kubernetes-memory-limit='10g' --timeout=3600 'Linux client fedora_amd64_27 build' # gitlab-runner exec docker --kubernetes-memory-limit='10g' --timeout=3600 'Linux client ubuntu_amd64_17_10 build' # gitlab-runner exec docker --kubernetes-memory-limit='10g' --timeout=3600 'Windows client build' @@ -1055,7 +1055,7 @@ Windows client build: - find codebis -type f -name "*.rc" -exec unix2dos {} \; - mkdir -p build - cd build - - wine cmake.exe -DWITH_RYZOM_CUSTOM_PATCH_SERVER=ON -DWITH_RYZOM_SERVER=OFF -DWITH_RYZOM_TOOLS=OFF -DWITH_RYZOM_CLIENT=ON -DWITH_RYZOM_PATCH=ON -DWITH_NEL_TESTS=OFF -DWITH_NEL_TOOLS=OFF -DWITH_TOOLS=OFF -DWITH_NEL_SAMPLES=OFF -DWITH_LUA53=ON -DWITH_LUA51=OFF -DWITH_STLPORT=OFF -DWITH_DRIVER_DSOUND=ON -G "NMake Makefiles JOM" -DWITH_STATIC=ON -DWITH_STATIC_DRIVERS=ON -DWITH_DRIVER_OPENAL=OFF -DWITH_DRIVER_DSOUND=ON -DWITH_DRIVER_XAUDIO2=ON -DWITH_DRIVER_FMOD=ON -DWITH_DRIVER_DIRECT3D=ON ../codebis + - wine cmake.exe -DWITH_RYZOM_CUSTOM_PATCH_SERVER=ON -DWITH_RYZOM_SERVER=OFF -DWITH_RYZOM_TOOLS=OFF -DWITH_RYZOM_CLIENT=ON -DWITH_RYZOM_PATCH=ON -DWITH_NEL_TESTS=OFF -DWITH_NEL_TOOLS=OFF -DWITH_TOOLS=OFF -DWITH_NEL_SAMPLES=OFF -DWITH_LUA53=ON -DWITH_LUA51=OFF -DWITH_STLPORT=OFF -G "NMake Makefiles JOM" -DWITH_STATIC=ON -DWITH_STATIC_DRIVERS=ON -DWITH_DRIVER_OPENAL=OFF -DWITH_DRIVER_FMOD=ON ../codebis - wine jom.exe artifacts: name: "khanat-client-windows-$CI_COMMIT_REF_NAME" @@ -1104,7 +1104,7 @@ Linux client test: - ./khanat-$(echo $CI_BUILD_REF | head -c 7 )-$CI_PIPELINE_ID-Linux-x86_64.run dependencies: - Linux client build - + .OSX client test: stage: test only: @@ -1120,7 +1120,7 @@ Linux client test: ##DEPLOYEMENT TO STAGING (TEST SERVER) -# Job de déploiment vers le staging. Inutilisé pour le moment, il pourrait servir à l'avenir pour déployer automatiquement les nouvelles versions du client/serveur vers l'environnement de staging (zone de test) +# Job de déploiment vers le staging. Inutilisé pour le moment, il pourrait servir à l'avenir pour déployer automatiquement les nouvelles versions du client/serveur vers l'environnement de staging (zone de test) .Deploy to Staging: stage: staging environment: Staging @@ -1138,9 +1138,9 @@ Linux client test: - OSX client test when: manual -##DEPLOYEMENT TO PRODUCTION +##DEPLOYEMENT TO PRODUCTION -# Job de déploiment vers la production. Inutilisé pour le moment, il pourrait servir à l'avenir pour déployer automatiquement les nouvelles versions du client/serveur vers l'environnement de production +# Job de déploiment vers la production. Inutilisé pour le moment, il pourrait servir à l'avenir pour déployer automatiquement les nouvelles versions du client/serveur vers l'environnement de production .Release to Production: stage: production environment: Production diff --git a/code/CMakeModules/ConfigureChecks.cmake b/code/CMakeModules/ConfigureChecks.cmake index cab7a08c1..ca0b39c51 100644 --- a/code/CMakeModules/ConfigureChecks.cmake +++ b/code/CMakeModules/ConfigureChecks.cmake @@ -10,10 +10,6 @@ MACRO(NL_CONFIGURE_CHECKS) SET(NL_OPENGLES_AVAILABLE 1) ENDIF() - IF(WITH_DRIVER_DIRECT3D) - SET(NL_DIRECT3D_AVAILABLE 1) - ENDIF() - # sound drivers IF(WITH_DRIVER_FMOD) SET(NL_FMOD_AVAILABLE 1) @@ -23,14 +19,6 @@ MACRO(NL_CONFIGURE_CHECKS) SET(NL_OPENAL_AVAILABLE 1) ENDIF() - IF(WITH_DRIVER_DSOUND) - SET(NL_DSOUND_AVAILABLE 1) - ENDIF() - - IF(WITH_DRIVER_XAUDIO2) - SET(NL_XAUDIO2_AVAILABLE 1) - ENDIF() - IF(NOT RYZOM_VERSION_MAJOR) SET(RYZOM_VERSION_MAJOR ${NL_VERSION_MAJOR}) SET(RYZOM_VERSION_MINOR ${NL_VERSION_MINOR}) diff --git a/code/CMakeModules/Find3dsMaxSDK.cmake b/code/CMakeModules/Find3dsMaxSDK.cmake index cf49a90d3..bedc6c368 100644 --- a/code/CMakeModules/Find3dsMaxSDK.cmake +++ b/code/CMakeModules/Find3dsMaxSDK.cmake @@ -1,6 +1,3 @@ -# - Find DirectInput -# Find the DirectSound includes and libraries -# # MAXSDK_DIR - 3DSMAX SDK root directory # MAXSDK_INCLUDE_DIR - where to find baseinterface.h # MAXSDK_LIBRARIES - List of libraries when using 3DSMAX. diff --git a/code/CMakeModules/FindDSound.cmake b/code/CMakeModules/FindDSound.cmake deleted file mode 100644 index dde5212ab..000000000 --- a/code/CMakeModules/FindDSound.cmake +++ /dev/null @@ -1,36 +0,0 @@ -# - Find DirectSound -# Find the DirectSound includes and libraries -# -# DSOUND_INCLUDE_DIR - where to find dsound.h -# DSOUND_LIBRARIES - List of libraries when using dsound. -# DSOUND_FOUND - True if dsound found. - -if(DSOUND_INCLUDE_DIR) - # Already in cache, be silent - set(DSOUND_FIND_QUIETLY TRUE) -ENDIF() - -find_path(DSOUND_INCLUDE_DIR dsound.h - "$ENV{DXSDK_DIR}" - "$ENV{DXSDK_DIR}/Include" -) - -find_library(DSOUND_LIBRARY dsound - "$ENV{DXSDK_DIR}" - "$ENV{DXSDK_DIR}/Lib" - "$ENV{DXSDK_DIR}/Lib/x86" -) - -# Handle the QUIETLY and REQUIRED arguments and set DSOUND_FOUND to TRUE if -# all listed variables are TRUE. -include(FindPackageHandleStandardArgs) -find_package_handle_standard_args(DSOUND DEFAULT_MSG - DSOUND_INCLUDE_DIR DSOUND_LIBRARY) - -if(DSOUND_FOUND) - set(DSOUND_LIBRARIES ${DSOUND_LIBRARY}) -ELSE() - set(DSOUND_LIBRARIES) -ENDIF() - -mark_as_advanced(DSOUND_INCLUDE_DIR DSOUND_LIBRARY) diff --git a/code/CMakeModules/FindDirectXSDK.cmake b/code/CMakeModules/FindDirectXSDK.cmake deleted file mode 100644 index 4519ef16d..000000000 --- a/code/CMakeModules/FindDirectXSDK.cmake +++ /dev/null @@ -1,69 +0,0 @@ -# - Find DirectX -# Find the DirectX includes and libraries -# -# DXSDK_INCLUDE_DIR - where to find baseinterface.h -# DXSDK_LIBRARIES - List of libraries when using 3DSMAX. -# DXSDK_FOUND - True if MAX SDK found. - -IF(DXSDK_DIR) - # Already in cache, be silent - SET(DXSDK_FIND_QUIETLY TRUE) -ENDIF() - -FIND_PATH(DXSDK_DIR - "Include/dxsdkver.h" - PATHS - "$ENV{DXSDK_DIR}" - "C:/Program Files (x86)/Microsoft DirectX SDK (June 2010)" - "C:/Program Files/Microsoft DirectX SDK (June 2010)" - "C:/Program Files (x86)/Microsoft DirectX SDK (February 2010)" - "C:/Program Files/Microsoft DirectX SDK (February 2010)" - "C:/Program Files (x86)/Microsoft DirectX SDK (November 2007)" - "C:/Program Files/Microsoft DirectX SDK (November 2007)" - "C:/Program Files (x86)/Microsoft DirectX SDK" - "C:/Program Files/Microsoft DirectX SDK" -) - -MACRO(FIND_DXSDK_LIBRARY MYLIBRARY MYLIBRARYNAME) - FIND_LIBRARY(${MYLIBRARY} - NAMES ${MYLIBRARYNAME} - HINTS - "${DXSDK_LIBRARY_DIR}" - ) -ENDMACRO() - -IF(DXSDK_DIR) - SET(DXSDK_INCLUDE_DIR "${DXSDK_DIR}/Include") - - IF(TARGET_X64) - SET(DXSDK_LIBRARY_DIRS ${DXSDK_DIR}/Lib/x64 ${DXSDK_DIR}/lib/amd64) - ELSE() - SET(DXSDK_LIBRARY_DIRS ${DXSDK_DIR}/Lib/x86 ${DXSDK_DIR}/lib) - ENDIF() - - FIND_PATH(DXSDK_LIBRARY_DIR - dxguid.lib - PATHS - ${DXSDK_LIBRARY_DIRS}) - - FIND_DXSDK_LIBRARY(DXSDK_GUID_LIBRARY dxguid) - FIND_DXSDK_LIBRARY(DXSDK_DINPUT_LIBRARY dinput8) - FIND_DXSDK_LIBRARY(DXSDK_DSOUND_LIBRARY dsound) - FIND_DXSDK_LIBRARY(DXSDK_XAUDIO_LIBRARY x3daudio) - FIND_DXSDK_LIBRARY(DXSDK_D3DX9_LIBRARY d3dx9) - FIND_DXSDK_LIBRARY(DXSDK_D3D9_LIBRARY d3d9) -ENDIF() - -# Handle the QUIETLY and REQUIRED arguments and set DXSDK_FOUND to TRUE if -# all listed variables are TRUE. -INCLUDE(FindPackageHandleStandardArgs) - -FIND_PACKAGE_HANDLE_STANDARD_ARGS(DirectXSDK DEFAULT_MSG DXSDK_DIR DXSDK_GUID_LIBRARY DXSDK_DINPUT_LIBRARY) - -MARK_AS_ADVANCED(DXSDK_INCLUDE_DIR - DXSDK_GUID_LIBRARY - DXSDK_DINPUT_LIBRARY - DXSDK_DSOUND_LIBRARY - DXSDK_XAUDIO_LIBRARY - DXSDK_D3DX9_LIBRARY - DXSDK_D3D9_LIBRARY) diff --git a/code/CMakeModules/FindMySQL.cmake b/code/CMakeModules/FindMySQL.cmake index 8a92cb0c4..f045d3497 100644 --- a/code/CMakeModules/FindMySQL.cmake +++ b/code/CMakeModules/FindMySQL.cmake @@ -30,12 +30,16 @@ ELSE() FIND_LIBRARY(MYSQL_LIBRARY_RELEASE NAMES libmysql mysqlclient PATHS $ENV{ProgramFiles}/MySQL/*/lib/opt - $ENV{SystemDrive}/MySQL/*/lib/opt) + $ENV{SystemDrive}/MySQL/*/lib/opt + $ENV{ProgramFiles}/MySQL/*/lib + $ENV{SystemDrive}/MySQL/*/lib) FIND_LIBRARY(MYSQL_LIBRARY_DEBUG NAMES libmysqld mysqlclientd PATHS $ENV{ProgramFiles}/MySQL/*/lib/opt - $ENV{SystemDrive}/MySQL/*/lib/opt) + $ENV{SystemDrive}/MySQL/*/lib/opt + $ENV{ProgramFiles}/MySQL/*/lib + $ENV{SystemDrive}/MySQL/*/lib) ELSE() FIND_LIBRARY(MYSQL_LIBRARY_RELEASE NAMES mysqlclient PATHS diff --git a/code/CMakeModules/nel.cmake b/code/CMakeModules/nel.cmake index 95b28bb8a..37935016a 100644 --- a/code/CMakeModules/nel.cmake +++ b/code/CMakeModules/nel.cmake @@ -122,12 +122,6 @@ ENDMACRO(NL_ADD_RUNTIME_FLAGS) MACRO(NL_ADD_STATIC_VID_DRIVERS name) IF(WITH_STATIC_DRIVERS) - IF(WIN32) - IF(WITH_DRIVER_DIRECT3D) - TARGET_LINK_LIBRARIES(${name} nel_drv_direct3d_win) - ENDIF() - ENDIF() - IF(WITH_DRIVER_OPENGL) IF(WIN32) TARGET_LINK_LIBRARIES(${name} nel_drv_opengl_win) @@ -149,14 +143,6 @@ ENDMACRO(NL_ADD_STATIC_VID_DRIVERS) MACRO(NL_ADD_STATIC_SND_DRIVERS name) IF(WITH_STATIC_DRIVERS) IF(WIN32) - IF(WITH_DRIVER_DSOUND) - TARGET_LINK_LIBRARIES(${name} nel_drv_dsound_win) - ENDIF() - - IF(WITH_DRIVER_XAUDIO2) - TARGET_LINK_LIBRARIES(${name} nel_drv_xaudio2_win) - ENDIF() - IF(WITH_DRIVER_OPENAL) TARGET_LINK_LIBRARIES(${name} nel_drv_openal_win) ENDIF() @@ -299,11 +285,8 @@ MACRO(NL_SETUP_NEL_DEFAULT_OPTIONS) ### OPTION(WITH_DRIVER_OPENGL "Build OpenGL Driver (3D)" ON ) OPTION(WITH_DRIVER_OPENGLES "Build OpenGL ES Driver (3D)" OFF) - OPTION(WITH_DRIVER_DIRECT3D "Build Direct3D Driver (3D)" OFF) OPTION(WITH_DRIVER_OPENAL "Build OpenAL Driver (Sound)" ON ) OPTION(WITH_DRIVER_FMOD "Build FMOD Driver (Sound)" OFF) - OPTION(WITH_DRIVER_DSOUND "Build DirectSound Driver (Sound)" OFF) - OPTION(WITH_DRIVER_XAUDIO2 "Build XAudio2 Driver (Sound)" OFF) ### # Optional support @@ -665,7 +648,7 @@ MACRO(NL_SETUP_BUILD) IF(APPLE) SET(OBJC_FLAGS -fobjc-abi-version=2 -fobjc-legacy-dispatch -fobjc-weak) - + IF(NOT XCODE) IF(CMAKE_OSX_ARCHITECTURES) SET(TARGETS_COUNT 0) @@ -1198,14 +1181,6 @@ MACRO(SETUP_EXTERNAL) INCLUDE_DIRECTORIES(${STLPORT_INCLUDE_DIR}) ENDIF() - IF(WIN32) - # Must include DXSDK before WINSDK - FIND_PACKAGE(DirectXSDK REQUIRED) - # IF(DXSDK_INCLUDE_DIR) - # INCLUDE_DIRECTORIES(${DXSDK_INCLUDE_DIR}) - # ENDIF() - ENDIF() - IF(MSVC) FIND_PACKAGE(MSVC REQUIRED) FIND_PACKAGE(WindowsSDK REQUIRED) diff --git a/code/config.h.cmake b/code/config.h.cmake index 69171cf68..1ead86c20 100644 --- a/code/config.h.cmake +++ b/code/config.h.cmake @@ -3,12 +3,9 @@ #cmakedefine NL_OPENGL_AVAILABLE ${NL_OPENGL_AVAILABLE} #cmakedefine NL_OPENGLES_AVAILABLE ${NL_OPENGLES_AVAILABLE} -#cmakedefine NL_DIRECT3D_AVAILABLE ${NL_DIRECT3D_AVAILABLE} #cmakedefine NL_FMOD_AVAILABLE ${NL_FMOD_AVAILABLE} #cmakedefine NL_OPENAL_AVAILABLE ${NL_OPENAL_AVAILABLE} -#cmakedefine NL_DSOUND_AVAILABLE ${NL_DSOUND_AVAILABLE} -#cmakedefine NL_XAUDIO2_AVAILABLE ${NL_XAUDIO2_AVAILABLE} #cmakedefine NL_STEREO_AVAILABLE ${NL_STEREO_AVAILABLE} diff --git a/code/nel/include/nel/3d/bloom_effect.h b/code/nel/include/nel/3d/bloom_effect.h index 49c959e23..0b3ecc2a0 100644 --- a/code/nel/include/nel/3d/bloom_effect.h +++ b/code/nel/include/nel/3d/bloom_effect.h @@ -37,7 +37,7 @@ class CTextureUser; //---------------------------------------- CBloomEffect ----------------------------------------------------- //----------------------------------------------------------------------------------------------------------- // CBloomEffect class apply a bloom effect on the whole scene. The whole scene is rendered in a -// render target (a Frame Buffer Object on OpengL, the normal back buffer in Direct3D) which is stretched +// render target (a Frame Buffer Object on OpengL) which is stretched // in a 256*256 another render target. // We apply a horizontal blur on this 256*256 render target, then a vertical blur on the result of this first pass. // The final blurred render target is blend with the initial render target of scene, with a dest + src - dest*src @@ -93,7 +93,6 @@ public: // to keep Z tests correct. // This method is called at the end of interfaces display in the main loop, to display final render target // (with added interfaces) in the color frame buffer. - // NB : In Direct3D, the final render target is displayed at the end of endBloom call. // void endInterfacesDisplayBloom(); private: diff --git a/code/nel/include/nel/3d/driver.h b/code/nel/include/nel/3d/driver.h index 52bda8576..a2ef613ba 100644 --- a/code/nel/include/nel/3d/driver.h +++ b/code/nel/include/nel/3d/driver.h @@ -188,9 +188,6 @@ public: /// Before rendering via a driver in a thread, must activate() (per thread). virtual bool activate() = 0; - // Test if the device is lost. Can only happen with D3D. - // The calling application may skip some part of its rendering when it is the case (this is not a requirement, but may save cpu for other applications) - virtual bool isLost() const = 0; /// Return true if driver is still active. Return false else. If he user close the window, must return false. virtual bool isActive() = 0; @@ -437,8 +434,7 @@ public: virtual uint getNbTextureStages() const = 0; /** Get max number of per stage constant that can be used simultaneously. - * This will usually match the number of texture stages, but with a D3D driver, this feature is not available most of the time - * so it is emulated. If pixel shaders are available this will be fully supported. + * This will usually match the number of texture stages. If pixel shaders are available this will be fully supported. * Under OpenGL this simply returns the maximum number of texture stages (getNbTextureStages) in both return values. */ virtual void getNumPerStageConstant(uint &lightedMaterial, uint &unlightedMaterial) const = 0; @@ -1363,7 +1359,7 @@ public: */ virtual bool setAdapter(uint adapter) = 0; - /** Tell if the vertex color memory format is RGBA (openGL) or BGRA (directx) + /** Tell if the vertex color memory format is RGBA (openGL) or BGRA * BGRA : * ***************************************************************** * Offset: * 0 * 1 * 2 * 3 * @@ -1446,4 +1442,3 @@ private: } #endif // NL_DRV_H - diff --git a/code/nel/include/nel/3d/driver_user.h b/code/nel/include/nel/3d/driver_user.h index 62c6fd6db..d553fa928 100644 --- a/code/nel/include/nel/3d/driver_user.h +++ b/code/nel/include/nel/3d/driver_user.h @@ -133,8 +133,6 @@ public: virtual ~CDriverUser(); // @} - virtual bool isLost() const; - /// \name Window / driver management. // @{ diff --git a/code/nel/include/nel/3d/dru.h b/code/nel/include/nel/3d/dru.h index fda543ecd..ab4db8819 100644 --- a/code/nel/include/nel/3d/dru.h +++ b/code/nel/include/nel/3d/dru.h @@ -27,11 +27,9 @@ #if defined (NL_COMP_MINGW) # define NL3D_GL_DLL_NAME "libnel_drv_opengl_win" # define NL3D_GLES_DLL_NAME "libnel_drv_opengles_win" -# define NL3D_D3D_DLL_NAME "libnel_drv_direct3d_win" #elif defined (NL_OS_WINDOWS) # define NL3D_GL_DLL_NAME "nel_drv_opengl_win" # define NL3D_GLES_DLL_NAME "nel_drv_opengles_win" -# define NL3D_D3D_DLL_NAME "nel_drv_direct3d_win" #elif defined (NL_OS_UNIX) # define NL3D_GL_DLL_NAME "nel_drv_opengl" # define NL3D_GLES_DLL_NAME "nel_drv_opengles" @@ -100,34 +98,6 @@ struct EDruOpenglEsDriverCantCreateDriver : public EDru EDruOpenglEsDriverCantCreateDriver() : EDru( NL3D_GLES_DLL_NAME " can't create driver" ) {} }; -#ifdef NL_OS_WINDOWS -// Direct3D -struct EDruDirect3dDriverNotFound : public EDru -{ - EDruDirect3dDriverNotFound() : EDru( NL3D_D3D_DLL_NAME " not found" ) {} -}; - -struct EDruDirect3dDriverCorrupted : public EDru -{ - EDruDirect3dDriverCorrupted() : EDru( "Can't get NL3D_createIDriverInstance from " NL3D_D3D_DLL_NAME " (Bad dll?)" ) {} -}; - -struct EDruDirect3dDriverOldVersion : public EDru -{ - EDruDirect3dDriverOldVersion() : EDru( NL3D_D3D_DLL_NAME " is a too old version. Ask for a more recent file" ) {} -}; - -struct EDruDirect3dDriverUnknownVersion : public EDru -{ - EDruDirect3dDriverUnknownVersion() : EDru( NL3D_D3D_DLL_NAME " is more recent than the application" ) {} -}; - -struct EDruDirect3dDriverCantCreateDriver : public EDru -{ - EDruDirect3dDriverCantCreateDriver() : EDru( NL3D_D3D_DLL_NAME " can't create driver" ) {} -}; -#endif // NL_OS_WINDOWS - /// The driver Utilities class of static. class CDRU { @@ -139,11 +109,6 @@ public: /// Portable Function which create a GL ES Driver (using gl dll...). static IDriver *createGlEsDriver() throw(EDru); -#ifdef NL_OS_WINDOWS - /// Windows Function which create a Direct3d Driver. - static IDriver *createD3DDriver() throw(EDru); -#endif // NL_OS_WINDOWS - /// \name 2D render. // @{ /// Draw a bitmap 2D. Warning: this is slow... diff --git a/code/nel/include/nel/3d/material.h b/code/nel/include/nel/3d/material.h index 7a300da45..8a1a18a76 100644 --- a/code/nel/include/nel/3d/material.h +++ b/code/nel/include/nel/3d/material.h @@ -223,8 +223,7 @@ public: /** \name Texture Addressing Modes. They are valid only with the normal texture shader. * All modes are not supported everywhere, so you should check for it in the driver. - * The modes are similar to those introduced with DirectX 8.0 Pixel Shaders and OpenGL - * TEXTURE_SHADERS_NV + * The modes are similar to those introduced with OpenGL TEXTURE_SHADERS_NV */ // @{ enum TTexAddressingMode { @@ -416,7 +415,7 @@ public: * * For compatibility problems: * - no scaling is allowed (some cards do not implement this well). - * - Texture can be the source only for Arg0 (DirectX restriction). nlassert... + * - Texture can be the source only for Arg0. nlassert... * * NB: for Alpha Aguments, only operands SrcAlpha and InvSrcAlpha are valid (nlassert..). */ diff --git a/code/nel/include/nel/3d/nelu.h b/code/nel/include/nel/3d/nelu.h index fb30a5012..5c25fc515 100644 --- a/code/nel/include/nel/3d/nelu.h +++ b/code/nel/include/nel/3d/nelu.h @@ -64,7 +64,7 @@ public: * * You can access the driver with CNELU::Driver. */ - static bool initDriver(uint w, uint h, uint bpp=32, bool windowed=true, nlWindow systemWindow=EmptyWindow, bool offscreen=false, bool direct3d=false) throw(EDru); + static bool initDriver(uint w, uint h, uint bpp=32, bool windowed=true, nlWindow systemWindow=EmptyWindow, bool offscreen=false) throw(EDru); /** Init all that we need for a Scene. * - register scene basics models, @@ -108,7 +108,7 @@ public: * - initScene(); * - initEventServer(); */ - static bool init(uint w, uint h, CViewport viewport=CViewport(), uint bpp=32, bool windowed=true, nlWindow systemWindow=EmptyWindow, bool offscreen = false, bool direct3d = false) throw(EDru); + static bool init(uint w, uint h, CViewport viewport=CViewport(), uint bpp=32, bool windowed=true, nlWindow systemWindow=EmptyWindow, bool offscreen = false) throw(EDru); /** Delete all: * - releaseEventServer(); diff --git a/code/nel/include/nel/3d/program.h b/code/nel/include/nel/3d/program.h index 77e6baa62..2183b9c07 100644 --- a/code/nel/include/nel/3d/program.h +++ b/code/nel/include/nel/3d/program.h @@ -6,20 +6,20 @@ * IProgram */ -/* +/* * Copyright (C) 2013 by authors - * + * * This file is part of NL3D. * NL3D is free software: you can redistribute it and/or modify it * under the terms of the GNU Affero General Public License as * published by the Free Software Foundation, either version 3 of the * License, or (at your option) any later version. - * + * * NL3D is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General * Public License for more details. - * + * * You should have received a copy of the GNU Affero General Public * License along with NL3D. If not, see * . @@ -61,7 +61,7 @@ public: }; // Features exposed by a program. Used to set builtin parameters on user provided shaders. -// This is only used for user provided shaders, not for builtin shaders, +// This is only used for user provided shaders, not for builtin shaders, // as it is a slow method which has to go through all of the options every time. // Builtin shaders should set all flags to 0. // Example: @@ -81,18 +81,18 @@ struct CProgramFeatures enum TDriverFlags { // Matrices - Matrices = 0x00000001, + Matrices = 0x00000001, // Fog - Fog = 0x00000002, + Fog = 0x00000002, }; uint32 DriverFlags; enum TMaterialFlags { /// Use the CMaterial texture stages as the textures for a Pixel Program - TextureStages = 0x00000001, - TextureMatrices = 0x00000002, + TextureStages = 0x00000001, + TextureMatrices = 0x00000002, }; // Material builtin parameters uint32 MaterialFlags; @@ -104,22 +104,22 @@ struct CProgramIndex { enum TName { - ModelView, - ModelViewInverse, - ModelViewTranspose, - ModelViewInverseTranspose, + ModelView, + ModelViewInverse, + ModelViewTranspose, + ModelViewInverseTranspose, - Projection, - ProjectionInverse, - ProjectionTranspose, - ProjectionInverseTranspose, + Projection, + ProjectionInverse, + ProjectionTranspose, + ProjectionInverseTranspose, - ModelViewProjection, - ModelViewProjectionInverse, - ModelViewProjectionTranspose, - ModelViewProjectionInverseTranspose, + ModelViewProjection, + ModelViewProjectionInverse, + ModelViewProjectionTranspose, + ModelViewProjectionInverseTranspose, - Fog, + Fog, NUM_UNIFORMS }; @@ -148,22 +148,6 @@ public: // nel - 0x31,type,bitfield nelvp = 0x31010001, // VP supported by CVertexProgramParser, similar to arbvp1, can be translated to vs_1_1 - // direct3d - 0xD9,type,major,minor - // vertex programs - vs_1_1 = 0xD9010101, - vs_2_0 = 0xD9010200, - // vs_2_sw = 0xD9010201, // not sure... - // vs_2_x = 0xD9010202, // not sure... - // vs_3_0 = 0xD9010300, // not supported - // pixel programs - ps_1_1 = 0xD9020101, - ps_1_2 = 0xD9020102, - ps_1_3 = 0xD9020103, - ps_1_4 = 0xD9020104, - ps_2_0 = 0xD9020200, - // ps_2_x = 0xD9020201, // not sure... - // ps_3_0 = 0xD9020300, // not supported - // opengl - 0x61,type,bitfield // vertex programs // vp20 = 0x61010001, // NV_vertex_program1_1, outdated @@ -211,7 +195,7 @@ public: /// Map with known parameter indices, used for assembly programs std::map ParamIndices; - + private: std::string SourceCopy; }; @@ -227,7 +211,7 @@ public: inline size_t addSource(CSource *source) { nlassert(!m_Source); m_Sources.push_back(source); return (m_Sources.size() - 1); } inline void removeSource(size_t i) { nlassert(!m_Source); m_Sources.erase(m_Sources.begin() + i); } - // Get the idx of a parameter (ogl: uniform, d3d: constant, etcetera) by name. Invalid name returns ~0 + // Get the idx of a parameter (ogl: uniform, etcetera) by name. Invalid name returns ~0 inline uint getUniformIndex(const char *name) const { return m_DrvInfo->getUniformIndex(name); }; inline uint getUniformIndex(const std::string &name) const { return m_DrvInfo->getUniformIndex(name.c_str()); }; inline uint getUniformIndex(CProgramIndex::TName name) const { return m_Index.Indices[name]; } diff --git a/code/nel/include/nel/3d/ps_attrib_maker.h b/code/nel/include/nel/3d/ps_attrib_maker.h index fb96cb86e..855dba45c 100644 --- a/code/nel/include/nel/3d/ps_attrib_maker.h +++ b/code/nel/include/nel/3d/ps_attrib_maker.h @@ -287,7 +287,7 @@ public: // misc - // used by colors only : set the internal color format. useful to write in vertex buffer (format differs between D3D & OpenGL) + // used by colors only : set the internal color format. useful to write in vertex buffer virtual void setColorType(CVertexBuffer::TVertexColorType /* type */) {} protected: diff --git a/code/nel/include/nel/3d/texture.h b/code/nel/include/nel/3d/texture.h index bd71a00fd..1a5c583ac 100644 --- a/code/nel/include/nel/3d/texture.h +++ b/code/nel/include/nel/3d/texture.h @@ -470,7 +470,7 @@ public: /** See if filter mode or wrap mode have been touched. * If this is the case, the driver should resetup them for that texture (If driver stores filter & wrap mode - * per texture (OpenGL) rather than globally (D3D)) + * per texture (OpenGL)) */ bool filterOrWrapModeTouched() const { return _FilterOrWrapModeTouched; } diff --git a/code/nel/include/nel/3d/u_driver.h b/code/nel/include/nel/3d/u_driver.h index 0500192ad..f33e93020 100644 --- a/code/nel/include/nel/3d/u_driver.h +++ b/code/nel/include/nel/3d/u_driver.h @@ -140,7 +140,7 @@ public: enum TStencilFunc { never = 0, less, lessequal, equal, notequal, greaterequal, greater, always}; // Existing drivers - enum TDriver { Direct3d = 0, OpenGl, OpenGlEs }; + enum TDriver { OpenGl = 1, OpenGlEs }; public: /// The EventServer of this driver. Init after setDisplay()!! @@ -157,10 +157,6 @@ public: virtual ~UDriver(); // @} - // Test if the device is lost. Can only happen with D3D. - // The calling application may skip some part of its rendering when it is the case (this is not a requirement, but may save cpu for other applications) - virtual bool isLost() const = 0; - /// \name Disable Hardware Feature /** Disable some Feature that may be supported by the Hardware @@ -200,7 +196,6 @@ public: virtual void showWindow(bool show = true)=0; /* Pass in dialog box mode. After having called this method, you can use normal GUI. - * In fullscreen under direct3d, the main 3d window is minimized. * * \code * Driver->beginDialogMode(); @@ -215,7 +210,6 @@ public: virtual void beginDialogMode() =0; /* Leave the dialog box mode. After having called this method, you can't use normal GUI anymore. - * In fullscreen under direct3d, the main 3d window is maximized. */ virtual void endDialogMode() =0; @@ -841,7 +835,7 @@ public: /** * This is the static function which build a UDriver, the root for all 3D functions. */ - static UDriver *createDriver(uintptr_t windowIcon = 0, bool direct3d = false, emptyProc exitFunc = 0); + static UDriver *createDriver(uintptr_t windowIcon = 0, emptyProc exitFunc = 0); static UDriver *createDriver(uintptr_t windowIcon, TDriver driver, emptyProc exitFunc = 0); /** diff --git a/code/nel/include/nel/3d/vertex_buffer.h b/code/nel/include/nel/3d/vertex_buffer.h index 1f1c789ae..60e047df2 100644 --- a/code/nel/include/nel/3d/vertex_buffer.h +++ b/code/nel/include/nel/3d/vertex_buffer.h @@ -178,7 +178,7 @@ public: /** - * Value type, there is 13 kind of value type as in DirectX8 and gl_vertex_program used in exteneded mode + * Value type, there is 13 kind of value type as in gl_vertex_program used in exteneded mode */ enum TType { @@ -1267,24 +1267,3 @@ inline void CVertexBuffer::unlock () const #endif // NL_VERTEX_BUFFER_H /* End of vertex_buffer.h */ - - - - - - - - - - - - - - - - - - - - - diff --git a/code/nel/include/nel/3d/vertex_program_parse.h b/code/nel/include/nel/3d/vertex_program_parse.h index 88538da07..de039e79b 100644 --- a/code/nel/include/nel/3d/vertex_program_parse.h +++ b/code/nel/include/nel/3d/vertex_program_parse.h @@ -24,10 +24,10 @@ /** * This class is a vertex program. * - * D3D / OPENGL compatibility notes: + * OPENGL compatibility notes: * --------------------------------- * - * To make your program compatible with D3D and OPENGL nel drivers, please follow thoses directives to write your vertex programs + * To make your program compatible with OPENGL nel drivers, please follow thoses directives to write your vertex programs * * - Use only v[0], v[1] etc.. syntax for input registers. Don't use v0, v1 or v[OPOS] etc.. * - Use only c[0], c[1] etc.. syntax for constant registers. Don't use c0, c1 etc.. @@ -39,11 +39,6 @@ * - Don't use macros. * * -> Thoses programs work without any change under OpenGL. - * -> Direct3D driver implementation will have to modify the syntax on the fly before the setup like this: - * - "v[0]" must be changed in "v0" etc.. - * - "o[HPOS]" must be changed in oPos etc.. - * - Semicolon must be changed in line return character. - * - ARL instruction must be changed in MOV. * * Behaviour of LOG may change depending on implementation: You can only expect to have dest.z = log2(abs(src.w)). * LIT may or may not clamp the specular exponent to [-128, 128] (not done when EXT_vertex_shader is used for example ..) @@ -166,7 +161,7 @@ struct CVPInstruction enum EOpcode { MOV = 0, - ARL, // in D3D, is equivalent to MOV + ARL, MUL, ADD, MAD, @@ -266,4 +261,3 @@ private: #endif - diff --git a/code/nel/include/nel/sound/driver/buffer.h b/code/nel/include/nel/sound/driver/buffer.h index 8e6030949..4bc82a432 100644 --- a/code/nel/include/nel/sound/driver/buffer.h +++ b/code/nel/include/nel/sound/driver/buffer.h @@ -46,7 +46,6 @@ public: /// Standard PCM format. FormatPcm = 1, /// Intel/DVI ADPCM format, only available for 1 channel at 16 bits per sample, encoded at 4 bits per sample. - /// This is only implemented in the DSound and XAudio2 driver. FormatDviAdpcm = 11, /// No format set. Used when a TBufferFormat value has not been set to any value yet. FormatNotSet = (~0), @@ -55,13 +54,13 @@ public: enum TStorageMode { /// Put buffer in sound hardware memory if possible, else in machine ram. - StorageAuto, + StorageAuto, /// Put buffer in sound hardware memory (fails if not possible). It is recommended to use StorageAuto instead of StorageHardware. - StorageHardware, + StorageHardware, /// Put buffer in machine ram (used for streaming). It behaves as if OptionSoftwareBuffer and OptionLocalBufferCopy are both enabled. StorageSoftware }; - + /** Preset the name of the buffer. Used for async loading to give a name * before the buffer is effectivly loaded. * If the name after loading of the buffer doesn't match the preset name, @@ -86,16 +85,16 @@ public: virtual bool unlock(uint size) = 0; /// Copy the data with specified size into the buffer. A readable local copy is only guaranteed when OptionLocalBufferCopy is set. Returns true if ok. virtual bool fill(const uint8 *src, uint size) = 0; - + /// Return the size of the buffer, in bytes. virtual uint getSize() const = 0; /// Return the duration (in ms) of the sample in the buffer. virtual float getDuration() const = 0; /// Return true if the buffer is stereo (multi-channel), false if mono. - virtual bool isStereo() const = 0; + virtual bool isStereo() const = 0; /// Return true if the buffer is loaded. Used for async load/unload. virtual bool isBufferLoaded() const = 0; - + //@{ //\name ***deprecated*** /// Set the sample format. Example: freq=44100. ***deprecated*** @@ -115,7 +114,7 @@ public: /// Return duration in seconds from pcm size in bytes. static float getDurationFromPCMSize(uint size, uint8 channels, uint8 bitsPerSample, uint32 frequency); //@} - + //@{ //\name ADPCM and sample bank building utility methods struct TADPCMState @@ -128,7 +127,7 @@ public: /// Encode 16bit Mono PCM buffer into Mono ADPCM. static void encodeADPCM(const sint16 *indata, uint8 *outdata, uint nbSample, TADPCMState &state); /// Decode Mono ADPCM into 16bit Mono PCM. - static void decodeADPCM(const uint8 *indata, sint16 *outdata, uint nbSample, TADPCMState &state); + static void decodeADPCM(const uint8 *indata, sint16 *outdata, uint nbSample, TADPCMState &state); /// Read a wav file. Data type uint8 is used as unspecified buffer format. static bool readWav(const uint8 *wav, uint size, std::vector &result, TBufferFormat &bufferFormat, uint8 &channels, uint8 &bitsPerSample, uint32 &frequency); /// Write a wav file. Data type uint8 does not imply a buffer of any format. @@ -138,20 +137,20 @@ public: /// Convert 16bit Mono PCM buffer data to ADPCM. static bool convertMono16PCMToMonoADPCM(const sint16 *buffer, uint samples, std::vector &result); //@} - + private: static const sint _IndexTable[16]; static const uint _StepsizeTable[89]; //@} - + protected: /// Constructor IBuffer() { } - + public: /// Destructor virtual ~IBuffer() { } - + }; } // NLSOUND diff --git a/code/nel/include/nel/sound/driver/sound_driver.h b/code/nel/include/nel/sound/driver/sound_driver.h index e38126fff..f8abfe75b 100644 --- a/code/nel/include/nel/sound/driver/sound_driver.h +++ b/code/nel/include/nel/sound/driver/sound_driver.h @@ -64,16 +64,12 @@ public: /// Driver Creation Choice enum TDriver { - /// DriverAuto automatically picks the most awesome driver (picks first available in this order: FMod, OpenAl, XAudio2, DSound). + /// DriverAuto automatically picks the most awesome driver (picks first available in this order: FMod, OpenAl). DriverAuto = 0, /// DriverFMod is a driver that runs on FMod, nice quality, but not fully implemented. DriverFMod, /// DriverOpenAl is the recommended driver, especially if you have hardware sound acceleration. DriverOpenAl, - /// DriverDSound is deprecated. - DriverDSound, - /// DriverXAudio2 runs on a fully software-based audio processing API without artificial limits. - DriverXAudio2, NumDrivers }; @@ -81,25 +77,25 @@ public: enum TSoundOptions { /// Enable EAX/I3DL2 environment effects. (not implemented on FMod driver). - OptionEnvironmentEffects = 0x01, + OptionEnvironmentEffects = 0x01, /// Allow the user to use the ADPCM encoding. (verify availability with getOption) - OptionAllowADPCM = 0x02, - /// Force software buffering (always true for XAudio2). - OptionSoftwareBuffer = 0x04, + OptionAllowADPCM = 0x02, + /// Force software buffering. + OptionSoftwareBuffer = 0x04, /** - * Configuration to use manual or API (directx or open AL) rolloff factor. - * 0 => API (directx, open AL, etc) rollOff control. + * Configuration to use manual or API (open AL) rolloff factor. + * 0 => API (open AL, etc) rollOff control. * ISource::setAlpha() will fail. * IListener::setRollOffFactor() works * 1 => Manual rollOff control * ISource::setAlpha() change the shape of attenuation (change the curve) * IListener::setRollOffFactor() will fail */ - OptionManualRolloff = 0x08, + OptionManualRolloff = 0x08, /// Enable local copy of buffer (used by OpenAL driver, required to build sample bank). - OptionLocalBufferCopy = 0x10, + OptionLocalBufferCopy = 0x10, /// Use to check availability of buffer streaming. (verify with getOption) - OptionHasBufferStreaming = 0x20, + OptionHasBufferStreaming = 0x20, }; /** The interface must be implemented and provided to the driver @@ -137,7 +133,7 @@ public: /// Return a list of available devices for the user. The value at index 0 is empty, and is used for automatic device selection. virtual void getDevices(std::vector &devices) = 0; - /** Initialize the driver with a user selected device. + /** Initialize the driver with a user selected device. * In case of failure, can throw one of these ESoundDriver exception objects: * ESoundDriverNotFound, ESoundDriverCorrupted, ESoundDriverOldVersion, ESoundDriverUnknownVersion * The driver instance should be deleted by the user after init failure. @@ -171,10 +167,10 @@ public: virtual uint countMaxSources() = 0; /// Return the maximum number of effects that can be created virtual uint countMaxEffects() { return 0; } - + /// Write information about the driver to the output stream. virtual void writeProfile(std::string& out) = 0; - + /// Stuff virtual void startBench() = 0; virtual void endBench() = 0; @@ -182,7 +178,7 @@ public: /// Filled at createDriver() const std::string &getDllName() const { return _DllName; } - + /// \name Stuff for drivers that have native music support //@{ /// Create a native music channel, only supported by the FMod driver. @@ -198,10 +194,10 @@ public: /// Return if a music extension is supported by the driver's music channel. virtual bool isMusicExtensionSupported(const std::string &extension) const = 0; //@} - + private: std::string _DllName; - + }; diff --git a/code/nel/include/nel/sound/driver/source.h b/code/nel/include/nel/sound/driver/source.h index d2f4a5186..3112bc3f3 100644 --- a/code/nel/include/nel/sound/driver/source.h +++ b/code/nel/include/nel/sound/driver/source.h @@ -33,7 +33,7 @@ #include "sound_driver.h" -/** +/** * The minimum allowed gain is specified as 0.0f. * Inverting the wave by specifying a negative gain is not allowed. * \brief Minimum allowed gain (volume). @@ -41,7 +41,7 @@ #define NLSOUND_MIN_GAIN 0.0f /** * The maximum allowed gain is specified as 1.0f. - * OpenAL implementations may or may not clamp the gain to a maximum + * OpenAL implementations may or may not clamp the gain to a maximum * of 1.0f, so this maximum is forced on all implementations. * If you pass a value outside the minimum and maximum bounds, * it will automatically be clamped between them. @@ -58,10 +58,8 @@ #define NLSOUND_MIN_PITCH 0.0f /** * The maximum allowed pitch is specified as 8.0f. - * Tests indicate that with OpenAL the pitch can be set to 8.0f, - * and with FMod to somewhere around 9.0f. The XAudio2 implementation - * uses this value directly to configure the maximum pitch, which can - * technically be as high as XAUDIO2_MAX_FREQ_RATIO which is 1024.0f. + * Tests indicate that with OpenAL the pitch can be set to 8.0f, + * and with FMod to somewhere around 9.0f. * If you pass a value outside the minimum and maximum bounds, * it will automatically be clamped between them. * \brief Maximum allowed pitch. @@ -123,8 +121,8 @@ namespace NLSOUND { /** * Sound source interface (implemented in sound driver dynamic library) - * - * - If the buffer is mono, the source is played in 3D mode. For + * + * - If the buffer is mono, the source is played in 3D mode. For * arguments as 3D vectors, use the NeL vector coordinate system: \verbatim (top) @@ -136,7 +134,7 @@ namespace NLSOUND { * * - If the buffer is multi-channel, only distance rolloff is applied. * - All streaming related functionalities are thread-safe. - * + * * \author Olivier Cado * \author Nevrax France * \author Jan Boon (Kaetemi) @@ -148,70 +146,70 @@ class ISource public: enum TFilter { - FilterLowPass, - FilterBandPass, - FilterHighPass, + FilterLowPass, + FilterBandPass, + FilterHighPass, }; - + /// Constructor ISource() { } /// Destructor virtual ~ISource() { } - + /// \name Initialization //@{ /** - * This function is used to switch between streaming and static + * This function is used to switch between streaming and static * buffer modes. By default, streaming mode is off. - * Streaming mode must be enabled before calling functions - * related to buffer streaming, such as 'submitStreamingBuffer' + * Streaming mode must be enabled before calling functions + * related to buffer streaming, such as 'submitStreamingBuffer' * and 'countStreamingBuffers'. - * In the default static buffer mode, only one buffer is set - * active on this source, and can be replayed or looped as many + * In the default static buffer mode, only one buffer is set + * active on this source, and can be replayed or looped as many * times as needed. * When in streaming mode, multiple buffers are chained after each - * other, and you must make sure that the source does not run out + * other, and you must make sure that the source does not run out * of data, to avoid sound stopping glitches. - * The source must be stopped before trying to change the mode, + * The source must be stopped before trying to change the mode, * if a static buffer was set it must be detached as well. * \brief Switch between streaming and static buffer modes. - * \param streaming Set to true to enable streaming mode, or + * \param streaming Set to true to enable streaming mode, or * false to use static buffers. If you omit this parameter, it * will be set as true, and streaming will be enabled. */ virtual void setStreaming(bool streaming = true) = 0; /** * Sets the buffer that is used for playback by this source. - * The static buffer will remain active on the source until - * this function is called with a NULL parameter, or until the - * mode is changed to streaming. It is possible to play or loop - * this buffer as often as needed, as long as it is attached + * The static buffer will remain active on the source until + * this function is called with a NULL parameter, or until the + * mode is changed to streaming. It is possible to play or loop + * this buffer as often as needed, as long as it is attached * to this source. - * If you attach a multichannel (stereo) buffer, the source will - * automatically be set to relative mode. Setting a mono channel + * If you attach a multichannel (stereo) buffer, the source will + * automatically be set to relative mode. Setting a mono channel * buffer will automatically set the relative mode back to it's - * original setting. It is not possible to enable relative mode - * with a multichannel buffer, instead you must manually split + * original setting. It is not possible to enable relative mode + * with a multichannel buffer, instead you must manually split * the sound data into multiple channels and use multiple sources. - * You cannot use this function in streaming mode, where you must + * You cannot use this function in streaming mode, where you must * use submitStreamingBuffer() instead. * A buffer can be attached to more than once source. - * Before destroying a buffer, it must be detached from all - * sources it's attached to, which can be done by calling this + * Before destroying a buffer, it must be detached from all + * sources it's attached to, which can be done by calling this * function with a NULL parameter as buffer on all relevant sources. * If you set the buffer while the source is already playing or in - * paused status, this function does nothing. You must stop() the + * paused status, this function does nothing. You must stop() the * source, or wait until it isStopped() before changing the buffer. * \brief Attach a buffer to this source. - * \param buffer The buffer to be attached on this source. It must - * be created on the same sound driver instance as this source. Set + * \param buffer The buffer to be attached on this source. It must + * be created on the same sound driver instance as this source. Set * this parameter to NULL to detach a previously set buffer. */ virtual void setStaticBuffer(IBuffer *buffer) = 0; /** - * Returns the buffer that was attached to this source. A buffer + * Returns the buffer that was attached to this source. A buffer * can by attached to this source by calling setStaticBuffer(). - * If no static buffer is set, or if the source is in streaming + * If no static buffer is set, or if the source is in streaming * mode, this function will return NULL. * \brief Get the buffer that is attached to this source. * \return A pointer to the attached IBuffer, or NULL if none. @@ -222,16 +220,16 @@ public: virtual void submitStreamingBuffer(IBuffer *buffer) = 0; /** * Returns the amount of buffers that are currently in the queue. - * This includes buffers that are waiting to be played, as well as - * the buffer that is currently playing. Buffers that have finished - * playing are removed from the queue, and do not count towards the + * This includes buffers that are waiting to be played, as well as + * the buffer that is currently playing. Buffers that have finished + * playing are removed from the queue, and do not count towards the * result of this function. - * It is recommended to have at least 2 or 3 buffers queued up when + * It is recommended to have at least 2 or 3 buffers queued up when * streaming, to avoid sound stopping glitches. - * If you need to know the total amount of buffers that were added - * into the queue, you should count them manually by increasing a + * If you need to know the total amount of buffers that were added + * into the queue, you should count them manually by increasing a * value each time 'submitStreamingBuffer' is called. - * This function always returns 0 when the source is in static + * This function always returns 0 when the source is in static * mode, when the source is stopped, or when no buffers have been * added yet into the queue. * \brief Get the number of buffers in the streaming queue. @@ -239,100 +237,100 @@ public: */ virtual uint countStreamingBuffers() const = 0; //@} - + /// \name Playback control //@{ /** * This function is used to enable or disable looping this source. - * By default, looping is off. The current looping status can be + * By default, looping is off. The current looping status can be * obtained by calling getLooping(). - * It is possible to call this function either before the source + * It is possible to call this function either before the source * has started playing, or while it is already playing. - * To cleanly exit a loop, you can call setLooping(false) instead - * of using stop(). Calling stop() on a source that is looping will + * To cleanly exit a loop, you can call setLooping(false) instead + * of using stop(). Calling stop() on a source that is looping will * immediately stop the source, which may suffer sound clicks. - * The looping state is useful on static buffers only. Setting this + * The looping state is useful on static buffers only. Setting this * while in streaming mode will have no effect, however, the loop * setting will be remembered when switching back to static mode. * \brief Enable or disable looping this source. - * \param l Set to true to enable, false to disable looping or to + * \param l Set to true to enable, false to disable looping or to * exit the current loop. */ virtual void setLooping(bool l = true) = 0; /** * Returns the looping status that was last set by setLooping(). * This function will always return the last set looping option. - * If you call this while in streaming mode, the result will be the + * If you call this while in streaming mode, the result will be the * setting that will be used when you go back to static buffer mode. * Looping has no effect on streaming. * \brief Get the currently set looping status. * \return Returns true if looping is enabled, false if disabled. */ virtual bool getLooping() const = 0; - + /** - * This function is used to enter playing mode. It will return - * true in case of success. The playing status can also be verified + * This function is used to enter playing mode. It will return + * true in case of success. The playing status can also be verified * by calling isPlaying() on this source. - * If the source is stopped, or has not started playing yet, the - * source will start playing from the beginning from the currently - * attached static buffer when in static mode. If no static buffer - * was set, the source will remain in stopped mode, and this - * will return false. A buffer can be attached to this source by + * If the source is stopped, or has not started playing yet, the + * source will start playing from the beginning from the currently + * attached static buffer when in static mode. If no static buffer + * was set, the source will remain in stopped mode, and this + * will return false. A buffer can be attached to this source by * calling the setStaticBuffer() method. - * When the source is stopped and in streaming mode, this function - * will always enter playing state. If no buffers were queued yet, - * it will effectively start playing this source once the first - * buffer has been submitted. It is recommended to queue up the - * first few buffers before calling play() to avoid running out of - * buffers early. In streaming mode, buffers can be submitted to + * When the source is stopped and in streaming mode, this function + * will always enter playing state. If no buffers were queued yet, + * it will effectively start playing this source once the first + * buffer has been submitted. It is recommended to queue up the + * first few buffers before calling play() to avoid running out of + * buffers early. In streaming mode, buffers can be submitted to * the queue by calling the submitStreamingBuffer() method. - * If the source is in paused mode, it will simply resume. - * In case it was already in playing mode, the source will be - * automatically stopped before re-entering playing status. In - * static buffer mode this is essentially the same as restarting - * the source from the beginning, while doing this in streaming + * If the source is in paused mode, it will simply resume. + * In case it was already in playing mode, the source will be + * automatically stopped before re-entering playing status. In + * static buffer mode this is essentially the same as restarting + * the source from the beginning, while doing this in streaming * mode will result in the streaming queue being cleared. * \brief Start or resume playback. * \return Returns true in case of success. */ virtual bool play() = 0; /** - * This function stops playing the source immediately. If the - * source is already stopped, it does nothing. If the source was + * This function stops playing the source immediately. If the + * source is already stopped, it does nothing. If the source was * paused, this will do the same as if it was playing. - * When the source is in static mode, the attached buffer will - * remain attached for later usage. To exit a loop, it is - * recommended to call setLooping(false) instead of stop(), - * to avoid sound clicks. The source will enter stopped state + * When the source is in static mode, the attached buffer will + * remain attached for later usage. To exit a loop, it is + * recommended to call setLooping(false) instead of stop(), + * to avoid sound clicks. The source will enter stopped state * automatically when it has finished playing. - * If this source uses streaming buffers, calling this function - * will immediately stop output, and clear the buffer queue, which + * If this source uses streaming buffers, calling this function + * will immediately stop output, and clear the buffer queue, which * means that any queued buffers that have not played yet are lost. * \brief Stop playback. */ virtual void stop() = 0; /** - * This function pauses playback of this source at it's current - * position. If the source is stopped or already paused, this - * function does nothing. You can verify if the source is paused + * This function pauses playback of this source at it's current + * position. If the source is stopped or already paused, this + * function does nothing. You can verify if the source is paused * by calling isPaused(). To resume playback, you must call play(). * \brief Pause playback. */ virtual void pause() = 0; /** * Returns if the source is currently playing. - * In streaming mode this will return true, even if no buffers are + * In streaming mode this will return true, even if no buffers are * available for playback when in playing status. - * This will also return true if the source is paused. To know if + * This will also return true if the source is paused. To know if * the source has been paused, use isPaused(). * \brief Get the playing state. * \return Returns the playing state. */ virtual bool isPlaying() const = 0; /** - * Returns true if the source has not started playing yet, when it - * has been stopped using the stop() method, or when the static + * Returns true if the source has not started playing yet, when it + * has been stopped using the stop() method, or when the static * buffer has finished playback. * If the source is playing or paused, this returns false. * \brief Get the stopped state. @@ -341,36 +339,36 @@ public: virtual bool isStopped() const = 0; /** * Returns true if the source has been paused by calling pause(). - * If the source is playing, stopped, or has finished playback + * If the source is playing, stopped, or has finished playback * this returns false. * \brief Get the paused state. * \return Returns the paused state. */ virtual bool isPaused() const = 0; /** - * Returns the number of milliseconds the current static buffer or + * Returns the number of milliseconds the current static buffer or * streaming queue has effectively been playing. - * In streaming mode, the time spent during buffer outruns is not - * counted towards the playback time, and the playback time is + * In streaming mode, the time spent during buffer outruns is not + * counted towards the playback time, and the playback time is * be the current time position in the entire submitted queue. - * When using static buffers, the result is the total time that the - * attached buffer has been playing. If the source is looping, the + * When using static buffers, the result is the total time that the + * attached buffer has been playing. If the source is looping, the * time will be the total of all playbacks of the buffer. - * When the source is stopped, this will return the time where the - * source was stopped. The value is reset to 0 when re-entering + * When the source is stopped, this will return the time where the + * source was stopped. The value is reset to 0 when re-entering * playing status. - * A buffer that is played at a higher pitch will result in a lower - * playback time. The result is not the buffer's playback position, + * A buffer that is played at a higher pitch will result in a lower + * playback time. The result is not the buffer's playback position, * but the actual time that has passed playing. - * It is not guaranteed that this function returns an accurate - * value, or that it even works. If it is not implemented, the result + * It is not guaranteed that this function returns an accurate + * value, or that it even works. If it is not implemented, the result * will always be 0. * \brief Get the current playback time in milliseconds. * \return Returns the current playback time in milliseconds. */ virtual uint32 getTime() = 0; //@} - + /// \name Source properties //@{ /// Set the position vector (default: (0,0,0)). @@ -405,29 +403,29 @@ public: virtual void setCone(float innerAngle, float outerAngle, float outerGain) = 0; /// Get the cone angles (in radian) virtual void getCone(float& innerAngle, float& outerAngle, float& outerGain) const = 0; - /** + /** * Set the alpha value for the volume-distance curve. - * + * * Used only with OptionManualRolloff. * Value ranges from -1.0 to 1.0, the default is 0.0. - * - * - alpha = 0.0: The volume will decrease linearly between 0dB + * + * - alpha = 0.0: The volume will decrease linearly between 0dB * and -100 dB. - * - alpha = 1.0: The volume will decrease linearly between 1.0f + * - alpha = 1.0: The volume will decrease linearly between 1.0f * and 0.0f (linear scale). - * - alpha = -1.0: The volume will decrease inversely with the - * distance (1/dist). This is the default distance attenuation + * - alpha = -1.0: The volume will decrease inversely with the + * distance (1/dist). This is the default distance attenuation * used without OptionManualRolloff. - * - * For any other value of alpha, an interpolation is be done - * between the two adjacent curves. For example, if alpha equals - * 0.5, the volume will be halfway between the linear dB curve and + * + * For any other value of alpha, an interpolation is be done + * between the two adjacent curves. For example, if alpha equals + * 0.5, the volume will be halfway between the linear dB curve and * the linear amplitude curve. * \brief Set the alpha value for the volume-distance curve */ virtual void setAlpha(double a) = 0; //@} - + /// \name Direct output //@{ /// Enable or disable direct output [true/false], default: true @@ -438,7 +436,7 @@ public: virtual void setDirectGain(float gain = NLSOUND_DEFAULT_DIRECT_GAIN) = 0; /// Get the gain for the direct path virtual float getDirectGain() const = 0; - + /// Enable or disable the filter for the direct channel virtual void enableDirectFilter(bool enable = true) = 0; /// Check if the filter on the direct channel is enabled @@ -452,7 +450,7 @@ public: /// Get the direct filter gain virtual float getDirectFilterPassGain() const = 0; //@} - + /// \name Effect output //@{ /// Set the effect send for this source, NULL to disable. [IEffect], default: NULL @@ -463,7 +461,7 @@ public: virtual void setEffectGain(float gain = NLSOUND_DEFAULT_EFFECT_GAIN) = 0; /// Get the gain for the effect path virtual float getEffectGain() const = 0; - + /// Enable or disable the filter for the effect channel virtual void enableEffectFilter(bool enable = true) = 0; /// Check if the filter on the effect channel is enabled @@ -477,9 +475,9 @@ public: /// Get the effect filter gain virtual float getEffectFilterPassGain() const = 0; //@} - + protected: - + // common method used only with OptionManualRolloff. return the volume in 1/100th DB ( = mB)modified static sint32 computeManualRollOff(sint32 volumeMB, sint32 mbMin, sint32 mbMax, double alpha, float sqrdist, float distMin, float distMax); // common method used only with OptionManualRolloff. return the rolloff in amplitude ratio (gain) diff --git a/code/nel/include/nel/sound/u_audio_mixer.h b/code/nel/include/nel/sound/u_audio_mixer.h index c3059152c..b29bdd143 100644 --- a/code/nel/include/nel/sound/u_audio_mixer.h +++ b/code/nel/include/nel/sound/u_audio_mixer.h @@ -82,8 +82,6 @@ public: DriverAuto = 0, DriverFMod, DriverOpenAl, - DriverDSound, - DriverXAudio2, NumDrivers }; @@ -124,42 +122,42 @@ public: } } }; - + /// Initialization information for the audio mixer. Use instead of the long parametered init function for readability. *** Subject to change. *** struct CInitInfo { public: - CInitInfo() - : MaxTrack(32), - EnableReverb(false), - EnableOccludeObstruct(false), - UseADPCM(false), - ForceSoftware(false), + CInitInfo() + : MaxTrack(32), + EnableReverb(false), + EnableOccludeObstruct(false), + UseADPCM(false), + ForceSoftware(false), ManualRolloff(true) { } /// The number of allocated physical playback tracks. Default: 32. uint MaxTrack; - + /// Enable environment reverberation effect. Default: false. bool EnableReverb; /// Enable occlusion and obstruction lowpass filters from walls and objects. Default: false. bool EnableOccludeObstruct; - + /// Use lower quality ADPCM encoded sources for lower memory usage. Default: false. bool UseADPCM; /// Force using a software sound device. Default: false. [KAETEMI TODO: Allow sound device selection.] bool ForceSoftware; - + /// Use NeL's distance rolloff math. Default: true. bool ManualRolloff; /// I forgot what this does, but it's fairly important. bool AutoLoadSample; }; - + //@{ //@name Init methods /// Create the audio mixer singleton and return a pointer to its instance @@ -175,7 +173,7 @@ public: * mixer config file, you MUST set the sample path * BEFORE calling init. */ - + virtual void setSamplePath(const std::string& path) = 0; /** Set the global path to the sample banks * If you have specified some sample bank to load in the @@ -199,17 +197,17 @@ public: * deactivated. (lies!) * autoLoadSample is used for tools like georges or object viewer where you don't bother to * specify each sample bank to load, you just want to ear the sound. - * + * * Deprecated by initDriver/getDevices/initDevice. - * + * * \param forceSoftware: to force the driver to load in software buffer, not hardware */ virtual void init(uint maxTrack = 32, bool useEax = true, bool useADPCM = true, NLMISC::IProgressCallback *progressCallBack = NULL, bool autoLoadSample = false, TDriver driverType = DriverAuto, bool forceSoftware = false, bool manualRolloff = true) = 0; - + /// Initialize the NeL Sound Driver with given driverName. virtual void initDriver(const std::string &driverName) = 0; /// Get the available devices on the loaded driver. - virtual void getDevices(std::vector &devices) = 0; + virtual void getDevices(std::vector &devices) = 0; /// Initialize the selected device on the currently initialized driver. Leave deviceName empty to select the default device. virtual void initDevice(const std::string &deviceName, const CInitInfo &initInfo, NLMISC::IProgressCallback *progressCallback = NULL) = 0; @@ -451,7 +449,7 @@ public: virtual void setEventMusicVolume(float gain) =0; /** true if the event music is ended */ - virtual bool isEventMusicEnded() =0; + virtual bool isEventMusicEnded() =0; /// Get audio/container extensions that are currently supported by nel or the used driver implementation. virtual void getMusicExtensions(std::vector &extensions) = 0; //@} diff --git a/code/nel/samples/3d/cegui/main.cpp b/code/nel/samples/3d/cegui/main.cpp index eda1ac666..897adc81e 100644 --- a/code/nel/samples/3d/cegui/main.cpp +++ b/code/nel/samples/3d/cegui/main.cpp @@ -77,9 +77,9 @@ bool handleCheck(const CEGUI::EventArgs& e); #endif // CEGUI_DATA_DIR #ifdef NL_OS_WINDOWS -int WINAPI WinMain( HINSTANCE hInstance, - HINSTANCE hPrevInstance, - LPSTR lpCmdLine, +int WINAPI WinMain( HINSTANCE hInstance, + HINSTANCE hPrevInstance, + LPSTR lpCmdLine, int nCmdShow ) { ghInstance = hInstance; #else @@ -100,7 +100,7 @@ int main(int argc, char **argv) NELRENDERER_CREATE_PROC createNelRenderer = reinterpret_cast(driverLib.getSymbolAddress(NELRENDERER_CREATE_PROC_NAME)); // CCeguiRendererNelLibrary *nelCeguiDriverLib = dynamic_cast(driverLib.getNelLibraryInterface()); - + NL3D::UDriver *driver; // Create a driver @@ -108,9 +108,8 @@ int main(int argc, char **argv) #ifdef NL_OS_WINDOWS icon = (uint)LoadIcon(ghInstance,MAKEINTRESOURCE(IDI_ICON1)); #endif - bool useD3D = false; #ifdef NL_INDEX_BUFFER_H //new 3d - NL3D::UDriver *driver = NL3D::UDriver::createDriver(icon,useD3D); + NL3D::UDriver *driver = NL3D::UDriver::createDriver(icon); #else driver = NL3D::UDriver::createDriver(icon); #endif @@ -123,7 +122,7 @@ int main(int argc, char **argv) // start up the Gui system. //gGuiLogger = nelCeguiDriverLib->createNelLogger(); //gGuiRenderer = new CEGUI::NeLRenderer(driver); - + gGuiRenderer = createNelRenderer(driver, true); gGuiSystem = new CEGUI::System(gGuiRenderer); CEGUI::NeLRenderer *rndr = (CEGUI::NeLRenderer *)gGuiRenderer; @@ -134,7 +133,7 @@ int main(int argc, char **argv) nlinfo("Start up and configure the GUI system."); try { using namespace CEGUI; - + Logger::getSingleton().setLoggingLevel(Insane); // load scheme and set up defaults @@ -328,5 +327,3 @@ bool handleCheck(const CEGUI::EventArgs& e) return true; } - - diff --git a/code/nel/samples/3d/font/main.cpp b/code/nel/samples/3d/font/main.cpp index bd1a91a09..3cbfdb24a 100644 --- a/code/nel/samples/3d/font/main.cpp +++ b/code/nel/samples/3d/font/main.cpp @@ -54,7 +54,7 @@ int main(int argc, char **argv) #endif { // look at 3dinit example - CNELU::init (800, 600, CViewport(), 32, true, 0, false, false); + CNELU::init (800, 600, CViewport(), 32, true, 0, false); NLMISC::CPath::addSearchPath(FONT_DIR); diff --git a/code/nel/samples/3d/nel_qt/graphics_viewport.cpp b/code/nel/samples/3d/nel_qt/graphics_viewport.cpp index 611e0d440..30ca5d645 100644 --- a/code/nel/samples/3d/nel_qt/graphics_viewport.cpp +++ b/code/nel/samples/3d/nel_qt/graphics_viewport.cpp @@ -51,18 +51,18 @@ QString nli18n(const char *label) } /* anonymous namespace */ -CGraphicsViewport::CGraphicsViewport(QWidget *parent) +CGraphicsViewport::CGraphicsViewport(QWidget *parent) : QWidget(parent), - m_GraphicsConfig(NULL), - m_Driver(NULL), + m_GraphicsConfig(NULL), + m_Driver(NULL), m_TextContext(NULL) { - + } CGraphicsViewport::~CGraphicsViewport() { - + } void CGraphicsViewport::init(CGraphicsConfig *graphicsConfig) @@ -72,44 +72,35 @@ void CGraphicsViewport::init(CGraphicsConfig *graphicsConfig) // copy parameters m_GraphicsConfig = graphicsConfig; - + // check stuff we need nlassert(m_GraphicsConfig); // create the driver nlassert(!m_Driver); - m_Direct3D = false; std::string driver = m_GraphicsConfig->getGraphicsDriver(); - if (driver == "Direct3D") m_Direct3D = true; //m_Driver = Direct3D; - else if (driver == "OpenGL") m_Direct3D = false; //m_Driver = OpenGL; - else - { - nlwarning("Invalid driver specified, defaulting to OpenGL"); - //m_Configuration->getConfigFile().getVar("GraphicsDriver").forceAsString("OpenGL"); - //m_Driver = OpenGL; - } - m_Driver = UDriver::createDriver(NULL, m_Direct3D, NULL); + m_Driver = UDriver::createDriver(NULL, NULL); nlassert(m_Driver); // initialize the window with config file values m_Driver->setDisplay(winId(), NL3D::UDriver::CMode(width(), height(), 32)); // register config callbacks - connect(m_GraphicsConfig, SIGNAL(onBackgroundColor(NLMISC::CRGBA)), + connect(m_GraphicsConfig, SIGNAL(onBackgroundColor(NLMISC::CRGBA)), this, SLOT(cfcbBackgroundColor(NLMISC::CRGBA))); m_BackgroundColor = m_GraphicsConfig->getBackgroundColor(); // set the cache size for the font manager(in bytes) m_Driver->setFontManagerMaxMemory(2097152); - + // create the text context nlassert(!m_TextContext); m_TextContext = m_Driver->createTextContext(CPath::lookup( m_GraphicsConfig->getFontName())); nlassert(m_TextContext); - connect(m_GraphicsConfig, SIGNAL(onFontShadow(bool)), + connect(m_GraphicsConfig, SIGNAL(onFontShadow(bool)), this, SLOT(cfcbFontShadow(bool))); - m_TextContext->setShaded(m_GraphicsConfig->getFontShadow()); + m_TextContext->setShaded(m_GraphicsConfig->getFontShadow()); } void CGraphicsViewport::release() @@ -119,14 +110,14 @@ void CGraphicsViewport::release() // release text context nlassert(m_TextContext); - disconnect(m_GraphicsConfig, SIGNAL(onFontShadow(bool)), + disconnect(m_GraphicsConfig, SIGNAL(onFontShadow(bool)), this, SLOT(cfcbFontShadow(bool))); m_Driver->deleteTextContext(m_TextContext); m_TextContext = NULL; // release driver nlassert(m_Driver); - disconnect(m_GraphicsConfig, SIGNAL(onBackgroundColor(NLMISC::CRGBA)), + disconnect(m_GraphicsConfig, SIGNAL(onBackgroundColor(NLMISC::CRGBA)), this, SLOT(cfcbBackgroundColor(NLMISC::CRGBA))); m_Driver->release(); delete m_Driver; @@ -185,7 +176,7 @@ void CGraphicsViewport::saveScreenshot(const string &name, bool jpg, bool png, b //H_AUTO2 // FIXME: create screenshot path if it doesn't exist! - + // empty bitmap CBitmap bitmap; // copy the driver buffer to the bitmap @@ -221,13 +212,12 @@ void CGraphicsViewport::saveScreenshot(const string &name, bool jpg, bool png, b void CGraphicsViewport::resizeEvent(QResizeEvent *resizeEvent) { QWidget::resizeEvent(resizeEvent); - if (m_Driver && !m_Direct3D) + if (m_Driver) { m_Driver->setMode(UDriver::CMode(resizeEvent->size().width(), resizeEvent->size().height(), 32)); } // The OpenGL driver does not resize automatically. - // The Direct3D driver breaks the window mode to include window borders when calling setMode windowed. // Resizing the window after switching drivers a few times becomes slow. // There is probably something inside the drivers not being released properly. diff --git a/code/nel/samples/3d/nel_qt/graphics_viewport.h b/code/nel/samples/3d/nel_qt/graphics_viewport.h index 0b9dde03a..040be0db3 100644 --- a/code/nel/samples/3d/nel_qt/graphics_viewport.h +++ b/code/nel/samples/3d/nel_qt/graphics_viewport.h @@ -72,7 +72,7 @@ public: inline NL3D::UTextContext *getTextContext() { return m_TextContext; } inline NL3D::UScene *getScene() { return m_Scene; } -public slots: +public slots: void saveScreenshot(); private slots: @@ -91,12 +91,10 @@ private: NL3D::UTextContext *m_TextContext; NL3D::UScene *m_Scene; - bool m_Direct3D; - private: CGraphicsViewport(const CGraphicsViewport &); CGraphicsViewport &operator=(const CGraphicsViewport &); - + }; /* class CGraphicsViewport */ } /* namespace NLQT */ diff --git a/code/nel/samples/3d/nel_qt/nel_qt_default.cfg b/code/nel/samples/3d/nel_qt/nel_qt_default.cfg index f8fd47131..a08854cff 100644 --- a/code/nel/samples/3d/nel_qt/nel_qt_default.cfg +++ b/code/nel/samples/3d/nel_qt/nel_qt_default.cfg @@ -55,9 +55,9 @@ LoginBackground = "login_background.dds"; // Graphics ////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////// -// Use OpenGL or Direct3D (Windows) +// Use OpenGL (Windows) GraphicsEnabled = 1; -GraphicsDrivers = { "OpenGL", "Direct3D" }; +GraphicsDrivers = { "OpenGL" }; GraphicsDriver = "OpenGL"; // Resolution of the screen @@ -134,9 +134,9 @@ FpsSmoothing = 64; // Sound ///////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////// -// The sound driver, choose between "Auto", "FMod", "DSound" and "OpenAl" +// The sound driver, choose between "Auto", "FMod" and "OpenAl" SoundEnabled = 1; -SoundDrivers = { "Auto", "OpenAL", "XAudio2", "FMod", "DSound" }; +SoundDrivers = { "Auto", "OpenAL", "FMod" }; SoundDriver = "OpenAL"; SoundDevice = ""; SoundMaxTrack = 48; @@ -153,46 +153,46 @@ SoundAutoLoadSample = 1; ////////////////////////////////////////////////////////////////////////////// // This setting is used to bind keys to actions. -// "key_handler", "args", "***", "Key1|Key2", +// "key_handler", "args", "***", "Key1|Key2", // *** -> CTRL, SHIFT, ALT don't matter // --- -> CTRL, SHIFT, ALT must all be disabled // -+- -> only SHIFT must be down KeySettings = { - "screenshot", "", "***", "KeyF5", - "command", "set_state Exit", "-+-", "KeyESCAPE", - "command", "set_state Login", "+--", "KeyESCAPE", - "command", "set_state Unload", "***", "KeyF8", - "command", "set_state Demo", "***", "KeyF7", - "move_forward", "", "***", "KeyUP|KeyZ|KeyW", - "move_backward", "", "***", "KeyDOWN|KeyS", - "move_left", "", "***", "KeyLEFT|KeyQ|KeyA", - "move_right", "", "***", "KeyRIGHT|KeyD", - "move_forward", "", "***", "KeyZ|KeyW", - "move_backward", "", "***", "KeyS", - "move_left", "", "***", "KeyQ|KeyA", - "move_right", "", "***", "KeyD", - "chat_begin", "", "***", "KeyT", - "chat_send", "", "***", "KeyENTER", - "chat_leave", "", "***", "KeyESCAPE", - "display_test", "", "***", "KeyTAB", - "send_action", "0", "---", "Key1", - "send_action", "1", "---", "Key2", - "send_action", "2", "---", "Key3", - "send_action", "3", "---", "Key4", - "send_action", "4", "---", "Key5", - "send_action", "5", "---", "Key6", - "send_action", "6", "---", "Key7", - "send_action", "7", "---", "Key8", - "send_action", "8", "---", "Key9", - "send_action", "9", "---", "Key0", - "demo_crystal_spawn", "", "---", "KeyO", - "demo_crystal_explode", "", "---", "KeyP", - "free_camera_forward", "", "---", "KeyNUMPAD8", - "free_camera_backward", "", "---", "KeyNUMPAD2", - "free_camera_left", "", "---", "KeyNUMPAD4", - "free_camera_right", "", "---", "KeyNUMPAD6", - "switch_camera", "", "---", "KeyF4", - "switch_ui_visible" ,"", "---", "KeyF6", + "screenshot", "", "***", "KeyF5", + "command", "set_state Exit", "-+-", "KeyESCAPE", + "command", "set_state Login", "+--", "KeyESCAPE", + "command", "set_state Unload", "***", "KeyF8", + "command", "set_state Demo", "***", "KeyF7", + "move_forward", "", "***", "KeyUP|KeyZ|KeyW", + "move_backward", "", "***", "KeyDOWN|KeyS", + "move_left", "", "***", "KeyLEFT|KeyQ|KeyA", + "move_right", "", "***", "KeyRIGHT|KeyD", + "move_forward", "", "***", "KeyZ|KeyW", + "move_backward", "", "***", "KeyS", + "move_left", "", "***", "KeyQ|KeyA", + "move_right", "", "***", "KeyD", + "chat_begin", "", "***", "KeyT", + "chat_send", "", "***", "KeyENTER", + "chat_leave", "", "***", "KeyESCAPE", + "display_test", "", "***", "KeyTAB", + "send_action", "0", "---", "Key1", + "send_action", "1", "---", "Key2", + "send_action", "2", "---", "Key3", + "send_action", "3", "---", "Key4", + "send_action", "4", "---", "Key5", + "send_action", "5", "---", "Key6", + "send_action", "6", "---", "Key7", + "send_action", "7", "---", "Key8", + "send_action", "8", "---", "Key9", + "send_action", "9", "---", "Key0", + "demo_crystal_spawn", "", "---", "KeyO", + "demo_crystal_explode", "", "---", "KeyP", + "free_camera_forward", "", "---", "KeyNUMPAD8", + "free_camera_backward", "", "---", "KeyNUMPAD2", + "free_camera_left", "", "---", "KeyNUMPAD4", + "free_camera_right", "", "---", "KeyNUMPAD6", + "switch_camera", "", "---", "KeyF4", + "switch_ui_visible" ,"", "---", "KeyF6", }; diff --git a/code/nel/samples/sound/sound_sources/main.cpp b/code/nel/samples/sound/sound_sources/main.cpp index 75f732b5a..49e171a67 100644 --- a/code/nel/samples/sound/sound_sources/main.cpp +++ b/code/nel/samples/sound/sound_sources/main.cpp @@ -67,8 +67,6 @@ void Init() printf("Select NLSOUND Driver:\n"); printf(" [1] FMod\n"); printf(" [2] OpenAl\n"); - printf(" [3] DSound\n"); - printf(" [4] XAudio2\n"); printf("> "); int selection = getchar(); printf("\n"); diff --git a/code/nel/samples/sound/stream_file/stream_file.cpp b/code/nel/samples/sound/stream_file/stream_file.cpp index 6362a0414..ee1968a24 100644 --- a/code/nel/samples/sound/stream_file/stream_file.cpp +++ b/code/nel/samples/sound/stream_file/stream_file.cpp @@ -64,30 +64,28 @@ static void initSample() new CApplicationContext(); CSheetId::initWithoutSheet(); CPath::addSearchPath(NL_SOUND_DATA"/data", true, false); - + printf("Sample demonstrating OGG playback using stream file .sound sheets."); printf("\n\n"); - + s_AudioMixer = UAudioMixer::createAudioMixer(); - + // Set the sample path before init, this allow the mixer to build the sample banks s_AudioMixer->setSamplePath(NL_SOUND_DATA"/data/samplebank"); // Packed sheet option, this mean we want packed sheet generated in 'data' folder s_AudioMixer->setPackedSheetOption(NL_SOUND_DATA"/data", true); - + printf("Select NLSOUND Driver:\n"); printf(" [1] FMod\n"); printf(" [2] OpenAl\n"); - printf(" [3] DSound\n"); - printf(" [4] XAudio2\n"); printf("> "); int selection = getchar(); getchar(); printf("\n"); - + // init with 8 tracks, EAX enabled, no ADPCM, and automatic sample bank loading s_AudioMixer->init(8, true, false, NULL, true, (UAudioMixer::TDriver)(selection - '0')); s_AudioMixer->setLowWaterMark(1); - + CVector initpos(0.0f, 0.0f, 0.0f); CVector frontvec(0.0f, 1.0f, 0.0f); CVector upvec(0.0f, 0.0f, 1.0f); @@ -95,14 +93,14 @@ static void initSample() s_AudioMixer->getListener()->setOrientation(frontvec, upvec); CPath::addSearchPath(RYZOM_DATA, true, false); - + //NLMISC::CHTimer::startBench(); s_Source = s_AudioMixer->createSource(CSheetId("stream_file.sound")); nlassert(s_Source); s_StreamFileSource = dynamic_cast(s_Source); nlassert(s_StreamFileSource); - // s_Source->setSourceRelativeMode(true); + // s_Source->setSourceRelativeMode(true); // s_Source->setPitch(2.0f); s_GroupController = s_AudioMixer->getGroupController("sound:dialog"); @@ -111,7 +109,7 @@ static void initSample() static void runSample() { s_Source->play(); - + printf("Change volume with - and +\n"); printf("Press ANY other key to exit\n"); for (; ; ) @@ -154,7 +152,7 @@ static void runSample() } s_AudioMixer->update(); - + nlSleep(40); } } diff --git a/code/nel/samples/sound/stream_ogg_vorbis/stream_ogg_vorbis.cpp b/code/nel/samples/sound/stream_ogg_vorbis/stream_ogg_vorbis.cpp index 1f491b21c..ceaded2f0 100644 --- a/code/nel/samples/sound/stream_ogg_vorbis/stream_ogg_vorbis.cpp +++ b/code/nel/samples/sound/stream_ogg_vorbis/stream_ogg_vorbis.cpp @@ -61,21 +61,19 @@ static void initSample() new CApplicationContext(); CSheetId::initWithoutSheet(); CPath::addSearchPath(NL_SOUND_DATA"/database/build/", true, false); - + printf("Sample demonstrating OGG playback using UStreamSource."); printf("\n\n"); - + s_AudioMixer = UAudioMixer::createAudioMixer(); - + printf("Select NLSOUND Driver:\n"); printf(" [1] FMod\n"); printf(" [2] OpenAl\n"); - printf(" [3] DSound\n"); - printf(" [4] XAudio2\n"); printf("> "); int selection = getchar(); getchar(); printf("\n"); - + // init with 128 tracks, EAX enabled, no ADPCM, and automatic sample bank loading s_AudioMixer->init(8, true, false, NULL, true, (UAudioMixer::TDriver)(selection - '0')); s_AudioMixer->setLowWaterMark(1); @@ -85,7 +83,7 @@ static void initSample() CVector upvec(0.0f, 0.0f, 1.0f); s_AudioMixer->getListener()->setPos(initpos); s_AudioMixer->getListener()->setOrientation(frontvec, upvec); - + //NLMISC::CHTimer::startBench(); USource *source = s_AudioMixer->createSource(CSheetId("default_stream.sound")); @@ -136,7 +134,7 @@ static void runSample() //bufferMore(bytes); s_StreamSource->play(); - + printf("Change volume with - and +\n"); printf("Press ANY other key to exit\n"); while (!s_AudioDecoder->isMusicEnded()) @@ -177,13 +175,13 @@ static void runSample() nlSleep(40); s_AudioMixer->update(); } - + s_StreamSource->stop(); - + printf("End of song\n"); printf("Press ANY key to exit\n"); #ifdef NL_OS_WINDOWS - while (!_kbhit()) + while (!_kbhit()) #else char ch; while (!read(0, &ch, 1)) diff --git a/code/nel/src/3d/coarse_mesh_manager.cpp b/code/nel/src/3d/coarse_mesh_manager.cpp index 2d4792263..847d37968 100644 --- a/code/nel/src/3d/coarse_mesh_manager.cpp +++ b/code/nel/src/3d/coarse_mesh_manager.cpp @@ -120,7 +120,7 @@ void CCoarseMeshManager::flushRender (IDriver *drv) H_AUTO( NL3D_StaticLod_Render ); if (_Meshs.empty()) return; - // if the driver is BGRA (Direct3D), then invert color format + // if the driver is BGRA, then invert color format if(!_VBuffer.isResident() && drv->getVertexColorFormat()==CVertexBuffer::TBGRA) { // since actually empty, no need to swap current memory diff --git a/code/nel/src/3d/driver/CMakeLists.txt b/code/nel/src/3d/driver/CMakeLists.txt index 8f1693716..39a52d9b4 100644 --- a/code/nel/src/3d/driver/CMakeLists.txt +++ b/code/nel/src/3d/driver/CMakeLists.txt @@ -5,9 +5,3 @@ ENDIF() IF(WITH_DRIVER_OPENGLES) ADD_SUBDIRECTORY(opengles) ENDIF() - -IF(WIN32) - IF(WITH_DRIVER_DIRECT3D) - ADD_SUBDIRECTORY(direct3d) - ENDIF() -ENDIF() diff --git a/code/nel/src/3d/driver/direct3d/CMakeLists.txt b/code/nel/src/3d/driver/direct3d/CMakeLists.txt deleted file mode 100644 index d74bdeceb..000000000 --- a/code/nel/src/3d/driver/direct3d/CMakeLists.txt +++ /dev/null @@ -1,24 +0,0 @@ -FILE(GLOB SRC *.cpp *.h *.def *.rc) - -NL_TARGET_DRIVER(nel_drv_direct3d_win ${SRC}) - -INCLUDE_DIRECTORIES(BEFORE ${DXSDK_INCLUDE_DIR}) - -TARGET_LINK_LIBRARIES(nel_drv_direct3d_win nel3d nelmisc ${DXSDK_D3DX9_LIBRARY} ${DXSDK_D3D9_LIBRARY}) - -NL_DEFAULT_PROPS(nel_drv_direct3d_win "NeL, Driver, Video: Direct3D") -NL_ADD_RUNTIME_FLAGS(nel_drv_direct3d_win) -NL_ADD_LIB_SUFFIX(nel_drv_direct3d_win) - -ADD_DEFINITIONS(-DRIVER_DIRECT3D_EXPORTS) - -IF(WITH_PCH) - ADD_NATIVE_PRECOMPILED_HEADER(nel_drv_direct3d_win ${CMAKE_CURRENT_SOURCE_DIR}/stddirect3d.h ${CMAKE_CURRENT_SOURCE_DIR}/stddirect3d.cpp) -ENDIF() - -IF((WITH_INSTALL_LIBRARIES AND WITH_STATIC_DRIVERS) OR NOT WITH_STATIC_DRIVERS) - INSTALL(TARGETS nel_drv_direct3d_win LIBRARY DESTINATION ${NL_DRIVER_PREFIX} ARCHIVE DESTINATION ${NL_LIB_PREFIX} RUNTIME DESTINATION ${NL_DRIVER_PREFIX} COMPONENT drivers3d) - IF(WITH_MAXPLUGIN) - INSTALL(TARGETS nel_drv_direct3d_win RUNTIME DESTINATION maxplugin COMPONENT drivers3d) - ENDIF() -ENDIF() diff --git a/code/nel/src/3d/driver/direct3d/driver_direct3d.cpp b/code/nel/src/3d/driver/direct3d/driver_direct3d.cpp deleted file mode 100644 index be7a74722..000000000 --- a/code/nel/src/3d/driver/direct3d/driver_direct3d.cpp +++ /dev/null @@ -1,4062 +0,0 @@ -// NeL - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as -// published by the Free Software Foundation, either version 3 of the -// License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -#include "stddirect3d.h" - -// by default, we disable the windows menu keys (F10, ALT and ALT+SPACE key doesn't freeze or open the menu) -#define NL_DISABLE_MENU - -#include - -#include "nel/3d/vertex_buffer.h" -#include "nel/3d/light.h" -#include "nel/3d/index_buffer.h" -#include "nel/misc/rect.h" -#include "nel/misc/dynloadlib.h" -#include "nel/3d/viewport.h" -#include "nel/3d/scissor.h" -#include "nel/3d/u_driver.h" - -#include "driver_direct3d.h" - -#ifdef DEBUG_NEW -#define new DEBUG_NEW -#endif - -using namespace std; -using namespace NLMISC; - -#define RASTERIZER D3DDEVTYPE_HAL -//#define RASTERIZER D3DDEVTYPE_REF - -#define D3D_WINDOWED_STYLE (WS_OVERLAPPED|WS_CAPTION|WS_SYSMENU|WS_THICKFRAME|WS_MINIMIZEBOX|WS_MAXIMIZEBOX) -#define D3D_FULLSCREEN_STYLE (WS_POPUP) - -// *************************************************************************** - -// Try to allocate 16Mo by default of AGP Ram. -#define NL3D_DRV_VERTEXARRAY_AGP_INIT_SIZE (16384*1024) - -// Initial volatile vertex buffer size -#define NL_VOLATILE_RAM_VB_SIZE 512*1024 -#define NL_VOLATILE_AGP_VB_SIZE 128*1024 -#define NL_VOLATILE_RAM_IB_SIZE 64*1024 -#define NL_VOLATILE_AGP_IB_SIZE 1024 -// -#define NL_VOLATILE_RAM_VB_MAXSIZE 512*1024 -#define NL_VOLATILE_AGP_VB_MAXSIZE 2500*1024 -#define NL_VOLATILE_RAM_IB_MAXSIZE 1024*1024 -#define NL_VOLATILE_AGP_IB_MAXSIZE 256*1024 - - - -// *************************************************************************** - -#ifndef NL_STATIC - -HINSTANCE HInstDLL = NULL; - -BOOL WINAPI DllMain(HINSTANCE hinstDLL,ULONG fdwReason,LPVOID lpvReserved) -{ - HInstDLL = hinstDLL; - - return true; -} - -class CDriverD3DNelLibrary : public INelLibrary { - void onLibraryLoaded(bool firstTime) { } - void onLibraryUnloaded(bool lastTime) { } -}; -NLMISC_DECL_PURE_LIB(CDriverD3DNelLibrary) - -#endif /* #ifndef NL_STATIC */ - -// *************************************************************************** - -namespace NL3D -{ - -// *************************************************************************** - -// Version of the driver. Not the interface version!! Increment when implementation of the driver change. -const uint32 CDriverD3D::ReleaseVersion = 0xe; - - - -// *************************************************************************** - -#ifdef NL_STATIC - -# pragma comment(lib, "d3dx9") -# pragma comment(lib, "d3d9") -# pragma comment(lib, "dinput8") -# pragma comment(lib, "dxguid") - -IDriver* createD3DDriverInstance () -{ - return new CDriverD3D; -} - -#else - -#ifdef NL_COMP_MINGW -extern "C" -{ -#endif -__declspec(dllexport) IDriver* NL3D_createIDriverInstance () -{ - return new CDriverD3D; -} - -__declspec(dllexport) uint32 NL3D_interfaceVersion () -{ - return IDriver::InterfaceVersion; -} -#ifdef NL_COMP_MINGW -} -#endif -#endif - -/*static*/ bool CDriverD3D::_CacheTest[CacheTest_Count] = -{ - false, // CacheTest_CullMode = 0; - false, // CacheTest_RenderState = 1, - false, // CacheTest_TextureState = 2, - false, // CacheTest_TextureIndexMode = 3, - false, // CacheTest_TextureIndexUV = 4, - false, // CacheTest_Texture = 5, - false, // CacheTest_VertexProgram = 6, - false, // CacheTest_PixelShader = 7, - false, // CacheTest_VertexProgramConstant = 8, - false, // CacheTest_PixelShaderConstant = 9, - false, // CacheTest_SamplerState = 10, - false, // CacheTest_VertexBuffer = 11, - false, // CacheTest_IndexBuffer = 12, - false, // CacheTest_VertexDecl = 13, - false, // CacheTest_Matrix = 14, - false, // CacheTest_RenderTarget = 15, - false, // CacheTest_MaterialState = 16, - false // CacheTest_DepthRange = 17, -}; - - - - -// *************************************************************************** - -CDriverD3D::CDriverD3D() -{ - _SwapBufferCounter = 0; - _CurrentOcclusionQuery = NULL; - _D3D = NULL; - _HWnd = NULL; - _DeviceInterface = NULL; - _DestroyWindow = false; - _CurrentMode.Width = 640; - _CurrentMode.Height = 480; - _WindowX = 0; - _WindowY = 0; - _FullScreen = false; - - _ColorDepth = ColorDepth32; - - _DefaultCursor = EmptyCursor; - - _AlphaBlendedCursorSupported = false; - _AlphaBlendedCursorSupportRetrieved = false; - _CurrCol = CRGBA::White; - _CurrRot = 0; - _CurrHotSpotX = 0; - _CurrHotSpotY = 0; - _CursorScale = 1.f; - - _UserViewMtx.identity(); - _UserModelMtx.identity(); - _PZBCameraPos = CVector::Null; - _CurrentMaterial = NULL; - _CurrentMaterialInfo = NULL; - _CurrentShader = NULL; - _BackBuffer = NULL; - _Maximized = false; - _HandlePossibleSizeChangeNextSize = false; - _Interval = 1; - _AGPMemoryAllocated = 0; - _VRAMMemoryAllocated = 0; - _Rasterizer = RASTERIZER; -#ifdef NL_DISABLE_HARDWARE_VERTEX_PROGAM - _DisableHardwareVertexProgram = true; -#else // NL_DISABLE_HARDWARE_VERTEX_PROGAM - _DisableHardwareVertexProgram = false; -#endif // NL_DISABLE_HARDWARE_VERTEX_PROGAM -#ifdef NL_DISABLE_HARDWARE_PIXEL_PROGAM - _DisableHardwarePixelProgram = true; -#else // NL_DISABLE_HARDWARE_PIXEL_PROGAM - _DisableHardwarePixelProgram = false; -#endif // NL_DISABLE_HARDWARE_PIXEL_PROGAM -#ifdef NL_DISABLE_HARDWARE_VERTEX_ARRAY_AGP - _DisableHardwareVertexArrayAGP = true; -#else // NL_DISABLE_HARDWARE_VERTEX_ARRAY_AGP - _DisableHardwareVertexArrayAGP = false; -#endif // NL_DISABLE_HARDWARE_VERTEX_ARRAY_AGP -#ifdef NL_DISABLE_HARDWARE_INDEX_ARRAY_AGP - _DisableHardwareIndexArrayAGP = true; -#else // NL_DISABLE_HARDWARE_INDEX_ARRAY_AGP - _DisableHardwareIndexArrayAGP = false; -#endif // NL_DISABLE_HARDWARE_INDEX_ARRAY_AGP -#ifdef NL_DISABLE_HARDWARE_PIXEL_SHADER - _DisableHardwarePixelShader = true; -#else // NL_DISABLE_HARDWARE_PIXEL_SHADER - _DisableHardwarePixelShader = false; -#endif // NL_DISABLE_HARDWARE_PIXEL_SHADER - - // Compute the Flag which say if one texture has been changed in CMaterial. - _MaterialAllTextureTouchedFlag= 0; - uint i; - for(i=0; i < IDRV_MAT_MAXTEXTURES; i++) - { - _MaterialAllTextureTouchedFlag|= IDRV_TOUCHED_TEX[i]; - } - - // Default adapter - _Adapter = 0xffffffff; - _ModifiedRenderState = NULL; - - // Create a Direct 3d object - if ( NULL == (_D3D = Direct3DCreate9(D3D_SDK_VERSION))) - { - nlwarning ("Can't create the direct 3d 9 object."); - -#ifdef NL_OS_WINDOWS - sint val = MessageBoxA(NULL, "Your DirectX version is too old. You need to install the latest one.\r\n\r\nPressing OK will quit the game and automatically open your browser to download the latest version of DirectX.\r\nPress Cancel will just quit the game.\r\n", "Mtp Target Error", MB_OKCANCEL); - if(val == IDOK) - { - openURL("http://www.microsoft.com/downloads/details.aspx?FamilyID=4b1f5d0c-5e44-4864-93cd-464ef59da050"); - } -#endif - exit(EXIT_FAILURE); - - } - _DepthRangeNear = 0.f; - _DepthRangeFar = 1.f; - // default for lightmap - _LightMapDynamicLightDirty= false; - _LightMapDynamicLightEnabled= false; - _CurrentMaterialSupportedShader= CMaterial::Normal; - // to avoid any problem if light0 never setuped, and ligthmap rendered - _UserLight0.setupDirectional(CRGBA::Black, CRGBA::White, CRGBA::White, CVector::K); - // All User Light are disabled by Default - for(i=0;i::max(); - _CurStencilOpFail = D3DSTENCILOP_KEEP; - _CurStencilOpZFail = D3DSTENCILOP_KEEP; - _CurStencilOpZPass = D3DSTENCILOP_KEEP; - _CurStencilWriteMask = std::numeric_limits::max(); - - - for(uint k = 0; k < MaxTexture; ++k) - { - _CurrentUVRouting[k] = (uint8) k; - } - _VolatileVertexBufferRAM[0] = new CVolatileVertexBuffer; - _VolatileVertexBufferRAM[1] = new CVolatileVertexBuffer; - _VolatileVertexBufferAGP[0] = new CVolatileVertexBuffer; - _VolatileVertexBufferAGP[1] = new CVolatileVertexBuffer; - _VolatileIndexBuffer16RAM[0]= new CVolatileIndexBuffer; - _VolatileIndexBuffer16RAM[1]= new CVolatileIndexBuffer; - _VolatileIndexBuffer16AGP[0]= new CVolatileIndexBuffer; - _VolatileIndexBuffer16AGP[1]= new CVolatileIndexBuffer; - _VolatileIndexBuffer32RAM[0]= new CVolatileIndexBuffer; - _VolatileIndexBuffer32RAM[1]= new CVolatileIndexBuffer; - _VolatileIndexBuffer32AGP[0]= new CVolatileIndexBuffer; - _VolatileIndexBuffer32AGP[1]= new CVolatileIndexBuffer; - _MustRestoreLight = false; - _Lost = false; - _SceneBegun = false; - _MaxVertexIndex = 0; - _QuadIB = NULL; - _MaxNumPerStageConstantLighted = 0; - _MaxNumPerStageConstantUnlighted = 0; - D3DXMatrixIdentity(&_D3DMatrixIdentity); - _FogColor = 0xffffffff; - _CurrIndexBufferFormat = CIndexBuffer::IndicesUnknownFormat; - _IsGeforce = false; - _NonPowerOfTwoTexturesSupported = false; - _MaxAnisotropy = 0; - _AnisotropicMinSupported = false; - _AnisotropicMagSupported = false; - _AnisotropicMinCubeSupported = false; - _AnisotropicMagCubeSupported = false; - - _FrustumLeft= -1.f; - _FrustumRight= 1.f; - _FrustumTop= 1.f; - _FrustumBottom= -1.f; - _FrustumZNear= -1.f; - _FrustumZFar= 1.f; - _FrustumPerspective= false; - _FogStart = 0; - _FogEnd = 1; - - _SumTextureMemoryUsed = false; - - - _DesktopGammaRampValid = false; -} - -// *************************************************************************** - -CDriverD3D::~CDriverD3D() -{ - release(); - - if(_D3D != NULL) - { - _D3D->Release(); - _D3D = NULL; - } - delete _VolatileVertexBufferRAM[0]; - delete _VolatileVertexBufferRAM[1]; - delete _VolatileVertexBufferAGP[0]; - delete _VolatileVertexBufferAGP[1]; - delete _VolatileIndexBuffer16RAM[0]; - delete _VolatileIndexBuffer16RAM[1]; - delete _VolatileIndexBuffer16AGP[0]; - delete _VolatileIndexBuffer16AGP[1]; - delete _VolatileIndexBuffer32RAM[0]; - delete _VolatileIndexBuffer32RAM[1]; - delete _VolatileIndexBuffer32AGP[0]; - delete _VolatileIndexBuffer32AGP[1]; -} - -// *************************************************************************** - -void CDriverD3D::resetRenderVariables() -{ - H_AUTO_D3D(CDriver3D_resetRenderVariables); - - uint i; - for (i=0; iinit (CVertexBuffer::RAMResident, _VolatileVertexBufferRAM[0]->Size, _VolatileVertexBufferRAM[0]->MaxSize, this); - _VolatileVertexBufferRAM[0]->reset (); - _VolatileVertexBufferRAM[1]->init (CVertexBuffer::RAMResident, _VolatileVertexBufferRAM[1]->Size, _VolatileVertexBufferRAM[1]->MaxSize, this); - _VolatileVertexBufferRAM[1]->reset (); - _VolatileVertexBufferAGP[0]->init (vertexAgpLocation, _VolatileVertexBufferAGP[0]->Size, _VolatileVertexBufferAGP[0]->MaxSize, this); - _VolatileVertexBufferAGP[0]->reset (); - _VolatileVertexBufferAGP[1]->init (vertexAgpLocation, _VolatileVertexBufferAGP[1]->Size, _VolatileVertexBufferAGP[1]->MaxSize, this); - _VolatileVertexBufferAGP[1]->reset (); - // - _VolatileIndexBuffer16RAM[0]->init (CIndexBuffer::RAMResident, _VolatileIndexBuffer16RAM[0]->Size, _VolatileIndexBuffer16RAM[0]->MaxSize, this, CIndexBuffer::Indices16); - _VolatileIndexBuffer16RAM[0]->reset (); - _VolatileIndexBuffer16RAM[1]->init (CIndexBuffer::RAMResident, _VolatileIndexBuffer16RAM[1]->Size, _VolatileIndexBuffer16RAM[1]->MaxSize, this, CIndexBuffer::Indices16); - _VolatileIndexBuffer16RAM[1]->reset (); - _VolatileIndexBuffer16AGP[0]->init (indexAgpLocation, _VolatileIndexBuffer16AGP[0]->Size, _VolatileIndexBuffer16AGP[0]->MaxSize, this, CIndexBuffer::Indices16); - _VolatileIndexBuffer16AGP[0]->reset (); - _VolatileIndexBuffer16AGP[1]->init (indexAgpLocation, _VolatileIndexBuffer16AGP[1]->Size, _VolatileIndexBuffer16AGP[1]->MaxSize, this, CIndexBuffer::Indices16); - _VolatileIndexBuffer16AGP[1]->reset (); - // - if (_MaxVertexIndex > 0xffff) // supports 32 bits ? - { - _VolatileIndexBuffer32RAM[0]->init (CIndexBuffer::RAMResident, _VolatileIndexBuffer32RAM[0]->Size, _VolatileIndexBuffer32RAM[0]->MaxSize, this, CIndexBuffer::Indices32); - _VolatileIndexBuffer32RAM[0]->reset (); - _VolatileIndexBuffer32RAM[1]->init (CIndexBuffer::RAMResident, _VolatileIndexBuffer32RAM[1]->Size, _VolatileIndexBuffer32RAM[1]->MaxSize, this, CIndexBuffer::Indices32); - _VolatileIndexBuffer32RAM[1]->reset (); - _VolatileIndexBuffer32AGP[0]->init (indexAgpLocation, _VolatileIndexBuffer32AGP[0]->Size, _VolatileIndexBuffer32AGP[0]->MaxSize, this, CIndexBuffer::Indices32); - _VolatileIndexBuffer32AGP[0]->reset (); - _VolatileIndexBuffer32AGP[1]->init (indexAgpLocation, _VolatileIndexBuffer32AGP[1]->Size, _VolatileIndexBuffer32AGP[1]->MaxSize, this, CIndexBuffer::Indices32); - _VolatileIndexBuffer32AGP[1]->reset (); - } - _ScissorTouched = true; -} - -// *************************************************************************** - -void CDriverD3D::initRenderVariables() -{ - H_AUTO_D3D(CDriver3D_initRenderVariables); - uint i; - for (i=0; i=MatrixStateRemap)?i-MatrixStateRemap+256:i); - memset (&(_MatrixCache[i].Matrix), 0xcc, sizeof(D3DXMATRIX)); - _MatrixCache[i].Modified = false; - } - _VertexBufferCache.Modified = false; - _VertexBufferCache.VertexBuffer = NULL; - _IndexBufferCache.Modified = false; - _IndexBufferCache.IndexBuffer = NULL; - _VertexDeclCache.Modified = false; - _VertexDeclCache.Decl = NULL; - for (i=0; iType) - { - case CRenderVariable::RenderState: - { - CRenderState *renderState = static_cast(currentRenderState); - _DeviceInterface->SetRenderState (renderState->StateID, renderState->Value); - } - break; - case CRenderVariable::TextureState: - { - CTextureState *textureState = static_cast(currentRenderState); - _DeviceInterface->SetTextureStageState (textureState->StageID, textureState->StateID, textureState->Value); - } - break; - case CRenderVariable::TextureIndexState: - { - CTextureIndexState *textureState = static_cast(currentRenderState); - if (textureState->TexGen) - setTextureState (textureState->StageID, D3DTSS_TEXCOORDINDEX, textureState->TexGenMode); - else - setTextureState (textureState->StageID, D3DTSS_TEXCOORDINDEX, textureState->UVChannel); - } - break; - case CRenderVariable::TexturePtrState: - { - CTexturePtrState *textureState = static_cast(currentRenderState); - _DeviceInterface->SetTexture (textureState->StageID, textureState->Texture); - } - break; - case CRenderVariable::VertexProgramPtrState: - { - CVertexProgramPtrState *vertexProgram = static_cast(currentRenderState); - _DeviceInterface->SetVertexShader(vertexProgram->VertexProgram); - } - break; - case CRenderVariable::PixelShaderPtrState: - { - CPixelShaderPtrState *pixelShader = static_cast(currentRenderState); - _DeviceInterface->SetPixelShader(pixelShader->PixelShader); - } - break; - case CRenderVariable::VertexProgramConstantState: - { - CVertexProgramConstantState *vertexProgramConstant = static_cast(currentRenderState); - switch (vertexProgramConstant->ValueType) - { - case CVertexProgramConstantState::Float: - _DeviceInterface->SetVertexShaderConstantF (vertexProgramConstant->StateID, (float*)vertexProgramConstant->Values, 1); - break; - case CVertexProgramConstantState::Int: - _DeviceInterface->SetVertexShaderConstantI (vertexProgramConstant->StateID, (int*)vertexProgramConstant->Values, 1); - break; - } - } - break; - case CRenderVariable::PixelShaderConstantState: - { - CPixelShaderConstantState *pixelShaderConstant = static_cast(currentRenderState); - switch (pixelShaderConstant->ValueType) - { - case CPixelShaderConstantState::Float: - _DeviceInterface->SetPixelShaderConstantF (pixelShaderConstant->StateID, (float*)pixelShaderConstant->Values, 1); - break; - case CPixelShaderConstantState::Int: - _DeviceInterface->SetPixelShaderConstantI (pixelShaderConstant->StateID, (int*)pixelShaderConstant->Values, 1); - break; - } - } - break; - case CRenderVariable::SamplerState: - { - CSamplerState *samplerState = static_cast(currentRenderState); - _DeviceInterface->SetSamplerState (samplerState->SamplerID, samplerState->StateID, samplerState->Value); - } - break; - case CRenderVariable::MatrixState: - { - CMatrixState *renderMatrix = static_cast(currentRenderState); - _DeviceInterface->SetTransform (renderMatrix->TransformType, &(renderMatrix->Matrix)); - } - break; - case CRenderVariable::VBState: - { - CVBState *renderVB = static_cast(currentRenderState); - if (renderVB->VertexBuffer) - { - _DeviceInterface->SetStreamSource (0, renderVB->VertexBuffer, renderVB->Offset, renderVB->Stride); - } - } - break; - case CRenderVariable::IBState: - { - CIBState *renderIB = static_cast(currentRenderState); - if (renderIB->IndexBuffer) - { - _DeviceInterface->SetIndices (renderIB->IndexBuffer); - } - } - break; - case CRenderVariable::VertexDecl: - { - CVertexDeclState *renderVB = static_cast(currentRenderState); - if (renderVB->Decl) - { - _DeviceInterface->SetVertexDeclaration (renderVB->Decl); - } - } - break; - case CRenderVariable::LightState: - { - CLightState *renderLight = static_cast(currentRenderState); - - // Enabel state modified ? - if (renderLight->EnabledTouched) - _DeviceInterface->LightEnable (renderLight->LightIndex, renderLight->Enabled); - - // Light enabled ? - if (renderLight->Enabled) - { - if (renderLight->SettingsTouched) - { - // New position - renderLight->Light.Position.x -= _PZBCameraPos.x; - renderLight->Light.Position.y -= _PZBCameraPos.y; - renderLight->Light.Position.z -= _PZBCameraPos.z; - _DeviceInterface->SetLight (renderLight->LightIndex, &(renderLight->Light)); - renderLight->SettingsTouched = false; - } - } - - // Clean - renderLight->EnabledTouched = false; - } - break; - case CRenderVariable::RenderTargetState: - { - CRenderTargetState *renderTarget = static_cast(currentRenderState); - _DeviceInterface->SetRenderTarget (0, renderTarget->Target); - setupViewport (_Viewport); - setupScissor (_Scissor); - } - break; - } -}*/ - - - - -// *************************************************************************** -#ifdef NL_DEBUG - inline -#endif -void CDriverD3D::replaceArgumentAtStage(D3DTEXTURESTAGESTATETYPE state, DWORD stage, DWORD from, DWORD to) -{ - if ((_TextureStateCache[stage][state].Value & D3DTA_SELECTMASK) == from) - { - setTextureState (stage, state, (_TextureStateCache[stage][state].Value&~D3DTA_SELECTMASK)|to); - } -} - -// *************************************************************************** -// Replace a constant with diffuse color at the given stage -#ifdef NL_DEBUG - inline -#endif -void CDriverD3D::replaceAllRGBArgumentAtStage(uint stage, DWORD from, DWORD to, DWORD blendOpFrom) -{ - replaceArgumentAtStage(D3DTSS_COLORARG1, stage, from, to); - if (_CurrentMaterialInfo->NumColorArg[stage] > 1) - { - replaceArgumentAtStage(D3DTSS_COLORARG2, stage, from, to); - if (_CurrentMaterialInfo->NumColorArg[stage] > 2) - { - replaceArgumentAtStage(D3DTSS_COLORARG0, stage, from, to); - } - } - // - // Operator is D3DTOP_BLENDDIFFUSEALPHA ? - if (_TextureStateCache[stage][D3DTSS_COLOROP].Value == blendOpFrom) - { - setTextureState (stage, D3DTSS_COLOROP, D3DTOP_LERP); - setTextureState (stage, D3DTSS_COLORARG0, to|D3DTA_ALPHAREPLICATE); - } - -} - -#ifdef NL_DEBUG - inline -#endif -void CDriverD3D::replaceAllAlphaArgumentAtStage(uint stage, DWORD from, DWORD to, DWORD blendOpFrom) -{ - replaceArgumentAtStage(D3DTSS_ALPHAARG1, stage, from, to); - if (_CurrentMaterialInfo->NumAlphaArg[stage] > 1) - { - replaceArgumentAtStage(D3DTSS_ALPHAARG2, stage, from, to); - if (_CurrentMaterialInfo->NumAlphaArg[stage] > 2) - { - replaceArgumentAtStage(D3DTSS_ALPHAARG0, stage, from, to); - } - } - if (_TextureStateCache[stage][D3DTSS_ALPHAOP].Value == blendOpFrom) - { - setTextureState (stage, D3DTSS_ALPHAOP, D3DTOP_LERP); - setTextureState (stage, D3DTSS_ALPHAARG0, to); - } -} - -#ifdef NL_DEBUG - inline -#endif -void CDriverD3D::replaceAllArgumentAtStage(uint stage, DWORD from, DWORD to, DWORD blendOpFrom) -{ - if (_CurrentMaterialInfo->RGBPipe[stage]) - { - replaceAllRGBArgumentAtStage(stage, from, to, blendOpFrom); - } - if (_CurrentMaterialInfo->AlphaPipe[stage]) - { - replaceAllAlphaArgumentAtStage(stage, from, to, blendOpFrom); - } -} - -// *************************************************************************** -// Replace all argument at relevant stages with the given value -#ifdef NL_DEBUG - inline -#endif -void CDriverD3D::replaceAllArgument(DWORD from, DWORD to, DWORD blendOpFrom) -{ - const uint maxTexture = inlGetNumTextStages(); - // Look for texture state - for (uint i=0; iColorOp[i] == D3DTOP_DISABLE) break; - replaceAllArgumentAtStage(i, from, to, blendOpFrom); - } -} - -// *************************************************************************** -#ifdef NL_DEBUG - inline -#endif -void CDriverD3D::setupConstantDiffuseColorFromLightedMaterial(D3DCOLOR color) -{ - for(uint i=1;i<_MaxLight;++i) - enableLightInternal(uint8(i), false); - _LightMapDynamicLightDirty= true; - D3DMATERIAL9 d3dMat; - setColor(d3dMat.Diffuse, 0.f, 0.f, 0.f, (1.f / 255.f) * (color >> 24)); - setColor(d3dMat.Ambient, 0.f, 0.f, 0.f, 0.f); - setColor(d3dMat.Specular, 0.f, 0.f, 0.f, 0.f); - setColor(d3dMat.Emissive, color); - setMaterialState(d3dMat); - setRenderState(D3DRS_LIGHTING, TRUE); -} - - -// *************************************************************************** -void CDriverD3D::updateRenderVariablesInternal() -{ - H_AUTO_D3D(CDriver3D_updateRenderVariablesInternal); - nlassert (_DeviceInterface); - bool aliasDiffuseToSpecular = false; - bool enableVertexColorFlag = true; - if (_CurrentMaterialInfo && (_CurrentMaterialInfo->NeedsConstantForDiffuse || _CurrentMaterialInfo->MultipleConstantNoPixelShader)) /* The "unlighted without vertex color" trick */ - { - // The material IS unlighted - // No pixel shader ? - if (_CurrentMaterialInfo->PixelShader) - { - /* - * We have to set the pixel shader now, because we have to choose between normal pixel shader and pixel shader without vertex color */ - // Must have two pixel shader - nlassert (_CurrentMaterialInfo->PixelShaderUnlightedNoVertexColor); - if (!_UseVertexColor && (_VertexProgramCache.VertexProgram == NULL)) - { - setPixelShader (_CurrentMaterialInfo->PixelShaderUnlightedNoVertexColor); - } - else - { - setPixelShader (_CurrentMaterialInfo->PixelShader); - } - } - else - { - setPixelShader (NULL); - if (_CurrentMaterialInfo->NeedsConstantForDiffuse) - { - /* - * We have to change all texture state setuped to D3DTA_DIFFUSE into D3DTA_TFACTOR - * if we use a vertex buffer with diffuse color vertex with an unlighted material and no vertex program */ - if (_VertexProgramCache.VertexProgram) - { - // Diffuse should be output from vertex program - // So we can only emulate 1 per stage constant (it has already been setup in CDriverD3D::setupMaterial) - #ifdef NL_DEBUG - nlassert(!_CurrentMaterialInfo->MultipleConstantNoPixelShader); - #endif - } - else - { - if (!_UseVertexColor) - { - if (!_CurrentMaterialInfo->MultipleConstantNoPixelShader) - { - // Diffuse is used, but no other constant is used in the shader - // Max texture - replaceAllArgument(D3DTA_DIFFUSE, D3DTA_TFACTOR, D3DTOP_BLENDDIFFUSEALPHA); - setRenderState (D3DRS_TEXTUREFACTOR, _CurrentMaterialInfo->UnlightedColor); - } - else - { - #ifdef NL_DEBUG - nlassert(!_CurrentMaterialInfo->MultiplePerStageConstant); // Can't render this material on current hardware - #endif - //replaceAllArgumentAtStage(_CurrentMaterialInfo->ConstantIndex, D3DTA_TFACTOR, D3DTA_DIFFUSE, D3DTOP_BLENDFACTORALPHA); - setupConstantDiffuseColorFromLightedMaterial(_CurrentMaterialInfo->UnlightedColor); - } - } - else - { - if (_CurrentMaterialInfo->MultiplePerStageConstant) - { - // vertex color, 1st constant from CMaterial::getColor (already setuped in CDriverD3D::setupMaterial) - // 2nd constant from a stage constant - // Vertex color is aliased to the specular stream -> all references to D3DTA_DIFFUSE must be replaced with references to D3DTA_SPECULAR - replaceAllArgument(D3DTA_DIFFUSE, D3DTA_SPECULAR, 0xffffffff); - aliasDiffuseToSpecular = true; - replaceAllArgumentAtStage(_CurrentMaterialInfo->ConstantIndex2, D3DTA_TFACTOR, D3DTA_DIFFUSE, D3DTOP_BLENDFACTORALPHA); - setupConstantDiffuseColorFromLightedMaterial(NL_D3DCOLOR_RGBA(_CurrentMaterialInfo->Constant2)); // set 2nd per stage constant - #ifdef NL_DEBUG - nlassert(_VertexDeclCache.DeclAliasDiffuseToSpecular); // VB must not have specular used ... else this material can't render - #endif - // NB : currently this don't work with the GeForce2 (seems to be a driver bug). Fortunately, this case isn't encountered with Ryzom materials :) - // So it's provided for convenience. - } - } - } - } - else - { - nlassert(_CurrentMaterialInfo->MultipleConstantNoPixelShader); - // If vertex color is used, alias it to specular - /* - if (_UseVertexColor) - { - replaceAllArgument(D3DTA_DIFFUSE, D3DTA_SPECULAR, 0xffffffff); - aliasDiffuseToSpecular = true; // VB must not have specular used ... else this material can't render - } - */ - // up to 2 constants with no pixel shaders - // look for constant at other stages and replaces then with diffuse color - // first constant color has already been set yet (in CD3DDriver::setupMaterial) - replaceAllArgumentAtStage(_CurrentMaterialInfo->ConstantIndex2, D3DTA_TFACTOR, D3DTA_DIFFUSE, D3DTOP_BLENDFACTORALPHA); - setupConstantDiffuseColorFromLightedMaterial(NL_D3DCOLOR_RGBA(_CurrentMaterialInfo->Constant2)); // set 2nd per stage constant - } - } - } - else - { - if (_CurrentMaterialInfo) enableVertexColorFlag = _CurrentMaterialInfo->VertexColorLighted; - } - - - if (_NbNeLTextureStages == 3) - { - // Fix (one more...) for Radeon 7xxx - // Don't know why, but the lighting is broken when MULTIPLYADD is used as in the lightmap shader.. - // Correct behaviour with GeForce & Ref. rasterizer... - // The fix is to disable the light contribution from dynamic lights - if (_TextureStateCache[0][D3DTSS_COLOROP].Value == D3DTOP_MULTIPLYADD && - _TextureStateCache[0][D3DTSS_COLORARG0].Value == D3DTA_DIFFUSE - ) - { - _TextureStateCache[0][D3DTSS_COLOROP].Value = D3DTOP_MODULATE; - touchRenderVariable(&_TextureStateCache[0][D3DTSS_COLOROP]); - } - // fix for radeon 7xxx -> should enable vertex color only if really used in pixel pipe - setEnableVertexColor(enableVertexColorFlag); - } - setAliasDiffuseToSpecular(aliasDiffuseToSpecular); - - - // Flush all the modified render states - while (_ModifiedRenderState) - { - // Current variable - CRenderVariable *currentRenderState = _ModifiedRenderState; - - // It is clean now - currentRenderState->Modified = false; - - // Unlinked - _ModifiedRenderState = currentRenderState->NextModified; - currentRenderState->apply(this); - } - - - // Maybe it is a driver bug : in some situation with GeForce, I got vertex color set to (0, 0, 0, 0) with unlighted vertices and vertex color. - // Forcing to resetup material solves the prb.. (though D3DRS_LIGHTING is set to FALSE ...) - // I only have the prb with GeForce. The behaviour doesn't exhibit when using the D3D debug dll. - if (_IsGeforce) - { - if (_RenderStateCache[D3DRS_LIGHTING].Value == FALSE && _VertexProgramCache.VertexProgram == NULL) - { - _MaterialState.apply(this); - } - } - -} - - - -// *************************************************************************** - -void D3DWndProc(CDriverD3D *driver, HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) -{ - H_AUTO_D3D(D3DWndProc); - - // Check this message in parents - - if ((message == WM_SIZE) || (message == WM_EXITSIZEMOVE) || (message == WM_MOVE)) - { - if (driver != NULL) - { - // *** Check the hwnd is the root parent of driver->_HWnd - - // hwnd must be a _HWnd parent - bool sameWindow = hWnd == driver->_HWnd; - bool rootWindow = false; - HWND tmp = driver->_HWnd; - while (tmp) - { - if (tmp == hWnd) - { - rootWindow = true; - break; - } - tmp = GetParent (tmp); - } - - // hwnd must be a top window - rootWindow &= (GetParent (hWnd) == NULL); - - // This is a root parent, not _HWnd - if (rootWindow) - { - if (message == WM_SIZE) - { - if( SIZE_MAXIMIZED == wParam) - { - driver->_Maximized = true; - if (sameWindow) - driver->handlePossibleSizeChange(); - else - driver->_HandlePossibleSizeChangeNextSize = true; - } - else if( SIZE_RESTORED == wParam) - { - if (driver->_Maximized) - { - driver->_Maximized = false; - if (sameWindow) - driver->handlePossibleSizeChange(); - else - driver->_HandlePossibleSizeChangeNextSize = true; - } - } - } - else if(message == WM_EXITSIZEMOVE) - { - if (driver != NULL) - { - driver->handlePossibleSizeChange(); - } - } - else if(message == WM_MOVE) - { - if (driver != NULL) - { - RECT rect; - GetWindowRect (hWnd, &rect); - driver->_WindowX = rect.left; - driver->_WindowY = rect.top; - } - } - } - // This is the window itself - else if (sameWindow) - { - if (message == WM_SIZE) - { - if (driver->_HandlePossibleSizeChangeNextSize) - { - driver->handlePossibleSizeChange(); - driver->_HandlePossibleSizeChangeNextSize = false; - } - } - } - - } - } - - if (driver->_EventEmitter.getNumEmitters() > 0) - { - CWinEventEmitter *we = NLMISC::safe_cast(driver->_EventEmitter.getEmitter(0)); - // Process the message by the emitter - we->setHWnd(hWnd); - we->processMessage (hWnd, message, wParam, lParam); - } -} - -// *************************************************************************** - -bool CDriverD3D::handlePossibleSizeChange() -{ - //DUMP_AUTO(handlePossibleSizeChange); - H_AUTO_D3D(CDriver3D_handlePossibleSizeChange); - // If windowed, check if the size as changed - if (_CurrentMode.Windowed) - { - RECT rect; - GetClientRect (_HWnd, &rect); - - // Setup d3d resolution - uint16 newWidth = uint16(rect.right-rect.left); - uint16 newHeight = uint16(rect.bottom-rect.top); - - // Set the new mode. Only change the size, keep the last setDisplay/setMode settings - GfxMode mode = _CurrentMode; - mode.Width = newWidth; - mode.Height = newHeight; - - if ( ( (mode.Width != _CurrentMode.Width) || (mode.Height != _CurrentMode.Height) ) && - ( mode.Width != 0 ) && - ( mode.Height != 0 ) ) - { - return reset (mode); - } - } - return false; -} - -// *************************************************************************** - -static LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) -{ - H_AUTO_D3D(WndProc); - // Get the driver pointer.. - CDriverD3D *pDriver=(CDriverD3D*)GetWindowLongPtrW (hWnd, GWLP_USERDATA); - if (pDriver != NULL) - { - D3DWndProc (pDriver, hWnd, message, wParam, lParam); - } - -#ifdef NL_DISABLE_MENU - // disable menu (F10, ALT and ALT+SPACE key doesn't freeze or open the menu) - if(message == WM_SYSCOMMAND && wParam == SC_KEYMENU) - return 0; -#endif // NL_DISABLE_MENU - - // ace: if we receive close, exit now or it'll assert after - if(message == WM_CLOSE) - { - if(pDriver && pDriver->ExitFunc) - { - pDriver->ExitFunc(); - } - else - { -#ifndef NL_DISABLE_MENU - // if we don't disable menu, alt F4 make a direct exit else we discard the message - exit(0); -#endif // NL_DISABLE_MENU - } - return 0; - } - - return DefWindowProcW(hWnd, message, wParam, lParam); -} - -// *************************************************************************** - -bool CDriverD3D::init (uintptr_t windowIcon, emptyProc exitFunc) -{ - H_AUTO_D3D(CDriver3D_init ); - - ExitFunc = exitFunc; - - createCursors(); - - _WindowClass = "NLD3D" + toString(windowIcon); - - // Register a window class - WNDCLASSA wc; - - memset(&wc,0,sizeof(wc)); - wc.style = 0; // CS_HREDRAW | CS_VREDRAW ;//| CS_DBLCLKS; - wc.lpfnWndProc = (WNDPROC)WndProc; - wc.cbClsExtra = 0; - wc.cbWndExtra = 0; - wc.hInstance = GetModuleHandleA(NULL); - wc.hIcon = (HICON)windowIcon; - wc.hCursor = _DefaultCursor; - wc.hbrBackground = WHITE_BRUSH; - wc.lpszClassName = _WindowClass.c_str(); - wc.lpszMenuName = NULL; - if (!RegisterClassA(&wc)) - { - DWORD error = GetLastError(); - if (error != ERROR_CLASS_ALREADY_EXISTS) - { - nlwarning("CDriverD3D::init: Can't register window class %s (error code %i)", _WindowClass.c_str(), (sint)error); - _WindowClass.clear(); - return false; - } - } - - return true; -} - -// *************************************************************************** - -// From the SDK -bool CDriverD3D::isDepthFormatOk(UINT adapter, D3DDEVTYPE rasterizer, D3DFORMAT DepthFormat, - D3DFORMAT AdapterFormat, - D3DFORMAT BackBufferFormat) -{ - H_AUTO_D3D(CDriverD3D_isDepthFormatOk); - // Verify that the depth format exists - HRESULT hr = _D3D->CheckDeviceFormat(adapter, - rasterizer, - AdapterFormat, - D3DUSAGE_DEPTHSTENCIL, - D3DRTYPE_SURFACE, - DepthFormat); - - if(FAILED(hr)) return FALSE; - - // Verify that the depth format is compatible - hr = _D3D->CheckDepthStencilMatch(adapter, - (D3DDEVTYPE) rasterizer, - AdapterFormat, - BackBufferFormat, - DepthFormat); - - return SUCCEEDED(hr); - -} - -// *************************************************************************** - -const D3DFORMAT FinalPixelFormat[ITexture::UploadFormatCount][CDriverD3D::FinalPixelFormatChoice]= -{ - { D3DFMT_A8R8G8B8, D3DFMT_A8R8G8B8, D3DFMT_A8R8G8B8, D3DFMT_A8R8G8B8, D3DFMT_A8R8G8B8 }, // Auto - { D3DFMT_A8R8G8B8, D3DFMT_A8R8G8B8, D3DFMT_A8R8G8B8, D3DFMT_A8R8G8B8, D3DFMT_A8R8G8B8 }, // RGBA8888 - { D3DFMT_A4R4G4B4, D3DFMT_A1R5G5B5, D3DFMT_A8R3G3B2, D3DFMT_A8R8G8B8, D3DFMT_A8R8G8B8 }, // RGBA4444 - { D3DFMT_A1R5G5B5, D3DFMT_A4R4G4B4, D3DFMT_A8R8G8B8, D3DFMT_A8R8G8B8, D3DFMT_A8R8G8B8 }, // RGBA5551 - { D3DFMT_R8G8B8, D3DFMT_A8R8G8B8, D3DFMT_A8R8G8B8, D3DFMT_A8R8G8B8, D3DFMT_A8R8G8B8 }, // RGB888 - { D3DFMT_R5G6B5, D3DFMT_A1R5G5B5, D3DFMT_A8R8G8B8, D3DFMT_A8R8G8B8, D3DFMT_A8R8G8B8 }, // RGB565 - { D3DFMT_DXT1, D3DFMT_R3G3B2, D3DFMT_A1R5G5B5, D3DFMT_R5G6B5, D3DFMT_A8R8G8B8 }, // DXTC1 - { D3DFMT_DXT1, D3DFMT_R3G3B2, D3DFMT_A1R5G5B5, D3DFMT_R5G6B5, D3DFMT_A8R8G8B8 }, // DXTC1Alpha - { D3DFMT_DXT3, D3DFMT_A4R4G4B4, D3DFMT_A8R8G8B8, D3DFMT_A8R8G8B8, D3DFMT_A8R8G8B8 }, // DXTC3 - { D3DFMT_DXT5, D3DFMT_A4R4G4B4, D3DFMT_A8R8G8B8, D3DFMT_A8R8G8B8, D3DFMT_A8R8G8B8 }, // DXTC5 - { D3DFMT_L8, D3DFMT_A8L8, D3DFMT_R5G6B5, D3DFMT_A1R5G5B5, D3DFMT_A8R8G8B8 }, // Luminance - { D3DFMT_A8, D3DFMT_A8L8, D3DFMT_A8R3G3B2, D3DFMT_A8R8G8B8, D3DFMT_A8R8G8B8 }, // Alpha - { D3DFMT_A8L8, D3DFMT_A8R8G8B8, D3DFMT_A8R8G8B8, D3DFMT_A8R8G8B8, D3DFMT_A8R8G8B8 }, // AlphaLuminance - { D3DFMT_V8U8, D3DFMT_A8R8G8B8, D3DFMT_A8R8G8B8, D3DFMT_A8R8G8B8, D3DFMT_A8R8G8B8 }, // DsDt -}; - -// *************************************************************************** - -bool CDriverD3D::setDisplay(nlWindow wnd, const GfxMode& mode, bool show, bool resizeable) throw(EBadDisplay) -{ - H_AUTO_D3D(CDriver3D_setDisplay); - - if (!mode.OffScreen) - NLMISC::INelContext::getInstance().setWindowedApplication(true); - - if (!_D3D) - return false; -#ifndef NL_NO_ASM - CFpuRestorer fpuRestorer; -#endif - // Release the driver if already setuped - release (); - - // Should be initialized - nlassert (!_WindowClass.empty()); - - // Should be released - nlassert (_DeviceInterface == NULL); - nlassert (_HWnd == NULL); - - // memorize desktop gamma ramp - HDC dc = CreateDCW (L"DISPLAY", NULL, NULL, NULL); - if (dc) - { - _DesktopGammaRampValid = GetDeviceGammaRamp (dc, _DesktopGammaRamp) != FALSE; - // Release the DC - ReleaseDC (NULL, dc); - } - - // Create a window - _HWnd = wnd; - - // Reset window state - _Maximized = false; - _HandlePossibleSizeChangeNextSize = false; - - if (_HWnd) - { - // We don't have to destroy this window - _DestroyWindow = false; - - // Init Window Width and Height - RECT clientRect; - GetClientRect (_HWnd, &clientRect); - _CurrentMode.OffScreen = false; - _CurrentMode.Width = (uint16)(clientRect.right-clientRect.left); - _CurrentMode.Height = (uint16)(clientRect.bottom-clientRect.top); - _CurrentMode.Frequency = 0; - _CurrentMode.Windowed = true; - _CurrentMode.Depth = 32; - } - else - { - _CurrentMode = mode; - - // We have to destroy this window - _DestroyWindow = true; - - // Window flags - //ULONG WndFlags=(mode.Windowed?D3D_WINDOWED_STYLE:D3D_FULLSCREEN_STYLE)&~WS_VISIBLE; - ULONG WndFlags; - if(mode.Windowed) - { - WndFlags = D3D_WINDOWED_STYLE; - if(!resizeable) - { - WndFlags &= ~(WS_THICKFRAME|WS_MAXIMIZEBOX); - } - } - else - { - WndFlags = D3D_FULLSCREEN_STYLE; - findNearestFullscreenVideoMode(); - } - - WndFlags &= ~WS_VISIBLE; - - // Window rect - RECT WndRect; - WndRect.left=0; - WndRect.top=0; - WndRect.right=_CurrentMode.Width; - WndRect.bottom=_CurrentMode.Height; - AdjustWindowRect(&WndRect,WndFlags,FALSE); - - // Create - ucstring ustr(_WindowClass); - _HWnd = CreateWindowW((LPCWSTR)ustr.c_str(), L"", WndFlags, CW_USEDEFAULT,CW_USEDEFAULT, WndRect.right-WndRect.left,WndRect.bottom-WndRect.top, NULL, NULL, - GetModuleHandleW(NULL), NULL); - if (!_HWnd) - { - nlwarning ("CreateWindowW failed"); - release(); - return false; - } - - // Set the window long integer - SetWindowLongPtrW (_HWnd, GWLP_USERDATA, (LONG_PTR)this); - - // Show the window - if (show || !_CurrentMode.Windowed) - showWindow(true); - } - - // Choose an adapter - UINT adapter = (_Adapter==0xffffffff)?D3DADAPTER_DEFAULT:(UINT)_Adapter; - - // Get adapter format - D3DDISPLAYMODE adapterMode; - if (_D3D->GetAdapterDisplayMode (adapter, &adapterMode) != D3D_OK) - { - nlwarning ("GetAdapterDisplayMode failed"); - release(); - return false; - } - - // The following code is taken from the NVPerfHud user guide - // Set default settings - _Rasterizer = RASTERIZER; -#ifdef NL_D3D_USE_NV_PERF_HUD - // Look for 'NVIDIA NVPerfHUD' adapter - // If it is present, override default settings - for (UINT adapterIndex = 0; adapterIndex < _D3D->GetAdapterCount(); adapterIndex++) - { - D3DADAPTER_IDENTIFIER9 identifier; - HRESULT res = _D3D->GetAdapterIdentifier(adapterIndex, 0, &identifier); - if (strstr(identifier.Description, "PerfHUD") != 0) - { - adapter = adapterIndex; - _Adapter = adapter; - _Rasterizer = D3DDEVTYPE_REF; - nlinfo("Using NVIDIA NVPerfHUD adapter"); - break; - } - } -#endif - - // Create device options - D3DPRESENT_PARAMETERS parameters; - D3DFORMAT adapterFormat; - if (!fillPresentParameter (parameters, adapterFormat, _CurrentMode, adapterMode)) - { - release(); - return false; - } - - #if WITH_PERFHUD - // Look for 'NVIDIA PerfHUD' adapter - // If it is present, override default settings - for (UINT gAdapter=0;gAdapter<_D3D->GetAdapterCount();gAdapter++) - { - D3DADAPTER_IDENTIFIER9 Identifier; - HRESULT Res; - Res = _D3D->GetAdapterIdentifier(gAdapter,0,&Identifier); - - if (strstr(Identifier.Description,"PerfHUD") != 0) - { - nlinfo ("Setting up with PerfHUD"); - adapter=gAdapter; - _Rasterizer=D3DDEVTYPE_REF; - break; - } - } - #endif /* WITH_PERFHUD */ - // Create the D3D device - HRESULT result = _D3D->CreateDevice (adapter, _Rasterizer, _HWnd, D3DCREATE_HARDWARE_VERTEXPROCESSING|D3DCREATE_PUREDEVICE, ¶meters, &_DeviceInterface); - if (result != D3D_OK) - { - nlwarning ("Can't create device hr:0x%x adap:0x%x rast:0x%x", result, adapter, _Rasterizer); - - // Create the D3D device without puredevice - HRESULT result = _D3D->CreateDevice (adapter, _Rasterizer, _HWnd, D3DCREATE_HARDWARE_VERTEXPROCESSING, ¶meters, &_DeviceInterface); - if (result != D3D_OK) - { - nlwarning ("Can't create device without puredevice hr:0x%x adap:0x%x rast:0x%x", result, adapter, _Rasterizer); - - // Create the D3D device without puredevice and hardware - HRESULT result = _D3D->CreateDevice (adapter, _Rasterizer, _HWnd, D3DCREATE_SOFTWARE_VERTEXPROCESSING, ¶meters, &_DeviceInterface); - if (result != D3D_OK) - { - nlwarning ("Can't create device without puredevice and hardware hr:0x%x adap:0x%x rast:0x%x", result, adapter, _Rasterizer); - release(); - return false; - } - } - } - - // Check some caps - D3DCAPS9 caps; - if (_DeviceInterface->GetDeviceCaps(&caps) == D3D_OK) - { - _TextureCubeSupported = (caps.TextureCaps & D3DPTEXTURECAPS_CUBEMAP) != 0; - _NbNeLTextureStages = (caps.MaxSimultaneousTextures= D3DPS_VERSION(2, 0) || caps.PixelShaderVersion < D3DPS_VERSION(1, 4)); - _NonPowerOfTwoTexturesSupported = !(caps.TextureCaps & D3DPTEXTURECAPS_POW2) || (caps.TextureCaps & D3DPTEXTURECAPS_NONPOW2CONDITIONAL); - _MaxAnisotropy = caps.MaxAnisotropy; - _AnisotropicMinSupported = (caps.TextureFilterCaps & D3DPTFILTERCAPS_MINFANISOTROPIC) != 0; - _AnisotropicMagSupported = (caps.TextureFilterCaps & D3DPTFILTERCAPS_MAGFANISOTROPIC) != 0; - _AnisotropicMinCubeSupported = (caps.CubeTextureFilterCaps & D3DPTFILTERCAPS_MINFANISOTROPIC) != 0; - _AnisotropicMagCubeSupported = (caps.CubeTextureFilterCaps & D3DPTFILTERCAPS_MAGFANISOTROPIC) != 0; - } - else - { - _TextureCubeSupported = false; - _NbNeLTextureStages = 1; - _MADOperatorSupported = false; - _EMBMSupported = false; - _CubbedMipMapSupported = false; - _PixelShaderVersion = 0; - _MaxPrimitiveCount = 0xffff; - _MaxVertexIndex = 0xffff; - _IsGeforce = false; - _NonPowerOfTwoTexturesSupported = false; - _MaxAnisotropy = 0; - _AnisotropicMinSupported = false; - _AnisotropicMagSupported = false; - _AnisotropicMinCubeSupported = false; - _AnisotropicMagCubeSupported = false; - } - // If 16 bits vertices only, build a vb for quads rendering - if (_MaxVertexIndex <= 0xffff) - { - if (!buildQuadIndexBuffer()) return false; - } - - // test for occlusion query support - IDirect3DQuery9 *dummyQuery = NULL; - if (_DeviceInterface->CreateQuery(D3DQUERYTYPE_OCCLUSION, &dummyQuery) == D3DERR_NOTAVAILABLE) - { - _OcclusionQuerySupported = false; - } - else - { - _OcclusionQuerySupported = true; - if (dummyQuery) dummyQuery->Release(); - } - - -#ifdef NL_FORCE_TEXTURE_STAGE_COUNT - _NbNeLTextureStages = min ((uint)NL_FORCE_TEXTURE_STAGE_COUNT, (uint)IDRV_MAT_MAXTEXTURES); -#endif // NL_FORCE_TEXTURE_STAGE_COUNT - - _VertexProgram = !_DisableHardwareVertexProgram && ((caps.VertexShaderVersion&0xffff) >= 0x0100); - _PixelProgramVersion = _DisableHardwareVertexProgram ? 0x0000 : caps.PixelShaderVersion & 0xffff; - nldebug("Pixel Program Version: %i.%i", (uint32)((_PixelProgramVersion & 0xFF00) >> 8), (uint32)(_PixelProgramVersion & 0xFF)); - _PixelProgram = _PixelProgramVersion >= 0x0101; - _MaxVerticesByVertexBufferHard = caps.MaxVertexIndex; - _MaxLight = caps.MaxActiveLights; - - if(_MaxLight > 0xFF) _MaxLight = 3; - - if (_PixelProgram) - { - _MaxNumPerStageConstantLighted = _NbNeLTextureStages; - _MaxNumPerStageConstantUnlighted = _NbNeLTextureStages; - } - else - { - // emulation of per stage constant through diffuse - _MaxNumPerStageConstantLighted = 1; - _MaxNumPerStageConstantUnlighted = 2; - } - - if (_DisableHardwarePixelShader && _NbNeLTextureStages > 3) // yes, 3 is not a bug - { - // If pixel shader are disabled, then can't emulate the texEnvColor feature with more than 2 stages. (only 2 constant available by using material emissive in addition to the texture factor) - // Radeon with 3 stages cases : let the third stage to ensure availability of the EMBM feature - // There is a special fix in CMaterial::isSupportedByDriver to force the number of stages to 2 for the radeons - _NbNeLTextureStages = 2; - } - - // *** Check textures caps - uint j; - uint i; - for (i=0; iinit (CVertexBuffer::RAMResident, NL_VOLATILE_RAM_VB_SIZE, NL_VOLATILE_RAM_VB_MAXSIZE, this); - _VolatileVertexBufferRAM[0]->reset (); - _VolatileVertexBufferRAM[1]->init (CVertexBuffer::RAMResident, NL_VOLATILE_RAM_VB_SIZE, NL_VOLATILE_RAM_VB_MAXSIZE, this); - _VolatileVertexBufferRAM[1]->reset (); - _VolatileVertexBufferAGP[0]->init (CVertexBuffer::AGPResident, NL_VOLATILE_AGP_VB_SIZE, (uint) (NL_VOLATILE_AGP_VB_MAXSIZE * maxAGPbufferSizeRatio), this); - _VolatileVertexBufferAGP[0]->reset (); - _VolatileVertexBufferAGP[1]->init (CVertexBuffer::AGPResident, NL_VOLATILE_AGP_VB_SIZE, (uint) (NL_VOLATILE_AGP_VB_MAXSIZE * maxAGPbufferSizeRatio), this); - _VolatileVertexBufferAGP[1]->reset (); - // - _VolatileIndexBuffer16RAM[0]->init (CIndexBuffer::RAMResident, NL_VOLATILE_RAM_IB_SIZE, NL_VOLATILE_RAM_IB_MAXSIZE, this, CIndexBuffer::Indices16); - _VolatileIndexBuffer16RAM[0]->reset (); - _VolatileIndexBuffer16RAM[1]->init (CIndexBuffer::RAMResident, NL_VOLATILE_RAM_IB_SIZE, NL_VOLATILE_RAM_IB_MAXSIZE, this, CIndexBuffer::Indices16); - _VolatileIndexBuffer16RAM[1]->reset (); - _VolatileIndexBuffer16AGP[0]->init (CIndexBuffer::AGPResident, NL_VOLATILE_AGP_IB_SIZE, (uint) (NL_VOLATILE_AGP_IB_MAXSIZE * maxAGPbufferSizeRatio), this, CIndexBuffer::Indices16); - _VolatileIndexBuffer16AGP[0]->reset (); - _VolatileIndexBuffer16AGP[1]->init (CIndexBuffer::AGPResident, NL_VOLATILE_AGP_IB_SIZE, (uint) (NL_VOLATILE_AGP_IB_MAXSIZE * maxAGPbufferSizeRatio), this, CIndexBuffer::Indices16); - _VolatileIndexBuffer16AGP[1]->reset (); - // 32 bits indices supported - if (_MaxVertexIndex > 0xffff) - { - _VolatileIndexBuffer32RAM[0]->init (CIndexBuffer::RAMResident, NL_VOLATILE_RAM_IB_SIZE, NL_VOLATILE_RAM_IB_MAXSIZE, this, CIndexBuffer::Indices32); - _VolatileIndexBuffer32RAM[0]->reset (); - _VolatileIndexBuffer32RAM[1]->init (CIndexBuffer::RAMResident, NL_VOLATILE_RAM_IB_SIZE, NL_VOLATILE_RAM_IB_MAXSIZE, this, CIndexBuffer::Indices32); - _VolatileIndexBuffer32RAM[1]->reset (); - _VolatileIndexBuffer32AGP[0]->init (CIndexBuffer::AGPResident, NL_VOLATILE_AGP_IB_SIZE, (uint) (NL_VOLATILE_AGP_IB_MAXSIZE * maxAGPbufferSizeRatio), this, CIndexBuffer::Indices32); - _VolatileIndexBuffer32AGP[0]->reset (); - _VolatileIndexBuffer32AGP[1]->init (CIndexBuffer::AGPResident, NL_VOLATILE_AGP_IB_SIZE, (uint) (NL_VOLATILE_AGP_IB_MAXSIZE * maxAGPbufferSizeRatio), this, CIndexBuffer::Indices32); - _VolatileIndexBuffer32AGP[1]->reset (); - } - // - setupViewport (CViewport()); - - - - // Begin now - //nldebug("BeginScene"); - if (!beginScene()) return false; - - // Done - return true; -} - -// *************************************************************************** -extern uint indexCount; -extern uint vertexCount; - -bool CDriverD3D::release() -{ - H_AUTO_D3D(CDriver3D_release); - // Call IDriver::release() before, to destroy textures, shaders and VBs... - IDriver::release(); - - ItShaderDrvInfoPtrList itshd; - while( (itshd = _ShaderDrvInfos.begin()) != _ShaderDrvInfos.end() ) - { - // NB: at IShader deletion, this->_MatDrvInfos is updated (entry deleted); - delete *itshd; - } - - _SwapBufferCounter = 0; - - if (_QuadIB) - { - _QuadIB->Release(); - _QuadIB = NULL; - } - - // delete queries - while (!_OcclusionQueryList.empty()) - { - deleteOcclusionQuery(_OcclusionQueryList.front()); - } - - // Back buffer ref - if (_BackBuffer) - _BackBuffer->Release(); - _BackBuffer = NULL; - - // Release all the vertex declaration - std::list::iterator ite = _VertexDeclarationList.begin(); - while (ite != _VertexDeclarationList.end()) - { - ite->VertexDecl->Release(); - ite++; - } - _VertexDeclarationList.clear (); - - // Release pixel shaders - _NormalPixelShaders[0].clear (); - _NormalPixelShaders[1].clear (); - - if( _DeviceInterface != NULL) - { - _DeviceInterface->Release(); - _DeviceInterface = NULL; - } - - if (_HWnd) - { - releaseCursors(); - - // make sure window icons are deleted - std::vector bitmaps; - setWindowIcon(bitmaps); - - if (_DestroyWindow) - DestroyWindow (_HWnd); - _HWnd = NULL; - } - - - nlassert (indexCount == 0); - nlassert (vertexCount == 0); - - // restore desktop gamma ramp - if (_DesktopGammaRampValid) - { - HDC dc = CreateDCW (L"DISPLAY", NULL, NULL, NULL); - if (dc) - { - SetDeviceGammaRamp (dc, _DesktopGammaRamp); - } - _DesktopGammaRampValid = false; - } - return true; -}; - -// *************************************************************************** - -emptyProc CDriverD3D::getWindowProc() -{ - return (emptyProc)D3DWndProc; -}; - -// *************************************************************************** - -IDriver::TMessageBoxId CDriverD3D::systemMessageBox (const char* message, const char* title, TMessageBoxType type, TMessageBoxIcon icon) -{ - switch (::MessageBoxW (_HWnd, utf8ToWide(message), utf8ToWide(title), ((type==retryCancelType)?MB_RETRYCANCEL: - (type==yesNoCancelType)?MB_YESNOCANCEL: - (type==okCancelType)?MB_OKCANCEL: - (type==abortRetryIgnoreType)?MB_ABORTRETRYIGNORE: - (type==yesNoType)?MB_YESNO|MB_ICONQUESTION:MB_OK)| - - ((icon==handIcon)?MB_ICONHAND: - (icon==questionIcon)?MB_ICONQUESTION: - (icon==exclamationIcon)?MB_ICONEXCLAMATION: - (icon==asteriskIcon)?MB_ICONASTERISK: - (icon==warningIcon)?MB_ICONWARNING: - (icon==errorIcon)?MB_ICONERROR: - (icon==informationIcon)?MB_ICONINFORMATION: - (icon==stopIcon)?MB_ICONSTOP:0))) - { - case IDOK: - return okId; - case IDCANCEL: - return cancelId; - case IDABORT: - return abortId; - case IDRETRY: - return retryId; - case IDIGNORE: - return ignoreId; - case IDYES: - return yesId; - case IDNO: - return noId; - } - return okId; -} - -// *************************************************************************** -bool CDriverD3D::activate() -{ - return true; -} - -// *************************************************************************** -bool CDriverD3D::isActive () -{ - return (IsWindow(_HWnd) != 0); -} - -// *************************************************************************** -nlWindow CDriverD3D::getDisplay() -{ - return _HWnd; -} - -// *************************************************************************** -NLMISC::IEventEmitter *CDriverD3D::getEventEmitter() -{ - return &_EventEmitter; -} - -// *************************************************************************** -void CDriverD3D::getWindowSize (uint32 &width, uint32 &height) -{ - H_AUTO_D3D(CDriverD3D_getWindowSize); - width = _CurrentMode.Width; - height = _CurrentMode.Height; -} - -// *************************************************************************** - -void CDriverD3D::getWindowPos (sint32 &x, sint32 &y) -{ - H_AUTO_D3D(CDriverD3D_getWindowPos); - x = _WindowX; - y = _WindowY; -} - -// *************************************************************************** -uint32 CDriverD3D::getImplementationVersion () const -{ - H_AUTO_D3D(CDriverD3D_getImplementationVersion); - return ReleaseVersion; -} - -// *************************************************************************** -const char *CDriverD3D::getDriverInformation () -{ - return "Directx 9 NeL Driver"; -} - -// *************************************************************************** -uint8 CDriverD3D::getBitPerPixel () -{ - return _CurrentMode.Depth; -} - -// *************************************************************************** -bool CDriverD3D::clear2D(CRGBA rgba) -{ - H_AUTO_D3D(CDriverD3D_clear2D); - nlassert (_DeviceInterface); - - // Backup viewport - CViewport oldViewport = _Viewport; - setupViewport (CViewport()); - updateRenderVariables (); - - bool result = _DeviceInterface->Clear( 0, NULL, D3DCLEAR_TARGET, NL_D3DCOLOR_RGBA(rgba), 1.0f, 0 ) == D3D_OK; - - // Restore the old viewport - setupViewport (oldViewport); - return result; -} - -// *************************************************************************** - -bool CDriverD3D::clearZBuffer(float zval) -{ - H_AUTO_D3D(CDriverD3D_clearZBuffer); - nlassert (_DeviceInterface); - - // Backup viewport - CViewport oldViewport = _Viewport; - setupViewport (CViewport()); - updateRenderVariables (); - - bool result = _DeviceInterface->Clear( 0, NULL, D3DCLEAR_ZBUFFER, D3DCOLOR_ARGB(0,0,0,0), zval, 0 ) == D3D_OK; - - // Restore the old viewport - setupViewport (oldViewport); - - // NVidia driver 56.72 needs to reset the vertex buffer after a clear Z - touchRenderVariable (&_VertexBufferCache); - - return result; -} - -// *************************************************************************** - -bool CDriverD3D::clearStencilBuffer(float stencilval) -{ - H_AUTO_D3D(CDriverD3D_clearStencilBuffer); - nlassert (_DeviceInterface); - - // Backup viewport - CViewport oldViewport = _Viewport; - setupViewport (CViewport()); - updateRenderVariables (); - - bool result = _DeviceInterface->Clear( 0, NULL, D3DCLEAR_STENCIL, D3DCOLOR_ARGB(0,0,0,0), 1.0f, (unsigned long)stencilval ) == D3D_OK; - - // Restore the old viewport - setupViewport (oldViewport); - - return result; -} - -// *************************************************************************** - -void CDriverD3D::setColorMask (bool bRed, bool bGreen, bool bBlue, bool bAlpha) -{ - H_AUTO_D3D(CDriverD3D_setColorMask); - setRenderState (D3DRS_COLORWRITEENABLE, - (bAlpha?D3DCOLORWRITEENABLE_ALPHA:0)| - (bRed?D3DCOLORWRITEENABLE_RED:0)| - (bGreen?D3DCOLORWRITEENABLE_GREEN:0)| - (bBlue?D3DCOLORWRITEENABLE_BLUE:0) - ); -} - - - - -// *************************************************************************** -bool CDriverD3D::swapBuffers() -{ - //DUMP_AUTO(swapBuffers); - H_AUTO_D3D(CDriverD3D_swapBuffers); - nlassert (_DeviceInterface); - - ++ _SwapBufferCounter; - // Swap & reset volatile buffers - _CurrentRenderPass++; - _VolatileVertexBufferRAM[_CurrentRenderPass&1]->reset (); - _VolatileVertexBufferAGP[_CurrentRenderPass&1]->reset (); - _VolatileIndexBuffer16RAM[_CurrentRenderPass&1]->reset (); - _VolatileIndexBuffer16AGP[_CurrentRenderPass&1]->reset (); - _VolatileIndexBuffer32RAM[_CurrentRenderPass&1]->reset (); - _VolatileIndexBuffer32AGP[_CurrentRenderPass&1]->reset (); - - // todo hulud volatile - //_DeviceInterface->SetStreamSource(0, _VolatileVertexBufferRAM[1]->VertexBuffer, 0, 12); - - // End now - if (!endScene()) - { - nlstop; - return false; - } - - HRESULT result = _DeviceInterface->Present( NULL, NULL, NULL, NULL); - if (result != D3D_OK) - { - // Device lost ? - if (result == D3DERR_DEVICELOST) - { - _Lost = true; - // check if we can exit lost state - if (_DeviceInterface->TestCooperativeLevel() == D3DERR_DEVICENOTRESET) - { - // Reset the driver - reset (_CurrentMode); - } - } - } - - // Check window size - handlePossibleSizeChange (); - - // Reset the profiling counter. - _PrimitiveProfileIn.reset(); - _PrimitiveProfileOut.reset(); - _NbSetupMaterialCall= 0; - _NbSetupModelMatrixCall= 0; - - // Reset the texture set - _TextureUsed.clear(); - - // Reset vertex program - setVertexProgram (NULL, NULL); - // Reset pixel program - setPixelShader (NULL); - - if (_VBHardProfiling) - { - ++_NumVBHardProfileFrame; - } - if (_IBProfiling) - { - ++ _NumIBProfileFrame; - } - - // Begin now - return beginScene(); -}; - -// *************************************************************************** - -void CDriverD3D::setPolygonMode (TPolygonMode mode) -{ - H_AUTO_D3D(CDriverD3D_setPolygonMode); - IDriver::setPolygonMode (mode); - - setRenderState (D3DRS_FILLMODE, mode==Point?D3DFILL_POINT:mode==Line?D3DFILL_WIREFRAME:D3DFILL_SOLID); -} - -// *************************************************************************** - -bool CDriverD3D::isTextureFormatOk(UINT adapter, D3DDEVTYPE rasterizer, D3DFORMAT TextureFormat, D3DFORMAT AdapterFormat) -{ - H_AUTO_D3D(CDriverD3D_isTextureFormatOk); - HRESULT hr = _D3D->CheckDeviceFormat( adapter, - rasterizer, - AdapterFormat, - 0, - D3DRTYPE_TEXTURE, - TextureFormat); - - return SUCCEEDED( hr ) != FALSE; -} - -// *************************************************************************** - -void CDriverD3D::forceDXTCCompression(bool dxtcComp) -{ - H_AUTO_D3D(CDriverD3D_forceDXTCCompression); - _ForceDXTCCompression = dxtcComp; -} - -// *************************************************************************** - -void CDriverD3D::setAnisotropicFilter(sint filter) -{ - H_AUTO_D3D(CDriverD3D_setAnisotropicFilter); - - // anisotropic filter not supported - if (_MaxAnisotropy < 2) return; - - if (filter < 0 || filter > _MaxAnisotropy) - { - _AnisotropicFilter = _MaxAnisotropy; - } - else - { - _AnisotropicFilter = filter; - } -} - -// *************************************************************************** - -uint CDriverD3D::getAnisotropicFilter() const -{ - H_AUTO_D3D(CDriverD3D_getAnisotropicFilter); - - return _AnisotropicFilter; -} - -// *************************************************************************** - -uint CDriverD3D::getAnisotropicFilterMaximum() const -{ - H_AUTO_D3D(CDriverD3D_getAnisotropicFilterMaximum); - - return _MaxAnisotropy; -} - -// *************************************************************************** - -void CDriverD3D::forceTextureResize(uint divisor) -{ - H_AUTO_D3D(CDriverD3D_forceTextureResize); - clamp(divisor, 1U, 256U); - - // 16 -> 4. - _ForceTextureResizePower= getPowerOf2(divisor); -} - -// *************************************************************************** - -bool CDriverD3D::fogEnabled() -{ - H_AUTO_D3D(CDriverD3D_fogEnabled); - // Return _RenderStateCache[D3DRS_FOGENABLE].Value == TRUE; - // Nico Patch : must return the _FogEnabled value here, because it MAY be - // different of the one found in _RenderStateCache[D3DRS_FOGENABLE] - // this happens for example when dest blend is one : the actual content of _RenderStateCache[D3DRS_FOGENABLE] - // is then restored when current material alpha blending settings are modified, or when a new material is set. - return _FogEnabled; -} - -// *************************************************************************** - -void CDriverD3D::enableFog(bool enable) -{ - H_AUTO_D3D(CDriverD3D_enableFog); - _FogEnabled = enable; - setRenderState (D3DRS_FOGENABLE, enable?TRUE:FALSE); -} - -// *************************************************************************** - -void CDriverD3D::setupFog(float start, float end, CRGBA color) -{ - H_AUTO_D3D(CDriverD3D_setupFog); - // Remember fog start and end - _FogStart = start; - _FogEnd = end; - _FogColor = NL_D3DCOLOR_RGBA(color); - - // Set the fog - setRenderState (D3DRS_FOGCOLOR, _FogColor); - setRenderState (D3DRS_FOGSTART, *((DWORD*) (&_FogStart))); - setRenderState (D3DRS_FOGEND, *((DWORD*) (&_FogEnd))); -} - -// *************************************************************************** - -float CDriverD3D::getFogStart() const -{ - return _FogStart; -} - -// *************************************************************************** - -float CDriverD3D::getFogEnd() const -{ - return _FogEnd; -} - -// *************************************************************************** - -CRGBA CDriverD3D::getFogColor() const -{ - return D3DCOLOR_NL_RGBA(_RenderStateCache[D3DRS_FOGCOLOR].Value); -} - -// *************************************************************************** - -CVertexBuffer::TVertexColorType CDriverD3D::getVertexColorFormat() const -{ - return CVertexBuffer::TBGRA; -} - -// *************************************************************************** - -uint CDriverD3D::getNbTextureStages() const -{ - return _NbNeLTextureStages; -} - -// *************************************************************************** - -bool CDriverD3D::getModes(std::vector &modes) -{ - H_AUTO_D3D(CDriverD3D_getModes); - static const D3DFORMAT format[]= - { - D3DFMT_A8R8G8B8, - D3DFMT_X8R8G8B8, - D3DFMT_R8G8B8, - D3DFMT_A1R5G5B5, - D3DFMT_R5G6B5, - }; - static const uint8 depth[]= - { - 32, - 32, - 24, - 16, - 16, - }; - uint f; - for (f=0; fGetAdapterModeCount(adapter, format[f]); - uint i; - for (i=0; iEnumAdapterModes( adapter, format[f], i, &mode) == D3D_OK) - { - GfxMode gfxMode; - gfxMode.Windowed=false; - gfxMode.Width=(uint16)mode.Width; - gfxMode.Height=(uint16)mode.Height; - gfxMode.Depth=depth[f]; - gfxMode.Frequency=(uint8)mode.RefreshRate; - modes.push_back (gfxMode); - } - } - } - return true; -} - -// *************************************************************************** -bool CDriverD3D::getCurrentScreenMode(GfxMode &gfxMode) -{ - H_AUTO_D3D(CDriverD3D_getCurrentScreenMode); - UINT adapter = (_Adapter==0xffffffff)?D3DADAPTER_DEFAULT:(UINT)_Adapter; - D3DDISPLAYMODE mode; - _D3D->GetAdapterDisplayMode(adapter, &mode); - gfxMode.Windowed = !_FullScreen; - gfxMode.Width = (uint16)mode.Width; - gfxMode.Height = (uint16)mode.Height; - gfxMode.Depth = ((mode.Format==D3DFMT_A8R8G8B8)||(mode.Format==D3DFMT_X8R8G8B8))?32:16; - gfxMode.Frequency = (uint8)mode.RefreshRate; - - return true; -} - -// *************************************************************************** -void CDriverD3D::setWindowTitle(const ucstring &title) -{ - if (!SetWindowTextW(_HWnd, (WCHAR*)title.c_str())) - { - nlwarning("SetWindowText failed: %s", formatErrorMessage(getLastError()).c_str()); - } -} - -// *************************************************************************** -void CDriverD3D::setWindowIcon(const std::vector &bitmaps) -{ - if (!_HWnd) - return; - - static HICON winIconBig = NULL; - static HICON winIconSmall = NULL; - - if (winIconBig) - { - DestroyIcon(winIconBig); - winIconBig = NULL; - } - - if (winIconSmall) - { - DestroyIcon(winIconSmall); - winIconSmall = NULL; - } - - sint smallIndex = -1; - uint smallWidth = GetSystemMetrics(SM_CXSMICON); - uint smallHeight = GetSystemMetrics(SM_CYSMICON); - - sint bigIndex = -1; - uint bigWidth = GetSystemMetrics(SM_CXICON); - uint bigHeight = GetSystemMetrics(SM_CYICON); - - // find icons with the exact size - for(uint i = 0; i < bitmaps.size(); ++i) - { - if (smallIndex == -1 && bitmaps[i].getWidth() == smallWidth && bitmaps[i].getHeight() == smallHeight) - smallIndex = i; - - if (bigIndex == -1 && bitmaps[i].getWidth() == bigWidth && bitmaps[i].getHeight() == bigHeight) - bigIndex = i; - } - - // find icons with taller size (we will resize them) - for(uint i = 0; i < bitmaps.size(); ++i) - { - if (smallIndex == -1 && bitmaps[i].getWidth() >= smallWidth && bitmaps[i].getHeight() >= smallHeight) - smallIndex = i; - - if (bigIndex == -1 && bitmaps[i].getWidth() >= bigWidth && bitmaps[i].getHeight() >= bigHeight) - bigIndex = i; - } - - if (smallIndex > -1) - convertBitmapToIcon(bitmaps[smallIndex], winIconSmall, smallWidth, smallHeight, 32); - - if (bigIndex > -1) - convertBitmapToIcon(bitmaps[bigIndex], winIconBig, bigWidth, bigHeight, 32); - - if (winIconBig) - { - SendMessageA(_HWnd, WM_SETICON, 0 /* ICON_SMALL */, (LPARAM)winIconSmall); - SendMessageA(_HWnd, WM_SETICON, 1 /* ICON_BIG */, (LPARAM)winIconBig); - } - else - { - SendMessageA(_HWnd, WM_SETICON, 0 /* ICON_SMALL */, (LPARAM)winIconSmall); - SendMessageA(_HWnd, WM_SETICON, 1 /* ICON_BIG */, (LPARAM)winIconSmall); - } -} - -// *************************************************************************** -void CDriverD3D::setWindowPos(sint32 x, sint32 y) -{ - _WindowX = x; - _WindowY = y; - SetWindowPos(_HWnd, NULL, _WindowX, _WindowY, 0, 0, SWP_NOZORDER | SWP_NOACTIVATE | SWP_NOSIZE); -} - -// *************************************************************************** -void CDriverD3D::showWindow(bool show) -{ - ShowWindow (_HWnd, show ? SW_SHOW:SW_HIDE); -} - -// *************************************************************************** - -uint CDriverD3D::getNumAdapter() const -{ -H_AUTO_D3D(CDriverD3D_getNumAdapter); - if (_D3D) - return _D3D->GetAdapterCount(); - else - return 0; -} - -// *************************************************************************** - -bool CDriverD3D::getAdapter(uint adapter, IDriver::CAdapter &desc) const -{ - H_AUTO_D3D(CDriverD3D_getAdapter); - if (_D3D) - { - D3DADAPTER_IDENTIFIER9 identifier; - UINT _adapter = (adapter==0xffffffff)?D3DADAPTER_DEFAULT:(UINT)adapter; - if (_D3D->GetAdapterIdentifier(_adapter, 0, &identifier) == D3D_OK) - { - desc.Description = identifier.Description; - desc.DeviceId = identifier.DeviceId; - desc.DeviceName = identifier.DeviceName; - desc.Driver = identifier.Driver; - desc.DriverVersion = (((sint64)identifier.DriverVersion.HighPart<<32))|(sint64)identifier.DriverVersion.LowPart; - desc.Revision = identifier.Revision; - desc.SubSysId = identifier.SubSysId; - desc.VendorId = identifier.VendorId; - desc.VideoMemory = _Adapter == _adapter ? getTotalVideoMemory():-1; - return true; - } - } - return false; -} - -// *************************************************************************** - -bool CDriverD3D::setAdapter(uint adapter) -{ - H_AUTO_D3D(CDriverD3D_setAdapter); - if (_D3D) - { - D3DDISPLAYMODE adapterMode; - UINT _adapter = (adapter==0xffffffff)?D3DADAPTER_DEFAULT:(UINT)adapter; - if (_D3D->GetAdapterDisplayMode (_adapter, &adapterMode) != D3D_OK) - { - nlwarning ("CDriverD3D::setDisplay: GetAdapterDisplayMode failed"); - release(); - return false; - } - _Adapter = adapter; - return true; - } - return false; -} - -// *************************************************************************** - -bool CDriverD3D::supportMADOperator() const -{ - H_AUTO_D3D(CDriverD3D_supportMADOperator); - if (_DeviceInterface) - { - return _MADOperatorSupported; - } - return false; // don't know.. -} - -// *************************************************************************** - -bool CDriverD3D::setMode (const GfxMode& mode) -{ - H_AUTO_D3D(CDriverD3D_setMode); - - // if fullscreen - if(!mode.Windowed) - { - // Must check if mode exist, else crash at reset() time - std::vector modes; - if(getModes(modes)) - { - bool found= false; - for(uint i=0;iIndexBufferPtr; - // If resident in RAM, content has not been lost - if (ib->getLocation () != CIndexBuffer::RAMResident) - { - // Realloc local memory - ib->setLocation (CIndexBuffer::NotResident); - delete indexBuffer; - } -} - - -// *************************************************************************** -bool CDriverD3D::reset (const GfxMode& mode) -{ - //DUMP_AUTO(reset); - H_AUTO_D3D(CDriverD3D_reset); - if (_DeviceInterface->TestCooperativeLevel() == D3DERR_DEVICELOST) return false; - - // Choose an adapter - UINT adapter = (_Adapter==0xffffffff)?D3DADAPTER_DEFAULT:(UINT)_Adapter; - - // Get adapter format - D3DDISPLAYMODE adapterMode; - if (_D3D->GetAdapterDisplayMode (adapter, &adapterMode) != D3D_OK) - { - nlwarning ("CDriverD3D::reset: GetAdapterDisplayMode failed"); - release(); - return false; - } - - // Do the reset - // Increment the IDriver reset counter - - D3DPRESENT_PARAMETERS parameters; - D3DFORMAT adapterFormat; - if (!fillPresentParameter (parameters, adapterFormat, mode, adapterMode)) - return false; - - // Current mode - _CurrentMode = mode; - _CurrentMaterial = NULL; - _CurrentMaterialInfo = NULL; - - // Restore non managed vertex buffer in system memory - ItVBDrvInfoPtrList iteVb = _VBDrvInfos.begin(); - while (iteVb != _VBDrvInfos.end()) - { - ItVBDrvInfoPtrList iteVbNext = iteVb; - iteVbNext++; - - CVBDrvInfosD3D *vertexBuffer = static_cast(*iteVb); - CVertexBuffer *vb = vertexBuffer->VertexBufferPtr; - - // If resident in RAM, content has not been lost - if (vb->getLocation () != CVertexBuffer::RAMResident) - { - // Realloc local memory - vb->setLocation (CVertexBuffer::NotResident); // If resident in RAM, content backuped by setLocation - delete vertexBuffer; - } - - iteVb = iteVbNext; - } - - // Restore non managed index buffer in system memory - ItIBDrvInfoPtrList iteIb = _IBDrvInfos.begin(); - while (iteIb != _IBDrvInfos.end()) - { - ItIBDrvInfoPtrList iteIbNext = iteIb; - iteIbNext++; - deleteIndexBuffer(static_cast(*iteIb)); - iteIb = iteIbNext; - } - deleteIndexBuffer(static_cast((IIBDrvInfos *) _QuadIndexesAGP.DrvInfos)); - - // Remove render targets - ItTexDrvSharePtrList ite = _TexDrvShares.begin(); - while (ite != _TexDrvShares.end()) - { - ItTexDrvSharePtrList iteNext = ite; - iteNext++; - - // Render target ? - nlassert ((*ite)->DrvTexture != NULL); - CTextureDrvInfosD3D *info = static_cast(static_cast((*ite)->DrvTexture)); - if (info->RenderTarget) - { - // Remove it - delete *ite; - } - ite = iteNext; - } - - // Free volatile buffers - _VolatileVertexBufferRAM[0]->release (); - _VolatileVertexBufferRAM[1]->release (); - _VolatileVertexBufferAGP[0]->release (); - _VolatileVertexBufferAGP[1]->release (); - _VolatileIndexBuffer16RAM[0]->release (); - _VolatileIndexBuffer16RAM[1]->release (); - _VolatileIndexBuffer16AGP[0]->release (); - _VolatileIndexBuffer16AGP[1]->release (); - _VolatileIndexBuffer32RAM[0]->release (); - _VolatileIndexBuffer32RAM[1]->release (); - _VolatileIndexBuffer32AGP[0]->release (); - _VolatileIndexBuffer32AGP[1]->release (); - - // Back buffer ref - if (_BackBuffer) - _BackBuffer->Release(); - _BackBuffer = NULL; - - // Invalidate all occlusion queries. - // TODO nico : for now, even if a result has been retrieved successfully by the query, the query is put in the lost state. See if its worth improving... - for(TOcclusionQueryList::iterator it = _OcclusionQueryList.begin(); it != _OcclusionQueryList.end(); ++it) - { - if ((*it)->Query) - { - (*it)->WasLost = true; - (*it)->Query->Release(); - (*it)->Query = NULL; - } - } - - // Release internal shaders - //releaseInternalShaders(); - - - notifyAllShaderDrvOfLostDevice(); - - - - /* Do not reset if reset will fail */ - _ResetCounter++; - bool sceneBegun = hasSceneBegun(); - if (sceneBegun) - { - //nldebug("EndScene"); - endScene(); - } - - // delete all .fx caches - for(TMatDrvInfoPtrList::iterator it = _MatDrvInfos.begin(); it != _MatDrvInfos.end(); ++it) - { - CMaterialDrvInfosD3D *mi = NLMISC::safe_cast(*it); - if (mi->FXCache) - { - mi->FXCache->reset(); - } - } - - { -#ifndef NL_NO_ASM - CFpuRestorer fpuRestorer; // fpu control word is changed by "Reset" -#endif - if (_Rasterizer!=D3DDEVTYPE_REF) - { - HRESULT hr = _DeviceInterface->Reset (¶meters); - if (hr != D3D_OK) - { - nlwarning("CDriverD3D::reset: Reset on _DeviceInterface error 0x%x", hr); - // tmp - nlstopex(("CDriverD3D::reset: Reset on _DeviceInterface")); - return false; - } - } - } - - _Lost = false; - // BeginScene now - if (sceneBegun) - { - //nldebug("BeginScene"); - beginScene(); - } - - notifyAllShaderDrvOfResetDevice(); - - // Reset internal caches - resetRenderVariables(); - - // Init shaders - //initInternalShaders(); - - // reallocate occlusion queries - for(TOcclusionQueryList::iterator it = _OcclusionQueryList.begin(); it != _OcclusionQueryList.end(); ++it) - { - if (!(*it)->Query) - { - _DeviceInterface->CreateQuery(D3DQUERYTYPE_OCCLUSION, &(*it)->Query); - } - } - return true; -} - -// *************************************************************************** - -bool CDriverD3D::fillPresentParameter (D3DPRESENT_PARAMETERS ¶meters, D3DFORMAT &adapterFormat, const GfxMode& mode, const D3DDISPLAYMODE &adapterMode) -{ - UINT adapter = (_Adapter==0xffffffff)?D3DADAPTER_DEFAULT:(UINT)_Adapter; - H_AUTO_D3D(CDriverD3D_fillPresentParameter); - memset (¶meters, 0, sizeof(D3DPRESENT_PARAMETERS)); - parameters.BackBufferWidth = mode.Width; - parameters.BackBufferHeight = mode.Height; - parameters.BackBufferCount = 1; - parameters.MultiSampleType = D3DMULTISAMPLE_NONE; - parameters.MultiSampleQuality = 0; - parameters.SwapEffect = D3DSWAPEFFECT_DISCARD; - parameters.hDeviceWindow = NULL; - parameters.Windowed = mode.Windowed; - parameters.EnableAutoDepthStencil = TRUE; - parameters.FullScreen_RefreshRateInHz = mode.Windowed?0:mode.Frequency; - switch (_Interval) - { - case 0: - parameters.PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE; - break; - case 1: - parameters.PresentationInterval = D3DPRESENT_INTERVAL_ONE; - break; - case 2: - parameters.PresentationInterval = D3DPRESENT_INTERVAL_TWO; - break; - case 3: - parameters.PresentationInterval = D3DPRESENT_INTERVAL_THREE; - break; - default: - parameters.PresentationInterval = D3DPRESENT_INTERVAL_FOUR; - break; - } - - // Build a depth index - const uint depthIndex = (mode.Depth==16)?0:(mode.Depth==24)?1:2; - - // Choose a back buffer format - const uint numFormat = 4; - D3DFORMAT backBufferFormats[3][numFormat]= - { - {D3DFMT_R5G6B5, D3DFMT_A1R5G5B5, D3DFMT_X1R5G5B5, D3DFMT_A4R4G4B4}, - {D3DFMT_R8G8B8, D3DFMT_A8R8G8B8, D3DFMT_X8R8G8B8, D3DFMT_X8R8G8B8}, - {D3DFMT_A8R8G8B8, D3DFMT_X8R8G8B8, D3DFMT_X8R8G8B8, D3DFMT_X8R8G8B8}, - }; - bool found = false; - if (mode.Windowed) - { - uint backBuffer; - for (backBuffer=0; backBufferCheckDeviceType(adapter, _Rasterizer, adapterMode.Format, backBufferFormats[depthIndex][backBuffer], TRUE) == D3D_OK) - { - parameters.BackBufferFormat = backBufferFormats[depthIndex][backBuffer]; - adapterFormat = adapterMode.Format; - found = true; - break; - } - } - } - else - { - // Found a pair display and back buffer format - uint backBuffer; - for (backBuffer=0; backBufferCheckDeviceType(adapter, _Rasterizer, backBufferFormats[depthIndex][display], backBufferFormats[depthIndex][display], FALSE) == D3D_OK) - { - parameters.BackBufferFormat = backBufferFormats[depthIndex][backBuffer]; - adapterFormat = backBufferFormats[depthIndex][display]; - found = true; - break; - } - } - if (found) - break; - } - } - - // Not found ? - if (!found) - { - nlwarning ("Can't create backbuffer"); - return false; - } - - // Choose a zbuffer format - D3DFORMAT zbufferFormats[]= - { - //uncomment to save zbuffer D3DFMT_D32F_LOCKABLE, - //uncomment to save zbuffer D3DFMT_D16_LOCKABLE, - /*D3DFMT_D32, - D3DFMT_D24X8,*/ - D3DFMT_D24S8, - D3DFMT_D24X4S4, - D3DFMT_D24FS8, - //D3DFMT_D16, - }; - - const uint zbufferFormatCount = sizeof(zbufferFormats)/sizeof(D3DFORMAT); - uint i; - for (i=0; i=zbufferFormatCount) - { - nlwarning ("Can't create zbuffer"); - return false; - } - - // Set the zbuffer format - parameters.AutoDepthStencilFormat = zbufferFormats[i]; - - if(mode.AntiAlias == -1) - { - parameters.Flags |= D3DPRESENTFLAG_LOCKABLE_BACKBUFFER; - } - else - { - DWORD aa = 0; - if(mode.AntiAlias == 0) - { - if(SUCCEEDED(_D3D->CheckDeviceMultiSampleType(adapter, _Rasterizer, adapterFormat, mode.Windowed, D3DMULTISAMPLE_NONMASKABLE, &aa))) - { - parameters.MultiSampleType = D3DMULTISAMPLE_NONMASKABLE; - parameters.MultiSampleQuality = aa - 1; - nlinfo("Use AntiAlias with %d sample", aa); - } - else - { - nlwarning("No AntiAlias support found"); - } - } - else - { - parameters.MultiSampleType = D3DMULTISAMPLE_NONMASKABLE; - parameters.MultiSampleQuality = mode.AntiAlias - 1; - nlinfo("Use AntiAlias with %d sample", mode.AntiAlias); - } - } - - return true; -} - -// *************************************************************************** - -const char *CDriverD3D::getVideocardInformation () -{ - H_AUTO_D3D(CDriverD3D_getVideocardInformation); - static char name[1024]; - -// if (!_DeviceInterface) -// return "Direct3d isn't initialized"; - - D3DADAPTER_IDENTIFIER9 identifier; - UINT adapter = (_Adapter==0xffffffff)?D3DADAPTER_DEFAULT:(UINT)_Adapter; - if (_D3D->GetAdapterIdentifier(adapter, 0, &identifier) == D3D_OK) - { - uint64 version = ((uint64)identifier.DriverVersion.HighPart) << 32; - version |= identifier.DriverVersion.LowPart; - smprintf (name, 1024, "Direct3d / %s / %s / %s / driver version : %d.%d.%d.%d", identifier.Driver, identifier.Description, identifier.DeviceName, - (uint16)((version>>48)&0xFFFF),(uint16)((version>>32)&0xFFFF),(uint16)((version>>16)&0xFFFF),(uint16)(version&0xffff)); - return name; - } - else - return "Can't get video card information"; -} - -// *************************************************************************** - -sint CDriverD3D::getTotalVideoMemory () const -{ - H_AUTO_D3D(CDriverD3D_getTotalVideoMemory); - - // Can't use _DeviceInterface->GetAvailableTextureMem() because it's not reliable - // Returns 4 GiB instead of 2 with my GPU - return -1; -} - -// *************************************************************************** - -void CDriverD3D::getBuffer (CBitmap &bitmap) -{ - H_AUTO_D3D(CDriverD3D_getBuffer); - NLMISC::CRect rect; - rect.setWH (0, 0, _CurrentMode.Width, _CurrentMode.Height); - getBufferPart (bitmap, rect); -} - -// *************************************************************************** - -void CDriverD3D::getBufferPart (CBitmap &bitmap, NLMISC::CRect &rect) -{ - H_AUTO_D3D(CDriverD3D_getBufferPart); - if (_DeviceInterface) - { - // Resize the bitmap - const uint lineCount = rect.Height; - const uint width = rect.Width; - bitmap.resize (width, lineCount, CBitmap::RGBA); - - // Lock the back buffer - IDirect3DSurface9 *surface; - if (_DeviceInterface->GetBackBuffer (0, 0, D3DBACKBUFFER_TYPE_MONO, &surface) == D3D_OK) - { - // Surface desc - D3DSURFACE_DESC desc; - if (surface->GetDesc(&desc) == D3D_OK) - { - // 32 bits format supported - if ((desc.Format == D3DFMT_R8G8B8) || - (desc.Format == D3DFMT_A8R8G8B8) || - (desc.Format == D3DFMT_X8R8G8B8) || - (desc.Format == D3DFMT_A8B8G8R8) || - (desc.Format == D3DFMT_X8B8G8R8)) - { - // Invert RGBA ? - bool invertRGBA = (desc.Format == D3DFMT_R8G8B8) || (desc.Format == D3DFMT_A8R8G8B8) || (desc.Format == D3DFMT_X8R8G8B8); - - // Lock the surface - D3DLOCKED_RECT lock; - ::RECT winRect; - winRect.left = rect.left(); - winRect.right = rect.right(); - winRect.top = rect.top(); - winRect.bottom = rect.bottom(); - if (surface->LockRect (&lock, &winRect, D3DLOCK_READONLY) == D3D_OK) - { - // Line count - uint8 *dest = &(bitmap.getPixels ()[0]); - uint i; - for (i=0; iUnlockRect (); - } - } - } - - surface->Release(); - } - } -} - -// *************************************************************************** - -IDirect3DSurface9 * CDriverD3D::getSurfaceTexture(ITexture * text) -{ - if(!text) - { - if(!_BackBuffer) - { - updateRenderVariables (); - _DeviceInterface->GetRenderTarget (0, &_BackBuffer); - } - nlassert(_BackBuffer); - return _BackBuffer; - } - - if(text->TextureDrvShare==NULL || text->TextureDrvShare->DrvTexture.getPtr()==NULL) - { - text->setRenderTarget(true); - setupTexture(*text); - } - CTextureDrvInfosD3D* rdvInfosD3D = (NLMISC::safe_cast(text->TextureDrvShare->DrvTexture.getPtr())); - - IDirect3DTexture9 * texture = rdvInfosD3D->Texture2d; - nlassert(texture); - - IDirect3DSurface9 * surface; - HRESULT hr = texture->GetSurfaceLevel(0, &surface); - nlassert(hr==D3D_OK); - - return surface; -} - -void CDriverD3D::getDirect3DRect(NLMISC::CRect &rect, RECT & d3dRect) -{ - d3dRect.left = rect.left(); - d3dRect.top = rect.top(); - d3dRect.right = rect.right(); - d3dRect.bottom = rect.bottom(); - - uint32 w, h; - getWindowSize(w, h); - - if(d3dRect.top>(sint32)h) - d3dRect.top = h; - - if(d3dRect.right>(sint32)w) - d3dRect.right = w; - - if(d3dRect.bottom<0) - d3dRect.bottom = 0; - - if(d3dRect.left<0) - d3dRect.left = 0; -} - -bool CDriverD3D::stretchRect(ITexture * srcText, NLMISC::CRect &srcRect, ITexture * destText, NLMISC::CRect &destRect) -{ - H_AUTO_D3D(CDriverD3D_stretchRect); - if (_DeviceInterface) - { - IDirect3DSurface9 * srcSurface = getSurfaceTexture(srcText); - IDirect3DSurface9 * destSurface = getSurfaceTexture(destText); - - D3DTEXTUREFILTERTYPE filterType = D3DTEXF_LINEAR; - - RECT srcD3DRect; - RECT destD3DRect; - getDirect3DRect(srcRect, srcD3DRect); - getDirect3DRect(destRect, destD3DRect); - - HRESULT hr = _DeviceInterface->StretchRect(srcSurface, &srcD3DRect, destSurface, &destD3DRect, filterType); - - srcSurface->Release(); - destSurface->Release(); - - return (hr==D3D_OK); - } - - return false; -} - -// *************************************************************************** - -bool CDriverD3D::supportBloomEffect() const -{ - return supportVertexProgram(CVertexProgram::nelvp); -} - -// *************************************************************************** - -bool CDriverD3D::supportNonPowerOfTwoTextures() const -{ - return _NonPowerOfTwoTexturesSupported; -} - -// *************************************************************************** - -bool CDriverD3D::fillBuffer (NLMISC::CBitmap &bitmap) -{ - H_AUTO_D3D(CDriverD3D_fillBuffer); - bool result = false; - if (_DeviceInterface) - { - // Resize the bitmap - const uint lineCount = _CurrentMode.Height; - const uint width = _CurrentMode.Width; - if ((bitmap.getWidth() == width) && (bitmap.getHeight() == lineCount)) - { - // Lock the back buffer - IDirect3DSurface9 *surface; - if (_DeviceInterface->GetBackBuffer (0, 0, D3DBACKBUFFER_TYPE_MONO, &surface) == D3D_OK) - { - // Surface desc - D3DSURFACE_DESC desc; - if (surface->GetDesc(&desc) == D3D_OK) - { - // 32 bits format supported - if ((desc.Format == D3DFMT_R8G8B8) || - (desc.Format == D3DFMT_A8R8G8B8) || - (desc.Format == D3DFMT_X8R8G8B8) || - (desc.Format == D3DFMT_A8B8G8R8) || - (desc.Format == D3DFMT_X8B8G8R8)) - { - // Invert RGBA ? - bool invertRGBA = (desc.Format == D3DFMT_R8G8B8) || (desc.Format == D3DFMT_A8R8G8B8) || (desc.Format == D3DFMT_X8R8G8B8); - - // Lock the surface - D3DLOCKED_RECT lock; - ::RECT winRect; - winRect.left = 0; - winRect.right = width; - winRect.top = 0; - winRect.bottom = lineCount; - if (surface->LockRect (&lock, &winRect, 0) == D3D_OK) - { - // Line count - uint8 *dest = &(bitmap.getPixels ()[0]); - uint i; - for (i=0; iUnlockRect (); - result = true; - } - } - } - - surface->Release(); - } - } - } - return result; -} - -// *************************************************************************** - -void CDriverD3D::setSwapVBLInterval(uint interval) -{ - H_AUTO_D3D(CDriverD3D_setSwapVBLInterval); - if (_Interval != interval) - { - _Interval = interval; - - // Must do a reset because the vsync parameter is choosed in the D3DPRESENT structure - if (_DeviceInterface) - reset (_CurrentMode); - } -} - -// *************************************************************************** - -uint CDriverD3D::getSwapVBLInterval() -{ - H_AUTO_D3D(CDriverD3D_getSwapVBLInterval); - return _Interval; -} - -// *************************************************************************** -void CDriverD3D::finish() -{ - // TODO : actually do not wait until everythin is rendered - H_AUTO_D3D(CDriverD3D_finish); - // Flush now - //nldebug("EndScene"); - endScene(); - //nldebug("BeginScene"); - beginScene(); -} - -// *************************************************************************** -void CDriverD3D::flush() -{ - H_AUTO_D3D(CDriverD3D_finish); - // Flush now - //nldebug("EndScene"); - endScene(); - //nldebug("BeginScene"); - beginScene(); -} - -// *************************************************************************** - -bool CDriverD3D::setMonitorColorProperties (const CMonitorColorProperties &properties) -{ - /* - H_AUTO_D3D(CDriverD3D_setMonitorColorProperties); - // The ramp - D3DGAMMARAMP ramp; - - // For each composant - uint c; - for( c=0; c<3; c++ ) - { - WORD *table = (c==0)?ramp.red:(c==1)?ramp.green:ramp.blue; - uint i; - for( i=0; i<256; i++ ) - { - // Floating value - float value = (float)i / 256; - - // Contrast - value = (float) max (0.0f, (value-0.5f) * (float) pow (3.f, properties.Contrast[c]) + 0.5f ); - - // Gamma - value = (float) pow (value, (properties.Gamma[c]>0) ? 1 - 3 * properties.Gamma[c] / 4 : 1 - properties.Gamma[c] ); - - // Luminosity - value = value + properties.Luminosity[c] / 2.f; - table[i] = min (65535, max (0, (int)(value * 65535))); - } - } - - // Set the ramp - _DeviceInterface->SetGammaRamp (0, D3DSGR_NO_CALIBRATION, &ramp); - return true; - */ - - // TODO nico - // It would be better to apply the gamma ramp only to the window and not to the whole desktop when playing in windowed mode. - // This require to switch to D3D 9.0c which has a flag for that purpose in the 'Present' function. - // Currently the SetGammaRamp only works in fullscreen mode, so we rely to the classic 'SetDeviceGammaRamp' instead. - HDC dc = CreateDCW (L"DISPLAY", NULL, NULL, NULL); - if (dc) - { - // The ramp - WORD ramp[256*3]; - - // For each composant - uint c; - for( c=0; c<3; c++ ) - { - uint i; - for( i=0; i<256; i++ ) - { - // Floating value - float value = (float)i / 256; - - // Contrast - value = (float) max (0.0f, (value-0.5f) * (float) pow (3.f, properties.Contrast[c]) + 0.5f ); - - // Gamma - value = (float) pow (value, (properties.Gamma[c]>0) ? 1 - 3 * properties.Gamma[c] / 4 : 1 - properties.Gamma[c] ); - - // Luminosity - value = value + properties.Luminosity[c] / 2.f; - ramp[i+(c<<8)] = (WORD)min (65535, max (0, (int)(value * 65535))); - } - } - - // Set the ramp - bool result = SetDeviceGammaRamp (dc, ramp) != FALSE; - - // Release the DC - ReleaseDC (NULL, dc); - - // Returns result - return result; - } - else - { - nlwarning ("(CDriverD3D::setMonitorColorProperties): can't create DC"); - return false; - } - -} -// *************************************************************************** - -// **************************************************************************** -bool CDriverD3D::supportEMBM() const -{ - H_AUTO_D3D(CDriverD3D_supportEMBM); - return _EMBMSupported; -} - -// **************************************************************************** -bool CDriverD3D::isEMBMSupportedAtStage(uint stage) const -{ - H_AUTO_D3D(CDriverD3D_isEMBMSupportedAtStage); - // we assume EMBM is supported at all stages except the last one - return stage < _NbNeLTextureStages - 1; -} - -// **************************************************************************** -void CDriverD3D::setEMBMMatrix(const uint stage, const float mat[4]) -{ - H_AUTO_D3D(CDriverD3D_setEMBMMatrix); - nlassert(stage < _NbNeLTextureStages - 1); - SetTextureStageState(stage, D3DTSS_BUMPENVMAT00, (DWORD &) mat[0]); - SetTextureStageState(stage, D3DTSS_BUMPENVMAT01, (DWORD &) mat[1]); - SetTextureStageState(stage, D3DTSS_BUMPENVMAT10, (DWORD &) mat[2]); - SetTextureStageState(stage, D3DTSS_BUMPENVMAT11, (DWORD &) mat[3]); -} - -// *************************************************************************** -bool CDriverD3D::supportOcclusionQuery() const -{ - H_AUTO_D3D(CDriverD3D_supportOcclusionQuery); - return _OcclusionQuerySupported; -} - -// *************************************************************************** -IOcclusionQuery *CDriverD3D::createOcclusionQuery() -{ - H_AUTO_D3D(CDriverD3D_createOcclusionQuery); - nlassert(_OcclusionQuerySupported); - nlassert(_DeviceInterface); - IDirect3DQuery9 *query; - if (_DeviceInterface->CreateQuery(D3DQUERYTYPE_OCCLUSION, &query) != D3D_OK) return NULL; - COcclusionQueryD3D *oqd3d = new COcclusionQueryD3D; - oqd3d->Driver = this; - oqd3d->Query = query; - oqd3d->VisibleCount = 0; - oqd3d->OcclusionType = IOcclusionQuery::NotAvailable; - oqd3d->QueryIssued = false; - oqd3d->WasLost = false; - _OcclusionQueryList.push_front(oqd3d); - oqd3d->Iterator = _OcclusionQueryList.begin(); - return oqd3d; -} - -// *************************************************************************** -void CDriverD3D::deleteOcclusionQuery(IOcclusionQuery *oq) -{ - H_AUTO_D3D(CDriverD3D_deleteOcclusionQuery); - if (!oq) return; - COcclusionQueryD3D *oqd3d = NLMISC::safe_cast(oq); - nlassert((CDriverD3D *) oqd3d->Driver == this); // should come from the same driver - oqd3d->Driver = NULL; - if (oqd3d->Query) - { - oqd3d->Query->Release(); - oqd3d->Query = NULL; - } - _OcclusionQueryList.erase(oqd3d->Iterator); - if (oqd3d == _CurrentOcclusionQuery) - { - _CurrentOcclusionQuery = NULL; - } - delete oqd3d; -} - -// *************************************************************************** -void COcclusionQueryD3D::begin() -{ - H_AUTO_D3D(COcclusionQueryD3D_begin); - if (!Query) return; // Lost device - nlassert(Driver); - nlassert(Driver->_CurrentOcclusionQuery == NULL); // only one query at a time - Query->Issue(D3DISSUE_BEGIN); - Driver->_CurrentOcclusionQuery = this; - OcclusionType = NotAvailable; - QueryIssued = false; - WasLost = false; -} - -// *************************************************************************** -void COcclusionQueryD3D::end() -{ - H_AUTO_D3D(COcclusionQueryD3D_end); - if (!Query) return; // Lost device - nlassert(Driver); - nlassert(Driver->_CurrentOcclusionQuery == this); // only one query at a time - if (!WasLost) - { - Query->Issue(D3DISSUE_END); - } - Driver->_CurrentOcclusionQuery = NULL; - QueryIssued = true; -} - -// *************************************************************************** -IOcclusionQuery::TOcclusionType COcclusionQueryD3D::getOcclusionType() -{ - if (!Query || WasLost) return QueryIssued ? Occluded : NotAvailable; - H_AUTO_D3D(COcclusionQueryD3D_getOcclusionType); - nlassert(Driver); - nlassert(Query); - nlassert(Driver->_CurrentOcclusionQuery != this); // can't query result between a begin/end pair! - if (OcclusionType == NotAvailable) - { - DWORD numPix; - if (Query->GetData(&numPix, sizeof(DWORD), 0) == S_OK) - { - OcclusionType = numPix != 0 ? NotOccluded : Occluded; - VisibleCount = (uint) numPix; - } - } - return OcclusionType; -} - -// *************************************************************************** -uint COcclusionQueryD3D::getVisibleCount() -{ - if (!Query || WasLost) return 0; - H_AUTO_D3D(COcclusionQueryD3D_getVisibleCount); - nlassert(Driver); - nlassert(Query); - nlassert(Driver->_CurrentOcclusionQuery != this); // can't query result between a begin/end pair! - if (getOcclusionType() == NotAvailable) return 0; - return VisibleCount; -} - -// *************************************************************************** -bool CDriverD3D::supportWaterShader() const -{ - H_AUTO_D3D(CDriverD3D_supportWaterShader); - return _PixelShaderVersion >= D3DPS_VERSION(1, 1); -} - -// *************************************************************************** -void CDriverD3D::setCullMode(TCullMode cullMode) -{ - H_AUTO_D3D(CDriver3D_cullMode); -#ifdef NL_D3D_USE_RENDER_STATE_CACHE - NL_D3D_CACHE_TEST(CacheTest_CullMode, cullMode != _CullMode) -#endif - { - if (_InvertCullMode) - { - setRenderState(D3DRS_CULLMODE, _CullMode == CCW ? D3DCULL_CW : D3DCULL_CCW); - } - else - { - setRenderState(D3DRS_CULLMODE, _CullMode == CCW ? D3DCULL_CCW : D3DCULL_CW); - } - _CullMode = cullMode; - } -} - -// *************************************************************************** -IDriver::TCullMode CDriverD3D::getCullMode() const -{ - H_AUTO_D3D(CDriver3D_CDriverD3D); - return _CullMode; -} - -// *************************************************************************** -void CDriverD3D::enableStencilTest(bool enable) -{ - H_AUTO_D3D(CDriver3D_CDriverD3D); - - _CurStencilTest = enable; - setRenderState(D3DRS_STENCILENABLE, enable?TRUE:FALSE); -} - -// *************************************************************************** -bool CDriverD3D::isStencilTestEnabled() const -{ - H_AUTO_D3D(CDriver3D_CDriverD3D); - return _CurStencilTest?TRUE:FALSE; -} - -// *************************************************************************** -void CDriverD3D::stencilFunc(TStencilFunc stencilFunc, int ref, uint mask) -{ - H_AUTO_D3D(CDriver3D_CDriverD3D); - - switch(stencilFunc) - { - case IDriver::never: _CurStencilFunc=D3DCMP_NEVER; break; - case IDriver::less: _CurStencilFunc=D3DCMP_LESS; break; - case IDriver::lessequal: _CurStencilFunc=D3DCMP_LESSEQUAL; break; - case IDriver::equal: _CurStencilFunc=D3DCMP_EQUAL; break; - case IDriver::notequal: _CurStencilFunc=D3DCMP_NOTEQUAL; break; - case IDriver::greaterequal: _CurStencilFunc=D3DCMP_GREATEREQUAL; break; - case IDriver::greater: _CurStencilFunc=D3DCMP_GREATER; break; - case IDriver::always: _CurStencilFunc=D3DCMP_ALWAYS; break; - default: nlstop; - } - - _CurStencilRef = (DWORD)ref; - _CurStencilMask = (DWORD)mask; - setRenderState(D3DRS_STENCILFUNC, _CurStencilFunc); - setRenderState(D3DRS_STENCILREF, _CurStencilRef); - setRenderState(D3DRS_STENCILMASK, _CurStencilMask); -} - -// *************************************************************************** -void CDriverD3D::stencilOp(TStencilOp fail, TStencilOp zfail, TStencilOp zpass) -{ - H_AUTO_D3D(CDriver3D_CDriverD3D); - - switch(fail) - { - case IDriver::keep: _CurStencilOpFail=D3DSTENCILOP_KEEP; break; - case IDriver::zero: _CurStencilOpFail=D3DSTENCILOP_ZERO; break; - case IDriver::replace: _CurStencilOpFail=D3DSTENCILOP_REPLACE; break; - case IDriver::incr: _CurStencilOpFail=D3DSTENCILOP_INCR; break; - case IDriver::decr: _CurStencilOpFail=D3DSTENCILOP_DECR; break; - case IDriver::invert: _CurStencilOpFail=D3DSTENCILOP_INVERT; break; - default: nlstop; - } - - switch(zfail) - { - case IDriver::keep: _CurStencilOpZFail=D3DSTENCILOP_KEEP; break; - case IDriver::zero: _CurStencilOpZFail=D3DSTENCILOP_ZERO; break; - case IDriver::replace: _CurStencilOpZFail=D3DSTENCILOP_REPLACE; break; - case IDriver::incr: _CurStencilOpZFail=D3DSTENCILOP_INCR; break; - case IDriver::decr: _CurStencilOpZFail=D3DSTENCILOP_DECR; break; - case IDriver::invert: _CurStencilOpZFail=D3DSTENCILOP_INVERT; break; - default: nlstop; - } - - switch(zpass) - { - case IDriver::keep: _CurStencilOpZPass=D3DSTENCILOP_KEEP; break; - case IDriver::zero: _CurStencilOpZPass=D3DSTENCILOP_ZERO; break; - case IDriver::replace: _CurStencilOpZPass=D3DSTENCILOP_REPLACE; break; - case IDriver::incr: _CurStencilOpZPass=D3DSTENCILOP_INCR; break; - case IDriver::decr: _CurStencilOpZPass=D3DSTENCILOP_DECR; break; - case IDriver::invert: _CurStencilOpZPass=D3DSTENCILOP_INVERT; break; - default: nlstop; - } - - setRenderState(D3DRS_STENCILFAIL, _CurStencilOpFail); - setRenderState(D3DRS_STENCILZFAIL, _CurStencilOpZFail); - setRenderState(D3DRS_STENCILPASS, _CurStencilOpZPass); -} - -// *************************************************************************** -void CDriverD3D::stencilMask(uint mask) -{ - H_AUTO_D3D(CDriver3D_CDriverD3D); - - _CurStencilWriteMask = (DWORD)mask; - setRenderState (D3DRS_STENCILWRITEMASK, _CurStencilWriteMask); -} - -// volatile bool preciseStateProfile = false; -// *************************************************************************** -void CDriverD3D::CRenderState::apply(CDriverD3D *driver) -{ - H_AUTO_D3D(CDriverD3D_CRenderState); - /*if (!preciseStateProfile) - {*/ - driver->_DeviceInterface->SetRenderState (StateID, Value); - /* - } - else - { - switch(StateID) - { - case D3DRS_ZENABLE: { H_AUTO_D3D(D3DRS_ZENABLE); driver->_DeviceInterface->SetRenderState(StateID, Value); } break; - case D3DRS_FILLMODE: { H_AUTO_D3D(D3DRS_FILLMODE); driver->_DeviceInterface->SetRenderState(StateID, Value); } break; - case D3DRS_SHADEMODE: { H_AUTO_D3D(D3DRS_SHADEMODE); driver->_DeviceInterface->SetRenderState(StateID, Value); } break; - case D3DRS_ZWRITEENABLE: { H_AUTO_D3D(D3DRS_ZWRITEENABLE); driver->_DeviceInterface->SetRenderState(StateID, Value); } break; - case D3DRS_ALPHATESTENABLE: { H_AUTO_D3D(D3DRS_ALPHATESTENABLE); driver->_DeviceInterface->SetRenderState(StateID, Value); } break; - case D3DRS_LASTPIXEL: { H_AUTO_D3D(D3DRS_LASTPIXEL); driver->_DeviceInterface->SetRenderState(StateID, Value); } break; - case D3DRS_SRCBLEND: { H_AUTO_D3D(D3DRS_SRCBLEND); driver->_DeviceInterface->SetRenderState(StateID, Value); } break; - case D3DRS_DESTBLEND: { H_AUTO_D3D(D3DRS_DESTBLEND); driver->_DeviceInterface->SetRenderState(StateID, Value); } break; - case D3DRS_CULLMODE: { H_AUTO_D3D(D3DRS_CULLMODE); driver->_DeviceInterface->SetRenderState(StateID, Value); } break; - case D3DRS_ZFUNC: { H_AUTO_D3D(D3DRS_ZFUNC); driver->_DeviceInterface->SetRenderState(StateID, Value); } break; - case D3DRS_ALPHAREF: { H_AUTO_D3D(D3DRS_ALPHAREF); driver->_DeviceInterface->SetRenderState(StateID, Value); } break; - case D3DRS_ALPHAFUNC: { H_AUTO_D3D(D3DRS_ALPHAFUNC); driver->_DeviceInterface->SetRenderState(StateID, Value); } break; - case D3DRS_DITHERENABLE: { H_AUTO_D3D(D3DRS_DITHERENABLE); driver->_DeviceInterface->SetRenderState(StateID, Value); } break; - case D3DRS_ALPHABLENDENABLE: { H_AUTO_D3D(D3DRS_ALPHABLENDENABLE); driver->_DeviceInterface->SetRenderState(StateID, Value); } break; - case D3DRS_FOGENABLE: { H_AUTO_D3D(D3DRS_FOGENABLE); driver->_DeviceInterface->SetRenderState(StateID, Value); } break; - case D3DRS_SPECULARENABLE: { H_AUTO_D3D(D3DRS_SPECULARENABLE); driver->_DeviceInterface->SetRenderState(StateID, Value); } break; - case D3DRS_FOGCOLOR: { H_AUTO_D3D(D3DRS_FOGCOLOR); driver->_DeviceInterface->SetRenderState(StateID, Value); } break; - case D3DRS_FOGTABLEMODE: { H_AUTO_D3D(D3DRS_FOGTABLEMODE); driver->_DeviceInterface->SetRenderState(StateID, Value); } break; - case D3DRS_FOGSTART: { H_AUTO_D3D(D3DRS_FOGSTART); driver->_DeviceInterface->SetRenderState(StateID, Value); } break; - case D3DRS_FOGEND: { H_AUTO_D3D(D3DRS_FOGEND); driver->_DeviceInterface->SetRenderState(StateID, Value); } break; - case D3DRS_FOGDENSITY: { H_AUTO_D3D(D3DRS_FOGDENSITY); driver->_DeviceInterface->SetRenderState(StateID, Value); } break; - case D3DRS_RANGEFOGENABLE: { H_AUTO_D3D(D3DRS_RANGEFOGENABLE); driver->_DeviceInterface->SetRenderState(StateID, Value); } break; - case D3DRS_STENCILENABLE: { H_AUTO_D3D(D3DRS_STENCILENABLE); driver->_DeviceInterface->SetRenderState(StateID, Value); } break; - case D3DRS_STENCILFAIL: { H_AUTO_D3D(D3DRS_STENCILFAIL); driver->_DeviceInterface->SetRenderState(StateID, Value); } break; - case D3DRS_STENCILZFAIL: { H_AUTO_D3D(D3DRS_STENCILZFAIL); driver->_DeviceInterface->SetRenderState(StateID, Value); } break; - case D3DRS_STENCILPASS: { H_AUTO_D3D(D3DRS_STENCILPASS); driver->_DeviceInterface->SetRenderState(StateID, Value); } break; - case D3DRS_STENCILFUNC: { H_AUTO_D3D(D3DRS_STENCILFUNC); driver->_DeviceInterface->SetRenderState(StateID, Value); } break; - case D3DRS_STENCILREF: { H_AUTO_D3D(D3DRS_STENCILREF); driver->_DeviceInterface->SetRenderState(StateID, Value); } break; - case D3DRS_STENCILMASK: { H_AUTO_D3D(D3DRS_STENCILMASK); driver->_DeviceInterface->SetRenderState(StateID, Value); } break; - case D3DRS_STENCILWRITEMASK: { H_AUTO_D3D(D3DRS_STENCILWRITEMASK); driver->_DeviceInterface->SetRenderState(StateID, Value); } break; - case D3DRS_TEXTUREFACTOR: { H_AUTO_D3D(D3DRS_TEXTUREFACTOR); driver->_DeviceInterface->SetRenderState(StateID, Value); } break; - case D3DRS_WRAP0: { H_AUTO_D3D(D3DRS_WRAP0); driver->_DeviceInterface->SetRenderState(StateID, Value); } break; - case D3DRS_WRAP1: { H_AUTO_D3D(D3DRS_WRAP1); driver->_DeviceInterface->SetRenderState(StateID, Value); } break; - case D3DRS_WRAP2: { H_AUTO_D3D(D3DRS_WRAP2); driver->_DeviceInterface->SetRenderState(StateID, Value); } break; - case D3DRS_WRAP3: { H_AUTO_D3D(D3DRS_WRAP3); driver->_DeviceInterface->SetRenderState(StateID, Value); } break; - case D3DRS_WRAP4: { H_AUTO_D3D(D3DRS_WRAP4); driver->_DeviceInterface->SetRenderState(StateID, Value); } break; - case D3DRS_WRAP5: { H_AUTO_D3D(D3DRS_WRAP5); driver->_DeviceInterface->SetRenderState(StateID, Value); } break; - case D3DRS_WRAP6: { H_AUTO_D3D(D3DRS_WRAP6); driver->_DeviceInterface->SetRenderState(StateID, Value); } break; - case D3DRS_WRAP7: { H_AUTO_D3D(D3DRS_WRAP7); driver->_DeviceInterface->SetRenderState(StateID, Value); } break; - case D3DRS_CLIPPING: { H_AUTO_D3D(D3DRS_CLIPPING); driver->_DeviceInterface->SetRenderState(StateID, Value); } break; - case D3DRS_LIGHTING: { H_AUTO_D3D(D3DRS_LIGHTING); driver->_DeviceInterface->SetRenderState(StateID, Value); } break; - case D3DRS_AMBIENT: { H_AUTO_D3D(D3DRS_AMBIENT); driver->_DeviceInterface->SetRenderState(StateID, Value); } break; - case D3DRS_FOGVERTEXMODE: { H_AUTO_D3D(D3DRS_FOGVERTEXMODE); driver->_DeviceInterface->SetRenderState(StateID, Value); } break; - case D3DRS_COLORVERTEX: { H_AUTO_D3D(D3DRS_COLORVERTEX); driver->_DeviceInterface->SetRenderState(StateID, Value); } break; - case D3DRS_LOCALVIEWER: { H_AUTO_D3D(D3DRS_LOCALVIEWER); driver->_DeviceInterface->SetRenderState(StateID, Value); } break; - case D3DRS_NORMALIZENORMALS: { H_AUTO_D3D(D3DRS_NORMALIZENORMALS); driver->_DeviceInterface->SetRenderState(StateID, Value); } break; - case D3DRS_DIFFUSEMATERIALSOURCE: { H_AUTO_D3D(D3DRS_DIFFUSEMATERIALSOURCE); driver->_DeviceInterface->SetRenderState(StateID, Value); } break; - case D3DRS_SPECULARMATERIALSOURCE: { H_AUTO_D3D(D3DRS_SPECULARMATERIALSOURCE); driver->_DeviceInterface->SetRenderState(StateID, Value); } break; - case D3DRS_AMBIENTMATERIALSOURCE: { H_AUTO_D3D(D3DRS_AMBIENTMATERIALSOURCE); driver->_DeviceInterface->SetRenderState(StateID, Value); } break; - case D3DRS_EMISSIVEMATERIALSOURCE: { H_AUTO_D3D(D3DRS_EMISSIVEMATERIALSOURCE); driver->_DeviceInterface->SetRenderState(StateID, Value); } break; - case D3DRS_VERTEXBLEND: { H_AUTO_D3D(D3DRS_VERTEXBLEND); driver->_DeviceInterface->SetRenderState(StateID, Value); } break; - case D3DRS_CLIPPLANEENABLE: { H_AUTO_D3D(D3DRS_CLIPPLANEENABLE); driver->_DeviceInterface->SetRenderState(StateID, Value); } break; - case D3DRS_POINTSIZE: { H_AUTO_D3D(D3DRS_POINTSIZE); driver->_DeviceInterface->SetRenderState(StateID, Value); } break; - case D3DRS_POINTSIZE_MIN: { H_AUTO_D3D(D3DRS_POINTSIZE_MIN); driver->_DeviceInterface->SetRenderState(StateID, Value); } break; - case D3DRS_POINTSPRITEENABLE: { H_AUTO_D3D(D3DRS_POINTSPRITEENABLE); driver->_DeviceInterface->SetRenderState(StateID, Value); } break; - case D3DRS_POINTSCALEENABLE: { H_AUTO_D3D(D3DRS_POINTSCALEENABLE); driver->_DeviceInterface->SetRenderState(StateID, Value); } break; - case D3DRS_POINTSCALE_A: { H_AUTO_D3D(D3DRS_POINTSCALE_A); driver->_DeviceInterface->SetRenderState(StateID, Value); } break; - case D3DRS_POINTSCALE_B: { H_AUTO_D3D(D3DRS_POINTSCALE_B); driver->_DeviceInterface->SetRenderState(StateID, Value); } break; - case D3DRS_POINTSCALE_C: { H_AUTO_D3D(D3DRS_POINTSCALE_C); driver->_DeviceInterface->SetRenderState(StateID, Value); } break; - case D3DRS_MULTISAMPLEANTIALIAS: { H_AUTO_D3D(D3DRS_MULTISAMPLEANTIALIAS); driver->_DeviceInterface->SetRenderState(StateID, Value); } break; - case D3DRS_MULTISAMPLEMASK: { H_AUTO_D3D(D3DRS_MULTISAMPLEMASK); driver->_DeviceInterface->SetRenderState(StateID, Value); } break; - case D3DRS_PATCHEDGESTYLE: { H_AUTO_D3D(D3DRS_PATCHEDGESTYLE); driver->_DeviceInterface->SetRenderState(StateID, Value); } break; - case D3DRS_DEBUGMONITORTOKEN: { H_AUTO_D3D(D3DRS_DEBUGMONITORTOKEN); driver->_DeviceInterface->SetRenderState(StateID, Value); } break; - case D3DRS_POINTSIZE_MAX: { H_AUTO_D3D(D3DRS_POINTSIZE_MAX); driver->_DeviceInterface->SetRenderState(StateID, Value); } break; - case D3DRS_INDEXEDVERTEXBLENDENABLE: { H_AUTO_D3D(D3DRS_INDEXEDVERTEXBLENDENABLE); driver->_DeviceInterface->SetRenderState(StateID, Value); } break; - case D3DRS_COLORWRITEENABLE: { H_AUTO_D3D(D3DRS_COLORWRITEENABLE); driver->_DeviceInterface->SetRenderState(StateID, Value); } break; - case D3DRS_TWEENFACTOR: { H_AUTO_D3D(D3DRS_TWEENFACTOR); driver->_DeviceInterface->SetRenderState(StateID, Value); } break; - case D3DRS_BLENDOP: { H_AUTO_D3D(D3DRS_BLENDOP); driver->_DeviceInterface->SetRenderState(StateID, Value); } break; - case D3DRS_POSITIONDEGREE: { H_AUTO_D3D(D3DRS_POSITIONDEGREE); driver->_DeviceInterface->SetRenderState(StateID, Value); } break; - case D3DRS_NORMALDEGREE: { H_AUTO_D3D(D3DRS_NORMALDEGREE); driver->_DeviceInterface->SetRenderState(StateID, Value); } break; - case D3DRS_SCISSORTESTENABLE: { H_AUTO_D3D(D3DRS_SCISSORTESTENABLE); driver->_DeviceInterface->SetRenderState(StateID, Value); } break; - case D3DRS_SLOPESCALEDEPTHBIAS: { H_AUTO_D3D(D3DRS_SLOPESCALEDEPTHBIAS); driver->_DeviceInterface->SetRenderState(StateID, Value); } break; - case D3DRS_ANTIALIASEDLINEENABLE: { H_AUTO_D3D(D3DRS_ANTIALIASEDLINEENABLE); driver->_DeviceInterface->SetRenderState(StateID, Value); } break; - case D3DRS_MINTESSELLATIONLEVEL: { H_AUTO_D3D(D3DRS_MINTESSELLATIONLEVEL); driver->_DeviceInterface->SetRenderState(StateID, Value); } break; - case D3DRS_MAXTESSELLATIONLEVEL: { H_AUTO_D3D(D3DRS_MAXTESSELLATIONLEVEL); driver->_DeviceInterface->SetRenderState(StateID, Value); } break; - case D3DRS_ADAPTIVETESS_X: { H_AUTO_D3D(D3DRS_ADAPTIVETESS_X); driver->_DeviceInterface->SetRenderState(StateID, Value); } break; - case D3DRS_ADAPTIVETESS_Y: { H_AUTO_D3D(D3DRS_ADAPTIVETESS_Y); driver->_DeviceInterface->SetRenderState(StateID, Value); } break; - case D3DRS_ADAPTIVETESS_Z: { H_AUTO_D3D(D3DRS_ADAPTIVETESS_Z); driver->_DeviceInterface->SetRenderState(StateID, Value); } break; - case D3DRS_ADAPTIVETESS_W: { H_AUTO_D3D(D3DRS_ADAPTIVETESS_W); driver->_DeviceInterface->SetRenderState(StateID, Value); } break; - case D3DRS_ENABLEADAPTIVETESSELLATION: { H_AUTO_D3D(D3DRS_ENABLEADAPTIVETESSELLATION); driver->_DeviceInterface->SetRenderState(StateID, Value); } break; - case D3DRS_TWOSIDEDSTENCILMODE: { H_AUTO_D3D(D3DRS_TWOSIDEDSTENCILMODE); driver->_DeviceInterface->SetRenderState(StateID, Value); } break; - case D3DRS_CCW_STENCILFAIL: { H_AUTO_D3D(D3DRS_CCW_STENCILFAIL); driver->_DeviceInterface->SetRenderState(StateID, Value); } break; - case D3DRS_CCW_STENCILZFAIL: { H_AUTO_D3D(D3DRS_CCW_STENCILZFAIL); driver->_DeviceInterface->SetRenderState(StateID, Value); } break; - case D3DRS_CCW_STENCILPASS: { H_AUTO_D3D(D3DRS_CCW_STENCILPASS); driver->_DeviceInterface->SetRenderState(StateID, Value); } break; - case D3DRS_CCW_STENCILFUNC: { H_AUTO_D3D(D3DRS_CCW_STENCILFUNC); driver->_DeviceInterface->SetRenderState(StateID, Value); } break; - case D3DRS_COLORWRITEENABLE1: { H_AUTO_D3D(D3DRS_COLORWRITEENABLE1); driver->_DeviceInterface->SetRenderState(StateID, Value); } break; - case D3DRS_COLORWRITEENABLE2: { H_AUTO_D3D(D3DRS_COLORWRITEENABLE2); driver->_DeviceInterface->SetRenderState(StateID, Value); } break; - case D3DRS_COLORWRITEENABLE3: { H_AUTO_D3D(D3DRS_COLORWRITEENABLE3); driver->_DeviceInterface->SetRenderState(StateID, Value); } break; - case D3DRS_BLENDFACTOR: { H_AUTO_D3D(D3DRS_BLENDFACTOR); driver->_DeviceInterface->SetRenderState(StateID, Value); } break; - case D3DRS_SRGBWRITEENABLE: { H_AUTO_D3D(D3DRS_SRGBWRITEENABLE); driver->_DeviceInterface->SetRenderState(StateID, Value); } break; - case D3DRS_DEPTHBIAS: { H_AUTO_D3D(D3DRS_DEPTHBIAS); driver->_DeviceInterface->SetRenderState(StateID, Value); } break; - case D3DRS_WRAP8: { H_AUTO_D3D(D3DRS_WRAP8); driver->_DeviceInterface->SetRenderState(StateID, Value); } break; - case D3DRS_WRAP9: { H_AUTO_D3D(D3DRS_WRAP9); driver->_DeviceInterface->SetRenderState(StateID, Value); } break; - case D3DRS_WRAP10: { H_AUTO_D3D(D3DRS_WRAP10); driver->_DeviceInterface->SetRenderState(StateID, Value); } break; - case D3DRS_WRAP11: { H_AUTO_D3D(D3DRS_WRAP11); driver->_DeviceInterface->SetRenderState(StateID, Value); } break; - case D3DRS_WRAP12: { H_AUTO_D3D(D3DRS_WRAP12); driver->_DeviceInterface->SetRenderState(StateID, Value); } break; - case D3DRS_WRAP13: { H_AUTO_D3D(D3DRS_WRAP13); driver->_DeviceInterface->SetRenderState(StateID, Value); } break; - case D3DRS_WRAP14: { H_AUTO_D3D(D3DRS_WRAP14); driver->_DeviceInterface->SetRenderState(StateID, Value); } break; - case D3DRS_WRAP15: { H_AUTO_D3D(D3DRS_WRAP15); driver->_DeviceInterface->SetRenderState(StateID, Value); } break; - case D3DRS_SEPARATEALPHABLENDENABLE: { H_AUTO_D3D(D3DRS_SEPARATEALPHABLENDENABLE); driver->_DeviceInterface->SetRenderState(StateID, Value); } break; - case D3DRS_SRCBLENDALPHA: { H_AUTO_D3D(D3DRS_SRCBLENDALPHA); driver->_DeviceInterface->SetRenderState(StateID, Value); } break; - case D3DRS_DESTBLENDALPHA: { H_AUTO_D3D(D3DRS_DESTBLENDALPHA); driver->_DeviceInterface->SetRenderState(StateID, Value); } break; - case D3DRS_BLENDOPALPHA: { H_AUTO_D3D(D3DRS_BLENDOPALPHA); driver->_DeviceInterface->SetRenderState(StateID, Value); } break; - } - } - */ -} - - -// *************************************************************************** -void CDriverD3D::CTextureState::apply(CDriverD3D *driver) -{ - H_AUTO_D3D(CDriverD3D_CTextureState); - if (Value != DeviceValue) - { - driver->_DeviceInterface->SetTextureStageState (StageID, StateID, Value); - DeviceValue = Value; - } -} - -// *************************************************************************** -void CDriverD3D::CTextureIndexState::apply(CDriverD3D *driver) -{ - H_AUTO_D3D(CDriverD3D_CTextureIndexState); - if (TexGen) - driver->setTextureState (StageID, D3DTSS_TEXCOORDINDEX, TexGenMode); - else - driver->setTextureState (StageID, D3DTSS_TEXCOORDINDEX, UVChannel); -} - -// *************************************************************************** -void CDriverD3D::CTexturePtrState::apply(CDriverD3D *driver) -{ - H_AUTO_D3D(CDriverD3D_CTexturePtrState); - driver->_DeviceInterface->SetTexture (StageID, Texture); -} - -// *************************************************************************** -void CDriverD3D::CVertexProgramPtrState::apply(CDriverD3D *driver) -{ - H_AUTO_D3D(CDriverD3D_CVertexProgramPtrState); - driver->_DeviceInterface->SetVertexShader(VertexProgram); -} - -// *************************************************************************** -void CDriverD3D::CPixelShaderPtrState::apply(CDriverD3D *driver) -{ - H_AUTO_D3D(CDriverD3D_CPixelShaderPtrState); - if (!driver->_PixelProgram) return; - driver->_DeviceInterface->SetPixelShader(PixelShader); -} - -// *************************************************************************** -void CDriverD3D::CVertexProgramConstantState::apply(CDriverD3D *driver) -{ - H_AUTO_D3D(CDriverD3D_CVertexProgramConstantState); - switch (ValueType) - { - case CVertexProgramConstantState::Float: - driver->_DeviceInterface->SetVertexShaderConstantF (StateID, (float*)Values, 1); - break; - case CVertexProgramConstantState::Int: - driver->_DeviceInterface->SetVertexShaderConstantI (StateID, (int*)Values, 1); - break; - } -} - -// *************************************************************************** -void CDriverD3D::CPixelShaderConstantState::apply(CDriverD3D *driver) -{ - H_AUTO_D3D(CDriverD3D_CPixelShaderConstantState); - switch (ValueType) - { - case CPixelShaderConstantState::Float: - driver->_DeviceInterface->SetPixelShaderConstantF (StateID, (float*)Values, 1); - break; - case CPixelShaderConstantState::Int: - driver->_DeviceInterface->SetPixelShaderConstantI (StateID, (int*)Values, 1); - break; - } -} - -// *************************************************************************** -void CDriverD3D::CSamplerState::apply(CDriverD3D *driver) -{ - H_AUTO_D3D(CDriverD3D_CSamplerState); - driver->_DeviceInterface->SetSamplerState (SamplerID, StateID, Value); -} - -// *************************************************************************** -void CDriverD3D::CMatrixState::apply(CDriverD3D *driver) -{ - H_AUTO_D3D(CDriverD3D_CMatrixState); - driver->_DeviceInterface->SetTransform (TransformType, &Matrix); -} - -// *************************************************************************** -void CDriverD3D::CVBState::apply(CDriverD3D *driver) -{ - H_AUTO_D3D(CDriverD3D_CVBState); - if (VertexBuffer) - { - driver->_DeviceInterface->SetStreamSource (0, VertexBuffer, Offset, Stride); - // Fix for radeon 7xxx & bad vertex layout - if (driver->inlGetNumTextStages() == 3) // If there are 3 stages this is a Radeon 7xxx - { - if (ColorOffset != 0 && driver->_VertexDeclCache.EnableVertexColor) - { - driver->_DeviceInterface->SetStreamSource (1, VertexBuffer, Offset + ColorOffset, Stride); - } - else - { - driver->_DeviceInterface->SetStreamSource (1, NULL, 0, 0); - } - } - } -} -// *************************************************************************** -void CDriverD3D::CIBState::apply(CDriverD3D *driver) -{ - H_AUTO_D3D(CDriverD3D_CIBState); - if (IndexBuffer) - { - driver->_DeviceInterface->SetIndices (IndexBuffer); - } -} - -// *************************************************************************** -void CDriverD3D::CVertexDeclState::apply(CDriverD3D *driver) -{ - H_AUTO_D3D(CDriverD3D_CVertexDeclState); - if (Decl) - { - if (!EnableVertexColor && DeclAliasDiffuseToSpecular && driver->inlGetNumTextStages() == 3) - { - // Fix for radeon 7xxx -> if vertex color is not used it should not be present in the vertex declaration (example : lighted material + vertex color but, no vertexColorLighted) - nlassert(DeclNoDiffuse); - driver->_DeviceInterface->SetVertexDeclaration (DeclNoDiffuse); - } - else - if (AliasDiffuseToSpecular) - { - nlassert(DeclAliasDiffuseToSpecular); - driver->_DeviceInterface->SetVertexDeclaration (DeclAliasDiffuseToSpecular); - } - else - { - nlassert(Decl); - driver->_DeviceInterface->SetVertexDeclaration (Decl); - } - } -} - -// *************************************************************************** -void CDriverD3D::CLightState::apply(CDriverD3D *driver) -{ - H_AUTO_D3D(CDriverD3D_CLightState); - // Enable state modified ? - { - H_AUTO_D3D(CDriverD3D_CLightStateEnabled); - if (EnabledTouched) - driver->_DeviceInterface->LightEnable (LightIndex, Enabled); - } - { - H_AUTO_D3D(CDriverD3D_CLightStateSetup); - // Light enabled ? - if (Enabled) - { - if (SettingsTouched) - { - // New position - Light.Position.x -= driver->_PZBCameraPos.x; - Light.Position.y -= driver->_PZBCameraPos.y; - Light.Position.z -= driver->_PZBCameraPos.z; - driver->_DeviceInterface->SetLight (LightIndex, &Light); - SettingsTouched = false; - } - } - // Clean - EnabledTouched = false; - } -} - -// *************************************************************************** -void CDriverD3D::CRenderTargetState::apply(CDriverD3D *driver) -{ - H_AUTO_D3D(CDriverD3D_CRenderTargetState); - driver->_DeviceInterface->SetRenderTarget (0, Target); - driver->setupViewport(driver->_Viewport); - driver->setupScissor(driver->_Scissor); -} - -// *************************************************************************** -void CDriverD3D::CMaterialState::apply(CDriverD3D *driver) -{ - H_AUTO_D3D(CDriverD3D_CMaterialState); - driver->_DeviceInterface->SetMaterial(&Current); -} - -// *************************************************************************** -void CDriverD3D::beginDialogMode() -{ - if (_FullScreen && _HWnd) - ShowWindow(_HWnd, SW_MINIMIZE); -} - -// *************************************************************************** -void CDriverD3D::endDialogMode() -{ - if (_FullScreen && _HWnd) - ShowWindow(_HWnd, SW_MAXIMIZE); -} - -bool CDriverD3D::clipRect(NLMISC::CRect &rect) -{ - // Clip the wanted rectangle with window. - uint32 width, height; - getWindowSize(width, height); - - sint32 xr=rect.right() ,yr=rect.bottom(); - - clamp((sint32&)rect.X, (sint32)0, (sint32)width); - clamp((sint32&)rect.Y, (sint32)0, (sint32)height); - clamp((sint32&)xr, (sint32)rect.X, (sint32)width); - clamp((sint32&)yr, (sint32)rect.Y, (sint32)height); - rect.Width= xr-rect.X; - rect.Height= yr-rect.Y; - - return rect.Width>0 && rect.Height>0; -} - -void CDriverD3D::getZBuffer(std::vector &zbuffer) -{ - H_AUTO_D3D(CDriverD3D_getZBuffer); - - CRect rect(0, 0); - getWindowSize(rect.Width, rect.Height); - getZBufferPart(zbuffer, rect); -} - -void CDriverD3D::getZBufferPart (std::vector &zbuffer, NLMISC::CRect &rect) -{ - zbuffer.clear(); - - IDirect3DSurface9 *surface; - if (SUCCEEDED(_DeviceInterface->GetDepthStencilSurface(&surface))) - { - if (clipRect(rect)) - { - RECT winRect; - winRect.left = rect.left(); - winRect.right = rect.right(); - winRect.top = rect.top(); - winRect.bottom = rect.bottom(); - - // Lock the surface - D3DLOCKED_RECT lock; - if (SUCCEEDED(surface->LockRect (&lock, &winRect, D3DLOCK_READONLY))) - { - zbuffer.resize(rect.Width*rect.Height); - - // Surface desc - D3DSURFACE_DESC desc; - if (SUCCEEDED(surface->GetDesc(&desc))) - { - const uint8* pBits = (uint8*)lock.pBits; - - for(uint y=0; y::max(); - } - } - else if (desc.Format == D3DFMT_D16_LOCKABLE) - { - uint16* pRow = (uint16*)(pBits + lock.Pitch * y); - while(offset != end) - { - uint16 value = *pRow++; - zbuffer[offset++] = (float)value / (float)std::numeric_limits::max(); - } - } - } - } - - surface->UnlockRect (); - } - } - - surface->Release(); - } -} - - -void CDriverD3D::findNearestFullscreenVideoMode() -{ - if(_CurrentMode.Windowed) - return; - - std::vector modes; - if(getModes(modes)) - { - sint32 nbPixels = _CurrentMode.Width * _CurrentMode.Height; - sint32 minError = nbPixels; - uint bestMode = (uint)modes.size(); - for(uint i=0; i < modes.size(); i++) - { - if(!modes[i].Windowed) - { - if(modes[i].Width==_CurrentMode.Width && modes[i].Height==_CurrentMode.Height) - { - // ok we found the perfect mode - return; - } - sint32 currentPixels = modes[i].Width * modes[i].Height; - sint32 currentError = abs(nbPixels - currentPixels); - if(currentError < minError) - { - minError = currentError; - bestMode = i; - } - } - } - if(bestMode != modes.size()) - { - nlwarning("The video mode %dx%d doesn't exist, use the nearest mode %dx%d", _CurrentMode.Width, _CurrentMode.Height, modes[bestMode].Width, modes[bestMode].Height); - _CurrentMode.Width = modes[bestMode].Width; - _CurrentMode.Height = modes[bestMode].Height; - } - } -} -bool CDriverD3D::copyTextToClipboard(const ucstring &text) -{ - return _EventEmitter.copyTextToClipboard(text); -} - -bool CDriverD3D::pasteTextFromClipboard(ucstring &text) -{ - return _EventEmitter.pasteTextFromClipboard(text); -} - -bool CDriverD3D::convertBitmapToIcon(const NLMISC::CBitmap &bitmap, HICON &icon, uint iconWidth, uint iconHeight, uint iconDepth, const NLMISC::CRGBA &col, sint hotSpotX, sint hotSpotY, bool cursor) -{ - CBitmap src = bitmap; - // resample bitmap if necessary - if (src.getWidth() != iconWidth || src.getHeight() != iconHeight) - { - src.resample(iconWidth, iconHeight); - } - CBitmap colorBm; - colorBm.resize(iconWidth, iconHeight, CBitmap::RGBA); - const CRGBA *srcColorPtr = (CRGBA *) &(src.getPixels()[0]); - const CRGBA *srcColorPtrLast = srcColorPtr + (iconWidth * iconHeight); - CRGBA *destColorPtr = (CRGBA *) &(colorBm.getPixels()[0]); - static volatile uint8 alphaThreshold = 127; - do - { - destColorPtr->modulateFromColor(*srcColorPtr, col); - std::swap(destColorPtr->R, destColorPtr->B); - ++ srcColorPtr; - ++ destColorPtr; - } - while (srcColorPtr != srcColorPtrLast); - // - HBITMAP colorHbm = NULL; - HBITMAP maskHbm = NULL; - // - if (iconDepth == 16) - { - std::vector colorBm16(iconWidth * iconHeight); - const CRGBA *src32 = (const CRGBA *) &colorBm.getPixels(0)[0]; - - for (uint k = 0; k < colorBm16.size(); ++k) - { - colorBm16[k] = ((uint16)(src32[k].R&0xf8)>>3) | ((uint16)(src32[k].G&0xfc)<<3) | ((uint16)(src32[k].B & 0xf8)<<8); - } - - colorHbm = CreateBitmap(iconWidth, iconHeight, 1, 16, &colorBm16[0]); - std::vector bitMask((iconWidth * iconHeight + 7) / 8, 0); - - for (uint k = 0;k < colorBm16.size(); ++k) - { - if (src32[k].A <= 120) - { - bitMask[k / 8] |= (0x80 >> (k & 7)); - } - } - - maskHbm = CreateBitmap(iconWidth, iconHeight, 1, 1, &bitMask[0]); - } - else - { - colorHbm = CreateBitmap(iconWidth, iconHeight, 1, 32, &colorBm.getPixels(0)[0]); - maskHbm = CreateBitmap(iconWidth, iconHeight, 1, 32, &colorBm.getPixels(0)[0]); - } - - ICONINFO iconInfo; - iconInfo.fIcon = cursor ? FALSE:TRUE; - iconInfo.xHotspot = (DWORD) hotSpotX; - iconInfo.yHotspot = (DWORD) hotSpotY; - iconInfo.hbmMask = maskHbm; - iconInfo.hbmColor = colorHbm; - - if (colorHbm && maskHbm) - { - icon = CreateIconIndirect(&iconInfo); - } - - // - if (colorHbm) DeleteObject(colorHbm); - if (maskHbm) DeleteObject(maskHbm); - - return true; -} - -} // NL3D diff --git a/code/nel/src/3d/driver/direct3d/driver_direct3d.def b/code/nel/src/3d/driver/direct3d/driver_direct3d.def deleted file mode 100644 index e52ed712d..000000000 --- a/code/nel/src/3d/driver/direct3d/driver_direct3d.def +++ /dev/null @@ -1,3 +0,0 @@ -EXPORTS - NL3D_createIDriverInstance - NL3D_interfaceVersion \ No newline at end of file diff --git a/code/nel/src/3d/driver/direct3d/driver_direct3d.h b/code/nel/src/3d/driver/direct3d/driver_direct3d.h deleted file mode 100644 index a4d9dbaeb..000000000 --- a/code/nel/src/3d/driver/direct3d/driver_direct3d.h +++ /dev/null @@ -1,2883 +0,0 @@ -// NeL - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as -// published by the Free Software Foundation, either version 3 of the -// License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -#ifndef NL_DRIVER_DIRECT3D_H -#define NL_DRIVER_DIRECT3D_H - - -#include "nel/misc/types_nl.h" - -// NeL includes -#include "nel/misc/matrix.h" -#include "nel/misc/smart_ptr.h" -#include "nel/misc/rgba.h" -#include "nel/misc/event_emitter.h" -#include "nel/misc/bit_set.h" -#include "nel/misc/heap_memory.h" -#include "nel/misc/event_emitter_multi.h" -#include "nel/misc/time_nl.h" -#include "nel/misc/hierarchical_timer.h" -#include "nel/misc/win_event_emitter.h" -#include "nel/3d/viewport.h" -#include "nel/3d/scissor.h" -#include "nel/3d/driver.h" -#include "nel/3d/material.h" -#include "nel/3d/vertex_buffer.h" -#include "nel/3d/index_buffer.h" -#include "nel/3d/ptr_set.h" -#include "nel/3d/texture_cube.h" -#include "nel/3d/occlusion_query.h" -#include "nel/3d/vertex_program_parse.h" -#include "nel/3d/light.h" -// -#include - -typedef HCURSOR nlCursor; -#define EmptyCursor NULL - - -// *** DEBUG MACRO - -// Define this to activate the debug mode (default is undefined) -//#define NL_DEBUG_D3D - -// Define this to enable the render state caching (default is defined) -#define NL_D3D_USE_RENDER_STATE_CACHE - -// allows to enable / disable cache test at runtime (for debug) -//#define NL_D3D_RUNTIME_DEBUG_CACHE_TEST -#ifdef NL_D3D_RUNTIME_DEBUG_CACHE_TEST - #define NL_D3D_CACHE_TEST(label, cond) if (!_CacheTest[label] || (cond)) -#else - #define NL_D3D_CACHE_TEST(label, cond) if (cond) -#endif - - -// Define this to disable hardware vertex program (default is undefined) -//#define NL_DISABLE_HARDWARE_VERTEX_PROGAM - -// Define this to disable hardware pixel shaders program (default is undefined) -//#define NL_DISABLE_HARDWARE_PIXEL_SHADER - -// Define this to disable hardware vertex array AGP (default is undefined) -//#define NL_DISABLE_HARDWARE_VERTEX_ARRAY_AGP - -// Define this to force the texture stage count (default is undefined) -//#define NL_FORCE_TEXTURE_STAGE_COUNT 2 - -// Define this to force the use of pixel shader in the normal shaders (default is undefined) -//#define NL_FORCE_PIXEL_SHADER_USE_FOR_NORMAL_SHADERS - -// Define this to enable profiling by the NV Perf HUD tool (default is undefined) -//#define NL_D3D_USE_NV_PERF_HUD - -// Define this to enable profiling of driver functions (default is undefined). -//#define NL_PROFILE_DRIVER_D3D - - - -#ifdef NL_PROFILE_DRIVER_D3D - #define H_AUTO_D3D(label) H_AUTO(label) -#else - #define H_AUTO_D3D(label) -#endif - -class CFpuRestorer -{ -public: - CFpuRestorer() { _FPControlWord = _controlfp(0, 0); } - ~CFpuRestorer() - { - _controlfp(_FPControlWord, ~0); - } -private: - unsigned int _FPControlWord; -}; - -class CFpuChecker -{ -public: - CFpuChecker(const char *label) { _FPControlWord = _controlfp(0, 0); _Label = label; } - ~CFpuChecker() - { - unsigned int newFP = _controlfp(0, 0); - if ((newFP & (_MCW_DN | _MCW_IC | _MCW_RC | _MCW_PC)) != (_FPControlWord & (_MCW_DN | _MCW_IC | _MCW_RC | _MCW_PC))) - { - nlwarning(_Label); - nlassert(0); - } - } -private: - const char *_Label; - unsigned int _FPControlWord; -}; - - - - -inline bool operator==(const D3DCOLORVALUE &lhs, const D3DCOLORVALUE &rhs) -{ - return lhs.r == rhs.r && lhs.g == rhs.g && lhs.b == rhs.b && lhs.a == rhs.a; -} -inline bool operator!=(const D3DCOLORVALUE &lhs, const D3DCOLORVALUE &rhs) -{ - return !(lhs == rhs); -} - - - - - -// *************************************************************************** - -namespace NL3D -{ - - - -const uint MAX_NUM_QUADS = 32767; // max number of quads in a single draw call - -using NLMISC::CMatrix; -using NLMISC::CVector; - -class CDriverD3D; -class CTextureDrvInfosD3D; -class COcclusionQueryD3D; -class CVolatileVertexBuffer; -class CVolatileIndexBuffer; - -typedef std::list TOcclusionQueryList; - -// *************************************************************************** -class COcclusionQueryD3D : public IOcclusionQuery -{ -public: - IDirect3DQuery9 *Query; - NLMISC::CRefPtr Driver; // owner driver - TOcclusionQueryList::iterator Iterator; // iterator in owner driver list of queries - TOcclusionType OcclusionType; // current type of occlusion - uint VisibleCount; // number of samples that passed the test - bool QueryIssued; - bool WasLost; // tells that query was lost, so calls to end() will have not effects (there's no matching begin) - // From IOcclusionQuery - virtual void begin(); - virtual void end(); - virtual TOcclusionType getOcclusionType(); - virtual uint getVisibleCount(); -}; - - -using NLMISC::CRefCount; - - -class IDriver; -class CDriverD3D; - -// List typedef. -class IShaderDrvInfos; -typedef std::list TShaderDrvInfoPtrList; -typedef TShaderDrvInfoPtrList::iterator ItShaderDrvInfoPtrList; - -/** - * Interface for shader driver infos. - */ -class IShaderDrvInfos : public CRefCount -{ -private: - CDriverD3D *_Driver; - ItShaderDrvInfoPtrList _DriverIterator; - -public: - IShaderDrvInfos(CDriverD3D *drv, ItShaderDrvInfoPtrList it) {_Driver= drv; _DriverIterator= it;} - // The virtual dtor is important. - virtual ~IShaderDrvInfos(); -}; - - -/** - * Shader resource for the driver. It is just a container for a ".fx" text file. - */ -/* *** IMPORTANT ******************** - * *** IF YOU MODIFY THE STRUCTURE OF THIS CLASS, PLEASE INCREMENT IDriver::InterfaceVersion TO INVALIDATE OLD DRIVER DLL - * ********************************** - */ -// -------------------------------------------------- -class CD3DShaderFX -{ -public: - CD3DShaderFX(); - ~CD3DShaderFX(); - - // Load a shader file - bool loadShaderFile (const char *filename); - - // Set the shader text - void setText (const char *text); - - // Get the shader text - const char *getText () const { return _Text.c_str(); } - - // Set the shader name - void setName (const char *name); - - // Get the shader name - const char *getName () const { return _Name.c_str(); } - -public: - // Private. For Driver only. - bool _ShaderChanged; - NLMISC::CRefPtr _DrvInfo; -private: - // The shader - std::string _Text; - // The shader name - std::string _Name; -}; - - - -// *************************************************************************** -class CTextureDrvInfosD3D : public ITextureDrvInfos -{ -public: - /* - ANY DATA ADDED HERE MUST BE SWAPPED IN swapTextureHandle() !! - */ - - // The texture - LPDIRECT3DBASETEXTURE9 Texture; - IDirect3DTexture9 *Texture2d; - IDirect3DCubeTexture9 *TextureCube; - - // The texture format and size - D3DFORMAT DestFormat; - uint Width; - uint Height; - - // This is the owner driver. - CDriverD3D *_Driver; - - // Is the internal format of the texture is a compressed one? - bool SrcCompressed; - bool IsCube; - - // Is a render target ? - bool RenderTarget; - - // Mipmap levels - uint8 Levels; - uint8 FirstMipMap; - - // This is the computed size of what memory this texture take. - uint32 TextureMemory; - - // The current wrap modes assigned to the texture. - D3DTEXTUREADDRESS WrapS; - D3DTEXTUREADDRESS WrapT; - D3DTEXTUREFILTERTYPE MagFilter; - D3DTEXTUREFILTERTYPE MinFilter; - D3DTEXTUREFILTERTYPE MipFilter; - - CTextureDrvInfosD3D(IDriver *drv, ItTexDrvInfoPtrMap it, CDriverD3D *drvGl, bool renderTarget); - ~CTextureDrvInfosD3D(); - virtual uint getTextureMemoryUsed() const {return TextureMemory;} -}; - - - -// *************************************************************************** -class CVertexProgamDrvInfosD3D : public IProgramDrvInfos -{ -public: - - // The shader - IDirect3DVertexShader9 *Shader; - - CVertexProgamDrvInfosD3D(IDriver *drv, ItGPUPrgDrvInfoPtrList it); - ~CVertexProgamDrvInfosD3D(); - - virtual uint getUniformIndex(const char *name) const - { - std::map::const_iterator it = ParamIndices.find(name); - if (it != ParamIndices.end()) return it->second; - return std::numeric_limits::max(); - }; - - std::map ParamIndices; -}; - - -// *************************************************************************** -class CPixelProgramDrvInfosD3D : public IProgramDrvInfos -{ -public: - - // The shader - IDirect3DPixelShader9 *Shader; - - CPixelProgramDrvInfosD3D(IDriver *drv, ItGPUPrgDrvInfoPtrList it); - ~CPixelProgramDrvInfosD3D(); - - virtual uint getUniformIndex(const char *name) const - { - std::map::const_iterator it = ParamIndices.find(name); - if (it != ParamIndices.end()) return it->second; - return std::numeric_limits::max(); - }; - - std::map ParamIndices; -}; - - -// *************************************************************************** - -class CVertexDeclaration -{ -public: - // The human readable values - D3DVERTEXELEMENT9 VertexElements[CVertexBuffer::NumValue+1]; - - // The driver pointer - IDirect3DVertexDeclaration9 *VertexDecl; -}; - - -// *************************************************************************** -class CVBDrvInfosD3D : public IVBDrvInfos -{ -public: - IDirect3DVertexDeclaration9 *VertexDecl; - IDirect3DVertexDeclaration9 *VertexDeclAliasDiffuseToSpecular; - IDirect3DVertexDeclaration9 *VertexDeclNoDiffuse; - uint ColorOffset; // Fix for Radeon 7xxx series -> see remarks in CDriverD3D::createVertexDeclaration - - - IDirect3DVertexBuffer9 *VertexBuffer; - uint Offset; // Vertex buffer offset - bool UseVertexColor:1; - bool Hardware:1; - bool Volatile:1; // Volatile vertex buffer - bool VolatileRAM:1; - uint8 Stride:8; - uint VolatileLockTime; // Volatile vertex buffer - DWORD Usage; - CVolatileVertexBuffer *VolatileVertexBuffer; - CDriverD3D *Driver; - #ifdef NL_DEBUG - bool Locked; - #endif - - CVBDrvInfosD3D(CDriverD3D *drv, ItVBDrvInfoPtrList it, CVertexBuffer *vb); - virtual ~CVBDrvInfosD3D(); - virtual uint8 *lock (uint first, uint last, bool readOnly); - virtual void unlock (uint first, uint last); -}; - - - -// *************************************************************************** - -class CIBDrvInfosD3D : public IIBDrvInfos -{ -public: - IDirect3DIndexBuffer9 *IndexBuffer; - uint Offset; // Index buffer offset - bool Volatile:1; // Volatile index buffer - bool VolatileRAM:1; - uint VolatileLockTime; // Volatile index buffer - CVolatileIndexBuffer *VolatileIndexBuffer; - CDriverD3D *Driver; - std::vector RamVersion; // If device doesn't support 32 bit indexes, works in ram (unless it a 16 bit index buffer) - CIBDrvInfosD3D(CDriverD3D *drv, ItIBDrvInfoPtrList it, CIndexBuffer *ib); - virtual ~CIBDrvInfosD3D(); - virtual void *lock (uint first, uint last, bool readOnly); - virtual void unlock (uint first, uint last); -}; - -// *************************************************************************** - -class CShaderDrvInfosD3D : public IShaderDrvInfos -{ -public: - enum - { - MaxShaderTexture=8, - }; - - - ID3DXEffect *Effect; - bool Validated; - - // Texture handles - D3DXHANDLE TextureHandle[MaxShaderTexture]; - - // Color handles - D3DXHANDLE ColorHandle[MaxShaderTexture]; - - // Factor handles - D3DXHANDLE FactorHandle[MaxShaderTexture]; - - // Scalar handles - D3DXHANDLE ScalarFloatHandle[MaxShaderTexture]; - - CShaderDrvInfosD3D(CDriverD3D *drv, ItShaderDrvInfoPtrList it); - virtual ~CShaderDrvInfosD3D(); -}; - - -// *************************************************************************** - -// Normal shader description -class CNormalShaderDesc -{ -public: - CNormalShaderDesc () - { - H_AUTO_D3D(CNormalShaderDesc_CNormalShaderDesc); - memset (this, 0, sizeof(CNormalShaderDesc)); - } - ~CNormalShaderDesc () - { - if (PixelShader) - PixelShader->Release(); - } - bool StageUsed[IDRV_MAT_MAXTEXTURES]; - uint32 TexEnvMode[IDRV_MAT_MAXTEXTURES]; - - bool operator==(const CNormalShaderDesc &other) const - { - uint i; - for (i=0; i Allocator; -}; - -// record of a single .fx pass -class CFXPassRecord -{ -public: - void apply(class CDriverD3D &drv); - ~CFXPassRecord(); - std::vector States; -}; - - -template -class CFXInputValue -{ -public: - T Value; - bool Set; - CFXInputValue() : Set(false) {} - void reset(); - bool operator==(const CFXInputValue &other) - { - if (!Set) return !(other.Set); - return (Value == other.Value) != 0; - } -}; - -class CFXInputParams -{ -public: - enum { MaxNumParams = CShaderDrvInfosD3D::MaxShaderTexture }; - CFXInputValue Textures[MaxNumParams]; - CFXInputValue Colors[MaxNumParams]; - CFXInputValue Vectors[MaxNumParams]; - CFXInputValue Floats[MaxNumParams]; - bool Touched; -public: - CFXInputParams() { Touched = true; } - void setTexture(uint index, LPDIRECT3DBASETEXTURE9 value) - { - nlassert(index < MaxNumParams); - if (!Textures[index].Set || value != Textures[index].Value) - { - Textures[index].Value = value; - Textures[index].Set = true; - Touched = true; - } - } - void setColor(uint index, DWORD value) - { - nlassert(index < MaxNumParams); - if (!Colors[index].Set || value != Colors[index].Value) - { - Colors[index].Value = value; - Colors[index].Set = true; - Touched = true; - } - } - void setVector(uint index, const D3DXVECTOR4 &value) - { - nlassert(index < MaxNumParams); - if (!Vectors[index].Set || value != Vectors[index].Value) - { - Vectors[index].Value = value; - Vectors[index].Set = true; - Touched = true; - } - } - void setFloat(uint index, FLOAT value) - { - nlassert(index < MaxNumParams); - if (!Floats[index].Set || value != Floats[index].Value) - { - Floats[index].Value = value; - Floats[index].Set = true; - Touched = true; - } - } - // - /* - bool operator==(const CFXInputParams &other) - { - return std::equal(Textures, Textures + CShaderDrvInfosD3D::MaxShaderTexture, other.Textures) && - std::equal(Vectors, Vectors + CShaderDrvInfosD3D::MaxShaderTexture, other.Vectors) && - std::equal(Colors, Colors + CShaderDrvInfosD3D::MaxShaderTexture, other.Colors) && - std::equal(Floats, Floats + CShaderDrvInfosD3D::MaxShaderTexture, other.Floats); - } - */ - void reset() - { - for(uint k = 0; k < MaxNumParams; ++k) - { - Textures[k].Set = false; - Colors[k].Set = false; - Vectors[k].Set = false; - Floats[k].Set = false; - } - Touched = true; - } -}; - -// .fx cache based on input parameters -class CFXCache -{ -public: - // Input parameters - CFXInputParams Params; - // cache for .fx states - std::vector Passes; - uint Steadyness; - uint NumPasses; -public: - CFXCache() : Steadyness(0) {} - void begin(CShaderDrvInfosD3D *si, class CDriverD3D *driver); - void applyPass(class CDriverD3D &drv, CShaderDrvInfosD3D *si, uint passIndex); - void end(CShaderDrvInfosD3D *si); - void reset(); - void setConstants(CShaderDrvInfosD3D *si); -}; - - - -// optimisation of an effect 2 -class CFXPassRecorder : public ID3DXEffectStateManager -{ -public: - CFXPassRecord *Target; - class CDriverD3D *Driver; -public: - CFXPassRecorder() : Target(NULL), Driver(NULL) {} - HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, LPVOID *ppvObj); - ULONG STDMETHODCALLTYPE AddRef(VOID); - ULONG STDMETHODCALLTYPE Release(VOID); - HRESULT STDMETHODCALLTYPE LightEnable(DWORD Index, BOOL Enable); - HRESULT STDMETHODCALLTYPE SetFVF(DWORD FVF); - HRESULT STDMETHODCALLTYPE SetLight(DWORD Index, CONST D3DLIGHT9* pLight); - HRESULT STDMETHODCALLTYPE SetMaterial(CONST D3DMATERIAL9* pMaterial); - HRESULT STDMETHODCALLTYPE SetNPatchMode(FLOAT nSegments); - HRESULT STDMETHODCALLTYPE SetPixelShader(LPDIRECT3DPIXELSHADER9 pShader); - HRESULT STDMETHODCALLTYPE SetPixelShaderConstantB(UINT StartRegister, CONST BOOL* pConstantData, UINT RegisterCount); - HRESULT STDMETHODCALLTYPE SetPixelShaderConstantF(UINT StartRegister, CONST FLOAT* pConstantData, UINT RegisterCount); - HRESULT STDMETHODCALLTYPE SetPixelShaderConstantI(UINT StartRegister, CONST INT* pConstantData, UINT RegisterCount); - HRESULT STDMETHODCALLTYPE SetRenderState(D3DRENDERSTATETYPE State, DWORD Value); - HRESULT STDMETHODCALLTYPE SetSamplerState(DWORD Sampler, D3DSAMPLERSTATETYPE Type, DWORD Value); - HRESULT STDMETHODCALLTYPE SetTexture (DWORD Stage, LPDIRECT3DBASETEXTURE9 pTexture); - HRESULT STDMETHODCALLTYPE SetTextureStageState(DWORD Stage, D3DTEXTURESTAGESTATETYPE Type, DWORD Value); - HRESULT STDMETHODCALLTYPE SetTransform(D3DTRANSFORMSTATETYPE State, CONST D3DMATRIX* pMatrix); - HRESULT STDMETHODCALLTYPE SetVertexShader(LPDIRECT3DVERTEXSHADER9 pShader); - HRESULT STDMETHODCALLTYPE SetVertexShaderConstantB(UINT StartRegister, CONST BOOL* pConstantData, UINT RegisterCount); - HRESULT STDMETHODCALLTYPE SetVertexShaderConstantF(UINT StartRegister, CONST FLOAT* pConstantData, UINT RegisterCount); - HRESULT STDMETHODCALLTYPE SetVertexShaderConstantI(UINT StartRegister, CONST INT* pConstantData, UINT RegisterCount); -}; - - -// *************************************************************************** -struct CMaterialDrvInfosD3D : public IMaterialDrvInfos -{ -public: - D3DMATERIAL9 Material; - D3DCOLOR UnlightedColor; - BOOL SpecularEnabled; - D3DBLEND SrcBlend; - D3DBLEND DstBlend; - D3DCMPFUNC ZComp; - DWORD AlphaRef; - D3DTEXTUREOP ColorOp[IDRV_MAT_MAXTEXTURES]; - DWORD ColorArg0[IDRV_MAT_MAXTEXTURES]; - DWORD ColorArg1[IDRV_MAT_MAXTEXTURES]; - DWORD ColorArg2[IDRV_MAT_MAXTEXTURES]; - uint NumColorArg[IDRV_MAT_MAXTEXTURES]; - uint NumAlphaArg[IDRV_MAT_MAXTEXTURES]; - D3DTEXTUREOP AlphaOp[IDRV_MAT_MAXTEXTURES]; - DWORD AlphaArg0[IDRV_MAT_MAXTEXTURES]; - DWORD AlphaArg1[IDRV_MAT_MAXTEXTURES]; - DWORD AlphaArg2[IDRV_MAT_MAXTEXTURES]; - D3DCOLOR ConstantColor[IDRV_MAT_MAXTEXTURES]; - DWORD TexGen[IDRV_MAT_MAXTEXTURES]; - IDirect3DPixelShader9 *PixelShader; - IDirect3DPixelShader9 *PixelShaderUnlightedNoVertexColor; - bool ActivateSpecularWorldTexMT[IDRV_MAT_MAXTEXTURES]; - bool ActivateInvViewModelTexMT[IDRV_MAT_MAXTEXTURES]; - bool VertexColorLighted; - bool NeedsConstantForDiffuse; // Must use TFactor if not vertex color in the vertex buffer - bool MultipleConstantNoPixelShader; // Multiple constant are possibly needed to setup the material. This flag is set only if the device has no pixel shaders - // In this case diffuse color will be emulated by using an unlighted material with ambient - bool MultiplePerStageConstant; // Are there more than one per-stage constant in the material ? - uint8 ConstantIndex; // Index of the constant color to use (when only one constant color is needed and NeedsConstantForDiffuse == false); - uint8 ConstantIndex2; // stage at which the 2nd constant is used (for emulation without pixel shaders) - - CRGBA Constant2; // value of the 2nd constant being used (for emulation without pixel shaders) - - uint NumUsedTexStages; // Last number of textures that were set in the material - // Tex Env are only built for stages at which textures are set so if the number of used texture - // change they must be rebuilt - - // Relevant parts of the pixel pipe for normal shader - bool RGBPipe[IDRV_MAT_MAXTEXTURES]; - bool AlphaPipe[IDRV_MAT_MAXTEXTURES]; - - CFXCache *FXCache; - - CMaterialDrvInfosD3D(IDriver *drv, ItMatDrvInfoPtrList it) : IMaterialDrvInfos(drv, it) - { - H_AUTO_D3D(CMaterialDrvInfosD3D_CMaterialDrvInfosD3D); - PixelShader = NULL; - PixelShaderUnlightedNoVertexColor = NULL; - std::fill(RGBPipe, RGBPipe + IDRV_MAT_MAXTEXTURES, true); - std::fill(AlphaPipe, AlphaPipe + IDRV_MAT_MAXTEXTURES, true); - FXCache = NULL; - NumUsedTexStages = 0; - } - ~CMaterialDrvInfosD3D() - { - delete FXCache; - } - void buildTexEnv (uint stage, const CMaterial::CTexEnv &env, bool textured); - -}; - - -// - -// *************************************************************************** - -/* Volatile buffers. - * - * The volatile buffer system is a double buffer allocated during the render pass by objects that needs - * a temporary buffer to render vertex or indexes. Each lock allocates a buffer region - * and locks it with the NOOVERWRITE flag. Locks are not blocked. The buffer is reset at each frame begin. - * There is a double buffer to take benefit of the "over swapbuffer" parallelisme. - */ - -// *************************************************************************** - -class CVolatileVertexBuffer -{ -public: - CVolatileVertexBuffer(); - ~CVolatileVertexBuffer(); - - CDriverD3D *Driver; - IDirect3DVertexBuffer9 *VertexBuffer; - uint Size; - CVertexBuffer::TLocation Location; - uint CurrentIndex; - uint MaxSize; - bool Locked; - - /* size is in bytes */ - void init (CVertexBuffer::TLocation location, uint size, uint maxSize, CDriverD3D *driver); - void release (); - - // Runtime buffer access, no-blocking lock. - void *lock (uint size, uint stride, uint &offset); - void unlock (); - - // Runtime reset (called at the beginning of the frame rendering), blocking lock here. - void reset (); -}; - -// *************************************************************************** - -class CVolatileIndexBuffer -{ -public: - CVolatileIndexBuffer(); - ~CVolatileIndexBuffer(); - - CDriverD3D *Driver; - IDirect3DIndexBuffer9 *IndexBuffer; - uint Size; - CIndexBuffer::TLocation Location; - // current position in bytes! - uint CurrentIndex; - uint MaxSize; - bool Locked; - CIndexBuffer::TFormat Format; - - /* size is in bytes */ - void init (CIndexBuffer::TLocation location, uint sizeInBytes, uint maxSize, CDriverD3D *driver, CIndexBuffer::TFormat format); - void release (); - - // Runtime buffer access, no-blocking lock. Re - void *lock (uint size, uint &offset); - void unlock (); - - // Runtime reset (called at the beginning of the frame rendering), blocking lock here. - void reset (); -}; - - - -// *************************************************************************** - -class CDriverD3D : public IDriver, public ID3DXEffectStateManager -{ -public: - - enum - { - CacheTest_CullMode = 0, - CacheTest_RenderState = 1, - CacheTest_TextureState = 2, - CacheTest_TextureIndexMode = 3, - CacheTest_TextureIndexUV = 4, - CacheTest_Texture = 5, - CacheTest_VertexProgram = 6, - CacheTest_PixelShader = 7, - CacheTest_VertexProgramConstant = 8, - CacheTest_PixelShaderConstant = 9, - CacheTest_SamplerState = 10, - CacheTest_VertexBuffer = 11, - CacheTest_IndexBuffer = 12, - CacheTest_VertexDecl = 13, - CacheTest_Matrix = 14, - CacheTest_RenderTarget = 15, - CacheTest_MaterialState = 16, - CacheTest_DepthRange = 17, - CacheTest_Count - }; - - // Some constants - enum - { - MaxLight=8, - MaxRenderState=256, - MaxTextureState=36, - MaxTexture=8, - MaxSamplerState=16, - MaxSampler=8, - - MatrixStateRemap = 24, - MaxMatrixState=32, - MaxVertexProgramConstantState=96, - MaxPixelShaderConstantState=96, - }; - - // Prefered pixel formats - enum - { - // Number of pixel format choice for each pixel format - FinalPixelFormatChoice = 5, - }; - - // Construction / destruction - CDriverD3D(); - virtual ~CDriverD3D(); - - virtual bool isLost() const { return _Lost; } - // *************************************************************************** - // Implementation - // see nel\src\3d\driver.h - // *************************************************************************** - - // Mode initialisation, requests - virtual bool init (uintptr_t windowIcon = 0, emptyProc exitFunc = 0); - virtual bool setDisplay(nlWindow wnd, const GfxMode& mode, bool show, bool resizeable) throw(EBadDisplay); - virtual bool release(); - virtual bool setMode(const GfxMode& mode); - virtual bool getModes(std::vector &modes); - virtual bool getCurrentScreenMode(GfxMode &mode); - virtual void beginDialogMode(); - virtual void endDialogMode(); - virtual bool activate(); - virtual bool isActive (); - virtual bool initVertexBufferHard(uint agpMem, uint vramMem); - - // Windows interface - virtual nlWindow getDisplay(); - virtual emptyProc getWindowProc(); - virtual NLMISC::IEventEmitter *getEventEmitter(); - virtual void getWindowSize (uint32 &width, uint32 &height); - virtual void getWindowPos (sint32 &x, sint32 &y); - virtual uint8 getBitPerPixel (); - - /// Set the title of the NeL window - virtual void setWindowTitle(const ucstring &title); - - /// Set icon(s) of the NeL window - virtual void setWindowIcon(const std::vector &bitmaps); - - /// Set the position of the NeL window - virtual void setWindowPos(sint32 x, sint32 y); - - /// Show or hide the NeL window - virtual void showWindow(bool show); - - // Driver parameters - virtual void disableHardwareVertexProgram(); - virtual void disableHardwarePixelProgram(); - virtual void disableHardwareIndexArrayAGP(); - virtual void disableHardwareVertexArrayAGP(); - virtual void disableHardwareTextureShader(); - virtual void forceDXTCCompression(bool dxtcComp); - virtual void setAnisotropicFilter(sint filter); - virtual uint getAnisotropicFilter() const; - virtual uint getAnisotropicFilterMaximum() const; - virtual void forceTextureResize(uint divisor); - - // Driver information - virtual uint getNumAdapter() const; - virtual bool getAdapter(uint adapter, CAdapter &desc) const; - virtual bool setAdapter(uint adapter); - virtual uint32 getAvailableVertexAGPMemory (); - virtual uint32 getAvailableVertexVRAMMemory (); - virtual uint getNbTextureStages() const; - virtual void getNumPerStageConstant(uint &lightedMaterial, uint &unlightedMaterial) const; - virtual bool supportVertexBufferHard() const; - virtual bool supportVolatileVertexBuffer() const; - virtual bool supportIndexBufferHard() const; - // todo hulud d3d vertex buffer hard - virtual bool slowUnlockVertexBufferHard() const {return false;}; - virtual uint getMaxVerticesByVertexBufferHard() const; - virtual uint32 getImplementationVersion () const; - virtual const char* getDriverInformation (); - virtual const char* getVideocardInformation (); - virtual sint getTotalVideoMemory () const; - virtual CVertexBuffer::TVertexColorType getVertexColorFormat() const; - - // Textures - virtual bool isTextureExist(const ITexture&tex); - virtual bool setupTexture (ITexture& tex); - virtual bool setupTextureEx (ITexture& tex, bool bUpload, bool &bAllUploaded, bool bMustRecreateSharedTexture= false); - virtual bool uploadTexture (ITexture& tex, NLMISC::CRect& rect, uint8 nNumMipMap); - // todo hulud d3d texture - virtual bool uploadTextureCube (ITexture& /* tex */, NLMISC::CRect& /* rect */, uint8 /* nNumMipMap */, uint8 /* nNumFace */) {return false;}; - - // Material - virtual bool setupMaterial(CMaterial& mat); - - virtual bool supportCloudRenderSinglePass () const; - - // Buffer - virtual bool clear2D(CRGBA rgba); - virtual bool clearZBuffer(float zval=1); - virtual bool clearStencilBuffer(float stencilval=0); - virtual void setColorMask (bool bRed, bool bGreen, bool bBlue, bool bAlpha); - virtual bool swapBuffers(); - virtual void getBuffer (CBitmap &bitmap); // Only 32 bits back buffer supported - virtual void setDepthRange(float znear, float zfar); - virtual void getDepthRange(float &znear, float &zfar) const; - - virtual void getZBuffer (std::vector &zbuffer); - virtual void getBufferPart (CBitmap &bitmap, NLMISC::CRect &rect); - - // return true if driver support Bloom effect. - virtual bool supportBloomEffect() const; - - // return true if driver support non-power of two textures - virtual bool supportNonPowerOfTwoTextures() const; - - // copy the first texture in a second one of different dimensions - virtual bool stretchRect (ITexture * srcText, NLMISC::CRect &srcRect, ITexture * destText, NLMISC::CRect &destRect); // Only 32 bits back buffer supported - virtual bool isTextureRectangle(ITexture * /* tex */) const {return false;} - IDirect3DSurface9* getSurfaceTexture(ITexture * text); - void getDirect3DRect(NLMISC::CRect &rect, RECT & d3dRect); - - // todo hulud d3d buffers - virtual void getZBufferPart (std::vector &zbuffer, NLMISC::CRect &rect); - virtual bool setRenderTarget (ITexture *tex, uint32 x, uint32 y, uint32 width, uint32 height, uint32 mipmapLevel, uint32 cubeFace); - virtual ITexture *getRenderTarget() const; - virtual bool copyTargetToTexture (ITexture *tex, uint32 offsetx, uint32 offsety, uint32 x, uint32 y, uint32 width, - uint32 height, uint32 mipmapLevel); - virtual bool textureCoordinateAlternativeMode() const { return true; }; - virtual bool getRenderTargetSize (uint32 &width, uint32 &height); - virtual bool fillBuffer (CBitmap &bitmap); - - // Performances - virtual void startSpecularBatch(); - virtual void endSpecularBatch(); - virtual void setSwapVBLInterval(uint interval); - virtual uint getSwapVBLInterval(); - virtual void swapTextureHandle(ITexture &tex0, ITexture &tex1); - virtual uintptr_t getTextureHandle(const ITexture&tex); - - // Matrix, viewport and frustum - virtual void setFrustum(float left, float right, float bottom, float top, float znear, float zfar, bool perspective = true); - virtual void setFrustumMatrix(CMatrix &frust); - virtual CMatrix getFrustumMatrix(); - virtual float getClipSpaceZMin() const { return 0.f; } - virtual void setupViewMatrix(const CMatrix& mtx); - virtual void setupViewMatrixEx(const CMatrix& mtx, const CVector &cameraPos); - virtual void setupModelMatrix(const CMatrix& mtx); - virtual CMatrix getViewMatrix() const; - virtual void forceNormalize(bool normalize); - virtual bool isForceNormalize() const; - virtual void setupScissor (const class CScissor& scissor); - virtual void setupViewport (const class CViewport& viewport); - virtual void getViewport(CViewport &viewport); - - // Vertex buffers - virtual bool activeVertexBuffer(CVertexBuffer& VB); - - // Index buffers - virtual bool activeIndexBuffer(CIndexBuffer& IB); - - // UV - virtual void mapTextureStageToUV(uint stage, uint uv); - - // Indexed primitives - virtual bool renderLines(CMaterial& mat, uint32 firstIndex, uint32 nlines); - virtual bool renderTriangles(CMaterial& Mat, uint32 firstIndex, uint32 ntris); - virtual bool renderSimpleTriangles(uint32 firstTri, uint32 ntris); - // Indexed primitives with index offset - virtual bool renderLinesWithIndexOffset(CMaterial& mat, uint32 firstIndex, uint32 nlines, uint indexOffset); - virtual bool renderTrianglesWithIndexOffset(CMaterial& mat, uint32 firstIndex, uint32 ntris, uint indexOffset); - virtual bool renderSimpleTrianglesWithIndexOffset(uint32 firstIndex, uint32 ntris, uint indexOffset); - // Unindexed primitives with index offset - virtual bool renderRawPoints(CMaterial& Mat, uint32 startIndex, uint32 numPoints); - virtual bool renderRawLines(CMaterial& Mat, uint32 startIndex, uint32 numLines); - virtual bool renderRawTriangles(CMaterial& Mat, uint32 startIndex, uint32 numTris); - virtual bool renderRawQuads(CMaterial& Mat, uint32 startIndex, uint32 numQuads); - // - virtual void setPolygonMode (TPolygonMode mode); - virtual void finish(); - virtual void flush(); - - // Profile - virtual void profileRenderedPrimitives(CPrimitiveProfile &pIn, CPrimitiveProfile &pOut); - virtual uint32 profileAllocatedTextureMemory(); - virtual uint32 profileSetupedMaterials() const; - virtual uint32 profileSetupedModelMatrix() const; - virtual void enableUsedTextureMemorySum (bool enable); - virtual uint32 getUsedTextureMemory() const; - virtual void startProfileVBHardLock(); - virtual void endProfileVBHardLock(std::vector &result); - virtual void profileVBHardAllocation(std::vector &result); - virtual void startProfileIBLock(); - virtual void endProfileIBLock(std::vector &result); - virtual void profileIBAllocation(std::vector &result); - //virtual void profileIBAllocation(std::vector &result); - - // Misc - virtual TMessageBoxId systemMessageBox (const char* message, const char* title, TMessageBoxType type=okType, TMessageBoxIcon icon=noIcon); - virtual uint64 getSwapBufferCounter() const { return _SwapBufferCounter; } - - // Inputs - virtual void showCursor (bool b); - virtual void setMousePos(float x, float y); - virtual void setCapture (bool b); - - // see if system cursor is currently captured - virtual bool isSystemCursorCaptured(); - - // Add a new cursor (name is case unsensitive) - virtual void addCursor(const std::string &name, const NLMISC::CBitmap &bitmap); - - // Display a cursor from its name (case unsensitive) - virtual void setCursor(const std::string &name, NLMISC::CRGBA col, uint8 rot, sint hotSpotX, sint hotSpotY, bool forceRebuild = false); - - // Change default scale for all cursors - virtual void setCursorScale(float scale); - - // Lights - virtual uint getMaxLight () const; - virtual void setLight (uint8 num, const CLight& light); - virtual void enableLight (uint8 num, bool enable=true); - virtual void setLightMapDynamicLight (bool enable, const CLight& light); - // todo hulud d3d light - virtual void setPerPixelLightingLight(CRGBA /* diffuse */, CRGBA /* specular */, float /* shininess */) {} - virtual void setAmbientColor (CRGBA color); - - // Fog - virtual bool fogEnabled(); - virtual void enableFog(bool enable); - virtual void setupFog(float start, float end, CRGBA color); - virtual float getFogStart() const; - virtual float getFogEnd() const; - virtual CRGBA getFogColor() const; - - // Texture addressing modes - // todo hulud d3d adressing mode - virtual bool supportTextureShaders() const {return false;}; - virtual bool supportMADOperator() const; - // todo hulud d3d adressing mode - virtual bool supportWaterShader() const; - // todo hulud d3d adressing mode - virtual bool supportTextureAddrMode(CMaterial::TTexAddressingMode /* mode */) const {return false;}; - // todo hulud d3d adressing mode - virtual void setMatrix2DForTextureOffsetAddrMode(const uint /* stage */, const float /* mat */[4]) {} - - // EMBM support - virtual bool supportEMBM() const; - virtual bool isEMBMSupportedAtStage(uint stage) const; - virtual void setEMBMMatrix(const uint stage, const float mat[4]); - virtual bool supportPerPixelLighting(bool /* specular */) const {return false;}; - - // index offset support - virtual bool supportIndexOffset() const { return true; /* always supported with D3D driver */ } - - // Blend - virtual bool supportBlendConstantColor() const; - virtual void setBlendConstantColor(NLMISC::CRGBA col); - virtual NLMISC::CRGBA getBlendConstantColor() const; - - // Monitor properties - virtual bool setMonitorColorProperties (const CMonitorColorProperties &properties); - - // Polygon smoothing - virtual void enablePolygonSmoothing(bool smooth); - virtual bool isPolygonSmoothingEnabled() const; - - // Material multipass - virtual sint beginMaterialMultiPass(); - virtual void setupMaterialPass(uint pass); - virtual void endMaterialMultiPass(); - - - - - - - /// \name Vertex Program - // @{ - - // Order of preference - // - activeVertexProgram - // - CMaterial pass[n] VP (uses activeVertexProgram, but does not override if one already set by code) - // - default generic VP that mimics fixed pipeline / no VP with fixed pipeline - - /** - * Does the driver supports vertex program, but emulated by CPU ? - */ - virtual bool isVertexProgramEmulated() const; - - /** Return true if the driver supports the specified vertex program profile. - */ - virtual bool supportVertexProgram(CVertexProgram::TProfile profile) const; - - /** Compile the given vertex program, return if successful. - * If a vertex program was set active before compilation, - * the state of the active vertex program is undefined behaviour afterwards. - */ - virtual bool compileVertexProgram(CVertexProgram *program); - - /** Set the active vertex program. This will override vertex programs specified in CMaterial render calls. - * Also used internally by setupMaterial(CMaterial) when getVertexProgram returns NULL. - * The vertex program is activated immediately. - */ - virtual bool activeVertexProgram(CVertexProgram *program); - // @} - - - - /// \name Pixel Program - // @{ - - // Order of preference - // - activePixelProgram - // - CMaterial pass[n] PP (uses activePixelProgram, but does not override if one already set by code) - // - PP generated from CMaterial (uses activePixelProgram, but does not override if one already set by code) - - /** Return true if the driver supports the specified pixel program profile. - */ - virtual bool supportPixelProgram(CPixelProgram::TProfile profile) const; - - /** Compile the given pixel program, return if successful. - * If a pixel program was set active before compilation, - * the state of the active pixel program is undefined behaviour afterwards. - */ - virtual bool compilePixelProgram(CPixelProgram *program); - - /** Set the active pixel program. This will override pixel programs specified in CMaterial render calls. - * Also used internally by setupMaterial(CMaterial) when getPixelProgram returns NULL. - * The pixel program is activated immediately. - */ - virtual bool activePixelProgram(CPixelProgram *program); - // @} - - - - /// \name Geometry Program - // @{ - - // Order of preference - // - activeGeometryProgram - // - CMaterial pass[n] PP (uses activeGeometryProgram, but does not override if one already set by code) - // - none - - /** Return true if the driver supports the specified pixel program profile. - */ - virtual bool supportGeometryProgram(CGeometryProgram::TProfile profile) const { return false; } - - /** Compile the given pixel program, return if successful. - * If a pixel program was set active before compilation, - * the state of the active pixel program is undefined behaviour afterwards. - */ - virtual bool compileGeometryProgram(CGeometryProgram *program) { return false; } - - /** Set the active pixel program. This will override pixel programs specified in CMaterial render calls. - * Also used internally by setupMaterial(CMaterial) when getGeometryProgram returns NULL. - * The pixel program is activated immediately. - */ - virtual bool activeGeometryProgram(CGeometryProgram *program) { return false; } - // @} - - - - /// \name Program parameters - // @{ - // Set parameters - virtual void setUniform1f(TProgram program, uint index, float f0); - virtual void setUniform2f(TProgram program, uint index, float f0, float f1); - virtual void setUniform3f(TProgram program, uint index, float f0, float f1, float f2); - virtual void setUniform4f(TProgram program, uint index, float f0, float f1, float f2, float f3); - virtual void setUniform1i(TProgram program, uint index, sint32 i0); - virtual void setUniform2i(TProgram program, uint index, sint32 i0, sint32 i1); - virtual void setUniform3i(TProgram program, uint index, sint32 i0, sint32 i1, sint32 i2); - virtual void setUniform4i(TProgram program, uint index, sint32 i0, sint32 i1, sint32 i2, sint32 i3); - virtual void setUniform1ui(TProgram program, uint index, uint32 ui0); - virtual void setUniform2ui(TProgram program, uint index, uint32 ui0, uint32 ui1); - virtual void setUniform3ui(TProgram program, uint index, uint32 ui0, uint32 ui1, uint32 ui2); - virtual void setUniform4ui(TProgram program, uint index, uint32 ui0, uint32 ui1, uint32 ui2, uint32 ui3); - virtual void setUniform3f(TProgram program, uint index, const NLMISC::CVector& v); - virtual void setUniform4f(TProgram program, uint index, const NLMISC::CVector& v, float f3); - virtual void setUniform4f(TProgram program, uint index, const NLMISC::CRGBAF& rgba); - virtual void setUniform4x4f(TProgram program, uint index, const NLMISC::CMatrix& m); - virtual void setUniform4fv(TProgram program, uint index, size_t num, const float *src); - virtual void setUniform4iv(TProgram program, uint index, size_t num, const sint32 *src); - virtual void setUniform4uiv(TProgram program, uint index, size_t num, const uint32 *src); - // Set builtin parameters - virtual void setUniformMatrix(TProgram program, uint index, TMatrix matrix, TTransform transform); - virtual void setUniformFog(TProgram program, uint index); - // Set feature parameters - virtual bool setUniformDriver(TProgram program); // set all driver-specific features params (based on program->features->DriverFlags) - virtual bool setUniformMaterial(TProgram program, CMaterial &material); // set all material-specific feature params (based on program->features->MaterialFlags) - virtual void setUniformParams(TProgram program, CGPUProgramParams ¶ms); // set all user-provided params from the storage - virtual bool isUniformProgramState() { return false; } - // @} - - - - - - virtual void enableVertexProgramDoubleSidedColor(bool doubleSided); - virtual bool supportVertexProgramDoubleSidedColor() const; - - // Occlusion query - virtual bool supportOcclusionQuery() const; - virtual IOcclusionQuery *createOcclusionQuery(); - virtual void deleteOcclusionQuery(IOcclusionQuery *oq); - - - - /** Shader implementation - * - * Shader can assume this states are setuped: - * TextureTransformFlags[n] = DISABLE; - * TexCoordIndex[n] = n; - * ColorOp[n] = DISABLE; - * AlphaOp[n] = DISABLE; - */ - bool activeShader(CD3DShaderFX *shd); - - // Bench - virtual void startBench (bool wantStandardDeviation = false, bool quick = false, bool reset = true); - virtual void endBench (); - virtual void displayBench (class NLMISC::CLog *log); - - - virtual void setCullMode(TCullMode cullMode); - virtual TCullMode getCullMode() const; - - virtual void enableStencilTest(bool enable); - virtual bool isStencilTestEnabled() const; - virtual void stencilFunc(TStencilFunc stencilFunc, int ref, uint mask); - virtual void stencilOp(TStencilOp fail, TStencilOp zfail, TStencilOp zpass); - virtual void stencilMask(uint mask); - - uint32 getMaxVertexIndex() const { return _MaxVertexIndex; } - - // *** Inline info - uint inlGetNumTextStages() const { return _NbNeLTextureStages; } - -//private: -public: - - // Hardware render variables, like matrices, render states - struct CRenderVariable - { - CRenderVariable() - { - NextModified = NULL; - Modified = false; - } - - // Type of render state - enum - { - RenderState = 0, - TextureState, - TextureIndexState, - TexturePtrState, - VertexProgramPtrState, - PixelShaderPtrState, - VertexProgramConstantState, - PixelShaderConstantState, - SamplerState, - MatrixState, - VBState, - IBState, - VertexDecl, - LightState, - RenderTargetState, - } Type; - CRenderVariable *NextModified; - bool Modified; - virtual void apply(CDriverD3D *driver) = 0; - }; - - // Render state - struct CRenderState : public CRenderVariable - { - CRenderState() - { - Type = RenderState; - Value= 0; - ValueSet = false; - } - D3DRENDERSTATETYPE StateID; - DWORD Value; - bool ValueSet; - virtual void apply(CDriverD3D *driver); - }; - - // Render texture state - struct CTextureState : public CRenderVariable - { - CTextureState() - { - Type = TextureState; - DeviceValue = 0xcccccccc; - } - DWORD StageID; - D3DTEXTURESTAGESTATETYPE StateID; - DWORD Value; - DWORD DeviceValue; - virtual void apply(CDriverD3D *driver); - }; - - - // Render texture index state - struct CTextureIndexState : public CRenderVariable - { - CTextureIndexState() - { - Type = TextureIndexState; - } - DWORD StageID; - DWORD TexGenMode; - DWORD UVChannel; - bool TexGen; - virtual void apply(CDriverD3D *driver); - }; - - // Render texture - struct CTexturePtrState : public CRenderVariable - { - CTexturePtrState() - { - Type = TexturePtrState; - Texture = NULL; - } - DWORD StageID; - LPDIRECT3DBASETEXTURE9 Texture; - virtual void apply(CDriverD3D *driver); - }; - - // Render texture - struct CVertexProgramPtrState : public CRenderVariable - { - CVertexProgramPtrState() - { - Type = VertexProgramPtrState; - VertexProgram = NULL; - } - LPDIRECT3DVERTEXSHADER9 VertexProgram; - // for debug - const CVertexProgram *VP; - virtual void apply(CDriverD3D *driver); - }; - - // Render texture - struct CPixelShaderPtrState : public CRenderVariable - { - CPixelShaderPtrState() - { - Type = PixelShaderPtrState; - PixelShader = NULL; - } - LPDIRECT3DPIXELSHADER9 PixelShader; - virtual void apply(CDriverD3D *driver); - }; - - // Vertex buffer constants state - struct CVertexProgramConstantState : public CRenderVariable - { - CVertexProgramConstantState() - { - Type = VertexProgramConstantState; - } - enum - { - Float= 0, - Int, - Undef, - } ValueType; - uint StateID; - DWORD Values[4]; - virtual void apply(CDriverD3D *driver); - }; - - // Pixel shader constants state - struct CPixelShaderConstantState : public CRenderVariable - { - CPixelShaderConstantState() - { - Type = PixelShaderConstantState; - } - enum - { - Float= 0, - Int, - Undef, - } ValueType; - uint StateID; - DWORD Values[4]; - virtual void apply(CDriverD3D *driver); - }; - - // Render sampler state - struct CSamplerState : public CRenderVariable - { - CSamplerState() - { - Type = SamplerState; - } - DWORD SamplerID; - D3DSAMPLERSTATETYPE StateID; - DWORD Value; - virtual void apply(CDriverD3D *driver); - }; - - // Render matrix - struct CMatrixState : public CRenderVariable - { - CMatrixState() - { - Type = MatrixState; - } - D3DTRANSFORMSTATETYPE TransformType; - D3DXMATRIX Matrix; - virtual void apply(CDriverD3D *driver); - }; - - // Render vertex buffer - struct CVBState : public CRenderVariable - { - CVBState() - { - Type = VBState; - VertexBuffer = NULL; - ColorOffset = 0; - } - IDirect3DVertexBuffer9 *VertexBuffer; - UINT Offset; - UINT Stride; - CVertexBuffer::TPreferredMemory PrefferedMemory; - DWORD Usage; // d3d vb usage - uint ColorOffset; // Fix for Radeon 7xxx series (see remark in CDriverD3D::createVertexDeclaration) - virtual void apply(CDriverD3D *driver); - }; - - // Render index buffer - struct CIBState : public CRenderVariable - { - CIBState() - { - Type = IBState; - IndexBuffer = NULL; - } - IDirect3DIndexBuffer9 *IndexBuffer; - virtual void apply(CDriverD3D *driver); - }; - - // Render vertex decl - struct CVertexDeclState : public CRenderVariable - { - CVertexDeclState() - { - Type = VertexDecl; - Decl = NULL; - DeclAliasDiffuseToSpecular = NULL; - DeclNoDiffuse = NULL; - Stride= 0; - AliasDiffuseToSpecular = false; - EnableVertexColor = false; - } - IDirect3DVertexDeclaration9 *Decl; - IDirect3DVertexDeclaration9 *DeclAliasDiffuseToSpecular; - IDirect3DVertexDeclaration9 *DeclNoDiffuse; - uint Stride; - bool AliasDiffuseToSpecular; - bool EnableVertexColor; - virtual void apply(CDriverD3D *driver); - }; - - // Render vertex buffer - struct CLightState : public CRenderVariable - { - CLightState() - { - Type = LightState; - Enabled = false; - SettingsTouched = false; - EnabledTouched = true; - Light.Type = D3DLIGHT_POINT; - Light.Range = 1; - Light.Falloff = 1; - Light.Position.x = 0; - Light.Position.y = 0; - Light.Position.z = 0; - Light.Direction.x = 1; - Light.Direction.y = 0; - Light.Direction.z = 0; - Light.Attenuation0 = 1; - Light.Attenuation1 = 1; - Light.Attenuation2 = 1; - Light.Theta = 0; - Light.Phi = 0; - } - uint8 LightIndex; - bool SettingsTouched; - bool EnabledTouched; - bool Enabled; - D3DLIGHT9 Light; - virtual void apply(CDriverD3D *driver); - }; - - // Render target - struct CRenderTargetState : public CRenderVariable - { - CRenderTargetState() - { - Type = RenderTargetState; - Target = NULL; - Texture = NULL; - Level = 0; - CubeFace = 0; - } - IDirect3DSurface9 *Target; - ITexture *Texture; - uint8 Level; - uint8 CubeFace; - virtual void apply(CDriverD3D *driver); - }; - - // material state - struct CMaterialState : public CRenderVariable - { - CMaterialState() - { - //Current.Power = -1.f; - Current.Diffuse.r = Current.Diffuse.g = Current.Diffuse.b = Current.Diffuse.a = 0.f; - Current.Ambient.r = Current.Ambient.g = Current.Ambient.b = Current.Ambient.a = 0.f; - Current.Specular.r = Current.Specular.g = Current.Specular.b = Current.Specular.a = 0.f; - Current.Emissive.r = Current.Emissive.g = Current.Emissive.b = Current.Emissive.a = 0.f; - Current.Power = 0.f; - } - D3DMATERIAL9 Current; - virtual void apply(CDriverD3D *driver); - }; - - - // Friends - friend void D3DWndProc(CDriverD3D *driver, HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam); - friend class CTextureDrvInfosD3D; - friend class CVBDrvInfosD3D; - friend class CIBDrvInfosD3D; - friend class CVolatileVertexBuffer; - friend class CVolatileIndexBuffer; - - // Init render states - void initRenderVariables(); - - // Reset render states - void resetRenderVariables(); - - // Replace all arguments of color / alpha operators in the pixel pipe with the given value - void replaceAllArgument(DWORD from, DWORD to, DWORD blendOpFrom); - - // Replace all arguments of color / alpha operators in the pixel pipe at the given stage with the given value - void replaceAllArgumentAtStage(uint stage, DWORD from, DWORD to, DWORD blendOpFrom); - void replaceAllRGBArgumentAtStage(uint stage, DWORD from, DWORD to, DWORD blendOpFrom); - void replaceAllAlphaArgumentAtStage(uint stage, DWORD from, DWORD to, DWORD blendOpFrom); - - // Replace a the given color / alpha op - void replaceArgumentAtStage(D3DTEXTURESTAGESTATETYPE state, DWORD stage, DWORD from, DWORD to); - - // Setup lighting & material so that it produces the given constant color (useful to simulate a per stage constant using diffuse) - void setupConstantDiffuseColorFromLightedMaterial(D3DCOLOR color); - - // Update all modified render states, reset current material - void updateRenderVariables(); - - // Update all modified render states, assume current material is still alive - void updateRenderVariablesInternal(); - - // Reset the driver, release the lost resources - bool reset (const GfxMode& mode); - - // Handle window size change - bool handlePossibleSizeChange(); - -public: - // Touch a render variable - inline void touchRenderVariable (CRenderVariable *renderVariable) - { - // Modified ? - if (!renderVariable->Modified) - { - // Link to modified states - renderVariable->NextModified = _ModifiedRenderState; - _ModifiedRenderState = renderVariable; - renderVariable->Modified = true; - } - } - - - - // Access render states - inline void setRenderState (D3DRENDERSTATETYPE renderState, DWORD value) - { - H_AUTO_D3D(CDriverD3D_setRenderState); - #ifdef NL_DEBUG - nlassert (_DeviceInterface); - nlassert (renderStateTexture); - setSamplerState (stage, D3DSAMP_ADDRESSU, d3dtext->WrapS); - setSamplerState (stage, D3DSAMP_ADDRESSV, d3dtext->WrapT); - setSamplerState (stage, D3DSAMP_MAGFILTER, d3dtext->MagFilter); - setSamplerState (stage, D3DSAMP_MINFILTER, d3dtext->MinFilter); - setSamplerState (stage, D3DSAMP_MIPFILTER, d3dtext->MipFilter); - setSamplerState (stage, D3DSAMP_MAXANISOTROPY, _AnisotropicFilter); - - // Profile, log the use of this texture - if (_SumTextureMemoryUsed) - { - // Insert the pointer of this texture - _TextureUsed.insert (d3dtext); - } - } - - // Access vertex program - inline void setVertexProgram (LPDIRECT3DVERTEXSHADER9 vertexProgram, const CVertexProgram *vp) - { - H_AUTO_D3D(CDriverD3D_setVertexProgram); - nlassert (_DeviceInterface); - - // Ref on the state -#ifdef NL_D3D_USE_RENDER_STATE_CACHE - NL_D3D_CACHE_TEST(CacheTest_VertexProgram, _VertexProgramCache.VertexProgram != vertexProgram) -#endif // NL_D3D_USE_RENDER_STATE_CACHE - { - _VertexProgramCache.VertexProgram = vertexProgram; - _VertexProgramCache.VP = vp; - touchRenderVariable (&_VertexProgramCache); - } - } - - // Access pixel shader - inline void setPixelShader (LPDIRECT3DPIXELSHADER9 pixelShader) - { - H_AUTO_D3D(CDriverD3D_setPixelShader); - nlassert (_DeviceInterface); - - // Ref on the state -#ifdef NL_D3D_USE_RENDER_STATE_CACHE - NL_D3D_CACHE_TEST(CacheTest_PixelShader, _PixelShaderCache.PixelShader != pixelShader) -#endif // NL_D3D_USE_RENDER_STATE_CACHE - { - _PixelShaderCache.PixelShader = pixelShader; - touchRenderVariable (&_PixelShaderCache); - } - } - - // Access vertex program constant - inline void setVertexProgramConstant (uint index, const float *values) - { - H_AUTO_D3D(CDriverD3D_setVertexProgramConstant); - nlassert (_DeviceInterface); - nlassert (index=256) - return (D3DTRANSFORMSTATETYPE)(MatrixStateRemap + type - 256); - else - return (uint)type; - } - inline void setMatrix (D3DTRANSFORMSTATETYPE type, const D3DXMATRIX &matrix) - { - H_AUTO_D3D(CDriverD3D_setMatrix); - nlassert (_DeviceInterface); - - // Remap high matrices indexes - type = (D3DTRANSFORMSTATETYPE)remapMatrixIndex (type); - nlassert ((int)type<(int)MaxMatrixState); - - CMatrixState &theMatrix = _MatrixCache[type]; -#ifdef NL_D3D_USE_RENDER_STATE_CACHE - bool doUpdate = (matrix._11 != theMatrix.Matrix._11) || - (matrix._12 != theMatrix.Matrix._12) || - (matrix._13 != theMatrix.Matrix._13) || - (matrix._14 != theMatrix.Matrix._14) || - (matrix._21 != theMatrix.Matrix._21) || - (matrix._22 != theMatrix.Matrix._22) || - (matrix._23 != theMatrix.Matrix._23) || - (matrix._24 != theMatrix.Matrix._24) || - (matrix._31 != theMatrix.Matrix._31) || - (matrix._32 != theMatrix.Matrix._32) || - (matrix._33 != theMatrix.Matrix._33) || - (matrix._34 != theMatrix.Matrix._34) || - (matrix._41 != theMatrix.Matrix._41) || - (matrix._42 != theMatrix.Matrix._42) || - (matrix._43 != theMatrix.Matrix._43) || - (matrix._44 != theMatrix.Matrix._44); - NL_D3D_CACHE_TEST(CacheTest_Matrix, doUpdate) -#endif // NL_D3D_USE_RENDER_STATE_CACHE - { - theMatrix.Matrix = matrix; - touchRenderVariable (&theMatrix); - } - } - - // Access texture states - inline void setRenderTarget (IDirect3DSurface9 *target, ITexture *texture, uint8 level, uint8 cubeFace) - { - H_AUTO_D3D(CDriverD3D_setRenderTarget); - nlassert (_DeviceInterface); - - // Ref on the state -#ifdef NL_D3D_USE_RENDER_STATE_CACHE - NL_D3D_CACHE_TEST(CacheTest_RenderTarget, _RenderTarget.Target != target) -#endif // NL_D3D_USE_RENDER_STATE_CACHE - { - _RenderTarget.Target = target; - _RenderTarget.Texture = texture; - _RenderTarget.Level = level; - _RenderTarget.CubeFace = cubeFace; - - touchRenderVariable (&_RenderTarget); - - _ScissorTouched = true; - } - } - - -public: - void setMaterialState(const D3DMATERIAL9 &material) - { - H_AUTO_D3D(setMaterialState); -#ifdef NL_D3D_USE_RENDER_STATE_CACHE - bool update = material.Power != _MaterialState.Current.Power || - material.Ambient != _MaterialState.Current.Ambient || - material.Emissive != _MaterialState.Current.Emissive || - material.Diffuse != _MaterialState.Current.Diffuse || - material.Specular != _MaterialState.Current.Specular; - NL_D3D_CACHE_TEST(CacheTest_MaterialState, update) -#endif - { - _MaterialState.Current = material; - touchRenderVariable(&_MaterialState); - } - } - - - - - // Get the d3dtext mirror of an existing setuped texture. - static inline CTextureDrvInfosD3D* getTextureD3D(ITexture& tex) - { - H_AUTO_D3D(CDriverD3D_getTextureD3D); - CTextureDrvInfosD3D* d3dtex; - d3dtex= (CTextureDrvInfosD3D*)(ITextureDrvInfos*)(tex.TextureDrvShare->DrvTexture); - return d3dtex; - } - - // Get the d3dtext mirror of an existing setuped pixel program. - static inline CPixelProgramDrvInfosD3D* getPixelProgramD3D(CPixelProgram& pixelProgram) - { - H_AUTO_D3D(CDriverD3D_getPixelProgramD3D); - CPixelProgramDrvInfosD3D* d3dPixelProgram; - d3dPixelProgram = (CPixelProgramDrvInfosD3D*)(IProgramDrvInfos*)(pixelProgram.m_DrvInfo); - return d3dPixelProgram; - } - - // Get the d3dtext mirror of an existing setuped vertex program. - static inline CVertexProgamDrvInfosD3D* getVertexProgramD3D(CVertexProgram& vertexProgram) - { - H_AUTO_D3D(CDriverD3D_getVertexProgramD3D); - CVertexProgamDrvInfosD3D* d3dVertexProgram; - d3dVertexProgram = (CVertexProgamDrvInfosD3D*)(IProgramDrvInfos*)(vertexProgram.m_DrvInfo); - return d3dVertexProgram; - } - - // *** Init helper - - bool isDepthFormatOk(UINT adapter, D3DDEVTYPE rasterizer, D3DFORMAT DepthFormat, D3DFORMAT AdapterFormat, D3DFORMAT BackBufferFormat); - bool isTextureFormatOk(UINT adapter, D3DDEVTYPE rasterizer, D3DFORMAT TextureFormat, D3DFORMAT AdapterFormat); - bool fillPresentParameter (D3DPRESENT_PARAMETERS ¶meters, D3DFORMAT &adapterFormat, const GfxMode& mode, const D3DDISPLAYMODE &adapterMode); - - // *** Texture helper - - D3DFORMAT getD3DDestTextureFormat (ITexture& tex); - // Generates the texture, degades it, creates / resizes the d3d surface. Don't fill the surface. - bool generateD3DTexture (ITexture& tex, bool textureDegradation, D3DFORMAT &destFormat, D3DFORMAT &srcFormat, bool &cube); - // Return the memory used by the surface described iwith the parameters - uint32 computeTextureMemoryUsage (uint width, uint height, uint levels, D3DFORMAT destFormat, bool cube); - // Upload a texture part - bool uploadTextureInternal (ITexture& tex, NLMISC::CRect& rect, uint8 destMipmap, uint8 srcMipmap, D3DFORMAT destFormat, D3DFORMAT srcFormat); - - // *** Matrix helper - - // Update _D3DModelView and _D3DModelViewProjection matrices. Call this if the model, the projection or the view matrix are modified - void updateMatrices (); - // Update the projection matrix. Call this if the driver resolution, the viewport or the frustum changes. - void updateProjectionMatrix (); - - // *** Vertex buffer helper - - // Create a vertex declaration - bool createVertexDeclaration (uint16 vertexFormat, const uint8 *typeArray, - IDirect3DVertexDeclaration9 **vertexDecl, - uint &colorOffset, - bool aliasDiffuseToSpecular, - bool bypassDiffuse, - uint *stride = NULL - ); - - // *** Index buffer helper - - // *** Multipass helpers - - void initInternalShaders(); - void releaseInternalShaders(); - bool setShaderTexture (uint textureHandle, ITexture *texture, CFXCache *cache); - - bool validateShader(CD3DShaderFX *shader); - - void activePass (uint pass) - { - H_AUTO_D3D(CDriverD3D_activePass); - if (_CurrentShader) - { - CShaderDrvInfosD3D *drvInfo = static_cast((IShaderDrvInfos*)_CurrentShader->_DrvInfo); - if (_CurrentMaterialInfo->FXCache) - { - nlassert(_CurrentMaterialInfo); - _CurrentMaterialInfo->FXCache->applyPass(*this, drvInfo, pass); - } - else - { -#if (DIRECT3D_VERSION >= 0x0900) && (D3D_SDK_VERSION >= 32) - drvInfo->Effect->BeginPass (pass); - drvInfo->Effect->EndPass (); -#else - drvInfo->Effect->Pass (pass); -#endif - } - } - - // Update render states - updateRenderVariablesInternal(); - } - - void beginMultiPass () - { - H_AUTO_D3D(CDriverD3D_beginMultiPass); - if (_CurrentShader) - { - // Does the shader validated ? - validateShader(_CurrentShader); - - // Init default state value - uint i; - for (i=0; i((IShaderDrvInfos*)_CurrentShader->_DrvInfo); - if (_CurrentMaterialInfo->FXCache) - { - nlassert(_CurrentMaterialInfo); - _CurrentMaterialInfo->FXCache->begin(drvInfo, this); - } - else - { - drvInfo->Effect->Begin (&_CurrentShaderPassCount, D3DXFX_DONOTSAVESTATE|D3DXFX_DONOTSAVESHADERSTATE); - } - } - else - // No shader setuped - _CurrentShaderPassCount = 1; - } - - void endMultiPass () - { - H_AUTO_D3D(CDriverD3D_endMultiPass); - if (_CurrentShader) - { - CShaderDrvInfosD3D *drvInfo = static_cast((IShaderDrvInfos*)_CurrentShader->_DrvInfo); - if (_CurrentMaterialInfo->FXCache) - { - _CurrentMaterialInfo->FXCache->end(drvInfo); - } - else - { - drvInfo->Effect->End (); - } - } - } - - // render helpers - bool renderPrimitives(D3DPRIMITIVETYPE primitiveType, uint numVertexPerPrim, CMaterial& mat, uint firstVertex, uint32 nPrims); - bool renderIndexedPrimitives(D3DPRIMITIVETYPE primitiveType, uint numVertexPerPrim, CMaterial& mat, uint32 firstIndex, uint32 nPrims, uint indexOffset = 0); - bool renderSimpleIndexedPrimitives(D3DPRIMITIVETYPE primitiveType, uint numVertexPerPrim, uint32 firstIndex, uint32 nPrims, uint indexOffset = 0); - void convertToIndices16(uint firstIndex, uint numIndices); - - // Returns true if this material needs a constant color for the diffuse component - static bool needsConstantForDiffuse (CMaterial &mat); - - /* Returns true if this normal needs constant. If true, numConstant is the number of needed constants, firstConstant is the first - constants needed. */ - static bool needsConstants (uint &numConstant, uint &firstConstant, uint &secondConstant, CMaterial &mat); - - // For normal shader, compute part of the pipeline that are worth setting - // For example : if alpha output if not used (no alpha test or blend), then the alpha part won't be set at all - static void computeRelevantTexEnv(CMaterial &mat, bool rgbPipe[IDRV_MAT_MAXTEXTURES], bool alphaPipe[IDRV_MAT_MAXTEXTURES]); - - // Build a pixel shader for normal shader - IDirect3DPixelShader9 *buildPixelShader (const CNormalShaderDesc &normalShaderDesc, bool unlightedNoVertexColor); - - - // Notify all the shaders drivers info that a device has been lost - void notifyAllShaderDrvOfLostDevice(); - // Notify all the shaders drivers info that a device has been reset - void notifyAllShaderDrvOfResetDevice(); - - // *** Debug helpers - - void setDebugMaterial(); - - // ** From ID3DXEffectStateManager -public: - HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, LPVOID *ppvObj); - ULONG STDMETHODCALLTYPE AddRef(VOID); - ULONG STDMETHODCALLTYPE Release(VOID); - HRESULT STDMETHODCALLTYPE LightEnable(DWORD Index, BOOL Enable); - HRESULT STDMETHODCALLTYPE SetFVF(DWORD FVF); - HRESULT STDMETHODCALLTYPE SetLight(DWORD Index, CONST D3DLIGHT9* pLight); - HRESULT STDMETHODCALLTYPE SetMaterial(CONST D3DMATERIAL9* pMaterial); - HRESULT STDMETHODCALLTYPE SetNPatchMode(FLOAT nSegments); - HRESULT STDMETHODCALLTYPE SetPixelShader(LPDIRECT3DPIXELSHADER9 pShader); - HRESULT STDMETHODCALLTYPE SetPixelShaderConstantB(UINT StartRegister, CONST BOOL* pConstantData, UINT RegisterCount); - HRESULT STDMETHODCALLTYPE SetPixelShaderConstantF(UINT StartRegister, CONST FLOAT* pConstantData, UINT RegisterCount); - HRESULT STDMETHODCALLTYPE SetPixelShaderConstantI(UINT StartRegister, CONST INT* pConstantData, UINT RegisterCount); - HRESULT STDMETHODCALLTYPE SetRenderState(D3DRENDERSTATETYPE State, DWORD Value); - HRESULT STDMETHODCALLTYPE SetSamplerState(DWORD Sampler, D3DSAMPLERSTATETYPE Type, DWORD Value); - HRESULT STDMETHODCALLTYPE SetTexture (DWORD Stage, LPDIRECT3DBASETEXTURE9 pTexture); - HRESULT STDMETHODCALLTYPE SetTextureStageState(DWORD Stage, D3DTEXTURESTAGESTATETYPE Type, DWORD Value); - HRESULT STDMETHODCALLTYPE SetTransform(D3DTRANSFORMSTATETYPE State, CONST D3DMATRIX* pMatrix); - HRESULT STDMETHODCALLTYPE SetVertexShader(LPDIRECT3DVERTEXSHADER9 pShader); - HRESULT STDMETHODCALLTYPE SetVertexShaderConstantB(UINT StartRegister, CONST BOOL* pConstantData, UINT RegisterCount); - HRESULT STDMETHODCALLTYPE SetVertexShaderConstantF(UINT StartRegister, CONST FLOAT* pConstantData, UINT RegisterCount); - HRESULT STDMETHODCALLTYPE SetVertexShaderConstantI(UINT StartRegister, CONST INT* pConstantData, UINT RegisterCount); -private: - - void findNearestFullscreenVideoMode(); - - TShaderDrvInfoPtrList _ShaderDrvInfos; - - // Windows - std::string _WindowClass; - HWND _HWnd; - sint32 _WindowX; - sint32 _WindowY; - bool _DestroyWindow; - bool _Maximized; - bool _HandlePossibleSizeChangeNextSize; - GfxMode _CurrentMode; - uint _Interval; - bool _FullScreen; - - // cursors - enum TColorDepth { ColorDepth16 = 0, ColorDepth32, ColorDepthCount }; - - TColorDepth _ColorDepth; - std::string _CurrName; - NLMISC::CRGBA _CurrCol; - uint8 _CurrRot; - uint _CurrHotSpotX; - uint _CurrHotSpotY; - float _CursorScale; - - nlCursor _DefaultCursor; - - bool _AlphaBlendedCursorSupported; - bool _AlphaBlendedCursorSupportRetrieved; - - class CCursor - { - public: - NLMISC::CBitmap Src; - TColorDepth ColorDepth; - uint OrigHeight; - float HotspotScale; - uint HotspotOffsetX; - uint HotspotOffsetY; - sint HotSpotX; - sint HotSpotY; - nlCursor Cursor; - NLMISC::CRGBA Col; - uint8 Rot; -#if defined(NL_OS_UNIX) && !defined(NL_OS_MAC) - Display *Dpy; -#endif - public: - CCursor(); - ~CCursor(); - CCursor& operator= (const CCursor& from); - - void reset(); - }; - - struct CStrCaseUnsensitiveCmp - { - bool operator()(const std::string &lhs, const std::string &rhs) const - { - return NLMISC::nlstricmp(lhs, rhs) < 0; - } - }; - - typedef std::map TCursorMap; - - TCursorMap _Cursors; - - // Directx - uint32 _Adapter; - D3DDEVTYPE _Rasterizer; - LPDIRECT3D9 _D3D; -public: - IDirect3DDevice9 *_DeviceInterface; -private: - - // Events - NLMISC::CEventEmitterMulti _EventEmitter; // this can contains a win emitter and eventually a direct input emitter - - // Some matrices (Local -> Model -> World -> Screen) -public: - CVector _PZBCameraPos; -private: - CMatrix _UserModelMtx; - CMatrix _UserViewMtx; -public: - CViewport _Viewport; -private: - D3DVIEWPORT9 _D3DViewport; -public: - CScissor _Scissor; -private: - float _OODeltaZ; // Backup znear and zfar - D3DXMATRIX _D3DSpecularWorldTex; // World (as in NeL) to model matrix. - D3DXMATRIX _D3DModelView; // Local to world (as in D3D) matrix. - D3DXMATRIX _D3DModelViewProjection; // Local to screen (as in D3D) matrix. - D3DXMATRIX _D3DInvModelView; // World (as in DX) to local matrix. - bool _ForceNormalize; - bool _FrustumPerspective; - bool _InvertCullMode; - bool _DoubleSided; - float _FrustumLeft; - float _FrustumRight; - float _FrustumTop; - float _FrustumBottom; - float _FrustumZNear; - float _FrustumZFar; - float _FogStart; - float _FogEnd; - - // Vertex memory available - uint32 _AGPMemoryAllocated; - uint32 _VRAMMemoryAllocated; - - // Textures caps - D3DFORMAT _PreferedTextureFormat[ITexture::UploadFormatCount]; - uint _ForceTextureResizePower; - bool _ForceDXTCCompression:1; - bool _TextureCubeSupported; - bool _VertexProgram; - bool _PixelProgram; - uint16 _PixelProgramVersion; - bool _DisableHardwareVertexProgram; - bool _DisableHardwarePixelProgram; - bool _DisableHardwareVertexArrayAGP; - bool _DisableHardwareIndexArrayAGP; - bool _DisableHardwarePixelShader; - bool _MADOperatorSupported; - bool _EMBMSupported; - bool _CubbedMipMapSupported; - bool _IsGeforce; - bool _NonPowerOfTwoTexturesSupported; - uint _MaxAnisotropy; - bool _AnisotropicMinSupported; - bool _AnisotropicMagSupported; - bool _AnisotropicMinCubeSupported; - bool _AnisotropicMagCubeSupported; - uint _NbNeLTextureStages; // Number of texture stage for NeL (max IDRV_MAT_MAXTEXTURES) - uint _MaxVerticesByVertexBufferHard; - uint _MaxLight; - uint32 _PixelShaderVersion; - uint32 _MaxPrimitiveCount; - uint32 _MaxVertexIndex; - uint _MaxNumPerStageConstantLighted; - uint _MaxNumPerStageConstantUnlighted; - - // Profiling - CPrimitiveProfile _PrimitiveProfileIn; - CPrimitiveProfile _PrimitiveProfileOut; - uint32 _AllocatedTextureMemory; - uint32 _NbSetupMaterialCall; - uint32 _NbSetupModelMatrixCall; - bool _SumTextureMemoryUsed; - std::set _TextureUsed; - - // VBHard Lock Profiling - struct CVBHardProfile - { - NLMISC::CRefPtr VBHard; - NLMISC::TTicks AccumTime; - // true if the VBHard was not always the same for the same chronogical place. - bool Change; - CVBHardProfile() - { - AccumTime= 0; - Change= false; - } - }; - - // Index buffer lock profiling - struct CIBProfile - { - NLMISC::CRefPtr IB; - NLMISC::TTicks AccumTime; - // true if the VBHard was not always the same for the same chronogical place. - bool Change; - CIBProfile() - { - AccumTime= 0; - Change= false; - } - }; - - // The vb hard Profiles in chronogical order. - bool _VBHardProfiling; - std::vector _VBHardProfiles; - uint _CurVBHardLockCount; - uint _NumVBHardProfileFrame; - void appendVBHardLockProfile(NLMISC::TTicks time, CVertexBuffer *vb); - - // The index buffer profile in chronogical order. - bool _IBProfiling; - std::vector _IBProfiles; - uint _CurIBLockCount; - uint _NumIBProfileFrame; -public: - NLMISC::TTicks _VolatileIBLockTime; - NLMISC::TTicks _VolatileVBLockTime; -private: - void appendIBLockProfile(NLMISC::TTicks time, CIndexBuffer *ib); - - // VBHard profile - std::set _VertexBufferHardSet; - - // The render variables -public: - CRenderState _RenderStateCache[MaxRenderState]; - CTextureState _TextureStateCache[MaxTexture][MaxTextureState]; - CTextureIndexState _TextureIndexStateCache[MaxTexture]; - CTexturePtrState _TexturePtrStateCache[MaxTexture]; - CSamplerState _SamplerStateCache[MaxSampler][MaxSamplerState]; - CMatrixState _MatrixCache[MaxMatrixState]; - CVertexProgramPtrState _VertexProgramCache; - CPixelShaderPtrState _PixelShaderCache; - CVertexProgramConstantState _VertexProgramConstantCache[MaxVertexProgramConstantState]; - CPixelShaderConstantState _PixelShaderConstantCache[MaxPixelShaderConstantState]; - CVertexDeclState _VertexDeclCache; - CLightState _LightCache[MaxLight]; - CRenderTargetState _RenderTarget; - CMaterialState _MaterialState; -private: - - // last activation of vertex buffer / index buffer - NLMISC::CRefPtr _LastIndexBufferInfo; - - // Vertex buffer cache - CVBState _VertexBufferCache; - uint _VertexBufferSize; - uint _VertexBufferOffset; -public: - bool _UseVertexColor; -private: - - // Index buffer cache - CIBState _IndexBufferCache; - uint _IndexBufferOffset; // Current index buffer offset - CIndexBuffer::TFormat _CurrIndexBufferFormat; // updated at call to activeIndexBuffer - - // The last vertex buffer needs vertex color - bool _FogEnabled; - - NLMISC::CRefPtr _VertexProgramUser; - NLMISC::CRefPtr _PixelProgramUser; - - // *** Internal resources - - // Current render pass - uint _CurrentRenderPass; - - - // Volatile double buffers - CVolatileVertexBuffer *_VolatileVertexBufferRAM[2]; - CVolatileVertexBuffer *_VolatileVertexBufferAGP[2]; - CVolatileIndexBuffer *_VolatileIndexBuffer16RAM[2]; - CVolatileIndexBuffer *_VolatileIndexBuffer16AGP[2]; - CVolatileIndexBuffer *_VolatileIndexBuffer32RAM[2]; - CVolatileIndexBuffer *_VolatileIndexBuffer32AGP[2]; - - // Special 16 bit index buffer for quads - IDirect3DIndexBuffer9 *_QuadIB; - - // Vertex declaration list - std::list _VertexDeclarationList; - - // Pixel shader list - std::list _NormalPixelShaders[2]; - - // Quad indexes - CIndexBuffer _QuadIndexes; - CIndexBuffer _QuadIndexesAGP; - - // The last setuped shader - CD3DShaderFX *_CurrentShader; - UINT _CurrentShaderPassCount; -public: - struct CTextureRef - { - CRefPtr NeLTexture; - LPDIRECT3DBASETEXTURE9 D3DTexture; - }; - const std::vector &getCurrentShaderTextures() const { return _CurrentShaderTextures; } -private: - std::vector _CurrentShaderTextures; - - // The last material setuped - CMaterial *_CurrentMaterial; -public: - CMaterialDrvInfosD3D *_CurrentMaterialInfo; -private: - - // Optim: To not test change in Materials states if just texture has changed. Very useful for landscape. - uint32 _MaterialAllTextureTouchedFlag; - - // The modified render variables list - CRenderVariable *_ModifiedRenderState; - - // Internal shaders - CD3DShaderFX _ShaderLightmap0; - CD3DShaderFX _ShaderLightmap1; - CD3DShaderFX _ShaderLightmap2; - CD3DShaderFX _ShaderLightmap3; - CD3DShaderFX _ShaderLightmap4; - CD3DShaderFX _ShaderLightmap0Blend; - CD3DShaderFX _ShaderLightmap1Blend; - CD3DShaderFX _ShaderLightmap2Blend; - CD3DShaderFX _ShaderLightmap3Blend; - CD3DShaderFX _ShaderLightmap4Blend; - CD3DShaderFX _ShaderLightmap0X2; - CD3DShaderFX _ShaderLightmap1X2; - CD3DShaderFX _ShaderLightmap2X2; - CD3DShaderFX _ShaderLightmap3X2; - CD3DShaderFX _ShaderLightmap4X2; - CD3DShaderFX _ShaderLightmap0BlendX2; - CD3DShaderFX _ShaderLightmap1BlendX2; - CD3DShaderFX _ShaderLightmap2BlendX2; - CD3DShaderFX _ShaderLightmap3BlendX2; - CD3DShaderFX _ShaderLightmap4BlendX2; - CD3DShaderFX _ShaderCloud; - CD3DShaderFX _ShaderWaterNoDiffuse; - CD3DShaderFX _ShaderWaterDiffuse; - - - // Backup frame buffer - IDirect3DSurface9 *_BackBuffer; - - // Static bitmap buffer to convert rgba to bgra - static std::vector _TempBuffer; - - // Version of the driver. Not the interface version!! Increment when implementation of the driver change. - static const uint32 ReleaseVersion; - - uint64 _SwapBufferCounter; - - // occlusion query - bool _OcclusionQuerySupported; - TOcclusionQueryList _OcclusionQueryList; - - // depth range - float _DepthRangeNear; - float _DepthRangeFar; - // - bool _ScissorTouched; - uint8 _CurrentUVRouting[MaxTexture]; - bool _MustRestoreLight; - D3DXMATRIX _D3DMatrixIdentity; - DWORD _FogColor; - uint _AnisotropicFilter; - - // stencil buffer - bool _CurStencilTest; - DWORD _CurStencilFunc; - DWORD _CurStencilRef; - DWORD _CurStencilMask; - DWORD _CurStencilOpFail; - DWORD _CurStencilOpZFail; - DWORD _CurStencilOpZPass; - DWORD _CurStencilWriteMask; - -public: - - // private, for access by COcclusionQueryD3D - COcclusionQueryD3D *_CurrentOcclusionQuery; - - // *** Lightmap Dynamic Light - // For Lightmap Dynamic Lighting - CLight _LightMapDynamicLight; - bool _LightMapDynamicLightEnabled; - bool _LightMapDynamicLightDirty; - CMaterial::TShader _CurrentMaterialSupportedShader; - // this is the backup of standard lighting (cause GL states may be modified by Lightmap Dynamic Lighting) - CLight _UserLight0; - bool _UserLightEnable[MaxLight]; - // methods to enable / disable DX light, without affecting _LightMapDynamicLight*, or _UserLight0* - void setLightInternal(uint8 num, const CLight& light); - void enableLightInternal(uint8 num, bool enable); - // on/off Lights for LightMap mode: only the first light is enabled in lightmap mode - void setupLightMapDynamicLighting(bool enable); - - TCullMode _CullMode; - - bool _Lost; - bool _SceneBegun; - - WORD _DesktopGammaRamp[256 * 3]; - bool _DesktopGammaRampValid; - - // for debug only - static bool _CacheTest[CacheTest_Count]; - - static std::vector _QuadIndices; // tmp : quads indices -> to allow support of quads on devices that don't have 32 bit indices - - // reset an index buffer and force it to be reallocated - void deleteIndexBuffer(CIBDrvInfosD3D *ib); - // Build 16 bit index buffer for quad - bool buildQuadIndexBuffer(); - - // Test if cursor is in the client area. always true when software cursor is used and window visible - // (displayed in software when DirectInput is used) - bool isSystemCursorInClientArea(); - - // Check if RGBA cursors are supported - bool isAlphaBlendedCursorSupported(); - - // Update cursor appearance - void updateCursor(bool forceRebuild = false); - - // Create default cursors - void createCursors(); - - // Release all cursors - void releaseCursors(); - - // Convert a NLMISC::CBitmap to nlCursor - bool convertBitmapToCursor(const NLMISC::CBitmap &bitmap, nlCursor &cursor, uint iconWidth, uint iconHeight, uint iconDepth, const NLMISC::CRGBA &col, sint hotSpotX, sint hotSpotY); - - // build a cursor from src, src should have the same size that the hardware cursor - // or a assertion is thrown - nlCursor buildCursor(const NLMISC::CBitmap &src, NLMISC::CRGBA col, uint8 rot, sint hotSpotX, sint hotSpotY); - - // reset the cursor shape to the system arrow - void setSystemArrow(); - - bool convertBitmapToIcon(const NLMISC::CBitmap &bitmap, HICON &icon, uint iconWidth, uint iconHeight, uint iconDepth, const NLMISC::CRGBA &col = NLMISC::CRGBA::White, sint hotSpotX = 0, sint hotSpotY = 0, bool cursor = false); - - virtual bool copyTextToClipboard(const ucstring &text); - virtual bool pasteTextFromClipboard(ucstring &text); - -public: - #ifdef NL_DEBUG - std::set _LockedBuffers; - #endif - - emptyProc ExitFunc; - - bool beginScene() - { - nlassert(!_SceneBegun); - if (_DeviceInterface->BeginScene() != D3D_OK) return false; - _SceneBegun = true; - return true; - } - - bool endScene() - { - nlassert(_SceneBegun); - if (_DeviceInterface->EndScene() != D3D_OK) return false; - _SceneBegun = false; - return true; - } - - bool hasSceneBegun() const { return _SceneBegun; } - - // Clip the wanted rectangle with window. return true if rect is not NULL. - bool clipRect(NLMISC::CRect &rect); - - friend class IShaderDrvInfos; - - void removeShaderDrvInfoPtr(ItShaderDrvInfoPtrList shaderIt); - -}; - -#define NL_D3DCOLOR_RGBA(rgba) (D3DCOLOR_ARGB(rgba.A,rgba.R,rgba.G,rgba.B)) -#define D3DCOLOR_NL_RGBA(rgba) (NLMISC::CRGBA((uint8)((rgba>>16)&0xff), (uint8)((rgba>>8)&0xff), (uint8)(rgba&0xff), (uint8)((rgba>>24)&0xff))) -#define NL_D3DCOLORVALUE_RGBA(dest,rgba) \ - dest.a=(float)rgba.A*(1.f/255.f);dest.r=(float)rgba.R*(1.f/255.f);dest.g=(float)rgba.G*(1.f/255.f);dest.b=(float)rgba.B*(1.f/255.f); -#define NL_D3D_MATRIX(d3d_mt,nl_mt) \ - { const float *nl_mt_ptr = nl_mt.get(); \ - d3d_mt._11 = nl_mt_ptr[0]; \ - d3d_mt._21 = nl_mt_ptr[4]; \ - d3d_mt._31 = nl_mt_ptr[8]; \ - d3d_mt._41 = nl_mt_ptr[12]; \ - d3d_mt._12 = nl_mt_ptr[1]; \ - d3d_mt._22 = nl_mt_ptr[5]; \ - d3d_mt._32 = nl_mt_ptr[9]; \ - d3d_mt._42 = nl_mt_ptr[13]; \ - d3d_mt._13 = nl_mt_ptr[2]; \ - d3d_mt._23 = nl_mt_ptr[6]; \ - d3d_mt._33 = nl_mt_ptr[10]; \ - d3d_mt._43 = nl_mt_ptr[14]; \ - d3d_mt._14 = nl_mt_ptr[3]; \ - d3d_mt._24 = nl_mt_ptr[7]; \ - d3d_mt._34 = nl_mt_ptr[11]; \ - d3d_mt._44 = nl_mt_ptr[15]; } -// build matrix for texture 2D transform (special case in D3D) -#define NL_D3D_TEX2D_MATRIX(d3d_mt,nl_mt) \ - { const float *nl_mt_ptr = nl_mt.get(); \ - d3d_mt._11 = nl_mt_ptr[0]; \ - d3d_mt._12 = nl_mt_ptr[1]; \ - d3d_mt._13 = nl_mt_ptr[3]; \ - d3d_mt._14 = 0.f; \ - d3d_mt._21 = nl_mt_ptr[4]; \ - d3d_mt._22 = nl_mt_ptr[5]; \ - d3d_mt._23 = nl_mt_ptr[7]; \ - d3d_mt._24 = 0.f; \ - d3d_mt._31 = nl_mt_ptr[12]; \ - d3d_mt._32 = nl_mt_ptr[13]; \ - d3d_mt._33 = nl_mt_ptr[15]; \ - d3d_mt._34 = 0.f; \ - d3d_mt._41 = 0.f; \ - d3d_mt._42 = 0.f; \ - d3d_mt._43 = 0.f; \ - d3d_mt._44 = 1.f; } - - - - - - -#define NL_D3DVECTOR_VECTOR(dest,vect) dest.x=(vect).x;dest.y=(vect).y;dest.z=(vect).z; -#define FTODW(f) (*((DWORD*)&(f))) -#define D3DCOLOR_FLOATS(floats,rgba) {floats[0]=(float)((rgba>>16)&0xff) * (1.f/255.f);floats[1]=(float)((rgba>>8)&0xff) * (1.f/255.f);\ - floats[2]=(float)(rgba&0xff) * (1.f/255.f);floats[3]=(float)((rgba>>24)&0xff) * (1.f/255.f);} -#define NL_FLOATS(floats,rgba) {floats[0] = (float)rgba.R * (1.f/255.f);floats[1] = (float)rgba.G * (1.f/255.f);\ - floats[2] = (float)rgba.B * (1.f/255.f);floats[3] = (float)rgba.A * (1.f/255.f);} - -// *************************************************************************** -// nbPixels is pixel count, not a byte count ! -inline void copyRGBA2BGRA (uint32 *dest, const uint32 *src, uint nbPixels) -{ - H_AUTO_D3D(CDriverD3D_copyRGBA2BGRA); - while (nbPixels != 0) - { - register uint32 color = *src; - *dest = (color & 0xff00ff00) | ((color&0xff)<<16) | ((color&0xff0000)>>16); - dest++; - src++; - nbPixels--; - } -} - - -// *************************************************************************** -// set a D3DCOLORVALUE -inline void setColor(D3DCOLORVALUE &dest, float r, float g, float b, float a) -{ - dest.r = r; - dest.g = g; - dest.b = b; - dest.a = a; -} - -// *************************************************************************** -// set a D3DCOLORVALUE from & D3DCOLOR -inline void setColor(D3DCOLORVALUE &dest, const D3DCOLOR &src) -{ - dest.r = (1.f / 255.f) * ((src >> 16) & 0xff); - dest.g = (1.f / 255.f) * ((src >> 8) & 0xff); - dest.b = (1.f / 255.f) * (src & 0xff); - dest.a = (1.f / 255.f) * (src >> 24); -} - -// *************************************************************************** -// set a D3DCOLORVALUE from a CRGBA -inline void setColor(D3DCOLORVALUE &dest, const NLMISC::CRGBA &src) -{ - dest.r = (1.f / 255.f) * src.R; - dest.g = (1.f / 255.f) * src.G; - dest.b = (1.f / 255.f) * src.B; - dest.a = (1.f / 255.f) * src.A; -} - -// *************************************************************************** -void fillQuadIndexes (uint16 *indexes, uint first, uint last); - -} // NL3D - -#ifndef NL_STATIC -extern HINSTANCE HInstDLL; -#endif - -#endif // NL_DRIVER_DIRECT3D_H diff --git a/code/nel/src/3d/driver/direct3d/driver_direct3d_index.cpp b/code/nel/src/3d/driver/direct3d/driver_direct3d_index.cpp deleted file mode 100644 index d7ee84303..000000000 --- a/code/nel/src/3d/driver/direct3d/driver_direct3d_index.cpp +++ /dev/null @@ -1,515 +0,0 @@ -// NeL - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as -// published by the Free Software Foundation, either version 3 of the -// License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -#include "stddirect3d.h" - -#include "nel/3d/index_buffer.h" -#include "nel/3d/light.h" -#include "nel/misc/rect.h" -#include "nel/3d/viewport.h" -#include "nel/3d/scissor.h" -#include "nel/3d/u_driver.h" - -#include "driver_direct3d.h" - -#ifdef DEBUG_NEW -#define new DEBUG_NEW -#endif - -using namespace std; -using namespace NLMISC; - -namespace NL3D -{ - -// *************************************************************************** - -CIBDrvInfosD3D::CIBDrvInfosD3D(CDriverD3D *drv, ItIBDrvInfoPtrList it, CIndexBuffer *ib) : IIBDrvInfos(drv, it, ib) -{ - H_AUTO_D3D(CIBDrvInfosD3D_CIBDrvInfosD3D) - Driver = drv; - IndexBuffer = NULL; - VolatileIndexBuffer = NULL; - -} - -// *************************************************************************** - -uint indexCount=0; - -CIBDrvInfosD3D::~CIBDrvInfosD3D() -{ - H_AUTO_D3D(CIBDrvInfosD3D_CIBDrvInfosD3DDtor); - // Restore non resident memory - if (IndexBufferPtr) - { - IndexBufferPtr->setLocation(CIndexBuffer::NotResident); - IndexBufferPtr= NULL; - } - - // release index buffer - if (IndexBuffer && !Volatile) - { - if (Driver) - { - if (Driver->_IndexBufferCache.IndexBuffer == IndexBuffer) - { - Driver->_IndexBufferCache.IndexBuffer = NULL; - Driver->touchRenderVariable(&Driver->_IndexBufferCache); - } - } - indexCount--; - IndexBuffer->Release(); - } -} - -// *************************************************************************** - -void *CIBDrvInfosD3D::lock (uint first, uint last, bool readOnly) -{ - H_AUTO_D3D(CIBDrvInfosD3D_lock); - nlassert (first != last); - CDriverD3D *driver = static_cast(_Driver); - - if (driver->getMaxVertexIndex() <= 0xffff && getFormat() != CIndexBuffer::Indices16) - { - nlassert(getFormat() == CIndexBuffer::Indices32); - // 32-bit index not supported -> uses RAM mirror - nlassert(!RamVersion.empty()); - return &RamVersion[0]; - } - else - { - if (Volatile) - { - // Lock the good buffer - CVolatileIndexBuffer **buffer = NULL; - if (getFormat() == CIndexBuffer::Indices16) - { - buffer = VolatileRAM ? (&driver->_VolatileIndexBuffer16RAM[driver->_CurrentRenderPass&1]):(&driver->_VolatileIndexBuffer16AGP[driver->_CurrentRenderPass&1]); - } - else if (getFormat() == CIndexBuffer::Indices32) - { - buffer = VolatileRAM ? (&driver->_VolatileIndexBuffer32RAM[driver->_CurrentRenderPass&1]):(&driver->_VolatileIndexBuffer32AGP[driver->_CurrentRenderPass&1]); - } - else - { - nlassert(0); - } - void *ptr = (*buffer)->lock ((last-first)*getIndexNumBytes(), Offset); - if (!ptr) - { - // buffer full, swap them - CVolatileIndexBuffer **bufferOther; - if (getFormat() == CIndexBuffer::Indices16) - { - bufferOther = VolatileRAM ? (&driver->_VolatileIndexBuffer16RAM[(driver->_CurrentRenderPass + 1) &1]):(&driver->_VolatileIndexBuffer16AGP[(driver->_CurrentRenderPass + 1 ) &1]); - } - else - { - bufferOther = VolatileRAM ? (&driver->_VolatileIndexBuffer32RAM[(driver->_CurrentRenderPass + 1) &1]):(&driver->_VolatileIndexBuffer32AGP[(driver->_CurrentRenderPass + 1 ) &1]); - } - std::swap(*buffer, *bufferOther); - (*buffer)->reset(); - ptr = (*buffer)->lock ((last-first)*getIndexNumBytes(), Offset); - nlassert(ptr); - } - nlassert(!VolatileIndexBuffer); - VolatileIndexBuffer = *buffer; - IndexBuffer = (*buffer)->IndexBuffer; - ptr = (uint8 *) ptr - first * getIndexNumBytes(); - - // Current lock time - VolatileLockTime = driver->_CurrentRenderPass; - - // Touch the index buffer - driver->touchRenderVariable (&driver->_IndexBufferCache); - - return ptr; - } - else - { - nlassert (IndexBuffer); - // Lock Profile? - TTicks beforeLock = 0; - if(driver->_IBProfiling /*&& Hardware*/) - { - beforeLock= CTime::getPerformanceTime(); - } - void *pbData; - HRESULT result = IndexBuffer->Lock ( first*getIndexNumBytes(), (last-first)*getIndexNumBytes(), &pbData, readOnly?D3DLOCK_READONLY:0); - nlassert(result == D3D_OK); - // Lock Profile? - if(driver->_IBProfiling /*&& Hardware*/) - { - TTicks afterLock; - afterLock= CTime::getPerformanceTime(); - driver->appendIBLockProfile(afterLock-beforeLock, IndexBufferPtr); - } - if (result == D3D_OK) return pbData; - } - } - return NULL; -} - -// *************************************************************************** - -void CIBDrvInfosD3D::unlock (uint /* first */, uint /* last */) -{ - H_AUTO_D3D(CIBDrvInfosD3D_unlock) - CDriverD3D *driver = static_cast(_Driver); - if (driver->getMaxVertexIndex() > 0xffff || getFormat() == CIndexBuffer::Indices16) - { - if (Volatile) - { - nlassert(VolatileIndexBuffer); - VolatileIndexBuffer->unlock (); - VolatileIndexBuffer = NULL; - } - else - { - if (IndexBuffer) IndexBuffer->Unlock (); - } - } -} - -// *************************************************************************** - -DWORD RemapIndexBufferUsage[CIndexBuffer::LocationCount]= -{ - D3DUSAGE_DYNAMIC, // RAMResident - D3DUSAGE_DYNAMIC|D3DUSAGE_WRITEONLY, // AGPResident - D3DUSAGE_WRITEONLY, // VRAMResident - 0, // Not used -}; - -// *************************************************************************** - -D3DPOOL RemapIndexBufferPool[CIndexBuffer::LocationCount]= -{ - D3DPOOL_SYSTEMMEM, // RAMResident - D3DPOOL_DEFAULT, // AGPResident - D3DPOOL_DEFAULT, // VRAMResident - D3DPOOL_DEFAULT, // Not used -}; - -// *************************************************************************** - -bool CDriverD3D::activeIndexBuffer(CIndexBuffer& IB) -{ - H_AUTO_D3D(CDriverD3D_activeIndexBuffer) - - // Must not be locked - nlassert (!IB.isLocked()); - - // Must not be empty - if (IB.capacity() == 0) - return false; - - const bool touched = (IB.getTouchFlags() & (CIndexBuffer::TouchedReserve|CIndexBuffer::TouchedIndexFormat)) != 0; - CIBDrvInfosD3D *info = static_cast(static_cast(IB.DrvInfos)); - - // Volatile buffers must be filled at each pass (exception if emulated) - if (_MaxVertexIndex > 0xffff) - { - nlassertex (!info || !info->Volatile || IB.getKeepLocalMemory() || (info->VolatileLockTime == _CurrentRenderPass), ("Volatile buffers must be filled at each pass")); - } - - // Build the driver info - if (touched) - { - // Delete previous index buffer info - if (IB.DrvInfos) - { - delete IB.DrvInfos; - nlassert (IB.DrvInfos == NULL); - } - - // Rebuild it - _IBDrvInfos.push_front (NULL); - ItIBDrvInfoPtrList ite = _IBDrvInfos.begin(); - info = new CIBDrvInfosD3D(this, ite, &IB); - *ite = info; - // Create the index buffer - const uint size = (uint)IB.capacity(); - uint preferredMemory = 0; - if (_DisableHardwareIndexArrayAGP) - { - preferredMemory = CIndexBuffer::RAMResident; - info->Volatile = false; - } - else - { - switch (IB.getPreferredMemory ()) - { - case CIndexBuffer::RAMPreferred: - preferredMemory = CIndexBuffer::RAMResident; - info->Volatile = false; - break; - case CIndexBuffer::AGPPreferred: - preferredMemory = CIndexBuffer::AGPResident; - info->Volatile = false; - break; - case CIndexBuffer::StaticPreferred: - if (getStaticMemoryToVRAM()) - preferredMemory = CIndexBuffer::VRAMResident; - else - preferredMemory = CIndexBuffer::AGPResident; - info->Volatile = false; - break; - case CIndexBuffer::RAMVolatile: - preferredMemory = CIndexBuffer::RAMResident; - info->Volatile = true; - break; - case CIndexBuffer::AGPVolatile: - preferredMemory = CIndexBuffer::AGPResident; - info->Volatile = true; - break; - } - } - - // if 32 bit index not supported, the index buffer will be reformated so return a RAM mirror - // Real index buffer will be allocated if indices are not modified (e.g a single lock is used to update the content) - if (_MaxVertexIndex <= 0xffff && IB.getFormat() == CIndexBuffer::Indices32) - { - info->RamVersion.resize(size); - info->IndexBuffer = NULL; - } - else - { - // Volatile index buffer - if (info->Volatile) - { - nlassert (info->IndexBuffer == NULL); - info->VolatileRAM = preferredMemory == CIndexBuffer::RAMResident; - } - else - { - // Offset will be 0 - info->Offset = 0; - bool success = false; - do - { - success = _DeviceInterface->CreateIndexBuffer(size*IB.getIndexNumBytes(), - RemapIndexBufferUsage[preferredMemory], - IB.getFormat() == CIndexBuffer::Indices32 ? D3DFMT_INDEX32 : D3DFMT_INDEX16, - RemapIndexBufferPool[preferredMemory], - &(info->IndexBuffer), NULL) == D3D_OK; - - if (success) - break; - } - while (preferredMemory--); - if (!success) - return false; - ++indexCount; - } - // Force the vertex buffer update - touchRenderVariable (&_IndexBufferCache); - } - // Release the local index buffer - IB.DrvInfos = info; - IB.setLocation((CIndexBuffer::TLocation)preferredMemory); - } - - // Set the current index buffer - nlassert (info); - _LastIndexBufferInfo = info; - - // Fill the buffer if in local memory - IB.fillBuffer (); - - _CurrIndexBufferFormat = IB.getFormat(); - - // Set the index buffer - if (_MaxVertexIndex > 0xffff || IB.getFormat() == CIndexBuffer::Indices16) - { - setIndexBuffer (info->IndexBuffer, info->Offset); - } - return true; -} - -// *************************************************************************** - -bool CDriverD3D::supportIndexBufferHard() const -{ - H_AUTO_D3D(CDriverD3D_supportIndexBufferHard); - return !_DisableHardwareIndexArrayAGP; -} - -// *************************************************************************** - -void CDriverD3D::disableHardwareIndexArrayAGP() -{ - H_AUTO_D3D(CDriverD3D_disableHardwareIndexArrayAGP) - _DisableHardwareIndexArrayAGP = true; -} - -// *************************************************************************** -// CVolatileIndexBuffer -// *************************************************************************** - -CVolatileIndexBuffer::CVolatileIndexBuffer() -{ - H_AUTO_D3D(CVolatileIndexBuffer_CVolatileIndexBuffer); - IndexBuffer = NULL; - Locked = false; -} - -// *************************************************************************** - -CVolatileIndexBuffer::~CVolatileIndexBuffer() -{ - H_AUTO_D3D(CVolatileIndexBuffer_CVolatileIndexBufferDtor); - release (); -} - -// *************************************************************************** - -void CVolatileIndexBuffer::release () -{ - H_AUTO_D3D(CVolatileIndexBuffer_release); - if (IndexBuffer) - IndexBuffer->Release(); - IndexBuffer = NULL; -} - -// *************************************************************************** -void CVolatileIndexBuffer::init (CIndexBuffer::TLocation location, uint sizeInBytes, uint maxSize, CDriverD3D *driver, CIndexBuffer::TFormat format) -{ - H_AUTO_D3D(CVolatileIndexBuffer_init); - release(); - if (maxSize < sizeInBytes) maxSize = sizeInBytes; - - // Init the buffer - Location = location; - Size = sizeInBytes; - MaxSize = maxSize; - Driver = driver; - - nlassert(format == CIndexBuffer::Indices16 || format == CIndexBuffer::Indices32); - if (format == CIndexBuffer::Indices32) - { - // device must support 32 bits indices - nlassert(driver->_MaxVertexIndex > 0xffff); - } - D3DFORMAT d3dFormat = format == CIndexBuffer::Indices16 ? D3DFMT_INDEX16 : D3DFMT_INDEX32; - - // Allocate the vertex buffer - if (Driver->_DeviceInterface->CreateIndexBuffer(sizeInBytes, RemapIndexBufferUsage[location], - d3dFormat, RemapIndexBufferPool[location], &IndexBuffer, NULL) != D3D_OK) - { - // Location in RAM must not failed - nlassert (location != CIndexBuffer::RAMResident); - - // Allocate in RAM - nlverify (Driver->_DeviceInterface->CreateIndexBuffer(sizeInBytes, RemapIndexBufferUsage[CIndexBuffer::RAMResident], - d3dFormat, RemapIndexBufferPool[CIndexBuffer::RAMResident], &IndexBuffer, NULL) != D3D_OK); - Location = CIndexBuffer::RAMResident; - } - Format = format; -} - - - - -// *************************************************************************** -void *CVolatileIndexBuffer::lock (uint size, uint &offset) -{ - nlassertex(!Locked, ("Volatile buffer usage should follow an atomic lock/unlock/render sequence")); - H_AUTO_D3D(CVolatileIndexBuffer_lock); - /* If not enough room to allocate this buffer, resise the buffer to Size+Size/2 but do not reset CurrentIndex - * to be sure the buffer will be large enough next pass. */ - - // Enough room for this index ? - if (CurrentIndex+size > Size) - { - if (CurrentIndex+size > MaxSize && CurrentIndex != 0) - { - return NULL; // max size exceeded -> can reallocate only if we are at start of block - } - // No, reallocate - init (Location, std::max (std::min(Size+Size/2, MaxSize), CurrentIndex+size), MaxSize, Driver, Format); - } - // Lock Profile? - TTicks beforeLock = 0; - if(Driver->_IBProfiling /*&& Hardware*/) - { - beforeLock= CTime::getPerformanceTime(); - } - // Lock the buffer, noblocking lock here if not the first allocation since a reset - VOID *pbData; - if (CurrentIndex==0) - { - nlverify (IndexBuffer->Lock (0, size, &pbData, 0) == D3D_OK); - } - else - { - nlverify (IndexBuffer->Lock (CurrentIndex, size, &pbData, D3DLOCK_NOOVERWRITE) == D3D_OK); - } - if(Driver->_IBProfiling /*&& Hardware*/) - { - TTicks afterLock; - afterLock= CTime::getPerformanceTime(); - Driver->_VolatileIBLockTime += afterLock - beforeLock; - } - - // Old buffer position - offset = CurrentIndex / (Format == CIndexBuffer::Indices32 ? sizeof(uint32) : sizeof(uint16)); - - // New buffer position - CurrentIndex += size; - Locked = true; - return pbData; -} - -// *************************************************************************** - -void CVolatileIndexBuffer::unlock () -{ - H_AUTO_D3D(CVolatileIndexBuffer_unlock); - nlassertex(Locked, ("Volatile buffer usage should follow an atomic lock/unlock/render sequence")); - nlverify (IndexBuffer->Unlock () == D3D_OK); - Locked = false; -} - -// *************************************************************************** -void CVolatileIndexBuffer::reset () -{ - H_AUTO_D3D(CVolatileIndexBuffer_reset); - CurrentIndex = 0; -} - -// *************************************************************************** -bool CDriverD3D::buildQuadIndexBuffer() -{ - // this code will becomes useless when 16 bits buffer are really supported - nlassert(!_QuadIB); - uint numQuads = std::min(MAX_NUM_QUADS, (uint) (_MaxPrimitiveCount * 2)); // 2 primitives for each quads - HRESULT r = _DeviceInterface->CreateIndexBuffer(sizeof(uint16) * 6 * numQuads, D3DUSAGE_DYNAMIC, D3DFMT_INDEX16, D3DPOOL_SYSTEMMEM, &_QuadIB, NULL); - if (r != D3D_OK) return false; - void *datas; - r = _QuadIB->Lock(0, sizeof(uint16) * 6 * numQuads, &datas, 0); - if (r != D3D_OK) return false; - fillQuadIndexes((uint16 *) datas, 0, 6 * numQuads); - _QuadIB->Unlock(); - return true; -} - - -// *************************************************************************** - -} // NL3D diff --git a/code/nel/src/3d/driver/direct3d/driver_direct3d_inputs.cpp b/code/nel/src/3d/driver/direct3d/driver_direct3d_inputs.cpp deleted file mode 100644 index d26741faf..000000000 --- a/code/nel/src/3d/driver/direct3d/driver_direct3d_inputs.cpp +++ /dev/null @@ -1,475 +0,0 @@ -// NeL - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as -// published by the Free Software Foundation, either version 3 of the -// License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -#include "stddirect3d.h" -#include "driver_direct3d.h" - -#ifdef DEBUG_NEW -#define new DEBUG_NEW -#endif - -using namespace std; -using namespace NLMISC; - -namespace NL3D -{ - -// ************************************************************************************* -CDriverD3D::CCursor::CCursor() : ColorDepth(CDriverD3D::ColorDepth32), - OrigHeight(32), - HotspotScale(1.f), - HotspotOffsetX(0), - HotspotOffsetY(0), - HotSpotX(0), - HotSpotY(0), - Cursor(EmptyCursor), - Col(CRGBA::White), - Rot(0) -{ -} - -// ************************************************************************************* -CDriverD3D::CCursor::~CCursor() -{ - reset(); -} - -// ************************************************************************************* -void CDriverD3D::CCursor::reset() -{ - if (Cursor != EmptyCursor) - { - DestroyIcon(Cursor); - } -} - -// ************************************************************************************* -CDriverD3D::CCursor& CDriverD3D::CCursor::operator= (const CDriverD3D::CCursor& from) -{ - if (&from == this) - return *this; - Src = from.Src; // requires more than a surface copy - OrigHeight = from.OrigHeight; - HotspotScale = from.HotspotScale; - HotspotOffsetX = from.HotspotOffsetX; - HotspotOffsetY = from.HotspotOffsetY; - HotSpotX = from.HotSpotX; - HotSpotY = from.HotSpotY; - Cursor = from.Cursor; - Col = from.Col; - Rot = from.Rot; - return *this; -} - -// ************************************************************************************* -bool CDriverD3D::isAlphaBlendedCursorSupported() -{ - if (!_AlphaBlendedCursorSupportRetrieved) - { - // Support starts with windows 2000 (not only from XP as seen in most docs) - // NB : Additionnaly, could query D3D caps to know if - // color hardware cursor is supported, not only emulated, - // but can't be sure that using the win32 api 'SetCursor' uses the same resources - // So far, seems to be supported on any modern card used by the game anyway ... - OSVERSIONINFO osvi; - osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); - if (GetVersionEx(&osvi)) - { - _AlphaBlendedCursorSupported = (osvi.dwMajorVersion >= 5); - } - - _AlphaBlendedCursorSupportRetrieved = true; - } - - return _AlphaBlendedCursorSupported; -} - -// ************************************************************************************* -void CDriverD3D::addCursor(const std::string &name, const NLMISC::CBitmap &cursorBitmap) -{ - if (!isAlphaBlendedCursorSupported()) return; - - nlassert(cursorBitmap.getWidth() != 0); - nlassert(cursorBitmap.getHeight() != 0); - - // find used part base on alpha, to avoid too much shrinking - const CRGBA *pixels = (const CRGBA *) &cursorBitmap.getPixels()[0]; - uint minX, maxX, minY, maxY; - uint width = cursorBitmap.getWidth(); - uint height = cursorBitmap.getHeight(); - // - minX = 0; - for (uint x = 0; x < width; ++x) - { - bool stop = false; - minX = x; - for (uint y = 0; y < height; ++y) - { - if(pixels[x + y * width].A != 0) - { - stop = true; - break; - } - } - if (stop) break; - } - // - maxX = width - 1; - for (sint x = width - 1; x >= 0; --x) - { - bool stop = false; - maxX = (uint) x; - for (uint y = 0; y < height; ++y) - { - if(pixels[x + y * width].A != 0) - { - stop = true; - break; - } - } - if (stop) break; - } - // - minY = 0; - for (uint y = 0; y < height; ++y) - { - bool stop = false; - minY = y; - for (uint x = 0; x < width; ++x) - { - if(pixels[x + y * width].A != 0) - { - stop = true; - break; - } - } - if (stop) break; - } - // - maxY = height - 1; - for (sint y = height - 1; y >= 0; --y) - { - bool stop = false; - maxY = (uint) y; - for (uint x = 0; x < width; ++x) - { - if(pixels[x + y * width].A != 0) - { - stop = true; - break; - } - } - if (stop) break; - } - // - CCursor &curs = _Cursors[name]; - curs = CCursor(); // erase possible previous cursor - - uint destWidth = GetSystemMetrics(SM_CXCURSOR); - uint destHeight = GetSystemMetrics(SM_CYCURSOR); - - // build a square bitmap - uint tmpSize = std::max(maxX - minX + 1, maxY - minY + 1); - curs.Src.resize(tmpSize, tmpSize); - // blit at top left corner - curs.Src.blit(cursorBitmap, minX, minY, maxX - minX + 1, maxY - minY + 1, 0, 0); - - curs.OrigHeight = cursorBitmap.getHeight(); - curs.HotspotOffsetX = minX; - curs.HotspotOffsetY = minY; - // - curs.HotspotScale = _CursorScale; - clamp(curs.HotspotScale, 0.f, 1.f); - // first resampling, same for all cursors - tmpSize = (uint) (tmpSize * curs.HotspotScale); - if (tmpSize == 0) tmpSize = 1; - - if (curs.HotspotScale < 1.f) - { - curs.Src.resample(tmpSize, tmpSize); - } - - // shrink if necessary - if (tmpSize > destWidth || tmpSize > destHeight) // need to shrink ? - { - // constraint proportions - curs.HotspotScale *= std::min(float(destWidth) / tmpSize, float(destHeight) / tmpSize); - curs.Src.resample(destWidth, destHeight); - } - else - { - CBitmap final; - final.resize(destWidth, destHeight); - final.blit(&curs.Src, 0, 0); - curs.Src.swap(final); - } - - if (name == _CurrName) - { - updateCursor(); - } -} - -// ************************************************************************************* -void CDriverD3D::createCursors() -{ - _DefaultCursor = LoadCursor(NULL, IDC_ARROW); -} - -// ************************************************************************************* -void CDriverD3D::releaseCursors() -{ - SetClassLongPtr(_HWnd, GCLP_HCURSOR, 0); - - _Cursors.clear(); -} - -// ************************************************************************************* -void CDriverD3D::updateCursor(bool forceRebuild) -{ - setCursor(_CurrName, _CurrCol, _CurrRot, _CurrHotSpotX, _CurrHotSpotY, forceRebuild); -} - -// ************************************************************************************* -void CDriverD3D::setCursor(const std::string &name, NLMISC::CRGBA col, uint8 rot, sint hotSpotX, sint hotSpotY, bool forceRebuild) -{ - // don't update cursor if it's hidden or if custom cursors are not suppported - if (!isAlphaBlendedCursorSupported() || _CurrName == "none") return; - - _CurrName = name; - _CurrCol = col; - _CurrRot = rot; - _CurrHotSpotX = hotSpotX; - _CurrHotSpotY = hotSpotY; - - // cursor has to be changed next time - if (_CurrName.empty()) return; - - if (rot > 3) rot = 3; // same than 'CViewRenderer::drawRotFlipBitmapTiled - - TCursorMap::iterator it = _Cursors.find(name); - - nlCursor cursorHandle = _DefaultCursor; - - if (it != _Cursors.end()) - { - // Update cursor if modified or not already built - CCursor &curs = it->second; - hotSpotX = (sint) (curs.HotspotScale * (hotSpotX - curs.HotspotOffsetX)); - hotSpotY = (sint) (curs.HotspotScale * ((curs.OrigHeight - hotSpotY) - curs.HotspotOffsetY)); - if (curs.Cursor == EmptyCursor || - curs.HotSpotX != hotSpotX || - curs.HotSpotY != hotSpotY || - curs.Col != col || - curs.Rot != rot || - curs.ColorDepth != _ColorDepth || - forceRebuild - ) - { - curs.reset(); - curs.Cursor = buildCursor(curs.Src, col, rot, hotSpotX, hotSpotY); - curs.Col = col; - curs.Rot = rot; - curs.HotSpotX = hotSpotX; - curs.HotSpotY = hotSpotY; - curs.ColorDepth = _ColorDepth; - } - cursorHandle = curs.Cursor ? curs.Cursor : _DefaultCursor; - } - - if (isSystemCursorInClientArea() || isSystemCursorCaptured() || forceRebuild) - { -// if (CInputHandlerManager::getInstance()->hasFocus()) - { - ::SetCursor(cursorHandle); - SetClassLongPtr(_HWnd, GCLP_HCURSOR, (LONG_PTR) cursorHandle); // set default mouse icon to the last one - } - } - -} - -// ************************************************************************************* -void CDriverD3D::setCursorScale(float scale) -{ - _CursorScale = scale; -} - -// ************************************************************************************* -nlCursor CDriverD3D::buildCursor(const CBitmap &src, NLMISC::CRGBA col, uint8 rot, sint hotSpotX, sint hotSpotY) -{ - nlassert(isAlphaBlendedCursorSupported()); - - uint mouseW = GetSystemMetrics(SM_CXCURSOR); - uint mouseH = GetSystemMetrics(SM_CYCURSOR); - - CBitmap rotSrc = src; - if (rot > 3) rot = 3; // mimic behavior of 'CViewRenderer::drawRotFlipBitmapTiled' (why not rot & 3 ??? ...) - switch(rot) - { - case 0: break; - case 1: rotSrc.rot90CW(); break; - case 2: rotSrc.rot90CW(); rotSrc.rot90CW(); break; - case 3: rotSrc.rot90CCW(); break; - } - - // create a cursor from bitmap - nlCursor result = NULL; - convertBitmapToCursor(rotSrc, result, mouseW, mouseH, _ColorDepth == ColorDepth16 ? 16:32, col, hotSpotX, hotSpotY); - return result; -} - - -// ************************************************************************************* -void CDriverD3D::setSystemArrow() -{ - H_AUTO_D3D(CDriverD3D_setSystemArrow); - - if (isSystemCursorInClientArea() || isSystemCursorCaptured()) - { - SetCursor(_DefaultCursor); - } - - // set default mouse icon to the default one - SetClassLongPtr(_HWnd, GCLP_HCURSOR, (LONG_PTR) _DefaultCursor); -} - -// *************************************************************************** -void CDriverD3D::showCursor(bool b) -{ - H_AUTO_D3D(CDriverD3D_showCursor); - - if (_HWnd == EmptyWindow) - return; - - if (b) - { - // update current hardware icon to avoid to have the plain arrow - updateCursor(true); - - while (ShowCursor(b) < 0) - ; - } - else - { - while (ShowCursor(b) >= 0) - ; - } -} - -// *************************************************************************** -void CDriverD3D::setMousePos(float x, float y) -{ - H_AUTO_D3D(CDriverD3D_setMousePos); - - if (_HWnd == EmptyWindow) - return; - - // convert position size from float to pixels - sint x1 = (sint)((float)_CurrentMode.Width*x); - sint y1 = (sint)((float)_CurrentMode.Height*(1.0f-y)); - - // NeL window coordinate to MSWindows coordinates - POINT pt; - pt.x = x1; - pt.y = y1; - ClientToScreen (_HWnd, &pt); - SetCursorPos(pt.x, pt.y); -} - -// *************************************************************************** -void CDriverD3D::setCapture (bool b) -{ - H_AUTO_D3D(CDriverD3D_setCapture); - - if (b && isSystemCursorInClientArea() && !isSystemCursorCaptured()) - { - SetCapture(_HWnd); - } - else if (!b && isSystemCursorCaptured()) - { - // if hardware mouse and not in client area, then force to update its aspect by updating its pos - if (!isSystemCursorInClientArea()) - { - // force update - showCursor(true); - } - - ReleaseCapture(); - } -} - -// *************************************************************************** -bool CDriverD3D::isSystemCursorInClientArea() -{ - if (_FullScreen /* || !IsMouseCursorHardware() */) - { - return IsWindowVisible(_HWnd) != FALSE; - } - else - { - POINT cursPos; - // the mouse should be in the client area of the window - if (!GetCursorPos(&cursPos)) - { - return false; - } - HWND wnd = WindowFromPoint(cursPos); - if (wnd != _HWnd) - { - return false; // not the same window - } - // want that the mouse be in the client area - RECT clientRect; - if (!GetClientRect(_HWnd, &clientRect)) - { - return false; - } - POINT tl, br; - tl.x = clientRect.left; - tl.y = clientRect.top; - br.x = clientRect.right; - br.y = clientRect.bottom; - if (!ClientToScreen(_HWnd, &tl)) - { - return false; - } - if (!ClientToScreen(_HWnd, &br)) - { - return false; - } - if ((cursPos.x < tl.x) || (cursPos.x >= br.x) || (cursPos.y < tl.y) || (cursPos.y >= br.y)) - { - return false; - } - } - - return true; -} - -// *************************************************************************** -bool CDriverD3D::isSystemCursorCaptured() -{ - H_AUTO_D3D(CDriverD3D_isSystemCursorCaptured); - - return GetCapture() == _HWnd; -} - -bool CDriverD3D::convertBitmapToCursor(const NLMISC::CBitmap &bitmap, nlCursor &cursor, uint iconWidth, uint iconHeight, uint iconDepth, const NLMISC::CRGBA &col, sint hotSpotX, sint hotSpotY) -{ - return convertBitmapToIcon(bitmap, cursor, iconWidth, iconHeight, iconDepth, col, hotSpotX, hotSpotY, true); -} - -} // NL3D diff --git a/code/nel/src/3d/driver/direct3d/driver_direct3d_light.cpp b/code/nel/src/3d/driver/direct3d/driver_direct3d_light.cpp deleted file mode 100644 index f68caab3a..000000000 --- a/code/nel/src/3d/driver/direct3d/driver_direct3d_light.cpp +++ /dev/null @@ -1,213 +0,0 @@ -// NeL - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as -// published by the Free Software Foundation, either version 3 of the -// License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -#include "stddirect3d.h" - -#include "nel/3d/vertex_buffer.h" -#include "nel/3d/light.h" -#include "nel/3d/index_buffer.h" -#include "nel/misc/rect.h" -#include "nel/3d/viewport.h" -#include "nel/3d/scissor.h" -#include "nel/3d/u_driver.h" - -#include "driver_direct3d.h" - -#ifdef DEBUG_NEW -#define new DEBUG_NEW -#endif - -using namespace std; -using namespace NLMISC; - -namespace NL3D -{ - -// *************************************************************************** -const D3DLIGHTTYPE RemapLightTypeNeL2D3D[3]= -{ - D3DLIGHT_DIRECTIONAL, // CLight::DirectionalLight - D3DLIGHT_POINT, // CLight::PointLight - D3DLIGHT_SPOT, // CLight::SpotLight -}; - - -// *************************************************************************** -void CDriverD3D::setLight (uint8 index, const CLight &light) -{ - H_AUTO_D3D(CDriverD3D_setLight); - // bkup real light, for lightmap dynamic lighting purpose - if(index==0) - { - _UserLight0= light; - // because the D3D setup change, must dirt lightmap rendering - _LightMapDynamicLightDirty= true; - } - - setLightInternal(index, light); -} - - -// *************************************************************************** -void CDriverD3D::enableLight (uint8 index, bool enable) -{ - H_AUTO_D3D(CDriverD3D_enableLight); - // User call => set the User flag - if(index -// Copyright (C) 2010 Winch Gate Property Limited -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as -// published by the Free Software Foundation, either version 3 of the -// License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -#include "stddirect3d.h" - -#include "nel/3d/vertex_buffer.h" -#include "nel/3d/light.h" -#include "nel/3d/index_buffer.h" -#include "nel/3d/texture_bump.h" -#include "nel/misc/rect.h" -#include "nel/3d/viewport.h" -#include "nel/3d/scissor.h" -#include "nel/3d/u_driver.h" - -#include "driver_direct3d.h" - -#ifdef DEBUG_NEW -#define new DEBUG_NEW -#endif - -using namespace std; -using namespace NLMISC; - - - - -namespace NL3D -{ - -// *************************************************************************** - -const D3DBLEND RemapBlendTypeNeL2D3D[CMaterial::blendCount]= -{ - D3DBLEND_ONE, // one - D3DBLEND_ZERO, // zero - D3DBLEND_SRCALPHA, // srcalpha - D3DBLEND_INVSRCALPHA, // invsrcalpha - D3DBLEND_SRCCOLOR, // srccolor - D3DBLEND_INVSRCCOLOR, // invsrccolor - D3DBLEND_ONE, // blendConstantColor - D3DBLEND_ONE, // blendConstantInvColor - D3DBLEND_ONE, // blendConstantAlpha - D3DBLEND_ONE, // blendConstantInvAlpha -}; - -// *************************************************************************** - -const D3DCMPFUNC RemapZFuncTypeNeL2D3D[CMaterial::zfuncCount]= -{ - D3DCMP_ALWAYS, // always - D3DCMP_NEVER, // never - D3DCMP_EQUAL, // equal - D3DCMP_NOTEQUAL, // notequal - D3DCMP_LESS, // less - D3DCMP_LESSEQUAL, // lessequal - D3DCMP_GREATER, // greater - D3DCMP_GREATEREQUAL,// greaterequal -}; - -// *************************************************************************** - -// For stage 0 only -const D3DTEXTUREOP RemapTexOpType0NeL2D3D[CMaterial::TexOperatorCount]= -{ - D3DTOP_SELECTARG1, // Replace - D3DTOP_MODULATE, // Modulate - D3DTOP_ADD, // Add - D3DTOP_ADDSIGNED, // AddSigned - D3DTOP_BLENDTEXTUREALPHA, // InterpolateTexture - D3DTOP_BLENDDIFFUSEALPHA, // InterpolatePrevious - D3DTOP_BLENDDIFFUSEALPHA, // InterpolateDiffuse - D3DTOP_LERP, // InterpolateConstant - D3DTOP_BUMPENVMAP, // EMBM - D3DTOP_MULTIPLYADD // MAD -}; - -// *************************************************************************** - -const D3DTEXTUREOP RemapTexOpTypeNeL2D3D[CMaterial::TexOperatorCount]= -{ - D3DTOP_SELECTARG1, // Replace - D3DTOP_MODULATE, // Modulate - D3DTOP_ADD, // Add - D3DTOP_ADDSIGNED, // AddSigned - D3DTOP_BLENDTEXTUREALPHA, // InterpolateTexture - D3DTOP_BLENDCURRENTALPHA, // InterpolatePrevious - D3DTOP_BLENDDIFFUSEALPHA, // InterpolateDiffuse - D3DTOP_LERP, // InterpolateConstant - D3DTOP_BUMPENVMAP, // EMBM - D3DTOP_MULTIPLYADD // MAD -}; - -const uint OpNumArg[CMaterial::TexOperatorCount] = -{ - 1, // Replace - 2, // Modulate - 2, // Add - 2, // AddSigned - 2, // InterpolateTexture - 2, // InterpolatePrevious - 2, // InterpolateDiffuse - 3, // InterpolateConstant - 2, // EMBM - 3 // MAD -}; - - -// *************************************************************************** - -// For stage 0 only -const DWORD RemapTexArg0NeL2D3D[CMaterial::TexSourceCount]= -{ - D3DTA_TEXTURE, // Texture - D3DTA_DIFFUSE, // Previous - D3DTA_DIFFUSE, // Diffuse - D3DTA_TFACTOR, // todo hulud constant color D3DTA_CONSTANT, // Constant -}; - -// *************************************************************************** - -const DWORD RemapTexArgNeL2D3D[CMaterial::TexSourceCount]= -{ - D3DTA_TEXTURE, // Texture - D3DTA_CURRENT, // Previous - D3DTA_DIFFUSE, // Diffuse - D3DTA_TFACTOR, // todo hulud constant color D3DTA_CONSTANT, // Constant -}; - -// *************************************************************************** -const DWORD RemapTexOpArgTypeNeL2D3D[CMaterial::TexOperandCount]= -{ - 0, // SrcColor - D3DTA_COMPLEMENT, // InvSrcColor - D3DTA_ALPHAREPLICATE, // SrcAlpha - D3DTA_ALPHAREPLICATE|D3DTA_COMPLEMENT, // InvSrcAlpha -}; - - -// *************************************************************************** - -const DWORD RemapTexArg0TypeNeL2D3D[CMaterial::TexOperatorCount]= -{ - D3DTA_TFACTOR, // todo hulud constant color D3DTA_CONSTANT, // Replace not used - D3DTA_TFACTOR, // todo hulud constant color D3DTA_CONSTANT, // Modulate not used - D3DTA_TFACTOR, // todo hulud constant color D3DTA_CONSTANT, // Add not used - D3DTA_TFACTOR, // todo hulud constant color D3DTA_CONSTANT, // AddSigned not used - D3DTA_TFACTOR, // todo hulud constant color D3DTA_CONSTANT, // InterpolateTexture not used - D3DTA_TFACTOR, // todo hulud constant color D3DTA_CONSTANT, // InterpolatePrevious not used - D3DTA_TFACTOR, // todo hulud constant color D3DTA_CONSTANT, // InterpolateDiffuse not used - D3DTA_TFACTOR|D3DTA_ALPHAREPLICATE, // todo hulud constant color D3DTA_CONSTANT|D3DTA_ALPHAREPLICATE, // InterpolateConstant - D3DTA_TFACTOR, // todo hulud constant color D3DTA_CONSTANT, // EMBM not used - D3DTA_TFACTOR // todo hulud constant color D3DTA_CONSTANT // MAD -}; - -// *************************************************************************** - -const DWORD RemapTexGenTypeNeL2D3D[CMaterial::numTexCoordGenMode]= -{ - D3DTSS_TCI_SPHEREMAP, // TexCoordGenReflect - D3DTSS_TCI_CAMERASPACEPOSITION, // TexCoordGenObjectSpace, not supported - D3DTSS_TCI_CAMERASPACEPOSITION, // TexCoordGenEyeSpace -}; - -// *************************************************************************** - -const DWORD RemapTexGenCubeTypeNeL2D3D[CMaterial::numTexCoordGenMode]= -{ - D3DTSS_TCI_CAMERASPACEREFLECTIONVECTOR, // TexCoordGenReflect - D3DTSS_TCI_CAMERASPACEPOSITION, // TexCoordGenObjectSpace, not supported - D3DTSS_TCI_CAMERASPACEPOSITION, // TexCoordGenEyeSpace -}; - -// *************************************************************************** - -void CMaterialDrvInfosD3D::buildTexEnv (uint stage, const CMaterial::CTexEnv &env, bool textured) -{ - H_AUTO_D3D(CMaterialDrvInfosD3D_buildTexEnv) - if (textured) - { - // The source operator pointer - const DWORD *srcOp = (stage==0)?RemapTexArg0NeL2D3D:RemapTexArgNeL2D3D; - - ColorOp[stage] = ((stage==0)?RemapTexOpType0NeL2D3D:RemapTexOpTypeNeL2D3D)[env.Env.OpRGB]; - NumColorArg[stage] = OpNumArg[env.Env.OpRGB]; - if (env.Env.OpRGB == CMaterial::Mad) - { - ColorArg2[stage] = srcOp[env.Env.SrcArg0RGB]; - ColorArg2[stage] |= RemapTexOpArgTypeNeL2D3D[env.Env.OpArg0RGB]; - ColorArg1[stage] = srcOp[env.Env.SrcArg1RGB]; - ColorArg1[stage] |= RemapTexOpArgTypeNeL2D3D[env.Env.OpArg1RGB]; - ColorArg0[stage] = srcOp[env.Env.SrcArg2RGB]; - ColorArg0[stage] |= RemapTexOpArgTypeNeL2D3D[env.Env.OpArg2RGB]; - } - else - { - // Only used for InterpolateConstant - ColorArg0[stage] = RemapTexArg0TypeNeL2D3D[env.Env.OpRGB]; - ColorArg1[stage] = srcOp[env.Env.SrcArg0RGB]; - ColorArg1[stage] |= RemapTexOpArgTypeNeL2D3D[env.Env.OpArg0RGB]; - ColorArg2[stage] = srcOp[env.Env.SrcArg1RGB]; - ColorArg2[stage] |= RemapTexOpArgTypeNeL2D3D[env.Env.OpArg1RGB]; - } - AlphaOp[stage] = ((stage==0)?RemapTexOpType0NeL2D3D:RemapTexOpTypeNeL2D3D)[env.Env.OpAlpha]; - NumAlphaArg[stage] = OpNumArg[env.Env.OpAlpha]; - if (env.Env.OpAlpha == CMaterial::Mad) - { - AlphaArg2[stage] = srcOp[env.Env.SrcArg0Alpha]; - AlphaArg2[stage] |= RemapTexOpArgTypeNeL2D3D[env.Env.OpArg0Alpha]; - AlphaArg1[stage] = srcOp[env.Env.SrcArg1Alpha]; - AlphaArg1[stage] |= RemapTexOpArgTypeNeL2D3D[env.Env.OpArg1Alpha]; - AlphaArg0[stage] = srcOp[env.Env.SrcArg2Alpha]; - AlphaArg0[stage] |= RemapTexOpArgTypeNeL2D3D[env.Env.OpArg2Alpha]; - } - else - { - // Only used for InterpolateConstant - AlphaArg0[stage] = RemapTexArg0TypeNeL2D3D[env.Env.OpAlpha]; - AlphaArg1[stage] = srcOp[env.Env.SrcArg0Alpha]; - AlphaArg1[stage] |= RemapTexOpArgTypeNeL2D3D[env.Env.OpArg0Alpha]; - AlphaArg2[stage] = srcOp[env.Env.SrcArg1Alpha]; - AlphaArg2[stage] |= RemapTexOpArgTypeNeL2D3D[env.Env.OpArg1Alpha]; - } - ConstantColor[stage] = NL_D3DCOLOR_RGBA(env.ConstantColor); - } - else - { - // The stage is disabled, active only the lighting - ColorOp[stage] = D3DTOP_SELECTARG1; - DWORD opSrc = D3DTA_DIFFUSE; - ColorArg0[stage] = opSrc; - ColorArg1[stage] = opSrc; - ColorArg2[stage] = opSrc; - AlphaOp[stage] = D3DTOP_SELECTARG1; - AlphaArg0[stage] = opSrc; - AlphaArg1[stage] = opSrc; - AlphaArg2[stage] = opSrc; - ConstantColor[stage] = NL_D3DCOLOR_RGBA(CRGBA::White); - NumColorArg[stage] = 1; - NumAlphaArg[stage] = 1; - } -} - - -// *************************************************************************** -static inline DWORD replaceDiffuseWithConstant(DWORD value) -{ - if ((value & D3DTA_SELECTMASK) == D3DTA_DIFFUSE) - { - return (value & ~D3DTA_SELECTMASK) | D3DTA_TFACTOR; - } - return value; -} - - - - -// helpers to set shaders parameters - -// Set a color in the shader -static inline void setShaderParam(CMaterialDrvInfosD3D *pShader, uint index, INT value) -{ - nlassert(pShader->FXCache); - pShader->FXCache->Params.setColor(index, value); -} - -// Set a color -static inline void setShaderParam(CMaterialDrvInfosD3D *pShader, uint index, CRGBA color) -{ - nlassert(pShader->FXCache); - float values[4]; - NL_FLOATS(values, color); - pShader->FXCache->Params.setVector(index, D3DXVECTOR4(values[0], values[1], values[2], values[3])); -} - - -// Set a float value in the shader -static inline void setShaderParam(CMaterialDrvInfosD3D *pShader, uint index, FLOAT value) -{ - nlassert(pShader->FXCache); - pShader->FXCache->Params.setFloat(index, value); -} - - -// Set a vector of floats -static inline void setShaderParam(CMaterialDrvInfosD3D *pShader, uint index, float vector[4]) -{ - nlassert(pShader->FXCache); \ - pShader->FXCache->Params.setVector(index, D3DXVECTOR4(vector[0], vector[1], vector[2], vector[3])); -} - -// *************************************************************************** -bool CDriverD3D::setupMaterial(CMaterial &mat) -{ - H_AUTO_D3D(CDriverD3D_setupMaterial) - CMaterialDrvInfosD3D* pShader; - - // Stats - _NbSetupMaterialCall++; - - // Max texture - const uint maxTexture = inlGetNumTextStages(); - - // Update material - uint32 touched=mat.getTouched(); - - // No shader ? - if (!mat._MatDrvInfo) - { - // Insert into driver list. (so it is deleted when driver is deleted). - ItMatDrvInfoPtrList it= _MatDrvInfos.insert(_MatDrvInfos.end(), (NL3D::IMaterialDrvInfos*)NULL); - - *it = mat._MatDrvInfo = new CMaterialDrvInfosD3D(this, it); - - // Must create all OpenGL shader states. - touched = IDRV_TOUCHED_ALL; - } - pShader = static_cast((IMaterialDrvInfos*)(mat._MatDrvInfo)); - - // Now we can get the supported shader from the cache. - CMaterial::TShader matShader = _PixelProgramUser ? CMaterial::Program : mat.getShader(); - - if (_CurrentMaterialSupportedShader != CMaterial::Normal) - { - // because of multipass, some shader need to disable fog - // restore fog here - if(_FogEnabled && _FogColor != _RenderStateCache[D3DRS_FOGCOLOR].Value) - { - // restore fog - setRenderState(D3DRS_FOGCOLOR, _FogColor); - } - } - { - H_AUTO_D3D(CDriverD3D_setupMaterial_light) - // if the shader has changed since last time - if(matShader != _CurrentMaterialSupportedShader) - { - // if current shader is normal shader, then must restore uv routing, because it may have been changed by a previous shader (such as lightmap) - if (matShader == CMaterial::Normal) - { - for(uint k = 0; k < MaxTexture; ++k) - { - setTextureIndexUV (k, _CurrentUVRouting[k]); - } - } - // if old was lightmap, restore standard lighting - if(_CurrentMaterialSupportedShader==CMaterial::LightMap) - { - _MustRestoreLight = true; - } - - // if new is lightmap, setup dynamic lighting - if(matShader==CMaterial::LightMap) - { - setupLightMapDynamicLighting(true); - _MustRestoreLight = false; - } - } - if (mat.isLighted() && _MustRestoreLight) - { - setupLightMapDynamicLighting(false); - _MustRestoreLight = false; - } - // setup the global - _CurrentMaterialSupportedShader= matShader; - } - - - { - // count number of tex stages - uint numUsedTexStages = 0; - for(numUsedTexStages = 0; numUsedTexStages < IDRV_MAT_MAXTEXTURES; ++numUsedTexStages) - { - if (mat.getTexture(uint8(numUsedTexStages)) == NULL) break; - } - - H_AUTO_D3D(CDriverD3D_setupMaterial_touchupdate) - if (pShader->NumUsedTexStages != numUsedTexStages) - { - touched |= IDRV_TOUCHED_TEXENV; - } - // Something to setup ? - if (touched) - { - if (touched & IDRV_TOUCHED_SHADER) - { - delete pShader->FXCache; - pShader->FXCache = NULL; - // See if material actually needs a fx cache - if (mat.getShader() != CMaterial::Specular && mat.getShader() != CMaterial::Normal) - { - pShader->FXCache = new CFXCache; - } - } - /* Exception: if only Textures are modified in the material, no need to "Bind OpenGL States", or even to test - for change, because textures are activated alone, see below. - No problem with delete/new problem (see below), because in this case, IDRV_TOUCHED_ALL is set (see above). - */ - // If any flag is set (but a flag of texture). - if(touched & (~_MaterialAllTextureTouchedFlag)) - { - // Convert Material to driver shader. - if (touched & IDRV_TOUCHED_BLENDFUNC) - { - pShader->SrcBlend = RemapBlendTypeNeL2D3D[mat.getSrcBlend()]; - pShader->DstBlend = RemapBlendTypeNeL2D3D[mat.getDstBlend()]; - } - if (touched & IDRV_TOUCHED_ZFUNC) - { - pShader->ZComp = RemapZFuncTypeNeL2D3D[mat.getZFunc()]; - } - if (touched & IDRV_TOUCHED_LIGHTING) - { - // Lighted material ? - if (mat.isLighted()) - { - // Setup the color - NL_D3DCOLORVALUE_RGBA(pShader->Material.Diffuse, mat.getDiffuse()); - NL_D3DCOLORVALUE_RGBA(pShader->Material.Ambient, mat.getAmbient()); - NL_D3DCOLORVALUE_RGBA(pShader->Material.Emissive, mat.getEmissive()); - - // Specular - CRGBA spec = mat.getSpecular(); - if (spec != CRGBA::Black) - { - NL_D3DCOLORVALUE_RGBA(pShader->Material.Specular, spec); - pShader->SpecularEnabled = TRUE; - pShader->Material.Power = mat.getShininess(); - } - else - setRenderState (D3DRS_SPECULARENABLE, FALSE); - } - else - { - // No specular - pShader->SpecularEnabled = FALSE; - } - } - if (touched & IDRV_TOUCHED_COLOR) - { - // Setup the color - pShader->UnlightedColor = NL_D3DCOLOR_RGBA(mat.getColor()); - } - if (touched & IDRV_TOUCHED_ALPHA_TEST_THRE) - { - float alphaRef = (float)floor(mat.getAlphaTestThreshold() * 255.f + 0.5f); - clamp (alphaRef, 0.f, 255.f); - pShader->AlphaRef = (DWORD)alphaRef; - } - if (touched & IDRV_TOUCHED_SHADER) - { - // todo hulud d3d material shaders - // Get shader. Fallback to other shader if not supported. - // pShader->SupportedShader= getSupportedShader(mat.getShader()); - } - if (touched & IDRV_TOUCHED_TEXENV) - { - // Build the tex env cache. - // Do not do it for Lightmap and per pixel lighting , because done in multipass in a very special fashion. - // This avoid the useless multiple change of texture states per lightmapped object. - // Don't do it also for Specular because the EnvFunction and the TexGen may be special. - if(matShader == CMaterial::Normal) - { - uint stage; - for(stage=0 ; stagebuildTexEnv (stage, mat._TexEnvs[stage], mat.getTexture(uint8(stage)) != NULL); - } - } - } - if (touched & (IDRV_TOUCHED_TEXGEN|IDRV_TOUCHED_ALLTEX)) - { - uint stage; - for(stage=0 ; stageActivateSpecularWorldTexMT[stage] = false; - pShader->ActivateInvViewModelTexMT[stage] = false; - - // Build the tex env - ITexture *text= mat.getTexture(uint8(stage)); - if (text && text->isTextureCube()) - { - if (mat.getTexCoordGen(stage)) - { - // Texture cube - pShader->TexGen[stage] = RemapTexGenCubeTypeNeL2D3D[mat.getTexCoordGenMode (stage)]; - - // Texture matrix - pShader->ActivateSpecularWorldTexMT[stage] = mat.getTexCoordGenMode (stage) == CMaterial::TexCoordGenReflect; - } - else - { - pShader->TexGen[stage] = mat.getTexCoordGen(stage); - } - } - else - { - if (mat.getTexCoordGen(stage)) - { - pShader->TexGen[stage] = RemapTexGenTypeNeL2D3D[mat.getTexCoordGenMode (stage)]; - - // Texture matrix - pShader->ActivateInvViewModelTexMT[stage] = mat.getTexCoordGenMode (stage) == CMaterial::TexCoordGenObjectSpace; - } - else - { - pShader->TexGen[stage] = mat.getTexCoordGen(stage); - } - } - } - } - - // Does this material needs a pixel shader ? - if (touched & (IDRV_TOUCHED_TEXENV|IDRV_TOUCHED_BLEND|IDRV_TOUCHED_ALPHA_TEST)) - { - std::fill(pShader->RGBPipe, pShader->RGBPipe + IDRV_MAT_MAXTEXTURES, true); - std::fill(pShader->AlphaPipe, pShader->AlphaPipe + IDRV_MAT_MAXTEXTURES, true); - - pShader->MultipleConstantNoPixelShader = false; - pShader->MultiplePerStageConstant = false; - pShader->VertexColorLighted = mat.getLightedVertexColor(); - bool _needPixelShader = false; - pShader->ConstantIndex = 0xff; - pShader->ConstantIndex2 = 0xff; - if (matShader == CMaterial::Normal) - { - // Need of constants ? - uint numConstants; - uint firstConstant; - uint secondConstant; - needsConstants (numConstants, firstConstant, secondConstant, mat); - - pShader->ConstantIndex = uint8(firstConstant); - pShader->ConstantIndex2 = uint8(secondConstant); - - // Need a constant color for the diffuse component ? - pShader->NeedsConstantForDiffuse = needsConstantForDiffuse (mat); - - // Need pixel shader ? - #ifndef NL_FORCE_PIXEL_SHADER_USE_FOR_NORMAL_SHADERS - _needPixelShader = (numConstants > 1) || ((numConstants==1) && pShader->NeedsConstantForDiffuse); - #else // NL_FORCE_PIXEL_SHADER_USE_FOR_NORMAL_SHADERS - _needPixelShader = true; - #endif // NL_FORCE_PIXEL_SHADER_USE_FOR_NORMAL_SHADERS - if (_needPixelShader) - { - // The shader description - CNormalShaderDesc normalShaderDesc; - - // Setup descriptor - uint stage; - for(stage=0 ; stage<(uint)maxTexture; stage++) - { - // Stage used ? - normalShaderDesc.StageUsed[stage] = mat.getTexture (uint8(stage)) != NULL; - normalShaderDesc.TexEnvMode[stage] = mat.getTexEnvMode(uint8(stage)); - } - - if (_PixelProgram) - { - #ifdef NL_DEBUG_D3D - // Check, should not occur - nlassertex (_PixelShader, ("STOP : no pixel shader available. Can't render this material.")); - #endif // NL_DEBUG_D3D - - // Build the pixel shader - pShader->PixelShader = buildPixelShader (normalShaderDesc, false); - if (!mat.isLighted()) - pShader->PixelShaderUnlightedNoVertexColor = buildPixelShader (normalShaderDesc, true); - else - pShader->PixelShaderUnlightedNoVertexColor = NULL; - } - else - { - // Possible configurations are : - // unlighted, 1 constant diffuse + 1 per stage constant - // unlighted, 2 constants (second constant emulated with material emissive + diffuse), possibly with vertex color (aliased to specular) - - // If there are no pixel shader then we're likely to have three stage or less - pShader->MultipleConstantNoPixelShader = true; - pShader->MultiplePerStageConstant = numConstants > 1; - #ifdef NL_DEBUG - nlassert(numConstants <= 2); - #endif - if (secondConstant != 0xffffffff) - { - pShader->Constant2 = mat.getTexConstantColor(secondConstant); - } - pShader->PixelShader = NULL; - pShader->PixelShaderUnlightedNoVertexColor = NULL; - // compute relevant parts of the pipeline - computeRelevantTexEnv(mat, pShader->RGBPipe, pShader->AlphaPipe); - } - } - else - { - // compute relevant parts of the pipeline - computeRelevantTexEnv(mat, pShader->RGBPipe, pShader->AlphaPipe); - } - } - else - { - // Other shaders - pShader->MultipleConstantNoPixelShader = false; - pShader->NeedsConstantForDiffuse = false; - } - - if (!_needPixelShader) - { - // Remove the old one - pShader->PixelShader = NULL; - pShader->PixelShaderUnlightedNoVertexColor = NULL; - pShader->MultipleConstantNoPixelShader = 0; - } - } - - // Since modified, must rebind all D3D states. And do this also for the delete/new problem. - /* If an old material is deleted, _CurrentMaterial is invalid. But this is grave only if a new - material is created, with the same pointer (bad luck). Since an newly allocated material always - pass here before use, we are sure to avoid any problems. - */ - _CurrentMaterial= NULL; - } - - // Optimize: reset all flags at the end. - mat.clearTouched(0xFFFFFFFF); - pShader->NumUsedTexStages = numUsedTexStages; - } - } - - - { - H_AUTO_D3D(CDriverD3D_setupMaterial_bindTexture) - // 2. Setup / Bind Textures. - //========================== - // Must setup textures each frame. (need to test if touched). - // Must separate texture setup and texture activation in 2 "for"... - // because setupTexture() may disable all stage. - - if (matShader == CMaterial::Normal - || ((matShader == CMaterial::Program) && (_PixelProgramUser->features().MaterialFlags & CProgramFeatures::TextureStages)) - ) - { - uint stage; - for(stage=0 ; stagefeatures().MaterialFlags & CProgramFeatures::TextureStages)) - ) - { - uint stage; - for(stage=0 ; stagePixelShader == NULL) - { - if (pShader->RGBPipe[stage]) - { - setTextureState (stage, D3DTSS_COLOROP, pShader->ColorOp[stage]); - setTextureState (stage, D3DTSS_COLORARG1, pShader->ColorArg1[stage]); - if (pShader->NumColorArg[stage] > 1) - { - setTextureState (stage, D3DTSS_COLORARG2, pShader->ColorArg2[stage]); - if (pShader->NumColorArg[stage] > 2) - { - setTextureState (stage, D3DTSS_COLORARG0, pShader->ColorArg0[stage]); - } - } - } - if (pShader->AlphaPipe[stage]) - { - setTextureState (stage, D3DTSS_ALPHAOP, pShader->AlphaOp[stage]); - setTextureState (stage, D3DTSS_ALPHAARG1, pShader->AlphaArg1[stage]); - if (pShader->NumAlphaArg[stage] > 1) - { - setTextureState (stage, D3DTSS_ALPHAARG2, pShader->AlphaArg2[stage]); - if (pShader->NumAlphaArg[stage] > 2) - { - setTextureState (stage, D3DTSS_ALPHAARG0, pShader->AlphaArg0[stage]); - } - } - } - // If there is one constant and the tfactor is not needed for diffuse, use the tfactor as constant - if (pShader->ConstantIndex == stage) - setRenderState (D3DRS_TEXTUREFACTOR, pShader->ConstantColor[stage]); - } - else - { - float colors[4]; - D3DCOLOR_FLOATS (colors, pShader->ConstantColor[stage]); - setPixelShaderConstant (stage, colors); - } - } - - // Set texture generator state - setTextureIndexMode (stage, pShader->TexGen[stage]!=D3DTSS_TCI_PASSTHRU, pShader->TexGen[stage]); - - // Need user matrix ? - bool needUserMtx = mat.isUserTexMatEnabled(stage); - D3DXMATRIX userMtx; - if (needUserMtx) - { - // If tex gen mode is used, or a cube texture is used, then use the matrix 'as it'. - // Must build a 3x3 matrix for 2D texture coordinates in D3D (which is kind of weird ...) - if (pShader->TexGen[stage] != D3DTSS_TCI_PASSTHRU || (mat.getTexture(uint8(stage)) && mat.getTexture(uint8(stage))->isTextureCube())) - { - NL_D3D_MATRIX(userMtx, mat.getUserTexMat(stage)); - } - else - { - const CMatrix &m = mat.getUserTexMat(stage); - NL_D3D_TEX2D_MATRIX(userMtx, m); - } - } - - // Need cubic texture coord generator ? - if (pShader->ActivateSpecularWorldTexMT[stage]) - { - // Set the driver matrix - setTextureState (stage, D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_COUNT3); - if (!needUserMtx) - setMatrix ((D3DTRANSFORMSTATETYPE)(D3DTS_TEXTURE0+stage), _D3DSpecularWorldTex); - else - { - D3DXMatrixMultiply (&userMtx, &_D3DSpecularWorldTex, &userMtx); - setMatrix ((D3DTRANSFORMSTATETYPE)(D3DTS_TEXTURE0+stage), userMtx); - } - } - else if (pShader->ActivateInvViewModelTexMT[stage]) - { - // Set the driver matrix - setTextureState (stage, D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_COUNT3); - if (!needUserMtx) - setMatrix ((D3DTRANSFORMSTATETYPE)(D3DTS_TEXTURE0+stage), _D3DInvModelView); - else - { - D3DXMatrixMultiply (&userMtx, &_D3DInvModelView, &userMtx); - setMatrix ((D3DTRANSFORMSTATETYPE)(D3DTS_TEXTURE0+stage), userMtx); - } - } - else - { - if (_NbNeLTextureStages == 3) - { - // Fix for Radeon 7xxx - // In some situation, texture transform stays enabled after a material change, so enable it all the - // time and use identity matrix instead of the D3DTTFF_DISABLE flag - setTextureState (stage, D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_COUNT3); - setMatrix ((D3DTRANSFORMSTATETYPE)(D3DTS_TEXTURE0+stage), needUserMtx ? userMtx : _D3DMatrixIdentity); - } - else - { - // Set the driver matrix - if (needUserMtx) - { - setTextureState (stage, D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_COUNT3); - setMatrix ((D3DTRANSFORMSTATETYPE)(D3DTS_TEXTURE0+stage), userMtx); - } - else - { - setTextureState (stage, D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_DISABLE); - } - } - } - if (!text && stage == 0) break; - } - } - } - - if (_CurrentMaterial != &mat) - { - // Material has changed ? - // Restore fog state to its current value - { - H_AUTO_D3D(CDriverD3D_setupMaterial_updateFog) - setRenderState (D3DRS_FOGENABLE, _FogEnabled?TRUE:FALSE); - } - - // Flags - const uint32 flags = mat.getFlags(); - - // Two sided - _DoubleSided = (flags&IDRV_MAT_DOUBLE_SIDED)!=0; - - { - H_AUTO_D3D(CDriverD3D_setupMaterial_handleBackSide) - // Handle backside - if (_CullMode == CCW) - { - setRenderState (D3DRS_CULLMODE, _DoubleSided?D3DCULL_NONE:_InvertCullMode?D3DCULL_CCW:D3DCULL_CW); - } - else - { - setRenderState (D3DRS_CULLMODE, _DoubleSided?D3DCULL_NONE:_InvertCullMode?D3DCULL_CW:D3DCULL_CCW); - } - } - - - bool blend = (flags&IDRV_MAT_BLEND) != 0; - { - H_AUTO_D3D(CDriverD3D_setupMaterial_updateBlend) - // Active states - if (blend) - { - setRenderState (D3DRS_ALPHABLENDENABLE, TRUE); - setRenderState (D3DRS_SRCBLEND, pShader->SrcBlend); - setRenderState (D3DRS_DESTBLEND, pShader->DstBlend); - } - else - setRenderState (D3DRS_ALPHABLENDENABLE, FALSE); - - // Alpha test - if (flags&IDRV_MAT_ALPHA_TEST) - { - setRenderState (D3DRS_ALPHATESTENABLE, TRUE); - setRenderState (D3DRS_ALPHAREF, pShader->AlphaRef); - setRenderState (D3DRS_ALPHAFUNC, D3DCMP_GREATER); - } - else - setRenderState (D3DRS_ALPHATESTENABLE, FALSE); - } - - { - H_AUTO_D3D(CDriverD3D_setupMaterial_updateZBuffer) - // Z buffer - setRenderState (D3DRS_ZWRITEENABLE, (flags&IDRV_MAT_ZWRITE)?TRUE:FALSE); - setRenderState (D3DRS_ZFUNC, pShader->ZComp); - float flt = mat.getZBias () * _OODeltaZ; - setRenderState (D3DRS_DEPTHBIAS, FTODW(flt)); - } - - { - H_AUTO_D3D(CDriverD3D_setupMaterial_updateLighting) - // Active lighting - if (mat.isLighted()) - { - setRenderState (D3DRS_LIGHTING, TRUE); - setMaterialState(pShader->Material); - } - else - { - setRenderState (D3DRS_LIGHTING, FALSE); - - // Set pixel shader unlighted color ? - if (pShader->PixelShader) - { - float colors[4]; - D3DCOLOR_FLOATS(colors,pShader->UnlightedColor); - setPixelShaderConstant (5, colors); - } - } - setRenderState (D3DRS_SPECULARENABLE, pShader->SpecularEnabled); - } - - { - H_AUTO_D3D(CDriverD3D_setupMaterial_updateVertexColorLighted) - // Active vertex color if not lighted or vertex color forced - if (mat.isLightedVertexColor ()) - { - setRenderState (D3DRS_COLORVERTEX, TRUE); - - setRenderState (D3DRS_DIFFUSEMATERIALSOURCE, D3DMCS_COLOR1); - } - else - { - setRenderState (D3DRS_COLORVERTEX, FALSE); - setRenderState (D3DRS_DIFFUSEMATERIALSOURCE, D3DMCS_MATERIAL); - } - } - - { - H_AUTO_D3D(CDriverD3D_setupMaterial_disableFog) - // Disable fog if dest blend is ONE - if (blend && (pShader->DstBlend == D3DBLEND_ONE)) - { - setRenderState (D3DRS_FOGENABLE, FALSE); - } - } - - // Set the good shader - switch (matShader) - { - case CMaterial::Normal: - { - H_AUTO_D3D(CDriverD3D_setupMaterial_setupNormalshader) - // No shader - activeShader (NULL); - - /* If unlighted trick is needed, set the shader later */ - if (!pShader->NeedsConstantForDiffuse && _PixelProgram) - setPixelShader (pShader->PixelShader); - } - break; - case CMaterial::LightMap: - { - H_AUTO_D3D(CDriverD3D_setupMaterial_setupLightmapShader) - setPixelShader (NULL); - static const uint32 RGBMaskPacked = CRGBA(255,255,255,0).getPacked(); - - if (_NbNeLTextureStages == 3) - { - touchRenderVariable(&_MaterialState); - } - - // if the dynamic lightmap light has changed since the last render (should not happen), resetup - // normal way is that setupLightMapDynamicLighting() is called at begin of setupMaterial() if shader different from prec - if(_LightMapDynamicLightDirty) - setupLightMapDynamicLighting(true); - - // Count the lightmaps - uint lightmap; - uint lightmapCount = 0; - uint lightmapMask = 0; - for(lightmap=0 ; lightmap<(sint)mat._LightMaps.size() ; lightmap++) - { - if (mat._LightMaps[lightmap].Factor.getPacked() & RGBMaskPacked) - { - lightmapCount++; - lightmapMask |= 1<FXCache)) - return false; - - // Get the effect - nlassert (_CurrentShader); - CShaderDrvInfosD3D *shaderInfo = static_cast((IShaderDrvInfos*)_CurrentShader->_DrvInfo); -// ID3DXEffect *effect = shaderInfo->Effect; - - - // Set the ambiant for 8Bit Light Compression - { - // Sum ambiant of all active lightmaps. - uint32 r=0; - uint32 g=0; - uint32 b=0; - for(lightmap=0 ; lightmap<(sint)mat._LightMaps.size() ; lightmap++) - { - if (lightmapMask & (1<>7))) >>8; - g+= ((uint32)ambFactor.G * ((uint32)lmcAmb.G+(lmcAmb.G>>7))) >>8; - b+= ((uint32)ambFactor.B * ((uint32)lmcAmb.B+(lmcAmb.B>>7))) >>8; - } - } - r= std::min(r, (uint32)255); - g= std::min(g, (uint32)255); - b= std::min(b, (uint32)255); - CRGBA lmcAmbient((uint8)r,(uint8)g,(uint8)b,255); - - // Set into FX shader - setShaderParam(pShader, 0, (INT) NL_D3DCOLOR_RGBA(lmcAmbient)); - if (shaderInfo->FactorHandle[0]) - { - setShaderParam(pShader, 0, lmcAmbient); - } - } - - - // Set the lightmaps - lightmapCount = 0; - for(lightmap=0 ; lightmap<(sint)mat._LightMaps.size() ; lightmap++) - { - if (lightmapMask & (1<FXCache)) - return false; - - // Get the lightmap color factor, and mul by lmcDiffuse compression - CRGBA lmapFactor = mat._LightMaps[lightmap].Factor; - CRGBA lmcDiff= mat._LightMaps[lightmap].LMCDiffuse; - lmapFactor.R = (uint8)(((uint32)lmapFactor.R * ((uint32)lmcDiff.R+(lmcDiff.R>>7))) >>8); - lmapFactor.G = (uint8)(((uint32)lmapFactor.G * ((uint32)lmcDiff.G+(lmcDiff.G>>7))) >>8); - lmapFactor.B = (uint8)(((uint32)lmapFactor.B * ((uint32)lmcDiff.B+(lmcDiff.B>>7))) >>8); - lmapFactor.A = 255; - - // Set the lightmap color factor into shader - setShaderParam(pShader, lightmapCount+1, (INT) NL_D3DCOLOR_RGBA(lmapFactor)); - if (shaderInfo->FactorHandle[lightmapCount+1]) - { - setShaderParam(pShader, lightmapCount+1, lmapFactor); - } - lightmapCount++; - } - } - } - break; - case CMaterial::Specular: - { - H_AUTO_D3D(CDriverD3D_setupMaterial_setupSpecularShader) - // No shader - activeShader (NULL); - setPixelShader (NULL); - - // Setup the texture - ITexture *texture = mat.getTexture(0); - if (!texture || !setupTexture (*texture)) - return false; - setTexture (0, texture); - - // Setup the texture - texture = mat.getTexture(1); - if (!texture || !setupTexture (*texture)) - return false; - setTexture (1, texture); - - // Set the driver matrix - if (texture->isTextureCube()) - { - setTextureIndexMode (1, true, D3DTSS_TCI_CAMERASPACEREFLECTIONVECTOR); - setTextureState (1, D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_COUNT3); - setMatrix ((D3DTRANSFORMSTATETYPE)(D3DTS_TEXTURE0+1), _D3DSpecularWorldTex); - } - - setRenderState (D3DRS_LIGHTING, mat.isLighted()?TRUE:FALSE); - setRenderState (D3DRS_DIFFUSEMATERIALSOURCE, D3DMCS_MATERIAL); - setTextureState (0, D3DTSS_COLOROP, D3DTOP_MODULATE); - setTextureState (0, D3DTSS_COLORARG1, D3DTA_DIFFUSE); - setTextureState (0, D3DTSS_COLORARG2, D3DTA_TEXTURE); - setTextureState (0, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1); - setTextureState (0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE); - setTextureState (1, D3DTSS_COLOROP, D3DTOP_MULTIPLYADD); - setTextureState (1, D3DTSS_COLORARG0, D3DTA_CURRENT); - setTextureState (1, D3DTSS_COLORARG1, D3DTA_TEXTURE); - setTextureState (1, D3DTSS_COLORARG2, D3DTA_CURRENT|D3DTA_ALPHAREPLICATE); - setTextureState (1, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1); - setTextureState (1, D3DTSS_ALPHAARG1, D3DTA_DIFFUSE); - - } - break; - case CMaterial::Cloud: - { - H_AUTO_D3D(CDriverD3D_setupMaterial_setupCloudShader) - activeShader (&_ShaderCloud); - - // Get the shader - nlassert (_CurrentShader); -// CShaderDrvInfosD3D *shaderInfo = static_cast((IShaderDrvInfos*)_CurrentShader->_DrvInfo); - - // Set the constant -// ID3DXEffect *effect = shaderInfo->Effect; - CRGBA color = mat.getColor(); - color.R = 255; - color.G = 255; - color.B = 255; - setShaderParam(pShader, 0, color); - - // Set the texture - if (!setShaderTexture (0, mat.getTexture(0), pShader->FXCache) || !setShaderTexture (1, mat.getTexture(1), pShader->FXCache)) - return false; - } - break; - case CMaterial::Water: - { - H_AUTO_D3D(CDriverD3D_setupMaterial_setupWaterShader) - activeShader(mat.getTexture(3) ? &_ShaderWaterDiffuse : &_ShaderWaterNoDiffuse); - // Get the shader - nlassert (_CurrentShader); -// CShaderDrvInfosD3D *shaderInfo = static_cast((IShaderDrvInfos*)_CurrentShader->_DrvInfo); - // Set the textures - if (_PixelShaderVersion >= D3DPS_VERSION(1, 4)) - { - ITexture *tex = mat.getTexture(0); - if (tex) - { - tex->setUploadFormat(ITexture::RGBA8888); -// if (tex->isBumpMap()) -// { -// CTextureBump *tb = static_cast(tex); -// } - setupTexture(*tex); - setShaderTexture (0, tex, pShader->FXCache); - } - } - ITexture *tex = mat.getTexture(1); - if (tex) - { - if (_PixelShaderVersion < D3DPS_VERSION(1, 4)) - { - tex->setUploadFormat(ITexture::DsDt); -// if (tex->isBumpMap()) -// { -// CTextureBump *tb = static_cast(tex); -// } - } - else - { - tex->setUploadFormat(ITexture::RGBA8888); -// if (tex->isBumpMap()) -// { -// CTextureBump *tb = static_cast(tex); -// } - } - setupTexture(*tex); - setShaderTexture (1, tex, pShader->FXCache); - } - // - tex = mat.getTexture(2); - if (tex) - { - setupTexture(*tex); - setShaderTexture (2, tex, pShader->FXCache); - } - tex = mat.getTexture(3); - if (tex) - { - setupTexture(*tex); - setShaderTexture (3, tex, pShader->FXCache); - } - - // Set the constants -// ID3DXEffect *effect = shaderInfo->Effect; - if (_PixelShaderVersion < D3DPS_VERSION(2, 0)) - { - if (_PixelShaderVersion < D3DPS_VERSION(1, 4)) - { - if (mat.getTexture(1) && mat.getTexture(1)->isBumpMap()) - { - float factor = NLMISC::safe_cast(mat.getTexture(1))->getNormalizationFactor(); - setShaderParam(pShader, 0, factor); - } - else - { - setShaderParam(pShader, 0, 1.f); - } - } - else - { - if (mat.getTexture(0) && mat.getTexture(0)->isBumpMap()) - { - float factor = NLMISC::safe_cast(mat.getTexture(0))->getNormalizationFactor(); - float cst[4] = { factor, factor, factor, 0.f }; - setShaderParam(pShader, 0, cst); - } - else - { - float cst[4] = { 1.f, 1.f, 1.f, 0.f }; - setShaderParam(pShader, 0, cst); - } - // - if (mat.getTexture(1) && mat.getTexture(1)->isBumpMap()) - { - float factor = NLMISC::safe_cast(mat.getTexture(1))->getNormalizationFactor(); - float cst[4] = { factor, factor, factor, 0.f }; - setShaderParam(pShader, 1, cst); - } - else - { - float cst[4] = { 1.f, 1.f, 1.f, 0.f }; - setShaderParam(pShader, 1, cst); - } - } - } - else - { - // setup the constant - if (mat.getTexture(0) && mat.getTexture(0)->isBumpMap()) - { - float factor = 0.25f * NLMISC::safe_cast(mat.getTexture(0))->getNormalizationFactor(); - float bmScale[4] = { -1.f * factor, -1.f * factor, 2.f * factor, 0.f }; - setShaderParam(pShader, 0, bmScale); - } - else - { - float bmScale[4] = { -1.f, -1.f, 2.f, 0.f }; - setShaderParam(pShader, 0, bmScale); - } - // setup the constant - if (mat.getTexture(1) && mat.getTexture(1)->isBumpMap()) - { - float factor = NLMISC::safe_cast(mat.getTexture(1))->getNormalizationFactor(); - float bmScale[4] = { -1.f * factor, -1.f * factor, 2.f * factor, 0.f }; - setShaderParam(pShader, 1, bmScale); - } - else - { - float bmScale[4] = { -1.f, -1.f, 2.f, 0.f }; - setShaderParam(pShader, 1, bmScale); - } - } - } - // CMaterial::Water - } - - // New material setuped - _CurrentMaterial = &mat; - - // Update variables - _CurrentMaterialInfo = pShader; - } - - return true; -} - -// *************************************************************************** -// Add one set to another -static void add(std::set &dest, const std::set &toAdd) -{ - for (std::set::const_iterator it = toAdd.begin(); it != toAdd.end(); ++it) - { - dest.insert(*it); - } -} - - -// *************************************************************************** -bool CDriverD3D::needsConstants (uint &numConstant, uint &firstConstant, uint &secondConstant, CMaterial &mat) -{ - H_AUTO_D3D(CDriverD3D_needsConstants) - firstConstant = 0xffffffff; - secondConstant = 0xffffffff; - // Of course std::set could be avoided, but much simpler that way - std::set rgbPipe[2]; // constant used to compute the rgb component - std::set alphaPipe[2]; // constant used to compute the alpha component - for (uint i=0; i= 0) - { - rgbPipe[currStage] = rgbUsed; - alphaPipe[currStage] = alphaUsed; - bool newAlphaUsed = false; - bool newRGBUsed = false; - CMaterial::CTexEnv texEnv; - texEnv.EnvPacked = mat.getTexEnvMode(currStage); - // test for rgb propagate - if (rgbUsed) - { - if (texEnv.Env.OpRGB == CMaterial::InterpolatePrevious) - { - newAlphaUsed = true; - } - for(uint l = 0; l < OpNumArg[texEnv.Env.OpRGB]; ++l) - { - if (texEnv.getColorArg(l) == CMaterial::Previous || - (currStage != 0 && texEnv.getColorArg(l) == CMaterial::Texture && mat.getTexEnvOpRGB(currStage - 1) == CMaterial::EMBM) - ) - { - if (texEnv.getColorOperand(l) == CMaterial::SrcColor || texEnv.getColorOperand(l) == CMaterial::InvSrcColor) - { - newRGBUsed = true; - } - if (texEnv.getColorOperand(l) == CMaterial::SrcAlpha || texEnv.getColorOperand(l) == CMaterial::InvSrcAlpha) - { - newAlphaUsed = true; - } - } - } - } - // test for alpha propagate - if (alphaUsed) - { - if (texEnv.Env.OpAlpha == CMaterial::InterpolatePrevious) - { - newAlphaUsed = true; - } - for(uint l = 0; l < OpNumArg[texEnv.Env.OpAlpha]; ++l) - { - if (texEnv.getAlphaArg(l) == CMaterial::Previous || - (currStage != 0 && texEnv.getAlphaArg(l) == CMaterial::Texture && mat.getTexEnvOpRGB(currStage - 1) == CMaterial::EMBM) - ) - { - if (texEnv.getAlphaOperand(l) == CMaterial::SrcAlpha || texEnv.getAlphaOperand(l) == CMaterial::InvSrcAlpha) - { - newAlphaUsed = true; - } - } - } - } - alphaUsed = newAlphaUsed; - rgbUsed = newRGBUsed; - - -- currStage; - } -} - - -// *************************************************************************** - -const char *RemapPSInstructions[CMaterial::TexOperatorCount]= -{ - "mov", // Replace - "mul", // Modulate - "add", // Add - "add", // AddSigned - "lrp", // InterpolateTexture - "lrp", // InterpolatePrevious - "lrp", // InterpolateDiffuse - "lrp", // InterpolateConstant - "bem", // EMBM - "mad" // MAD -}; - -// *************************************************************************** - -const char *RemapPSThirdArguments[CMaterial::TexOperatorCount][2]= -{ - {"", ""}, // Replace - {"", ""}, // Modulate - {"", ""}, // Add - {"", ""}, // AddSigned - {"t", "t"}, // InterpolateTexture - {"r0", "r0"}, // InterpolatePrevious - {"v0", "c5"}, // InterpolateDiffuse - {"c", "c"}, // InterpolateConstant - {"", ""}, // EMBM - {"", ""} // MAD (not used) -}; - -// *************************************************************************** - -// Only for stage 0 -const char *RemapPSThirdArguments0[CMaterial::TexOperatorCount][2]= -{ - {"", ""}, // Replace - {"", ""}, // Modulate - {"", ""}, // Add - {"", ""}, // AddSigned - {"t", "t"}, // InterpolateTexture - {"v0", "c5"}, // InterpolatePrevious - {"v0", "c5"}, // InterpolateDiffuse - {"c", "c"}, // InterpolateConstant - {"", ""}, // EMBM - {"", ""} // MAD (not used) -}; - -// *************************************************************************** - -const char *RemapPSSecondRegisterModificator[CMaterial::TexOperatorCount]= -{ - "", // Replace - "", // Modulate - "", // Add - "_bias", // AddSigned - "", // InterpolateTexture - "", // InterpolatePrevious - "", // InterpolateDiffuse - "", // InterpolateConstant - "", // EMBM - "" // MAD -}; - -// *************************************************************************** - -const char *RemapPSArguments[CMaterial::TexOperatorCount][2]= -{ - {"t", "t"}, // Texture - {"r0", "r0"}, // Previous - {"v0", "c5"}, // Diffuse - {"c", "c"}, // Constant -}; - -// *************************************************************************** - -// Only for stage 0 -const char *RemapPSArguments0[CMaterial::TexOperatorCount][2]= -{ - {"t", "t"}, // Texture - {"v0", "c5"}, // Previous - {"v0", "c5"}, // Diffuse - {"c", "c"}, // Constant -}; - -// *************************************************************************** - -void buildColorOperation (string &dest, const char *prefix, const char *destSizzle, uint stage, CMaterial::TTexOperator &op, CMaterial::TTexSource src0, CMaterial::TTexSource src1, CMaterial::TTexSource src2, CMaterial::TTexOperand &op0, CMaterial::TTexOperand &op1, CMaterial::TTexOperand &op2, bool unlightedNoVertexColor) -{ - H_AUTO_D3D(buildColorOperation) - // Refix - dest += prefix; - - // RGB operation - dest += RemapPSInstructions[op]; - - // Destination argument - dest += " r0"; - dest += destSizzle; - - // Need a third argument ? - if (op != CMaterial::Mad) - { - const char *remapPSThirdArguments = ((stage==0)?RemapPSThirdArguments0:RemapPSThirdArguments)[op][(uint)unlightedNoVertexColor]; - if (remapPSThirdArguments[0] != 0) - { - dest += ", "; - dest += remapPSThirdArguments; - - // Need stage postfix ? - if ((op == CMaterial::InterpolateTexture) || (op == CMaterial::InterpolateConstant)) - dest += toString (stage); - - // Add alpha swizzle - dest += ".w"; - } - } - - // First argument - dest += ", "; - - // Inverted ? - if ((op0 == CMaterial::InvSrcColor) || (op0 == CMaterial::InvSrcAlpha)) - dest += "1-"; - - // The first operator argument - dest += ((stage==0)?RemapPSArguments0:RemapPSArguments)[src0][(uint)unlightedNoVertexColor]; - - // Need stage postfix ? - if ((src0 == CMaterial::Texture) || (src0 == CMaterial::Constant)) - dest += toString (stage); - - // Need alpha ? - if ((op0 == CMaterial::SrcAlpha) || (op0 == CMaterial::InvSrcAlpha)) - dest += ".w"; - - if (op != CMaterial::Replace) - { - dest += ", "; - - // Inverted ? - if ((op1 == CMaterial::InvSrcColor) || (op1 == CMaterial::InvSrcAlpha)) - dest += "1-"; - - dest += ((stage==0)?RemapPSArguments0:RemapPSArguments)[src1][(uint)unlightedNoVertexColor]; - - // Second register modifier - dest += RemapPSSecondRegisterModificator[op]; - - // Need stage postfix ? - if ((src1 == CMaterial::Texture) || (src1 == CMaterial::Constant)) - dest += toString (stage); - - // Need alpha ? - if ((op1 == CMaterial::SrcAlpha) || (op1 == CMaterial::InvSrcAlpha)) - dest += ".w"; - } - - if (op == CMaterial::Mad) - { - dest += ", "; - - // Inverted ? - if ((op2 == CMaterial::InvSrcColor) || (op2 == CMaterial::InvSrcAlpha)) - dest += "1-"; - - dest += ((stage==0)?RemapPSArguments0:RemapPSArguments)[src2][(uint)unlightedNoVertexColor]; - - // Second register modifier - dest += RemapPSSecondRegisterModificator[op]; - - // Need stage postfix ? - if ((src2 == CMaterial::Texture) || (src2 == CMaterial::Constant)) - dest += toString (stage); - - // Need alpha ? - if ((op2 == CMaterial::SrcAlpha) || (op2 == CMaterial::InvSrcAlpha)) - dest += ".w"; - } - - // End - dest += ";\n"; -} - -// *************************************************************************** - -IDirect3DPixelShader9 *CDriverD3D::buildPixelShader (const CNormalShaderDesc &normalShaderDesc, bool unlightedNoVertexColor) -{ - H_AUTO_D3D(CDriverD3D_buildPixelShader) - static string shaderText; - shaderText = "ps_1_1;\n"; - - // Look for a shader already created - std::list &normalPixelShaders = _NormalPixelShaders[(uint)unlightedNoVertexColor]; - std::list::iterator ite = normalPixelShaders.begin(); - while (ite != normalPixelShaders.end()) - { - if (normalShaderDesc == *ite) - { - // Good one - return (*ite).PixelShader; - } - ite++; - } - - // For each state, texture lookup - uint i; - for (i=0; iCreatePixelShader((DWORD*)pShader->GetBufferPointer(), &shader) == D3D_OK) - normalPixelShaders.back().PixelShader = shader; - else - normalPixelShaders.back().PixelShader = NULL; - } - else - { - nlwarning ("Can't assemble pixel shader:"); - nlwarning ((const char*)pErrorMsgs->GetBufferPointer()); - normalPixelShaders.back().PixelShader = NULL; - } - - return normalPixelShaders.back().PixelShader; -} - -// *************************************************************************** - -void CDriverD3D::startSpecularBatch() -{ - /* Not used in direct3d, use normal caching */ -} - -// *************************************************************************** - -void CDriverD3D::endSpecularBatch() -{ - /* Not used in direct3d, use normal caching */ -} - -// *************************************************************************** - -bool CDriverD3D::supportBlendConstantColor() const -{ - /* Not supported in D3D */ - return false; -}; - -// *************************************************************************** - -void CDriverD3D::setBlendConstantColor(NLMISC::CRGBA /* col */) -{ - /* Not supported in D3D */ -}; - -// *************************************************************************** - -NLMISC::CRGBA CDriverD3D::getBlendConstantColor() const -{ - /* Not supported in D3D */ - return CRGBA::White; -}; - -// *************************************************************************** - -void CDriverD3D::enablePolygonSmoothing(bool /* smooth */) -{ - /* Not supported in D3D */ -} - -// *************************************************************************** - -bool CDriverD3D::isPolygonSmoothingEnabled() const -{ - /* Not supported in D3D */ - return false; -} - -// *************************************************************************** - -sint CDriverD3D::beginMaterialMultiPass() -{ - H_AUTO_D3D(CDriverD3D_beginMaterialMultiPass) - beginMultiPass (); - return _CurrentShaderPassCount; -} - -// *************************************************************************** - -void CDriverD3D::setupMaterialPass(uint pass) -{ - H_AUTO_D3D(CDriver3D_setupMaterialPass); - activePass (pass); -} - -// *************************************************************************** - -void CDriverD3D::endMaterialMultiPass() -{ - H_AUTO_D3D(CDriver3D_endMaterialMultiPass); - endMultiPass (); -} - -// *************************************************************************** - -bool CDriverD3D::supportCloudRenderSinglePass () const -{ - H_AUTO_D3D(CDriver3D_supportCloudRenderSinglePass); - return _PixelProgram; -} - -// *************************************************************************** - -void CDriverD3D::getNumPerStageConstant(uint &lightedMaterial, uint &unlightedMaterial) const -{ - lightedMaterial = _MaxNumPerStageConstantLighted; - unlightedMaterial = _MaxNumPerStageConstantUnlighted; -} - - - -} // NL3D diff --git a/code/nel/src/3d/driver/direct3d/driver_direct3d_matrix.cpp b/code/nel/src/3d/driver/direct3d/driver_direct3d_matrix.cpp deleted file mode 100644 index 6e7520fb7..000000000 --- a/code/nel/src/3d/driver/direct3d/driver_direct3d_matrix.cpp +++ /dev/null @@ -1,445 +0,0 @@ -// NeL - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as -// published by the Free Software Foundation, either version 3 of the -// License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -#include "stddirect3d.h" - -#include "nel/3d/vertex_buffer.h" -#include "nel/3d/light.h" -#include "nel/3d/index_buffer.h" -#include "nel/misc/rect.h" -#include "nel/3d/viewport.h" -#include "nel/3d/scissor.h" -#include "nel/3d/u_driver.h" - -#include "driver_direct3d.h" - -#ifdef DEBUG_NEW -#define new DEBUG_NEW -#endif - -using namespace std; -using namespace NLMISC; - -namespace NL3D -{ - -// *************************************************************************** - -void CDriverD3D::updateMatrices () -{ - H_AUTO_D3D(CDriver3D_updateMatrices ); - // Update view model matrix - D3DXMatrixMultiply (&_D3DModelView, &(_MatrixCache[remapMatrixIndex (D3DTS_WORLD)].Matrix), &(_MatrixCache[remapMatrixIndex (D3DTS_VIEW)].Matrix)); - - // Update view model projection matrix - _D3DModelViewProjection = _D3DModelView; - D3DXMatrixMultiply (&_D3DModelViewProjection, &_D3DModelViewProjection, &(_MatrixCache[remapMatrixIndex (D3DTS_PROJECTION)].Matrix)); - - // Update the inverted view model matrix - D3DXMatrixInverse (&_D3DInvModelView, NULL, &_D3DModelView); - - // Update the normalize state - setRenderState (D3DRS_NORMALIZENORMALS, (_UserViewMtx.hasScalePart() || _UserModelMtx.hasScalePart() || _ForceNormalize)?TRUE:FALSE); -} - -// *************************************************************************** - -void CDriverD3D::updateProjectionMatrix () -{ - H_AUTO_D3D(CDriver3D_updateProjectionMatrix ); - float left = _FrustumLeft; - float right = _FrustumRight; - float top = _FrustumTop; - float bottom = _FrustumBottom; - - if (_RenderTarget.Texture) - swap (bottom, top); - - // Get the render target size - uint32 clientWidth; - uint32 clientHeight; - getRenderTargetSize (clientWidth, clientHeight); - - // In D3D, the center of the first screen pixel is [0.0,0.0]. Is NeL it is [0.5,0.5] - const float addW = (right-left)/(2*(_Viewport.getWidth() * (float)clientWidth)); - const float addH = (bottom-top)/(2*(_Viewport.getHeight() * (float)clientHeight)); - - left += addW; - right += addW; - top += addH; - bottom += addH; - - D3DXMATRIX projection; - if (_FrustumPerspective) - { - D3DXMatrixPerspectiveOffCenterLH (&projection, left, right, bottom, top, _FrustumZNear, _FrustumZFar); - } - else - { - D3DXMatrixOrthoOffCenterLH (&projection, left, right, bottom, top, _FrustumZNear, _FrustumZFar); - } - setMatrix (D3DTS_PROJECTION, projection); - - // Backup znear and zfar for zbias setup - _OODeltaZ = 1 / (_FrustumZFar - _FrustumZNear); - - updateMatrices (); -} - -// *************************************************************************** - -void CDriverD3D::setFrustum(float left, float right, float bottom, float top, float znear, float zfar, bool perspective) -{ - H_AUTO_D3D(CDriverD3D_setFrustum) - _FrustumLeft = left; - _FrustumRight = right; - _FrustumTop = top; - _FrustumBottom = bottom; - _FrustumZNear = znear; - _FrustumZFar = zfar; - _FrustumPerspective = perspective; - updateProjectionMatrix (); -} - - -// *************************************************************************** - -void CDriverD3D::setFrustumMatrix(CMatrix &frustumMatrix) -{ - H_AUTO_D3D(CDriverD3D_setFrustum) - - frustumMatrix.transpose(); - setMatrix (D3DTS_PROJECTION, D3DXMATRIX(frustumMatrix.get())); -} - -// *************************************************************************** - -CMatrix CDriverD3D::getFrustumMatrix() -{ - H_AUTO_D3D(CDriverD3D_getFrustum) - - CMatrix frustumMatrix; - frustumMatrix.set((float *)_MatrixCache[D3DTS_PROJECTION].Matrix.m); - frustumMatrix.transpose(); - - return frustumMatrix; -} - -// *************************************************************************** - -void CDriverD3D::setupViewMatrix(const CMatrix& mtx) -{ - H_AUTO_D3D(CDriverD3D_setupViewMatrix) - // Remember the view matrix - _UserViewMtx= mtx; - _PZBCameraPos= CVector::Null; - - // Set the driver matrix - D3DXMATRIX view; - NL_D3D_MATRIX (view, mtx); - - // Pass to directx matrix basis - swap (view._12, view._13); - swap (view._22, view._23); - swap (view._32, view._33); - swap (view._42, view._43); - - setMatrix (D3DTS_VIEW, view); - - // Set the spacular matrix - CMatrix specularTex; - specularTex = mtx; - specularTex.setPos(CVector(0.0f,0.0f,0.0f)); - specularTex.invert(); - NL_D3D_MATRIX (_D3DSpecularWorldTex, specularTex); - - updateMatrices (); -} - -// *************************************************************************** - -void CDriverD3D::setupViewMatrixEx(const CMatrix& mtx, const CVector &cameraPos) -{ - H_AUTO_D3D(CDriverD3D_setupViewMatrixEx) - // Remeber the view matrix - _UserViewMtx= mtx; - _PZBCameraPos= cameraPos; - - // Set the driver matrix - D3DXMATRIX view; - NL_D3D_MATRIX (view, mtx); - - // Pass to directx matrix basis - swap (view._12, view._13); - swap (view._22, view._23); - swap (view._32, view._33); - swap (view._42, view._43); - - // Reset the viewMtx position. - view._41 = 0; - view._42 = 0; - view._43 = 0; - - setMatrix (D3DTS_VIEW, view); - - // Set the spacular matrix - CMatrix specularTex; - specularTex = mtx; - NL_D3D_MATRIX (_D3DSpecularWorldTex, specularTex); - swap (_D3DSpecularWorldTex._12, _D3DSpecularWorldTex._13); - swap (_D3DSpecularWorldTex._22, _D3DSpecularWorldTex._23); - swap (_D3DSpecularWorldTex._32, _D3DSpecularWorldTex._33); - swap (_D3DSpecularWorldTex._42, _D3DSpecularWorldTex._43); - _D3DSpecularWorldTex._41 = 0; - _D3DSpecularWorldTex._42 = 0; - _D3DSpecularWorldTex._43 = 0; - - D3DXMatrixInverse ( &_D3DSpecularWorldTex, NULL, &_D3DSpecularWorldTex); - swap (_D3DSpecularWorldTex._12, _D3DSpecularWorldTex._13); - swap (_D3DSpecularWorldTex._22, _D3DSpecularWorldTex._23); - swap (_D3DSpecularWorldTex._32, _D3DSpecularWorldTex._33); - swap (_D3DSpecularWorldTex._42, _D3DSpecularWorldTex._43); - - updateMatrices (); -} - -// *************************************************************************** - -void CDriverD3D::setupModelMatrix(const CMatrix& mtx) -{ - H_AUTO_D3D(CDriverD3D_setupModelMatrix) - // Stats - _NbSetupModelMatrixCall++; - - // Remeber the model matrix - _UserModelMtx= mtx; - - D3DXMATRIX world; - NL_D3D_MATRIX (world, mtx); - - // Remove from position the camera position - world._41 -= _PZBCameraPos.x; - world._42 -= _PZBCameraPos.y; - world._43 -= _PZBCameraPos.z; - - setMatrix (D3DTS_WORLD, world); - - updateMatrices (); -} - -// *************************************************************************** - -CMatrix CDriverD3D::getViewMatrix() const -{ - H_AUTO_D3D(CDriverD3D_getViewMatrix) - return _UserViewMtx; -} - -// *************************************************************************** - -void CDriverD3D::forceNormalize(bool normalize) -{ - H_AUTO_D3D(CDriverD3D_forceNormalize) - _ForceNormalize = normalize; - updateMatrices (); -} - -// *************************************************************************** - -bool CDriverD3D::isForceNormalize() const -{ - H_AUTO_D3D(CDriverD3D_isForceNormalize) - return _RenderStateCache[D3DRS_NORMALIZENORMALS].Value != FALSE; -} - - - -// *************************************************************************** - -void CDriverD3D::setupScissor (const class CScissor& scissor) -{ - H_AUTO_D3D(CDriverD3D_setupScissor ) - if (!_ScissorTouched && - _Scissor.X == scissor.X && - _Scissor.Y == scissor.Y && - _Scissor.Width == scissor.Width && - _Scissor.Height == scissor.Height - ) return; - nlassert (_DeviceInterface); - - // Get viewport - _ScissorTouched = false; - float x= scissor.X; - float width= scissor.Width; - float height= scissor.Height; - - if(x==0 && x==0 && width==1 && height==1) - { - setRenderState (D3DRS_SCISSORTESTENABLE, FALSE); - } - else - { - - float y= scissor.Y; - - if (_HWnd) - { - // Get the render target size - uint32 clientWidth; - uint32 clientHeight; - getRenderTargetSize (clientWidth, clientHeight); - - // Setup d3d scissor - - RECT rect; - rect.left=(int)floor((float)clientWidth * x + 0.5f); - clamp (rect.left, 0, (int)clientWidth); - if (_RenderTarget.Texture) - rect.top=(int)floor((float)clientHeight* y + 0.5f); - else - rect.top=(int)floor((float)clientHeight* (1-y-height) + 0.5f); - clamp (rect.top, 0, (int)clientHeight); - - rect.right=(int)floor((float)clientWidth * (x+width) + 0.5f ); - clamp (rect.right, 0, (int)clientWidth); - if (_RenderTarget.Texture) - rect.bottom=(int)floor((float)clientHeight* (y+height) + 0.5f); - else - rect.bottom=(int)floor((float)clientHeight* (1-y) + 0.5f); - clamp (rect.bottom, 0, (int)clientHeight); - - { - H_AUTO_D3D(CDriverD3D_setupScissorDevice ) - _DeviceInterface->SetScissorRect (&rect); - } - setRenderState (D3DRS_SCISSORTESTENABLE, TRUE); - - } - } - - // Backup the scissor - _Scissor = scissor; -} - -// *************************************************************************** - -void CDriverD3D::setupViewport (const class CViewport& viewport) -{ - H_AUTO_D3D(CDriverD3D_setupViewport ) - if (_HWnd == NULL) - return; - - // Get the render target size - uint32 clientWidth; - uint32 clientHeight; - getRenderTargetSize (clientWidth, clientHeight); - - // Get viewport - float x; - float y; - float width; - float height; - viewport.getValues (x, y, width, height); - - // Get integer values - int ix=(int)((float)clientWidth*x); - clamp (ix, 0, (int)clientWidth); - int iy; - if (_RenderTarget.Texture) - iy=(int)((float)clientHeight*y); - else - iy=(int)((float)clientHeight*(1.f-(y+height))); - clamp (iy, 0, (int)clientHeight); - int iwidth=(int)((float)clientWidth*width); - clamp (iwidth, 0, (int)clientWidth-ix); - int iheight=(int)((float)clientHeight*height); - clamp (iheight, 0, (int)clientHeight-iy); - - // Setup D3D viewport - _D3DViewport.X = ix; - _D3DViewport.Y = iy; - _D3DViewport.Width = iwidth; - _D3DViewport.Height = iheight; - _D3DViewport.MinZ = _DepthRangeNear; - _D3DViewport.MaxZ = _DepthRangeFar; - _DeviceInterface->SetViewport (&_D3DViewport); - - // Backup the viewport - _Viewport = viewport; - - updateProjectionMatrix (); -} - -// *************************************************************************** -void CDriverD3D::setDepthRange(float znear, float zfar) -{ - H_AUTO_D3D(CDriverD3D_setDepthRange) - nlassert(znear != zfar); - if (_HWnd == NULL) - return; -#ifdef NL_D3D_USE_RENDER_STATE_CACHE - NL_D3D_CACHE_TEST(CacheTest_DepthRange, znear != _DepthRangeNear || zfar != _DepthRangeFar) -#endif - { - _DepthRangeNear = znear; - _DepthRangeFar = zfar; - _D3DViewport.MinZ = _DepthRangeNear; - _D3DViewport.MaxZ = _DepthRangeFar; - _DeviceInterface->SetViewport (&_D3DViewport); - } -} - -// *************************************************************************** -void CDriverD3D::getDepthRange(float &znear, float &zfar) const -{ - H_AUTO_D3D(CDriverD3D_getDepthRange) - znear = _DepthRangeNear; - zfar = _DepthRangeFar; -} - -// *************************************************************************** - -void CDriverD3D::getViewport(CViewport &viewport) -{ - H_AUTO_D3D(CDriverD3D_getViewport) - viewport = _Viewport; -} - -// *************************************************************************** - - -} // NL3D - - - - - - - - - - - - - - - - - - - - - diff --git a/code/nel/src/3d/driver/direct3d/driver_direct3d_pixel_program.cpp b/code/nel/src/3d/driver/direct3d/driver_direct3d_pixel_program.cpp deleted file mode 100644 index 7d79eb1a7..000000000 --- a/code/nel/src/3d/driver/direct3d/driver_direct3d_pixel_program.cpp +++ /dev/null @@ -1,157 +0,0 @@ -/** \file driver_direct3d_pixel_program.cpp - * Direct 3d driver implementation - * - * $Id: driver_direct3d_pixel_program.cpp,v 1.1.2.4 2007/07/09 15:26:35 legallo Exp $ - * - * \todo manage better the init/release system (if a throw occurs in the init, we must release correctly the driver) - */ - -/* Copyright, 2000 Nevrax Ltd. - * - * This file is part of NEVRAX NEL. - * NEVRAX NEL is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - - * NEVRAX NEL is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with NEVRAX NEL; see the file COPYING. If not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, - * MA 02111-1307, USA. - */ - -#include "stddirect3d.h" - -#include "driver_direct3d.h" - -#ifdef DEBUG_NEW -#define new DEBUG_NEW -#endif - -using namespace std; -using namespace NLMISC; - -namespace NL3D -{ - -// *************************************************************************** - -CPixelProgramDrvInfosD3D::CPixelProgramDrvInfosD3D(IDriver *drv, ItGPUPrgDrvInfoPtrList it) : IProgramDrvInfos (drv, it) -{ - H_AUTO_D3D(CPixelProgramDrvInfosD3D_CPixelProgamDrvInfosD3D) - Shader = NULL; -} - -// *************************************************************************** - -CPixelProgramDrvInfosD3D::~CPixelProgramDrvInfosD3D() -{ - H_AUTO_D3D(CPixelProgramDrvInfosD3D_CPixelProgramDrvInfosD3DDtor) - if (Shader) - Shader->Release(); -} - -// *************************************************************************** - -bool CDriverD3D::supportPixelProgram (CPixelProgram::TProfile profile) const -{ - H_AUTO_D3D(CDriverD3D_supportPixelProgram_profile) - return ((profile & 0xFFFF0000) == 0xD9020000) - && (_PixelProgramVersion >= (uint16)(profile & 0x0000FFFF)); -} - -// *************************************************************************** - -bool CDriverD3D::compilePixelProgram(CPixelProgram *program) -{ - // Program setuped ? - if (program->m_DrvInfo==NULL) - { - // Find a supported pixel program profile - IProgram::CSource *source = NULL; - for (uint i = 0; i < program->getSourceNb(); ++i) - { - if (supportPixelProgram(program->getSource(i)->Profile)) - { - source = program->getSource(i); - } - } - if (!source) - { - nlwarning("No supported source profile for pixel program"); - return false; - } - - _GPUPrgDrvInfos.push_front (NULL); - ItGPUPrgDrvInfoPtrList itPix = _GPUPrgDrvInfos.begin(); - CPixelProgramDrvInfosD3D *drvInfo; - *itPix = drvInfo = new CPixelProgramDrvInfosD3D(this, itPix); - - // Create a driver info structure - program->m_DrvInfo = *itPix; - - LPD3DXBUFFER pShader; - LPD3DXBUFFER pErrorMsgs; - if (D3DXAssembleShader(source->SourcePtr, source->SourceLen, NULL, NULL, 0, &pShader, &pErrorMsgs) == D3D_OK) - { - if (_DeviceInterface->CreatePixelShader((DWORD*)pShader->GetBufferPointer(), &(getPixelProgramD3D(*program)->Shader)) != D3D_OK) - return false; - } - else - { - nlwarning ("Can't assemble pixel program:"); - nlwarning ((const char*)pErrorMsgs->GetBufferPointer()); - return false; - } - - // Set parameters for assembly programs - drvInfo->ParamIndices = source->ParamIndices; - - // Build the feature info - program->buildInfo(source); - } - - return true; -} - -// *************************************************************************** - -bool CDriverD3D::activePixelProgram(CPixelProgram *program) -{ - H_AUTO_D3D(CDriverD3D_activePixelProgram ) - if (_DisableHardwarePixelProgram) - return false; - - // Set the pixel program - if (program) - { - if (!CDriverD3D::compilePixelProgram(program)) return false; - - CPixelProgramDrvInfosD3D *info = static_cast((IProgramDrvInfos*)program->m_DrvInfo); - _PixelProgramUser = program; - setPixelShader(info->Shader); - } - else - { - setPixelShader(NULL); - _PixelProgramUser = NULL; - } - - return true; -} - -// *************************************************************************** - -void CDriverD3D::disableHardwarePixelProgram() -{ - H_AUTO_D3D(CDriverD3D_disableHardwarePixelProgram) - _DisableHardwarePixelProgram = true; - _PixelProgram = false; -} - -} // NL3D diff --git a/code/nel/src/3d/driver/direct3d/driver_direct3d_profile.cpp b/code/nel/src/3d/driver/direct3d/driver_direct3d_profile.cpp deleted file mode 100644 index b574fff54..000000000 --- a/code/nel/src/3d/driver/direct3d/driver_direct3d_profile.cpp +++ /dev/null @@ -1,358 +0,0 @@ -// NeL - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as -// published by the Free Software Foundation, either version 3 of the -// License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -#include "stddirect3d.h" - -#include "driver_direct3d.h" -#include "nel/misc/hierarchical_timer.h" - -#ifdef DEBUG_NEW -#define new DEBUG_NEW -#endif - -using namespace std; -using namespace NLMISC; - -namespace NL3D -{ - -// *************************************************************************** - -void CDriverD3D::profileRenderedPrimitives(CPrimitiveProfile &pIn, CPrimitiveProfile &pOut) -{ - pIn= _PrimitiveProfileIn; - pOut= _PrimitiveProfileOut; -} - -// *************************************************************************** - -uint32 CDriverD3D::profileAllocatedTextureMemory() -{ - return _AllocatedTextureMemory; -} - -// *************************************************************************** - -uint32 CDriverD3D::profileSetupedMaterials() const -{ - return _NbSetupMaterialCall; -} - -// *************************************************************************** - -uint32 CDriverD3D::profileSetupedModelMatrix() const -{ - return _NbSetupModelMatrixCall; -} - -// *************************************************************************** - -void CDriverD3D::enableUsedTextureMemorySum (bool enable) -{ - if (enable) - nlinfo ("PERFORMANCE INFO: enableUsedTextureMemorySum has been set to true in CDriverD3D\n"); - _SumTextureMemoryUsed=enable; -} - -// *************************************************************************** - -uint32 CDriverD3D::getUsedTextureMemory() const -{ - // Sum memory used - uint32 memory=0; - - // For each texture used - set::const_iterator ite=_TextureUsed.begin(); - while (ite!=_TextureUsed.end()) - { - // Get the d3d texture - CTextureDrvInfosD3D* d3dtext; - d3dtext= (*ite); - - // Sum the memory used by this texture - memory+=d3dtext->TextureMemory; - - // Next texture - ite++; - } - - // Return the count - return memory; -} - -// *************************************************************************** -void CDriverD3D::startProfileVBHardLock() -{ - if(_VBHardProfiling) - return; - - // start - _VBHardProfiles.clear(); - _VBHardProfiles.reserve(50); - _VBHardProfiling= true; - _CurVBHardLockCount= 0; - _NumVBHardProfileFrame= 0; - _VolatileVBLockTime = 0; -} - -// *************************************************************************** - -void CDriverD3D::endProfileVBHardLock(std::vector &result) -{ - if(!_VBHardProfiling) - return; - - // Fill infos. - result.clear(); - result.resize(_VBHardProfiles.size() + 2); - float total= 0; - for(uint i=0;i<_VBHardProfiles.size();i++) - { - const uint tmpSize= 256; - char tmp[tmpSize]; - CVBHardProfile &vbProf= _VBHardProfiles[i]; - const char *vbName; - if(vbProf.VBHard && !vbProf.VBHard->getName().empty()) - { - vbName= vbProf.VBHard->getName().c_str(); - } - else - { - vbName= "????"; - } - // Display in ms. - float timeLock= (float)CTime::ticksToSecond(vbProf.AccumTime)*1000 / max(_NumVBHardProfileFrame,1U); - smprintf(tmp, tmpSize, "%16s%c: %2.3f ms", vbName, vbProf.Change?'*':' ', timeLock ); - total+= timeLock; - - result[i]= tmp; - } - result[_VBHardProfiles.size()]= toString("Total: %2.3f", total); -// float volatileVBTimeLock = (float)CTime::ticksToSecond(_VolatileVBLockTime)*1000 / max(_NumVBHardProfileFrame,1U); - result[_VBHardProfiles.size() + 1]= toString("Volatile Vertex Buffer lock time = %2.3f", _VolatileVBLockTime); - - // clear. - _VBHardProfiling= false; - contReset(_VBHardProfiles); -} - -// *************************************************************************** - -void CDriverD3D::appendVBHardLockProfile(NLMISC::TTicks time, CVertexBuffer *vb) -{ - // must allocate a new place? - if(_CurVBHardLockCount>=_VBHardProfiles.size()) - { - _VBHardProfiles.resize(_VBHardProfiles.size()+1); - // set the original VBHard - _VBHardProfiles[_CurVBHardLockCount].VBHard= vb; - } - - // Accumulate. - _VBHardProfiles[_CurVBHardLockCount].AccumTime+= time; - // if change of VBHard for this chrono place - if(_VBHardProfiles[_CurVBHardLockCount].VBHard != vb) - { - // flag, and set new - _VBHardProfiles[_CurVBHardLockCount].VBHard= vb; - _VBHardProfiles[_CurVBHardLockCount].Change= true; - } - - // next! - _CurVBHardLockCount++; -} - -// *************************************************************************** -void CDriverD3D::startProfileIBLock() -{ - if(_IBProfiling) - return; - - // start - _IBProfiles.clear(); - _IBProfiles.reserve(50); - _IBProfiling= true; - _CurIBLockCount= 0; - _NumIBProfileFrame= 0; - _VolatileIBLockTime = 0; -} - -// *************************************************************************** - -void CDriverD3D::endProfileIBLock(std::vector &result) -{ - if(!_IBProfiling) - return; - - // Fill infos. - result.clear(); - result.resize(_IBProfiles.size() + 2); - float total= 0; - for(uint i=0;i<_IBProfiles.size();i++) - { - const uint tmpSize= 256; - char tmp[tmpSize]; - CIBProfile &ibProf= _IBProfiles[i]; - const char *ibName; - if(ibProf.IB && !ibProf.IB->getName().empty()) - { - ibName= ibProf.IB->getName().c_str(); - } - else - { - ibName= "????"; - } - // Display in ms. - float timeLock= (float)CTime::ticksToSecond(ibProf.AccumTime)*1000 / max(_NumIBProfileFrame,1U); - smprintf(tmp, tmpSize, "%16s%c: %2.3f ms", ibName, ibProf.Change?'*':' ', timeLock ); - total+= timeLock; - - result[i]= tmp; - } - result[_IBProfiles.size()]= toString("Total: %2.3f", total); - float volatileIBTimeLock = (float)CTime::ticksToSecond(_VolatileIBLockTime)*1000 / max(_NumIBProfileFrame,1U); - result[_IBProfiles.size() + 1]= toString("Volatile Index Buffer lock time = %2.3f", volatileIBTimeLock); - nlwarning("IB lock time = %2.3f", total); - nlwarning("Volatile IB lock time = %2.3f", volatileIBTimeLock); - - // clear. - _IBProfiling= false; - contReset(_IBProfiles); -} - -// *************************************************************************** - -void CDriverD3D::appendIBLockProfile(NLMISC::TTicks time, CIndexBuffer *ib) -{ - // must allocate a new place? - if(_CurIBLockCount>=_IBProfiles.size()) - { - _IBProfiles.resize(_IBProfiles.size()+1); - _IBProfiles[_CurIBLockCount].IB= ib; - } - - // Accumulate. - _IBProfiles[_CurIBLockCount].AccumTime+= time; - // if change of VBHard for this chrono place - if(_IBProfiles[_CurIBLockCount].IB != ib) - { - // flag, and set new - _IBProfiles[_CurIBLockCount].IB= ib; - _IBProfiles[_CurIBLockCount].Change= true; - } - - // next! - _CurIBLockCount++; -} - -// *************************************************************************** -void CDriverD3D::profileVBHardAllocation(std::vector &result) -{ - result.clear(); - result.reserve(1000); - result.push_back(toString("Memory Allocated: %4d Ko in AGP / %4d Ko in VRAM", - getAvailableVertexAGPMemory()/1000, getAvailableVertexVRAMMemory()/1000 )); - result.push_back(toString("Num VBHard: %d", _VertexBufferHardSet.size())); - - uint totalMemUsed= 0; - set::iterator it; - for(it= _VertexBufferHardSet.begin(); it!=_VertexBufferHardSet.end(); it++) - { - CVBDrvInfosD3D *vbHard= *it; - if(vbHard) - { - uint vSize= vbHard->VertexBufferPtr->getVertexSize(); - uint numVerts= vbHard->VertexBufferPtr->getNumVertices(); - totalMemUsed+= vSize*numVerts; - } - } - result.push_back(toString("Mem Used: %4d Ko", totalMemUsed/1000) ); - - for(it= _VertexBufferHardSet.begin(); it!=_VertexBufferHardSet.end(); it++) - { - CVBDrvInfosD3D *vbHard= *it; - if(vbHard) - { - uint vSize= vbHard->VertexBufferPtr->getVertexSize(); - uint numVerts= vbHard->VertexBufferPtr->getNumVertices(); - result.push_back(toString(" %16s: %4d ko (format: %d / numVerts: %d)", - vbHard->VertexBufferPtr->getName().c_str(), vSize*numVerts/1000, vSize, numVerts )); - } - } -} - -// *************************************************************************** -void CDriverD3D::profileIBAllocation(std::vector &result) -{ - result.clear(); - result.reserve(1000); - result.push_back(toString("Memory Allocated: %4d Ko in AGP / %4d Ko in VRAM", - getAvailableVertexAGPMemory()/1000, getAvailableVertexVRAMMemory()/1000 )); - result.push_back(toString("Num Index buffers : %d", _IBDrvInfos.size())); - - uint totalMemUsed= 0; - for(TIBDrvInfoPtrList::iterator it = _IBDrvInfos.begin(); it != _IBDrvInfos.end(); ++it) - { - CIBDrvInfosD3D *ib = NLMISC::safe_cast(*it); - if(ib) - { - uint numIndex= ib->IndexBufferPtr->getNumIndexes(); - totalMemUsed+= sizeof(uint32)*numIndex; - } - } - result.push_back(toString("Mem Used: %4d Ko", totalMemUsed/1000) ); - - for(TIBDrvInfoPtrList::iterator it = _IBDrvInfos.begin(); it != _IBDrvInfos.end(); ++it) - { - CIBDrvInfosD3D *ib = NLMISC::safe_cast(*it); - if(ib) - { - uint numIndex= ib->IndexBufferPtr->getNumIndexes(); - result.push_back(toString(" %16s: %4d ko ", - ib->IndexBufferPtr->getName().c_str(), sizeof(uint32) * numIndex)); - } - } -} - -// *************************************************************************** - -void CDriverD3D::startBench (bool wantStandardDeviation, bool quick, bool reset) -{ - CHTimer::startBench (wantStandardDeviation, quick, reset); -} - -// *************************************************************************** - -void CDriverD3D::endBench () -{ - CHTimer::endBench (); -} - -// *************************************************************************** - -void CDriverD3D::displayBench (class NLMISC::CLog *log) -{ - // diplay - CHTimer::displayHierarchicalByExecutionPathSorted(log, CHTimer::TotalTime, true, 48, 2); - CHTimer::displayHierarchical(log, true, 48, 2); - CHTimer::displayByExecutionPath(log, CHTimer::TotalTime); - CHTimer::display(log, CHTimer::TotalTime); - CHTimer::display(log, CHTimer::TotalTimeWithoutSons); -} - -// *************************************************************************** - -} // NL3D diff --git a/code/nel/src/3d/driver/direct3d/driver_direct3d_render.cpp b/code/nel/src/3d/driver/direct3d/driver_direct3d_render.cpp deleted file mode 100644 index 6b9d2ce0c..000000000 --- a/code/nel/src/3d/driver/direct3d/driver_direct3d_render.cpp +++ /dev/null @@ -1,468 +0,0 @@ -// NeL - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as -// published by the Free Software Foundation, either version 3 of the -// License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -#include "stddirect3d.h" - -#include "nel/3d/vertex_buffer.h" -#include "nel/3d/light.h" -#include "nel/3d/index_buffer.h" -#include "nel/misc/rect.h" -#include "nel/misc/fast_mem.h" -#include "nel/3d/viewport.h" -#include "nel/3d/scissor.h" -#include "nel/3d/u_driver.h" - -#include "driver_direct3d.h" - -#ifdef DEBUG_NEW -#define new DEBUG_NEW -#endif - -using namespace std; -using namespace NLMISC; - - - - -namespace NL3D -{ - - - - -// convert 32 bit indices to 16 bit indices on devices that don't have 32 bit indices -// *************************************************************************** -void CDriverD3D::convertToIndices16(uint firstIndex, uint numIndices) -{ - nlassert(numIndices > 0); - // Lock the good buffer - uint offset; - CVolatileIndexBuffer *&buffer = _VolatileIndexBuffer16RAM[_CurrentRenderPass&1]; - uint16 *ptr = (uint16*)buffer->lock (numIndices*sizeof(uint16), offset); - if (!ptr) - { - // index buffer full, swap with other buffer - CVolatileIndexBuffer *&bufferOther = _VolatileIndexBuffer16RAM[(_CurrentRenderPass + 1) &1]; - std::swap(buffer, bufferOther); - buffer->reset(); - ptr = (uint16*)buffer->lock (numIndices*sizeof(uint16), offset); - } - const uint32 *currIndex = &_LastIndexBufferInfo->RamVersion[firstIndex]; - const uint32 *indexEnd = currIndex + numIndices; - do - { - #ifdef NL_DEBUG - nlassertex(*currIndex < _MaxVertexIndex, ("In this implementation, only 16 bit indices are supported")); - #endif - *ptr++ = (uint16&) (*currIndex++); - } - while (currIndex != indexEnd); - buffer->unlock(); - setIndexBuffer(buffer->IndexBuffer, offset); -} - -// *************************************************************************** -#ifndef NL_DEBUG - inline -#endif -bool CDriverD3D::renderPrimitives(D3DPRIMITIVETYPE primitiveType, uint /* numVertexPerPrim */, CMaterial& mat, uint firstVertex, uint32 nPrims) -{ - // Setup material - if ( !setupMaterial(mat) ) - return false; - if (nPrims == 0) - return false; - nlassertex(nPrims < _MaxPrimitiveCount, ("Number of max primitive at each calls limited in this implementation on current hradware")); - if (_VertexBufferCache.VertexBuffer) - { - uint pass; - beginMultiPass (); - for (pass=0; pass<_CurrentShaderPassCount; pass++) - { - // Active the pass - activePass (pass); - HRESULT r = _DeviceInterface->DrawPrimitive (primitiveType, firstVertex + _VertexBufferOffset, nPrims); - nlassert(r == D3D_OK); - } - endMultiPass (); - } - return true; -} - - - - -// *************************************************************************** -#ifndef NL_DEBUG - inline -#endif -bool CDriverD3D::renderIndexedPrimitives(D3DPRIMITIVETYPE primitiveType, uint numVertexPerPrim, CMaterial& mat, uint32 firstIndex, uint32 nPrims, uint indexOffset /*= 0*/) -{ - // Setup material - if ( !setupMaterial(mat) ) - return false; - if (nPrims == 0) - return false; - nlassertex(nPrims < _MaxPrimitiveCount, ("Number of max primitive at each calls limited in this implementation on current hardware")); - nlassert(_CurrIndexBufferFormat != CIndexBuffer::IndicesUnknownFormat); - if (_MaxVertexIndex <= 0xffff && _CurrIndexBufferFormat == CIndexBuffer::Indices32) - { - convertToIndices16(firstIndex, numVertexPerPrim * nPrims); - firstIndex = 0; - } - if (_VertexBufferCache.VertexBuffer && _IndexBufferCache.IndexBuffer) - { - uint pass; - beginMultiPass (); - for (pass=0; pass< _CurrentShaderPassCount; pass++) - { - // Active the pass - activePass (pass); - // NB : indexOffset is actually a constant added to each index in the current index buffer (actually may be implemented - // by moving vertex pointer in the driver ...), whereas _IndexBufferOffset+firstIndex gives an offset into the index buffer - HRESULT r = _DeviceInterface->DrawIndexedPrimitive (primitiveType, _VertexBufferOffset + indexOffset, 0, _VertexBufferSize, - firstIndex+_IndexBufferOffset, nPrims); - nlassert(r == D3D_OK); - - } - endMultiPass (); - } - return true; -} - -// *************************************************************************** -#ifndef NL_DEBUG - inline -#endif -bool CDriverD3D::renderSimpleIndexedPrimitives(D3DPRIMITIVETYPE primitiveType, uint numVertexPerPrim, uint32 firstIndex, uint32 nPrims, uint indexOffset /*= 0*/) -{ - if (nPrims == 0) - return false; - nlassertex(nPrims < _MaxPrimitiveCount, ("Number of max primitive at each calls limited in this implementation on current hardware")); - nlassert(_CurrIndexBufferFormat != CIndexBuffer::IndicesUnknownFormat); - if (_MaxVertexIndex <= 0xffff && _CurrIndexBufferFormat == CIndexBuffer::Indices32) - { - convertToIndices16(firstIndex, numVertexPerPrim * nPrims); - firstIndex = 0; - } - if (_VertexBufferCache.VertexBuffer && _IndexBufferCache.IndexBuffer) - { - updateRenderVariablesInternal(); - //fixVB(nPrims, numVertexPerPrim); - // NB : indexOffset is actually a constant added to each index in the current index buffer (actually may be implemented - // by moving vertex pointer in the driver ...), whereas _IndexBufferOffset+firstIndex gives an offset into the index buffer - HRESULT r = _DeviceInterface->DrawIndexedPrimitive (primitiveType, _VertexBufferOffset + indexOffset, 0, _VertexBufferSize, - firstIndex+_IndexBufferOffset, nPrims); - nlassert(r == D3D_OK); - } - return true; -} - -// *************************************************************************** - -bool CDriverD3D::renderLines(CMaterial& mat, uint32 firstIndex, uint32 nlines) -{ - H_AUTO_D3D(CDriverD3D_renderLines) - if (!renderIndexedPrimitives(D3DPT_LINELIST, 2, mat, firstIndex, nlines)) return false; - // Stats - _PrimitiveProfileIn.NLines += nlines; - _PrimitiveProfileOut.NLines += nlines*_CurrentShaderPassCount; - - return true; -} - - -// *************************************************************************** - -bool CDriverD3D::renderTriangles(CMaterial& mat, uint32 firstIndex, uint32 ntris) -{ - H_AUTO_D3D(CDriverD3D_renderTriangles) - if (!renderIndexedPrimitives(D3DPT_TRIANGLELIST, 3, mat, firstIndex, ntris)) return false; - // Stats - _PrimitiveProfileIn.NTriangles += ntris; - _PrimitiveProfileOut.NTriangles += ntris*_CurrentShaderPassCount; - return true; -} - -// *************************************************************************** - -bool CDriverD3D::renderSimpleTriangles(uint32 firstIndex, uint32 ntris) -{ - H_AUTO_D3D(CDriverD3D_renderSimpleTriangles) - nlassert (ntris != 0); - nlassert (_VertexBufferCache.VertexBuffer); - nlassert (_IndexBufferCache.IndexBuffer); - if (!renderSimpleIndexedPrimitives(D3DPT_TRIANGLELIST, 3, firstIndex, ntris)) return false; - // Stats - _PrimitiveProfileIn.NTriangles += ntris; - _PrimitiveProfileOut.NTriangles += ntris; - - return true; -} - -// *************************************************************************** -bool CDriverD3D::renderLinesWithIndexOffset(CMaterial& mat, uint32 firstIndex, uint32 nlines, uint indexOffset) -{ - H_AUTO_D3D(CDriverD3D_renderLinesWithIndexOffset) - if (!renderIndexedPrimitives(D3DPT_LINELIST, 2, mat, firstIndex, nlines, indexOffset)) return false; - // Stats - _PrimitiveProfileIn.NLines += nlines; - _PrimitiveProfileOut.NLines += nlines*_CurrentShaderPassCount; - return true; -} - -// *************************************************************************** -bool CDriverD3D::renderTrianglesWithIndexOffset(CMaterial& mat, uint32 firstIndex, uint32 ntris, uint indexOffset) -{ - H_AUTO_D3D(CDriverD3D_renderTrianglesWithIndexOffset) - if (!renderIndexedPrimitives(D3DPT_TRIANGLELIST, 3, mat, firstIndex, ntris, indexOffset)) return false; - // Stats - _PrimitiveProfileIn.NTriangles += ntris; - _PrimitiveProfileOut.NTriangles += ntris*_CurrentShaderPassCount; - return true; -} - -// *************************************************************************** -bool CDriverD3D::renderSimpleTrianglesWithIndexOffset(uint32 firstIndex, uint32 ntris, uint indexOffset) -{ - H_AUTO_D3D(CDriverD3D_renderSimpleTrianglesWithIndexOffset) - nlassert (ntris != 0); - nlassert (_VertexBufferCache.VertexBuffer); - nlassert (_IndexBufferCache.IndexBuffer); - if (!renderSimpleIndexedPrimitives(D3DPT_TRIANGLELIST, 3, firstIndex, ntris, indexOffset)) return false; - // Stats - _PrimitiveProfileIn.NTriangles += ntris; - _PrimitiveProfileOut.NTriangles += ntris; - - return true; -} - -// *************************************************************************** -bool CDriverD3D::renderRawPoints(CMaterial& mat, uint32 firstIndex, uint32 numPoints) -{ - H_AUTO_D3D(CDriverD3D_renderRawPoints); - if (!renderPrimitives(D3DPT_POINTLIST, 1, mat, firstIndex, numPoints)) - // Stats - _PrimitiveProfileIn.NPoints += numPoints; - _PrimitiveProfileOut.NPoints += numPoints*_CurrentShaderPassCount; - return true; -} - -// *************************************************************************** -bool CDriverD3D::renderRawLines(CMaterial& mat, uint32 firstIndex, uint32 numLines) -{ - H_AUTO_D3D(CDriverD3D_renderRawLines); - if (!renderPrimitives(D3DPT_LINELIST, 2, mat, firstIndex, numLines)) return false; - // Stats - _PrimitiveProfileIn.NLines += numLines; - _PrimitiveProfileOut.NLines += numLines*_CurrentShaderPassCount; - - return true; -} - -// *************************************************************************** - -bool CDriverD3D::renderRawTriangles(CMaterial& mat, uint32 firstIndex, uint32 numTris) -{ - H_AUTO_D3D(CDriverD3D_renderRawTriangles) - if (!renderPrimitives(D3DPT_TRIANGLELIST, 3, mat, 3 * firstIndex, numTris)) return false; - // Stats - _PrimitiveProfileIn.NTriangles += numTris; - _PrimitiveProfileOut.NTriangles += numTris*_CurrentShaderPassCount; - - return true; -} - -// *************************************************************************** -// 32 bits version -void fillQuadIndexes (uint32 *indexes, uint first, uint last) -{ - H_AUTO_D3D(fillQuadIndexes) - uint firstQuad = (first / 6) * 4; - for (;firstSetRenderState (D3DRS_ALPHABLENDENABLE, FALSE); - _DeviceInterface->SetRenderState (D3DRS_SRCBLEND, D3DBLEND_ONE); - _DeviceInterface->SetRenderState (D3DRS_DESTBLEND, D3DBLEND_ZERO); - _DeviceInterface->SetRenderState (D3DRS_ALPHATESTENABLE, FALSE); - _DeviceInterface->SetRenderState (D3DRS_ALPHAREF, 128); - _DeviceInterface->SetRenderState (D3DRS_ALPHAFUNC, D3DCMP_GREATER); - _DeviceInterface->SetRenderState (D3DRS_LIGHTING, FALSE); - _DeviceInterface->SetRenderState (D3DRS_TEXTUREFACTOR, NL_D3DCOLOR_RGBA(CRGBA(255,0,255,255))); - _DeviceInterface->SetRenderState (D3DRS_CULLMODE, D3DCULL_CW); - _DeviceInterface->SetRenderState (D3DRS_COLORVERTEX, FALSE); - _DeviceInterface->SetRenderState (D3DRS_ZWRITEENABLE, TRUE); - _DeviceInterface->SetRenderState (D3DRS_ZFUNC, D3DCMP_LESSEQUAL); - _DeviceInterface->SetRenderState (D3DRS_DIFFUSEMATERIALSOURCE, D3DMCS_MATERIAL); - _DeviceInterface->SetRenderState (D3DRS_SPECULARMATERIALSOURCE, D3DMCS_MATERIAL); - _DeviceInterface->SetRenderState (D3DRS_AMBIENTMATERIALSOURCE, D3DMCS_MATERIAL); - _DeviceInterface->SetRenderState (D3DRS_EMISSIVEMATERIALSOURCE, D3DMCS_MATERIAL); - _DeviceInterface->SetTexture (0, NULL); - _DeviceInterface->SetTexture (1, NULL); - _DeviceInterface->SetTexture (2, NULL); - _DeviceInterface->SetTexture (3, NULL); - _DeviceInterface->SetTexture (4, NULL); - _DeviceInterface->SetTexture (5, NULL); - _DeviceInterface->SetTexture (6, NULL); - _DeviceInterface->SetTexture (7, NULL); - _DeviceInterface->SetTextureStageState (0, D3DTSS_COLOROP, D3DTOP_SELECTARG1); - _DeviceInterface->SetTextureStageState (0, D3DTSS_COLORARG0, D3DTA_TFACTOR); - _DeviceInterface->SetTextureStageState (0, D3DTSS_COLORARG1, D3DTA_TFACTOR); - _DeviceInterface->SetTextureStageState (0, D3DTSS_COLORARG2, D3DTA_TFACTOR); - _DeviceInterface->SetTextureStageState (0, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1); - _DeviceInterface->SetTextureStageState (0, D3DTSS_ALPHAARG0, D3DTA_TFACTOR); - _DeviceInterface->SetTextureStageState (0, D3DTSS_ALPHAARG1, D3DTA_TFACTOR); - _DeviceInterface->SetTextureStageState (0, D3DTSS_ALPHAARG2, D3DTA_TFACTOR); - // _DeviceInterface->SetTextureStageState (0, D3DTSS_CONSTANT, 0x0); - uint i; - for (i=1; i<8; i++) - { - _DeviceInterface->SetTextureStageState (i, D3DTSS_COLOROP, D3DTOP_DISABLE); - _DeviceInterface->SetTextureStageState (i, D3DTSS_COLORARG0, D3DTA_TFACTOR); - _DeviceInterface->SetTextureStageState (i, D3DTSS_COLORARG1, D3DTA_TFACTOR); - _DeviceInterface->SetTextureStageState (i, D3DTSS_COLORARG2, D3DTA_TFACTOR); - _DeviceInterface->SetTextureStageState (i, D3DTSS_ALPHAOP, D3DTOP_DISABLE); - _DeviceInterface->SetTextureStageState (i, D3DTSS_ALPHAARG0, D3DTA_TFACTOR); - _DeviceInterface->SetTextureStageState (i, D3DTSS_ALPHAARG1, D3DTA_TFACTOR); - _DeviceInterface->SetTextureStageState (i, D3DTSS_ALPHAARG2, D3DTA_TFACTOR); - // _DeviceInterface->SetTextureStageState (i, D3DTSS_CONSTANT, 0x0); - } -} - - -// *************************************************************************** -bool CDriverD3D::renderRawQuads(CMaterial& mat, uint32 startIndex, uint32 numQuads) -{ - H_AUTO_D3D(CDriverD3D_renderRawQuads) - if (numQuads == 0) return false; - else - if (_VertexBufferCache.VertexBuffer) - { - // Num of indexes needed - const uint numQuadsNeeded = numQuads*6; - nlassert(numQuads < MAX_NUM_QUADS); // this limitation should suffice for now - { - if (_MaxVertexIndex <= 0xffff) - { - nlassert(_QuadIB); - setIndexBuffer(_QuadIB, 0); - _CurrIndexBufferFormat = CIndexBuffer::Indices16; // must set the format because we don't call activeIndexBuffer - } - else - { - const uint IB_RESIZE_STRIDE = 6 * 256; - nlctassert(IB_RESIZE_STRIDE % 6 == 0); - // Need to resize the quad indexes array ? - if (_QuadIndexes.getNumIndexes() < numQuadsNeeded) - { - // Resize it - uint32 numIndexResize = IB_RESIZE_STRIDE * ((numQuadsNeeded + (IB_RESIZE_STRIDE - 1)) / IB_RESIZE_STRIDE); - _QuadIndexes.setFormat(NL_DEFAULT_INDEX_BUFFER_FORMAT); - _QuadIndexes.setNumIndexes(numIndexResize); // snap to nearest size - // Fill the index buffer in VRAM - CIndexBufferReadWrite iba; - _QuadIndexes.lock (iba); - if (_QuadIndexes.getFormat() == CIndexBuffer::Indices32) - { - fillQuadIndexes ((uint32 *) iba.getPtr(), 0, numIndexResize); - } - else - { - fillQuadIndexes ((uint16 *) iba.getPtr(), 0, numIndexResize); - } - } - activeIndexBuffer (_QuadIndexes); - } - // Setup material - if ( !setupMaterial(mat) ) - return false; - - uint pass; - beginMultiPass (); - for (pass=0; pass<_CurrentShaderPassCount; pass++) - { - // Active the pass - activePass (pass); - //fixVB(numQuads, 4); - _DeviceInterface->DrawIndexedPrimitive (D3DPT_TRIANGLELIST, _VertexBufferOffset + startIndex, 0, numQuads * 4, - 0, numQuads*2); - } - endMultiPass (); - } - } - - // Stats - _PrimitiveProfileIn.NTriangles += numQuads*2; - _PrimitiveProfileOut.NTriangles += numQuads*2*_CurrentShaderPassCount; - - return true; -} - -// *************************************************************************** - -} // NL3D - - - - - - - - - - - - - - - - - - - - - diff --git a/code/nel/src/3d/driver/direct3d/driver_direct3d_shader.cpp b/code/nel/src/3d/driver/direct3d/driver_direct3d_shader.cpp deleted file mode 100644 index 3f11f8bce..000000000 --- a/code/nel/src/3d/driver/direct3d/driver_direct3d_shader.cpp +++ /dev/null @@ -1,4011 +0,0 @@ -// NeL - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as -// published by the Free Software Foundation, either version 3 of the -// License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -#include "stddirect3d.h" - -#include "driver_direct3d.h" -#include "nel/misc/path.h" -#include "nel/misc/file.h" - -#ifdef DEBUG_NEW -#define new DEBUG_NEW -#endif - -using namespace std; -using namespace NLMISC; - -namespace NL3D -{ - - -// *************************************************************************** - -CD3DShaderFX::~CD3DShaderFX() -{ - // Must kill the drv mirror of this shader. - _DrvInfo.kill(); -} - -// *************************************************************************** - -CD3DShaderFX::CD3DShaderFX() -{ - _ShaderChanged = true; -} - -// *************************************************************************** - -void CD3DShaderFX::setText (const char *text) -{ - _Text = text; - _ShaderChanged = true; -} - -// *************************************************************************** - -void CD3DShaderFX::setName (const char *name) -{ - _Name = name; - _ShaderChanged = true; -} - -// *************************************************************************** - -bool CD3DShaderFX::loadShaderFile (const char *filename) -{ - _Text.clear(); - // Lookup - string _filename = NLMISC::CPath::lookup(filename, false, true, true); - if (!_filename.empty()) - { - // File length - uint size = NLMISC::CFile::getFileSize (_filename); - _Text.reserve (size+1); - - try - { - NLMISC::CIFile file; - if (file.open (_filename)) - { - // Read it - while (!file.eof ()) - { - char line[512]; - file.getline (line, 512); - _Text += line; - } - - // Set the shader name - _Name = NLMISC::CFile::getFilename (filename); - return true; - } - else - { - nlwarning ("Can't open the file %s for reading", _filename.c_str()); - } - } - catch (const Exception &e) - { - nlwarning ("Error while reading %s : %s", _filename.c_str(), e.what()); - } - } - return false; -} - -// *************************************************************************** - -IShaderDrvInfos::~IShaderDrvInfos() -{ - _Driver->removeShaderDrvInfoPtr(_DriverIterator); -} - -void CDriverD3D::removeShaderDrvInfoPtr(ItShaderDrvInfoPtrList shaderIt) -{ - _ShaderDrvInfos.erase(shaderIt); -} - -// mem allocator for state records -std::allocator CStateRecord::Allocator; - - -// *************************************************************************** -// The state manager with cache -// *************************************************************************** - -HRESULT CDriverD3D::QueryInterface(REFIID /* riid */, LPVOID * /* ppvObj */) -{ - H_AUTO_D3D(CDriverD3D_QueryInterface) - return D3D_OK; -} - -// *************************************************************************** - -ULONG CDriverD3D::AddRef(VOID) -{ - H_AUTO_D3D(CDriverD3D_AddRef) - return 0; -} - -// *************************************************************************** - -ULONG CDriverD3D::Release(VOID) -{ - H_AUTO_D3D(CDriverD3D_Release) - return 0; -} - -// *************************************************************************** - -HRESULT CDriverD3D::LightEnable(DWORD Index, BOOL Enable) -{ - H_AUTO_D3D(CDriverD3D_LightEnable) - enableLight ((uint8)Index, Enable!=FALSE); - return D3D_OK; -} - -// *************************************************************************** - -HRESULT CDriverD3D::SetFVF(DWORD /* FVF */) -{ - H_AUTO_D3D(CDriverD3D_SetFVF) - // Not implemented - return D3D_OK; -} - -// *************************************************************************** - -HRESULT CDriverD3D::SetLight(DWORD Index, CONST D3DLIGHT9* pLight) -{ - H_AUTO_D3D(CDriverD3D_SetLight) - _LightCache[Index].Light = *pLight; - touchRenderVariable (&_LightCache[Index]); - return D3D_OK; -} - -// *************************************************************************** - -HRESULT CDriverD3D::SetMaterial(CONST D3DMATERIAL9* pMaterial) -{ - H_AUTO_D3D(CDriverD3D_SetMaterial) - setMaterialState( *pMaterial ); - return D3D_OK; -} - -// *************************************************************************** - -HRESULT CDriverD3D::SetNPatchMode(FLOAT /* nSegments */) -{ - H_AUTO_D3D(CDriverD3D_SetNPatchMode) - // Not implemented - return D3D_OK; -} - -// *************************************************************************** - -HRESULT CDriverD3D::SetPixelShader(LPDIRECT3DPIXELSHADER9 pShader) -{ - H_AUTO_D3D(CDriverD3D_SetPixelShader) - setPixelShader (pShader); - return D3D_OK; -} - -// *************************************************************************** - -HRESULT CDriverD3D::SetPixelShaderConstantB(UINT StartRegister, CONST BOOL* pConstantData, UINT RegisterCount) -{ - H_AUTO_D3D(CDriverD3D_SetPixelShaderConstantB) - uint i; - for (i=0; iRelease(); -} - -// *************************************************************************** - -bool CDriverD3D::validateShader(CD3DShaderFX *shader) -{ - H_AUTO_D3D(CDriverD3D_validateShader) - CShaderDrvInfosD3D *shaderInfo = static_cast((IShaderDrvInfos*)shader->_DrvInfo); - - if (!shaderInfo->Validated) - { - // Choose the good method - D3DXHANDLE hTechnique = NULL; - D3DXHANDLE hCurrentTechnique = NULL; - while (hTechnique == NULL) - { - if (shaderInfo->Effect->FindNextValidTechnique(hCurrentTechnique, &hCurrentTechnique) != D3D_OK) - return false; - - // Info - -#ifdef NL_FORCE_TEXTURE_STAGE_COUNT - D3DXTECHNIQUE_DESC desc; - nlverify (shaderInfo->Effect->GetTechniqueDesc(hCurrentTechnique, &desc) == D3D_OK); - - // Check this is compatible - const uint len = strlen(desc.Name); - if (len) - { - char shaderStageCount = desc.Name[len-1]; - if ((shaderStageCount>='0') && (shaderStageCount<='9')) - { - uint stageCount = NL_FORCE_TEXTURE_STAGE_COUNT; - - if ((uint)(shaderStageCount-'0')<=stageCount) - // The good technique - hTechnique = hCurrentTechnique; - } - } -#else // NL_FORCE_TEXTURE_STAGE_COUNT - hTechnique = hCurrentTechnique; -#endif // NL_FORCE_TEXTURE_STAGE_COUNT - -#ifdef NL_DEBUG_D3D - { - D3DXTECHNIQUE_DESC desc; - nlverify (shaderInfo->Effect->GetTechniqueDesc(hCurrentTechnique, &desc) == D3D_OK); - if (hTechnique) - nlinfo ("Shader \"%s\" : use technique \"%s\" with %d passes.", shader->getName(), desc.Name, desc.Passes); - } -#endif // NL_DEBUG_D3D - } - - // Set the technique - shaderInfo->Effect->SetTechnique(hTechnique); - - // Set the state manager - shaderInfo->Effect->SetStateManager (this); - - shaderInfo->Validated = true; - } - return true; -} - -// *************************************************************************** - -bool CDriverD3D::activeShader(CD3DShaderFX *shd) -{ - H_AUTO_D3D(CDriverD3D_activeShader) - if (_DisableHardwarePixelShader) - return false; - - // Clear current textures - _CurrentShaderTextures.clear(); - - // Shader has been changed ? - if (shd && shd->_ShaderChanged) - { - // Remove old shader - shd->_DrvInfo.kill(); - - // Already setuped ? - CShaderDrvInfosD3D *shaderInfo = static_cast((IShaderDrvInfos*)shd->_DrvInfo); - if ( !shd->_DrvInfo ) - { - // insert into driver list. (so it is deleted when driver is deleted). - ItShaderDrvInfoPtrList it= _ShaderDrvInfos.insert(_ShaderDrvInfos.end(), (NL3D::IShaderDrvInfos*)NULL); - // create and set iterator, for future deletion. - shaderInfo = new CShaderDrvInfosD3D(this, it); - *it= shd->_DrvInfo = shaderInfo; - } - - // Assemble the shader - LPD3DXBUFFER pErrorMsgs; - HRESULT hr = D3DXCreateEffect(_DeviceInterface, shd->getText(), (UINT)strlen(shd->getText())+1, NULL, NULL, 0, NULL, &(shaderInfo->Effect), &pErrorMsgs); - if (hr == D3D_OK) - { - // Get the texture handle - uint i; - for (i=0; iTextureHandle[i] = shaderInfo->Effect->GetParameterByName(NULL, name.c_str()); - name = "color" + toString (i); - shaderInfo->ColorHandle[i] = shaderInfo->Effect->GetParameterByName(NULL, name.c_str()); - name = "factor" + toString (i); - shaderInfo->FactorHandle[i] = shaderInfo->Effect->GetParameterByName(NULL, name.c_str()); - name = "scalarFloat" + toString (i); - shaderInfo->ScalarFloatHandle[i] = shaderInfo->Effect->GetParameterByName(NULL, name.c_str()); - } - } - else - { - nlwarning ("Can't create shader '%s' (0x%x):", shd->getName(), hr); - if (pErrorMsgs) - nlwarning ((const char*)pErrorMsgs->GetBufferPointer()); - shd->_ShaderChanged = false; - _CurrentShader = NULL; - return false; - } - - // Done - shd->_ShaderChanged = false; - } - - // Set the shader - _CurrentShader = shd; - - return true; -} - - -static void setFX(CD3DShaderFX &s, const char *name, const char *prog, CDriverD3D *drv) -{ - H_AUTO_D3D(setFX) - - s.setName(name); - s.setText(prog); - nlverify (drv->activeShader (&s)); -} - -#define setFx(a,b,c) { setFX(a, b, c, this); } - -static const char *CloudFx = -" \n\ -texture texture0; \n\ -texture texture1; \n\ -float4 factor0; \n\ - \n\ -pixelshader two_stages_ps = asm \n\ -{ \n\ - ps_1_1; \n\ - tex t0; \n\ - tex t1; \n\ - lrp r0.w, v0, t0, t1; \n\ - mov r0.xyz, c0; \n\ - +mul r0.w, c0, r0; \n\ -}; \n\ - \n\ -technique two_stages_2 \n\ -{ \n\ - pass p0 \n\ - { \n\ - Texture[0] = ; \n\ - Texture[1] = ; \n\ - PixelShaderConstant[0] = ; \n\ - PixelShader = (two_stages_ps); \n\ - } \n\ -}; \n\ - \n\ -"; - -static const char *Lightmap0Fx = -" \n\ -texture texture0; \n\ - \n\ -float4 g_black = { 0.0f, 0.0f, 0.0f, 1.0f }; \n\ -float4 g_dyn_factor = { 1.0f, 1.0f, 1.0f, 1.0f }; \n\ - \n\ -technique one_stage_1 \n\ -{ \n\ - pass p0 \n\ - { \n\ - // do a standard lighting with the first light \n\ - Lighting = true; \n\ - MaterialEmissive= ; \n\ - MaterialAmbient= ; \n\ - MaterialDiffuse= ; \n\ - MaterialSpecular= ; \n\ - AlphaBlendEnable = false; \n\ - \n\ - Texture[0] = ; \n\ - ColorOp[0] = MODULATE; \n\ - ColorArg1[0] = TEXTURE; \n\ - ColorArg2[0] = DIFFUSE; \n\ - AlphaOp[0] = SELECTARG1; // for alpha test \n\ - AlphaArg1[0] = TEXTURE; \n\ - } \n\ -}; \n\ - \n\ -"; - -static const char *Lightmap0blendFx = -" \n\ -texture texture0; \n\ - \n\ -float4 g_black = { 0.0f, 0.0f, 0.0f, 1.0f }; \n\ -float4 g_dyn_factor = { 1.0f, 1.0f, 1.0f, 1.0f }; \n\ - \n\ -technique one_stage_1 \n\ -{ \n\ - pass p0 \n\ - { \n\ - // do a standard lighting with the first light \n\ - Lighting = true; \n\ - MaterialEmissive= ; \n\ - MaterialAmbient= ; \n\ - MaterialDiffuse= ; \n\ - MaterialSpecular= ; \n\ - AlphaBlendEnable = true; \n\ - SrcBlend = SRCALPHA; \n\ - DestBlend = INVSRCALPHA; \n\ - \n\ - Texture[0] = ; \n\ - ColorOp[0] = MODULATE; \n\ - ColorArg1[0] = TEXTURE; \n\ - ColorArg2[0] = DIFFUSE; \n\ - AlphaOp[0] = SELECTARG1; \n\ - AlphaArg1[0] = TEXTURE; \n\ - } \n\ -}; \n\ - \n\ -"; - -static const char *Lightmap0blend_x2Fx = -" \n\ -texture texture0; \n\ - \n\ -float4 g_black = { 0.0f, 0.0f, 0.0f, 1.0f }; \n\ -float4 g_dyn_factor = { 1.0f, 1.0f, 1.0f, 1.0f }; \n\ - \n\ -technique one_stage_1 \n\ -{ \n\ - pass p0 \n\ - { \n\ - // do a standard lighting with the first light \n\ - Lighting = true; \n\ - MaterialEmissive= ; \n\ - MaterialAmbient= ; \n\ - MaterialDiffuse= ; \n\ - MaterialSpecular= ; \n\ - AlphaBlendEnable = true; \n\ - SrcBlend = SRCALPHA; \n\ - DestBlend = INVSRCALPHA; \n\ - \n\ - Texture[0] = ; \n\ - ColorOp[0] = MODULATE; \n\ - ColorArg1[0] = TEXTURE; \n\ - ColorArg2[0] = DIFFUSE; \n\ - AlphaOp[0] = SELECTARG1; \n\ - AlphaArg1[0] = TEXTURE; \n\ - } \n\ -}; \n\ - \n\ -"; - -static const char *Lightmap0_x2Fx = -" \n\ -texture texture0; \n\ - \n\ -float4 g_black = { 0.0f, 0.0f, 0.0f, 1.0f }; \n\ -float4 g_dyn_factor = { 1.0f, 1.0f, 1.0f, 1.0f }; \n\ - \n\ -technique one_stage_1 \n\ -{ \n\ - pass p0 \n\ - { \n\ - // do a standard lighting with the first light \n\ - Lighting = true; \n\ - MaterialEmissive= ; \n\ - MaterialAmbient= ; \n\ - MaterialDiffuse= ; \n\ - MaterialSpecular= ; \n\ - AlphaBlendEnable = false; \n\ - \n\ - Texture[0] = ; \n\ - ColorOp[0] = MODULATE; \n\ - ColorArg1[0] = TEXTURE; \n\ - ColorArg2[0] = DIFFUSE; \n\ - AlphaOp[0] = SELECTARG1; // for alpha test \n\ - AlphaArg1[0] = TEXTURE; \n\ - } \n\ -}; \n\ - \n\ -"; - -static const char *Lightmap1Fx = -" \n\ -texture texture0; \n\ -texture texture1; \n\ -// Color0 is the Ambient Added to the lightmap (for Lightmap 8 bit compression)\n\ -// Other colors are the lightmap Factors for each lightmap \n\ -dword color0; \n\ -dword color1; \n\ -float4 factor0; \n\ -float4 factor1; \n\ - \n\ -float4 g_black = { 0.0f, 0.0f, 0.0f, 1.0f }; \n\ -float4 g_dyn_factor = { 1.0f, 1.0f, 1.0f, 1.0f }; \n\ - \n\ -technique two_stages_2 \n\ -{ \n\ - pass p0 \n\ - { \n\ - // Use Emissive For LMCAmbient, and diffuse for per vertex dynamic lighting\n\ - Lighting = true; \n\ - MaterialEmissive= ; \n\ - MaterialAmbient= ; \n\ - MaterialDiffuse= ; \n\ - MaterialSpecular= ; \n\ - AlphaBlendEnable = false; \n\ - \n\ - // the DiffuseTexture texture 0 is in last stage \n\ - TexCoordIndex[0] = 1; \n\ - TexCoordIndex[1] = 0; \n\ - Texture[0] = ; \n\ - Texture[1] = ; \n\ - TextureFactor = ; \n\ - ColorOp[0] = MULTIPLYADD; \n\ - ColorArg0[0] = DIFFUSE; \n\ - ColorArg1[0] = TFACTOR; \n\ - ColorArg2[0] = TEXTURE; \n\ - ColorOp[1] = MODULATE; \n\ - ColorArg1[1] = CURRENT; \n\ - ColorArg2[1] = TEXTURE; \n\ - AlphaOp[0] = SELECTARG1; \n\ - AlphaArg1[0] = TFACTOR; \n\ - AlphaOp[1] = SELECTARG1; // for alpha test \n\ - AlphaArg1[1] = TEXTURE; \n\ - } \n\ -}; \n\ - \n\ -"; - -static const char *Lightmap1blendFx = -" \n\ -texture texture0; \n\ -texture texture1; \n\ -// Color0 is the Ambient Added to the lightmap (for Lightmap 8 bit compression)\n\ -// Other colors are the lightmap Factors for each lightmap \n\ -dword color0; \n\ -dword color1; \n\ -float4 factor0; \n\ -float4 factor1; \n\ - \n\ -float4 g_black = { 0.0f, 0.0f, 0.0f, 1.0f }; \n\ -float4 g_dyn_factor = { 1.0f, 1.0f, 1.0f, 1.0f }; \n\ - \n\ -technique two_stages_2 \n\ -{ \n\ - pass p0 \n\ - { \n\ - // Use Emissive For LMCAmbient, and diffuse for per vertex dynamic lighting\n\ - Lighting = true; \n\ - MaterialEmissive= ; \n\ - MaterialAmbient= ; \n\ - MaterialDiffuse= ; \n\ - MaterialSpecular= ; \n\ - AlphaBlendEnable = true; \n\ - SrcBlend = SRCALPHA; \n\ - DestBlend = INVSRCALPHA; \n\ - \n\ - // the DiffuseTexture texture 0 is in last stage \n\ - TexCoordIndex[0] = 1; \n\ - TexCoordIndex[1] = 0; \n\ - Texture[0] = ; \n\ - Texture[1] = ; \n\ - TextureFactor = ; \n\ - ColorOp[0] = MULTIPLYADD; \n\ - ColorArg0[0] = DIFFUSE; \n\ - ColorArg1[0] = TFACTOR; \n\ - ColorArg2[0] = TEXTURE; \n\ - ColorOp[1] = MODULATE; \n\ - ColorArg1[1] = CURRENT; \n\ - ColorArg2[1] = TEXTURE; \n\ - // Alpha stage 0 unused \n\ - AlphaOp[0] = SELECTARG1; \n\ - AlphaArg1[0] = TFACTOR; \n\ - AlphaOp[1] = SELECTARG1; \n\ - AlphaArg1[1] = TEXTURE; \n\ - } \n\ -}; \n\ - \n\ -"; - -static const char *Lightmap1blend_x2Fx = -" \n\ -texture texture0; \n\ -texture texture1; \n\ -// Color0 is the Ambient Added to the lightmap (for Lightmap 8 bit compression)\n\ -// Other colors are the lightmap Factors for each lightmap \n\ -dword color0; \n\ -dword color1; \n\ -float4 factor0; \n\ -float4 factor1; \n\ - \n\ -float4 g_black = { 0.0f, 0.0f, 0.0f, 1.0f }; \n\ -// modulate the dyn light by 0.5, because of MODULATE2X \n\ -float4 g_dyn_factor = { 0.5f, 0.5f, 0.5f, 1.0f }; \n\ - \n\ -technique two_stages_2 \n\ -{ \n\ - pass p0 \n\ - { \n\ - // Use Emissive For LMCAmbient, and diffuse for per vertex dynamic lighting\n\ - Lighting = true; \n\ - MaterialEmissive= ; \n\ - MaterialAmbient= ; \n\ - MaterialDiffuse= ; \n\ - MaterialSpecular= ; \n\ - AlphaBlendEnable = true; \n\ - SrcBlend = SRCALPHA; \n\ - DestBlend = INVSRCALPHA; \n\ - \n\ - // the DiffuseTexture texture 0 is in last stage \n\ - TexCoordIndex[0] = 1; \n\ - TexCoordIndex[1] = 0; \n\ - Texture[0] = ; \n\ - Texture[1] = ; \n\ - TextureFactor = ; \n\ - ColorOp[0] = MULTIPLYADD; \n\ - ColorArg0[0] = DIFFUSE; \n\ - ColorArg1[0] = TFACTOR; \n\ - ColorArg2[0] = TEXTURE; \n\ - ColorOp[1] = MODULATE2X; \n\ - ColorArg1[1] = CURRENT; \n\ - ColorArg2[1] = TEXTURE; \n\ - // Alpha stage 0 unused \n\ - AlphaOp[0] = SELECTARG1; \n\ - AlphaArg1[0] = TFACTOR; \n\ - AlphaOp[1] = SELECTARG1; \n\ - AlphaArg1[1] = TEXTURE; \n\ - } \n\ -}; \n\ - \n\ -"; - -static const char *Lightmap1_x2Fx = -" \n\ -texture texture0; \n\ -texture texture1; \n\ -// Color0 is the Ambient Added to the lightmap (for Lightmap 8 bit compression)\n\ -// Other colors are the lightmap Factors for each lightmap \n\ -dword color0; \n\ -dword color1; \n\ -float4 factor0; \n\ -float4 factor1; \n\ - \n\ -float4 g_black = { 0.0f, 0.0f, 0.0f, 1.0f }; \n\ -// modulate the dyn light by 0.5, because of MODULATE2X \n\ -float4 g_dyn_factor = { 0.5f, 0.5f, 0.5f, 1.0f }; \n\ - \n\ -technique two_stages_2 \n\ -{ \n\ - pass p0 \n\ - { \n\ - // Use Emissive For LMCAmbient, and diffuse for per vertex dynamic lighting\n\ - Lighting = true; \n\ - MaterialEmissive= ; \n\ - MaterialAmbient= ; \n\ - MaterialDiffuse= ; \n\ - MaterialSpecular= ; \n\ - AlphaBlendEnable = false; \n\ - \n\ - // the DiffuseTexture texture 0 is in last stage \n\ - TexCoordIndex[0] = 1; \n\ - TexCoordIndex[1] = 0; \n\ - Texture[0] = ; \n\ - Texture[1] = ; \n\ - TextureFactor = ; \n\ - ColorOp[0] = MULTIPLYADD; \n\ - ColorArg0[0] = DIFFUSE; \n\ - ColorArg1[0] = TFACTOR; \n\ - ColorArg2[0] = TEXTURE; \n\ - ColorOp[1] = MODULATE2X; \n\ - ColorArg1[1] = CURRENT; \n\ - ColorArg2[1] = TEXTURE; \n\ - AlphaOp[0] = SELECTARG1; \n\ - AlphaArg1[0] = TFACTOR; \n\ - AlphaOp[1] = SELECTARG1; // for alpha test \n\ - AlphaArg1[1] = TEXTURE; \n\ - } \n\ -}; \n\ - \n\ -"; - -static const char *Lightmap2Fx = -" \n\ -texture texture0; \n\ -texture texture1; \n\ -texture texture2; \n\ -// Color0 is the Ambient Added to the lightmap (for Lightmap 8 bit compression)\n\ -// Other colors are the lightmap Factors for each lightmap \n\ -dword color0; \n\ -dword color1; \n\ -dword color2; \n\ -float4 factor0; \n\ -float4 factor1; \n\ -float4 factor2; \n\ - \n\ -float4 g_black = { 0.0f, 0.0f, 0.0f, 1.0f }; \n\ -float4 g_dyn_factor = { 1.0f, 1.0f, 1.0f, 1.0f }; \n\ - \n\ - \n\ -// **** 3 stages technique \n\ -pixelshader three_stages_ps = asm \n\ -{ \n\ - ps_1_1; \n\ - tex t0; \n\ - tex t1; \n\ - tex t2; \n\ - // multiply lightmap with factor, and add with LMCAmbient+DynamicLight term\n\ - mad r0.xyz, c1, t1, v0; \n\ - mad r0.xyz, c2, t2, r0; \n\ - mul r0.xyz, r0, t0; \n\ - +mov r0.w, t0; \n\ -}; \n\ - \n\ -technique three_stages_3 \n\ -{ \n\ - pass p0 \n\ - { \n\ - TexCoordIndex[2] = 1; \n\ - \n\ - // Use Emissive For LMCAmbient, and diffuse for per vertex dynamic lighting\n\ - Lighting = true; \n\ - MaterialEmissive= ; \n\ - MaterialAmbient= ; \n\ - MaterialDiffuse= ; \n\ - MaterialSpecular= ; \n\ - AlphaBlendEnable = false; \n\ - \n\ - Texture[0] = ; \n\ - Texture[1] = ; \n\ - Texture[2] = ; \n\ - PixelShaderConstant[1] = ; \n\ - PixelShaderConstant[2] = ; \n\ - PixelShader = (three_stages_ps); \n\ - } \n\ -} \n\ - \n\ -// **** 2 stages, no pixel shader technique \n\ -technique two_stages_2 \n\ -{ \n\ - pass p0 \n\ - { \n\ - // Use Emissive For LMCAmbient, and diffuse for per vertex dynamic lighting\n\ - Lighting = true; \n\ - MaterialEmissive= ; \n\ - MaterialAmbient= ; \n\ - MaterialDiffuse= ; \n\ - MaterialSpecular= ; \n\ - AlphaBlendEnable = false; \n\ - \n\ - // the DiffuseTexture texture 0 is in last stage \n\ - TexCoordIndex[0] = 1; \n\ - TexCoordIndex[1] = 0; \n\ - Texture[0] = ; \n\ - Texture[1] = ; \n\ - TextureFactor = ; \n\ - ColorOp[0] = MULTIPLYADD; \n\ - ColorArg0[0] = DIFFUSE; \n\ - ColorArg1[0] = TFACTOR; \n\ - ColorArg2[0] = TEXTURE; \n\ - ColorOp[1] = MODULATE; \n\ - ColorArg1[1] = CURRENT; \n\ - ColorArg2[1] = TEXTURE; \n\ - // Alpha stage 0 unused \n\ - AlphaOp[0] = SELECTARG1; \n\ - AlphaArg1[0] = TFACTOR; \n\ - AlphaOp[1] = SELECTARG1; // for alpha test \n\ - AlphaArg1[1] = TEXTURE; \n\ - } \n\ - pass p1 \n\ - { \n\ - FogColor = 0x00000000; // don't accumulate fog several times\n\ - Lighting = false; \n\ - AlphaBlendEnable = true; \n\ - SrcBlend = one; \n\ - DestBlend = one; \n\ - Texture[0] = ; \n\ - TextureFactor = ; \n\ - ColorOp[0] = MODULATE; \n\ - } \n\ -} \n\ - \n\ -"; - -static const char *Lightmap2blendFx = -" \n\ -texture texture0; \n\ -texture texture1; \n\ -texture texture2; \n\ -// Color0 is the Ambient Added to the lightmap (for Lightmap 8 bit compression)\n\ -// Other colors are the lightmap Factors for each lightmap \n\ -dword color0; \n\ -dword color1; \n\ -dword color2; \n\ -float4 factor0; \n\ -float4 factor1; \n\ -float4 factor2; \n\ - \n\ -float4 g_black = { 0.0f, 0.0f, 0.0f, 1.0f }; \n\ -float4 g_dyn_factor = { 1.0f, 1.0f, 1.0f, 1.0f }; \n\ - \n\ - \n\ -// **** 3 stages technique \n\ -pixelshader three_stages_ps = asm \n\ -{ \n\ - ps_1_1; \n\ - tex t0; \n\ - tex t1; \n\ - tex t2; \n\ - // multiply lightmap with factor, and add with LMCAmbient+DynamicLight term\n\ - mad r0.xyz, c1, t1, v0; \n\ - mad r0.xyz, c2, t2, r0; \n\ - mul r0.xyz, r0, t0; \n\ - +mov r0.w, t0; \n\ -}; \n\ - \n\ -technique three_stages_3 \n\ -{ \n\ - pass p0 \n\ - { \n\ - TexCoordIndex[2] = 1; \n\ - \n\ - // Use Emissive For LMCAmbient, and diffuse for per vertex dynamic lighting\n\ - Lighting = true; \n\ - MaterialEmissive= ; \n\ - MaterialAmbient= ; \n\ - MaterialDiffuse= ; \n\ - MaterialSpecular= ; \n\ - AlphaBlendEnable = true; \n\ - SrcBlend = srcalpha; \n\ - DestBlend = invsrcalpha; \n\ - \n\ - Texture[0] = ; \n\ - Texture[1] = ; \n\ - Texture[2] = ; \n\ - PixelShaderConstant[1] = ; \n\ - PixelShaderConstant[2] = ; \n\ - PixelShader = (three_stages_ps); \n\ - } \n\ -} \n\ - \n\ -// **** 2 stages, no pixel shader technique \n\ -technique two_stages_2 \n\ -{ \n\ - pass p0 \n\ - { \n\ - // Use Emissive For LMCAmbient, and diffuse for per vertex dynamic lighting\n\ - Lighting = true; \n\ - MaterialEmissive= ; \n\ - MaterialAmbient= ; \n\ - MaterialDiffuse= ; \n\ - MaterialSpecular= ; \n\ - AlphaBlendEnable = true; \n\ - SrcBlend = srcalpha; \n\ - DestBlend = invsrcalpha; \n\ - \n\ - // the DiffuseTexture texture 0 is in last stage \n\ - TexCoordIndex[0] = 1; \n\ - TexCoordIndex[1] = 0; \n\ - Texture[0] = ; \n\ - Texture[1] = ; \n\ - TextureFactor = ; \n\ - ColorOp[0] = MULTIPLYADD; \n\ - ColorArg0[0] = DIFFUSE; \n\ - ColorArg1[0] = TFACTOR; \n\ - ColorArg2[0] = TEXTURE; \n\ - ColorOp[1] = MODULATE; \n\ - ColorArg1[1] = CURRENT; \n\ - ColorArg2[1] = TEXTURE; \n\ - // Alpha stage 0 unused \n\ - AlphaOp[0] = SELECTARG1; \n\ - AlphaArg1[0] = TFACTOR; \n\ - AlphaOp[1] = SELECTARG1; \n\ - AlphaArg1[1] = TEXTURE; \n\ - } \n\ - pass p1 \n\ - { \n\ - FogColor = 0x00000000; // don't accumulate fog several times\n\ - Lighting = false; \n\ - DestBlend = one; \n\ - Texture[0] = ; \n\ - TextureFactor = ; \n\ - ColorOp[0] = MODULATE; \n\ - } \n\ -} \n\ - \n\ - \n\ -"; - -static const char *Lightmap2blend_x2Fx = -" \n\ -texture texture0; \n\ -texture texture1; \n\ -texture texture2; \n\ -// Color0 is the Ambient Added to the lightmap (for Lightmap 8 bit compression)\n\ -// Other colors are the lightmap Factors for each lightmap \n\ -dword color0; \n\ -dword color1; \n\ -dword color2; \n\ -float4 factor0; \n\ -float4 factor1; \n\ -float4 factor2; \n\ - \n\ -float4 g_black = { 0.0f, 0.0f, 0.0f, 1.0f }; \n\ -// modulate the dyn light by 0.5, because of MODULATE2X \n\ -float4 g_dyn_factor = { 0.5f, 0.5f, 0.5f, 1.0f }; \n\ - \n\ - \n\ -// **** 3 stages technique \n\ -pixelshader three_stages_ps = asm \n\ -{ \n\ - ps_1_1; \n\ - tex t0; \n\ - tex t1; \n\ - tex t2; \n\ - // multiply lightmap with factor, and add with LMCAmbient+DynamicLight term\n\ - mad r0.xyz, c1, t1, v0; \n\ - mad r0.xyz, c2, t2, r0; \n\ - mul_x2 r0.xyz, r0, t0; \n\ - mov r0.w, t0; \n\ -}; \n\ - \n\ -technique three_stages_3 \n\ -{ \n\ - pass p0 \n\ - { \n\ - TexCoordIndex[2] = 1; \n\ - \n\ - // Use Emissive For LMCAmbient, and diffuse for per vertex dynamic lighting\n\ - Lighting = true; \n\ - MaterialEmissive= ; \n\ - MaterialAmbient= ; \n\ - MaterialDiffuse= ; \n\ - MaterialSpecular= ; \n\ - AlphaBlendEnable = true; \n\ - SrcBlend = srcalpha; \n\ - DestBlend = invsrcalpha; \n\ - \n\ - Texture[0] = ; \n\ - Texture[1] = ; \n\ - Texture[2] = ; \n\ - PixelShaderConstant[1] = ; \n\ - PixelShaderConstant[2] = ; \n\ - PixelShader = (three_stages_ps); \n\ - } \n\ -} \n\ - \n\ -// **** 2 stages, no pixel shader technique \n\ -technique two_stages_2 \n\ -{ \n\ - pass p0 \n\ - { \n\ - // Use Emissive For LMCAmbient, and diffuse for per vertex dynamic lighting\n\ - Lighting = true; \n\ - MaterialEmissive= ; \n\ - MaterialAmbient= ; \n\ - MaterialDiffuse= ; \n\ - MaterialSpecular= ; \n\ - AlphaBlendEnable = true; \n\ - SrcBlend = srcalpha; \n\ - DestBlend = invsrcalpha; \n\ - \n\ - // the DiffuseTexture texture 0 is in last stage \n\ - TexCoordIndex[0] = 1; \n\ - TexCoordIndex[1] = 0; \n\ - Texture[0] = ; \n\ - Texture[1] = ; \n\ - TextureFactor = ; \n\ - ColorOp[0] = MULTIPLYADD; \n\ - ColorArg0[0] = DIFFUSE; \n\ - ColorArg1[0] = TFACTOR; \n\ - ColorArg2[0] = TEXTURE; \n\ - ColorOp[1] = MODULATE2X; \n\ - ColorArg1[1] = CURRENT; \n\ - ColorArg2[1] = TEXTURE; \n\ - // Alpha stage 0 unused \n\ - AlphaOp[0] = SELECTARG1; \n\ - AlphaArg1[0] = TFACTOR; \n\ - AlphaOp[1] = SELECTARG1; \n\ - AlphaArg1[1] = TEXTURE; \n\ - } \n\ - pass p1 \n\ - { \n\ - FogColor = 0x00000000; // don't accumulate fog several times\n\ - Lighting = false; \n\ - DestBlend = one; \n\ - Texture[0] = ; \n\ - TextureFactor = ; \n\ - ColorOp[0] = MODULATE; \n\ - } \n\ -} \n\ - \n\ - \n\ -"; - -static const char *Lightmap2_x2Fx = -" \n\ -texture texture0; \n\ -texture texture1; \n\ -texture texture2; \n\ -// Color0 is the Ambient Added to the lightmap (for Lightmap 8 bit compression)\n\ -// Other colors are the lightmap Factors for each lightmap \n\ -dword color0; \n\ -dword color1; \n\ -dword color2; \n\ -float4 factor0; \n\ -float4 factor1; \n\ -float4 factor2; \n\ - \n\ -float4 g_black = { 0.0f, 0.0f, 0.0f, 1.0f }; \n\ -// modulate the dyn light by 0.5, because of MODULATE2X \n\ -float4 g_dyn_factor = { 0.5f, 0.5f, 0.5f, 1.0f }; \n\ - \n\ - \n\ -// **** 3 stages technique \n\ -pixelshader three_stages_ps = asm \n\ -{ \n\ - ps_1_1; \n\ - tex t0; \n\ - tex t1; \n\ - tex t2; \n\ - // multiply lightmap with factor, and add with LMCAmbient+DynamicLight term\n\ - mad r0.xyz, c1, t1, v0; \n\ - mad r0.xyz, c2, t2, r0; \n\ - mul_x2 r0.xyz, r0, t0; \n\ - +mov r0.w, t0; \n\ -}; \n\ - \n\ -technique three_stages_3 \n\ -{ \n\ - pass p0 \n\ - { \n\ - TexCoordIndex[2] = 1; \n\ - \n\ - // Use Emissive For LMCAmbient, and diffuse for per vertex dynamic lighting\n\ - Lighting = true; \n\ - MaterialEmissive= ; \n\ - MaterialAmbient= ; \n\ - MaterialDiffuse= ; \n\ - MaterialSpecular= ; \n\ - AlphaBlendEnable = false; \n\ - \n\ - Texture[0] = ; \n\ - Texture[1] = ; \n\ - Texture[2] = ; \n\ - PixelShaderConstant[1] = ; \n\ - PixelShaderConstant[2] = ; \n\ - PixelShader = (three_stages_ps); \n\ - } \n\ -} \n\ - \n\ -// **** 2 stages, no pixel shader technique \n\ -technique two_stages_2 \n\ -{ \n\ - pass p0 \n\ - { \n\ - // Use Emissive For LMCAmbient, and diffuse for per vertex dynamic lighting\n\ - Lighting = true; \n\ - MaterialEmissive= ; \n\ - MaterialAmbient= ; \n\ - MaterialDiffuse= ; \n\ - MaterialSpecular= ; \n\ - AlphaBlendEnable = false; \n\ - \n\ - // the DiffuseTexture texture 0 is in last stage \n\ - TexCoordIndex[0] = 1; \n\ - TexCoordIndex[1] = 0; \n\ - Texture[0] = ; \n\ - Texture[1] = ; \n\ - TextureFactor = ; \n\ - ColorOp[0] = MULTIPLYADD; \n\ - ColorArg0[0] = DIFFUSE; \n\ - ColorArg1[0] = TFACTOR; \n\ - ColorArg2[0] = TEXTURE; \n\ - ColorOp[1] = MODULATE2X; \n\ - ColorArg1[1] = CURRENT; \n\ - ColorArg2[1] = TEXTURE; \n\ - // Alpha stage 0 unused \n\ - AlphaOp[0] = SELECTARG1; \n\ - AlphaArg1[0] = TFACTOR; \n\ - AlphaOp[1] = SELECTARG1; // for alpha test if enabled \n\ - AlphaArg1[1] = TEXTURE; \n\ - } \n\ - pass p1 \n\ - { \n\ - FogColor = 0x00000000; // don't accumulate fog several times\n\ - Lighting = false; \n\ - AlphaBlendEnable = true; \n\ - SrcBlend = one; \n\ - DestBlend = one; \n\ - Texture[0] = ; \n\ - TextureFactor = ; \n\ - ColorOp[0] = MODULATE; \n\ - } \n\ -} \n\ - \n\ -"; - -static const char *Lightmap3Fx = -" \n\ -texture texture0; \n\ -texture texture1; \n\ -texture texture2; \n\ -texture texture3; \n\ -// Color0 is the Ambient Added to the lightmap (for Lightmap 8 bit compression)\n\ -// Other colors are the lightmap Factors for each lightmap \n\ -dword color0; \n\ -dword color1; \n\ -dword color2; \n\ -dword color3; \n\ -float4 factor0; \n\ -float4 factor1; \n\ -float4 factor2; \n\ -float4 factor3; \n\ - \n\ -float4 g_black = { 0.0f, 0.0f, 0.0f, 1.0f }; \n\ -float4 g_dyn_factor = { 1.0f, 1.0f, 1.0f, 1.0f }; \n\ - \n\ - \n\ -// **** 4 stages technique \n\ -pixelshader four_stages_ps = asm \n\ -{ \n\ - ps_1_1; \n\ - tex t0; \n\ - tex t1; \n\ - tex t2; \n\ - tex t3; \n\ - // multiply lightmap with factor, and add with LMCAmbient+DynamicLight term\n\ - mad r0.xyz, c1, t1, v0; \n\ - mad r0.xyz, c2, t2, r0; \n\ - mad r0.xyz, c3, t3, r0; \n\ - mul r0.xyz, r0, t0; \n\ - +mov r0.w, t0; \n\ -}; \n\ - \n\ -technique four_stages_4 \n\ -{ \n\ - pass p0 \n\ - { \n\ - TexCoordIndex[2] = 1; \n\ - TexCoordIndex[3] = 1; \n\ - \n\ - // Use Emissive For LMCAmbient, and diffuse for per vertex dynamic lighting\n\ - Lighting = true; \n\ - MaterialEmissive= ; \n\ - MaterialAmbient= ; \n\ - MaterialDiffuse= ; \n\ - MaterialSpecular= ; \n\ - AlphaBlendEnable = false; \n\ - \n\ - Texture[0] = ; \n\ - Texture[1] = ; \n\ - Texture[2] = ; \n\ - Texture[3] = ; \n\ - PixelShaderConstant[1] = ; \n\ - PixelShaderConstant[2] = ; \n\ - PixelShaderConstant[3] = ; \n\ - PixelShader = (four_stages_ps); \n\ - } \n\ -} \n\ - \n\ -// **** 3 stages technique \n\ -pixelshader three_stages_0_ps = asm \n\ -{ \n\ - ps_1_1; \n\ - tex t0; \n\ - tex t1; \n\ - tex t2; \n\ - // multiply lightmap with factor, and add with LMCAmbient+DynamicLight term\n\ - mad r0.xyz, c1, t1, v0; \n\ - mad r0.xyz, c2, t2, r0; \n\ - mul r0.xyz, r0, t0; \n\ - +mov r0.w, t0; \n\ -}; \n\ - \n\ -technique three_stages_3 \n\ -{ \n\ - pass p0 \n\ - { \n\ - TexCoordIndex[2] = 1; \n\ - \n\ - // Use Emissive For LMCAmbient, and diffuse for per vertex dynamic lighting\n\ - Lighting = true; \n\ - MaterialEmissive= ; \n\ - MaterialAmbient= ; \n\ - MaterialDiffuse= ; \n\ - MaterialSpecular= ; \n\ - AlphaBlendEnable = false; \n\ - \n\ - Texture[0] = ; \n\ - Texture[1] = ; \n\ - Texture[2] = ; \n\ - PixelShaderConstant[1] = ; \n\ - PixelShaderConstant[2] = ; \n\ - PixelShader = (three_stages_0_ps); \n\ - } \n\ - pass p1 \n\ - { \n\ - FogColor = 0x00000000; // don't accumulate fog several times\n\ - AlphaBlendEnable = true; \n\ - SrcBlend = one; \n\ - DestBlend = one; \n\ - Lighting = false; \n\ - \n\ - // the DiffuseTexture texture 0 is in last stage \n\ - TexCoordIndex[0] = 1; \n\ - TexCoordIndex[1] = 0; \n\ - Texture[0] = ; \n\ - Texture[1] = ; \n\ - TextureFactor = ; \n\ - ColorOp[0] = MODULATE; \n\ - ColorArg1[0] = TFACTOR; \n\ - ColorArg2[0] = TEXTURE; \n\ - ColorOp[1] = MODULATE; \n\ - ColorArg1[1] = CURRENT; \n\ - ColorArg2[1] = TEXTURE; \n\ - ColorOp[2] = DISABLE; \n\ - // Alpha stage 0 unused \n\ - AlphaOp[0] = SELECTARG1; \n\ - AlphaArg1[0] = TFACTOR; \n\ - AlphaOp[1] = SELECTARG1; \n\ - AlphaArg1[1] = TEXTURE; // for case when there's alpha test \n\ - AlphaOp[2] = DISABLE; \n\ - PixelShader = NULL; \n\ - } \n\ -} \n\ - \n\ -// **** 2 stages, no pixel shader technique \n\ -technique two_stages_2 \n\ -{ \n\ - pass p0 \n\ - { \n\ - // Use Emissive For LMCAmbient, and diffuse for per vertex dynamic lighting\n\ - Lighting = true; \n\ - MaterialEmissive= ; \n\ - MaterialAmbient= ; \n\ - MaterialDiffuse= ; \n\ - MaterialSpecular= ; \n\ - AlphaBlendEnable = false; \n\ - \n\ - // the DiffuseTexture texture 0 is in last stage \n\ - TexCoordIndex[0] = 1; \n\ - TexCoordIndex[1] = 0; \n\ - Texture[0] = ; \n\ - Texture[1] = ; \n\ - TextureFactor = ; \n\ - ColorOp[0] = MULTIPLYADD; \n\ - ColorArg0[0] = DIFFUSE; \n\ - ColorArg1[0] = TFACTOR; \n\ - ColorArg2[0] = TEXTURE; \n\ - ColorOp[1] = MODULATE; \n\ - ColorArg1[1] = CURRENT; \n\ - ColorArg2[1] = TEXTURE; \n\ - // Alpha stage 0 unused \n\ - AlphaOp[0] = SELECTARG1; \n\ - AlphaArg1[0] = TFACTOR; \n\ - AlphaOp[1] = SELECTARG1; // alpha in case were alpha test is used\n\ - AlphaArg1[1] = TEXTURE; \n\ - } \n\ - pass p1 \n\ - { \n\ - FogColor = 0x00000000; // don't accumulate fog several times\n\ - Lighting = false; \n\ - AlphaBlendEnable = true; \n\ - SrcBlend = one; \n\ - DestBlend = one; \n\ - Texture[0] = ; \n\ - TextureFactor = ; \n\ - ColorOp[0] = MODULATE; \n\ - } \n\ - pass p2 \n\ - { \n\ - Texture[0] = ; \n\ - TextureFactor = ; \n\ - } \n\ -} \n\ - \n\ - \n\ - \n\ -"; - -static const char *Lightmap3blendFx = -" \n\ -texture texture0; \n\ -texture texture1; \n\ -texture texture2; \n\ -texture texture3; \n\ -// Color0 is the Ambient Added to the lightmap (for Lightmap 8 bit compression)\n\ -// Other colors are the lightmap Factors for each lightmap \n\ -dword color0; \n\ -dword color1; \n\ -dword color2; \n\ -dword color3; \n\ -float4 factor0; \n\ -float4 factor1; \n\ -float4 factor2; \n\ -float4 factor3; \n\ - \n\ -float4 g_black = { 0.0f, 0.0f, 0.0f, 1.0f }; \n\ -float4 g_dyn_factor = { 1.0f, 1.0f, 1.0f, 1.0f }; \n\ - \n\ - \n\ -// **** 4 stages technique \n\ -pixelshader four_stages_ps = asm \n\ -{ \n\ - ps_1_1; \n\ - tex t0; \n\ - tex t1; \n\ - tex t2; \n\ - tex t3; \n\ - // multiply lightmap with factor, and add with LMCAmbient+DynamicLight term\n\ - mad r0.xyz, c1, t1, v0; \n\ - mad r0.xyz, c2, t2, r0; \n\ - mad r0.xyz, c3, t3, r0; \n\ - mul r0.xyz, r0, t0; \n\ - +mov r0.w, t0; \n\ -}; \n\ - \n\ -technique four_stages_4 \n\ -{ \n\ - pass p0 \n\ - { \n\ - TexCoordIndex[2] = 1; \n\ - TexCoordIndex[3] = 1; \n\ - \n\ - // Use Emissive For LMCAmbient, and diffuse for per vertex dynamic lighting\n\ - Lighting = true; \n\ - MaterialEmissive= ; \n\ - MaterialAmbient= ; \n\ - MaterialDiffuse= ; \n\ - MaterialSpecular= ; \n\ - AlphaBlendEnable = true; \n\ - SrcBlend = srcalpha; \n\ - DestBlend = invsrcalpha; \n\ - \n\ - Texture[0] = ; \n\ - Texture[1] = ; \n\ - Texture[2] = ; \n\ - Texture[3] = ; \n\ - PixelShaderConstant[1] = ; \n\ - PixelShaderConstant[2] = ; \n\ - PixelShaderConstant[3] = ; \n\ - PixelShader = (four_stages_ps); \n\ - } \n\ -} \n\ - \n\ -// **** 3 stages technique \n\ -pixelshader three_stages_0_ps = asm \n\ -{ \n\ - ps_1_1; \n\ - tex t0; \n\ - tex t1; \n\ - tex t2; \n\ - // multiply lightmap with factor, and add with LMCAmbient+DynamicLight term\n\ - mad r0.xyz, c1, t1, v0; \n\ - mad r0.xyz, c2, t2, r0; \n\ - mul r0.xyz, r0, t0; \n\ - +mov r0.w, t0; \n\ -}; \n\ - \n\ -technique three_stages_3 \n\ -{ \n\ - pass p0 \n\ - { \n\ - TexCoordIndex[2] = 1; \n\ - \n\ - // Use Emissive For LMCAmbient, and diffuse for per vertex dynamic lighting\n\ - Lighting = true; \n\ - MaterialEmissive= ; \n\ - MaterialAmbient= ; \n\ - MaterialDiffuse= ; \n\ - MaterialSpecular= ; \n\ - AlphaBlendEnable = true; \n\ - SrcBlend = srcalpha; \n\ - DestBlend = invsrcalpha; \n\ - \n\ - Texture[0] = ; \n\ - Texture[1] = ; \n\ - Texture[2] = ; \n\ - PixelShaderConstant[1] = ; \n\ - PixelShaderConstant[2] = ; \n\ - PixelShader = (three_stages_0_ps); \n\ - } \n\ - pass p1 \n\ - { \n\ - FogColor = 0x00000000; // don't accumulate fog several times\n\ - DestBlend = one; \n\ - Lighting = false; \n\ - \n\ - // the DiffuseTexture texture 0 is in last stage \n\ - TexCoordIndex[0] = 1; \n\ - TexCoordIndex[1] = 0; \n\ - Texture[0] = ; \n\ - Texture[1] = ; \n\ - TextureFactor = ; \n\ - ColorOp[0] = MODULATE; \n\ - ColorArg1[0] = TFACTOR; \n\ - ColorArg2[0] = TEXTURE; \n\ - ColorOp[1] = MODULATE; \n\ - ColorArg1[1] = CURRENT; \n\ - ColorArg2[1] = TEXTURE; \n\ - ColorOp[2] = DISABLE; \n\ - // Alpha stage 0 unused \n\ - AlphaOp[0] = SELECTARG1; \n\ - AlphaArg1[0] = TFACTOR; \n\ - AlphaOp[1] = SELECTARG1; \n\ - AlphaArg1[1] = TEXTURE; \n\ - AlphaOp[2] = DISABLE; \n\ - PixelShader = NULL; \n\ - } \n\ -} \n\ - \n\ -// **** 2 stages, no pixel shader technique \n\ -technique two_stages_2 \n\ -{ \n\ - pass p0 \n\ - { \n\ - // Use Emissive For LMCAmbient, and diffuse for per vertex dynamic lighting\n\ - Lighting = true; \n\ - MaterialEmissive= ; \n\ - MaterialAmbient= ; \n\ - MaterialDiffuse= ; \n\ - MaterialSpecular= ; \n\ - AlphaBlendEnable = true; \n\ - SrcBlend = srcalpha; \n\ - DestBlend = invsrcalpha; \n\ - \n\ - // the DiffuseTexture texture 0 is in last stage \n\ - TexCoordIndex[0] = 1; \n\ - TexCoordIndex[1] = 0; \n\ - Texture[0] = ; \n\ - Texture[1] = ; \n\ - TextureFactor = ; \n\ - ColorOp[0] = MULTIPLYADD; \n\ - ColorArg0[0] = DIFFUSE; \n\ - ColorArg1[0] = TFACTOR; \n\ - ColorArg2[0] = TEXTURE; \n\ - ColorOp[1] = MODULATE; \n\ - ColorArg1[1] = CURRENT; \n\ - ColorArg2[1] = TEXTURE; \n\ - // Alpha stage 0 unused \n\ - AlphaOp[0] = SELECTARG1; \n\ - AlphaArg1[0] = TFACTOR; \n\ - AlphaOp[1] = SELECTARG1; \n\ - AlphaArg1[1] = TEXTURE; \n\ - } \n\ - pass p1 \n\ - { \n\ - FogColor = 0x00000000; // don't accumulate fog several times\n\ - Lighting = false; \n\ - DestBlend = one; \n\ - Texture[0] = ; \n\ - TextureFactor = ; \n\ - ColorOp[0] = MODULATE; \n\ - } \n\ - pass p2 \n\ - { \n\ - Texture[0] = ; \n\ - TextureFactor = ; \n\ - } \n\ -} \n\ - \n\ -"; - -static const char *Lightmap3blend_x2Fx = -" \n\ -texture texture0; \n\ -texture texture1; \n\ -texture texture2; \n\ -texture texture3; \n\ -// Color0 is the Ambient Added to the lightmap (for Lightmap 8 bit compression)\n\ -// Other colors are the lightmap Factors for each lightmap \n\ -dword color0; \n\ -dword color1; \n\ -dword color2; \n\ -dword color3; \n\ -float4 factor0; \n\ -float4 factor1; \n\ -float4 factor2; \n\ -float4 factor3; \n\ - \n\ -float4 g_black = { 0.0f, 0.0f, 0.0f, 1.0f }; \n\ -// modulate the dyn light by 0.5, because of MODULATE2X \n\ -float4 g_dyn_factor = { 0.5f, 0.5f, 0.5f, 1.0f }; \n\ - \n\ - \n\ -// **** 4 stages technique \n\ -pixelshader four_stages_ps = asm \n\ -{ \n\ - ps_1_1; \n\ - tex t0; \n\ - tex t1; \n\ - tex t2; \n\ - tex t3; \n\ - // multiply lightmap with factor, and add with LMCAmbient+DynamicLight term\n\ - mad r0.xyz, c1, t1, v0; \n\ - mad r0.xyz, c2, t2, r0; \n\ - mad r0.xyz, c3, t3, r0; \n\ - mul_x2 r0.xyz, r0, t0; \n\ - +mov r0.w, t0; \n\ -}; \n\ - \n\ -technique four_stages_4 \n\ -{ \n\ - pass p0 \n\ - { \n\ - TexCoordIndex[2] = 1; \n\ - TexCoordIndex[3] = 1; \n\ - \n\ - // Use Emissive For LMCAmbient, and diffuse for per vertex dynamic lighting\n\ - Lighting = true; \n\ - MaterialEmissive= ; \n\ - MaterialAmbient= ; \n\ - MaterialDiffuse= ; \n\ - MaterialSpecular= ; \n\ - AlphaBlendEnable = true; \n\ - SrcBlend = srcalpha; \n\ - DestBlend = invsrcalpha; \n\ - \n\ - Texture[0] = ; \n\ - Texture[1] = ; \n\ - Texture[2] = ; \n\ - Texture[3] = ; \n\ - PixelShaderConstant[1] = ; \n\ - PixelShaderConstant[2] = ; \n\ - PixelShaderConstant[3] = ; \n\ - PixelShader = (four_stages_ps); \n\ - } \n\ -} \n\ - \n\ -// **** 3 stages technique \n\ -pixelshader three_stages_0_ps = asm \n\ -{ \n\ - ps_1_1; \n\ - tex t0; \n\ - tex t1; \n\ - tex t2; \n\ - // multiply lightmap with factor, and add with LMCAmbient+DynamicLight term\n\ - mad r0.xyz, c1, t1, v0; \n\ - mad r0.xyz, c2, t2, r0; \n\ - mul_x2 r0.xyz, r0, t0; \n\ - +mov r0.w, t0; \n\ -}; \n\ - \n\ -technique three_stages_3 \n\ -{ \n\ - pass p0 \n\ - { \n\ - TexCoordIndex[2] = 1; \n\ - \n\ - // Use Emissive For LMCAmbient, and diffuse for per vertex dynamic lighting\n\ - Lighting = true; \n\ - MaterialEmissive= ; \n\ - MaterialAmbient= ; \n\ - MaterialDiffuse= ; \n\ - MaterialSpecular= ; \n\ - AlphaBlendEnable = true; \n\ - SrcBlend = srcalpha; \n\ - DestBlend = invsrcalpha; \n\ - \n\ - Texture[0] = ; \n\ - Texture[1] = ; \n\ - Texture[2] = ; \n\ - PixelShaderConstant[1] = ; \n\ - PixelShaderConstant[2] = ; \n\ - PixelShader = (three_stages_0_ps); \n\ - } \n\ - pass p1 \n\ - { \n\ - FogColor = 0x00000000; // don't accumulate fog several times\n\ - DestBlend = one; \n\ - Lighting = false; \n\ - \n\ - // the DiffuseTexture texture 0 is in last stage \n\ - TexCoordIndex[0] = 1; \n\ - TexCoordIndex[1] = 0; \n\ - Texture[0] = ; \n\ - Texture[1] = ; \n\ - TextureFactor = ; \n\ - ColorOp[0] = MODULATE; \n\ - ColorArg1[0] = TFACTOR; \n\ - ColorArg2[0] = TEXTURE; \n\ - ColorOp[1] = MODULATE2X; \n\ - ColorArg1[1] = CURRENT; \n\ - ColorArg2[1] = TEXTURE; \n\ - ColorOp[2] = DISABLE; \n\ - // Alpha stage 0 unused \n\ - AlphaOp[0] = SELECTARG1; \n\ - AlphaArg1[0] = TFACTOR; \n\ - AlphaOp[1] = SELECTARG1; \n\ - AlphaArg1[1] = TEXTURE; \n\ - AlphaOp[2] = DISABLE; \n\ - PixelShader = NULL; \n\ - } \n\ -} \n\ - \n\ -// **** 2 stages, no pixel shader technique \n\ -technique two_stages_2 \n\ -{ \n\ - pass p0 \n\ - { \n\ - // Use Emissive For LMCAmbient, and diffuse for per vertex dynamic lighting\n\ - Lighting = true; \n\ - MaterialEmissive= ; \n\ - MaterialAmbient= ; \n\ - MaterialDiffuse= ; \n\ - MaterialSpecular= ; \n\ - AlphaBlendEnable = true; \n\ - SrcBlend = srcalpha; \n\ - DestBlend = invsrcalpha; \n\ - \n\ - // the DiffuseTexture texture 0 is in last stage \n\ - TexCoordIndex[0] = 1; \n\ - TexCoordIndex[1] = 0; \n\ - Texture[0] = ; \n\ - Texture[1] = ; \n\ - TextureFactor = ; \n\ - ColorOp[0] = MULTIPLYADD; \n\ - ColorArg0[0] = DIFFUSE; \n\ - ColorArg1[0] = TFACTOR; \n\ - ColorArg2[0] = TEXTURE; \n\ - ColorOp[1] = MODULATE2X; \n\ - ColorArg1[1] = CURRENT; \n\ - ColorArg2[1] = TEXTURE; \n\ - // Alpha stage 0 unused \n\ - AlphaOp[0] = SELECTARG1; \n\ - AlphaArg1[0] = TFACTOR; \n\ - AlphaOp[1] = SELECTARG1; \n\ - AlphaArg1[1] = TEXTURE; \n\ - } \n\ - pass p1 \n\ - { \n\ - FogColor = 0x00000000; // don't accumulate fog several times\n\ - Lighting = false; \n\ - DestBlend = one; \n\ - Texture[0] = ; \n\ - TextureFactor = ; \n\ - ColorOp[0] = MODULATE; \n\ - } \n\ - pass p2 \n\ - { \n\ - Texture[0] = ; \n\ - TextureFactor = ; \n\ - } \n\ -} \n\ - \n\ -"; - -static const char *Lightmap3_x2Fx = -" \n\ -texture texture0; \n\ -texture texture1; \n\ -texture texture2; \n\ -texture texture3; \n\ -// Color0 is the Ambient Added to the lightmap (for Lightmap 8 bit compression)\n\ -// Other colors are the lightmap Factors for each lightmap \n\ -dword color0; \n\ -dword color1; \n\ -dword color2; \n\ -dword color3; \n\ -float4 factor0; \n\ -float4 factor1; \n\ -float4 factor2; \n\ -float4 factor3; \n\ - \n\ -float4 g_black = { 0.0f, 0.0f, 0.0f, 1.0f }; \n\ -// modulate the dyn light by 0.5, because of MODULATE2X \n\ -float4 g_dyn_factor = { 0.5f, 0.5f, 0.5f, 1.0f }; \n\ - \n\ - \n\ -// **** 4 stages technique \n\ -pixelshader four_stages_ps = asm \n\ -{ \n\ - ps_1_1; \n\ - tex t0; \n\ - tex t1; \n\ - tex t2; \n\ - tex t3; \n\ - // multiply lightmap with factor, and add with LMCAmbient+DynamicLight term\n\ - mad r0.xyz, c1, t1, v0; \n\ - mad r0.xyz, c2, t2, r0; \n\ - mad r0.xyz, c3, t3, r0; \n\ - mul_x2 r0.xyz, r0, t0; \n\ - +mov r0.w, t0; \n\ -}; \n\ - \n\ -technique four_stages_4 \n\ -{ \n\ - pass p0 \n\ - { \n\ - TexCoordIndex[2] = 1; \n\ - TexCoordIndex[3] = 1; \n\ - \n\ - // Use Emissive For LMCAmbient, and diffuse for per vertex dynamic lighting\n\ - Lighting = true; \n\ - MaterialEmissive= ; \n\ - MaterialAmbient= ; \n\ - MaterialDiffuse= ; \n\ - MaterialSpecular= ; \n\ - AlphaBlendEnable = false; \n\ - \n\ - Texture[0] = ; \n\ - Texture[1] = ; \n\ - Texture[2] = ; \n\ - Texture[3] = ; \n\ - PixelShaderConstant[1] = ; \n\ - PixelShaderConstant[2] = ; \n\ - PixelShaderConstant[3] = ; \n\ - PixelShader = (four_stages_ps); \n\ - } \n\ -} \n\ - \n\ -// **** 3 stages technique \n\ -pixelshader three_stages_0_ps = asm \n\ -{ \n\ - ps_1_1; \n\ - tex t0; \n\ - tex t1; \n\ - tex t2; \n\ - // multiply lightmap with factor, and add with LMCAmbient+DynamicLight term\n\ - mad r0.xyz, c1, t1, v0; \n\ - mad r0.xyz, c2, t2, r0; \n\ - mul_x2 r0.xyz, r0, t0; \n\ - +mov r0.w, t0; \n\ -}; \n\ - \n\ -technique three_stages_3 \n\ -{ \n\ - pass p0 \n\ - { \n\ - TexCoordIndex[2] = 1; \n\ - \n\ - // Use Emissive For LMCAmbient, and diffuse for per vertex dynamic lighting\n\ - Lighting = true; \n\ - MaterialEmissive= ; \n\ - MaterialAmbient= ; \n\ - MaterialDiffuse= ; \n\ - MaterialSpecular= ; \n\ - AlphaBlendEnable = false; \n\ - \n\ - Texture[0] = ; \n\ - Texture[1] = ; \n\ - Texture[2] = ; \n\ - PixelShaderConstant[1] = ; \n\ - PixelShaderConstant[2] = ; \n\ - PixelShader = (three_stages_0_ps); \n\ - } \n\ - pass p1 \n\ - { \n\ - FogColor = 0x00000000; // don't accumulate fog several times\n\ - AlphaBlendEnable = true; \n\ - SrcBlend = one; \n\ - DestBlend = one; \n\ - Lighting = false; \n\ - \n\ - // the DiffuseTexture texture 0 is in last stage \n\ - TexCoordIndex[0] = 1; \n\ - TexCoordIndex[1] = 0; \n\ - Texture[0] = ; \n\ - Texture[1] = ; \n\ - TextureFactor = ; \n\ - ColorOp[0] = MODULATE; \n\ - ColorArg1[0] = TFACTOR; \n\ - ColorArg2[0] = TEXTURE; \n\ - ColorOp[1] = MODULATE2X; \n\ - ColorArg1[1] = CURRENT; \n\ - ColorArg2[1] = TEXTURE; \n\ - ColorOp[2] = DISABLE; \n\ - // Alpha stage 0 unused \n\ - AlphaOp[0] = SELECTARG1; \n\ - AlphaArg1[0] = TFACTOR; \n\ - AlphaOp[1] = SELECTARG1; \n\ - AlphaArg1[1] = TEXTURE; // for case when there's alpha test \n\ - AlphaOp[2] = DISABLE; \n\ - PixelShader = NULL; \n\ - } \n\ -} \n\ - \n\ -// **** 2 stages, no pixel shader technique \n\ -technique two_stages_2 \n\ -{ \n\ - pass p0 \n\ - { \n\ - // Use Emissive For LMCAmbient, and diffuse for per vertex dynamic lighting\n\ - Lighting = true; \n\ - MaterialEmissive= ; \n\ - MaterialAmbient= ; \n\ - MaterialDiffuse= ; \n\ - MaterialSpecular= ; \n\ - AlphaBlendEnable = false; \n\ - \n\ - // the DiffuseTexture texture 0 is in last stage \n\ - TexCoordIndex[0] = 1; \n\ - TexCoordIndex[1] = 0; \n\ - Texture[0] = ; \n\ - Texture[1] = ; \n\ - TextureFactor = ; \n\ - ColorOp[0] = MULTIPLYADD; \n\ - ColorArg0[0] = DIFFUSE; \n\ - ColorArg1[0] = TFACTOR; \n\ - ColorArg2[0] = TEXTURE; \n\ - ColorOp[1] = MODULATE2X; \n\ - ColorArg1[1] = CURRENT; \n\ - ColorArg2[1] = TEXTURE; \n\ - // Alpha stage 0 unused \n\ - AlphaOp[0] = SELECTARG1; \n\ - AlphaArg1[0] = TFACTOR; \n\ - AlphaOp[1] = SELECTARG1; // alpha in case were alpha test is used\n\ - AlphaArg1[1] = TEXTURE; \n\ - } \n\ - pass p1 \n\ - { \n\ - FogColor = 0x00000000; // don't accumulate fog several times\n\ - Lighting = false; \n\ - AlphaBlendEnable = true; \n\ - SrcBlend = one; \n\ - DestBlend = one; \n\ - Texture[0] = ; \n\ - TextureFactor = ; \n\ - ColorOp[0] = MODULATE; \n\ - } \n\ - pass p2 \n\ - { \n\ - Texture[0] = ; \n\ - TextureFactor = ; \n\ - } \n\ -} \n\ - \n\ - \n\ - \n\ -"; - -static const char *Lightmap4Fx = -" \n\ -texture texture0; \n\ -texture texture1; \n\ -texture texture2; \n\ -texture texture3; \n\ -texture texture4; \n\ -// Color0 is the Ambient Added to the lightmap (for Lightmap 8 bit compression)\n\ -// Other colors are the lightmap Factors for each lightmap \n\ -dword color0; \n\ -dword color1; \n\ -dword color2; \n\ -dword color3; \n\ -dword color4; \n\ -float4 factor0; \n\ -float4 factor1; \n\ -float4 factor2; \n\ -float4 factor3; \n\ -float4 factor4; \n\ - \n\ -float4 g_black = { 0.0f, 0.0f, 0.0f, 1.0f }; \n\ -float4 g_dyn_factor = { 1.0f, 1.0f, 1.0f, 1.0f }; \n\ - \n\ - \n\ -// **** 5 stages technique \n\ -pixelshader five_stages_ps = asm \n\ -{ \n\ - ps_1_4; \n\ - texld r0, t0; \n\ - texld r1, t1; \n\ - texld r2, t2; \n\ - texld r3, t3; \n\ - texld r4, t4; \n\ - // multiply lightmap with factor, and add with LMCAmbient+DynamicLight term\n\ - mad r1.xyz, c1, r1, v0; \n\ - mad r1.xyz, c2, r2, r1; \n\ - mad r1.xyz, c3, r3, r1; \n\ - mad r1.xyz, c4, r4, r1; \n\ - mul r0.xyz, r1, r0; \n\ -}; \n\ - \n\ -technique five_stages_5 \n\ -{ \n\ - pass p0 \n\ - { \n\ - TexCoordIndex[2] = 1; \n\ - TexCoordIndex[3] = 1; \n\ - TexCoordIndex[4] = 1; \n\ - \n\ - // Use Emissive For LMCAmbient, and diffuse for per vertex dynamic lighting\n\ - Lighting = true; \n\ - MaterialEmissive= ; \n\ - MaterialAmbient= ; \n\ - MaterialDiffuse= ; \n\ - MaterialSpecular= ; \n\ - AlphaBlendEnable = false; \n\ - \n\ - Texture[0] = ; \n\ - Texture[1] = ; \n\ - Texture[2] = ; \n\ - Texture[3] = ; \n\ - Texture[4] = ; \n\ - PixelShaderConstant[1] = ; \n\ - PixelShaderConstant[2] = ; \n\ - PixelShaderConstant[3] = ; \n\ - PixelShaderConstant[4] = ; \n\ - PixelShader = (five_stages_ps); \n\ - } \n\ -} \n\ - \n\ -// **** 4 stages technique \n\ -pixelshader four_stages_ps = asm \n\ -{ \n\ - ps_1_1; \n\ - tex t0; \n\ - tex t1; \n\ - tex t2; \n\ - tex t3; \n\ - // multiply lightmap with factor, and add with LMCAmbient+DynamicLight term\n\ - mad r0.xyz, c1, t1, v0; \n\ - mad r0.xyz, c2, t2, r0; \n\ - mad r0.xyz, c3, t3, r0; \n\ - mul r0.xyz, r0, t0; \n\ - +mov r0.w, t0; \n\ -}; \n\ - \n\ -technique four_stages_4 \n\ -{ \n\ - pass p0 \n\ - { \n\ - TexCoordIndex[2] = 1; \n\ - TexCoordIndex[3] = 1; \n\ - \n\ - // Use Emissive For LMCAmbient, and diffuse for per vertex dynamic lighting\n\ - Lighting = true; \n\ - MaterialEmissive= ; \n\ - MaterialAmbient= ; \n\ - MaterialDiffuse= ; \n\ - MaterialSpecular= ; \n\ - AlphaBlendEnable = false; \n\ - \n\ - Texture[0] = ; \n\ - Texture[1] = ; \n\ - Texture[2] = ; \n\ - Texture[3] = ; \n\ - PixelShaderConstant[1] = ; \n\ - PixelShaderConstant[2] = ; \n\ - PixelShaderConstant[3] = ; \n\ - PixelShader = (four_stages_ps); \n\ - } \n\ - pass p1 \n\ - { \n\ - FogColor = 0x00000000; // don't accumulate fog several times\n\ - Lighting = false; \n\ - AlphaBlendEnable = true; \n\ - SrcBlend = one; \n\ - DestBlend = one; \n\ - \n\ - // the DiffuseTexture texture 0 is in last stage \n\ - TexCoordIndex[0] = 1; \n\ - TexCoordIndex[1] = 0; \n\ - Texture[0] = ; \n\ - Texture[1] = ; \n\ - TextureFactor = ; \n\ - ColorOp[0] = MODULATE; \n\ - ColorArg1[0] = TFACTOR; \n\ - ColorArg2[0] = TEXTURE; \n\ - ColorOp[1] = MODULATE; \n\ - ColorArg1[1] = CURRENT; \n\ - ColorArg2[1] = TEXTURE; \n\ - ColorOp[2] = DISABLE; \n\ - ColorOp[3] = DISABLE; \n\ - // Alpha stage 0 unused \n\ - AlphaOp[0] = SELECTARG1; \n\ - AlphaArg1[0] = TFACTOR; \n\ - AlphaOp[1] = SELECTARG1; \n\ - AlphaArg1[1] = TEXTURE; \n\ - AlphaOp[2] = DISABLE; \n\ - AlphaOp[3] = DISABLE; \n\ - PixelShader = NULL; \n\ - } \n\ -} \n\ - \n\ -// **** 3 stages technique \n\ -pixelshader three_stages_0_ps = asm \n\ -{ \n\ - ps_1_1; \n\ - tex t0; \n\ - tex t1; \n\ - tex t2; \n\ - // multiply lightmap with factor, and add with LMCAmbient+DynamicLight term\n\ - mad r0.xyz, c1, t1, v0; \n\ - mad r0.xyz, c2, t2, r0; \n\ - mul r0.xyz, r0, t0; \n\ - +mov r0.w, t0; \n\ -}; \n\ - \n\ -technique three_stages_3 \n\ -{ \n\ - // 2 pass with the same pixel shader \n\ - pass p0 \n\ - { \n\ - TexCoordIndex[2] = 1; \n\ - \n\ - // Use Emissive For LMCAmbient, and diffuse for per vertex dynamic lighting\n\ - Lighting = true; \n\ - MaterialEmissive= ; \n\ - MaterialAmbient= ; \n\ - MaterialDiffuse= ; \n\ - MaterialSpecular= ; \n\ - AlphaBlendEnable = false; \n\ - \n\ - Texture[0] = ; \n\ - Texture[1] = ; \n\ - Texture[2] = ; \n\ - PixelShaderConstant[1] = ; \n\ - PixelShaderConstant[2] = ; \n\ - PixelShader = (three_stages_0_ps); \n\ - } \n\ - pass p1 \n\ - { \n\ - FogColor = 0x00000000; // don't accumulate fog several times\n\ - // second pass: shut down all lighting (lmc ambient term and dynamic lighting already added in first pass)\n\ - MaterialEmissive= ; \n\ - MaterialDiffuse= ; \n\ - \n\ - AlphaBlendEnable = true; \n\ - SrcBlend = one; \n\ - DestBlend = one; \n\ - Texture[1] = ; \n\ - Texture[2] = ; \n\ - PixelShaderConstant[1] = ; \n\ - PixelShaderConstant[2] = ; \n\ - } \n\ -} \n\ - \n\ -// **** 2 stages, no pixel shader technique \n\ -technique two_stages_2 \n\ -{ \n\ - pass p0 \n\ - { \n\ - // Use Emissive For LMCAmbient, and diffuse for per vertex dynamic lighting\n\ - Lighting = true; \n\ - MaterialEmissive= ; \n\ - MaterialAmbient= ; \n\ - MaterialDiffuse= ; \n\ - MaterialSpecular= ; \n\ - AlphaBlendEnable = false; \n\ - \n\ - // the DiffuseTexture texture 0 is in last stage \n\ - TexCoordIndex[0] = 1; \n\ - TexCoordIndex[1] = 0; \n\ - Texture[0] = ; \n\ - Texture[1] = ; \n\ - TextureFactor = ; \n\ - ColorOp[0] = MULTIPLYADD; \n\ - ColorArg0[0] = DIFFUSE; \n\ - ColorArg1[0] = TFACTOR; \n\ - ColorArg2[0] = TEXTURE; \n\ - ColorOp[1] = MODULATE; \n\ - ColorArg1[1] = CURRENT; \n\ - ColorArg2[1] = TEXTURE; \n\ - // Alpha stage 0 unused \n\ - AlphaOp[0] = SELECTARG1; \n\ - AlphaArg1[0] = TFACTOR; \n\ - AlphaOp[1] = SELECTARG1; \n\ - AlphaArg1[1] = TEXTURE; \n\ - } \n\ - pass p1 \n\ - { \n\ - FogColor = 0x00000000; // don't accumulate fog several times\n\ - Lighting = false; \n\ - AlphaBlendEnable = true; \n\ - SrcBlend = one; \n\ - DestBlend = one; \n\ - Texture[0] = ; \n\ - TextureFactor = ; \n\ - ColorOp[0] = MODULATE; \n\ - } \n\ - pass p2 \n\ - { \n\ - Texture[0] = ; \n\ - TextureFactor = ; \n\ - } \n\ - pass p3 \n\ - { \n\ - Texture[0] = ; \n\ - TextureFactor = ; \n\ - } \n\ -} \n\ - \n\ - \n\ -"; - -static const char *Lightmap4blendFx = -" \n\ -texture texture0; \n\ -texture texture1; \n\ -texture texture2; \n\ -texture texture3; \n\ -texture texture4; \n\ -// Color0 is the Ambient Added to the lightmap (for Lightmap 8 bit compression)\n\ -// Other colors are the lightmap Factors for each lightmap \n\ -dword color0; \n\ -dword color1; \n\ -dword color2; \n\ -dword color3; \n\ -dword color4; \n\ -float4 factor0; \n\ -float4 factor1; \n\ -float4 factor2; \n\ -float4 factor3; \n\ -float4 factor4; \n\ - \n\ -float4 g_black = { 0.0f, 0.0f, 0.0f, 1.0f }; \n\ -float4 g_dyn_factor = { 1.0f, 1.0f, 1.0f, 1.0f }; \n\ - \n\ - \n\ -// **** 5 stages technique \n\ -pixelshader five_stages_ps = asm \n\ -{ \n\ - ps_1_4; \n\ - texld r0, t0; \n\ - texld r1, t1; \n\ - texld r2, t2; \n\ - texld r3, t3; \n\ - texld r4, t4; \n\ - // multiply lightmap with factor, and add with LMCAmbient+DynamicLight term\n\ - mad r1.xyz, c1, r1, v0; \n\ - mad r1.xyz, c2, r2, r1; \n\ - mad r1.xyz, c3, r3, r1; \n\ - mad r1.xyz, c4, r4, r1; \n\ - mul r0.xyz, r1, r0; \n\ - mov r0.w, r0; \n\ -}; \n\ - \n\ -technique five_stages_5 \n\ -{ \n\ - pass p0 \n\ - { \n\ - TexCoordIndex[2] = 1; \n\ - TexCoordIndex[3] = 1; \n\ - TexCoordIndex[4] = 1; \n\ - \n\ - // Use Emissive For LMCAmbient, and diffuse for per vertex dynamic lighting\n\ - Lighting = true; \n\ - MaterialEmissive= ; \n\ - MaterialAmbient= ; \n\ - MaterialDiffuse= ; \n\ - MaterialSpecular= ; \n\ - AlphaBlendEnable = true; \n\ - SrcBlend = srcalpha; \n\ - DestBlend = invsrcalpha; \n\ - \n\ - Texture[0] = ; \n\ - Texture[1] = ; \n\ - Texture[2] = ; \n\ - Texture[3] = ; \n\ - Texture[4] = ; \n\ - PixelShaderConstant[1] = ; \n\ - PixelShaderConstant[2] = ; \n\ - PixelShaderConstant[3] = ; \n\ - PixelShaderConstant[4] = ; \n\ - PixelShader = (five_stages_ps); \n\ - } \n\ -} \n\ - \n\ -// **** 4 stages technique \n\ -pixelshader four_stages_ps = asm \n\ -{ \n\ - ps_1_1; \n\ - tex t0; \n\ - tex t1; \n\ - tex t2; \n\ - tex t3; \n\ - // multiply lightmap with factor, and add with LMCAmbient+DynamicLight term\n\ - mad r0.xyz, c1, t1, v0; \n\ - mad r0.xyz, c2, t2, r0; \n\ - mad r0.xyz, c3, t3, r0; \n\ - mul r0.xyz, r0, t0; \n\ - mov r0.w, t0; \n\ -}; \n\ - \n\ -technique four_stages_4 \n\ -{ \n\ - pass p0 \n\ - { \n\ - TexCoordIndex[2] = 1; \n\ - TexCoordIndex[3] = 1; \n\ - \n\ - // Use Emissive For LMCAmbient, and diffuse for per vertex dynamic lighting\n\ - Lighting = true; \n\ - MaterialEmissive= ; \n\ - MaterialAmbient= ; \n\ - MaterialDiffuse= ; \n\ - MaterialSpecular= ; \n\ - AlphaBlendEnable = true; \n\ - SrcBlend = srcalpha; \n\ - DestBlend = invsrcalpha; \n\ - \n\ - Texture[0] = ; \n\ - Texture[1] = ; \n\ - Texture[2] = ; \n\ - Texture[3] = ; \n\ - PixelShaderConstant[1] = ; \n\ - PixelShaderConstant[2] = ; \n\ - PixelShaderConstant[3] = ; \n\ - PixelShader = (four_stages_ps); \n\ - } \n\ - pass p1 \n\ - { \n\ - FogColor = 0x00000000; // don't accumulate fog several times\n\ - Lighting = false; \n\ - DestBlend = one; \n\ - \n\ - // the DiffuseTexture texture 0 is in last stage \n\ - TexCoordIndex[0] = 1; \n\ - TexCoordIndex[1] = 0; \n\ - Texture[0] = ; \n\ - Texture[1] = ; \n\ - TextureFactor = ; \n\ - ColorOp[0] = MODULATE; \n\ - ColorArg1[0] = TFACTOR; \n\ - ColorArg2[0] = TEXTURE; \n\ - ColorOp[1] = MODULATE; \n\ - ColorArg1[1] = CURRENT; \n\ - ColorArg2[1] = TEXTURE; \n\ - ColorOp[2] = DISABLE; \n\ - ColorOp[3] = DISABLE; \n\ - // Alpha stage 0 unused \n\ - AlphaOp[0] = SELECTARG1; \n\ - AlphaArg1[0] = TFACTOR; \n\ - AlphaOp[1] = SELECTARG1; \n\ - AlphaArg1[1] = TEXTURE; \n\ - AlphaOp[2] = DISABLE; \n\ - AlphaOp[3] = DISABLE; \n\ - PixelShader = NULL; \n\ - } \n\ -} \n\ - \n\ -// **** 3 stages technique \n\ -pixelshader three_stages_0_ps = asm \n\ -{ \n\ - ps_1_1; \n\ - tex t0; \n\ - tex t1; \n\ - tex t2; \n\ - // multiply lightmap with factor, and add with LMCAmbient+DynamicLight term\n\ - mad r0.xyz, c1, t1, v0; \n\ - mad r0.xyz, c2, t2, r0; \n\ - mul r0.xyz, r0, t0; \n\ - mov r0.w, t0; \n\ -}; \n\ - \n\ -technique three_stages_3 \n\ -{ \n\ - // 2 pass with the same pixel shader \n\ - pass p0 \n\ - { \n\ - TexCoordIndex[2] = 1; \n\ - \n\ - // Use Emissive For LMCAmbient, and diffuse for per vertex dynamic lighting\n\ - Lighting = true; \n\ - MaterialEmissive= ; \n\ - MaterialAmbient= ; \n\ - MaterialDiffuse= ; \n\ - MaterialSpecular= ; \n\ - AlphaBlendEnable = true; \n\ - SrcBlend = srcalpha; \n\ - DestBlend = invsrcalpha; \n\ - \n\ - Texture[0] = ; \n\ - Texture[1] = ; \n\ - Texture[2] = ; \n\ - PixelShaderConstant[1] = ; \n\ - PixelShaderConstant[2] = ; \n\ - PixelShader = (three_stages_0_ps); \n\ - } \n\ - pass p1 \n\ - { \n\ - FogColor = 0x00000000; // don't accumulate fog several times\n\ - // second pass: shut down all lighting (lmc ambient term and dynamic lighting already added in first pass)\n\ - MaterialEmissive= ; \n\ - MaterialDiffuse= ; \n\ - \n\ - DestBlend = one; \n\ - Texture[1] = ; \n\ - Texture[2] = ; \n\ - PixelShaderConstant[1] = ; \n\ - PixelShaderConstant[2] = ; \n\ - } \n\ -} \n\ - \n\ -// **** 2 stages, no pixel shader technique \n\ -technique two_stages_2 \n\ -{ \n\ - pass p0 \n\ - { \n\ - // Use Emissive For LMCAmbient, and diffuse for per vertex dynamic lighting\n\ - Lighting = true; \n\ - MaterialEmissive= ; \n\ - MaterialAmbient= ; \n\ - MaterialDiffuse= ; \n\ - MaterialSpecular= ; \n\ - AlphaBlendEnable = true; \n\ - SrcBlend = srcalpha; \n\ - DestBlend = invsrcalpha; \n\ - \n\ - // the DiffuseTexture texture 0 is in last stage \n\ - TexCoordIndex[0] = 1; \n\ - TexCoordIndex[1] = 0; \n\ - Texture[0] = ; \n\ - Texture[1] = ; \n\ - TextureFactor = ; \n\ - ColorOp[0] = MULTIPLYADD; \n\ - ColorArg0[0] = DIFFUSE; \n\ - ColorArg1[0] = TFACTOR; \n\ - ColorArg2[0] = TEXTURE; \n\ - ColorOp[1] = MODULATE; \n\ - ColorArg1[1] = CURRENT; \n\ - ColorArg2[1] = TEXTURE; \n\ - // Alpha stage 0 unused \n\ - AlphaOp[0] = SELECTARG1; \n\ - AlphaArg1[0] = TFACTOR; \n\ - AlphaOp[1] = SELECTARG1; \n\ - AlphaArg1[1] = TEXTURE; \n\ - } \n\ - pass p1 \n\ - { \n\ - FogColor = 0x00000000; // don't accumulate fog several times\n\ - Lighting = false; \n\ - DestBlend = one; \n\ - Texture[0] = ; \n\ - TextureFactor = ; \n\ - ColorOp[0] = MODULATE; \n\ - } \n\ - pass p2 \n\ - { \n\ - Texture[0] = ; \n\ - TextureFactor = ; \n\ - } \n\ - pass p3 \n\ - { \n\ - Texture[0] = ; \n\ - TextureFactor = ; \n\ - } \n\ -} \n\ - \n\ - \n\ - \n\ -"; - -static const char *Lightmap4blend_x2Fx = -" \n\ -texture texture0; \n\ -texture texture1; \n\ -texture texture2; \n\ -texture texture3; \n\ -texture texture4; \n\ -// Color0 is the Ambient Added to the lightmap (for Lightmap 8 bit compression)\n\ -// Other colors are the lightmap Factors for each lightmap \n\ -dword color0; \n\ -dword color1; \n\ -dword color2; \n\ -dword color3; \n\ -dword color4; \n\ -float4 factor0; \n\ -float4 factor1; \n\ -float4 factor2; \n\ -float4 factor3; \n\ -float4 factor4; \n\ - \n\ -float4 g_black = { 0.0f, 0.0f, 0.0f, 1.0f }; \n\ -// modulate the dyn light by 0.5, because of MODULATE2X \n\ -float4 g_dyn_factor = { 0.5f, 0.5f, 0.5f, 1.0f }; \n\ - \n\ - \n\ -// **** 5 stages technique \n\ -pixelshader five_stages_ps = asm \n\ -{ \n\ - ps_1_4; \n\ - texld r0, t0; \n\ - texld r1, t1; \n\ - texld r2, t2; \n\ - texld r3, t3; \n\ - texld r4, t4; \n\ - // multiply lightmap with factor, and add with LMCAmbient+DynamicLight term\n\ - mad r1.xyz, c1, r1, v0; \n\ - mad r1.xyz, c2, r2, r1; \n\ - mad r1.xyz, c3, r3, r1; \n\ - mad r1.xyz, c4, r4, r1; \n\ - mul_x2 r0.xyz, r1, r0; \n\ -}; \n\ - \n\ -technique five_stages_5 \n\ -{ \n\ - pass p0 \n\ - { \n\ - TexCoordIndex[2] = 1; \n\ - TexCoordIndex[3] = 1; \n\ - TexCoordIndex[4] = 1; \n\ - \n\ - // Use Emissive For LMCAmbient, and diffuse for per vertex dynamic lighting\n\ - Lighting = true; \n\ - MaterialEmissive= ; \n\ - MaterialAmbient= ; \n\ - MaterialDiffuse= ; \n\ - MaterialSpecular= ; \n\ - AlphaBlendEnable = true; \n\ - SrcBlend = srcalpha; \n\ - DestBlend = invsrcalpha; \n\ - \n\ - Texture[0] = ; \n\ - Texture[1] = ; \n\ - Texture[2] = ; \n\ - Texture[3] = ; \n\ - Texture[4] = ; \n\ - PixelShaderConstant[1] = ; \n\ - PixelShaderConstant[2] = ; \n\ - PixelShaderConstant[3] = ; \n\ - PixelShaderConstant[4] = ; \n\ - PixelShader = (five_stages_ps); \n\ - } \n\ -} \n\ - \n\ -// **** 4 stages technique \n\ -pixelshader four_stages_ps = asm \n\ -{ \n\ - ps_1_1; \n\ - tex t0; \n\ - tex t1; \n\ - tex t2; \n\ - tex t3; \n\ - // multiply lightmap with factor, and add with LMCAmbient+DynamicLight term\n\ - mad r0.xyz, c1, t1, v0; \n\ - mad r0.xyz, c2, t2, r0; \n\ - mad r0.xyz, c3, t3, r0; \n\ - mul_x2 r0.xyz, r0, t0; \n\ - +mov r0.w, t0; \n\ -}; \n\ - \n\ -technique four_stages_4 \n\ -{ \n\ - pass p0 \n\ - { \n\ - TexCoordIndex[2] = 1; \n\ - TexCoordIndex[3] = 1; \n\ - \n\ - // Use Emissive For LMCAmbient, and diffuse for per vertex dynamic lighting\n\ - Lighting = true; \n\ - MaterialEmissive= ; \n\ - MaterialAmbient= ; \n\ - MaterialDiffuse= ; \n\ - MaterialSpecular= ; \n\ - AlphaBlendEnable = true; \n\ - SrcBlend = srcalpha; \n\ - DestBlend = invsrcalpha; \n\ - \n\ - Texture[0] = ; \n\ - Texture[1] = ; \n\ - Texture[2] = ; \n\ - Texture[3] = ; \n\ - PixelShaderConstant[1] = ; \n\ - PixelShaderConstant[2] = ; \n\ - PixelShaderConstant[3] = ; \n\ - PixelShader = (four_stages_ps); \n\ - } \n\ - pass p1 \n\ - { \n\ - FogColor = 0x00000000; // don't accumulate fog several times\n\ - Lighting = false; \n\ - DestBlend = one; \n\ - \n\ - // the DiffuseTexture texture 0 is in last stage \n\ - TexCoordIndex[0] = 1; \n\ - TexCoordIndex[1] = 0; \n\ - Texture[0] = ; \n\ - Texture[1] = ; \n\ - TextureFactor = ; \n\ - ColorOp[0] = MODULATE; \n\ - ColorArg1[0] = TFACTOR; \n\ - ColorArg2[0] = TEXTURE; \n\ - ColorOp[1] = MODULATE2X; \n\ - ColorArg1[1] = CURRENT; \n\ - ColorArg2[1] = TEXTURE; \n\ - ColorOp[2] = DISABLE; \n\ - ColorOp[3] = DISABLE; \n\ - // Alpha stage 0 unused \n\ - AlphaOp[0] = SELECTARG1; \n\ - AlphaArg1[0] = TFACTOR; \n\ - AlphaOp[1] = SELECTARG1; \n\ - AlphaArg1[1] = TEXTURE; \n\ - AlphaOp[2] = DISABLE; \n\ - AlphaOp[3] = DISABLE; \n\ - PixelShader = NULL; \n\ - } \n\ -} \n\ - \n\ -// **** 3 stages technique \n\ -pixelshader three_stages_0_ps = asm \n\ -{ \n\ - ps_1_1; \n\ - tex t0; \n\ - tex t1; \n\ - tex t2; \n\ - // multiply lightmap with factor, and add with LMCAmbient+DynamicLight term\n\ - mad r0.xyz, c1, t1, v0; \n\ - mad r0.xyz, c2, t2, r0; \n\ - mul_x2 r0.xyz, r0, t0; \n\ - +mov r0.w, t0; \n\ -}; \n\ - \n\ -technique three_stages_3 \n\ -{ \n\ - // 2 pass with the same pixel shader \n\ - pass p0 \n\ - { \n\ - TexCoordIndex[2] = 1; \n\ - \n\ - // Use Emissive For LMCAmbient, and diffuse for per vertex dynamic lighting\n\ - Lighting = true; \n\ - MaterialEmissive= ; \n\ - MaterialAmbient= ; \n\ - MaterialDiffuse= ; \n\ - MaterialSpecular= ; \n\ - AlphaBlendEnable = true; \n\ - SrcBlend = srcalpha; \n\ - DestBlend = invsrcalpha; \n\ - \n\ - Texture[0] = ; \n\ - Texture[1] = ; \n\ - Texture[2] = ; \n\ - PixelShaderConstant[1] = ; \n\ - PixelShaderConstant[2] = ; \n\ - PixelShader = (three_stages_0_ps); \n\ - } \n\ - pass p1 \n\ - { \n\ - FogColor = 0x00000000; // don't accumulate fog several times\n\ - // second pass: shut down all lighting (lmc ambient term and dynamic lighting already added in first pass)\n\ - MaterialEmissive= ; \n\ - MaterialDiffuse= ; \n\ - \n\ - DestBlend = one; \n\ - Texture[1] = ; \n\ - Texture[2] = ; \n\ - PixelShaderConstant[1] = ; \n\ - PixelShaderConstant[2] = ; \n\ - } \n\ -} \n\ - \n\ -// **** 2 stages, no pixel shader technique \n\ -technique two_stages_2 \n\ -{ \n\ - pass p0 \n\ - { \n\ - // Use Emissive For LMCAmbient, and diffuse for per vertex dynamic lighting\n\ - Lighting = true; \n\ - MaterialEmissive= ; \n\ - MaterialAmbient= ; \n\ - MaterialDiffuse= ; \n\ - MaterialSpecular= ; \n\ - AlphaBlendEnable = true; \n\ - SrcBlend = srcalpha; \n\ - DestBlend = invsrcalpha; \n\ - \n\ - // the DiffuseTexture texture 0 is in last stage \n\ - TexCoordIndex[0] = 1; \n\ - TexCoordIndex[1] = 0; \n\ - Texture[0] = ; \n\ - Texture[1] = ; \n\ - TextureFactor = ; \n\ - ColorOp[0] = MULTIPLYADD; \n\ - ColorArg0[0] = DIFFUSE; \n\ - ColorArg1[0] = TFACTOR; \n\ - ColorArg2[0] = TEXTURE; \n\ - ColorOp[1] = MODULATE2X; \n\ - ColorArg1[1] = CURRENT; \n\ - ColorArg2[1] = TEXTURE; \n\ - // Alpha stage 0 unused \n\ - AlphaOp[0] = SELECTARG1; \n\ - AlphaArg1[0] = TFACTOR; \n\ - AlphaOp[1] = SELECTARG1; \n\ - AlphaArg1[1] = TEXTURE; \n\ - } \n\ - pass p1 \n\ - { \n\ - FogColor = 0x00000000; // don't accumulate fog several times\n\ - Lighting = false; \n\ - DestBlend = one; \n\ - Texture[0] = ; \n\ - TextureFactor = ; \n\ - ColorOp[0] = MODULATE; \n\ - } \n\ - pass p2 \n\ - { \n\ - Texture[0] = ; \n\ - TextureFactor = ; \n\ - } \n\ - pass p3 \n\ - { \n\ - Texture[0] = ; \n\ - TextureFactor = ; \n\ - } \n\ -} \n\ - \n\ - \n\ - \n\ -"; - -static const char *Lightmap4_x2Fx = -" \n\ -texture texture0; \n\ -texture texture1; \n\ -texture texture2; \n\ -texture texture3; \n\ -texture texture4; \n\ -// Color0 is the Ambient Added to the lightmap (for Lightmap 8 bit compression)\n\ -// Other colors are the lightmap Factors for each lightmap \n\ -dword color0; \n\ -dword color1; \n\ -dword color2; \n\ -dword color3; \n\ -dword color4; \n\ -float4 factor0; \n\ -float4 factor1; \n\ -float4 factor2; \n\ -float4 factor3; \n\ -float4 factor4; \n\ - \n\ -float4 g_black = { 0.0f, 0.0f, 0.0f, 1.0f }; \n\ -// modulate the dyn light by 0.5, because of MODULATE2X \n\ -float4 g_dyn_factor = { 0.5f, 0.5f, 0.5f, 1.0f }; \n\ - \n\ - \n\ -// **** 5 stages technique \n\ -pixelshader five_stages_ps = asm \n\ -{ \n\ - ps_1_4; \n\ - texld r0, t0; \n\ - texld r1, t1; \n\ - texld r2, t2; \n\ - texld r3, t3; \n\ - texld r4, t4; \n\ - // multiply lightmap with factor, and add with LMCAmbient+DynamicLight term\n\ - mad r1.xyz, c1, r1, v0; \n\ - mad r1.xyz, c2, r2, r1; \n\ - mad r1.xyz, c3, r3, r1; \n\ - mad r1.xyz, c4, r4, r1; \n\ - mul_x2 r0.xyz, r1, r0; \n\ -}; \n\ - \n\ -technique five_stages_5 \n\ -{ \n\ - pass p0 \n\ - { \n\ - TexCoordIndex[2] = 1; \n\ - TexCoordIndex[3] = 1; \n\ - TexCoordIndex[4] = 1; \n\ - \n\ - // Use Emissive For LMCAmbient, and diffuse for per vertex dynamic lighting\n\ - Lighting = true; \n\ - MaterialEmissive= ; \n\ - MaterialAmbient= ; \n\ - MaterialDiffuse= ; \n\ - MaterialSpecular= ; \n\ - AlphaBlendEnable = false; \n\ - \n\ - Texture[0] = ; \n\ - Texture[1] = ; \n\ - Texture[2] = ; \n\ - Texture[3] = ; \n\ - Texture[4] = ; \n\ - PixelShaderConstant[1] = ; \n\ - PixelShaderConstant[2] = ; \n\ - PixelShaderConstant[3] = ; \n\ - PixelShaderConstant[4] = ; \n\ - PixelShader = (five_stages_ps); \n\ - } \n\ -} \n\ - \n\ -// **** 4 stages technique \n\ -pixelshader four_stages_ps = asm \n\ -{ \n\ - ps_1_1; \n\ - tex t0; \n\ - tex t1; \n\ - tex t2; \n\ - tex t3; \n\ - // multiply lightmap with factor, and add with LMCAmbient+DynamicLight term\n\ - mad r0.xyz, c1, t1, v0; \n\ - mad r0.xyz, c2, t2, r0; \n\ - mad r0.xyz, c3, t3, r0; \n\ - mul_x2 r0.xyz, r0, t0; \n\ - +mov r0.w, t0; \n\ -}; \n\ - \n\ -technique four_stages_4 \n\ -{ \n\ - pass p0 \n\ - { \n\ - TexCoordIndex[2] = 1; \n\ - TexCoordIndex[3] = 1; \n\ - \n\ - // Use Emissive For LMCAmbient, and diffuse for per vertex dynamic lighting\n\ - Lighting = true; \n\ - MaterialEmissive= ; \n\ - MaterialAmbient= ; \n\ - MaterialDiffuse= ; \n\ - MaterialSpecular= ; \n\ - AlphaBlendEnable = false; \n\ - \n\ - Texture[0] = ; \n\ - Texture[1] = ; \n\ - Texture[2] = ; \n\ - Texture[3] = ; \n\ - PixelShaderConstant[1] = ; \n\ - PixelShaderConstant[2] = ; \n\ - PixelShaderConstant[3] = ; \n\ - PixelShader = (four_stages_ps); \n\ - } \n\ - pass p1 \n\ - { \n\ - FogColor = 0x00000000; // don't accumulate fog several times\n\ - Lighting = false; \n\ - AlphaBlendEnable = true; \n\ - SrcBlend = one; \n\ - DestBlend = one; \n\ - \n\ - // the DiffuseTexture texture 0 is in last stage \n\ - TexCoordIndex[0] = 1; \n\ - TexCoordIndex[1] = 0; \n\ - Texture[0] = ; \n\ - Texture[1] = ; \n\ - TextureFactor = ; \n\ - ColorOp[0] = MODULATE; \n\ - ColorArg1[0] = TFACTOR; \n\ - ColorArg2[0] = TEXTURE; \n\ - ColorOp[1] = MODULATE2X; \n\ - ColorArg1[1] = CURRENT; \n\ - ColorArg2[1] = TEXTURE; \n\ - ColorOp[2] = DISABLE; \n\ - ColorOp[3] = DISABLE; \n\ - // Alpha stage 0 unused \n\ - AlphaOp[0] = SELECTARG1; \n\ - AlphaArg1[0] = TFACTOR; \n\ - AlphaOp[1] = SELECTARG1; \n\ - AlphaArg1[1] = TEXTURE; \n\ - AlphaOp[2] = DISABLE; \n\ - AlphaOp[3] = DISABLE; \n\ - PixelShader = NULL; \n\ - } \n\ -} \n\ - \n\ -// **** 3 stages technique \n\ -pixelshader three_stages_0_ps = asm \n\ -{ \n\ - ps_1_1; \n\ - tex t0; \n\ - tex t1; \n\ - tex t2; \n\ - // multiply lightmap with factor, and add with LMCAmbient+DynamicLight term\n\ - mad r0.xyz, c1, t1, v0; \n\ - mad r0.xyz, c2, t2, r0; \n\ - mul_x2 r0.xyz, r0, t0; \n\ - +mov r0.w, t0; \n\ -}; \n\ - \n\ -technique three_stages_3 \n\ -{ \n\ - // 2 pass with the same pixel shader \n\ - pass p0 \n\ - { \n\ - TexCoordIndex[2] = 1; \n\ - \n\ - // Use Emissive For LMCAmbient, and diffuse for per vertex dynamic lighting\n\ - Lighting = true; \n\ - MaterialEmissive= ; \n\ - MaterialAmbient= ; \n\ - MaterialDiffuse= ; \n\ - MaterialSpecular= ; \n\ - AlphaBlendEnable = false; \n\ - \n\ - Texture[0] = ; \n\ - Texture[1] = ; \n\ - Texture[2] = ; \n\ - PixelShaderConstant[1] = ; \n\ - PixelShaderConstant[2] = ; \n\ - PixelShader = (three_stages_0_ps); \n\ - } \n\ - pass p1 \n\ - { \n\ - FogColor = 0x00000000; // don't accumulate fog several times\n\ - // second pass: shut down all lighting (lmc ambient term and dynamic lighting already added in first pass)\n\ - MaterialEmissive= ; \n\ - MaterialDiffuse= ; \n\ - \n\ - AlphaBlendEnable = true; \n\ - SrcBlend = one; \n\ - DestBlend = one; \n\ - Texture[1] = ; \n\ - Texture[2] = ; \n\ - PixelShaderConstant[1] = ; \n\ - PixelShaderConstant[2] = ; \n\ - } \n\ -} \n\ - \n\ -// **** 2 stages, no pixel shader technique \n\ -technique two_stages_2 \n\ -{ \n\ - pass p0 \n\ - { \n\ - // Use Emissive For LMCAmbient, and diffuse for per vertex dynamic lighting\n\ - Lighting = true; \n\ - MaterialEmissive= ; \n\ - MaterialAmbient= ; \n\ - MaterialDiffuse= ; \n\ - MaterialSpecular= ; \n\ - AlphaBlendEnable = false; \n\ - \n\ - // the DiffuseTexture texture 0 is in last stage \n\ - TexCoordIndex[0] = 1; \n\ - TexCoordIndex[1] = 0; \n\ - Texture[0] = ; \n\ - Texture[1] = ; \n\ - TextureFactor = ; \n\ - ColorOp[0] = MULTIPLYADD; \n\ - ColorArg0[0] = DIFFUSE; \n\ - ColorArg1[0] = TFACTOR; \n\ - ColorArg2[0] = TEXTURE; \n\ - ColorOp[1] = MODULATE2X; \n\ - ColorArg1[1] = CURRENT; \n\ - ColorArg2[1] = TEXTURE; \n\ - // Alpha stage 0 unused \n\ - AlphaOp[0] = SELECTARG1; \n\ - AlphaArg1[0] = TFACTOR; \n\ - AlphaOp[1] = SELECTARG1; \n\ - AlphaArg1[1] = TEXTURE; \n\ - } \n\ - pass p1 \n\ - { \n\ - FogColor = 0x00000000; // don't accumulate fog several times\n\ - Lighting = false; \n\ - AlphaBlendEnable = true; \n\ - SrcBlend = one; \n\ - DestBlend = one; \n\ - Texture[0] = ; \n\ - TextureFactor = ; \n\ - ColorOp[0] = MODULATE; \n\ - } \n\ - pass p2 \n\ - { \n\ - Texture[0] = ; \n\ - TextureFactor = ; \n\ - } \n\ - pass p3 \n\ - { \n\ - Texture[0] = ; \n\ - TextureFactor = ; \n\ - } \n\ -} \n\ - \n\ - \n\ -"; - -static const char *Water_diffuseFx = -" \n\ -texture texture0; // bumpmap0 \n\ -texture texture1; // bumpmap1 \n\ -texture texture2; // envmap \n\ -texture texture3; // diffuse \n\ - \n\ -float4 factor0; // bumpmap0 scale \n\ -float4 factor1; // bumpmap1 scale \n\ -float scalarFloat0; // bump scale for 1_1 version \n\ - \n\ -pixelshader water_diffuse_2_0 = asm \n\ -{ \n\ - ps_2_0; \n\ - dcl t0.xy; \n\ - dcl t1.xy; \n\ - dcl t2.xy; \n\ - dcl t3.xy; \n\ - dcl_2d s0; \n\ - dcl_2d s1; \n\ - dcl_2d s2; \n\ - dcl_2d s3; \n\ - //read bump map 0 \n\ - texld r0, t0, s0; \n\ - //bias result (include scaling) \n\ - mad r0.xy, r0, c0.z, c0; \n\ - add r0.xy, r0, t1; \n\ - //read bump map 1 \n\ - texld r0, r0, s1; \n\ - //bias result (include scaling) \n\ - mad r0.xy, r0, c1.z, c1; \n\ - //add envmap coord \n\ - add r0.xy, r0, t2; \n\ - // read envmap \n\ - texld r0, r0, s2; \n\ - // read diffuse \n\ - texld r1, t3, s3; \n\ - mul r0, r0, r1; \n\ - mov oC0, r0 \n\ -}; \n\ - \n\ -technique technique_water_diffuse_2_0 \n\ -{ \n\ - pass p0 \n\ - { \n\ - Texture[0] = ; \n\ - Texture[1] = ; \n\ - Texture[2] = ; \n\ - Texture[3] = ; \n\ - PixelShaderConstant[0] = ; \n\ - PixelShaderConstant[1] = ; \n\ - PixelShader = (water_diffuse_2_0); \n\ - } \n\ -}; \n\ - \n\ -pixelshader water_diffuse_1_4 = asm \n\ -{ \n\ - ps_1_4; \n\ - texld r0, t0; \n\ - texld r1, t1; \n\ - texcrd r2.xyz, t2; \n\ - mad r2.xy, r0_bx2, c0, r2; \n\ - mad r2.xy, r1_bx2, c1, r2; \n\ - phase \n\ - texld r2, r2; \n\ - texld r3, t3; \n\ - mul r0, r2, r3; \n\ -}; \n\ - \n\ -technique technique_water_diffuse_1_4 \n\ -{ \n\ - pass p0 \n\ - { \n\ - Texture[0] = ; \n\ - Texture[1] = ; \n\ - Texture[2] = ; \n\ - Texture[3] = ; \n\ - PixelShaderConstant[0] = ; \n\ - PixelShaderConstant[1] = ; \n\ - PixelShader = (water_diffuse_1_4); \n\ - } \n\ -}; \n\ - \n\ -pixelshader water_diffuse_1_1 = asm \n\ -{ \n\ - // note in OpenGL on nVidia cards, it is permitted to chain 2 texbem so the effect is less nice there (no bumpmap animation)\n\ - ps_1_1; \n\ - tex t1; \n\ - texbem t2, t1; \n\ - tex t3; \n\ - mul r0, t3, t2; \n\ -}; \n\ - \n\ -technique technique_water_diffuse_1_1 \n\ -{ \n\ - pass p0 \n\ - { \n\ - Texture[1] = ; \n\ - Texture[2] = ; \n\ - Texture[3] = ; \n\ - PixelShaderConstant[0] = ; \n\ - PixelShaderConstant[1] = ; \n\ - PixelShader = (water_diffuse_1_1); \n\ - BumpEnvMat00[2] = ; \n\ - BumpEnvMat01[0] = 0; \n\ - BumpEnvMat10[0] = 0; \n\ - BumpEnvMat11[2] = ; \n\ - } \n\ -}; \n\ - \n\ -"; - -static const char *Water_no_diffuseFx = -" \n\ -texture texture0; // bumpmap0 \n\ -texture texture1; // bumpmap1 \n\ -texture texture2; // envmap \n\ - \n\ -float4 factor0; // bumpmap0 scale \n\ -float4 factor1; // bumpmap1 scale \n\ -float scalarFloat0; // bump scale for 1_1 version \n\ - \n\ -pixelshader water_no_diffuse_2_0 = asm \n\ -{ \n\ - ps_2_0; \n\ - dcl t0.xy; \n\ - dcl t1.xy; \n\ - dcl t2.xy; \n\ - dcl_2d s0; \n\ - dcl_2d s1; \n\ - dcl_2d s2; \n\ - //read bump map 0 \n\ - texld r0, t0, s0; \n\ - //bias result (include scaling) \n\ - mad r0.xy, r0, c0.z, c0; \n\ - add r0.xy, r0, t1; \n\ - //read bump map 1 \n\ - texld r0, r0, s1; \n\ - //bias result (include scaling) \n\ - mad r0.xy, r0, c1.z, c1; \n\ - //add envmap coord \n\ - add r0.xy, r0, t2; \n\ - //read envmap \n\ - texld r0, r0, s2; \n\ - mov oC0, r0; \n\ -}; \n\ - \n\ -technique technique_water_no_diffuse_2_0 \n\ -{ \n\ - pass p0 \n\ - { \n\ - Texture[0] = ; \n\ - Texture[1] = ; \n\ - Texture[2] = ; \n\ - PixelShaderConstant[0] = ; \n\ - PixelShaderConstant[1] = ; \n\ - PixelShader = (water_no_diffuse_2_0); \n\ - } \n\ -}; \n\ - \n\ -pixelshader water_no_diffuse_1_4 = asm \n\ -{ \n\ - ps_1_4; \n\ - texld r0, t0; \n\ - texld r1, t1; \n\ - texcrd r2.xyz, t2; \n\ - mad r2.xy, r0_bx2, c0, r2; \n\ - mad r2.xy, r1_bx2, c1, r2; \n\ - phase \n\ - texld r2, r2; \n\ - mov r0, r2; \n\ -}; \n\ - \n\ -technique technique_water_no_diffuse_1_4 \n\ -{ \n\ - pass p0 \n\ - { \n\ - Texture[0] = ; \n\ - Texture[1] = ; \n\ - Texture[2] = ; \n\ - PixelShaderConstant[0] = ; \n\ - PixelShaderConstant[1] = ; \n\ - PixelShader = (water_no_diffuse_1_4); \n\ - } \n\ -}; \n\ - \n\ -pixelshader water_no_diffuse_1_1 = asm \n\ -{ \n\ - // note in OpenGL on nVidia cards, it is permitted to chain 2 texbem so the effect is less nice there (no bumpmap animation)\n\ - ps_1_1; \n\ - tex t1; \n\ - texbem t2, t1; \n\ - mov r0, t2; \n\ -}; \n\ - \n\ -technique technique_water_no_diffuse_1_1 \n\ -{ \n\ - pass p0 \n\ - { \n\ - Texture[1] = ; \n\ - Texture[2] = ; \n\ - PixelShaderConstant[0] = ; \n\ - PixelShaderConstant[1] = ; \n\ - PixelShader = (water_no_diffuse_1_1); \n\ - BumpEnvMat00[2] = ; \n\ - BumpEnvMat01[0] = 0; \n\ - BumpEnvMat10[0] = 0; \n\ - BumpEnvMat11[2] = ; \n\ - } \n\ -}; \n\ - \n\ -"; - - - -void CDriverD3D::initInternalShaders() -{ - H_AUTO_D3D(CDriverD3D_initInternalShaders) - setFx(_ShaderLightmap0,"lightmap0Fx", Lightmap0Fx); - setFx(_ShaderLightmap1,"lightmap1Fx", Lightmap1Fx); - setFx(_ShaderLightmap2,"lightmap2Fx", Lightmap2Fx); - setFx(_ShaderLightmap3,"lightmap3Fx", Lightmap3Fx); - setFx(_ShaderLightmap4,"lightmap4Fx", Lightmap4Fx); - setFx(_ShaderLightmap0Blend,"lightmap0blendFx", Lightmap0blendFx); - setFx(_ShaderLightmap1Blend,"lightmap1blendFx", Lightmap1blendFx); - setFx(_ShaderLightmap2Blend,"lightmap2blendFx", Lightmap2blendFx); - setFx(_ShaderLightmap3Blend,"lightmap3blendFx", Lightmap3blendFx); - setFx(_ShaderLightmap4Blend,"lightmap4blendFx", Lightmap4blendFx); - setFx(_ShaderLightmap0X2,"lightmap0_x2Fx", Lightmap0_x2Fx); - setFx(_ShaderLightmap1X2,"lightmap1_x2Fx", Lightmap1_x2Fx); - setFx(_ShaderLightmap2X2,"lightmap2_x2Fx", Lightmap2_x2Fx); - setFx(_ShaderLightmap3X2,"lightmap3_x2Fx", Lightmap3_x2Fx); - setFx(_ShaderLightmap4X2,"lightmap4_x2Fx", Lightmap4_x2Fx); - setFx(_ShaderLightmap0BlendX2,"lightmap0blend_x2Fx", Lightmap0blend_x2Fx); - setFx(_ShaderLightmap1BlendX2,"lightmap1blend_x2Fx", Lightmap1blend_x2Fx); - setFx(_ShaderLightmap2BlendX2,"lightmap2blend_x2Fx", Lightmap2blend_x2Fx); - setFx(_ShaderLightmap3BlendX2,"lightmap3blend_x2Fx", Lightmap3blend_x2Fx); - setFx(_ShaderLightmap4BlendX2,"lightmap4blend_x2Fx", Lightmap4blend_x2Fx); - setFx(_ShaderCloud, "cloudFx", CloudFx); - setFx(_ShaderWaterNoDiffuse,"water_no_diffuseFx", Water_no_diffuseFx); - setFx(_ShaderWaterDiffuse, "water_diffuseFx", Water_diffuseFx); -} - - -// *************************************************************************** - -void CDriverD3D::releaseInternalShaders() -{ - H_AUTO_D3D(CDriverD3D_releaseInternalShaders) - _ShaderLightmap0._DrvInfo.kill(); - _ShaderLightmap1._DrvInfo.kill(); - _ShaderLightmap2._DrvInfo.kill(); - _ShaderLightmap3._DrvInfo.kill(); - _ShaderLightmap4._DrvInfo.kill(); - _ShaderLightmap0Blend._DrvInfo.kill(); - _ShaderLightmap1Blend._DrvInfo.kill(); - _ShaderLightmap2Blend._DrvInfo.kill(); - _ShaderLightmap3Blend._DrvInfo.kill(); - _ShaderLightmap4Blend._DrvInfo.kill(); - _ShaderLightmap0X2._DrvInfo.kill(); - _ShaderLightmap1X2._DrvInfo.kill(); - _ShaderLightmap2X2._DrvInfo.kill(); - _ShaderLightmap3X2._DrvInfo.kill(); - _ShaderLightmap4X2._DrvInfo.kill(); - _ShaderLightmap0BlendX2._DrvInfo.kill(); - _ShaderLightmap1BlendX2._DrvInfo.kill(); - _ShaderLightmap2BlendX2._DrvInfo.kill(); - _ShaderLightmap3BlendX2._DrvInfo.kill(); - _ShaderLightmap4BlendX2._DrvInfo.kill(); - _ShaderCloud._DrvInfo.kill(); - _ShaderWaterNoDiffuse._DrvInfo.kill(); - _ShaderWaterDiffuse._DrvInfo.kill(); -} - -// *************************************************************************** -bool CDriverD3D::setShaderTexture (uint textureHandle, ITexture *texture, CFXCache *cache) -{ - H_AUTO_D3D(CDriverD3D_setShaderTexture ) - // Setup the texture - if (!setupTexture(*texture)) - return false; - - // Set the main texture - nlassert (_CurrentShader); - CShaderDrvInfosD3D *shaderInfo = static_cast((IShaderDrvInfos*)_CurrentShader->_DrvInfo); - nlassert (shaderInfo); - ID3DXEffect *effect = shaderInfo->Effect; - CTextureDrvInfosD3D *d3dtext = getTextureD3D (*texture); - if (texture) - { - if (cache) - { - cache->Params.setTexture(textureHandle, d3dtext->Texture); - } - else - { - effect->SetTexture (shaderInfo->TextureHandle[textureHandle], d3dtext->Texture); - } - } - - - // Add a ref on this texture - _CurrentShaderTextures.push_back (CTextureRef()); - CTextureRef &ref = _CurrentShaderTextures.back(); - ref.NeLTexture = texture; - ref.D3DTexture = d3dtext->Texture; - return true; -} - -// *************************************************************************** - -void CDriverD3D::disableHardwareTextureShader() -{ - // cannot disable pixel shader under DX, because it crashes with lightmap - // => no-op - /* - _DisableHardwarePixelShader = true; - _PixelShader = false; - */ -} - - - -// *************************************************************************** -void CDriverD3D::notifyAllShaderDrvOfLostDevice() -{ - for(TShaderDrvInfoPtrList::iterator it = _ShaderDrvInfos.begin(); it != _ShaderDrvInfos.end(); ++it) - { - nlassert(*it); - CShaderDrvInfosD3D *drvInfo = NLMISC::safe_cast(*it); - if (drvInfo->Effect) - { - nlverify(drvInfo->Effect->OnLostDevice() == D3D_OK); - } - } -} - -// *************************************************************************** -void CDriverD3D::notifyAllShaderDrvOfResetDevice() -{ - for(TShaderDrvInfoPtrList::iterator it = _ShaderDrvInfos.begin(); it != _ShaderDrvInfos.end(); ++it) - { - nlassert(*it); - CShaderDrvInfosD3D *drvInfo = NLMISC::safe_cast(*it); - if (drvInfo->Effect) - { - //nlverify( - drvInfo->Effect->OnResetDevice(); - //== D3D_OK); - } - } -} - - -// *************************************************************************** -// state records (for .fx caching) -// *************************************************************************** - -class CStateRecordLightEnable : public CStateRecord -{ -public: - DWORD Index; - BOOL Enable; -public: - CStateRecordLightEnable(DWORD index, BOOL enable) : Index(index), Enable(enable) {} - virtual void apply(class CDriverD3D &drv) - { - drv.enableLight ((uint8)Index, Enable!=FALSE); - } -}; -// -class CStateRecordLight : public CStateRecord -{ -public: - DWORD Index; - D3DLIGHT9 Light; -public: - CStateRecordLight(DWORD index, const D3DLIGHT9 *pLight) : Index(index), Light(*pLight) {} - virtual void apply(class CDriverD3D &drv) - { - drv._LightCache[Index].Light = Light; - drv.touchRenderVariable (&drv._LightCache[Index]); - } -}; -// -class CStateRecordMaterial : public CStateRecord -{ -public: - D3DMATERIAL9 Material; -public: - CStateRecordMaterial(const D3DMATERIAL9 *pMaterial) : Material(*pMaterial) {} - virtual void apply(class CDriverD3D &drv) - { - drv.setMaterialState(Material); - } -}; -// -class CStateRecordPixelShader : public CStateRecord -{ -public: - LPDIRECT3DPIXELSHADER9 PixelShader; -public: - CStateRecordPixelShader(LPDIRECT3DPIXELSHADER9 pixelShader) : PixelShader(pixelShader) {} - virtual void apply(class CDriverD3D &drv) - { - drv.setPixelShader(PixelShader); - } -}; -// -class CStateRecordPixelShaderConstantB : public CStateRecord -{ -public: - std::vector Values; - uint StartRegister; -public: - CStateRecordPixelShaderConstantB(DWORD startRegister, const BOOL *values, DWORD countVec4) : StartRegister(startRegister) - { - Values.resize(countVec4 * 4); - std::copy(values, values + countVec4 * 4, Values.begin()); - } - virtual void apply(class CDriverD3D &drv) - { - const BOOL *curr = &Values[0]; - const BOOL *last = &Values[0] + Values.size(); - uint i = StartRegister; - while (curr != last) - { - drv.setPixelShaderConstant (i, curr); - curr += 4; - ++ i; - } - } -}; -// -class CStateRecordPixelShaderConstantF : public CStateRecord -{ -public: - std::vector Values; - uint StartRegister; -public: - CStateRecordPixelShaderConstantF(DWORD startRegister, const FLOAT *values, DWORD countVec4) : StartRegister(startRegister) - { - Values.resize(countVec4 * 4); - std::copy(values, values + countVec4 * 4, Values.begin()); - } - virtual void apply(class CDriverD3D &drv) - { - const FLOAT *curr = &Values[0]; - const FLOAT *last = &Values[0] + Values.size(); - uint i = StartRegister; - while (curr != last) - { - drv.setPixelShaderConstant (i, curr); - curr += 4; - ++ i; - } - } -}; -// -class CStateRecordPixelShaderConstantI : public CStateRecord -{ -public: - std::vector Values; - uint StartRegister; -public: - CStateRecordPixelShaderConstantI(DWORD startRegister, const INT *values, DWORD countVec4) : StartRegister(startRegister) - { - Values.resize(countVec4 * 4); - std::copy(values, values + countVec4 * 4, Values.begin()); - } - virtual void apply(class CDriverD3D &drv) - { - const INT *curr = &Values[0]; - const INT *last = &Values[0] + Values.size(); - uint i = StartRegister; - while (curr != last) - { - drv.setPixelShaderConstant (i, curr); - curr += 4; - ++ i; - } - } -}; -// -class CStateRecordRenderState : public CStateRecord -{ -public: - D3DRENDERSTATETYPE State; - DWORD Value; -public: - CStateRecordRenderState(D3DRENDERSTATETYPE state, DWORD value) : State(state), Value(value) {} - virtual void apply(class CDriverD3D &drv) - { - drv.setRenderState(State, Value); - } -}; -// -class CStateRecordSamplerState : public CStateRecord -{ -public: - DWORD Sampler; - D3DSAMPLERSTATETYPE Type; - DWORD Value; -public: - CStateRecordSamplerState(DWORD sampler, D3DSAMPLERSTATETYPE type, DWORD value) : Sampler(sampler), Type(type), Value(value) {} - virtual void apply(class CDriverD3D &drv) - { - drv.setSamplerState(Sampler, Type, Value); - } -}; -// -class CStateRecordTexture : public CStateRecord -{ -public: - DWORD Stage; - CRefPtr TexRef; - LPDIRECT3DBASETEXTURE9 Texture; - BOOL IsNelTexture; -public: - CStateRecordTexture(DWORD stage, LPDIRECT3DBASETEXTURE9 texture, ITexture *nelTexture) : Stage(stage), Texture(texture) - { - nlassert(Texture); - H_AUTO_D3D(CDriverD3D_SetTexture ) - // if not a NeL texture, should add a reference on texture, else use refptr instead - IsNelTexture = nelTexture != NULL; - TexRef = nelTexture; - if (!IsNelTexture) - { - HRESULT r = Texture->AddRef(); - nlassert(r == D3D_OK); - } - } - ~CStateRecordTexture() - { - nlassert(Texture); // no default ctor, so texture should have been set - if (!IsNelTexture) - { - nlassert(TexRef == NULL); - HRESULT r = Texture->Release(); - nlassert(r == D3D_OK); - } - } - virtual void apply(class CDriverD3D &drv) - { - nlassert(Texture); - if (TexRef) - { - drv.setTexture(Stage, TexRef); - } - else - { - drv.setTexture(Stage, Texture); - } - } -}; -// -class CStateRecordTextureStageState : public CStateRecord -{ -public: - DWORD Stage; - D3DTEXTURESTAGESTATETYPE Type; - DWORD Value; -public: - CStateRecordTextureStageState(DWORD stage, D3DTEXTURESTAGESTATETYPE type, DWORD value) : Stage(stage), Type(type), Value(value) {} - virtual void apply(class CDriverD3D &drv) - { - if (Type == D3DTSS_TEXCOORDINDEX) - drv.setTextureIndexUV (Stage, Value); - else - drv.setTextureState (Stage, Type, Value); - } -}; -// -class CStateRecordTransform : public CStateRecord -{ -public: - D3DTRANSFORMSTATETYPE State; - D3DMATRIX Matrix; -public: - CStateRecordTransform(D3DTRANSFORMSTATETYPE state, const D3DMATRIX *pMatrix) : State(state), Matrix(*pMatrix) {} - virtual void apply(class CDriverD3D &drv) - { - drv.setMatrix(State, Matrix); - } -}; -// -class CStateRecordVertexShader : public CStateRecord -{ -public: - LPDIRECT3DVERTEXSHADER9 Shader; -public: - CStateRecordVertexShader(LPDIRECT3DVERTEXSHADER9 shader) : Shader(shader) {} - virtual void apply(class CDriverD3D &/* drv */) - { - nlassert(0); // not supported - //drv.setVertexProgram(Shader); - } -}; -// -class CStateRecordVertexShaderConstantB : public CStateRecord -{ -public: - std::vector Values; - uint StartRegister; -public: - CStateRecordVertexShaderConstantB(DWORD startRegister, const BOOL *values, DWORD countVec4) : StartRegister(startRegister) - { - Values.resize(countVec4 * 4); - std::copy(values, values + countVec4 * 4, Values.begin()); - } - virtual void apply(class CDriverD3D &drv) - { - const BOOL *curr = &Values[0]; - const BOOL *last = &Values[0] + Values.size(); - uint i = StartRegister; - while (curr != last) - { - drv.setVertexProgramConstant(i, curr); - curr += 4; - ++ i; - } - } -}; -class CStateRecordVertexShaderConstantF : public CStateRecord -{ -public: - std::vector Values; - uint StartRegister; -public: - CStateRecordVertexShaderConstantF(DWORD startRegister, const FLOAT *values, DWORD countVec4) : StartRegister(startRegister) - { - Values.resize(countVec4 * 4); - std::copy(values, values + countVec4 * 4, Values.begin()); - } - virtual void apply(class CDriverD3D &drv) - { - const FLOAT *curr = &Values[0]; - const FLOAT *last = &Values[0] + Values.size(); - uint i = StartRegister; - while (curr != last) - { - drv.setVertexProgramConstant(i, curr); - curr += 4; - ++ i; - } - } -}; -class CStateRecordVertexShaderConstantI : public CStateRecord -{ -public: - std::vector Values; - uint StartRegister; -public: - CStateRecordVertexShaderConstantI(DWORD startRegister, const INT *values, DWORD countVec4) : StartRegister(startRegister) - { - Values.resize(countVec4 * 4); - std::copy(values, values + countVec4 * 4, Values.begin()); - } - virtual void apply(class CDriverD3D &drv) - { - const INT *curr = &Values[0]; - const INT *last = &Values[0] + Values.size(); - uint i = StartRegister; - while (curr != last) - { - drv.setVertexProgramConstant(i, curr); - curr += 4; - ++ i; - } - } -}; - -// state recorder -HRESULT STDMETHODCALLTYPE CFXPassRecorder::QueryInterface(REFIID riid, LPVOID *ppvObj) -{ - nlassert(Driver); - return Driver->QueryInterface(riid, ppvObj); -} - -ULONG STDMETHODCALLTYPE CFXPassRecorder::AddRef(VOID) -{ - nlassert(Driver); - return Driver->AddRef(); -} - -ULONG STDMETHODCALLTYPE CFXPassRecorder::Release(VOID) -{ - nlassert(Driver); - return Driver->Release(); -} - -HRESULT STDMETHODCALLTYPE CFXPassRecorder::LightEnable(DWORD Index, BOOL Enable) -{ - nlassert(Driver); - nlassert(Target); - Target->States.push_back(new CStateRecordLightEnable(Index, Enable)); - return D3D_OK; -} - -HRESULT STDMETHODCALLTYPE CFXPassRecorder::SetFVF(DWORD /* FVF */) -{ - nlassert(0); // not managed - return D3D_OK; -} - -HRESULT STDMETHODCALLTYPE CFXPassRecorder::SetLight(DWORD Index, CONST D3DLIGHT9* pLight) -{ - nlassert(Driver); - nlassert(Target); - Target->States.push_back(new CStateRecordLight(Index, pLight)); - return D3D_OK; -} - -HRESULT STDMETHODCALLTYPE CFXPassRecorder::SetMaterial(CONST D3DMATERIAL9* pMaterial) -{ - nlassert(Driver); - nlassert(Target); - Target->States.push_back(new CStateRecordMaterial(pMaterial)); - return D3D_OK; -} - -HRESULT STDMETHODCALLTYPE CFXPassRecorder::SetNPatchMode(FLOAT /* nSegments */) -{ - nlassert(0); // not managed - return D3D_OK; -} - -HRESULT STDMETHODCALLTYPE CFXPassRecorder::SetPixelShader(LPDIRECT3DPIXELSHADER9 pShader) -{ - nlassert(Driver); - nlassert(Target); - Target->States.push_back(new CStateRecordPixelShader(pShader)); - return D3D_OK; -} - -HRESULT STDMETHODCALLTYPE CFXPassRecorder::SetPixelShaderConstantB(UINT StartRegister, CONST BOOL* pConstantData, UINT RegisterCount) -{ - nlassert(Driver); - nlassert(Target); - Target->States.push_back(new CStateRecordPixelShaderConstantB(StartRegister, pConstantData, RegisterCount)); - return D3D_OK; -} - -HRESULT STDMETHODCALLTYPE CFXPassRecorder::SetPixelShaderConstantF(UINT StartRegister, CONST FLOAT* pConstantData, UINT RegisterCount) -{ - nlassert(Driver); - nlassert(Target); - Target->States.push_back(new CStateRecordPixelShaderConstantF(StartRegister, pConstantData, RegisterCount)); - return D3D_OK; -} - -HRESULT STDMETHODCALLTYPE CFXPassRecorder::SetPixelShaderConstantI(UINT StartRegister, CONST INT* pConstantData, UINT RegisterCount) -{ - nlassert(Driver); - nlassert(Target); - Target->States.push_back(new CStateRecordPixelShaderConstantI(StartRegister, pConstantData, RegisterCount)); - return D3D_OK; -} - -HRESULT STDMETHODCALLTYPE CFXPassRecorder::SetRenderState(D3DRENDERSTATETYPE State, DWORD Value) -{ - nlassert(Driver); - nlassert(Target); - Target->States.push_back(new CStateRecordRenderState(State, Value)); - return D3D_OK; -} - -HRESULT STDMETHODCALLTYPE CFXPassRecorder::SetSamplerState(DWORD Sampler, D3DSAMPLERSTATETYPE Type, DWORD Value) -{ - nlassert(Driver); - nlassert(Target); - Target->States.push_back(new CStateRecordSamplerState(Sampler, Type, Value)); - return D3D_OK; -} - -HRESULT STDMETHODCALLTYPE CFXPassRecorder::SetTexture(DWORD Stage, LPDIRECT3DBASETEXTURE9 pTexture) -{ - nlassert(Driver); - nlassert(Target); - // Look for the current texture - uint i; - const uint count = (uint)Driver->getCurrentShaderTextures().size(); - for (i=0; igetCurrentShaderTextures()[i]; - if (ref.D3DTexture == pTexture) - { - // Set the additionnal stage set by NeL texture (D3DSAMP_ADDRESSU, D3DSAMP_ADDRESSV, D3DSAMP_MAGFILTER, D3DSAMP_MINFILTER and D3DSAMP_MIPFILTER) - Target->States.push_back(new CStateRecordTexture(Stage, pTexture, ref.NeLTexture)); - break; - } - } - if (i == count) - { - // The texture isn't a NeL texture (was created inside driver) - Target->States.push_back(new CStateRecordTexture(Stage, pTexture, NULL)); - } - return D3D_OK; -} - - -HRESULT STDMETHODCALLTYPE CFXPassRecorder::SetTextureStageState(DWORD Stage, D3DTEXTURESTAGESTATETYPE Type, DWORD Value) -{ - nlassert(Driver); - nlassert(Target); - Target->States.push_back(new CStateRecordTextureStageState(Stage, Type, Value)); - return D3D_OK; -} - -HRESULT STDMETHODCALLTYPE CFXPassRecorder::SetTransform(D3DTRANSFORMSTATETYPE State, CONST D3DMATRIX* pMatrix) -{ - nlassert(Driver); - nlassert(Target); - Target->States.push_back(new CStateRecordTransform(State, pMatrix)); - return D3D_OK; -} - -HRESULT STDMETHODCALLTYPE CFXPassRecorder::SetVertexShader(LPDIRECT3DVERTEXSHADER9 pShader) -{ - nlassert(Driver); - nlassert(Target); - Target->States.push_back(new CStateRecordVertexShader(pShader)); - return D3D_OK; -} - -HRESULT STDMETHODCALLTYPE CFXPassRecorder::SetVertexShaderConstantB(UINT StartRegister, CONST BOOL* pConstantData, UINT RegisterCount) -{ - nlassert(Driver); - nlassert(Target); - Target->States.push_back(new CStateRecordVertexShaderConstantB(StartRegister, pConstantData, RegisterCount)); - return D3D_OK; -} - -HRESULT STDMETHODCALLTYPE CFXPassRecorder::SetVertexShaderConstantF(UINT StartRegister, CONST FLOAT* pConstantData, UINT RegisterCount) -{ - nlassert(Driver); - nlassert(Target); - Target->States.push_back(new CStateRecordVertexShaderConstantF(StartRegister, pConstantData, RegisterCount)); - return D3D_OK; -} - -HRESULT STDMETHODCALLTYPE CFXPassRecorder::SetVertexShaderConstantI(UINT StartRegister, CONST INT* pConstantData, UINT RegisterCount) -{ - nlassert(Driver); - nlassert(Target); - Target->States.push_back(new CStateRecordVertexShaderConstantI(StartRegister, pConstantData, RegisterCount)); - return D3D_OK; -} - -//=================================================================================== -CFXPassRecord::~CFXPassRecord() -{ - for(std::vector::iterator it = States.begin(); it != States.end(); ++it) - { - delete *it; - } -} - -void CFXPassRecord::apply(CDriverD3D &drv) -{ - for(std::vector::iterator it = States.begin(); it != States.end(); ++it) - { - (*it)->apply(drv); - } -} - -const uint NL_D3D_NUM_RENDER_FOR_FX_CACHING = 4; - -//=================================================================================== -void CFXCache::setConstants(CShaderDrvInfosD3D *si) -{ - nlassert(si); - nlassert(si->Effect); - for(uint k = 0; k < CFXInputParams::MaxNumParams; ++k) - { - if (Params.Textures[k].Set) si->Effect->SetTexture(si->TextureHandle[k], Params.Textures[k].Value); - if (Params.Vectors[k].Set) si->Effect->SetFloatArray(si->FactorHandle[k], (CONST FLOAT *) &(Params.Vectors[k].Value), 4); - if (Params.Colors[k].Set) si->Effect->SetInt(si->ColorHandle[k], Params.Colors[k].Value); - if (Params.Floats[k].Set) si->Effect->SetFloat(si->ScalarFloatHandle[k], Params.Floats[k].Value); - } -} - -void CFXCache::begin(CShaderDrvInfosD3D *si, CDriverD3D *driver) -{ - nlassert(driver); - // amortize cost of caching for animated material -> ensure that the parameters don't change for - // a few number of display before doing caching - if (Params.Touched) - { - Steadyness = 0; - Passes.clear(); - NumPasses = 0; - Params.Touched = false; - return; - } - if (!Params.Touched) - { - ++ Steadyness; - } - if (Steadyness < NL_D3D_NUM_RENDER_FOR_FX_CACHING) - { - NumPasses = 0; - Passes.clear(); - return; - } - if (Passes.empty()) // must record shader ? - { - Passes.clear(); - UINT numPasses; - CFXPassRecorder pr; - pr.Driver = driver; - si->Effect->SetStateManager(&pr); - // Set constants - setConstants(si); - // - HRESULT r = si->Effect->Begin(&numPasses, D3DXFX_DONOTSAVESTATE|D3DXFX_DONOTSAVESHADERSTATE); - nlassert(r == D3D_OK); - Passes.resize(numPasses); - for(uint k = 0; k < numPasses; ++k) - { - pr.Target = &Passes[k]; -#if (DIRECT3D_VERSION >= 0x0900) && (D3D_SDK_VERSION >= 32) - si->Effect->BeginPass(k); - si->Effect->EndPass(); -#else - si->Effect->Pass(k); -#endif - } - r = si->Effect->End(); - nlassert(r == D3D_OK); - NumPasses = numPasses; - si->Effect->SetStateManager(driver); - } -} - -void CFXCache::applyPass(class CDriverD3D &drv, CShaderDrvInfosD3D *si, uint passIndex) -{ - if (Passes.empty() && NumPasses == 0) - { - // the shader has not been cached yet (maybe animated) - // so uses the standard path - UINT numPasses; - setConstants(si); - HRESULT r = si->Effect->Begin(&numPasses, D3DXFX_DONOTSAVESTATE|D3DXFX_DONOTSAVESHADERSTATE); - nlassert(r == D3D_OK); - NumPasses = numPasses; - } - nlassert(passIndex < NumPasses); - if (Passes.empty()) - { -#if (DIRECT3D_VERSION >= 0x0900) && (D3D_SDK_VERSION >= 32) - HRESULT r = si->Effect->BeginPass(passIndex); - si->Effect->EndPass (); -#else - HRESULT r = si->Effect->Pass(passIndex); -#endif - nlassert(r == D3D_OK); - } - else - { - Passes[passIndex].apply(drv); - } -} - -void CFXCache::end(CShaderDrvInfosD3D *si) -{ - if (Passes.empty()) - { - HRESULT r = si->Effect->End(); - nlassert(r == D3D_OK); - } -} - - -void CFXCache::reset() -{ - Params.reset(); - Passes.clear(); - Steadyness = 0; -} - - - -} // NL3D diff --git a/code/nel/src/3d/driver/direct3d/driver_direct3d_texture.cpp b/code/nel/src/3d/driver/direct3d/driver_direct3d_texture.cpp deleted file mode 100644 index a10732c64..000000000 --- a/code/nel/src/3d/driver/direct3d/driver_direct3d_texture.cpp +++ /dev/null @@ -1,1229 +0,0 @@ -// NeL - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as -// published by the Free Software Foundation, either version 3 of the -// License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -#include "stddirect3d.h" - -#include "nel/3d/vertex_buffer.h" -#include "nel/3d/light.h" -#include "nel/3d/index_buffer.h" -#include "nel/misc/rect.h" -#include "nel/3d/viewport.h" -#include "nel/3d/scissor.h" -#include "nel/3d/u_driver.h" - -#include "driver_direct3d.h" - -#ifdef DEBUG_NEW -#define new DEBUG_NEW -#endif - -using namespace std; -using namespace NLMISC; - - -namespace NL3D -{ - -std::vector CDriverD3D::_TempBuffer; - -// *************************************************************************** - -CTextureDrvInfosD3D::CTextureDrvInfosD3D(IDriver *drv, ItTexDrvInfoPtrMap it, CDriverD3D *drvD3D, bool renderTarget) - : ITextureDrvInfos(drv, it) -{ - H_AUTO_D3D(CTextureDrvInfosD3D_CTextureDrvInfosD3D) - Texture = NULL; - Texture2d = NULL; - TextureCube = NULL; - TextureMemory = 0; - RenderTarget = renderTarget; - FirstMipMap = 0; - - // Nb: at Driver dtor, all tex infos are deleted, so _Driver is always valid. - _Driver= drvD3D; - - WrapS = D3DTADDRESS_WRAP; - WrapT = D3DTADDRESS_WRAP; - MagFilter = D3DTEXF_POINT; - MinFilter = D3DTEXF_POINT; - MipFilter = D3DTEXF_NONE; -} - -// *************************************************************************** - -CTextureDrvInfosD3D::~CTextureDrvInfosD3D() -{ - H_AUTO_D3D(CTextureDrvInfosD3D_CTextureDrvInfosD3DDtor) - if (Texture) - { - // If a texture is in the cache state -> set to null (texture no more used) - for (uint32 i = 0; i < CDriverD3D::MaxTexture; ++i) - if (_Driver->_TexturePtrStateCache[i].Texture == Texture) - _Driver->setTexture(i, (LPDIRECT3DBASETEXTURE9)NULL); - - Texture->Release(); - Texture = NULL; - Texture2d = NULL; - TextureCube = NULL; - } - - // release profiling texture mem. - _Driver->_AllocatedTextureMemory -= TextureMemory; - - // release in TextureUsed. - _Driver->_TextureUsed.erase (this); -} - -// *************************************************************************** - -bool CDriverD3D::setupTexture (ITexture& tex) -{ - H_AUTO_D3D(CDriverD3D_setupTexture ) - bool nTmp; - return setupTextureEx (tex, true, nTmp, false); -} - -// *************************************************************************** - -const D3DTEXTUREADDRESS RemapTextureAdressTypeNeL2D3D[ITexture::WrapModeCount]= -{ - D3DTADDRESS_WRAP, // Repeat - D3DTADDRESS_CLAMP, // Clamp -}; - -// *************************************************************************** - -const D3DTEXTUREFILTERTYPE RemapMagTextureFilterTypeNeL2D3D[ITexture::MagFilterCount]= -{ - D3DTEXF_POINT, // Nearest - D3DTEXF_LINEAR, // Linear -}; - -// *************************************************************************** - -const D3DTEXTUREFILTERTYPE RemapMinTextureFilterTypeNeL2D3D[ITexture::MinFilterCount]= -{ - D3DTEXF_POINT, // NearestMipMapOff - D3DTEXF_POINT, // NearestMipMapNearest - D3DTEXF_POINT, // NearestMipMapLinear - D3DTEXF_LINEAR, // LinearMipMapOff - D3DTEXF_LINEAR, // LinearMipMapNearest - D3DTEXF_LINEAR, // LinearMipMapLinear -}; - -// *************************************************************************** - -const D3DTEXTUREFILTERTYPE RemapMipTextureFilterTypeNeL2D3D[ITexture::MinFilterCount]= -{ - D3DTEXF_NONE, // NearestMipMapOff - D3DTEXF_POINT, // NearestMipMapNearest - D3DTEXF_LINEAR, // NearestMipMapLinear - D3DTEXF_NONE, // LinearMipMapOff - D3DTEXF_POINT, // LinearMipMapNearest - D3DTEXF_LINEAR, // LinearMipMapLinear -}; - -// *************************************************************************** - -const D3DFORMAT RemapTextureFormatTypeNeL2D3D[CBitmap::ModeCount]= -{ - D3DFMT_A8R8G8B8, // RGBA - D3DFMT_L8, // Luminance - D3DFMT_A8, // Alpha - D3DFMT_A8L8, // AlphaLuminance - D3DFMT_DXT1, // DXTC1 - D3DFMT_DXT1, // DXTC1Alpha - D3DFMT_DXT3, // DXTC3 - D3DFMT_DXT5, // DXTC5 - D3DFMT_V8U8, // DsDt -}; - -// *************************************************************************** - -const bool RemapTextureFormatCompressedTypeNeL2D3D[CBitmap::ModeCount]= -{ - false, // RGBA - false, // Luminance - false, // Alpha - false, // AlphaLuminance - true, // DXTC1 - true, // DXTC1Alpha - true, // DXTC3 - true, // DXTC5 - false, // DsDt -}; - -// *************************************************************************** - -const D3DCUBEMAP_FACES RemapCubeFaceTypeNeL2D3D[6]= -{ - D3DCUBEMAP_FACE_POSITIVE_X, // positive_x - D3DCUBEMAP_FACE_NEGATIVE_X, // negative_x - D3DCUBEMAP_FACE_POSITIVE_Z, // positive_y - D3DCUBEMAP_FACE_NEGATIVE_Z, // negative_y - D3DCUBEMAP_FACE_POSITIVE_Y, // positive_z - D3DCUBEMAP_FACE_NEGATIVE_Y, // negative_z -}; - -// *************************************************************************** - -D3DFORMAT CDriverD3D::getD3DDestTextureFormat (ITexture& tex) -{ - H_AUTO_D3D(CDriverD3D_getD3DDestTextureFormat ) - ITexture::TUploadFormat texfmt= tex.getUploadFormat(); - - // If auto, retrieve the pixel format of the bitmap. - if(texfmt == ITexture::Auto) - { - switch(tex.getPixelFormat()) - { - case CBitmap::RGBA: - if(_ForceDXTCCompression && tex.allowDegradation() ) - texfmt= ITexture::DXTC5; - else - texfmt= ITexture::RGBA8888; - break; - case CBitmap::DXTC1: - texfmt= ITexture::DXTC1; - break; - case CBitmap::DXTC1Alpha: - texfmt= ITexture::DXTC1Alpha; - break; - case CBitmap::DXTC3: - texfmt= ITexture::DXTC3; - break; - case CBitmap::DXTC5: - texfmt= ITexture::DXTC5; - break; - case CBitmap::Luminance: - texfmt= ITexture::Luminance; - break; - case CBitmap::Alpha: - texfmt= ITexture::Alpha; - break; - case CBitmap::AlphaLuminance: - texfmt= ITexture::AlphaLuminance; - break; - case CBitmap::DsDt: - texfmt= ITexture::DsDt; - break; - default: texfmt= ITexture::RGBA8888; break; - } - } - - // Get standard prefered tex format. - nlassert (texfmt0) - { - size += (width * height * bits) >> 3; - width = max((uint)(width>>1), 1U); - height = max((uint)(height>>1), 1U); - levels--; - } - if (cube) - size *= 6; - return size; -} - -// *************************************************************************** - -bool CDriverD3D::generateD3DTexture (ITexture& tex, bool textureDegradation, D3DFORMAT &destFormat, D3DFORMAT &srcFormat, bool &cube) -{ - H_AUTO_D3D(CDriverD3D_generateD3DTexture ) - // Regenerate all the texture. - tex.generate(); - - // Is a cube texture ? - cube = tex.isTextureCube(); - - // D3D infos - CTextureDrvInfosD3D* d3dtext; - d3dtext= getTextureD3D(tex); - - // For each face - UINT width = 0; - UINT height = 0; - UINT levels = 0; - bool srcFormatCompressed = true; - bool renderTarget = false; - const uint faceCount = cube?6:1; - uint face; - uint firstMipMap = 0; - for (face=0; face(&tex)->getTexture((CTextureCube::TFace)face)):&tex; - - // getD3DTextureFormat choose a d3d dest and a src format. src format should be the tex one. - if (face==0) - { - srcFormatCompressed = RemapTextureFormatCompressedTypeNeL2D3D[texture->getPixelFormat()]; - srcFormat = RemapTextureFormatTypeNeL2D3D[texture->getPixelFormat()]; - destFormat = getD3DDestTextureFormat (*texture); - } - else - { - // All cube texture must have the same format - nlassert (srcFormatCompressed == RemapTextureFormatCompressedTypeNeL2D3D[texture->getPixelFormat()]); - nlassert (srcFormat == RemapTextureFormatTypeNeL2D3D[texture->getPixelFormat()]); - nlassert (destFormat == getD3DDestTextureFormat (*texture)); - } - - // Should not happen - nlassert (!((srcFormatCompressed) && (destFormat == D3DFMT_A8R8G8B8))); - - // Get new texture format - width = texture->getWidth(); - height = texture->getHeight(); - levels = texture->getMipMapCount(); - if (levels == 1 && !srcFormatCompressed) - { - // if not built-in mipmap levels, compute how many of them are needed - levels = texture->computeNeededMipMapCount(); - } - if (cube && !_CubbedMipMapSupported) - { - levels = 1; - } - renderTarget = texture->getRenderTarget(); - - // Texture degradation - if (_ForceTextureResizePower>0 && texture->allowDegradation() && (!srcFormatCompressed || levels>1) && textureDegradation) - { - // New size - width = max(1U, (UINT)(texture->getWidth(0) >> _ForceTextureResizePower)); - height = max(1U, (UINT)(texture->getHeight(0) >> _ForceTextureResizePower)); - levels = (levels>_ForceTextureResizePower)?levels-_ForceTextureResizePower:1; - - // Modify source texture - if (srcFormatCompressed) - { - if (cube && !_CubbedMipMapSupported) - { - // just uses one the level of interest and not the others - firstMipMap = (texture->getMipMapCount()>_ForceTextureResizePower)?_ForceTextureResizePower : texture->getMipMapCount() - 1; - levels = 1; - } - else - { - // Skip a compressed mipmap - firstMipMap = texture->getMipMapCount()-levels; - } - } - else - { - // Resample the non-compressed texture - texture->resample(width, height); - } - } - - // Generate mipmap - if (!srcFormatCompressed) - { - if (texture->mipMapOn() && levels > 1) - { - texture->buildMipMaps(); - levels= texture->getMipMapCount(); - } - else - levels= 1; - } - } - - // If compressed, width and height must be 4x4 aligned - if (srcFormatCompressed) - { - if (width & 3) - width = (width & ~3)+4; - if (height & 3) - height = (height & ~3)+4; - } - - // Got an old texture ? - if (d3dtext->Texture && - ( - (d3dtext->Width != width) || - (d3dtext->Height != height) || - (d3dtext->Levels != levels) || - (d3dtext->FirstMipMap != firstMipMap) || - (d3dtext->DestFormat != destFormat) || - (d3dtext->IsCube != cube) || - (d3dtext->RenderTarget != renderTarget) - ) - ) - { - // Delete this texture - if (d3dtext->Texture) - { - d3dtext->Texture->Release(); - d3dtext->Texture = NULL; - d3dtext->Texture2d = NULL; - d3dtext->TextureCube = NULL; - } - - // profiling: count TextureMemory usage. - _AllocatedTextureMemory -= d3dtext->TextureMemory; - d3dtext->TextureMemory = 0; - } - - // Texture must be created ? - if (d3dtext->Texture == NULL) - { - // profiling: count TextureMemory usage. - uint32 textureMemory = computeTextureMemoryUsage (width, height, levels, destFormat, cube); - - // Create the texture - bool createSuccess; - - if (cube) - { - createSuccess = _DeviceInterface->CreateCubeTexture(width, levels, renderTarget?D3DUSAGE_RENDERTARGET:0, destFormat, renderTarget?D3DPOOL_DEFAULT:D3DPOOL_MANAGED, &(d3dtext->TextureCube), NULL) == D3D_OK; - d3dtext->Texture = d3dtext->TextureCube; - } - else - { -/* - // textures with mipmaps doesn't support not power of two sizes - // only DXTC formats are beginning with a 'D' - if (supportNonPowerOfTwoTextures() && (!isPowerOf2(width) || !isPowerOf2(height)) && levels == 1) - { - // support for non-power of two sizes for textures need these lines - _DeviceInterface->SetRenderState(D3DRS_WRAP0, 0); - _DeviceInterface->SetSamplerState(0, D3DSAMP_ADDRESSU, D3DTADDRESS_CLAMP); - _DeviceInterface->SetSamplerState(0, D3DSAMP_ADDRESSV, D3DTADDRESS_CLAMP); - _DeviceInterface->SetSamplerState(0, D3DSAMP_ADDRESSW, D3DTADDRESS_CLAMP); - } -*/ - - HRESULT hr = _DeviceInterface->CreateTexture (width, height, levels, renderTarget?D3DUSAGE_RENDERTARGET:0, destFormat, renderTarget?D3DPOOL_DEFAULT:D3DPOOL_MANAGED, &(d3dtext->Texture2d), NULL); - - if (hr != D3D_OK) - { - nlwarning("CreateTexture failed with code 0x%x for texture %s in %ux%u", hr, tex.getShareName().c_str(), width, height); - } - - createSuccess = hr == D3D_OK; - d3dtext->Texture = d3dtext->Texture2d; - } - - if (!createSuccess) - return false; - - // Stats - d3dtext->TextureMemory = textureMemory; - _AllocatedTextureMemory += d3dtext->TextureMemory; - - // Copy parameters - d3dtext->Width = width; - d3dtext->Height = height; - d3dtext->Levels = uint8(levels); - d3dtext->FirstMipMap = uint8(firstMipMap); - d3dtext->DestFormat = destFormat; - d3dtext->SrcCompressed = srcFormatCompressed; - d3dtext->IsCube = cube; - } - - return true; -} - -// *************************************************************************** -inline void CDriverD3D::setupTextureWrapMode(ITexture& tex) -{ - CTextureDrvInfosD3D *d3dtext = CDriverD3D::getTextureD3D(tex); - nlassert(d3dtext); - d3dtext->WrapS = RemapTextureAdressTypeNeL2D3D[tex.getWrapS()]; - d3dtext->WrapT = RemapTextureAdressTypeNeL2D3D[tex.getWrapT()]; - d3dtext->MagFilter = RemapMagTextureFilterTypeNeL2D3D[tex.getMagFilter()]; - d3dtext->MinFilter = RemapMinTextureFilterTypeNeL2D3D[tex.getMinFilter()]; - d3dtext->MipFilter = RemapMipTextureFilterTypeNeL2D3D[tex.getMinFilter()]; - - // only enable for min filter, because it's never supported for mag filter - if (_AnisotropicFilter > 1 && tex.getMinFilter() > ITexture::NearestMipMapLinear) - { - if (tex.isTextureCube()) - { - if (_AnisotropicMinCubeSupported) d3dtext->MinFilter = D3DTEXF_ANISOTROPIC; - } - else - { - if (_AnisotropicMinSupported) d3dtext->MinFilter = D3DTEXF_ANISOTROPIC; - } - } -} - - -bool CDriverD3D::setupTextureEx (ITexture& tex, bool bUpload, bool &bAllUploaded, bool bMustRecreateSharedTexture) -{ - H_AUTO_D3D(CDriverD3D_setupTextureEx ) - bAllUploaded = false; - - - // 0. Create/Retrieve the driver texture. - //======================================= - bool mustCreate = false; - if ( !tex.TextureDrvShare ) - { - // insert into driver list. (so it is deleted when driver is deleted). - ItTexDrvSharePtrList it= _TexDrvShares.insert(_TexDrvShares.end(), (NL3D::CTextureDrvShare*)NULL); - // create and set iterator, for future deletion. - *it= tex.TextureDrvShare= new CTextureDrvShare(this, it, &tex); - - // Must (re)-create the texture. - mustCreate = true; - } - - // Does the texture has been touched ? - if ( (!tex.touched()) && (!mustCreate) ) - { - setupTextureWrapMode(tex); // update basics parameters if needed - return true; // Do not do anything - } - - - // 1. If modified, may (re)load texture part or all of the texture. - //================================================================= - - - bool mustLoadAll= false; - bool mustLoadPart= false; - - // A. Share mgt. - //============== - if(tex.supportSharing()) - { - // Try to get the shared texture. - - // Create the shared Name. - std::string name; - getTextureShareName (tex, name); - - // insert or get the texture. - { - CSynchronized::CAccessor access(&_SyncTexDrvInfos); - TTexDrvInfoPtrMap &rTexDrvInfos = access.value(); - - ItTexDrvInfoPtrMap itTex; - itTex= rTexDrvInfos.find(name); - - // texture not found? - if( itTex==rTexDrvInfos.end() ) - { - // insert into driver map. (so it is deleted when driver is deleted). - itTex= (rTexDrvInfos.insert(make_pair(name, (ITextureDrvInfos*)NULL))).first; - // create and set iterator, for future deletion. - itTex->second= tex.TextureDrvShare->DrvTexture= new CTextureDrvInfosD3D(this, itTex, this, tex.getRenderTarget()); - - // need to load ALL this texture. - mustLoadAll= true; - } - else - { - tex.TextureDrvShare->DrvTexture= itTex->second; - - if(bMustRecreateSharedTexture) - // reload this shared texture (user request) - mustLoadAll= true; - else - // Do not need to reload this texture, even if the format/mipmap has changed, since we found this - // couple in the map. - mustLoadAll= false; - } - } - // Do not test if part of texture may need to be computed, because Rect invalidation is incompatible - // with texture sharing. - } - else - { - // If texture not already created. - if(!tex.TextureDrvShare->DrvTexture) - { - // Must create it. Create auto a D3D id (in constructor). - // Do not insert into the map. This un-shared texture will be deleted at deletion of the texture. - // Inform ITextureDrvInfos by passing NULL _Driver. - tex.TextureDrvShare->DrvTexture= new CTextureDrvInfosD3D(NULL, ItTexDrvInfoPtrMap(), this, tex.getRenderTarget()); - - // need to load ALL this texture. - mustLoadAll= true; - } - else if(tex.isAllInvalidated()) - mustLoadAll= true; - else if(tex.touched()) - mustLoadPart= true; - } - - if(tex.isTextureCube() && (!_TextureCubeSupported)) - { - return true; - } - - // B. Setup texture. - //================== - if(mustLoadAll || mustLoadPart) - { - CTextureDrvInfosD3D* d3dtext; - d3dtext= getTextureD3D(tex); - - // a. Load All the texture case. - //============================== - if (mustLoadAll) - { - D3DFORMAT srcFormat; - D3DFORMAT destFormat; - bool cube; - if (generateD3DTexture (tex, true, destFormat, srcFormat, cube)) - { - if((tex.getSize()>0) || cube) - { - // Can support multi part upload ? - if ((destFormat != srcFormat) && d3dtext->SrcCompressed) - { - // No, force upload - bUpload = true; // Force all upload - } - - // Must upload the texture ? - if (bUpload && !tex.getRenderTarget()) - { - // Update the pixels - uint i; - UINT destLevel = 0; - uint blockCount = d3dtext->Height>>(d3dtext->SrcCompressed?2:0); - uint lineWidth = d3dtext->Width; - const uint srcPixelSize = getPixelFormatSize (srcFormat); - for(i=d3dtext->FirstMipMap;iFirstMipMap)+uint(d3dtext->Levels);i++, destLevel++) - { - // Size of a line - const uint blockSize = ((lineWidth*srcPixelSize)>>3)<<(d3dtext->SrcCompressed?2:0); - - // Several faces for cube texture - const uint numFaces = d3dtext->IsCube?6:1; - uint face; - for (face=0; faceIsCube?(static_cast(&tex)->getTexture((CTextureCube::TFace)face)):&tex; - if (texture) - { - // Same format ? - if (destFormat == srcFormat) - { - // Lock the surface level - D3DLOCKED_RECT rect; - bool locked = false; - if (!d3dtext->IsCube) - locked = d3dtext->Texture2d->LockRect (destLevel, &rect, NULL, 0) == D3D_OK; - else - locked = d3dtext->TextureCube->LockRect (RemapCubeFaceTypeNeL2D3D[face], destLevel, &rect, NULL, 0) == D3D_OK; - - // Rect locked ? - if (locked) - { - uint block; - for (block=0; blockgetPixels(i)[block*blockSize]); - uint8 *dest = ((uint8*)rect.pBits)+block*rect.Pitch; - if (destFormat == D3DFMT_A8R8G8B8) - copyRGBA2BGRA ((uint32*)dest, (const uint32*)src, blockSize>>2); - else - memcpy (dest, src, blockSize); - } - - // Unlock - if (!d3dtext->IsCube) - d3dtext->Texture2d->UnlockRect (destLevel); - else - d3dtext->TextureCube->UnlockRect (RemapCubeFaceTypeNeL2D3D[face], destLevel); - } - } - else - { - // Convert the surface using a D3DX method - IDirect3DSurface9 *pDestSurface; - bool surfaceOk = false; - if (!d3dtext->IsCube) - surfaceOk = d3dtext->Texture2d->GetSurfaceLevel(destLevel, &pDestSurface) == D3D_OK; - else - surfaceOk = d3dtext->TextureCube->GetCubeMapSurface(RemapCubeFaceTypeNeL2D3D[face], destLevel, &pDestSurface) == D3D_OK; - - // Surface has been retrieved ? - if (surfaceOk) - { - if (srcFormat == D3DFMT_A8R8G8B8) - { - const uint8 *src = &(texture->getPixels(i)[0]); - - // Fill the temp buffer with BGRA info - _TempBuffer.resize (blockCount*blockSize); - uint8 *dest = &(_TempBuffer[0]); - uint line; - for (line=0; linegetPixels(i)[0]), srcFormat, - blockSize, NULL, &rect, D3DX_FILTER_NONE, 0); - } - pDestSurface->Release(); - } - } - } - } - - // Next level - lineWidth = max((UINT)(lineWidth>>1), (UINT)(d3dtext->SrcCompressed?4:1)); - blockCount = max((UINT)(blockCount>>1), 1U); - } - - // Upload now - if (!d3dtext->IsCube) - d3dtext->Texture->PreLoad(); - else - d3dtext->Texture->PreLoad(); - bAllUploaded = true; - } - } - } - } - // b. Load part of the texture case. - //================================== - // Replace parts of a compressed image. Maybe don't work with the actual system of invalidateRect()... - else if (mustLoadPart && !d3dtext->SrcCompressed) - { - D3DFORMAT destFormat; - D3DFORMAT srcFormat; - bool cube; - if (CDriverD3D::generateD3DTexture (tex, false, destFormat, srcFormat, cube)) - { - // No degradation in load part - nlassert (d3dtext->FirstMipMap == 0); - - if(tex.getSize()>0 && bUpload && !tex.getRenderTarget()) - { - // For all rect, update the texture/mipmap. - //=============================================== - list::iterator itRect; - for(itRect=tex._ListInvalidRect.begin(); itRect!=tex._ListInvalidRect.end(); itRect++) - { - CRect &rect = *itRect; - sint x0= rect.X; - sint y0= rect.Y; - sint x1= rect.X+rect.Width; - sint y1= rect.Y+rect.Height; - - // Update the pixels - uint i; - UINT destLevel = 0; - for(i=d3dtext->FirstMipMap;iFirstMipMap)+uint(d3dtext->Levels);i++, destLevel++) - { - CRect rectDest; - rectDest.X = x0; - rectDest.Y = y0; - rectDest.Width = x1-x0; - rectDest.Height = y1-y0; - uploadTextureInternal (tex, rectDest, uint8(destLevel), uint8(i), destFormat, srcFormat); - - // floor . - x0= x0/2; - y0= y0/2; - // ceil. - x1= (x1+1)/2; - y1= (y1+1)/2; - } - } - } - } - } - - // Release, if wanted. - if(tex.getReleasable()) - tex.release(); - } - - setupTextureWrapMode(tex); - // The texture is correctly setuped. - tex.clearTouched(); - return true; -} - -// *************************************************************************** - -bool CDriverD3D::uploadTexture (ITexture& tex, CRect& rect, uint8 nNumMipMap) -{ - H_AUTO_D3D(CDriverD3D_uploadTexture ) - if (tex.TextureDrvShare == NULL) - return false; // Texture not created - if (tex.TextureDrvShare->DrvTexture == NULL) - return false; // Texture not created - if (tex.isTextureCube()) - return false; - - CTextureDrvInfosD3D* d3dtext = getTextureD3D(tex); - // if the texture src is in DXTC MipMaped, and mipmapskip is enabled, skip first levels the user want to upload - if(d3dtext->FirstMipMap > nNumMipMap) - return false; - - nlassert (rect.X < (sint)d3dtext->Width); - nlassert (rect.Y < (sint)d3dtext->Height); - nlassert (rect.X + rect.Width <= (sint)d3dtext->Width); - nlassert (rect.Y + rect.Height <= (sint)d3dtext->Height); - nlassert(nNumMipMap<(uint8)tex.getMipMapCount()); - - // validate rect. - sint x0 = rect.X; - sint y0 = rect.Y; - sint x1 = rect.X+rect.Width; - sint y1 = rect.Y+rect.Height; - sint w = tex.getWidth (nNumMipMap); - sint h = tex.getHeight (nNumMipMap); - clamp (x0, 0, w); - clamp (y0, 0, h); - clamp (x1, x0, w); - clamp (y1, y0, h); - rect.X = x0; - rect.Y = y0; - rect.Width = x1 - x0; - rect.Height = y1 - y0; - - // Texture format - nlassert (!tex.isTextureCube()); - D3DFORMAT srcFormat = RemapTextureFormatTypeNeL2D3D[tex.getPixelFormat()]; - D3DFORMAT destFormat = getD3DDestTextureFormat (tex); - - return uploadTextureInternal (tex, rect, nNumMipMap-d3dtext->FirstMipMap, nNumMipMap, destFormat, srcFormat); -} - -// *************************************************************************** - -bool CDriverD3D::uploadTextureInternal (ITexture& tex, CRect& rect, uint8 destMipmap, uint8 srcMipmap, - D3DFORMAT destFormat, D3DFORMAT srcFormat) -{ - H_AUTO_D3D(CDriverD3D_uploadTextureInternal) - - if (rect.Width == 0 || rect.Height == 0) - { - nlwarning("Rectangle width or height cannot be 0"); - return false; - } - - // The D3D texture - CTextureDrvInfosD3D* d3dtext = getTextureD3D(tex); - - // The pixel size - const uint pixelSize = CBitmap::bitPerPixels[tex.getPixelFormat()]; - - // The line width of that mipmap level - uint lineWidth = max(d3dtext->Width>>destMipmap, uint(d3dtext->SrcCompressed?4:1)); - - sint x0= rect.X; - sint y0= rect.Y; - sint x1= rect.X+rect.Width; - sint y1= rect.Y+rect.Height; - sint x1Copy = x1; - sint y1Copy = y1; - - if (d3dtext->SrcCompressed) - { - nlassert ((x0 & 0x3) == 0); - nlassert ((y0 & 0x3) == 0); - nlassert (((x1 & 0x3) == 0) || (x1<4)); - nlassert (((y1 & 0x3) == 0) || (y1<4)); - x1Copy = std::max(4, x1); - y1Copy = std::max(4, y1); - } - - // Size of a line - const uint lineSize = ((lineWidth*pixelSize)>>3)<<(d3dtext->SrcCompressed?2:0); - const uint offsetX = (x0*pixelSize)>>3; - - // Block of line (for compressed textures) - uint lineStart = y0; - uint lineEnd = y1Copy; - - // Pitch for compressed texture - if (d3dtext->SrcCompressed) - { - lineStart >>= 2; - lineEnd >>= 2; - } - - // Same format ? - if (destFormat == srcFormat) - { - // Lock the surface level - D3DLOCKED_RECT rect; - RECT region; - region.left = x0; - region.right = x1; - region.top = y0; - region.bottom = y1; - - - - const sint dataToCopy = (((x1Copy-x0)*pixelSize)>>3)<<(d3dtext->SrcCompressed?2:0); - if (d3dtext->Texture2d->LockRect (destMipmap, &rect, ®ion, 0) == D3D_OK) - { - uint line; - for (line=lineStart; line>2); - else - memcpy (dest, src, dataToCopy); - } - d3dtext->Texture2d->UnlockRect (destMipmap); - } - else - { - return false; - } - } - else - { - // Convert the surface using a D3DX method - IDirect3DSurface9 *pDestSurface; - - // Surface has been retrieved ? - if (d3dtext->Texture2d->GetSurfaceLevel(destMipmap, &pDestSurface) == D3D_OK) - { - RECT destRect; - destRect.top = y0; - destRect.bottom = y1; - destRect.left = x0; - destRect.right = x1; - - if (srcFormat == D3DFMT_A8R8G8B8) - { - const uint8 *src = &(tex.getPixels(srcMipmap)[0]); - - // Fill the temp buffer with BGRA info - const sint lineWidth = x1-x0; - _TempBuffer.resize (((y1-y0)*lineWidth)<<2); - uint8 *dest = &(_TempBuffer[0]); - uint line; - for (line=y0; line<(uint)y1; line++) - { - copyRGBA2BGRA ((uint32*)dest, (uint32*)(src+line*lineSize+(x0<<2)), lineWidth); - dest += lineWidth<<2; - } - - // Upload the texture part - RECT srcRect; - srcRect.top = 0; - srcRect.bottom = y1-y0; - srcRect.left = 0; - srcRect.right = lineWidth; - if (D3DXLoadSurfaceFromMemory (pDestSurface, NULL, &destRect, &(_TempBuffer[0]), srcFormat, - lineWidth<<2, NULL, &srcRect, D3DX_FILTER_NONE, 0) != D3D_OK) - return false; - } - else - { - RECT srcRect; - srcRect.top = y0; - srcRect.bottom = y1; - srcRect.left = x0; - srcRect.right = x1; - const uint8 *src = &(tex.getPixels(srcMipmap)[0]); - if (D3DXLoadSurfaceFromMemory (pDestSurface, NULL, &destRect, src, srcFormat, - lineSize, NULL, &srcRect, D3DX_FILTER_NONE, 0) != D3D_OK) - return false; - } - pDestSurface->Release(); - } - } - - return true; -} - -// *************************************************************************** - -bool CDriverD3D::isTextureExist(const ITexture&tex) -{ - H_AUTO_D3D(CDriverD3D_isTextureExist) - bool result; - - // Create the shared Name. - std::string name; - getTextureShareName (tex, name); - - { - CSynchronized::CAccessor access(&_SyncTexDrvInfos); - TTexDrvInfoPtrMap &rTexDrvInfos = access.value(); - result = (rTexDrvInfos.find(name) != rTexDrvInfos.end()); - } - return result; -} - -// *************************************************************************** - -void CDriverD3D::swapTextureHandle(ITexture &tex0, ITexture &tex1) -{ - H_AUTO_D3D(CDriverD3D_swapTextureHandle) - // ensure creation of both texture - setupTexture(tex0); - setupTexture(tex1); - - // avoid any problem, disable all textures - for(uint stage=0; stageTexture, t1->Texture); - swap(t0->Texture2d, t1->Texture2d); - swap(t0->TextureCube, t1->TextureCube); - swap(t0->DestFormat, t1->DestFormat); - swap(t0->Width, t1->Width); - swap(t0->Height, t1->Height); - swap(t0->SrcCompressed, t1->SrcCompressed); - swap(t0->IsCube, t1->IsCube); - swap(t0->Levels, t1->Levels); - swap(t0->FirstMipMap, t1->FirstMipMap); - swap(t0->TextureMemory, t1->TextureMemory); - swap(t0->WrapS, t1->WrapS); - swap(t0->WrapT, t1->WrapT); - swap(t0->MagFilter, t1->MagFilter); - swap(t0->MinFilter, t1->MinFilter); - swap(t0->MipFilter, t1->MipFilter); -} - -// *************************************************************************** - -uintptr_t CDriverD3D::getTextureHandle(const ITexture &tex) -{ - H_AUTO_D3D(CDriverD3D_getTextureHandle) - // If DrvShare not setuped - if(!tex.TextureDrvShare) - return 0; - - CTextureDrvInfosD3D *d3dtext= getTextureD3D(const_cast(tex)); - - // If DrvInfo not setuped - if(!d3dtext) - return 0; - - return (uintptr_t)(d3dtext->Texture); -} - -// *************************************************************************** - -bool CDriverD3D::setRenderTarget (ITexture *tex, uint32 /* x */, uint32 /* y */, uint32 /* width */, uint32 /* height */, uint32 mipmapLevel, uint32 cubeFace) -{ - H_AUTO_D3D(CDriverD3D_setRenderTarget ) - // Check the texture is a render target - if (tex) - nlassertex (tex->getRenderTarget(), ("The texture must be a render target. Call ITexture::setRenderTarget(true).")); - - if (tex == NULL) - { - _InvertCullMode = false; - if (_BackBuffer) - { - setRenderTarget (_BackBuffer, NULL, 0, 0); - _BackBuffer->Release(); - _BackBuffer = NULL; - } - } - else - { - _InvertCullMode = true; - if (!_BackBuffer) - { - updateRenderVariables (); - _DeviceInterface->GetRenderTarget (0, &_BackBuffer); - } - - // Alread setuped ? - if (tex->TextureDrvShare) - { - // Get texture info - CTextureDrvInfosD3D *d3dtext = getTextureD3D(*tex); - - // Renderable ? Erase and rebuild - if (!d3dtext->RenderTarget) - // Touch the texture - tex->touch(); - } - - // Setup the new texture - bool nTmp; - if (!setupTextureEx (*tex, false, nTmp, false)) - return false; - - // Get texture info - CTextureDrvInfosD3D *d3dtext = getTextureD3D(*tex); - - // Setup texture for texture rendering - IDirect3DSurface9 *pDestSurface; - bool surfaceOk = false; - if (!d3dtext->IsCube) - surfaceOk = d3dtext->Texture2d->GetSurfaceLevel(mipmapLevel, &pDestSurface) == D3D_OK; - else - surfaceOk = d3dtext->TextureCube->GetCubeMapSurface(RemapCubeFaceTypeNeL2D3D[cubeFace], mipmapLevel, &pDestSurface) == D3D_OK; - if (surfaceOk) - { - setRenderTarget (pDestSurface, tex, (uint8)mipmapLevel, (uint8)cubeFace); - pDestSurface->Release(); - } - else - return false; - } - - // Handle backside - if (!_DoubleSided) - { - if (_CullMode == CCW) - { - setRenderState (D3DRS_CULLMODE, _InvertCullMode?D3DCULL_CCW:D3DCULL_CW); - } - else - { - setRenderState (D3DRS_CULLMODE, _InvertCullMode?D3DCULL_CW:D3DCULL_CCW); - } - } - - return true; -} - -ITexture *CDriverD3D::getRenderTarget() const -{ - return _RenderTarget.Texture; -} - -// *************************************************************************** - -bool CDriverD3D::copyTargetToTexture (ITexture * /* tex */, uint32 /* offsetx */, uint32 /* offsety */, uint32 /* x */, uint32 /* y */, uint32 /* width */, - uint32 /* height */, uint32 /* mipmapLevel */) -{ - H_AUTO_D3D(CDriverD3D_copyTargetToTexture) - return false; -} - -// *************************************************************************** - -bool CDriverD3D::getRenderTargetSize (uint32 &width, uint32 &height) -{ - H_AUTO_D3D(CDriverD3D_getRenderTargetSize) - // Target is the frame buffer ? - if (_RenderTarget.Texture) - { - CTextureDrvInfosD3D* d3dtext = getTextureD3D(*_RenderTarget.Texture); - width = max ((uint32)1, (uint32)(d3dtext->Width >> (_RenderTarget.Level))); - height = max ((uint32)1, (uint32)(d3dtext->Height >> (_RenderTarget.Level))); - return true; - } - else - { - getWindowSize (width, height); - return true; - } -} - -// *************************************************************************** - - -} // NL3D diff --git a/code/nel/src/3d/driver/direct3d/driver_direct3d_uniform.cpp b/code/nel/src/3d/driver/direct3d/driver_direct3d_uniform.cpp deleted file mode 100644 index a936d5b46..000000000 --- a/code/nel/src/3d/driver/direct3d/driver_direct3d_uniform.cpp +++ /dev/null @@ -1,246 +0,0 @@ -// NeL - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as -// published by the Free Software Foundation, either version 3 of the -// License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -#include "stddirect3d.h" - -#include "driver_direct3d.h" - -#ifdef DEBUG_NEW -#define new DEBUG_NEW -#endif - -using namespace std; -using namespace NLMISC; - -namespace NL3D -{ - -void CDriverD3D::setUniform4f(TProgram program, uint index, float f0, float f1, float f2, float f3) -{ - H_AUTO_D3D(CDriverD3D_setUniform4f); - - const float tabl[4] = { f0, f1, f2, f3 }; - switch (program) - { - case VertexProgram: - if (_VertexProgram) - { - setVertexProgramConstant(index, tabl); - } - break; - case PixelProgram: - if (_PixelProgram) - { - setPixelShaderConstant(index, tabl); - } - break; - } -} - -void CDriverD3D::setUniform4fv(TProgram program, uint index, size_t num, const float *src) -{ - H_AUTO_D3D(CDriverD3D_setUniform4fv); - - switch (program) - { - case VertexProgram: - if (_VertexProgram) - { - for (uint i = 0; i < num; ++i) - { - setVertexProgramConstant(index + i, src + (i * 4)); - } - } - break; - case PixelProgram: - if (_PixelProgram) - { - for (uint i = 0; i < num; ++i) - { - setPixelShaderConstant(index + i, src + (i * 4)); - } - } - break; - } -} - -void CDriverD3D::setUniform1f(TProgram program, uint index, float f0) -{ - CDriverD3D::setUniform4f(program, index, f0, 0.f, 0.f, 0.f); -} - -void CDriverD3D::setUniform2f(TProgram program, uint index, float f0, float f1) -{ - CDriverD3D::setUniform4f(program, index, f0, f1, 0.f, 0.f); -} - -void CDriverD3D::setUniform3f(TProgram program, uint index, float f0, float f1, float f2) -{ - CDriverD3D::setUniform4f(program, index, f0, f1, f2, 0.0f); -} - -void CDriverD3D::setUniform1i(TProgram program, uint index, sint32 i0) -{ - -} - -void CDriverD3D::setUniform2i(TProgram program, uint index, sint32 i0, sint32 i1) -{ - -} - -void CDriverD3D::setUniform3i(TProgram program, uint index, sint32 i0, sint32 i1, sint32 i2) -{ - -} - -void CDriverD3D::setUniform4i(TProgram program, uint index, sint32 i0, sint32 i1, sint32 i2, sint32 i3) -{ - -} - -void CDriverD3D::setUniform1ui(TProgram program, uint index, uint32 ui0) -{ - -} - -void CDriverD3D::setUniform2ui(TProgram program, uint index, uint32 ui0, uint32 ui1) -{ - -} - -void CDriverD3D::setUniform3ui(TProgram program, uint index, uint32 ui0, uint32 ui1, uint32 ui2) -{ - -} - -void CDriverD3D::setUniform4ui(TProgram program, uint index, uint32 ui0, uint32 ui1, uint32 ui2, uint32 ui3) -{ - -} - -void CDriverD3D::setUniform3f(TProgram program, uint index, const NLMISC::CVector& v) -{ - CDriverD3D::setUniform4f(program, index, v.x, v.y, v.z, 0.f); -} - -void CDriverD3D::setUniform4f(TProgram program, uint index, const NLMISC::CVector& v, float f3) -{ - CDriverD3D::setUniform4f(program, index, v.x, v.y, v.z, f3); -} - -void CDriverD3D::setUniform4f(TProgram program, uint index, const NLMISC::CRGBAF& rgba) -{ - CDriverD3D::setUniform4fv(program, index, 1, &rgba.R); -} - -void CDriverD3D::setUniform4x4f(TProgram program, uint index, const NLMISC::CMatrix& m) -{ - H_AUTO_D3D(CDriverD3D_setUniform4x4f); - - // TODO: Verify this! - NLMISC::CMatrix mat = m; - mat.transpose(); - const float *md = mat.get(); - - CDriverD3D::setUniform4fv(program, index, 4, md); -} - -void CDriverD3D::setUniform4iv(TProgram program, uint index, size_t num, const sint32 *src) -{ - -} - -void CDriverD3D::setUniform4uiv(TProgram program, uint index, size_t num, const uint32 *src) -{ - -} - -void CDriverD3D::setUniformMatrix(NL3D::IDriver::TProgram program, uint index, NL3D::IDriver::TMatrix matrix, NL3D::IDriver::TTransform transform) -{ - H_AUTO_D3D(CDriverD3D_setUniformMatrix); - - D3DXMATRIX mat; - D3DXMATRIX *matPtr = NULL; - switch (matrix) - { - case IDriver::ModelView: - matPtr = &_D3DModelView; - break; - case IDriver::Projection: - matPtr = &(_MatrixCache[remapMatrixIndex(D3DTS_PROJECTION)].Matrix); - break; - case IDriver::ModelViewProjection: - matPtr = &_D3DModelViewProjection; - break; - } - if (transform != IDriver::Identity) - { - switch (transform) - { - case IDriver::Inverse: - D3DXMatrixInverse(&mat, NULL, matPtr); - break; - case IDriver::Transpose: - D3DXMatrixTranspose(&mat, matPtr); - break; - case IDriver::InverseTranspose: - D3DXMatrixInverse(&mat, NULL, matPtr); - D3DXMatrixTranspose(&mat, &mat); - break; - } - matPtr = &mat; - } - - D3DXMatrixTranspose(&mat, matPtr); - - CDriverD3D::setUniform4fv(program, index, 4, &mat.m[0][0]); -} - -void CDriverD3D::setUniformFog(NL3D::IDriver::TProgram program, uint index) -{ - H_AUTO_D3D(CDriverD3D_setUniformFog) - - /* "oFog" must always be between [1, 0] what ever you set in D3DRS_FOGSTART and D3DRS_FOGEND (1 for no fog, 0 for full fog). - The Geforce4 TI 4200 (drivers 53.03 and 45.23) doesn't accept other values for "oFog". */ - const float delta = _FogEnd - _FogStart; - CDriverD3D::setUniform4f(program, index, - -_D3DModelView._13 / delta, - -_D3DModelView._23 / delta, - -_D3DModelView._33 / delta, - 1 - (_D3DModelView._43 - _FogStart) / delta); -} - -bool CDriverD3D::setUniformDriver(TProgram program) -{ - // todo - - return true; -} - -bool CDriverD3D::setUniformMaterial(TProgram program, CMaterial &material) -{ - // todo - - return true; -} - -void CDriverD3D::setUniformParams(TProgram program, CGPUProgramParams ¶ms) -{ - // todo -} - -} // NL3D diff --git a/code/nel/src/3d/driver/direct3d/driver_direct3d_vertex.cpp b/code/nel/src/3d/driver/direct3d/driver_direct3d_vertex.cpp deleted file mode 100644 index ba726fcc9..000000000 --- a/code/nel/src/3d/driver/direct3d/driver_direct3d_vertex.cpp +++ /dev/null @@ -1,943 +0,0 @@ -// NeL - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as -// published by the Free Software Foundation, either version 3 of the -// License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -#include "stddirect3d.h" - -#include "nel/3d/vertex_buffer.h" -#include "nel/3d/light.h" -#include "nel/3d/index_buffer.h" -#include "nel/misc/rect.h" -#include "nel/3d/viewport.h" -#include "nel/3d/scissor.h" -#include "nel/3d/u_driver.h" - -#include "driver_direct3d.h" - -#ifdef DEBUG_NEW -#define new DEBUG_NEW -#endif - -using namespace std; -using namespace NLMISC; - -// 500K min. -#define NL3D_DRV_VERTEXARRAY_MINIMUM_SIZE (20*1024) - - - -namespace NL3D -{ - -// *************************************************************************** - -CVBDrvInfosD3D::CVBDrvInfosD3D(CDriverD3D *drv, ItVBDrvInfoPtrList it, CVertexBuffer *vb) : IVBDrvInfos(drv, it, vb) -{ - H_AUTO_D3D(CVBDrvInfosD3D_CVBDrvInfosD3D) - VertexDecl = NULL; - VertexDeclAliasDiffuseToSpecular = NULL; - ColorOffset = 0; - VertexBuffer = NULL; - Usage = 0; - VolatileVertexBuffer = NULL; - VertexDeclNoDiffuse = NULL; - #ifdef NL_DEBUG - Locked = false; - #endif - Driver = drv; -} - -// *************************************************************************** - -uint vertexCount=0; - -CVBDrvInfosD3D::~CVBDrvInfosD3D() -{ - H_AUTO_D3D(CVBDrvInfosD3D_CVBDrvInfosD3D) - CDriverD3D *driver = static_cast(_Driver); - // Restore non resident memory - if (VertexBufferPtr) - { - VertexBufferPtr->setLocation(CVertexBuffer::NotResident); - VertexBufferPtr = NULL; - } - - // Don't release VertexDecl, it is release by the driver - if (VertexBuffer && !Volatile) - { - if (Driver) - { - if (Driver->_VertexBufferCache.VertexBuffer == VertexBuffer) - { - Driver->_VertexBufferCache.VertexBuffer = NULL; - Driver->touchRenderVariable(&Driver->_VertexBufferCache); - } - } - vertexCount--; - VertexBuffer->Release(); - } - - // Stats - if (Hardware) - driver->_VertexBufferHardSet.erase(this); - - #ifdef NL_DEBUG - if (Locked) - { - nlinfo("VBuffer %s is still locked at destruction", VertexBufferPtr->getName().c_str()) ; - CDriverD3D *drv = NLMISC::safe_cast(_Driver); - drv->_LockedBuffers.erase(this); - } - #endif -} - - - -// *************************************************************************** - -uint8 *CVBDrvInfosD3D::lock (uint begin, uint end, bool readOnly) -{ - H_AUTO_D3D(CVBDrvInfosD3D_lock) - nlassert (begin != end); - CDriverD3D *driver = static_cast(_Driver); - //nlinfo("lock from %s", VertexBufferPtr->getName().c_str()); - #ifdef NL_DEBUG - nlassert(!Locked); - driver->_LockedBuffers.insert(this); - Locked = true; - static volatile bool dumpLockedBuffers = false; - if (dumpLockedBuffers) - { - nlinfo("Num locked buffers = %d", (int) driver->_LockedBuffers.size()); - for(std::set::iterator it = driver->_LockedBuffers.begin(); it != driver->_LockedBuffers.end(); ++it) - { - if (!(*it)->VertexBufferPtr) - { - nlinfo("Empty buffer"); - } - else - { - nlinfo("Buffer %s at %p is Locked", (*it)->VertexBufferPtr->getName().c_str(), *it); - } - } - } - #endif - if (Volatile) - { - // Lock the good buffer - CVolatileVertexBuffer *&buffer = VolatileRAM ? (driver->_VolatileVertexBufferRAM[driver->_CurrentRenderPass&1]): - (driver->_VolatileVertexBufferAGP[driver->_CurrentRenderPass&1]); - uint8 *ptr = (uint8*)buffer->lock (end-begin, Stride, Offset); - if (!ptr) - { - // buffer full, swap them - CVolatileVertexBuffer *&bufferOther = VolatileRAM ? (driver->_VolatileVertexBufferRAM[(driver->_CurrentRenderPass + 1) &1]): - (driver->_VolatileVertexBufferAGP[(driver->_CurrentRenderPass + 1) &1]); - std::swap(buffer, bufferOther); - buffer->reset(); - ptr = (uint8*)buffer->lock (end-begin, Stride, Offset); - nlassert(ptr); - } - nlassert(!VolatileVertexBuffer); - VolatileVertexBuffer = buffer; - VertexBuffer = buffer->VertexBuffer; - ptr -= begin; - - // Current lock time - VolatileLockTime = driver->_CurrentRenderPass; - - // Touch the vertex buffer - driver->touchRenderVariable (&driver->_VertexBufferCache); - - return ptr; - } - else - { - nlassert (VertexBuffer); - // Lock Profile? - TTicks beforeLock = 0; - if(driver->_VBHardProfiling /*&& Hardware*/) - { - beforeLock= CTime::getPerformanceTime(); - } - - void *pbData; - if (VertexBuffer->Lock ( begin, end-begin, &pbData, readOnly?D3DLOCK_READONLY:0) != D3D_OK) - return NULL; - - // Lock Profile? - if(driver->_VBHardProfiling /*&& Hardware*/) - { - TTicks afterLock; - afterLock= CTime::getPerformanceTime(); - driver->appendVBHardLockProfile(afterLock-beforeLock, VertexBufferPtr); - } - return (uint8*)pbData; - } -} - -// *************************************************************************** - -void CVBDrvInfosD3D::unlock (uint /* begin */, uint /* end */) -{ - H_AUTO_D3D(CVBDrvInfosD3D_unlock ) - CDriverD3D *drv = NLMISC::safe_cast(_Driver); - #ifdef NL_DEBUG - nlassert(Locked); - drv->_LockedBuffers.erase(this); - Locked = false; - #endif - //nlinfo("unlock from %s", VertexBufferPtr->getName().c_str()); - if (Volatile) - { - nlassert(VolatileVertexBuffer); - VolatileVertexBuffer->unlock (); - VolatileVertexBuffer = NULL; - } - else - VertexBuffer->Unlock (); -} - -// *************************************************************************** - -const D3DDECLTYPE RemapVertexBufferTypeNeL2D3D[CVertexBuffer::NumType]= -{ - D3DDECLTYPE_UNUSED, // Double1, - D3DDECLTYPE_FLOAT1, // Float1, - D3DDECLTYPE_UNUSED, // Short1, - D3DDECLTYPE_UNUSED, // Double2, - D3DDECLTYPE_FLOAT2, // Float2, - D3DDECLTYPE_SHORT2, // Short2, - D3DDECLTYPE_UNUSED, // Double3, - D3DDECLTYPE_FLOAT3, // Float3, - D3DDECLTYPE_UNUSED, // Short3, - D3DDECLTYPE_UNUSED, // Double4, - D3DDECLTYPE_FLOAT4, // Float4, - D3DDECLTYPE_SHORT4, // Short4, - D3DDECLTYPE_D3DCOLOR, // UChar4, -}; - -// *************************************************************************** - -const D3DDECLUSAGE RemapVertexBufferUsageNeL2D3D[CVertexBuffer::NumValue]= -{ - D3DDECLUSAGE_POSITION, // Position - D3DDECLUSAGE_NORMAL, // Normal - D3DDECLUSAGE_TEXCOORD, // TexCoord0 - D3DDECLUSAGE_TEXCOORD, // TexCoord1 - D3DDECLUSAGE_TEXCOORD, // TexCoord2 - D3DDECLUSAGE_TEXCOORD, // TexCoord3 - D3DDECLUSAGE_TEXCOORD, // TexCoord4 - D3DDECLUSAGE_TEXCOORD, // TexCoord5 - D3DDECLUSAGE_TEXCOORD, // TexCoord6 - D3DDECLUSAGE_TEXCOORD, // TexCoord7 - D3DDECLUSAGE_COLOR, // PrimaryColor - D3DDECLUSAGE_COLOR, // SecondaryColor - D3DDECLUSAGE_BLENDWEIGHT, // Weight - D3DDECLUSAGE_BLENDINDICES, // PaletteSkin - D3DDECLUSAGE_FOG, // Fog -}; - -// *************************************************************************** - -const uint RemapVertexBufferIndexNeL2D3D[CVertexBuffer::NumValue]= -{ - 0, // Position - 0, // Normal - 0, // TexCoord0 - 1, // TexCoord1 - 2, // TexCoord2 - 3, // TexCoord3 - 4, // TexCoord4 - 5, // TexCoord5 - 6, // TexCoord6 - 7, // TexCoord7 - 0, // PrimaryColor - 1, // SecondaryColor - 0, // Weight - 0, // PaletteSkin - 0, // Fog -}; - -// *************************************************************************** - -DWORD RemapVertexBufferUsage[CVertexBuffer::LocationCount]= -{ - D3DUSAGE_DYNAMIC, // RAMResident - D3DUSAGE_DYNAMIC|D3DUSAGE_WRITEONLY, // AGPResident - D3DUSAGE_WRITEONLY, // VRAMResident - 0, // Not used -}; - -// *************************************************************************** - -D3DPOOL RemapVertexBufferPool[CVertexBuffer::LocationCount]= -{ - D3DPOOL_SYSTEMMEM, // RAMResident - D3DPOOL_DEFAULT, // AGPResident - D3DPOOL_DEFAULT, // VRAMResident - D3DPOOL_DEFAULT, // Not used -}; - - -// *************************************************************************** - -bool CDriverD3D::activeVertexBuffer(CVertexBuffer& VB) -{ - H_AUTO_D3D(CDriverD3D_activeVertexBuffer) - // Must not be locked - nlassert (!VB.isLocked()); - - // Must not be empty - if (VB.capacity() == 0) - return false; - - - const bool touched = (VB.getTouchFlags() & (CVertexBuffer::TouchedReserve|CVertexBuffer::TouchedVertexFormat)) != 0; - - CVBDrvInfosD3D *info = static_cast(static_cast(VB.DrvInfos)); - - // Volatile buffers must be filled at each pass - nlassertex (!info || !info->Volatile || VB.getKeepLocalMemory() || (info->VolatileLockTime == _CurrentRenderPass), ("Volatile buffers must be filled at each pass")); - - // Build the driver info - if (touched) - { - // Delete previous vertex buffer info - if (VB.DrvInfos) - { - delete VB.DrvInfos; - nlassert (VB.DrvInfos == NULL); - } - - // Force the vertex color format to BGRA - VB.setVertexColorFormat (CVertexBuffer::TBGRA); - - // Rebuild it - _VBDrvInfos.push_front (NULL); - ItVBDrvInfoPtrList ite = _VBDrvInfos.begin(); - info = new CVBDrvInfosD3D(this, ite, &VB); - *ite = info; - - // Use vertex color ? - info->UseVertexColor = (VB.getVertexFormat()&CVertexBuffer::PrimaryColorFlag) != 0; - info->Stride = (uint8)VB.getVertexSize(); - - // Create the vertex declaration - if (!createVertexDeclaration (VB.getVertexFormat(), VB.getValueTypePointer(), &(info->VertexDecl), info->ColorOffset, false, false)) - return false; - info->VertexDeclAliasDiffuseToSpecular = NULL; - info->VertexDeclNoDiffuse = NULL; - if (VB.hasValueEx(CVertexBuffer::PrimaryColor) && !VB.hasValueEx(CVertexBuffer::SecondaryColor)) - { - uint colorOffset2; - if (!createVertexDeclaration (VB.getVertexFormat(), VB.getValueTypePointer(), &(info->VertexDeclAliasDiffuseToSpecular), colorOffset2, true, false)) - return false; - nlassert(colorOffset2 == info->ColorOffset); // should be the same value - } - if (_NbNeLTextureStages == 3 && info->UseVertexColor) - { - // Fix for radeon 7xxx -> if vertex color is not used it should not be declared (example : lighted material + vertex color but, no vertexColorLighted) - uint colorOffset2; - if (!createVertexDeclaration (VB.getVertexFormat(), VB.getValueTypePointer(), &(info->VertexDeclNoDiffuse), colorOffset2, false, true)) - return false; - } - - // Create the vertex buffer - const uint size = VB.capacity()*VB.getVertexSize(); - uint preferredMemory = 0; - if (_DisableHardwareVertexArrayAGP) - { - preferredMemory = CVertexBuffer::RAMResident; - info->Volatile = false; - } - else - { - switch (VB.getPreferredMemory ()) - { - case CVertexBuffer::RAMPreferred: - preferredMemory = CVertexBuffer::RAMResident; - info->Volatile = false; - break; - case CVertexBuffer::AGPPreferred: - preferredMemory = CVertexBuffer::AGPResident; - info->Volatile = false; - break; - case CVertexBuffer::StaticPreferred: - if (getStaticMemoryToVRAM()) - preferredMemory = CVertexBuffer::VRAMResident; - else - preferredMemory = CVertexBuffer::AGPResident; - info->Volatile = false; - break; - case CVertexBuffer::RAMVolatile: - preferredMemory = CVertexBuffer::RAMResident; - info->Volatile = true; - break; - case CVertexBuffer::AGPVolatile: - preferredMemory = CVertexBuffer::AGPResident; - info->Volatile = true; - break; - } - } - - // Volatile vertex buffer - if (info->Volatile) - { - nlassert (info->VertexBuffer == NULL); - info->Hardware = false; - info->VolatileRAM = preferredMemory == CVertexBuffer::RAMResident; - } - else - { - // Offset will be 0 - info->Offset = 0; - - bool success; - do - { - success = _DeviceInterface->CreateVertexBuffer(size, RemapVertexBufferUsage[preferredMemory], - 0, RemapVertexBufferPool[preferredMemory], &(info->VertexBuffer), NULL) == D3D_OK; - if (success) - break; - } - while (preferredMemory--); - if (!success) - return false; - - ++vertexCount; - - // Hardware ? - info->Hardware = preferredMemory != CVertexBuffer::RAMResident; - - // Stats - if (info->Hardware) - _VertexBufferHardSet.insert(info); - } - - // Release the local vertex buffer - VB.DrvInfos = info; - VB.setLocation ((CVertexBuffer::TLocation)preferredMemory); - - // Force the vertex buffer update - touchRenderVariable (&_VertexDeclCache); - touchRenderVariable (&_VertexBufferCache); - } - - // Set the current vertex buffer - nlassert (info); - - // Fill the buffer if in local memory - VB.fillBuffer (); - - setVertexDecl (info->VertexDecl, info->VertexDeclAliasDiffuseToSpecular, info->VertexDeclNoDiffuse, info->Stride); - //setVertexBuffer (info->VertexBuffer, info->Offset, info->Stride, info->UseVertexColor, VB.getNumVertices(), VB.getPreferredMemory(), info->Usage, info->ColorOffset); - setVertexBuffer (info->VertexBuffer, info->Offset, info->Stride, info->UseVertexColor, VB.getNumVertices(), VB.getPreferredMemory(), info->Usage, info->ColorOffset); - - - // Set UVRouting - const uint8 *uvRouting = VB.getUVRouting(); - uint i; - for (i=0; i(static_cast(VB.DrvInfos)); - static vector temp; - uint size = VB.capacity()*VB.getVertexSize(); - - // No special flag for the lock, the driver should return a valid vertex buffer pointer with previous values. - uint8 *out = info->lock (0, 0, false); - nlassert (out); - { - temp.resize (size); - memcpy (&(temp[0]), out, size); - } - info->unlock (0, 0); - out = info->lock (0, 0, false); - nlassert (out); - { - memcpy (out, &(temp[0]), size); - } - info->unlock (0, 0); -*/ - - return true; -} - - -// *************************************************************************** -bool CDriverD3D::createVertexDeclaration (uint16 vertexFormat, const uint8 *typeArray, - IDirect3DVertexDeclaration9 **vertexDecl, - uint &colorOffset, - bool aliasDiffuseToSpecular, - bool bypassDiffuse, - uint *stride) -{ - H_AUTO_D3D(CDriverD3D_createVertexDeclaration) - CVertexDeclaration declaration; - - if (aliasDiffuseToSpecular) - { - // there should be a single color stream : diffuse - nlassert(vertexFormat & CVertexBuffer::PrimaryColorFlag); // diffuse required - nlassert(!(vertexFormat & CVertexBuffer::SecondaryColorFlag)); // specular should not be used - } - - // Set the vertex format - uint i; - uint j = 0; - uint offset = 0; - colorOffset = 0; - for (i=0; i this free PrimaryColor to build a constant - // Ueful to emulate per stage constant (which we can do on 2 stages only) - } - else - { - vertexElement.UsageIndex = BYTE(RemapVertexBufferIndexNeL2D3D[(uint)i]); - } - - // nico : Fix for Radeon 7xxx series - // Vertex declaration doesn't work when the vertex layout has vertex color defined after tex coord. - // For example, the following layout (Position/TexCoord0/Diffuse) will silently be converted into (Position/Diffuse/TexCoord0) - // It seems that the driver tries to map the vertex declaration to the matching FVF. FVF has a prefined order and requires Diffuse to appear - // before texture coordinates in the vertex. Don't know if it is a limitation of D3D related to the 7xxx sries of if it is a driver bug. - // The D3D debug dll doesn't issue a warning about it. - // To solve this 2 vertex streams are declared : - // - First streams contains Position/Normal/Texcoord - // - When vertex color are used, second stream contains Diffuse/Specular vertex component(s) - // In fact the 2 streams map to the same vertex buffer, but the 2nd stream has an added offset to point on the color component - // I tried to add this offset directly into the vertex declaration, but D3D complains about it... - // If the following field contains a non 0 value, then a second stream must be used for diffuse/specular with the given offset - if (_NbNeLTextureStages == 3) - { - if (vertexElement.Usage == D3DDECLUSAGE_COLOR) - { - if (bypassDiffuse) - { - continue; - } - vertexElement.Stream = 1; - if (colorOffset == 0) - { - vertexElement.Offset = 0; - colorOffset = offset; - } - else - { - vertexElement.Offset = 4; - } - } - } - j++; - } - offset += CVertexBuffer::SizeType[typeArray[i]]; - } - } - - // Set the stride ? - if (stride) - *stride = offset; - - // End - D3DVERTEXELEMENT9 end = D3DDECL_END(); - declaration.VertexElements[j] = end; - - // Look for the same vertex declaration - std::list::iterator ite = _VertexDeclarationList.begin(); - while (ite != _VertexDeclarationList.end()) - { - for (i=0; i<=j; i++) - { - const D3DVERTEXELEMENT9 &vertexElementNew = declaration.VertexElements[i]; - const D3DVERTEXELEMENT9 &vertexElementOld = ite->VertexElements[i]; - if ( (vertexElementNew.Stream != vertexElementOld.Stream) || - (vertexElementNew.Type != vertexElementOld.Type) || - (vertexElementNew.Offset != vertexElementOld.Offset) || - (vertexElementNew.Method != vertexElementOld.Method) || - (vertexElementNew.Usage != vertexElementOld.Usage) || - (vertexElementNew.UsageIndex != vertexElementOld.UsageIndex)) - { - - break; - } - } - - // All is good ? - if (i == (j+1)) - { - // It is the same vertex declaration - *vertexDecl = ite->VertexDecl; - return true; - } - - ite++; - } - - // Not found, create the vertex declaration - if (_DeviceInterface->CreateVertexDeclaration (declaration.VertexElements, &(declaration.VertexDecl)) != D3D_OK) - { - return false; - } - - // Add the vertex declaration - _VertexDeclarationList.push_back (declaration); - - // Set the final declaration pointer - *vertexDecl = declaration.VertexDecl; - - return true; - -} - - -// *************************************************************************** - -bool CDriverD3D::supportVertexBufferHard() const -{ - H_AUTO_D3D(CDriverD3D_supportVertexBufferHard) - return !_DisableHardwareVertexArrayAGP; -} - -// *************************************************************************** - -bool CDriverD3D::supportVolatileVertexBuffer() const -{ - H_AUTO_D3D(CDriverD3D_supportVolatileVertexBuffer) - return true; -} - - -// *************************************************************************** - -void CDriverD3D::disableHardwareVertexArrayAGP() -{ - H_AUTO_D3D(CDriverD3D_disableHardwareVertexArrayAGP) - _DisableHardwareVertexArrayAGP = true; -} - -// *************************************************************************** - -uint CDriverD3D::getMaxVerticesByVertexBufferHard() const -{ - H_AUTO_D3D(CDriverD3D_getMaxVerticesByVertexBufferHard) - return _MaxVerticesByVertexBufferHard; -} - -// *************************************************************************** - -uint32 CDriverD3D::getAvailableVertexAGPMemory () -{ - H_AUTO_D3D(CDriverD3D_getAvailableVertexAGPMemory ) - return _AGPMemoryAllocated; -} - -// *************************************************************************** - -uint32 CDriverD3D::getAvailableVertexVRAMMemory () -{ - H_AUTO_D3D(CDriverD3D_getAvailableVertexVRAMMemory ) - return _VRAMMemoryAllocated; -} - -// *************************************************************************** - -bool CDriverD3D::initVertexBufferHard(uint agpMem, uint vramMem) -{ - H_AUTO_D3D(CDriverD3D_initVertexBufferHard) - if(!supportVertexBufferHard()) - return false; - - // First, reset any VBHard created. - bool ok= true; - - // Try to allocate AGPMemory. - _AGPMemoryAllocated = agpMem; - if(_AGPMemoryAllocated>0) - { - _AGPMemoryAllocated&= ~15; // ensure 16-bytes aligned mem count (maybe useful :) ). - _AGPMemoryAllocated= max(_AGPMemoryAllocated, (uint32)NL3D_DRV_VERTEXARRAY_MINIMUM_SIZE); - while(_AGPMemoryAllocated >= NL3D_DRV_VERTEXARRAY_MINIMUM_SIZE) - { - IDirect3DVertexBuffer9 *vb; - if (_DeviceInterface->CreateVertexBuffer (_AGPMemoryAllocated, D3DUSAGE_WRITEONLY|D3DUSAGE_DYNAMIC, 0, - D3DPOOL_DEFAULT, &vb, NULL) == D3D_OK) - { - D3DVERTEXBUFFER_DESC desc; - nlverify (vb->GetDesc (&desc) == D3D_OK); - if (((desc.Usage&(D3DUSAGE_WRITEONLY|D3DUSAGE_DYNAMIC)) == (D3DUSAGE_WRITEONLY|D3DUSAGE_DYNAMIC)) && - (desc.Pool == D3DPOOL_DEFAULT)) - { - nlinfo("%.d vertices supported", _MaxVerticesByVertexBufferHard); - nlinfo("Success to allocate %.1f Mo of AGP VAR Ram", _AGPMemoryAllocated / 1000000.f); - vb->Release(); - break; - } - else - vb->Release(); - } - else - { - _AGPMemoryAllocated/=2; - _AGPMemoryAllocated &=~15; - } - } - - if(_AGPMemoryAllocated< NL3D_DRV_VERTEXARRAY_MINIMUM_SIZE) - { - nlwarning("%.d vertices supported", _MaxVerticesByVertexBufferHard); - nlwarning("Failed to allocate %.1f Mo of AGP VAR Ram", NL3D_DRV_VERTEXARRAY_MINIMUM_SIZE / 1000000.f); - ok= false; - } - } - - - // Try to allocate VRAMMemory. - _VRAMMemoryAllocated = vramMem; - if(_VRAMMemoryAllocated>0) - { - _VRAMMemoryAllocated&= ~15; // ensure 16-bytes aligned mem count (maybe useful :) ). - _VRAMMemoryAllocated= max(_VRAMMemoryAllocated, (uint32)NL3D_DRV_VERTEXARRAY_MINIMUM_SIZE); - while(_VRAMMemoryAllocated>= NL3D_DRV_VERTEXARRAY_MINIMUM_SIZE) - { - IDirect3DVertexBuffer9 *vb; - if (_DeviceInterface->CreateVertexBuffer (_VRAMMemoryAllocated, D3DUSAGE_WRITEONLY, 0, - D3DPOOL_DEFAULT, &vb, NULL) == D3D_OK) - { - vb->Release(); - break; - } - else - { - _VRAMMemoryAllocated/=2; - _VRAMMemoryAllocated &=~15; - } - } - - if(_VRAMMemoryAllocated< NL3D_DRV_VERTEXARRAY_MINIMUM_SIZE) - { - ok= false; - } - } - - return ok; -} - -// *************************************************************************** - -void CDriverD3D::mapTextureStageToUV(uint stage, uint uv) -{ - H_AUTO_D3D(CDriverD3D_mapTextureStageToUV) - setTextureIndexUV (stage, uv); -} - -// *************************************************************************** -// CVolatileVertexBuffer -// *************************************************************************** - -CVolatileVertexBuffer::CVolatileVertexBuffer() -{ - H_AUTO_D3D(CVolatileVertexBuffer_CVolatileVertexBuffer) - VertexBuffer = NULL; - Locked = false; -} - -// *************************************************************************** - -CVolatileVertexBuffer::~CVolatileVertexBuffer() -{ - H_AUTO_D3D(CVolatileVertexBuffer_CVolatileVertexBufferDtor) - release (); -} - -// *************************************************************************** - -void CVolatileVertexBuffer::release () -{ - H_AUTO_D3D(CVolatileVertexBuffer_release ) - if (VertexBuffer) - VertexBuffer->Release(); - VertexBuffer = NULL; -} - -// *************************************************************************** - -void CVolatileVertexBuffer::init (CVertexBuffer::TLocation location, uint size, uint maxSize, CDriverD3D *driver) -{ - H_AUTO_D3D(CVolatileVertexBuffer_init ) - release(); - if (maxSize < size) maxSize = size; - MaxSize = maxSize; - // Init the buffer - Location = location; - Size = size; - Driver = driver; - - // Allocate the vertex buffer - if (Driver->_DeviceInterface->CreateVertexBuffer(size, RemapVertexBufferUsage[location], - 0, RemapVertexBufferPool[location], &VertexBuffer, NULL) != D3D_OK) - { - // Location in RAM must not failed - nlassert (location != CVertexBuffer::RAMResident); - - // Allocate in RAM - nlverify (Driver->_DeviceInterface->CreateVertexBuffer(size, RemapVertexBufferUsage[CVertexBuffer::RAMResident], - 0, RemapVertexBufferPool[CVertexBuffer::RAMResident], &VertexBuffer, NULL) != D3D_OK); - - Location = CVertexBuffer::RAMResident; - } -} - -// *************************************************************************** - -//volatile int callCount = 0; -//volatile int callStop = 17700; - - - -void *CVolatileVertexBuffer::lock (uint size, uint stride, uint &offset) -{ - nlassertex(!Locked, ("Volatile buffer usage should follow an atomic lock/unlock/render sequence")); - H_AUTO_D3D(CVolatileVertexBuffer_lock) - /* If not enough room to allocate this buffer, resise the buffer to Size+Size/2 but do not reset CurrentIndex - * to be sure the buffer will be large enough next pass. */ - - //if (callCount == callStop) - // nlstop; - //callCount++; - - // Align the index - uint mod = CurrentIndex / stride; - if (CurrentIndex != (mod*stride)) - CurrentIndex = (mod+1)*stride; - - - // Enough room for this vertex ? - if (CurrentIndex+size+stride > Size) - { - if (CurrentIndex+size > MaxSize && CurrentIndex != 0) - { - reset(); - if (size > MaxSize) - { - init (Location, std::max (std::min(Size+Size/2, MaxSize), size), MaxSize, Driver); - } - } - else - { - // Max size not reached, so reallocate - init (Location, std::max (std::min(Size+Size/2, MaxSize), CurrentIndex+size), MaxSize, Driver); - reset(); // reallocate will cause a cpu stall anyway ... - } - } - - // Lock Profile? - TTicks beforeLock = 0; - if(Driver->_VBHardProfiling) - { - beforeLock= CTime::getPerformanceTime(); - } - // Lock the buffer, noblocking lock here if not the first allocation since a reset - - VOID *pbData; - if (CurrentIndex==0) - { - nlverify (VertexBuffer->Lock (0, Size, &pbData, D3DLOCK_DISCARD) == D3D_OK); - } - else - { - nlverify (VertexBuffer->Lock (CurrentIndex, size, &pbData, D3DLOCK_NOOVERWRITE) == D3D_OK); - } - if(Driver->_VBHardProfiling) - { - TTicks afterLock; - afterLock= CTime::getPerformanceTime(); - Driver->_VolatileVBLockTime += afterLock - beforeLock; - } - - // Old buffer position - offset = CurrentIndex/stride; - - // New buffer position - CurrentIndex += size; - Locked = true; - return pbData; -} - -// *************************************************************************** - -void CVolatileVertexBuffer::unlock () -{ - H_AUTO_D3D(CVolatileVertexBuffer_unlock ) - nlassertex(Locked, ("Volatile buffer usage should follow an atomic lock/unlock/render sequence")); - nlverify (VertexBuffer->Unlock () == D3D_OK); - Locked = false; -} - -// *************************************************************************** -void CVolatileVertexBuffer::reset () -{ - H_AUTO_D3D(CVolatileVertexBuffer_reset ) - CurrentIndex = 0; -// callCount = 0; -} - -// *************************************************************************** - -} // NL3D - - - - - - - - - - - - - - - - - - - - - diff --git a/code/nel/src/3d/driver/direct3d/driver_direct3d_vertex_program.cpp b/code/nel/src/3d/driver/direct3d/driver_direct3d_vertex_program.cpp deleted file mode 100644 index 265468125..000000000 --- a/code/nel/src/3d/driver/direct3d/driver_direct3d_vertex_program.cpp +++ /dev/null @@ -1,439 +0,0 @@ -// NeL - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as -// published by the Free Software Foundation, either version 3 of the -// License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -#include "stddirect3d.h" - -#include "driver_direct3d.h" - -#ifdef DEBUG_NEW -#define new DEBUG_NEW -#endif - -using namespace std; -using namespace NLMISC; - -namespace NL3D -{ - -// *************************************************************************** - -CVertexProgamDrvInfosD3D::CVertexProgamDrvInfosD3D(IDriver *drv, ItGPUPrgDrvInfoPtrList it) : IProgramDrvInfos (drv, it) -{ - H_AUTO_D3D(CVertexProgamDrvInfosD3D_CVertexProgamDrvInfosD3D) - Shader = NULL; -} - -// *************************************************************************** - -CVertexProgamDrvInfosD3D::~CVertexProgamDrvInfosD3D() -{ - H_AUTO_D3D(CVertexProgamDrvInfosD3D_CVertexProgamDrvInfosD3DDtor) - if (Shader) - Shader->Release(); -} - -// *************************************************************************** - -bool CDriverD3D::supportVertexProgram (CVertexProgram::TProfile profile) const -{ - H_AUTO_D3D(CDriverD3D_supportVertexProgram ) - return (profile == CVertexProgram::nelvp) && _VertexProgram; -} - -// *************************************************************************** - -bool CDriverD3D::isVertexProgramEmulated () const -{ - H_AUTO_D3D(CDriverD3D_isVertexProgramEmulated ) - // Pure HAL driver, no emulation available - return false; -} - -// *************************************************************************** - -static const char *instrToName[] = -{ - "mov ", - "mov ", - "mul ", - "add ", - "mad ", - "rsq ", - "dp3 ", - "dp4 ", - "dst ", - "lit ", - "min ", - "max ", - "slt ", - "sge ", - "expp ", - "log ", - "rcp " -}; - -// *************************************************************************** - -static const char *outputRegisterToName[] = -{ - "Pos", - "D0", - "D1", - "BFC0", - "BFC1", - "Fog", - "Pts", - "T0", - "T1", - "T2", - "T3", - "T4", - "T5", - "T6", - "T7" -}; - -// *************************************************************************** - -void dumpWriteMask(uint mask, std::string &out) -{ - H_AUTO_D3D(dumpWriteMask) - if (mask == 0xf) - { - out.clear(); - return; - } - out = "."; - if (mask & 1) out +="x"; - if (mask & 2) out +="y"; - if (mask & 4) out +="z"; - if (mask & 8) out +="w"; -} - -// *************************************************************************** - -void dumpSwizzle(const CVPSwizzle &swz, std::string &out) -{ - H_AUTO_D3D(dumpSwizzle) - if (swz.isIdentity()) - { - out.clear(); - return; - } - out = "."; - for(uint k = 0; k < 4; ++k) - { - switch(swz.Comp[k]) - { - case CVPSwizzle::X: out += "x"; break; - case CVPSwizzle::Y: out += "y"; break; - case CVPSwizzle::Z: out += "z"; break; - case CVPSwizzle::W: out += "w"; break; - default: - nlassert(0); - break; - } - if (swz.isScalar() && k == 0) break; - } - -} - -// *************************************************************************** - -void dumpOperand(const CVPOperand &op, bool destOperand, std::string &out, set &inputs) -{ - H_AUTO_D3D(dumpOperand) - out = op.Negate ? " -" : " "; - switch(op.Type) - { - case CVPOperand::Variable: out += "r" + NLMISC::toString(op.Value.VariableValue); break; - case CVPOperand::Constant: - out += "c["; - if (op.Indexed) - { - out += "a0.x + "; - } - out += NLMISC::toString(op.Value.ConstantValue) + "]"; - break; - case CVPOperand::InputRegister: - out += "v" + NLMISC::toString((uint) op.Value.InputRegisterValue); - inputs.insert (op.Value.InputRegisterValue); - break; - case CVPOperand::OutputRegister: - nlassert(op.Value.OutputRegisterValue < CVPOperand::OutputRegisterCount); - out += "o" + std::string(outputRegisterToName[op.Value.OutputRegisterValue]); - break; - case CVPOperand::AddressRegister: - out += "a0.x"; - break; - } - std::string suffix; - if (destOperand) - { - // No mask for the fog value - if (op.Value.OutputRegisterValue != CVPOperand::OFogCoord) - dumpWriteMask(op.WriteMask, suffix); - } - else - { - dumpSwizzle(op.Swizzle, suffix); - } - out += suffix; -} - -// *************************************************************************** - -void dumpInstr(const CVPInstruction &instr, std::string &out, set &inputs) -{ - H_AUTO_D3D(dumpInstr) - nlassert(instr.Opcode < CVPInstruction::OpcodeCount); - out = instrToName[instr.Opcode]; - uint nbOp = instr.getNumUsedSrc(); - std::string destOperand; - dumpOperand(instr.Dest, true, destOperand, inputs); - out += destOperand; - for(uint k = 0; k < nbOp; ++k) - { - out += ", "; - std::string srcOperand; - dumpOperand(instr.getSrc(k), false, srcOperand, inputs); - out += srcOperand; - } - out +="; \n"; -} - -// *************************************************************************** - -static const char *inputToDecl[CVPOperand::InputRegisterCount] = -{ - "dcl_position v0", - "dcl_blendweight v1", - "dcl_normal v2", - "dcl_color0 v3", - "dcl_color1 v4", - "dcl_fog v5", - "dcl_blendindices v6", - "", - "dcl_texcoord0 v8", - "dcl_texcoord1 v9", - "dcl_texcoord2 v10", - "dcl_texcoord3 v11", - "dcl_texcoord4 v12", - "dcl_texcoord5 v13", - "dcl_texcoord6 v14", - "dcl_texcoord7 v15", -}; - -// *************************************************************************** - -void dump(const CVPParser::TProgram &prg, std::string &dest) -{ - H_AUTO_D3D(dump) - // Set of input registers used - set inputs; - - string program; - for(uint k = 0; k < prg.size(); ++k) - { - std::string instr; - dumpInstr(prg[k], instr, inputs); - program += instr; - } - - // Write the header - dest = "vs.1.1\n"; - set::iterator ite = inputs.begin(); - while (ite != inputs.end()) - { - dest += inputToDecl[*ite] + string("\n"); - ite++; - } - dest += program; -} - -// *************************************************************************** - -bool CDriverD3D::compileVertexProgram(NL3D::CVertexProgram *program) -{ - // Program setuped ? - if (program->m_DrvInfo == NULL) - { - // Find nelvp - IProgram::CSource *source = NULL; - for (uint i = 0; i < program->getSourceNb(); ++i) - { - if (program->getSource(i)->Profile == CVertexProgram::nelvp) - { - source = program->getSource(i); - } - } - if (!source) - { - nlwarning("Direct3D driver only supports 'nelvp' profile, vertex program cannot be used"); - return false; - } - - _GPUPrgDrvInfos.push_front (NULL); - ItGPUPrgDrvInfoPtrList itTex = _GPUPrgDrvInfos.begin(); - CVertexProgamDrvInfosD3D *drvInfo; - *itTex = drvInfo = new CVertexProgamDrvInfosD3D(this, itTex); - - // Create a driver info structure - program->m_DrvInfo = *itTex; - - /** Check with our parser if the program will works with other implemented extensions, too. (EXT_vertex_shader ..). - * There are some incompatibilities. - */ - CVPParser parser; - CVPParser::TProgram parsedProgram; - std::string errorOutput; - bool result = parser.parse(source->SourcePtr, parsedProgram, errorOutput); - if (!result) - { - nlwarning("Unable to parse a vertex program :"); - nlwarning(errorOutput.c_str()); - #ifdef NL_DEBUG_D3D - nlassert(0); - #endif // NL_DEBUG_D3D - return false; - } - - // tmp fix for Radeon 8500/9000/9200 - // Currently they hang when PaletteSkin / SkinWeight are present in the vertex declaration, but not used - // so disable them in the vertex declaration - // We don't use these component in vertex programs currently.. - #ifdef NL_DEBUG - for(uint k = 0; k < parsedProgram.size(); ++k) - { - for(uint l = 0; l < parsedProgram[k].getNumUsedSrc(); ++l) - { - const CVPOperand &op = parsedProgram[k].getSrc(l); - if (op.Type == CVPOperand::InputRegister) - { - nlassert(op.Value.InputRegisterValue != CVPOperand::IWeight); - nlassert(op.Value.InputRegisterValue != CVPOperand::IPaletteSkin); - } - } - } - #endif - - // Dump the vertex program - std::string dest; - dump(parsedProgram, dest); -#ifdef NL_DEBUG_D3D - nlinfo("Assemble Vertex Shader : "); - string::size_type lineBegin = 0; - string::size_type lineEnd; - while ((lineEnd = dest.find('\n', lineBegin)) != string::npos) - { - nlinfo(dest.substr (lineBegin, lineEnd-lineBegin).c_str()); - lineBegin = lineEnd+1; - } - nlinfo(dest.substr (lineBegin, lineEnd-lineBegin).c_str()); -#endif // NL_DEBUG_D3D - - LPD3DXBUFFER pShader; - LPD3DXBUFFER pErrorMsgs; - if (D3DXAssembleShader (dest.c_str(), (UINT)dest.size(), NULL, NULL, 0, &pShader, &pErrorMsgs) == D3D_OK) - { - if (_DeviceInterface->CreateVertexShader((DWORD*)pShader->GetBufferPointer(), &(getVertexProgramD3D(*program)->Shader)) != D3D_OK) - return false; - } - else - { - nlwarning ("Can't assemble vertex program:"); - nlwarning ((const char*)pErrorMsgs->GetBufferPointer()); - return false; - } - - // Set parameters for assembly programs - drvInfo->ParamIndices = source->ParamIndices; - - // Build the feature info - program->buildInfo(source); - } - - return true; -} - -// *************************************************************************** - -bool CDriverD3D::activeVertexProgram (CVertexProgram *program) -{ - H_AUTO_D3D(CDriverD3D_activeVertexProgram ) - if (_DisableHardwareVertexProgram) - return false; - - // Set the vertex program - if (program) - { - if (!CDriverD3D::compileVertexProgram(program)) return false; - - CVertexProgamDrvInfosD3D *info = NLMISC::safe_cast((IProgramDrvInfos*)program->m_DrvInfo); - _VertexProgramUser = program; - setVertexProgram (info->Shader, program); - - /* D3DRS_FOGSTART and D3DRS_FOGEND must be set with [1, 0] else the fog doesn't work properly on VertexShader and non-VertexShader objects - (random fog flicking) with Geforce4 TI 4200 (drivers 53.03 and 45.23). The other cards seam to interpret the "oFog"'s values using D3DRS_FOGSTART, - D3DRS_FOGEND. - Related to setUniformFog(). - */ - float z = 0; - float o = 1; - setRenderState (D3DRS_FOGSTART, *((DWORD*) (&o))); - setRenderState (D3DRS_FOGEND, *((DWORD*) (&z))); - } - else - { - setVertexProgram (NULL, NULL); - _VertexProgramUser = NULL; - - // Set the old fog range - setRenderState (D3DRS_FOGSTART, *((DWORD*) (&_FogStart))); - setRenderState (D3DRS_FOGEND, *((DWORD*) (&_FogEnd))); - } - - return true; -} - -// *************************************************************************** - -void CDriverD3D::enableVertexProgramDoubleSidedColor(bool /* doubleSided */) -{ - H_AUTO_D3D(CDriverD3D_enableVertexProgramDoubleSidedColor) -} - -// *************************************************************************** - -bool CDriverD3D::supportVertexProgramDoubleSidedColor() const -{ - H_AUTO_D3D(CDriverD3D_supportVertexProgramDoubleSidedColor) - // Not supported under D3D - return false; -} - -// *************************************************************************** - -void CDriverD3D::disableHardwareVertexProgram() -{ - H_AUTO_D3D(CDriverD3D_disableHardwareVertexProgram) - _DisableHardwareVertexProgram = true; - _VertexProgram = false; -} - -// *************************************************************************** - -} // NL3D diff --git a/code/nel/src/3d/driver/direct3d/resources.rc b/code/nel/src/3d/driver/direct3d/resources.rc deleted file mode 100644 index 4211b6c32..000000000 --- a/code/nel/src/3d/driver/direct3d/resources.rc +++ /dev/null @@ -1,37 +0,0 @@ -#include -#include "config.h" - -VS_VERSION_INFO VERSIONINFO -FILEVERSION NL_VERSION_RC -PRODUCTVERSION NL_VERSION_RC -FILEFLAGSMASK VS_FFI_FILEFLAGSMASK -#ifdef _DEBUG -FILEFLAGS VS_FF_DEBUG -#else -FILEFLAGS 0x0L -#endif -FILEOS VOS_NT_WINDOWS32 -FILETYPE VFT_DLL -FILESUBTYPE 0x0L -BEGIN - BLOCK "StringFileInfo" - BEGIN - BLOCK "040904b0" - BEGIN - VALUE "FileDescription", "NeL Direct3D driver" - VALUE "FileVersion", NL_VERSION - VALUE "LegalCopyright", COPYRIGHT -#ifdef _DEBUG - VALUE "OriginalFilename", "nel_drv_direct3d_win_d.dll" -#else - VALUE "OriginalFilename", "nel_drv_direct3d_win_r.dll" -#endif - VALUE "ProductName", "Ryzom Core" - VALUE "ProductVersion", NL_VERSION - END - END - BLOCK "VarFileInfo" - BEGIN - VALUE "Translation", 0x409, 1252 - END -END diff --git a/code/nel/src/3d/driver/direct3d/stddirect3d.cpp b/code/nel/src/3d/driver/direct3d/stddirect3d.cpp deleted file mode 100644 index 319b352be..000000000 --- a/code/nel/src/3d/driver/direct3d/stddirect3d.cpp +++ /dev/null @@ -1,17 +0,0 @@ -// NeL - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as -// published by the Free Software Foundation, either version 3 of the -// License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -#include "stddirect3d.h" diff --git a/code/nel/src/3d/driver/direct3d/stddirect3d.h b/code/nel/src/3d/driver/direct3d/stddirect3d.h deleted file mode 100644 index 366627b44..000000000 --- a/code/nel/src/3d/driver/direct3d/stddirect3d.h +++ /dev/null @@ -1,72 +0,0 @@ -// NeL - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as -// published by the Free Software Foundation, either version 3 of the -// License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -#ifndef STDDIRECT3D_H -#define STDDIRECT3D_H - -#if defined(_MSC_VER) && defined(_DEBUG) - #define _CRTDBG_MAP_ALLOC - #include - #include - #define DEBUG_NEW new(_NORMAL_BLOCK, __FILE__, __LINE__) -#endif - -// System includes -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -// Default NeL includes -#include "nel/misc/types_nl.h" - -#ifdef NL_DEBUG - // add Direct3D debug infos - #define D3D_DEBUG_INFO -#endif - -// NeL includes -#include "nel/misc/common.h" -#include "nel/misc/debug.h" -#include "nel/misc/stream.h" -#include "nel/misc/mem_stream.h" -#include "nel/misc/time_nl.h" -#include "nel/misc/command.h" - -#ifdef NL_OS_WINDOWS -# define WIN32_LEAN_AND_MEAN -# ifndef NL_COMP_MINGW -# define NOMINMAX -# endif -# include -#endif - -// Directx includes -#include -#include - -#endif diff --git a/code/nel/src/3d/driver/opengl/EGL/eglext.h b/code/nel/src/3d/driver/opengl/EGL/eglext.h index a28f5b88e..db90b478d 100644 --- a/code/nel/src/3d/driver/opengl/EGL/eglext.h +++ b/code/nel/src/3d/driver/opengl/EGL/eglext.h @@ -320,11 +320,6 @@ EGLAPI EGLBoolean eglQuerySurfacePointerANGLE(EGLDisplay dpy, EGLSurface surface typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYSURFACEPOINTERANGLEPROC) (EGLDisplay dpy, EGLSurface surface, EGLint attribute, void **value); #endif -#ifndef EGL_ANGLE_surface_d3d_texture_2d_share_handle -#define EGL_ANGLE_surface_d3d_texture_2d_share_handle 1 -#define EGL_D3D_TEXTURE_2D_SHARE_HANDLE_ANGLE 0x3200 -#endif - #ifndef EGL_NV_coverage_sample_resolve #define EGL_NV_coverage_sample_resolve 1 #define EGL_COVERAGE_SAMPLE_RESOLVE_NV 0x3131 @@ -435,11 +430,6 @@ typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYSTREAMTIMEKHRPROC)(EGLDisplay dpy, E #define EGL_LOSE_CONTEXT_ON_RESET_EXT 0x31BF #endif -#ifndef EGL_ANGLE_d3d_share_handle_client_buffer -#define EGL_ANGLE_d3d_share_handle_client_buffer 1 -/* reuse EGL_D3D_TEXTURE_2D_SHARE_HANDLE_ANGLE */ -#endif - #ifndef EGL_KHR_create_context #define EGL_KHR_create_context 1 #define EGL_CONTEXT_MAJOR_VERSION_KHR EGL_CONTEXT_CLIENT_VERSION diff --git a/code/nel/src/3d/driver/opengl/driver_opengl.cpp b/code/nel/src/3d/driver/opengl/driver_opengl.cpp index 023997065..f46c47ddc 100644 --- a/code/nel/src/3d/driver/opengl/driver_opengl.cpp +++ b/code/nel/src/3d/driver/opengl/driver_opengl.cpp @@ -1262,7 +1262,7 @@ sint CDriverGL::getTotalVideoMemory() const nlwarning("3D: Unable to get renderer ID (%s)", CGLErrorString(error)); } } - + CGLDestroyRendererInfo(rend); } else @@ -2883,7 +2883,7 @@ IOcclusionQuery::TOcclusionType COcclusionQueryGL::getOcclusionType() nglGetOcclusionQueryuivNV(ID, GL_PIXEL_COUNT_NV, &result); OcclusionType = result != 0 ? NotOccluded : Occluded; VisibleCount = (uint) result; - // Note : we could return the exact number of pixels that passed the z-test, but this value is not supported by all implementation (Direct3D ...) + // Note : we could return the exact number of pixels that passed the z-test, but this value is not supported by all implementation ... } } else diff --git a/code/nel/src/3d/driver/opengl/driver_opengl.h b/code/nel/src/3d/driver/opengl/driver_opengl.h index 68e6b0edf..70b89aef6 100644 --- a/code/nel/src/3d/driver/opengl/driver_opengl.h +++ b/code/nel/src/3d/driver/opengl/driver_opengl.h @@ -440,7 +440,7 @@ public: virtual bool supportCloudRenderSinglePass() const; - virtual bool supportIndexOffset() const { return false; /* feature only supported in D3D for now */ } + virtual bool supportIndexOffset() const { return false; } virtual bool slowUnlockVertexBufferHard() const; @@ -1006,7 +1006,6 @@ private: bool setScreenMode(const GfxMode &mode); // Test if cursor is in the client area. always true when software cursor is used and window visible - // (displayed in software when DirectInput is used) bool isSystemCursorInClientArea(); // Check if RGBA cursors are supported @@ -1337,7 +1336,7 @@ private: virtual bool supportVertexProgram(CVertexProgram::TProfile profile) const; /** Compile the given vertex program, return if successful. - * If a vertex program was set active before compilation, + * If a vertex program was set active before compilation, * the state of the active vertex program is undefined behaviour afterwards. */ virtual bool compileVertexProgram(CVertexProgram *program); @@ -1364,7 +1363,7 @@ private: virtual bool supportPixelProgram(CPixelProgram::TProfile profile = CPixelProgram::arbfp1) const; /** Compile the given pixel program, return if successful. - * If a pixel program was set active before compilation, + * If a pixel program was set active before compilation, * the state of the active pixel program is undefined behaviour afterwards. */ virtual bool compilePixelProgram(CPixelProgram *program); @@ -1391,7 +1390,7 @@ private: virtual bool supportGeometryProgram(CGeometryProgram::TProfile profile) const { return false; } /** Compile the given pixel program, return if successful. - * If a pixel program was set active before compilation, + * If a pixel program was set active before compilation, * the state of the active pixel program is undefined behaviour afterwards. */ virtual bool compileGeometryProgram(CGeometryProgram *program) { return false; } @@ -1464,7 +1463,7 @@ private: bool activeARBPixelProgram (CPixelProgram *program); bool setupPixelProgram (CPixelProgram *program, GLuint id/*, bool &specularWritten*/); //@} - + /// \fallback for material shaders // @{ @@ -1477,7 +1476,7 @@ private: // Don't use glIsEnabled, too slow. return _VertexProgramEnabled; } - + bool isPixelProgramEnabled () const { // Don't use glIsEnabled, too slow. @@ -1668,9 +1667,9 @@ public: CVertexProgamDrvInfosGL (CDriverGL *drv, ItGPUPrgDrvInfoPtrList it); virtual uint getUniformIndex(const char *name) const - { + { std::map::const_iterator it = ParamIndices.find(name); - if (it != ParamIndices.end()) return it->second; + if (it != ParamIndices.end()) return it->second; return std::numeric_limits::max(); }; @@ -1683,14 +1682,14 @@ class CPixelProgamDrvInfosGL : public IProgramDrvInfos public: // The GL Id. GLuint ID; - + // The gl id is auto created here. CPixelProgamDrvInfosGL (CDriverGL *drv, ItGPUPrgDrvInfoPtrList it); virtual uint getUniformIndex(const char *name) const - { + { std::map::const_iterator it = ParamIndices.find(name); - if (it != ParamIndices.end()) return it->second; + if (it != ParamIndices.end()) return it->second; return std::numeric_limits::max(); }; diff --git a/code/nel/src/3d/driver/opengl/driver_opengl_inputs.cpp b/code/nel/src/3d/driver/opengl/driver_opengl_inputs.cpp index 0d27166fc..6c02f2d82 100644 --- a/code/nel/src/3d/driver/opengl/driver_opengl_inputs.cpp +++ b/code/nel/src/3d/driver/opengl/driver_opengl_inputs.cpp @@ -113,10 +113,6 @@ bool CDriverGL::isAlphaBlendedCursorSupported() { #ifdef NL_OS_WINDOWS // Support starts with windows 2000 (not only from XP as seen in most docs) - // NB : Additionnaly, could query D3D caps to know if - // color hardware cursor is supported, not only emulated, - // but can't be sure that using the win32 api 'SetCursor' uses the same resources - // So far, seems to be supported on any modern card used by the game anyway ... OSVERSIONINFO osvi; osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); if (GetVersionEx(&osvi)) diff --git a/code/nel/src/3d/driver_user.cpp b/code/nel/src/3d/driver_user.cpp index d1a747478..3b74247ea 100644 --- a/code/nel/src/3d/driver_user.cpp +++ b/code/nel/src/3d/driver_user.cpp @@ -88,9 +88,9 @@ void UDriver::setMatrixMode2D43() } // *************************************************************************** -UDriver *UDriver::createDriver(uintptr_t windowIcon, bool direct3d, emptyProc exitFunc) +UDriver *UDriver::createDriver(uintptr_t windowIcon, emptyProc exitFunc) { - return new CDriverUser (windowIcon, direct3d ? CDriverUser::Direct3d:CDriverUser::OpenGl, exitFunc); + return new CDriverUser (windowIcon, CDriverUser::OpenGl, exitFunc); } // *************************************************************************** @@ -128,12 +128,6 @@ CDriverUser::CDriverUser (uintptr_t windowIcon, TDriver driver, emptyProc exitFu _Driver = NULL; - // Create/Init Driver. -#if defined(NL_OS_WINDOWS) - if (driver == Direct3d) - _Driver= CDRU::createD3DDriver(); -#endif - if (!_Driver && driver == OpenGl) _Driver= CDRU::createGlDriver(); @@ -1840,13 +1834,6 @@ UDriver::TCullMode CDriverUser::getCullMode() const return (TCullMode) _Driver->getCullMode(); } -// *************************************************************************** -bool CDriverUser::isLost() const -{ - NL3D_HAUTO_UI_DRIVER - return _Driver->isLost(); -} - // *************************************************************************** void CDriverUser::beginDialogMode() { diff --git a/code/nel/src/3d/dru.cpp b/code/nel/src/3d/dru.cpp index 15ccbfe01..f6788c32a 100644 --- a/code/nel/src/3d/dru.cpp +++ b/code/nel/src/3d/dru.cpp @@ -29,9 +29,6 @@ # include "config.h" #else # define NL_OPENGL_AVAILABLE -# ifdef NL_OS_WINDOWS -# define NL_DIRECT3D_AVAILABLE -# endif #endif // HAVE_CONFIG_H #ifdef NL_OS_WINDOWS @@ -66,10 +63,6 @@ const char *IDRV_VERSION_PROC_NAME = "NL3D_interfaceVersion"; extern IDriver* createGlDriverInstance (); #endif -#if defined(NL_OS_WINDOWS) && defined(NL_DIRECT3D_AVAILABLE) -extern IDriver* createD3DDriverInstance (); -#endif - #ifdef NL_OPENGLES_AVAILABLE extern IDriver* createGlEsDriverInstance (); #endif @@ -186,60 +179,6 @@ IDriver *CDRU::createGlEsDriver() throw (EDru) // *************************************************************************** -#ifdef NL_OS_WINDOWS - -IDriver *CDRU::createD3DDriver() throw (EDru) -{ -#ifdef NL_STATIC - -#ifdef NL_DIRECT3D_AVAILABLE - return createD3DDriverInstance (); -#else - return NULL; -#endif // NL_DIRECT3D_AVAILABLE - -#else - - IDRV_CREATE_PROC createDriver = NULL; - IDRV_VERSION_PROC versionDriver = NULL; - - CLibrary driverLib; - - if (!driverLib.loadLibrary(NL3D_D3D_DLL_NAME, true, true, false)) - { - throw EDruDirect3dDriverNotFound(); - } - - nlinfo ("Using the library '" NL3D_D3D_DLL_NAME "' that is in the directory: '%s'", driverLib.getLibFileName().c_str()); - - createDriver = (IDRV_CREATE_PROC) driverLib.getSymbolAddress(IDRV_CREATE_PROC_NAME); - if (createDriver == NULL) - { - throw EDruDirect3dDriverCorrupted(); - } - - versionDriver = (IDRV_VERSION_PROC) driverLib.getSymbolAddress(IDRV_VERSION_PROC_NAME); - if (versionDriver != NULL) - { - if (versionDriver()IDriver::InterfaceVersion) - throw EDruDirect3dDriverUnknownVersion(); - } - - IDriver *ret= createDriver(); - if (ret == NULL) - { - throw EDruDirect3dDriverCantCreateDriver(); - } - - return ret; -#endif -} -#endif // NL_OS_WINDOWS - -// *************************************************************************** - void CDRU::drawBitmap (float x, float y, float width, float height, ITexture& texture, IDriver& driver, CViewport viewport, bool blend) { CMatrix mtx; diff --git a/code/nel/src/3d/fxaa.cpp b/code/nel/src/3d/fxaa.cpp index d37a159ef..b7dd0d121 100644 --- a/code/nel/src/3d/fxaa.cpp +++ b/code/nel/src/3d/fxaa.cpp @@ -78,14 +78,6 @@ CFXAA::CFXAA(NL3D::UDriver *driver) : m_Driver(driver), m_VP(NULL), m_PP(NULL), source->setSourcePtr(a_arbfp1); m_PP->addSource(source); } - // ps_2_0 - { - IProgram::CSource *source = new IProgram::CSource(); - source->Features.MaterialFlags = CProgramFeatures::TextureStages; - source->Profile = IProgram::ps_2_0; - source->setSourcePtr(a_ps_2_0); - m_PP->addSource(source); - } if (!drv->compilePixelProgram(m_PP)) { nlwarning("3D: No supported pixel program for FXAA effect"); diff --git a/code/nel/src/3d/landscapevb_info.cpp b/code/nel/src/3d/landscapevb_info.cpp index f5955e622..3995ffdc4 100644 --- a/code/nel/src/3d/landscapevb_info.cpp +++ b/code/nel/src/3d/landscapevb_info.cpp @@ -105,7 +105,6 @@ void CFarVertexBufferInfo::setupVertexBuffer(CVertexBuffer &vb, bool forVertexP if(VertexFormat & CVertexBuffer::PrimaryColorFlag) { ColorOff= vb.getColorOff(); - // todo hulud d3d vertex color RGBA / BGRA ColorPointer= Accessor.getColorPointer(); } else diff --git a/code/nel/src/3d/light.cpp b/code/nel/src/3d/light.cpp index ba887a447..a9d8d8a82 100644 --- a/code/nel/src/3d/light.cpp +++ b/code/nel/src/3d/light.cpp @@ -133,7 +133,7 @@ void CLight::setupAttenuation (float farAttenuationBegin, float farAttenuationEn const float quadratic= 10.0f; /* - With GL/D3D 'att=1/(c+l*r+q*r2)' formula, I think it is impossible to simulate correctly + With GL 'att=1/(c+l*r+q*r2)' formula, I think it is impossible to simulate correctly farAttenuationBegin (very big decrase if for instance farAttenuationBegin is near farAttenuationEnd), hence I simulate it very badly by multiplying the farAttenuationEnd by some factor */ diff --git a/code/nel/src/3d/lod_character_manager.cpp b/code/nel/src/3d/lod_character_manager.cpp index 92dee846a..dc513a58f 100644 --- a/code/nel/src/3d/lod_character_manager.cpp +++ b/code/nel/src/3d/lod_character_manager.cpp @@ -444,7 +444,6 @@ bool CLodCharacterManager::addRenderCharacterKey(CLodCharacterInstance &instan _LockDone= true; } - // After lock, For D3D, the VertexColor may be in BGRA format if(_VertexStream.isBRGA()) { // then swap only the B and R (no cpu cycle added per vertex) diff --git a/code/nel/src/3d/material.cpp b/code/nel/src/3d/material.cpp index 3cae5dd30..c4fdb1f63 100644 --- a/code/nel/src/3d/material.cpp +++ b/code/nel/src/3d/material.cpp @@ -580,7 +580,6 @@ bool CMaterial::isSupportedByDriver(IDriver &drv, bool forceBaseCaps) const { uint numTexStages = drv.getNbTextureStages(); // special case for radeon : though 3 stages are supported, do as if there were only 2, because of the texEnvColor feature - // not managed in Direct3D : emulation is provided, but for no more than 2 constants (and if diffuse is not used) if (numTexStages == 3) numTexStages = 2; if (forceBaseCaps) numTexStages = std::min(numTexStages, (uint) 2); switch(getShader()) @@ -628,4 +627,3 @@ bool CMaterial::isSupportedByDriver(IDriver &drv, bool forceBaseCaps) const } } - diff --git a/code/nel/src/3d/mesh_morpher.cpp b/code/nel/src/3d/mesh_morpher.cpp index d546bc97d..747f8e755 100644 --- a/code/nel/src/3d/mesh_morpher.cpp +++ b/code/nel/src/3d/mesh_morpher.cpp @@ -196,7 +196,6 @@ void CMeshMorpher::update (std::vector *pBSFactor) if (_VBDst->getVertexFormat() & CVertexBuffer::PrimaryColorFlag) if (!rBS.deltaCol.empty()) { - // todo hulud d3d vertex color RGBA / BGRA CRGBA *pRGBA = (CRGBA*)dstvba.getColorPointer (vp); CRGBAF rgbf(*pRGBA); rgbf.R += rBS.deltaCol[j].R * rFactor; @@ -324,7 +323,6 @@ void CMeshMorpher::updateSkinned (std::vector *pBSFactor) if (_VBDst->getVertexFormat() & CVertexBuffer::PrimaryColorFlag) if (!rBS.deltaCol.empty()) { - // todo hulud d3d vertex color RGBA / BGRA CRGBA *pRGBA = (CRGBA*)dstvba.getColorPointer (vp); CRGBAF rgbf(*pRGBA); rgbf.R += rBS.deltaCol[j].R * rFactor; @@ -440,13 +438,3 @@ void CMeshMorpher::updateRawSkin (CVertexBuffer *vbOri, } // NL3D - - - - - - - - - - diff --git a/code/nel/src/3d/meshvp_wind_tree.cpp b/code/nel/src/3d/meshvp_wind_tree.cpp index 620465a0a..89a273171 100644 --- a/code/nel/src/3d/meshvp_wind_tree.cpp +++ b/code/nel/src/3d/meshvp_wind_tree.cpp @@ -76,8 +76,7 @@ static const char* WindTreeVPCodeEnd= DP4 o[HPOS].z, c[2], R5; \n\ DP4 o[HPOS].w, c[3], R5; \n\ MOV o[TEX0], v[8]; \n\ - # hulud : remove this line for the moment because it doesn't work under d3d, if it is needed, we will have to create 2 CVertexProgram objects.\n\ - #MOV o[TEX1], v[9]; \n\ + MOV o[TEX1], v[9]; \n\ DP4 o[FOGC].x, c[6], R5; \n\ END \n\ "; @@ -288,13 +287,13 @@ inline void CMeshVPWindTree::setupPerMesh(IDriver *driver, CScene *scene) // Setup common constants for each instances. // c[8] take useful constants. - driver->setUniform4f(IDriver::VertexProgram, program->idx().ProgramConstants[0], + driver->setUniform4f(IDriver::VertexProgram, program->idx().ProgramConstants[0], 0, 1, 0.5f, 2); // c[9] take other useful constants. - driver->setUniform4f(IDriver::VertexProgram, program->idx().ProgramConstants[1], + driver->setUniform4f(IDriver::VertexProgram, program->idx().ProgramConstants[1], 3.f, 0.f, -1.f, -2.f); // c[10] take Number of phase (4) for level2 and 3. -0.01 to avoid int value == 4. - driver->setUniform4f(IDriver::VertexProgram, program->idx().ProgramConstants[2], + driver->setUniform4f(IDriver::VertexProgram, program->idx().ProgramConstants[2], 4-0.01f, 0, 0, 0); } @@ -324,7 +323,7 @@ inline void CMeshVPWindTree::setupPerInstanceConstants(IDriver *driver, CScene setupLighting(scene, mbi, invertedModelMat); // c[0..3] take the ModelViewProjection Matrix. After setupModelMatrix(); - driver->setUniformMatrix(IDriver::VertexProgram, program->getUniformIndex(CProgramIndex::ModelViewProjection), + driver->setUniformMatrix(IDriver::VertexProgram, program->getUniformIndex(CProgramIndex::ModelViewProjection), IDriver::ModelViewProjection, IDriver::Identity); // c[4..7] take the ModelView Matrix. After setupModelMatrix();00 driver->setUniformFog(IDriver::VertexProgram, program->getUniformIndex(CProgramIndex::Fog)); @@ -334,7 +333,7 @@ inline void CMeshVPWindTree::setupPerInstanceConstants(IDriver *driver, CScene float f; f= _CurrentTime[0] + instancePhase; f= speedCos(f) + Bias[0]; - driver->setUniform3f(IDriver::VertexProgram, program->idx().WindLevel1, + driver->setUniform3f(IDriver::VertexProgram, program->idx().WindLevel1, maxDeltaPosOS[0]*f ); @@ -343,19 +342,19 @@ inline void CMeshVPWindTree::setupPerInstanceConstants(IDriver *driver, CScene float instTime1= _CurrentTime[1] + instancePhase; // phase 0. f= speedCos( instTime1+0 ) + Bias[1]; - driver->setUniform3f(IDriver::VertexProgram, program->idx().WindLevel2[0], + driver->setUniform3f(IDriver::VertexProgram, program->idx().WindLevel2[0], maxDeltaPosOS[1]*f); // phase 1. f= speedCos( instTime1+0.25f ) + Bias[1]; - driver->setUniform3f(IDriver::VertexProgram, program->idx().WindLevel2[1], + driver->setUniform3f(IDriver::VertexProgram, program->idx().WindLevel2[1], maxDeltaPosOS[1]*f); // phase 2. f= speedCos( instTime1+0.50f ) + Bias[1]; - driver->setUniform3f(IDriver::VertexProgram, program->idx().WindLevel2[2], + driver->setUniform3f(IDriver::VertexProgram, program->idx().WindLevel2[2], maxDeltaPosOS[1]*f); // phase 3. f= speedCos( instTime1+0.75f ) + Bias[1]; - driver->setUniform3f(IDriver::VertexProgram, program->idx().WindLevel2[3], + driver->setUniform3f(IDriver::VertexProgram, program->idx().WindLevel2[3], maxDeltaPosOS[1]*f); @@ -364,19 +363,19 @@ inline void CMeshVPWindTree::setupPerInstanceConstants(IDriver *driver, CScene float instTime2= _CurrentTime[2] + instancePhase; // phase 0. f= speedCos( instTime2+0 ) + Bias[2]; - driver->setUniform3f(IDriver::VertexProgram, program->idx().WindLevel3[0], + driver->setUniform3f(IDriver::VertexProgram, program->idx().WindLevel3[0], maxDeltaPosOS[2]*f); // phase 1. f= speedCos( instTime2+0.25f ) + Bias[2]; - driver->setUniform3f(IDriver::VertexProgram, program->idx().WindLevel3[1], + driver->setUniform3f(IDriver::VertexProgram, program->idx().WindLevel3[1], maxDeltaPosOS[2]*f); // phase 2. f= speedCos( instTime2+0.50f ) + Bias[2]; - driver->setUniform3f(IDriver::VertexProgram, program->idx().WindLevel3[2], + driver->setUniform3f(IDriver::VertexProgram, program->idx().WindLevel3[2], maxDeltaPosOS[2]*f); // phase 3. f= speedCos( instTime2+0.75f ) + Bias[2]; - driver->setUniform3f(IDriver::VertexProgram, program->idx().WindLevel3[3], + driver->setUniform3f(IDriver::VertexProgram, program->idx().WindLevel3[3], maxDeltaPosOS[2]*f); } diff --git a/code/nel/src/3d/nelu.cpp b/code/nel/src/3d/nelu.cpp index 8cb6e0968..c7337a71c 100644 --- a/code/nel/src/3d/nelu.cpp +++ b/code/nel/src/3d/nelu.cpp @@ -51,7 +51,7 @@ CEventServer CNELU::EventServer; CEventListenerAsync CNELU::AsyncListener; -bool CNELU::initDriver (uint w, uint h, uint bpp, bool windowed, nlWindow systemWindow, bool offscreen, bool direct3d) throw(EDru) +bool CNELU::initDriver (uint w, uint h, uint bpp, bool windowed, nlWindow systemWindow, bool offscreen) throw(EDru) { // Init debug system // NLMISC::InitDebug(); @@ -61,13 +61,6 @@ bool CNELU::initDriver (uint w, uint h, uint bpp, bool windowed, nlWindow syst CNELU::Driver = NULL; // Init driver. -#ifdef NL_OS_WINDOWS - if (direct3d) - { - CNELU::Driver= CDRU::createD3DDriver(); - } -#endif - if (!CNELU::Driver) { CNELU::Driver= CDRU::createGlDriver(); @@ -183,10 +176,10 @@ void CNELU::releaseDriver() } } -bool CNELU::init (uint w, uint h, CViewport viewport, uint bpp, bool windowed, nlWindow systemWindow, bool offscreen, bool direct3d) throw(EDru) +bool CNELU::init (uint w, uint h, CViewport viewport, uint bpp, bool windowed, nlWindow systemWindow, bool offscreen) throw(EDru) { NL3D::registerSerial3d(); - if (initDriver(w,h,bpp,windowed,systemWindow,offscreen,direct3d)) + if (initDriver(w,h,bpp,windowed,systemWindow,offscreen)) { initScene(viewport); initEventServer(); diff --git a/code/nel/src/3d/noise_3d.cpp b/code/nel/src/3d/noise_3d.cpp index 3c5257c49..50a30d693 100644 --- a/code/nel/src/3d/noise_3d.cpp +++ b/code/nel/src/3d/noise_3d.cpp @@ -185,7 +185,6 @@ void CNoise3d::render2passes (CQuadUV &qc, float wpos, float alpha) uint8 finalAlpha = (uint8)(255*alphaPos*alpha); - // todo hulud d3d vertex color RGBA / BGRA uint8 *pColA = (uint8*)vba.getColorPointer(_NbVertices) + 3; *pColA = finalAlpha; pColA = ((uint8*)pColA) + nVSize; *pColA = finalAlpha; pColA = ((uint8*)pColA) + nVSize; @@ -260,7 +259,6 @@ void CNoise3d::render (CQuadUV &qc, float wpos, float intensity) pUV = (CUV*)( ((uint8*)pUV) + nVSize ); *pUV = CUV(qc.Uv3.U*_ScaleW+_OffS[nSlice2].U, qc.Uv3.V*_ScaleH+_OffS[nSlice2].V); - // todo hulud d3d vertex color RGBA / BGRA uint8 *pColA = (uint8*)vba.getColorPointer(_NbVertices) + 3; *pColA = nAlphaPos; pColA = ((uint8*)pColA) + nVSize; *pColA = nAlphaPos; pColA = ((uint8*)pColA) + nVSize; @@ -306,7 +304,6 @@ void CNoise3d::renderGrid (uint32 nbw, uint32 nbh, uint32 w, uint32 h, pVertices = vba.getVertexCoordPointer(0); pUV0 = vba.getTexCoordPointer (0, 0); pUV1 = vba.getTexCoordPointer (0, 1); - // todo hulud d3d vertex color RGBA / BGRA pColA = (uint8*)vba.getColorPointer(0) + 3; for (j = 0; j < nbh; ++j) @@ -374,7 +371,6 @@ void CNoise3d::renderGrid2passes (uint32 nbw, uint32 nbh, uint32 w, uint32 h, pVertices = vba.getVertexCoordPointer(0); pUV0 = vba.getTexCoordPointer (0, 0); - // todo hulud d3d vertex color RGBA / BGRA pColA = (uint8*)vba.getColorPointer(0) + 3; for (j = 0; j < nbh; ++j) @@ -471,4 +467,3 @@ uint32 CNoise3d::getDepth () } } // namespace NL3D - diff --git a/code/nel/src/3d/ps_mesh.cpp b/code/nel/src/3d/ps_mesh.cpp index 6f21e2c25..fbe3f3b8d 100644 --- a/code/nel/src/3d/ps_mesh.cpp +++ b/code/nel/src/3d/ps_mesh.cpp @@ -1952,7 +1952,6 @@ void CPSConstraintMesh::computeColors(CVertexBuffer &outVB, const CVertexBuffer // TODO: optimisation : avoid to duplicate colors... _ColorScheme->makeN(_Owner, startIndex, vba.getColorPointer(), outVB.getVertexSize(), toProcess, inVB.getNumVertices(), srcStep); // modulate from the source mesh - // todo hulud d3d vertex color RGBA / BGRA uint8 *vDest = (uint8 *) vba.getColorPointer(); uint8 *vSrc = (uint8 *) vbaIn.getColorPointer(); const uint vSize = outVB.getVertexSize(); diff --git a/code/nel/src/3d/ps_quad.cpp b/code/nel/src/3d/ps_quad.cpp index 8ce6ce821..dab3397d4 100644 --- a/code/nel/src/3d/ps_quad.cpp +++ b/code/nel/src/3d/ps_quad.cpp @@ -485,7 +485,6 @@ void CPSQuad::updateVbColNUVForRender(CVertexBuffer &vb, uint32 startIndex, uint if (_ColorScheme) { // compute the colors, each color is replicated 4 times - // todo hulud d3d vertex color RGBA / BGRA _ColorScheme->make4(_Owner, startIndex, vba.getColorPointer(), vb.getVertexSize(), size, srcStep); } diff --git a/code/nel/src/3d/render_trav.cpp b/code/nel/src/3d/render_trav.cpp index cab2e3c00..798d23a1d 100644 --- a/code/nel/src/3d/render_trav.cpp +++ b/code/nel/src/3d/render_trav.cpp @@ -102,7 +102,6 @@ void CRenderTrav::traverse(UScene::TRenderPart renderPart, bool newRender, bool nlwarning("Render trave begin"); #endif H_AUTO( NL3D_TravRender ); - if (getDriver()->isLost()) return; // device is lost so no need to render anything CTravCameraScene::update(); // Bind to Driver. setupDriverCamera(); diff --git a/code/nel/src/3d/shadow_map_manager.cpp b/code/nel/src/3d/shadow_map_manager.cpp index c592b5a07..8193222c9 100644 --- a/code/nel/src/3d/shadow_map_manager.cpp +++ b/code/nel/src/3d/shadow_map_manager.cpp @@ -179,7 +179,6 @@ CShadowMapManager::CShadowMapManager() _ReceiveShadowMaterial.setTexCoordGen(0, true); _ReceiveShadowMaterial.setTexCoordGenMode(0, CMaterial::TexCoordGenObjectSpace); // Setup the stage so we interpolate ShadowColor and White (according to shadowmap alpha) - // nico : with D3D driver, limitation of the number of per stage constant (Only 1 if diffuse is used), so do a blend between inv diffuse & black (instead of diffuse & white), which resolve to a modulate between // source alpha & inverse diffuse. then invert result at subsequent stage _ReceiveShadowMaterial.texEnvOpRGB(0, CMaterial::Modulate); _ReceiveShadowMaterial.texEnvArg0RGB(0, CMaterial::Diffuse, CMaterial::InvSrcColor); @@ -1242,4 +1241,3 @@ void CShadowMapManager::garbageShadowTextures(CScene *scene) } // NL3D - diff --git a/code/nel/src/3d/vegetable_manager.cpp b/code/nel/src/3d/vegetable_manager.cpp index 8946bc67b..efbbcd288 100644 --- a/code/nel/src/3d/vegetable_manager.cpp +++ b/code/nel/src/3d/vegetable_manager.cpp @@ -596,7 +596,7 @@ public: CSource *source = new CSource(); source->Profile = nelvp; source->DisplayName = "nelvp/Veget"; - + // Init the Vertex Program. string vpgram; // start always with Bend. @@ -711,7 +711,7 @@ private: void CVegetableManager::initVertexProgram(uint vpType, bool fogEnabled) { nlassert(_LastDriver); // update driver should have been called at least once ! - + // create VP. _VertexProgram[vpType][fogEnabled ? 1 : 0] = new CVertexProgramVeget(vpType, fogEnabled); } @@ -1335,7 +1335,6 @@ void CVegetableManager::addInstance(CVegetableInstanceGroup *ig, uint dstBendOff= dstVBInfo.getValueOffEx(NL3D_VEGETABLE_VPPOS_BENDINFO); uint dstCenterOff= dstVBInfo.getValueOffEx(NL3D_VEGETABLE_VPPOS_CENTER); - // For D3D, If the VertexBuffer is in BGRA mode if(allocator->isBGRA()) { // then swap only the B and R (no cpu cycle added per vertex) @@ -1870,7 +1869,7 @@ public: void CVegetableManager::setupVertexProgramConstants(IDriver *driver, bool fogEnabled) { nlassert(_ActiveVertexProgram); - + // Standard // setup VertexProgram constants. @@ -2666,7 +2665,6 @@ uint CVegetableManager::updateInstanceLighting(CVegetableInstanceGroup *ig, uin uint dstColor0Off= dstVBInfo.getValueOffEx(NL3D_VEGETABLE_VPPOS_COLOR0); uint dstColor1Off= dstVBInfo.getValueOffEx(NL3D_VEGETABLE_VPPOS_COLOR1); - // For D3D, If the VertexBuffer is in BGRA mode if(allocator->isBGRA()) { // then swap only the B and R (no cpu cycle added per vertex) diff --git a/code/nel/src/3d/vegetable_shape.cpp b/code/nel/src/3d/vegetable_shape.cpp index 3e4c2b7f0..3ea3feb71 100644 --- a/code/nel/src/3d/vegetable_shape.cpp +++ b/code/nel/src/3d/vegetable_shape.cpp @@ -153,7 +153,6 @@ void CVegetableShape::build(CVegetableShapeBuild &vbuild) CUV *dstUVBend= vbaOut.getTexCoordPointer(i, 1); if(bendFromColor) { - // todo hulud d3d vertex color RGBA / BGRA const CRGBA *srcColor= (const CRGBA*)vba.getColorPointer(i); // Copy and scale by MaxBendWeight dstUVBend->U= (srcColor->R / 255.f) * vbuild.MaxBendWeight; diff --git a/code/nel/src/sound/audio_decoder_vorbis.cpp b/code/nel/src/sound/audio_decoder_vorbis.cpp index fdda6e742..db0822d05 100644 --- a/code/nel/src/sound/audio_decoder_vorbis.cpp +++ b/code/nel/src/sound/audio_decoder_vorbis.cpp @@ -6,20 +6,20 @@ * CAudioDecoderVorbis */ -/* +/* * Copyright (C) 2008-2012 by authors - * + * * This file is part of RYZOM CORE. * RYZOM CORE is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as * published by the Free Software Foundation, either version 3 of the * License, or (at your option) any later version. - * + * * RYZOM CORE is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Affero General Public License for more details. - * + * * You should have received a copy of the GNU Affero General Public * License along with RYZOM CORE. If not, see * . @@ -56,7 +56,6 @@ int vorbisSeekFunc(void *datasource, ogg_int64_t offset, int whence) { if (whence == SEEK_CUR && offset == 0) { - // nlwarning(NLSOUND_XAUDIO2_PREFIX "This seek call doesn't do a damn thing, wtf."); return 0; // ooookkaaaaaayyy } @@ -75,7 +74,6 @@ int vorbisSeekFunc(void *datasource, ogg_int64_t offset, int whence) origin = NLMISC::IStream::end; break; default: - // nlwarning(NLSOUND_XAUDIO2_PREFIX "Seeking to fake origin."); return -1; } @@ -101,7 +99,7 @@ static ov_callbacks OV_CALLBACKS_NLMISC_STREAM = { (long (*)(void *)) vorbisTellFunc }; -CAudioDecoderVorbis::CAudioDecoderVorbis(NLMISC::IStream *stream, bool loop) +CAudioDecoderVorbis::CAudioDecoderVorbis(NLMISC::IStream *stream, bool loop) : _Stream(stream), _Loop(loop), _IsMusicEnded(false), _StreamSize(0) { _StreamOffset = stream->getPos(); @@ -148,12 +146,11 @@ uint32 CAudioDecoderVorbis::getNextBytes(uint8 *buffer, uint32 minimum, uint32 m do { // signed 16-bit or unsigned 8-bit little-endian samples - sint br = ov_read(&_OggVorbisFile, (char *)&buffer[bytes_read], maximum - bytes_read, + sint br = ov_read(&_OggVorbisFile, (char *)&buffer[bytes_read], maximum - bytes_read, endianness, // Specifies big or little endian byte packing. 0 for little endian, 1 for b ig endian. Typical value is 0. - getBitsPerSample() == 8 ? 1 : 2, + getBitsPerSample() == 8 ? 1 : 2, getBitsPerSample() == 8 ? 0 : 1, // Signed or unsigned data. 0 for unsigned, 1 for signed. Typically 1. ¤t_section); - // nlinfo(NLSOUND_XAUDIO2_PREFIX "current_section: %i", current_section); if (br > 0) { bytes_read += (uint32)br; @@ -165,14 +162,14 @@ uint32 CAudioDecoderVorbis::getNextBytes(uint8 *buffer, uint32 minimum, uint32 m ov_pcm_seek(&_OggVorbisFile, 0); //_Stream->seek(0, NLMISC::IStream::begin); } - else + else { _IsMusicEnded = true; - break; + break; } } else - { + { // error switch(br) { diff --git a/code/nel/src/sound/audio_mixer_user.cpp b/code/nel/src/sound/audio_mixer_user.cpp index 854a2c1dc..90123b4b0 100644 --- a/code/nel/src/sound/audio_mixer_user.cpp +++ b/code/nel/src/sound/audio_mixer_user.cpp @@ -275,7 +275,7 @@ void CAudioMixerUser::reset() _Leaving = true; _SourceWaitingForPlay.clear(); - + for (uint i = 0; i < _NbMusicChannelFaders; ++i) _MusicChannelFaders[i].reset(); @@ -374,9 +374,7 @@ void CAudioMixerUser::initDriver(const std::string &driverName) ISoundDriver::TDriver driverType; if (dn == "auto") driverType = ISoundDriver::DriverAuto; else if (dn == "fmod") driverType = ISoundDriver::DriverFMod; - else if (dn == "dsound") driverType = ISoundDriver::DriverDSound; else if (dn == "openal") driverType = ISoundDriver::DriverOpenAl; - else if (dn == "xaudio2") driverType = ISoundDriver::DriverXAudio2; else { driverType = ISoundDriver::DriverAuto; @@ -510,7 +508,7 @@ void CAudioMixerUser::initDevice(const std::string &deviceName, const CInitInfo if (!_ReverbEffect) { _UseEax = false; } else // createEffect succeeded, add environments - { + { nldebug("AM: Reverb OK"); // todo: loading this data from a file or something would be neat // also: check if this should go into clustered_sound (background_sound_manager also uses this stuff at one point, though) @@ -572,7 +570,7 @@ void CAudioMixerUser::initDevice(const std::string &deviceName, const CInitInfo { buildSampleBankList(); } - + // Init music channels for (i = 0; i < _NbMusicChannelFaders; ++i) _MusicChannelFaders[i].init(_SoundDriver); @@ -1528,7 +1526,7 @@ void CAudioMixerUser::getPlayingSoundsPos(bool virtualPos, std::vectorgetSourceRelativeMode() ? source->getPos() + _ListenPosition : source->getPos())); - + if (source->getTrack() == 0) nbmute++; else @@ -2833,5 +2831,3 @@ NLMISC_CATEGORISED_COMMAND(nel, displaySoundProfile, "Display information on sou } // NLSOUND - - diff --git a/code/nel/src/sound/clustered_sound.cpp b/code/nel/src/sound/clustered_sound.cpp index 25f0e5b64..14e739a99 100644 --- a/code/nel/src/sound/clustered_sound.cpp +++ b/code/nel/src/sound/clustered_sound.cpp @@ -158,7 +158,7 @@ CClusteredSound::CClusteredSound() _LastEnv(CStringMapper::emptyId()), _LastEnvSize(-1.0f) // size goes from 0.0f to 100.0f { - + } @@ -590,10 +590,10 @@ void CClusteredSound::soundTraverse(const std::vector &clusters, CSo CClusterSoundStatus css; css.Gain = travContext.Gain; CVector soundDir = (nearPos - travContext.ListenerPos).normed(); - /* ****** Todo: OpenAL EFX & XAudio2 implementation of Occlusion & Obstruction (not implemented for fmod anyways) !!! ****** + /* ****** Todo: OpenAL EFX implementation of Occlusion & Obstruction (not implemented for fmod anyways) !!! ****** TStringId occId = portal->getOcclusionModelId(); TStringIntMap::iterator it(_IdToMaterial.find(occId)); - ****** Todo: OpenAL EFX & XAudio2 implementation of Occlusion & Obstruction (not implemented for fmod anyways) !!! ****** */ + ****** Todo: OpenAL EFX implementation of Occlusion & Obstruction (not implemented for fmod anyways) !!! ****** */ #if EAX_AVAILABLE == 1 // EAX_AVAILABLE no longer used => TODO: implement with EFX and remove when new implementation OK. if (it != _IdToMaterial.end()) @@ -612,14 +612,14 @@ void CClusteredSound::soundTraverse(const std::vector &clusters, CSo css.OcclusionRoomRatio = travContext.OcclusionRoomRatio; } #else // EAX_AVAILABLE - /* ****** Todo: OpenAL EFX & XAudio2 implementation of Occlusion & Obstruction (not implemented for fmod anyways) !!! ****** + /* ****** Todo: OpenAL EFX implementation of Occlusion & Obstruction (not implemented for fmod anyways) !!! ****** if (it != _IdToMaterial.end()) { // found an occlusion material for this portal uint matId = it->second; css.Gain *= EAX_MATERIAL_PARAM[matId]; } - ****** Todo: OpenAL EFX & XAudio2 implementation of Occlusion & Obstruction (not implemented for fmod anyways) !!! ****** */ + ****** Todo: OpenAL EFX implementation of Occlusion & Obstruction (not implemented for fmod anyways) !!! ****** */ #endif // EAX_AVAILABLE /* if (portal->getOcclusionModel() == "wood door") { diff --git a/code/nel/src/sound/driver/CMakeLists.txt b/code/nel/src/sound/driver/CMakeLists.txt index 320c4ee05..f9c004ff4 100644 --- a/code/nel/src/sound/driver/CMakeLists.txt +++ b/code/nel/src/sound/driver/CMakeLists.txt @@ -25,11 +25,3 @@ ENDIF() IF(WITH_DRIVER_FMOD) ADD_SUBDIRECTORY(fmod) ENDIF() - -IF(WITH_DRIVER_DSOUND) - ADD_SUBDIRECTORY(dsound) -ENDIF() - -IF(WITH_DRIVER_XAUDIO2) - ADD_SUBDIRECTORY(xaudio2) -ENDIF() diff --git a/code/nel/src/sound/driver/dsound/CMakeLists.txt b/code/nel/src/sound/driver/dsound/CMakeLists.txt deleted file mode 100644 index e3a81fb85..000000000 --- a/code/nel/src/sound/driver/dsound/CMakeLists.txt +++ /dev/null @@ -1,21 +0,0 @@ -FILE(GLOB SRC *.cpp *.h *.def *.rc) - -NL_TARGET_DRIVER(nel_drv_dsound_win ${SRC}) - -INCLUDE_DIRECTORIES(BEFORE ${DXSDK_INCLUDE_DIR}) -TARGET_LINK_LIBRARIES(nel_drv_dsound_win nelmisc nelsnd_lowlevel ${DXSDK_DSOUND_LIBRARY}) - -NL_DEFAULT_PROPS(nel_drv_dsound_win "NeL, Driver, Sound: DirectSound") -NL_ADD_RUNTIME_FLAGS(nel_drv_dsound_win) -NL_ADD_LIB_SUFFIX(nel_drv_dsound_win) - -IF(WITH_PCH) - ADD_NATIVE_PRECOMPILED_HEADER(nel_drv_dsound_win ${CMAKE_CURRENT_SOURCE_DIR}/stddsound.h ${CMAKE_CURRENT_SOURCE_DIR}/stddsound.cpp) -ENDIF() - -IF((WITH_INSTALL_LIBRARIES AND WITH_STATIC_DRIVERS) OR NOT WITH_STATIC_DRIVERS) - INSTALL(TARGETS nel_drv_dsound_win RUNTIME DESTINATION ${NL_DRIVER_PREFIX} LIBRARY DESTINATION ${NL_DRIVER_PREFIX} ARCHIVE DESTINATION ${NL_LIB_PREFIX} COMPONENT driverssound) - IF(WITH_MAXPLUGIN) - INSTALL(TARGETS nel_drv_dsound_win RUNTIME DESTINATION maxplugin COMPONENT driverssound) - ENDIF() -ENDIF() diff --git a/code/nel/src/sound/driver/dsound/buffer_dsound.cpp b/code/nel/src/sound/driver/dsound/buffer_dsound.cpp deleted file mode 100644 index 72423bba7..000000000 --- a/code/nel/src/sound/driver/dsound/buffer_dsound.cpp +++ /dev/null @@ -1,271 +0,0 @@ -// NeL - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as -// published by the Free Software Foundation, either version 3 of the -// License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - - -#include "stddsound.h" -#include "buffer_dsound.h" -#include "sound_driver_dsound.h" - -#define NOMINMAX -#include -#include - -#ifdef DEBUG_NEW -#define new DEBUG_NEW -#endif - -using namespace NLMISC; -using namespace std; - -namespace NLSOUND { - -static const std::string EmptyString; - -// Custom mutimedia IO proc. -/*LRESULT NelIOProc(LPSTR lpmmioinfo, UINT uMsg, LONG lParam1, LONG lParam2) -{ - MMIOINFO *mmioinfo = (MMIOINFO*) lpmmioinfo; - - switch (uMsg) - { - case MMIOM_OPEN: - { - // do some validity checking. - nlassert((mmioinfo->dwFlags & MMIO_CREATE) == 0); - - char *fileName = (char*)lParam1; - std::string fullName = NLMISC::CPath::lookup(fileName, false); - if (fullName.empty()) - { - mmioinfo->adwInfo[0] = NULL; - return MMIOERR_CANNOTOPEN; - } - - NLMISC::CIFile *pfile = new NLMISC::CIFile(fullName); - - mmioinfo->adwInfo[0] = (DWORD)pfile; - return MMSYSERR_NOERROR ; - } - break; - case MMIOM_CLOSE: - { - NLMISC::CIFile *file = (NLMISC::CIFile *)mmioinfo->adwInfo[0]; - delete file; - return 0; - } - break; - case MMIOM_READ: - { - uint8 *pdst = (uint8*) lParam1; - uint bytes = (uint) lParam2; - - nlassert(mmioinfo->adwInfo[0] != NULL); - NLMISC::CIFile *file = (NLMISC::CIFile *)mmioinfo->adwInfo[0]; - bytes = std::min(uint(file->getFileSize() - file->getPos()), bytes); - file->serialBufferWithSize(pdst, bytes); - - mmioinfo->lBufOffset = file->getPos(); - - return bytes; - } - break; - case MMIOM_SEEK: - { - uint newPos = (uint) lParam1; - uint seekMode = lParam2; - - nlassert(mmioinfo->adwInfo[0] != NULL); - NLMISC::CIFile *file = (NLMISC::CIFile *)mmioinfo->adwInfo[0]; - - switch(seekMode) - { - case SEEK_CUR: - file->seek(newPos, NLMISC::IStream::current); - break; - case SEEK_END: - file->seek(newPos, NLMISC::IStream::end); - break; - case SEEK_SET: - file->seek(newPos, NLMISC::IStream::begin); - break; - } - - mmioinfo->lBufOffset = file->getPos(); - - return mmioinfo->lBufOffset; - } - break; - case MMIOM_WRITE: - nlassert("Mutimedia IO write is not supported !"); - break; - case MMIOM_WRITEFLUSH: - nlassert("Mutimedia IO write is not supported !"); - break; - } -} -*/ - - -CBufferDSound::CBufferDSound() : _Data(NULL), _Capacity(0), _Size(0) -{ - _Name = CStringMapper::map(EmptyString); - _Format = Mono16; - _Freq = 0; -} - -CBufferDSound::~CBufferDSound() -{ -// nldebug("Destroying DirectSound buffer %s (%p)", CSoundDriverDSound::instance()->getStringMapper()->unmap(_Name).c_str(), this); - - if (_Data) - { - delete[] _Data; - _Data = NULL; - } -} - -void CBufferDSound::setName(NLMISC::TStringId bufferName) -{ - _Name = bufferName; -} - -/// Set the sample format. (channels = 1, 2, ...; bitsPerSample = 8, 16; frequency = samples per second, 44100, ...) -void CBufferDSound::setFormat(TBufferFormat format, uint8 channels, uint8 bitsPerSample, uint32 frequency) -{ - bufferFormatToSampleFormat(format, channels, bitsPerSample, _Format); - _Freq = frequency; -} - -/// Get a writable pointer to the buffer of specified size. Returns NULL in case of failure. It is only guaranteed that the original data is still available when using StorageSoftware and the specified size is not larger than the available data. Call setStorageMode() and setFormat() first. -uint8 *CBufferDSound::lock(uint capacity) -{ - if (_Data) - { - if (capacity > _Capacity) - { - delete[] _Data; - _Data = NULL; - } - } - - if (!_Data) - { - _Data = new uint8[capacity]; - _Capacity = capacity; - if (_Size > capacity) - _Size = capacity; - } - - return _Data; -} - -/// Notify that you are done writing to this buffer, so it can be copied over to hardware if needed. Returns true if ok. -bool CBufferDSound::unlock(uint size) -{ - if (size > _Capacity) - { - _Size = _Capacity; - return false; - } - else - { - _Size = size; - return true; - } -} - -/// Copy the data with specified size into the buffer. A readable local copy is only guaranteed when OptionLocalBufferCopy is set. Returns true if ok. -bool CBufferDSound::fill(const uint8 *src, uint size) -{ - uint8 *dest = lock(size); - if (dest == NULL) return false; - CFastMem::memcpy(dest, src, size); - return unlock(size); -} - -/// Return the sample format information. -void CBufferDSound::getFormat(TBufferFormat &format, uint8 &channels, uint8 &bitsPerSample, uint32 &frequency) const -{ - sampleFormatToBufferFormat(_Format, format, channels, bitsPerSample); - frequency = _Freq; -} - -/// Return the size of the buffer, in bytes. -uint CBufferDSound::getSize() const -{ - return _Size; -} - -float CBufferDSound::getDuration() const -{ - float frames = (float) _Size; - - switch (_Format) - { - case Mono8: - break; - case Mono16ADPCM: - frames *= 2.0f; - break; - case Mono16: - frames /= 2.0f; - break; - case Stereo8: - frames /= 2.0f; - break; - case Stereo16: - frames /= 4.0f; - break; - } - - return 1000.0f * frames / (float) _Freq; -} - -bool CBufferDSound::isStereo() const -{ - return (_Format == Stereo8) || (_Format == Stereo16); -} - -/// Return the name of this buffer -NLMISC::TStringId CBufferDSound::getName() const -{ - return _Name; -} - -/// Return true if the buffer is loaded. Used for async load/unload. -bool CBufferDSound::isBufferLoaded() const -{ - return _Data != NULL; -} - - -/// Set the storage mode of this buffer, call before filling this buffer. Storage mode is always software if OptionSoftwareBuffer is enabled. Default is auto. -void CBufferDSound::setStorageMode(TStorageMode /* storageMode */) -{ - // software buffering, no hardware storage mode available -} - -/// Get the storage mode of this buffer. -IBuffer::TStorageMode CBufferDSound::getStorageMode() -{ - // always uses software buffers - return IBuffer::StorageSoftware; -} - -} // NLSOUND - - - diff --git a/code/nel/src/sound/driver/dsound/buffer_dsound.h b/code/nel/src/sound/driver/dsound/buffer_dsound.h deleted file mode 100644 index fed09c413..000000000 --- a/code/nel/src/sound/driver/dsound/buffer_dsound.h +++ /dev/null @@ -1,102 +0,0 @@ -// NeL - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as -// published by the Free Software Foundation, either version 3 of the -// License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -#ifndef NL_BUFFER_DSOUND_H -#define NL_BUFFER_DSOUND_H - -#include "nel/sound/driver/buffer.h" - -namespace NLSOUND { - -/** - * Buffer for the DSound implementation of the audio driver. - * - * A buffer represents a sound file loaded in RAM. - * - * \author Peter Hanappe, Olivier Cado - * \author Nevrax France - * \date 2002 - */ -class CBufferDSound : public IBuffer -{ -public: - /// Constructor - CBufferDSound(); - - /// Destructor - virtual ~CBufferDSound(); - - /// Return a pointer to the sample data - inline const uint8 *getData() const { return _Data; } - - /** Preset the name of the buffer. Used for async loading to give a name - * before the buffer is effectivly loaded. - * If the name after loading of the buffer doesn't match the preset name, - * the load will assert. - */ - virtual void setName(NLMISC::TStringId bufferName); - /// Return the name of this buffer - virtual NLMISC::TStringId getName() const; - - /// Set the sample format. (channels = 1, 2, ...; bitsPerSample = 8, 16; frequency = samples per second, 44100, ...) - virtual void setFormat(TBufferFormat format, uint8 channels, uint8 bitsPerSample, uint32 frequency); - /// Return the sample format information. - virtual void getFormat(TBufferFormat &format, uint8 &channels, uint8 &bitsPerSample, uint32 &frequency) const; - /// Set the storage mode of this buffer, call before filling this buffer. Storage mode is always software if OptionSoftwareBuffer is enabled. Default is auto. - virtual void setStorageMode(TStorageMode storageMode = IBuffer::StorageAuto); - /// Get the storage mode of this buffer. - virtual TStorageMode getStorageMode(); - - /// Get a writable pointer to the buffer of specified size. Use capacity to specify the required bytes. Returns NULL in case of failure. It is only guaranteed that the original data is still available when using StorageSoftware and the specified size is not larger than the size specified in the last lock. Call setStorageMode() and setFormat() first. - virtual uint8 *lock(uint capacity); - /// Notify that you are done writing to this buffer, so it can be copied over to hardware if needed. Set size to the number of bytes actually written to the buffer. Returns true if ok. - virtual bool unlock(uint size); - /// Copy the data with specified size into the buffer. A readable local copy is only guaranteed when OptionLocalBufferCopy is set. Returns true if ok. - virtual bool fill(const uint8 *src, uint size); - - /// Return the size of the buffer, in bytes. - virtual uint getSize() const; - /// Return the duration (in ms) of the sample in the buffer. - virtual float getDuration() const; - /// Return true if the buffer is stereo (multi-channel), false if mono. - virtual bool isStereo() const; - /// Return true if the buffer is loaded. Used for async load/unload. - virtual bool isBufferLoaded() const; - -private: - NLMISC::TStringId _Name; - /// The sample data in this buffer. - uint8 *_Data; - /// The capacity of the buffer - uint _Capacity; - /// The size of the data in the buffer - uint _Size; - TSampleFormat _Format; - uint _Freq; - -#if USE_LOCDEFER - LPDIRECTSOUNDBUFFER _SecondaryBuffer; - LPDIRECTSOUND3DBUFFER _3DBuffer; -#endif - -}; - - -} // NLSOUND - - -#endif // NL_BUFFER_DSOUND_H - diff --git a/code/nel/src/sound/driver/dsound/driver_dsound.def b/code/nel/src/sound/driver/dsound/driver_dsound.def deleted file mode 100644 index 41e42cf9d..000000000 --- a/code/nel/src/sound/driver/dsound/driver_dsound.def +++ /dev/null @@ -1,4 +0,0 @@ -EXPORTS NLSOUND_createISoundDriverInstance -EXPORTS NLSOUND_interfaceVersion -EXPORTS NLSOUND_outputProfile -EXPORTS NLSOUND_getDriverType diff --git a/code/nel/src/sound/driver/dsound/listener_dsound.cpp b/code/nel/src/sound/driver/dsound/listener_dsound.cpp deleted file mode 100644 index d8c81b58b..000000000 --- a/code/nel/src/sound/driver/dsound/listener_dsound.cpp +++ /dev/null @@ -1,376 +0,0 @@ -// NeL - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as -// published by the Free Software Foundation, either version 3 of the -// License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -#include "stddsound.h" -#include "listener_dsound.h" -#include "sound_driver_dsound.h" - -#ifdef DEBUG_NEW -#define new DEBUG_NEW -#endif - -using namespace NLMISC; - - -namespace NLSOUND { - - -// The instance of the singleton -CListenerDSound *CListenerDSound::_Instance = NULL; - - -/* - * Constructor - */ -CListenerDSound::CListenerDSound(LPDIRECTSOUND3DLISTENER dsoundListener) //: IListener() -: _Pos(CVector::Null) -{ -#if EAX_AVAILABLE == 1 - _EAXListener = 0; -#endif - if ( _Instance == NULL ) - { - _Instance = this; - _Listener = dsoundListener; - - if (CSoundDriverDSound::instance()->getOption(ISoundDriver::OptionManualRolloff)) - { - // Manual RollOff => disable API rollOff - if ( !_Listener || FAILED(_Listener->SetRolloffFactor(DS3D_MINROLLOFFFACTOR, DS3D_DEFERRED))) - { - nlwarning("SetRolloffFactor failed"); - } - } - } - else - { - //nlerror( "Listener singleton instanciated twice" ); - } -} - - -CListenerDSound::~CListenerDSound() -{ - nldebug("Destroying DirectSound listener"); - - release(); - _Instance = NULL; -} - - -/* - * Release all DirectSound resources - */ -void CListenerDSound::release() -{ - if (_Listener != NULL) - { - _Listener->Release(); - _Listener = NULL; - } -#if EAX_AVAILABLE == 1 - if (_EAXListener != NULL) - { - _EAXListener->Release(); - _EAXListener = NULL; - } -#endif -} - - -/* - * Set the position vector (default: (0,0,0)) (3D mode only) - */ -void CListenerDSound::setPos( const NLMISC::CVector& pos ) -{ - - _Pos = pos; - // Coordinate system: conversion from NeL to OpenAL/GL: - if (_Listener != NULL) - { - if (FAILED(_Listener->SetPosition(pos.x, pos.z, pos.y, DS3D_DEFERRED))) - { - nlwarning("SetPosition failed"); - } - else - { - //nlwarning ("set listener NEL(p:%.2f/%.2f/%.2f) DS(p:%.2f/%.2f/%.2f)", pos.x, pos.y, pos.z, pos.x, pos.z, pos.y); - } - } -} - - -/** Get the position vector. - * See setPos() for details. - */ -const NLMISC::CVector &CListenerDSound::getPos() const -{ - return _Pos; -/* return; - // Coordinate system: conversion from NeL to OpenAL/GL: - if (_Listener != NULL) - { - D3DVECTOR v; - if (FAILED(_Listener->GetPosition(&v))) - { - nlwarning("GetPosition failed"); - pos.set(0.0f, 0.0f, 0.0f); - } - else - { - pos.set(v.x, v.z, v.y); - } - } - else - { - pos.set(0, 0, 0); - } -*/ -} - - -/* - * Set the velocity vector (3D mode only) - */ -void CListenerDSound::setVelocity( const NLMISC::CVector& vel ) -{ - if (_Listener != NULL) - { - if (FAILED(_Listener->SetVelocity(vel.x, vel.z, vel.y, DS3D_DEFERRED))) - { - nlwarning("SetVelocity failed"); - } - } -} - - -/* - * Get the velocity vector - */ -void CListenerDSound::getVelocity( NLMISC::CVector& vel ) const -{ - if (_Listener != NULL) - { - D3DVECTOR v; - if (FAILED(_Listener->GetVelocity(&v))) - { - nlwarning("GetVelocity failed"); - vel.set(0.0f, 0.0f, 0.0f); - } - else - { - vel.set(v.x, v.z, v.y); - } - } - else - { - vel.set(0, 0, 0); - } -} - - -/* - * Set the orientation vectors (3D mode only) - */ -void CListenerDSound::setOrientation( const NLMISC::CVector& front, const NLMISC::CVector& up ) -{ - if (_Listener != NULL) - { - if (FAILED(_Listener->SetOrientation(front.x, front.z, front.y, up.x, up.z, up.y, DS3D_DEFERRED))) - { - nlwarning("SetOrientation failed"); - } - else - { - //nlwarning ("NLSOUND: set listener orientation NEL(f:%.2f/%.2f/%.2f up:%.2f/%.2f/%.2f) DS(f:%.2f/%.2f/%.2f up:%.2f/%.2f/%.2f)", front.x, front.y, front.z, up.x, up.y, up.z, front.x, front.z, front.y, up.x, up.z, up.y); - } - } -} - - -/* - * Get the orientation vectors - */ -void CListenerDSound::getOrientation( NLMISC::CVector& front, NLMISC::CVector& up ) const -{ - if (_Listener != NULL) - { - D3DVECTOR vfront, vtop; - if (FAILED(_Listener->GetOrientation(&vfront, &vtop))) - { - nlwarning("GetOrientation failed"); - front.set(0.0f, 0.0f, 1.0f); - up.set(0.0f, 1.0f, 0.0f); - } - else - { - front.set(vfront.x, vfront.z, vfront.y); - up.set(vtop.x, vtop.z, vtop.y); - } - } - else - { - front.set(0, 0, 1); - up.set(0, 1, 0); - } -} - - -/* Set the gain (volume value inside [0 , 1]). (default: 1) - * 0.0 -> silence - * 0.5 -> -6dB - * 1.0 -> no attenuation - * values > 1 (amplification) not supported by most drivers - */ -void CListenerDSound::setGain( float gain ) -{ - CSoundDriverDSound::instance()->setGain(gain); -} - - -/* - * Get the gain - */ -float CListenerDSound::getGain() const -{ - return CSoundDriverDSound::instance()->getGain(); -} - - -/* - * Set the doppler factor (default: 1) to exaggerate or not the doppler effect - */ -void CListenerDSound::setDopplerFactor( float f ) -{ - if (_Listener != NULL) - { - if (f > DS3D_MAXDOPPLERFACTOR) - { - f = DS3D_MAXDOPPLERFACTOR; - } - else if (f < DS3D_MINDOPPLERFACTOR) - { - f = DS3D_MINDOPPLERFACTOR; - } - - if (FAILED(_Listener->SetDopplerFactor(f, DS3D_DEFERRED))) - { - nlwarning("SetDopplerFactor failed"); - } - } -} - - -/* - * Set the rolloff factor (default: 1) to scale the distance attenuation effect - */ -void CListenerDSound::setRolloffFactor( float f ) -{ - // Works only in API rolloff mode - nlassert(!CSoundDriverDSound::instance()->getOption(ISoundDriver::OptionManualRolloff)); - - if (!CSoundDriverDSound::instance()->getOption(ISoundDriver::OptionManualRolloff)) - { - if (_Listener != NULL) - { - clamp(f, DS3D_MINROLLOFFFACTOR, DS3D_MAXROLLOFFFACTOR); - if (FAILED(_Listener->SetRolloffFactor(f, DS3D_DEFERRED))) - { - nlwarning("SetRolloffFactor failed"); - } - } - } -} - - -float CListenerDSound::getRolloffFactor() -{ - // Works only in API rolloff mode - nlassert(!CSoundDriverDSound::instance()->instance()->getOption(ISoundDriver::OptionManualRolloff)); - - if (!CSoundDriverDSound::instance()->instance()->getOption(ISoundDriver::OptionManualRolloff)) - { - if (_Listener != NULL) - { - float f; - _Listener->GetRolloffFactor(&f); - return f; - } - } - - return 1.f; -} - - -void CListenerDSound::commit3DChanges() -{ - if (_Listener != NULL) - { - _Listener->CommitDeferredSettings(); - } -} - - -/* - * Set DSPROPERTY_EAXLISTENER_ENVIRONMENT and DSPROPERTY_EAXLISTENER_ENVIRONMENTSIZE if EAX available (see EAX listener properties) - */ -#if EAX_AVAILABLE == 1 -void CListenerDSound::setEnvironment(uint env, float size) -{ - if (_EAXListener == NULL) - { - _EAXListener = CSoundDriverDSound::instance()->createPropertySet(NULL); - } - if ( _EAXListener != NULL ) - { - HRESULT res = _EAXListener->Set( DSPROPSETID_EAX_ListenerProperties, DSPROPERTY_EAXLISTENER_ENVIRONMENT, NULL, 0, &env, sizeof(unsigned long) ); - if (res != S_OK) - nlwarning("Setting EAX environment #%u fail : %x", env, res); - res = _EAXListener->Set( DSPROPSETID_EAX_ListenerProperties, DSPROPERTY_EAXLISTENER_ENVIRONMENTSIZE, NULL, 0, &size, sizeof(float) ); - if (res != S_OK) - nlwarning("Setting EAX environment size %f fail : %x", size, res); - } -#else -void CListenerDSound::setEnvironment(uint /* env */, float /* size */) -{ -#endif -} - - -/* - * Set any EAX listener property if EAX available - */ -#if EAX_AVAILABLE -void CListenerDSound::setEAXProperty(uint prop, void *value, uint valuesize) -{ - if (_EAXListener == NULL) - { - _EAXListener = CSoundDriverDSound::instance()->createPropertySet(NULL); - } - if ( _EAXListener != NULL ) - { - HRESULT res = _EAXListener->Set(DSPROPSETID_EAX_ListenerProperties, prop, NULL, 0, value, valuesize ); - if (res != S_OK) - nlwarning("Setting EAX listener prop #%d fail : %x", prop, res); - } -#else -void CListenerDSound::setEAXProperty(uint /* prop */, void * /* value */, uint /* valuesize */) -{ -#endif -} - - -} // NLSOUND diff --git a/code/nel/src/sound/driver/dsound/listener_dsound.h b/code/nel/src/sound/driver/dsound/listener_dsound.h deleted file mode 100644 index fe8872cc2..000000000 --- a/code/nel/src/sound/driver/dsound/listener_dsound.h +++ /dev/null @@ -1,132 +0,0 @@ -// NeL - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as -// published by the Free Software Foundation, either version 3 of the -// License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -#ifndef NL_LISTENER_DSOUND_H -#define NL_LISTENER_DSOUND_H - -#include "nel/sound/driver/listener.h" - -namespace NLSOUND { - - -/** - * DirectSound listener. - * - * For arguments as 3D vectors, use the NeL vector coordinate system - * (not OpenAL/OpenGL's one). - * - * \author Peter Hanappe, Olivier Cado - * \author Nevrax France - * \date 2002 - */ -class CListenerDSound : public IListener -{ -friend class CSoundDriverDSound; - -public: - - /// Constructor - CListenerDSound(LPDIRECTSOUND3DLISTENER dsoundListener); - - /// Deconstructor - virtual ~CListenerDSound(); - - /// Return the instance of the singleton - static CListenerDSound* instance() { return _Instance; } - - /// \name Listener properties - //@{ - - /// Set the position vector (default: (0,0,0)) (3D mode only) - virtual void setPos( const NLMISC::CVector& pos ); - - /** Get the position vector. - * See setPos() for details. - */ - virtual const NLMISC::CVector &getPos() const; - - /// Set the velocity vector (3D mode only) (default: (0,0,0)) - virtual void setVelocity( const NLMISC::CVector& vel ); - - /// Get the velocity vector - virtual void getVelocity( NLMISC::CVector& vel ) const; - - /// Set the orientation vectors (3D mode only) (default: (0,1,0), (0,0,1)) - virtual void setOrientation( const NLMISC::CVector& front, const NLMISC::CVector& up ); - - /// Get the orientation vectors - virtual void getOrientation( NLMISC::CVector& front, NLMISC::CVector& up ) const; - - /** Set the gain (volume value inside [0 , 1]). (default: 1) - * 0.0 -> silence - * 0.5 -> -6dB - * 1.0 -> no attenuation - * values > 1 (amplification) not supported by most drivers - */ - virtual void setGain( float gain ); - - /// Get the gain - virtual float getGain() const; - //@} - - /// \name Global properties - //@{ - - /// Set the doppler factor (default: 1) to exaggerate or not the doppler effect - virtual void setDopplerFactor( float f ); - - /// Set the rolloff factor (default: 1) to scale the distance attenuation effect - virtual void setRolloffFactor( float f ); - - /// Return the rolloff factor - virtual float getRolloffFactor(); - - /// Set DSPROPERTY_EAXLISTENER_ENVIRONMENT and DSPROPERTY_EAXLISTENER_ENVIRONMENTSIZE if EAX available (see EAX listener properties) - virtual void setEnvironment( uint env, float size=7.5f ); - - /// Set any EAX listener property if EAX available - virtual void setEAXProperty( uint prop, void *value, uint valuesize ); - //@} - - /// Commit any changes to the 3D environment - void commit3DChanges(); - - -private: - - /// Release all DirectSound resources - void release(); - - /// The instance of the singleton - static CListenerDSound *_Instance; - - /// The DirectSound listener interface - LPDIRECTSOUND3DLISTENER _Listener; - - // TMP : TEST - NLMISC::CVector _Pos; - -#if EAX_AVAILABLE == 1 - LPKSPROPERTYSET _EAXListener; -#endif -}; - - -} // NLSOUND - - -#endif // NL_LISTENER_DSOUND_H - diff --git a/code/nel/src/sound/driver/dsound/resources.rc b/code/nel/src/sound/driver/dsound/resources.rc deleted file mode 100644 index 31bf52aed..000000000 --- a/code/nel/src/sound/driver/dsound/resources.rc +++ /dev/null @@ -1,37 +0,0 @@ -#include -#include "config.h" - -VS_VERSION_INFO VERSIONINFO -FILEVERSION NL_VERSION_RC -PRODUCTVERSION NL_VERSION_RC -FILEFLAGSMASK VS_FFI_FILEFLAGSMASK -#ifdef _DEBUG -FILEFLAGS VS_FF_DEBUG -#else -FILEFLAGS 0x0L -#endif -FILEOS VOS_NT_WINDOWS32 -FILETYPE VFT_DLL -FILESUBTYPE 0x0L -BEGIN - BLOCK "StringFileInfo" - BEGIN - BLOCK "040904b0" - BEGIN - VALUE "FileDescription", "NeL DirectSound driver" - VALUE "FileVersion", NL_VERSION - VALUE "LegalCopyright", COPYRIGHT -#ifdef _DEBUG - VALUE "OriginalFilename", "nel_drv_dsound_win_d.dll" -#else - VALUE "OriginalFilename", "nel_drv_dsound_win_r.dll" -#endif - VALUE "ProductName", "Ryzom Core" - VALUE "ProductVersion", NL_VERSION - END - END - BLOCK "VarFileInfo" - BEGIN - VALUE "Translation", 0x409, 1252 - END -END diff --git a/code/nel/src/sound/driver/dsound/sound_driver_dsound.cpp b/code/nel/src/sound/driver/dsound/sound_driver_dsound.cpp deleted file mode 100644 index d95b80ca0..000000000 --- a/code/nel/src/sound/driver/dsound/sound_driver_dsound.cpp +++ /dev/null @@ -1,1110 +0,0 @@ -// NeL - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as -// published by the Free Software Foundation, either version 3 of the -// License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -#include "stddsound.h" - -// The one and only INITGUID -#define INITGUID - -#ifdef DIRECTSOUND_VERSION - #undef DIRECTSOUND_VERSION -#endif -#define DIRECTSOUND_VERSION 0x0800 - -#include "nel/sound/driver/sound_driver.h" - -#include "nel/misc/hierarchical_timer.h" -#include "nel/misc/dynloadlib.h" -#include "sound_driver_dsound.h" -#include "listener_dsound.h" - -#ifdef DEBUG_NEW -#define new DEBUG_NEW -#endif - -using namespace std; -using namespace NLMISC; - - -namespace NLSOUND { - -CSoundDriverDSound* CSoundDriverDSound::_Instance = NULL; -uint32 CSoundDriverDSound::_TimerPeriod = 100; -HWND CSoundDriverWnd = 0; - -/// import io proc def from buffer_dsound. -LRESULT NelIOProc(LPSTR lpmmioinfo, UINT uMsg, LONG lParam1, LONG lParam2); - -#ifndef NL_STATIC - -HINSTANCE CSoundDriverDllHandle = 0; - -// ****************************************************************** -// The main entry of the DLL. It's used to get a hold of the hModule handle. -BOOL WINAPI DllMain(HANDLE hModule, DWORD /* ul_reason_for_call */, LPVOID /* lpReserved */) -{ - CSoundDriverDllHandle = (HINSTANCE) hModule; - return TRUE; -} - -class CSoundDriverDSoundNelLibrary : public NLMISC::INelLibrary { - void onLibraryLoaded(bool /* firstTime */) { } - void onLibraryUnloaded(bool /* lastTime */) { } -}; -NLMISC_DECL_PURE_LIB(CSoundDriverDSoundNelLibrary) - -#endif /* #ifndef NL_STATIC */ - - -// ****************************************************************** -// The event handling procedure of the invisible window created below. - -LRESULT CALLBACK CSoundDriverCreateWindowProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) -{ - return DefWindowProc(hWnd, message, wParam, lParam); -} - -// ****************************************************************** - -#ifdef NL_STATIC -ISoundDriver* createISoundDriverInstanceDSound -#else -__declspec(dllexport) ISoundDriver *NLSOUND_createISoundDriverInstance -#endif - (ISoundDriver::IStringMapperProvider *stringMapper) -{ -#ifdef NL_STATIC - HINSTANCE CSoundDriverDllHandle = (HINSTANCE)GetModuleHandle(NULL); -#endif - - static bool Registered = false; - - if (!Registered) - { - // Don't ask me why we have to create a window to do sound! - // echo | mail support@microsoft.com -s "F#%@cking window" - WNDCLASS myClass; - myClass.hCursor = LoadCursor( NULL, IDC_ARROW ); - myClass.hIcon = NULL; - myClass.lpszMenuName = (LPSTR) NULL; - myClass.lpszClassName = (LPSTR) "CSoundDriver"; - myClass.hbrBackground = (HBRUSH)(COLOR_WINDOW); - myClass.hInstance = CSoundDriverDllHandle; - myClass.style = CS_GLOBALCLASS; - myClass.lpfnWndProc = CSoundDriverCreateWindowProc; - myClass.cbClsExtra = 0; - myClass.cbWndExtra = 0; - - if (!RegisterClass(&myClass)) - { - nlwarning("Failed to initialize the sound driver (RegisterClass)"); - return 0; - } - - Registered = true; - } - - CSoundDriverWnd = CreateWindow((LPSTR) "CSoundDriver", (LPSTR) "CSoundDriver", WS_OVERLAPPEDWINDOW, - CW_USEDEFAULT, CW_USEDEFAULT, 400, 300, (HWND) NULL, (HMENU) NULL, - CSoundDriverDllHandle, (LPSTR) NULL); - - if (CSoundDriverWnd == NULL) - { - nlwarning("Failed to initialize the sound driver (CreateWindow)"); - return 0; - } - -/* // install the NeL Io routine - LPMMIOPROC ret = mmioInstallIOProc(mmioStringToFOURCC("NEL_", 0), (LPMMIOPROC)NelIOProc, MMIO_INSTALLPROC); - nlassert(ret != 0); -*/ - - return new CSoundDriverDSound(stringMapper); -} - -// ****************************************************************** - -#ifdef NL_STATIC -uint32 interfaceVersionDSound() -#else -__declspec(dllexport) uint32 NLSOUND_interfaceVersion() -#endif -{ - return ISoundDriver::InterfaceVersion; -} - -// ****************************************************************** - -#ifdef NL_STATIC -void outputProfileDSound -#else -__declspec(dllexport) void NLSOUND_outputProfile -#endif - (string &out) -{ - CSoundDriverDSound::instance()->writeProfile(out); -} - -// ****************************************************************** - -#ifdef NL_STATIC -ISoundDriver::TDriver getDriverTypeDSound() -#else -__declspec(dllexport) ISoundDriver::TDriver NLSOUND_getDriverType() -#endif -{ - return ISoundDriver::DriverDSound; -} - -// ****************************************************************** - - - - -// ****************************************************************** - -CSoundDriverDSound::CSoundDriverDSound(ISoundDriver::IStringMapperProvider *stringMapper) -: _StringMapper(stringMapper) -{ - if ( _Instance == NULL ) - { - _Instance = this; - - _DirectSound = NULL; - _PrimaryBuffer = NULL; - _SourceCount = 0; - _TimerID = NULL; - -#if NLSOUND_PROFILE - _TimerIntervalCount = 0; - _TotalTime = 0.0; - _TotalUpdateTime = 0.0; - _UpdateCount = 0; - _UpdateSources = 0; - _UpdateExec = 0; -#endif - - } - else - { - nlerror("Sound driver singleton instanciated twice"); - } -} - - -#if EAX_AVAILABLE == 1 - -LPKSPROPERTYSET CSoundDriverDSound::createPropertySet(CSourceDSound *source) -{ - if (_Sources.empty()) - return NULL; - - LPDIRECTSOUND3DBUFFER8 d3dBuffer; - if (source == NULL) - d3dBuffer = (*_Sources.begin())->_3DBuffer; - else - { - d3dBuffer = source->_3DBuffer; - } - LPKSPROPERTYSET propertySet; - d3dBuffer->QueryInterface(IID_IKsPropertySet, (void**) &propertySet); - - // some checking code - { - if (propertySet != 0) - { - char *listenerProperties[] = - { - "DSPROPERTY_EAXLISTENER_NONE", - "DSPROPERTY_EAXLISTENER_ALLPARAMETERS", - "DSPROPERTY_EAXLISTENER_ROOM", - "DSPROPERTY_EAXLISTENER_ROOMHF", - "DSPROPERTY_EAXLISTENER_ROOMROLLOFFFACTOR", - "DSPROPERTY_EAXLISTENER_DECAYTIME", - "DSPROPERTY_EAXLISTENER_DECAYHFRATIO", - "DSPROPERTY_EAXLISTENER_REFLECTIONS", - "DSPROPERTY_EAXLISTENER_REFLECTIONSDELAY", - "DSPROPERTY_EAXLISTENER_REVERB", - "DSPROPERTY_EAXLISTENER_REVERBDELAY", - "DSPROPERTY_EAXLISTENER_ENVIRONMENT", - "DSPROPERTY_EAXLISTENER_ENVIRONMENTSIZE", - "DSPROPERTY_EAXLISTENER_ENVIRONMENTDIFFUSION", - "DSPROPERTY_EAXLISTENER_AIRABSORPTIONHF", - "DSPROPERTY_EAXLISTENER_FLAGS" - }; - uint i; - for (i=DSPROPERTY_EAXLISTENER_NONE; i<= DSPROPERTY_EAXLISTENER_FLAGS; ++i) - { - ULONG ulSupport = 0; - propertySet->QuerySupport(DSPROPSETID_EAX_ListenerProperties, i, &ulSupport); - if ( (ulSupport&(KSPROPERTY_SUPPORT_GET|KSPROPERTY_SUPPORT_SET)) != (KSPROPERTY_SUPPORT_GET|KSPROPERTY_SUPPORT_SET) ) - { -// nlwarning("CSoundDriverDSound::createPropertySet : listener property %s not supported", listenerProperties[i]); - } - } - - char *bufferProperties[] = - { - "DSPROPERTY_EAXBUFFER_NONE", - "DSPROPERTY_EAXBUFFER_ALLPARAMETERS", - "DSPROPERTY_EAXBUFFER_DIRECT", - "DSPROPERTY_EAXBUFFER_DIRECTHF", - "DSPROPERTY_EAXBUFFER_ROOM", - "DSPROPERTY_EAXBUFFER_ROOMHF", - "DSPROPERTY_EAXBUFFER_ROOMROLLOFFFACTOR", - "DSPROPERTY_EAXBUFFER_OBSTRUCTION", - "DSPROPERTY_EAXBUFFER_OBSTRUCTIONLFRATIO", - "DSPROPERTY_EAXBUFFER_OCCLUSION", - "DSPROPERTY_EAXBUFFER_OCCLUSIONLFRATIO", - "DSPROPERTY_EAXBUFFER_OCCLUSIONROOMRATIO", - "DSPROPERTY_EAXBUFFER_OUTSIDEVOLUMEHF", - "DSPROPERTY_EAXBUFFER_AIRABSORPTIONFACTOR", - "DSPROPERTY_EAXBUFFER_FLAGS" - }; - - for (i=DSPROPERTY_EAXBUFFER_NONE; i<=DSPROPERTY_EAXBUFFER_FLAGS; ++i) - { - ULONG ulSupport = 0; - propertySet->QuerySupport(DSPROPSETID_EAX_BufferProperties, i, &ulSupport); - if ( (ulSupport&(KSPROPERTY_SUPPORT_GET|KSPROPERTY_SUPPORT_SET)) != (KSPROPERTY_SUPPORT_GET|KSPROPERTY_SUPPORT_SET) ) - { -// nlwarning("CSoundDriverDSound::createPropertySet : buffer property %s not supported", bufferProperties[i]); - } - } - } - else - { - nlwarning("CSoundDriverDSound::createPropertySet : propertie set not available !"); - } - } - - return propertySet; -} - -#endif // EAX_AVAILABLE - - -// ****************************************************************** - -class CDeviceDescription -{ -public: - - static CDeviceDescription* _List; - - CDeviceDescription(LPGUID guid, const char* descr) - { - _Guid = guid; - _Description = strdup(descr); - _Next = _List; - _List = this; - } - - virtual ~CDeviceDescription() - { - if (_Description) - { - free(_Description); - } - if (_Next) - { - delete _Next; - } - } - - char* _Description; - CDeviceDescription* _Next; - LPGUID _Guid; -}; - -CDeviceDescription* CDeviceDescription::_List = 0; - - -BOOL CALLBACK CSoundDriverDSoundEnumCallback(LPGUID guid, LPCSTR description, PCSTR /* module */, LPVOID /* context */) -{ - new CDeviceDescription(guid, description); - return TRUE; -} - -// ****************************************************************** - -CSoundDriverDSound::~CSoundDriverDSound() -{ - nldebug("Destroying DirectSound driver"); - - if (_TimerID != NULL) - { - timeKillEvent(_TimerID); - timeEndPeriod(_TimerResolution); - } - - - // Assure that the remaining sources have released all their DSBuffers - // before closing down DirectSound - set::iterator iter; - - for (iter = _Sources.begin(); iter != _Sources.end(); iter++) - { - (*iter)->release(); - } - - - // Assure that the listener has released all resources before closing - // down DirectSound - if (CListenerDSound::instance() != 0) - { - CListenerDSound::instance()->release(); - } - - - if (_PrimaryBuffer != NULL) - { - _PrimaryBuffer->Release(); - _PrimaryBuffer = NULL; - } - - if (_DirectSound != NULL) - { - _DirectSound->Release(); - _DirectSound = NULL; - } - - _Instance = 0; - - // free the enumerated list - if (CDeviceDescription::_List) - { - delete CDeviceDescription::_List; - CDeviceDescription::_List = NULL; - } -} - -/// Return a list of available devices for the user. The value at index 0 is empty, and is used for automatic device selection. -void CSoundDriverDSound::getDevices(std::vector &devices) -{ - devices.push_back(""); // empty -} - -/// Initialize the driver with a user selected device. If device.empty(), the default or most appropriate device is used. -void CSoundDriverDSound::initDevice(const std::string &device, ISoundDriver::TSoundOptions options) -{ - // list of supported options in this driver - // disable effects if no eax, no buffer streaming - const sint supportedOptions = - OptionAllowADPCM -#if EAX_AVAILABLE - | OptionEnvironmentEffects -#endif - | OptionSoftwareBuffer - | OptionManualRolloff - | OptionLocalBufferCopy; - - // list of forced options in this driver - // always have local copy - const sint forcedOptions = - OptionLocalBufferCopy; - - // set the options - _Options = (TSoundOptions)(((sint)options & supportedOptions) | forcedOptions); - - if (FAILED(DirectSoundEnumerate(CSoundDriverDSoundEnumCallback, this))) - { - throw ESoundDriver("Failed to enumerate the DirectSound devices"); - } - - // Create a DirectSound object and set the cooperative level. -#if EAX_AVAILABLE - if (getOption(OptionEnvironmentEffects)) - { - if (EAXDirectSoundCreate8(NULL, &_DirectSound, NULL) != DS_OK) - { - throw ESoundDriver("Failed to create the DirectSound object from EAX proxy funtion"); - } - } - else -#endif - { - if (DirectSoundCreate(NULL, &_DirectSound, NULL) != DS_OK) - { - throw ESoundDriver("Failed to create the DirectSound object"); - } - } - - - if (_DirectSound->SetCooperativeLevel(CSoundDriverWnd, DSSCL_PRIORITY) != DS_OK) - { - throw ESoundDriver("Failed to set the cooperative level"); - } - - - // Analyse the capabilities of the sound driver/device - - _Caps.dwSize = sizeof(_Caps); - - if (_DirectSound->GetCaps(&_Caps) != DS_OK) - { - throw ESoundDriver("Failed to query the sound device caps"); - } - - - // Create primary buffer - - DSBUFFERDESC desc; - - ZeroMemory(&desc, sizeof(DSBUFFERDESC)); - desc.dwSize = sizeof(DSBUFFERDESC); - - - // First, try to allocate a 3D hardware buffer. - // If we can't get a 3D hardware buffer, use a 2D hardware buffer. - // As last option, use a 2D software buffer. - - // check if wa can honor eax request - if (countHw3DBuffers() > 10) - { - _UseEAX = getOption(OptionEnvironmentEffects); - } - else - { - // not enougth hardware buffer, can't use eax - _UseEAX = false; - } - - if (countHw3DBuffers() > 0) - { - nldebug("Primary buffer: Allocating 3D buffer in hardware"); - desc.dwFlags = DSBCAPS_PRIMARYBUFFER | DSBCAPS_LOCHARDWARE | DSBCAPS_CTRL3D | DSBCAPS_CTRLVOLUME; - } - else - { - nldebug("Primary buffer: Allocating 3D buffer in software"); - desc.dwFlags = DSBCAPS_PRIMARYBUFFER | DSBCAPS_LOCSOFTWARE | DSBCAPS_CTRL3D | DSBCAPS_CTRLVOLUME; -// desc.guid3DAlgorithm = DS3DALG_NO_VIRTUALIZATION; - } - - - - HRESULT res = _DirectSound->CreateSoundBuffer(&desc, &_PrimaryBuffer, NULL); - - if (res != DS_OK && res != DS_NO_VIRTUALIZATION) - { - - nlwarning("Primary buffer: Failed to create a buffer with 3D capabilities."); - - ZeroMemory(&desc, sizeof(DSBUFFERDESC)); - desc.dwSize = sizeof(DSBUFFERDESC); - - if (countHw2DBuffers() > 0) - { - nldebug("Primary buffer: Allocating 2D buffer in hardware"); - desc.dwFlags = DSBCAPS_PRIMARYBUFFER | DSBCAPS_LOCHARDWARE | DSBCAPS_CTRLVOLUME; - } - else - { - nldebug("Primary buffer: Allocating 2D buffer in software"); - desc.dwFlags = DSBCAPS_PRIMARYBUFFER | DSBCAPS_LOCSOFTWARE | DSBCAPS_CTRLVOLUME; - } - - if (_DirectSound->CreateSoundBuffer(&desc, &_PrimaryBuffer, NULL) != DS_OK) - { - throw ESoundDriver("Failed to create the primary buffer"); - } - } - - - // Set the format of the primary buffer - - WAVEFORMATEX format; - - format.cbSize = sizeof(WAVEFORMATEX); - - // Make sure the sound card accepts the default settings. - // For now, only the default settings are accepted. Fallback - // strategy will be handled later. - - if ((_Caps.dwMinSecondarySampleRate > 22050) && (22050 > _Caps.dwMaxSecondarySampleRate)) { - throw ESoundDriver("Unsupported sample rate range"); - } - - if ((_Caps.dwFlags & DSCAPS_PRIMARY16BIT) == 0) { - throw ESoundDriver("Unsupported sample size [16bits]"); - } - - format.wBitsPerSample = 16; - format.nChannels = 1; - format.nSamplesPerSec = 22050; - format.nBlockAlign = format.nChannels * format.wBitsPerSample / 8; - format.nAvgBytesPerSec = format.nSamplesPerSec * format.nBlockAlign; - format.wFormatTag = WAVE_FORMAT_PCM; - - - if (_PrimaryBuffer->SetFormat(&format) != DS_OK) - { - throw ESoundDriver("Failed to create set the format of the primary buffer"); - } - - // Fill the buffer with silence -/* LPVOID ptr; - DWORD bytes; - - HRESULT hr = _PrimaryBuffer->Lock(0, 0, &ptr, &bytes, NULL, NULL, DSBLOCK_ENTIREBUFFER); - if (FAILED(hr)) - { - switch (hr) - { - case DSERR_BUFFERLOST: - throw ESoundDriver("Failed to lock the DirectSound primary buffer: DSERR_BUFFERLOST"); - case DSERR_INVALIDCALL: - throw ESoundDriver("Failed to lock the DirectSound primary buffer: DSERR_INVALIDCALL"); - case DSERR_INVALIDPARAM: - throw ESoundDriver("Failed to lock the DirectSound primary buffer: DSERR_INVALIDPARAM"); - case DSERR_PRIOLEVELNEEDED: - throw ESoundDriver("Failed to lock the DirectSound primary buffer: DSERR_PRIOLEVELNEEDED"); - default: - throw ESoundDriver("Failed to lock the DirectSound primary buffer: unknown error"); - - } - } - - memset(ptr, 0, bytes); - - _PrimaryBuffer->Unlock(ptr, bytes, 0, 0); -*/ - - uint32 numBuffers = countHw3DBuffers(); - if (numBuffers == 0) - { - numBuffers = 31; - } - - /* - _Sources = new CSourceDSound*[numBuffers]; - - - for (uint i = 0; i < numBuffers; i++) - { - _Sources[i] = 0; - } - - try - { - for (i = 0; i < numBuffers; i++) - { - _Sources[i] = new CSourceDSound(i); - _Sources[i]->init(_DirectSound); - _SourceCount++; - } - } - catch (const ESoundDriver& e) - { - // Okay, here's the situation: I'm listening to WinAmp while debugging. - // The caps told me there were 31 buffers available. In reality, there were - // only 30 available because WinAmp was using one. Somehow DirectSound didn't - // notice. So when creating buffer 31, an exception was thrown. - // If something like this happens, don't bother and go on with the buffers we've - // got. If no buffers are created at all, throw the exception again. - - if (_Sources == 0) - { - throw e; - } - } - -*/ - - TIMECAPS tcaps; - - timeGetDevCaps(&tcaps, sizeof(TIMECAPS)); - _TimerResolution = (tcaps.wPeriodMin > 10)? tcaps.wPeriodMin : 10; - timeBeginPeriod(_TimerResolution); - -#if NLSOUND_PROFILE - for (uint i = 0; i < 1024; i++) - { - _TimerInterval[i] = 0; - } - - _TimerDate = CTime::getPerformanceTime(); -#endif - - _TimerID = timeSetEvent(_TimerPeriod, 0, &CSoundDriverDSound::TimerCallback, (DWORD_PTR)this, TIME_CALLBACK_FUNCTION | TIME_PERIODIC); - - if (_TimerID == NULL) - { - throw ESoundDriver("Failed to create the timer"); - } -} - -/// Return options that are enabled (including those that cannot be disabled on this driver). -ISoundDriver::TSoundOptions CSoundDriverDSound::getOptions() -{ - return _Options; -} - -/// Return if an option is enabled (including those that cannot be disabled on this driver). -bool CSoundDriverDSound::getOption(ISoundDriver::TSoundOptions option) -{ - return ((uint)_Options & (uint)option) == (uint)option; -} - -// ****************************************************************** - -uint CSoundDriverDSound::countMaxSources() -{ - // Try the hardware 3d buffers first - uint n = countHw3DBuffers(); - if (n > 0) - { - return n; - } - - // If not, try the hardware 2d buffers first - n = countHw2DBuffers(); - if (n > 0) - { - return n; - } - - // Okay, we'll use 32 software buffers - return 32; -} - -// ****************************************************************** - -void CSoundDriverDSound::writeProfile(string& out) -{ - // Write the available sound devices - CDeviceDescription* list = CDeviceDescription::_List; - while (list) { - out += "\t" + string(list->_Description) + "\n"; - list = list->_Next; - } - - // Write the buffers sizes - out += "\tBuffer size: " + toString ((int)CSourceDSound::_SecondaryBufferSize) + "\n"; - out += "\tCopy size: " + toString ((int)CSourceDSound::_UpdateCopySize) + "\n"; - out += "\tSwap size: " + toString ((int)CSourceDSound::_SwapCopySize) + "\n"; - - // Write the number of hardware buffers - DSCAPS caps; - caps.dwSize = sizeof(caps); - _DirectSound->GetCaps(&caps); - - out += "\t3d hw buffers: " + toString ((uint32)caps.dwMaxHw3DAllBuffers) + "\n"; - out += "\t2d hw buffers: " + toString ((uint32)caps.dwMaxHwMixingAllBuffers) + "\n"; - - // Write the number of hardware buffers -#if NLSOUND_PROFILE - out += "\tUpdate time total --- " + toString (getAverageUpdateTime()) + "\n"; - out += "\tUpdate time source --- " + toString (CSourceDSound::getAverageUpdateTime()) + "\n"; - out += "\tUpdate --- t: " + toString (CSourceDSound::getAverageCumulTime()); - out += "\t - p: " + toString (CSourceDSound::getAveragePosTime()); - out += "\t - l: " + toString (CSourceDSound::getAverageLockTime()); - out += "\t - c: " + toString (CSourceDSound::getAverageCopyTime()); - out += "\t - u: " + toString (CSourceDSound::getAverageUnlockTime()) + "\n"; - out += "\tUpdate percentage: --- " + toString (getUpdatePercentage()) + "\n"; - out += "\tUpdate num sources --- " + toString ((int)getAverageUpdateSources()) + "\n"; - out += "\tUpdate byte size --- " + toString (CSourceDSound::getAverageUpdateSize()) + "\n"; - out += "\tSwap time --- " + toString (CSourceDSound::getTestAverage()) + "\n"; - out += "\tSrc --- " + toString (countPlayingSources()) + "\n"; -#endif -} - - -void CALLBACK CSoundDriverDSound::TimerCallback(UINT /* uID */, UINT /* uMsg */, DWORD_PTR dwUser, DWORD_PTR /* dw1 */, DWORD_PTR /* dw2 */) -{ - // a little speed check - static NLMISC::TTime lastUpdate = NLMISC::CTime::getLocalTime(); - NLMISC::TTime now = NLMISC::CTime::getLocalTime(); - - if (now - lastUpdate > _TimerPeriod * 2) - { -// nlwarning("CSoundDriverDSound::TimerCallback : no update since %u millisec (nominal update = %u", uint32(now-lastUpdate), uint32(_TimerPeriod)); - } - else - { -// nldebug("Callback delay = %u ms", uint32(now-lastUpdate)); - } - - lastUpdate = now; - - - CSoundDriverDSound* driver = (CSoundDriverDSound*) dwUser; - driver->update(); -} - -// ****************************************************************** - -void CSoundDriverDSound::update() -{ - H_AUTO(NLSOUND_DSoundUpdate) -#if NLSOUND_PROFILE - TTicks tnow = CTime::getPerformanceTime(); -#endif - - NLMISC::TTime now = NLMISC::CTime::getLocalTime(); - - set::iterator first(_Sources.begin()), last(_Sources.end()); - for (;first != last; ++first) - { - if ((*first)->needsUpdate()) - { - if ((*first)->update()) - { -#if NLSOUND_PROFILE - _UpdateSources++; -#endif - } - } - } - -/* - set::iterator iter; - - iter = _Sources.begin(); - - - if ((iter != _Sources.end()) && (*iter)->needsUpdate()) - { - while (iter != _Sources.end()) - { -// if ((*iter)->update2()) { - if ((*iter)->update()) - { -#if NLSOUND_PROFILE - _UpdateSources++; -#endif - } - iter++; - } - } - -*/ - { - NLMISC::TTime last = CTime::getLocalTime() - now; - if (last > _TimerPeriod / 2) - { - nlwarning("CSoundDriverDSound::TimerCallback : update took %u millisec", (uint32)last); - } - } - -#if NLSOUND_PROFILE - _TotalUpdateTime += 1000.0 * CTime::ticksToSecond(CTime::getPerformanceTime() - tnow); - _UpdateCount++; -#endif -} - -// ****************************************************************** - -uint CSoundDriverDSound::countHw3DBuffers() -{ - DSCAPS caps; - caps.dwSize = sizeof(caps); - - if (_DirectSound->GetCaps(&caps) != DS_OK) - { - throw ESoundDriver("Failed to query the sound device caps"); - } - - return caps.dwFreeHw3DStreamingBuffers; -} - -// ****************************************************************** - -uint CSoundDriverDSound::countHw2DBuffers() -{ - DSCAPS caps; - caps.dwSize = sizeof(caps); - - if (_DirectSound->GetCaps(&caps) != DS_OK) - { - throw ESoundDriver("Failed to query the sound device caps"); - } - - return caps.dwFreeHwMixingStreamingBuffers; -} - -// ****************************************************************** - -IListener *CSoundDriverDSound::createListener() -{ - LPDIRECTSOUND3DLISTENER dsoundListener; - - if (CListenerDSound::instance() != NULL) - { - return CListenerDSound::instance(); - } - - if (_PrimaryBuffer == 0) - { - throw ESoundDriver("Corrupt driver"); - } - - if (FAILED(_PrimaryBuffer->QueryInterface(IID_IDirectSound3DListener, (LPVOID *) &dsoundListener))) - { - nlwarning("The 3D listener interface is not available."); - return new CListenerDSound(NULL); - } - - return new CListenerDSound(dsoundListener); -} - -// ****************************************************************** - -IBuffer *CSoundDriverDSound::createBuffer() -{ - if (_PrimaryBuffer == 0) - { - throw ESoundDriver("Corrupt driver"); - } - - - // FIXME: set buffer ID - return new CBufferDSound(); -} - -// ****************************************************************** - -void CSoundDriverDSound::removeBuffer(IBuffer * /* buffer */) -{ -} - -//// ****************************************************************** -//bool CSoundDriverDSound::readWavBuffer( IBuffer *destbuffer, const std::string &name, uint8 *wavData, uint dataSize) -//{ -// return ((CBufferDSound*) destbuffer)->readWavBuffer(name, wavData, dataSize); -//} -// -//bool CSoundDriverDSound::readRawBuffer( IBuffer *destbuffer, const std::string &name, uint8 *rawData, uint dataSize, TSampleFormat format, uint32 frequency) -//{ -// return ((CBufferDSound*) destbuffer)->readRawBuffer(name, rawData, dataSize, format, frequency); -//} - - -// ****************************************************************** - -ISource *CSoundDriverDSound::createSource() -{ - if (_PrimaryBuffer == 0) - { - throw ESoundDriver("Corrupt driver"); - } - - - CSourceDSound* src = new CSourceDSound(0); - src->init(_DirectSound, _UseEAX); - _Sources.insert(src); - - return src; -} - - -// ****************************************************************** - -void CSoundDriverDSound::removeSource(ISource *source) -{ - _Sources.erase((CSourceDSound*) source); -} - -// ****************************************************************** - -void CSoundDriverDSound::commit3DChanges() -{ - CListenerDSound* listener = CListenerDSound::instance(); - listener->commit3DChanges(); - - - const CVector &origin = listener->getPos(); - - set::iterator iter; - - // We handle the volume of the source according to the distance - // ourselves. Call updateVolume() to, well..., update the volume - // according to, euh ..., the new distance! - for (iter = _Sources.begin(); iter != _Sources.end(); iter++) - { - if ((*iter)->isPlaying()) - { - (*iter)->updateVolume(origin); - } - } -} - - -// ****************************************************************** - -uint CSoundDriverDSound::countPlayingSources() -{ - uint n = 0; - set::iterator iter; - - for (iter = _Sources.begin(); iter != _Sources.end(); iter++) - { - if ((*iter)->isPlaying()) - { - n++; - } - } - - return n; -} - - -// ****************************************************************** - -void CSoundDriverDSound::setGain( float gain ) -{ - if (_PrimaryBuffer != 0) - { - if (gain < 0.00001f) - { - gain = 0.00001f; - } - - /* convert from linear amplitude to hundredths of decibels */ - LONG volume = (LONG)(100.0 * 20.0 * log10(gain)); - - if (volume < DSBVOLUME_MIN) - { - volume = DSBVOLUME_MIN; - } - else if (volume > DSBVOLUME_MAX) - { - volume = DSBVOLUME_MAX; - } - - HRESULT hr = _PrimaryBuffer->SetVolume(volume); - - if (hr != DS_OK) - { - nldebug("Failed to set the volume"); - } - } -} - -// ****************************************************************** - -float CSoundDriverDSound::getGain() -{ - if (_PrimaryBuffer != 0) - { - /* convert from hundredths of decibels to linear amplitude */ - LONG volume; - HRESULT hr = _PrimaryBuffer->GetVolume(&volume); - - if (hr != DS_OK) - { - nldebug("Failed to get the volume"); - return 1.0; - } - - return (float) pow((double)10, (double) volume / 20.0 / 100.0); - } - - return 1.0; -} - - - -#if NLSOUND_PROFILE - -// ****************************************************************** - -uint CSoundDriverDSound::countTimerIntervals() -{ - return 1024; -} - -// ****************************************************************** - -uint CSoundDriverDSound::getTimerIntervals(uint index) -{ - return _TimerInterval[index]; -} - -// ****************************************************************** - -void CSoundDriverDSound::addTimerInterval(uint32 dt) -{ - if (_TimerIntervalCount >= 1024) - { - _TimerIntervalCount = 0; - } - - _TimerInterval[_TimerIntervalCount++] = dt; -} - -// ****************************************************************** - -double CSoundDriverDSound::getCPULoad() -{ - return (_TotalTime > 0.0)? 100.0 * _TotalUpdateTime / _TotalTime : 0.0; -} - -// ****************************************************************** - -void CSoundDriverDSound::printDriverInfo(FILE* fp) -{ - CDeviceDescription* list = CDeviceDescription::_List; - - while (list) { - fprintf(fp, "%s\n", list->_Description); - list = list->_Next; - } - - fprintf(fp, "\n"); - - fprintf(fp, "buffer size: %d\n" - "copy size: %d\n" - "swap size: %d\n", - CSourceDSound::_SecondaryBufferSize, - CSourceDSound::_UpdateCopySize, - CSourceDSound::_SwapCopySize); - - fprintf(fp, "\n"); - - DSCAPS caps; - caps.dwSize = sizeof(caps); - - if (_DirectSound->GetCaps(&caps) != DS_OK) - { - throw ESoundDriver("Failed to query the sound device caps"); - } - - - fprintf(fp, "3d hw buffers: %d\n" "2d hw buffers: %d\n\n", caps.dwMaxHw3DAllBuffers, caps.dwMaxHwMixingAllBuffers); -} - -#endif - - -void CSoundDriverDSound::startBench() -{ - NLMISC::CHTimer::startBench(); -} -void CSoundDriverDSound::endBench() -{ - NLMISC::CHTimer::endBench(); -} -void CSoundDriverDSound::displayBench(CLog *log) -{ - NLMISC::CHTimer::displayHierarchicalByExecutionPathSorted(log, CHTimer::TotalTime, true, 48, 2); - NLMISC::CHTimer::displayHierarchical(log, true, 48, 2); - NLMISC::CHTimer::displayByExecutionPath(log, CHTimer::TotalTime); - NLMISC::CHTimer::display(log, CHTimer::TotalTime); -} - -} // NLSOUND diff --git a/code/nel/src/sound/driver/dsound/sound_driver_dsound.h b/code/nel/src/sound/driver/dsound/sound_driver_dsound.h deleted file mode 100644 index e928cf137..000000000 --- a/code/nel/src/sound/driver/dsound/sound_driver_dsound.h +++ /dev/null @@ -1,214 +0,0 @@ -// NeL - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as -// published by the Free Software Foundation, either version 3 of the -// License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -#ifndef NL_SOUND_DRIVER_DSOUND_H -#define NL_SOUND_DRIVER_DSOUND_H - -#include "nel/sound/driver/sound_driver.h" - -#include "source_dsound.h" -#include "buffer_dsound.h" - -namespace NLSOUND { - -class IListener; -class ISource; -class IBuffer; -class CListenerDSound; -class CSourceDSound; -class CBufferDSound; - -class CSoundDriverDSound : public ISoundDriver -{ -public: - /// Constructor - CSoundDriverDSound(ISoundDriver::IStringMapperProvider *stringMapper); - - virtual ~CSoundDriverDSound(); - - /// Return the instance of the singleton - static CSoundDriverDSound *instance() { return _Instance; } - - /// Return a list of available devices for the user. The value at index 0 is empty, and is used for automatic device selection. - virtual void getDevices(std::vector &devices); - /// Initialize the driver with a user selected device. If device.empty(), the default or most appropriate device is used. - virtual void initDevice(const std::string &device, TSoundOptions options); - - /// Return options that are enabled (including those that cannot be disabled on this driver). - virtual TSoundOptions getOptions(); - /// Return if an option is enabled (including those that cannot be disabled on this driver). - virtual bool getOption(TSoundOptions option); - - /// Create the listener instance - virtual IListener *createListener(); - - /// Create a sound buffer - virtual IBuffer *createBuffer(); - - // Source management - - /// Create a source - virtual ISource *createSource(); - - /// Commit all the changes made to 3D settings of listener and sources - virtual void commit3DChanges(); - - /// Return the maximum number of sources that can created - virtual uint countMaxSources(); - - /// Count the number of available hardware streaming 3D buffers - uint countHw3DBuffers(); - - /// Count the number of available hardware streaming 2D buffers - uint countHw2DBuffers(); - - /// Count the number of sources that are actually playing. - uint countPlayingSources(); - - /// Update all the driver and its sources. To be called only by the timer callback. - void update(); - - /// Write information about the driver to the output stream. - void writeProfile(std::string& out); - - - /** Set the gain (volume value inside [0 , 1]). (default: 1) - * 0.0 -> silence - * 0.5 -> -6dB - * 1.0 -> no attenuation - * values > 1 (amplification) not supported by most drivers - */ - void setGain( float gain ); - - /// Get the gain - float getGain(); - - /// Return the string mapper - IStringMapperProvider *getStringMapper() {return _StringMapper;} - -#if EAX_AVAILABLE == 1 - LPKSPROPERTYSET createPropertySet(CSourceDSound *source); -#endif - - /// Create a music channel, destroy with destroyMusicChannel - virtual IMusicChannel *createMusicChannel() { return NULL; } - - /// Destroy a music channel - virtual void destroyMusicChannel(IMusicChannel * /* musicChannel */) { nlassert(false); } - - /** Get music info. Returns false if the song is not found or the function is not implemented. - * If the song has no name, result is filled with the filename. - * \param filepath path to file, CPath::lookup done by driver - * \param artist returns the song artist (empty if not available) - * \param title returns the title (empty if not available) - */ - virtual bool getMusicInfo(const std::string & /* filepath */, std::string &artist, std::string &title, float &length) { artist.clear(); title.clear(); length = 0.f; return false; } - -private: - - // The callback for the multimedia timer - static void CALLBACK TimerCallback(UINT uID, UINT uMsg, DWORD_PTR dwUser, DWORD_PTR dw1, DWORD_PTR dw2); - - // The refence to the singleton. - static CSoundDriverDSound* _Instance; - - // The period of the timer. - static uint32 _TimerPeriod; - - friend CBufferDSound::~CBufferDSound(); - friend CSourceDSound::~CSourceDSound(); - - /// Remove a buffer (should be called by the friend destructor of the buffer class) - virtual void removeBuffer(IBuffer *buffer); - - /// Remove a source (should be called by the friend destructor of the source class) - virtual void removeSource(ISource *source); - - - virtual void startBench(); - virtual void endBench(); - virtual void displayBench(NLMISC::CLog *log); - - - /// Get audio/container extensions that are supported natively by the driver implementation. - virtual void getMusicExtensions(std::vector & /* extensions */) const { } - /// Return if a music extension is supported by the driver's music channel. - virtual bool isMusicExtensionSupported(const std::string & /* extension */) const { return false; } - - - // The DirectSound object - LPDIRECTSOUND _DirectSound; - - // The application-wide primary buffer - LPDIRECTSOUNDBUFFER _PrimaryBuffer; - - // The capabilities of the driver - DSCAPS _Caps; - - // Array with the allocated sources - //CSourceDSound** _Sources; - std::set _Sources; - - // The number of allocated sources - uint _SourceCount; - - // The Windows ID of the multimedia timer used in the update. - UINT _TimerID; - - // The timer resolution. - uint32 _TimerResolution; - - /// The EAX support is requested and accepted (ie, there is enougth hardware 3D buffer) - bool _UseEAX; - /// The string mapper provided by client code - IStringMapperProvider *_StringMapper; - /// Driver options - TSoundOptions _Options; - -#if NLSOUND_PROFILE -protected: - - - uint _TimerInterval[1024]; - uint _TimerIntervalCount; - NLMISC::TTicks _TimerDate; - double _TotalTime; - double _TotalUpdateTime; - uint32 _UpdateCount; - uint32 _UpdateSources; - uint32 _UpdateExec; - - -public: - - void printDriverInfo(FILE* fp); - uint countTimerIntervals(); - uint getTimerIntervals(uint index); - void addTimerInterval(uint32 dt); - double getCPULoad(); - double getTotalTime() { return _TotalTime; }; - double getAverageUpdateTime() { return (_UpdateCount) ? _TotalUpdateTime / _UpdateCount : 0.0; } - uint32 getAverageUpdateSources() { return (_UpdateExec) ? _UpdateSources / _UpdateExec : 0; } - double getUpdatePercentage() { return (_UpdateCount) ? (double) _UpdateExec / (double) _UpdateCount: 0; } -#endif - - - -}; - -} // NLSOUND - -#endif // NL_SOUND_DRIVER_DSOUND_H diff --git a/code/nel/src/sound/driver/dsound/source_dsound.cpp b/code/nel/src/sound/driver/dsound/source_dsound.cpp deleted file mode 100644 index b80d03590..000000000 --- a/code/nel/src/sound/driver/dsound/source_dsound.cpp +++ /dev/null @@ -1,3200 +0,0 @@ -// NeL - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as -// published by the Free Software Foundation, either version 3 of the -// License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - - -#include "stddsound.h" -#include "source_dsound.h" -#include "sound_driver_dsound.h" -#include "buffer_dsound.h" -#include "listener_dsound.h" - -#ifdef DEBUG_NEW -#define new DEBUG_NEW -#endif - -using namespace NLMISC; -using namespace std; - - -namespace NLSOUND { - - -#if NLSOUND_PROFILE - - #define INITTIME(_var) TTicks _var = CTime::getPerformanceTime() - - #define DEBUG_POSITIONS 1 - - #if DEBUG_POSITIONS - #define DBGPOS(_a) nldebug ## _a - #else - #define DBGPOS(_a) - #endif - -#else - #define INITTIME(_var) - #define DBGPOS(_a) -#endif - - - -const uint32 CSourceDSound::_SecondaryBufferSize = 0x10000; -const uint32 CSourceDSound::_SizeMask = 0xffff; -const uint32 CSourceDSound::_SwapCopySize = 0x8000; -const uint32 CSourceDSound::_UpdateCopySize = 0x4000; -const uint32 CSourceDSound::_XFadeSize = 64; -const uint CSourceDSound::_DefaultChannels = 1; -const uint CSourceDSound::_DefaultSampleRate = 22050; -const uint CSourceDSound::_DefaultSampleSize = 16; - - - -#define NLSOUND_MIN(_a,_b) (((_a) < (_b)) ? (_a) : (_b)) -#define NLSOUND_DISTANCE(_from, _to, _period) (((_to) > (_from)) ? (_to) - (_from) : (_period) + (_to) - (_from)) - - -#if NLSOUND_PROFILE - -// Static variables used for profiling -double CSourceDSound::_LastSwapTime = 0.0; -double CSourceDSound::_TotalSwapTime = 0.0; -double CSourceDSound::_MaxSwapTime = 0.0; -double CSourceDSound::_MinSwapTime = 1000000.0; -uint32 CSourceDSound::_SwapCount = 0; -double CSourceDSound::_PosTime = 0.0; -double CSourceDSound::_LockTime = 0.0; -double CSourceDSound::_CopyTime = 0.0; -double CSourceDSound::_UnlockTime = 0.0; -uint32 CSourceDSound::_CopyCount = 0; -double CSourceDSound::_TotalUpdateTime = 0.0; -double CSourceDSound::_MaxUpdateTime = 0.0; -double CSourceDSound::_MinUpdateTime = 1000000.0; -uint32 CSourceDSound::_UpdateCount = 0; -uint32 CSourceDSound::_TotalUpdateSize = 0; -#endif - - -uint32 getWritePosAndSpace(uint32 &nextWritePos, uint32 playPos, uint32 writePos, uint32 bufferSize); - - -// ****************************************************************** - -CSourceDSound::CSourceDSound( uint sourcename ) -: ISource(), - _SourceName(sourcename) -{ -#if EAX_AVAILABLE == 1 - _EAXSource = 0; -#endif - _Sample = 0; - _SampleSize = 0; - _SampleOffset = 0; - _Format = Mono8; - _SampleFreq = _DefaultSampleRate; - _FillOffset = 0; - _State = source_stopped; - _PlayOffset = 0; - _LastPlayPos = 0; - _PosRelative= false; - -// _BufferSize = 0; -// _SwapBuffer = 0; - _SecondaryBuffer = 0; -// _SecondaryBufferState = NL_DSOUND_SILENCED; - _3DBuffer = 0; -// _NextWritePos = 0; -// _BytesWritten = 0; -// _SilenceWritten = 0; - _Loop = false; -// _EndPosition = 0; -// _EndState = NL_DSOUND_TAIL1; -// _UserState = NL_DSOUND_STOPPED; - _Freq = 1.0f; - _SampleRate = _DefaultSampleRate; -// _IsUsed = false; - _Gain = 1.0f; - _Volume = 0; - _Alpha = 0.0; - InitializeCriticalSection(&_CriticalSection); -} - - -// ****************************************************************** - -CSourceDSound::~CSourceDSound() -{ - nldebug("Destroying DirectSound source"); - - CSoundDriverDSound::instance()->removeSource(this); - - EnterCriticalSection(&_CriticalSection); - - // Release the DirectSound buffer within the critical zone - // to avoid a call to update during deconstruction - release(); - - LeaveCriticalSection(&_CriticalSection); - DeleteCriticalSection(&_CriticalSection); -} - - -// ****************************************************************** - -void CSourceDSound::release() -{ -// _Buffer = 0; - -#if EAX_AVAILABLE == 1 - if (_EAXSource != 0) - { - _EAXSource->Release(); - _EAXSource = 0; - } -#endif - - if (_SecondaryBuffer != 0) - { - _SecondaryBuffer->Stop(); - } - - if (_3DBuffer != 0) - { - _3DBuffer->Release(); - _3DBuffer = 0; - } - - if (_SecondaryBuffer != 0) - { - _SecondaryBuffer->Release(); - _SecondaryBuffer = 0; - } - -} - - -uint32 CSourceDSound::getTime() -{ - if (_Sample == 0) - return 0; - - TSampleFormat format; - uint freq; - - _Sample->getFormat(format, freq); - - return uint32(1000.0f * (_PlayOffset+1) / (float)freq); -} - -// ****************************************************************** - -void CSourceDSound::init(LPDIRECTSOUND directSound, bool useEax) -{ - - // Initialize the buffer format - WAVEFORMATEX format; - - format.cbSize = sizeof(WAVEFORMATEX); - format.nChannels = _DefaultChannels; - format.wBitsPerSample = _DefaultSampleSize; - format.nSamplesPerSec = _DefaultSampleRate; - format.nBlockAlign = format.nChannels * format.wBitsPerSample / 8; - format.nAvgBytesPerSec = format.nSamplesPerSec * format.nBlockAlign; - format.wFormatTag = WAVE_FORMAT_PCM; - - - // Initialize the buffer description - - DSBUFFERDESC desc; - - CSoundDriverDSound* driver = CSoundDriverDSound::instance(); - - - ZeroMemory(&desc, sizeof(DSBUFFERDESC)); - desc.dwSize = sizeof(DSBUFFERDESC); - desc.lpwfxFormat = &format; - desc.dwBufferBytes = _SecondaryBufferSize; - desc.dwReserved = 0; - - if (driver->countHw3DBuffers() > 0) - { - //nldebug("Source: Allocating 3D buffer in hardware"); - desc.dwFlags = DSBCAPS_GLOBALFOCUS | DSBCAPS_LOCHARDWARE | DSBCAPS_GETCURRENTPOSITION2 - | DSBCAPS_CTRL3D | DSBCAPS_CTRLVOLUME | DSBCAPS_CTRLFREQUENCY | DSBCAPS_MUTE3DATMAXDISTANCE; - } - else - { - nldebug("Failed to create a 3D Hardware DirectX secondary buffer. Try 3D software one"); - - if (useEax) - { - throw ESoundDriver("No 3d hardware sound buffer, but EAX support requested"); - } - //nldebug("Source: Allocating 3D buffer in software"); - desc.dwFlags = DSBCAPS_GLOBALFOCUS | DSBCAPS_LOCSOFTWARE | DSBCAPS_GETCURRENTPOSITION2 - | DSBCAPS_CTRL3D | DSBCAPS_CTRLVOLUME | DSBCAPS_CTRLFREQUENCY | DSBCAPS_MUTE3DATMAXDISTANCE; - desc.guid3DAlgorithm = DS3DALG_NO_VIRTUALIZATION; - //desc.guid3DAlgorithm = DS3DALG_HRTF_FULL; - } - - - // Allocate the secondary buffer - - if (FAILED(directSound->CreateSoundBuffer(&desc, &_SecondaryBuffer, NULL))) - { - if (useEax) - { - throw ESoundDriver("Failed to create a 3d hardware sound buffer, but EAX support requested"); - } - nlwarning("Source: Failed to create a buffer with 3D capabilities."); - - ZeroMemory(&desc, sizeof(DSBUFFERDESC)); - desc.dwSize = sizeof(DSBUFFERDESC); - desc.lpwfxFormat = &format; - desc.dwBufferBytes = _SecondaryBufferSize; - desc.dwReserved = 0; - - if (driver->countHw2DBuffers() > 0) - { - //nldebug("Source: Allocating 2D buffer in hardware"); - desc.dwFlags = DSBCAPS_GLOBALFOCUS | DSBCAPS_LOCHARDWARE | DSBCAPS_GETCURRENTPOSITION2 | DSBCAPS_CTRLVOLUME | DSBCAPS_CTRLFREQUENCY; - } - else - { - //nldebug("Source: Allocating 2D buffer in software"); - desc.dwFlags = DSBCAPS_GLOBALFOCUS | DSBCAPS_LOCSOFTWARE | DSBCAPS_GETCURRENTPOSITION2 | DSBCAPS_CTRLVOLUME | DSBCAPS_CTRLFREQUENCY; - } - - if (FAILED(directSound->CreateSoundBuffer(&desc, &_SecondaryBuffer, NULL))) - { - throw ESoundDriver("Failed to allocate the DirectSound secondary buffer"); - } - } - - - nldebug("Created DirectX secondary buffer @ %p", _SecondaryBuffer); - - // Fill the buffer with silence - LPVOID ptr; - DWORD bytes; - - if (FAILED(_SecondaryBuffer->Lock(0, 0, &ptr, &bytes, NULL, NULL, DSBLOCK_ENTIREBUFFER))) - { - throw ESoundDriver("Failed to lock the DirectSound secondary buffer"); - } - - memset(ptr, 0, bytes); - - _SecondaryBuffer->Unlock(ptr, bytes, 0, 0); - - // Allocate the 3D interface, if necessary - - if (FAILED(_SecondaryBuffer->QueryInterface(IID_IDirectSound3DBuffer, (LPVOID *) &_3DBuffer))) - { - throw ESoundDriver("Failed to allocate the DirectSound 3D buffer"); - } - - - if (FAILED(_SecondaryBuffer->Play(0, 0, DSBPLAY_LOOPING))) - { - throw ESoundDriver("Play failed"); - } - -} - -// ****************************************************************** - -void CSourceDSound::reset() -{ - setPitch(1.0f); - setLooping(false); - setGain(1.0f); -} - -/// Enable or disable streaming mode. Source must be stopped to call this. -void CSourceDSound::setStreaming(bool streaming) -{ - if (streaming) throw ESoundDriverNoBufferStreaming(); -} - -// ****************************************************************** - -void CSourceDSound::setStaticBuffer( IBuffer *buffer ) -{ - EnterCriticalSection(&_CriticalSection); - - if (_State == source_playing) - { - _State = source_swap_pending; - _Sample = 0; - _NextSample = buffer; - _SampleOffset = 0; - _PlayOffset = 0; - } - else - { - _Sample = buffer; - _NextSample = 0; - _SampleOffset = 0; - _PlayOffset = 0; - _ADPCMState.PreviousSample = 0; - _ADPCMState.StepIndex = 0; - if (buffer) - { -// _SampleSize = buffer->getSize(); - buffer->getFormat(_Format, _SampleFreq); - switch(_Format) - { - case Mono8: - _SampleSize = buffer->getSize(); - break; - case Mono16: - _SampleSize = buffer->getSize() / 2; - break; - case Mono16ADPCM: - _SampleSize = buffer->getSize() * 2; - break; - case Stereo8: - _SampleSize = buffer->getSize() / 2; - break; - case Stereo16: - _SampleSize = buffer->getSize() / 4; - break; - } - } - } - -/* - // If the user calls setStaticBuffer with a null buffer, - // stop the currently playing buffer and set it to null. - // Otherwise, store the buffer in the swap buffer variable. - // A crossfade between the current buffer and the swap buffer - // will be done when the user calls play. - if (buffer == 0) - { - stop(); - _Buffer = 0; - _BufferSize = 0; - _BytesWritten = 0; - } - - _SwapBuffer = _Buffer = buffer; - - _ADPCMState.PreviousSample = 0; - _ADPCMState.StepIndex = 0; -*/ - LeaveCriticalSection(&_CriticalSection); -} - -IBuffer *CSourceDSound::getStaticBuffer() -{ - if (_State == source_swap_pending) - return _NextSample; - else - return _Sample; - -} - -/// Add a buffer to the streaming queue. A buffer of 100ms length is optimal for streaming. -/// Should be called by a thread which checks countStreamingBuffers every 100ms. -void CSourceDSound::submitStreamingBuffer(IBuffer * /* buffer */) -{ - throw ESoundDriverNoBufferStreaming(); -} - -/// Return the amount of buffers in the queue (playing and waiting). 3 buffers is optimal. -uint CSourceDSound::countStreamingBuffers() const -{ - throw ESoundDriverNoBufferStreaming(); -} - -void CSourceDSound::getCursors(TCursors &cursors) -{ - _SecondaryBuffer->GetCurrentPosition((DWORD*)&cursors.PlayCursor, (DWORD*)&cursors.WriteCursor); - // add a security margin to the write cursor -/* cursors.WriteCursor += _UpdateCopySize; - if (cursors.WriteCursor > _SecondaryBufferSize) - cursors.WriteCursor -= _SecondaryBufferSize; -*/ - // compute the available write size -// cursors.WriteSize = std::min(_UpdateCopySize, cursors.PlayCursor + _SecondaryBufferSize - cursors.WriteCursor); - cursors.WriteSize = std::min(_UpdateCopySize, (cursors.PlayCursor - cursors.WriteCursor) & _SizeMask); -} - -void CSourceDSound::fillData(sint16 *dst, uint nbSample) -{ - nlassert((nbSample & 0xfffffffe) == nbSample); - if (_Sample != 0) - { - const void *data = ((CBufferDSound*) _Sample)->getData(); - const sint8 *data8; - const uint8 *dataAdpcm; - const sint16 *data16; - uint i; - -//nldebug("Filling from %p to %p (%p sample, %p bytes)", dst, dst+nbSample, nbSample, nbSample*2); - - - switch(_Format) - { - case Mono8: - data8 = (sint8*) data; - data8 += _SampleOffset; -// nldebug(" with data (Mono8) from %p to %p (sample : base = %p, size = %p)", data8, data8+nbSample, data, _SampleSize); - for (i=0; i %p with %p to %p", dst, dst+nbSample, dataAdpcm - (uint8*)data, dataAdpcm + (nbSample/2)-(uint8*)data); -//nldebug(" with data (Mono16ADPCM) from %p to %p (sample : base = %p, size = %p)", dataAdpcm, dataAdpcm+(nbSample/2), data, _SampleSize*2); - IBuffer::decodeADPCM(dataAdpcm, dst, nbSample, _ADPCMState); - _SampleOffset += nbSample; - break; - case Mono16: - data16 = (sint16*)data; - data16 += _SampleOffset; -//nldebug("Filling Mono16 : %p => %p with %p to %p", dst, dst+nbSample, data16 - (sint16*)data, data16 + (nbSample)-(sint16*)data); -// nldebug(" with data (Mono16) from %p to %p (sample : base = %p, size = %p)", data16, data16+nbSample, data, _SampleSize/2); - CFastMem::memcpy(dst, data16, nbSample*2); - _SampleOffset += nbSample; - break; - case Stereo8: - data8 = (sint8*) data; - data8 += _SampleOffset*2; - for (i=0; i>1) + (data16[i*2+1]>>1); - } - _SampleOffset += nbSample*2; - break; - } - -/* if (_SampleOffset == _SampleSize) - { - _SampleOffset = 0; - _ADPCMState.PreviousSample = 0; - _ADPCMState.StepIndex = 0; - } -*/ - - nlassert(_SampleOffset <= _SampleSize); - } - else - { - nldebug("Filling : NO DATA from %p to %p (%p sample, %p bytes)", dst, dst+nbSample, nbSample, nbSample*2); - - // write silence in the dst. - while (nbSample) - { - *dst++ = 0; - --nbSample; - } - } -} - -void CSourceDSound::fillData(const TLockedBufferInfo &lbi, int nbSample) -{ - nlassert((nbSample & 0x1) == 0); -/* nlassert(lbi.Size1 != 0); - nlassert(lbi.Ptr1 != NULL); -*/ uint size = std::min(uint32(nbSample), lbi.Size1>>1); - fillData(lbi.Ptr1, size); - nbSample -= size; - - if (nbSample) - { -/* nlassert(lbi.Size2 != 0); - nlassert(lbi.Ptr2 != NULL); -*/ size = min(uint32(nbSample), lbi.Size2>>1); - fillData(lbi.Ptr2, size); - nbSample -= size; - } - nlassert(nbSample == 0); -} - -void CSourceDSound::fillSilence(const TLockedBufferInfo &lbi, int nbSample) -{ - uint size = min(uint32(nbSample), lbi.Size1>>1); - uint tmp = size; - sint16 *ptr = lbi.Ptr1; -// nldebug("Silencing from %p to %p (%p sample, %p bytes)", ptr, ptr+size, size, size*2); - - for (; size != 0; --size) - *ptr++ = 0; - nbSample -= tmp; - - if (nbSample) - { - size = std::min(uint32(nbSample), lbi.Size2>>1); - tmp = size; - ptr = lbi.Ptr2; -// nldebug("Silencing from %p to %p (%p sample, %p bytes)", ptr, ptr+size, size, size*2); - for (; size != 0; --size) - *ptr++ = 0; - nbSample -= tmp; - } - nlassert(nbSample == 0); - -} - -void CSourceDSound::xfade(const TLockedBufferInfo &lbi, sint16 *src) -{ - // do the XFade in integer fixed point arithmetic - - nlassert((_XFadeSize & 0x1) == 0); - uint fade = _XFadeSize; - sint16 *ptr = lbi.Ptr1; - uint count = lbi.Size1 /2; - sint alpha, invAlpha; - - while (fade && count) - { - alpha = (fade<<16) / _XFadeSize; - invAlpha = 0x10000 - alpha; - *ptr = (sint(*ptr)*alpha + sint(*src) * invAlpha) >> 16; - ++src; - ++ptr; - --count; - --fade; - } - - ptr = lbi.Ptr2; - count = lbi.Size2 /2; - - while (fade && count) - { - alpha = (fade<<16) / _XFadeSize; - invAlpha = 0x10000 - alpha; - *ptr = (sint(*ptr)*alpha + sint(*src) * invAlpha) >> 16; - ++src; - ++ptr; - --count; - --fade; - } -} - -void CSourceDSound::fadeOut(const TLockedBufferInfo &lbi) -{ - nlassert((_XFadeSize & 0x1) == 0); - uint fade = _XFadeSize; - sint16 *ptr = lbi.Ptr1; - uint count = lbi.Size1/2; - sint alpha; - - while (fade && count) - { - alpha = (fade<<16) / _XFadeSize; - *ptr = (*ptr*alpha) >> 16; - ++ptr; - --count; - --fade; - } - - ptr = lbi.Ptr2; - count = lbi.Size2/2; - - while (fade && count) - { - alpha = (fade<<16) / _XFadeSize; - *ptr = (*ptr*alpha) >> 16; - ++ptr; - --count; - --fade; - } -} -void CSourceDSound::fadeIn(const TLockedBufferInfo &lbi) -{ - // do the XFade in integer fixed point arithmetic - - nlassert((_XFadeSize & 0x1) == 0); - uint fade = _XFadeSize; - sint16 *ptr = lbi.Ptr1; - uint count = lbi.Size1 /2; - sint alpha, invAlpha; - - while (fade && count) - { - alpha = (fade<<16) / _XFadeSize; - invAlpha = 0x10000 - alpha; - *ptr = (*ptr*invAlpha) >> 16; - ++ptr; - --count; - --fade; - } - - ptr = lbi.Ptr2; - count = lbi.Size2 /2; - - while (fade && count) - { - alpha = (fade<<16) / _XFadeSize; - invAlpha = 0x10000 - alpha; - *ptr = (*ptr*invAlpha) >> 16; - ++ptr; - --count; - --fade; - } -} - - -void CSourceDSound::advanceFill(TLockedBufferInfo &lbi, uint nbSample) -{ - uint32 size = nbSample * 2; - if (lbi.Size1 < size) - { - size -= lbi.Size1; - lbi.Size1 = lbi.Size2; - lbi.Size2 = 0; - lbi.Ptr1 = lbi.Ptr2; - lbi.Ptr2 = 0; - } - - nlassert(lbi.Size1 >= size); - lbi.Size1 -= size; - lbi.Ptr1 += size/2; - - _FillOffset += nbSample*2; - nlassert(_FillOffset == (_FillOffset & 0xfffffffC)); - _FillOffset &= _SizeMask; -// if (_FillOffset >= _SecondaryBufferSize) -// _FillOffset -= _SecondaryBufferSize; - nlassert(_FillOffset < _SecondaryBufferSize); -} - - - -bool CSourceDSound::play() -{ -// nldebug("Play"); - EnterCriticalSection(&_CriticalSection); - - _SilenceWriten = 0; - -// uint32 writeSize = checkFillCursor(); - TCursors cursors; - getCursors(cursors); - - // set a new filling point - _FillOffset = cursors.WriteCursor; - _FillOffset = (_FillOffset+3) & 0xfffffffC; - cursors.WriteCursor = _FillOffset; - - TLockedBufferInfo lbi; - if (lock(_FillOffset, cursors.WriteSize, lbi)) - { - TLockedBufferInfo unlockInfo(lbi); - // ok, the buffer is locked, write data - if (_State == source_swap_pending) - { - // we swap the buffer. - _Sample = _NextSample; - _NextSample = 0; - if (_Sample != 0) - { - _Sample->getFormat(_Format, _SampleFreq); - switch(_Format) - { - case Mono8: - _SampleSize = _Sample->getSize(); - break; - case Mono16: - _SampleSize = _Sample->getSize() / 2; - break; - case Mono16ADPCM: - _SampleSize = _Sample->getSize() * 2; - break; - case Stereo8: - _SampleSize = _Sample->getSize() / 2; - break; - case Stereo16: - _SampleSize = _Sample->getSize() / 4; - break; - } - _State = source_playing; - } - else - { - _SampleSize = 0; - _State = source_silencing; - } - } - _LastPlayPos = cursors.PlayCursor; - _SampleOffset = 0; - _PlayOffset = 0; - _ADPCMState.PreviousSample = 0; - _ADPCMState.StepIndex = 0; - // Compute the size of data to write. - uint dataToFill = std::min(uint(cursors.WriteSize / 2), _SampleSize - _SampleOffset); - dataToFill &= 0xfffffffe; - // ok, the buffer is locked, write data - if (_State == source_playing || _State == source_silencing) - { - // we need a little XFade - sint16 fadeBuffer[_XFadeSize]; - fillData(fadeBuffer, _XFadeSize); - xfade(lbi, fadeBuffer); - advanceFill(lbi, _XFadeSize); - cursors.WriteSize -= _XFadeSize*2; - dataToFill -= _XFadeSize; - } - else - { - // we need a little FadeIn - fillData(lbi, _XFadeSize); - fadeIn(lbi); - advanceFill(lbi, _XFadeSize); - cursors.WriteSize -= _XFadeSize*2; - dataToFill -= _XFadeSize; - } - fillData(lbi, dataToFill); - cursors.WriteSize -= dataToFill * 2; - advanceFill(lbi, dataToFill); - _State = source_playing; - if (_Loop) - { - while (cursors.WriteSize >= 4) - { - if (_SampleOffset == _SampleSize) - { - // rewind the sample - _SampleOffset = 0; - _ADPCMState.PreviousSample = 0; - _ADPCMState.StepIndex = 0; - } - nlassert(_SampleOffset < _SampleSize); - dataToFill = std::min(uint(cursors.WriteSize / 2), _SampleSize - _SampleOffset); - dataToFill &= 0xfffffffe; - fillData(lbi, dataToFill); - advanceFill(lbi, dataToFill); - cursors.WriteSize -= dataToFill*2; - } - } - else - { - if (_SampleOffset == _SampleSize) - { - // begin to write silence, but stil in play state until all sample are played -// _State = source_silencing; - fillSilence(lbi, cursors.WriteSize/2); - advanceFill(lbi, cursors.WriteSize/2); - _SilenceWriten = cursors.WriteSize; - cursors.WriteSize = 0; - } -// else -// _State = source_playing; - } - - - unlock(unlockInfo); - } - else - { - nlwarning("Couldn't lock the sound buffer for %u bytes", cursors.WriteSize); - } - - // set the volume NOW - CListenerDSound* listener = CListenerDSound::instance(); - - updateVolume(listener->getPos()); - - LeaveCriticalSection(&_CriticalSection); - - return true; -} - -void CSourceDSound::stop() -{ -// nldebug("Stop"); - EnterCriticalSection(&_CriticalSection); - - if (_State != source_stopped && _State != source_silencing) - { - // retreive the cursors; - TCursors cursors; - getCursors(cursors); - - _FillOffset = cursors.WriteCursor; - _FillOffset = (_FillOffset+3) & 0xfffffffC; - - TLockedBufferInfo lbi; - if (lock(_FillOffset, cursors.WriteSize, lbi)) - { - TLockedBufferInfo unlockInfo(lbi); - - fadeOut(lbi); - advanceFill(lbi, _XFadeSize); - cursors.WriteSize -= _XFadeSize*2; - fillSilence(lbi, cursors.WriteSize/2); - advanceFill(lbi, cursors.WriteSize/2); - _SilenceWriten = cursors.WriteSize; - - _State = source_silencing; - - unlock(unlockInfo); - } - } - - LeaveCriticalSection(&_CriticalSection); -} - - - -// ****************************************************************** - -void CSourceDSound::setLooping( bool l ) -{ - _Loop = l; -} - - -// ****************************************************************** - -bool CSourceDSound::getLooping() const -{ - return _Loop; -} - - -// ****************************************************************** -/* -void CSourceDSound::swap() -{ - _Buffer = _SwapBuffer; - _BufferSize = _Buffer->getSize(); - _BytesWritten = 0; - _SwapBuffer = 0; -} -*/ -// ****************************************************************** -/* -bool CSourceDSound::play() -{ - EnterCriticalSection(&_CriticalSection); - - if (_Buffer == 0 || ((CBufferDSound*) _Buffer)->getData() == 0) - { - // the sample has been unloaded, can't play! - - LeaveCriticalSection(&_CriticalSection); - return false; - } - - - DBGPOS(("[%p] PLAY: Enter, buffer state = %u", this, _SecondaryBufferState)); - switch (_SecondaryBufferState) - { - case NL_DSOUND_FILLING: - if (_SwapBuffer != 0) - { - // crossfade to the new sound - DBGPOS(("[%p] PLAY: XFading 1", this)); - crossFade(); - } - break; - - case NL_DSOUND_SILENCING: - if (_SwapBuffer != 0) - { - if ((_Buffer != 0) && (_UserState == NL_DSOUND_PLAYING)) - { - // crossfade to the new sound - DBGPOS(("[%p] PLAY: XFading 2", this)); - crossFade(); - } - else - { - DBGPOS(("[%p] PLAY: Swap & fadein 1", this)); - swap(); - fadeIn(); - } - } - else - { - DBGPOS(("[%p] PLAY: Fadein", this)); - _BytesWritten = 0; - // start the old sound again - fadeIn(); - } - - break; - - - case NL_DSOUND_SILENCED: - if (_SwapBuffer != 0) - { - // fade in to the new sound - DBGPOS(("[%p] PLAY: Swap & fadein 2", this)); - swap(); - fadeIn(); - } - else - { - DBGPOS(("[%p] PLAY: Fadein", this)); - _BytesWritten = 0; - // start the old sound again - fadeIn(); - } - } - - _UserState = NL_DSOUND_PLAYING; - DBGPOS(("[%p] PLAY: PLAYING", this)); - - //nldebug ("NLSOUND: %p play", this); - - LeaveCriticalSection(&_CriticalSection); - - return true; -} -*/ - -// ****************************************************************** -/* -void CSourceDSound::stop() -{ - EnterCriticalSection(&_CriticalSection); - - TSourceDSoundUserState old = _UserState; - - _UserState = NL_DSOUND_STOPPED; - DBGPOS(("[%p] STOP: STOPPED", this)); - - //nldebug ("NLSOUND: %p stop", this); - - if (old == NL_DSOUND_PLAYING) - { - fadeOut(); - } - - _BytesWritten = 0; - - LeaveCriticalSection(&_CriticalSection); -} -*/ -// ****************************************************************** - -void CSourceDSound::pause() -{ - // TODO : recode this ! - nlassert(false); -/* EnterCriticalSection(&_CriticalSection); - - TSourceDSoundUserState old = _UserState; - - _UserState = NL_DSOUND_PAUSED; - DBGPOS(("[%p] PAUZ: PAUSED", this)); - - //nldebug ("NLOUND: pause %p", this); - - if (old == NL_DSOUND_PLAYING) - { - fadeOut(); - } - - LeaveCriticalSection(&_CriticalSection); -*/ -} - -// ****************************************************************** - -bool CSourceDSound::isPlaying() const -{ -// return (_UserState == NL_DSOUND_PLAYING); - return _State == source_playing || _State == source_swap_pending; -} - - -// ****************************************************************** - -bool CSourceDSound::isPaused() const -{ - // TODO - nlassert(false); - return false; -// return (_UserState == NL_DSOUND_PAUSED); -} - - -// ****************************************************************** - -bool CSourceDSound::isStopped() const -{ - return _State == source_silencing || _State == source_stopped; -// return (_UserState == NL_DSOUND_STOPPED); -} - - -// ****************************************************************** - -bool CSourceDSound::needsUpdate() -{ - return _State == source_silencing || _State == source_playing || _State == source_swap_pending; -} - - - -// ****************************************************************** - -bool CSourceDSound::update() -{ - H_AUTO(NLSOUND_SourceDSoundUpdate) - bool updateDone = false; - - EnterCriticalSection(&_CriticalSection); - - // fill some data into the buffer - TCursors cursors; - getCursors(cursors); - uint32 writeSize; - - // The total size available for fill (between fillOffset and play cusors) - uint32 fillSize = (cursors.PlayCursor - _FillOffset) & _SizeMask; - // The play margin (between play and write cursor) - uint32 margin = (cursors.WriteCursor - cursors.PlayCursor) & _SizeMask; - // The number of sample played since previous update - uint32 samplePlayed = ((cursors.PlayCursor - _LastPlayPos) & _SizeMask) / 2; - _LastPlayPos = cursors.PlayCursor; - - -// if (_FillOffset < cursors.WriteCursor && _FillOffset >cursors.PlayCursor) - if (fillSize + margin > _SecondaryBufferSize) - { - // arg ! - nlwarning("FillOffset is between play and write cursor (P = %p F = %p W = %p!", cursors.PlayCursor, _FillOffset, cursors.WriteCursor); - _FillOffset = cursors.WriteCursor; - _FillOffset = (_FillOffset+3) & 0xfffffffC; - _SilenceWriten = 0; - nlassert(_FillOffset < _SecondaryBufferSize); - } - - // advance of the fill offset over the write cursor - uint32 advance = (_FillOffset - cursors.WriteCursor) & _SizeMask; - -/* nldebug("Play = %p, Write = %p, Fill = %p, FillSize = %p, Margin = %p, Advance = %p", - cursors.PlayCursor, cursors.WriteCursor, _FillOffset, fillSize, margin, advance); -*/ - if (advance > _UpdateCopySize) - { - // enougth data wrote, wait until next update - cursors.WriteSize = 0; - } -/* if (cursors.WriteSize) - { - if (_FillOffset < cursors.WriteCursor) - { - if (_FillOffset > cursors.WriteCursor + _UpdateCopySize - _SecondaryBufferSize ) - { -// nlwarning("Enougth data wrote"); - // already fill enough data - cursors.WriteSize = 0; - } - } - else - { - if (_FillOffset > cursors.WriteCursor + _UpdateCopySize) - { -// nlwarning("Enougth data wrote"); - // already fill enough data - cursors.WriteSize = 0; - } - } - } -*/ -// nldebug("Cursors : Play = %p, Write = %p, Fill = %p", cursors.PlayCursor, cursors.WriteCursor, _FillOffset); - - cursors.WriteCursor = _FillOffset; - writeSize = cursors.WriteSize; // compute the real played sample offset - - // update the real number of played sample - if (_State == source_playing) - _PlayOffset += samplePlayed; - - if (writeSize >= _UpdateCopySize) - { -// nldebug("Update %p bytes", _UpdateCopySize); - writeSize = _UpdateCopySize; - updateDone = true; - TLockedBufferInfo lbi; - if (lock(_FillOffset, writeSize, lbi)) - { - TLockedBufferInfo unlockInfo(lbi); - if (_State == source_playing) - { - nlassert(_SampleOffset <= _SampleSize); - uint32 updateSize = min(_SampleSize - _SampleOffset, uint(writeSize/2)); - updateSize &= 0xfffffffe; - fillData(lbi, updateSize); - advanceFill(lbi, updateSize); - writeSize -= updateSize*2; - - if (_Loop) - { - while (_PlayOffset >= _SampleSize) - _PlayOffset -= _SampleSize; - - // repeat until we have at least 2 sample to write - while (writeSize >= 4) - { - if (_SampleOffset == _SampleSize) - { - // rewind the sample - _SampleOffset = 0; - _ADPCMState.PreviousSample = 0; - _ADPCMState.StepIndex = 0; - } - - updateSize = min(_SampleSize - _SampleOffset, uint(writeSize/2)); - updateSize &= 0xfffffffe; - fillData(lbi, updateSize); - advanceFill(lbi, updateSize); - writeSize -= updateSize*2; - } - } - else - { - if (_SampleOffset == _SampleSize) - { - fillSilence(lbi, writeSize/2); - advanceFill(lbi, writeSize/2); - _SilenceWriten += writeSize; - } - if (_PlayOffset >= _SampleSize) - { - // all the sample is played, no we are in silencing state ! - _PlayOffset = _SampleSize; - _State = source_silencing; - } - } - - } - else if (_State == source_swap_pending) - { - // the sample has been changed but not replayed yet ? so we 'stop' the old buffer - - fadeOut(lbi); - advanceFill(lbi, _XFadeSize); - writeSize -= _XFadeSize*2; - fillSilence(lbi, writeSize/2); - advanceFill(lbi, writeSize/2); - _SilenceWriten = writeSize; - _State = source_silencing; - } - else if (_State == source_silencing) - { - // write silence into the buffer. - uint32 updateSize = min(writeSize, _SecondaryBufferSize - _SilenceWriten); - updateSize &= 0xfffffffC; - fillSilence(lbi, updateSize/2); - advanceFill(lbi, updateSize/2); - _SilenceWriten += updateSize; - - if (_SilenceWriten == _SecondaryBufferSize) - _State = source_stopped; - } - else - { - nlwarning("Update not needed !"); - } - - unlock(unlockInfo); - } - } - - LeaveCriticalSection(&_CriticalSection); - - return updateDone; -} - -// ****************************************************************** -/* -bool CSourceDSound::update2() -{ - bool res = false; - - - - INITTIME(start); - - // - // Enter critical region - // - EnterCriticalSection(&_CriticalSection); - - - switch (_SecondaryBufferState) - { - - - case NL_DSOUND_SILENCED: - { - // Just pretend were writing silence by advancing the next - // write position. - DWORD playPos, writePos; - uint32 space; - - _SecondaryBuffer->GetCurrentPosition(&playPos, &writePos); - - if (playPos == _NextWritePos) - { - LeaveCriticalSection(&_CriticalSection); - return false; - } - - space = getWritePosAndSpace(_NextWritePos, playPos, writePos, _SecondaryBufferSize); - - // not enougth space available - if (space < _UpdateCopySize) - break; - - _NextWritePos += _UpdateCopySize; - - if (_NextWritePos >= _SecondaryBufferSize) - { - _NextWritePos -= _SecondaryBufferSize; - } - } - break; - - - case NL_DSOUND_FILLING: - res = fill(); - break; - - - case NL_DSOUND_SILENCING: - res = silence(); - break; - - } - - - // - // Leave critical region - // - LeaveCriticalSection(&_CriticalSection); - - -#if NLSOUND_PROFILE - double dt = CTime::ticksToSecond(CTime::getPerformanceTime() - start);; - _TotalUpdateTime += dt; - _MaxUpdateTime = (dt > _MaxUpdateTime) ? dt : _MaxUpdateTime; - _MinUpdateTime = (dt < _MinUpdateTime) ? dt : _MinUpdateTime; - _UpdateCount++; -#endif - - return res; -} -*/ - - -// ****************************************************************** - -void CSourceDSound::setPos( const NLMISC::CVector& pos, bool deferred ) -{ - _Pos = pos; - // Coordinate system: conversion from NeL to OpenAL/GL: - if (_3DBuffer != NULL) - { - if (_3DBuffer->SetPosition(pos.x, pos.z, pos.y, deferred ? DS3D_DEFERRED : DS3D_IMMEDIATE) != DS_OK) - { - nlwarning ("SetPosition failed"); - } - else - { - //nlwarning ("%p set source NEL(p:%.2f/%.2f/%.2f) DS(p:%.2f/%.2f/%.2f)", this, pos.x, pos.y, pos.z, pos.x, pos.z, pos.y); - } - } -} - - -// ****************************************************************** - -const NLMISC::CVector &CSourceDSound::getPos() const -{ - return _Pos; -} - - -// ****************************************************************** - -void CSourceDSound::setVelocity( const NLMISC::CVector& vel, bool deferred ) -{ - if (_3DBuffer != NULL) - { - if (_3DBuffer->SetVelocity(vel.x, vel.z, vel.y, deferred ? DS3D_DEFERRED : DS3D_IMMEDIATE) != DS_OK) - { - nlwarning ("SetVelocity failed"); - } - } -} - - -// ****************************************************************** - -void CSourceDSound::getVelocity( NLMISC::CVector& vel ) const -{ - if (_3DBuffer != NULL) - { - D3DVECTOR v; - - if (_3DBuffer->GetVelocity(&v) != DS_OK) - { - nlwarning ("GetVelocity failed"); - vel.set(0, 0, 0); - } - else - { - vel.set(v.x, v.z, v.y); - } - } - else - { - vel.set(0, 0, 0); - } -} - - -// ****************************************************************** - -void CSourceDSound::setDirection( const NLMISC::CVector& dir ) -{ - if (_3DBuffer != 0) - { - if (_3DBuffer->SetConeOrientation(dir.x, dir.z, dir.y, DS3D_DEFERRED) != DS_OK) - { - nlwarning ("SetConeOrientation failed (x=%.2f, y=%.2f, z=%.2f)", dir.x, dir.y, dir.z); - } - else - { - //nlwarning ("NLSOUND: %p set source direction NEL(p:%.2f/%.2f/%.2f) DS(p:%.2f/%.2f/%.2f)", this, dir.x, dir.y, dir.z, dir.x, dir.z, dir.y); - } - } -} - - -// ****************************************************************** - -void CSourceDSound::getDirection( NLMISC::CVector& dir ) const -{ - if (_3DBuffer != NULL) - { - D3DVECTOR v; - - if (_3DBuffer->GetConeOrientation(&v) != DS_OK) - { - nlwarning("GetConeOrientation failed"); - dir.set(0, 0, 1); - } - else - { - dir.set(v.x, v.z, v.y); - } - } - else - { - dir.set(0, 0, 1); - } -} - - -// ****************************************************************** - -void CSourceDSound::setGain( float gain ) -{ - clamp(gain, 0.00001f, 1.0f); - _Gain = gain; - - /* convert from linear amplitude to hundredths of decibels */ - _Volume = (uint32)(100.0 * 20.0 * log10(gain)); - clamp(_Volume, DSBVOLUME_MIN, DSBVOLUME_MAX); - - //nlwarning ("set gain %f vol %d", gain, _Volume); - - /* - if ((_SecondaryBuffer != 0) && (_SecondaryBuffer->SetVolume(_Volume) != DS_OK)) - { - nlwarning("SetVolume failed"); - } - */ -} - - -/* - * Get the gain - */ -float CSourceDSound::getGain() const -{ - return _Gain; -} - - -// ****************************************************************** - -void CSourceDSound::setPitch( float coeff ) -{ -// _Freq = coeff; - - if ((_Sample != 0) && (_SecondaryBuffer != 0)) - { - TSampleFormat format; - uint freq; - - _Sample->getFormat(format, freq); - - _SampleRate = (uint32) (coeff * (float) freq); - - //nlwarning("Freq=%d", newfreq); - - if (_SecondaryBuffer->SetFrequency(_SampleRate) != DS_OK) - { -// nlwarning("SetFrequency failed (buffer freq=%d, NeL freq=%.5f, DSound freq=%d)", freq, coeff, newfreq); - nlwarning("SetFrequency"); - } - } -} - - -// ****************************************************************** - -float CSourceDSound::getPitch() const -{ - if ((_Sample != 0) && (_SecondaryBuffer != 0)) - { - TSampleFormat format; - uint freq0; - DWORD freq; - - _Sample->getFormat(format, freq0); - - if (_SecondaryBuffer->GetFrequency(&freq) != DS_OK) - { - nlwarning("GetFrequency failed"); - return 1.0; - } - - return ((float) freq / (float) freq0); - } - - return 1.0; -} - - -// ****************************************************************** - -void CSourceDSound::setSourceRelativeMode( bool mode ) -{ - if (_3DBuffer != 0) - { - HRESULT hr; - - if (mode) - { - hr = _3DBuffer->SetMode(DS3DMODE_HEADRELATIVE, DS3D_IMMEDIATE); - } - else - { - hr = _3DBuffer->SetMode(DS3DMODE_NORMAL, DS3D_IMMEDIATE); - } - - // cache - if (hr == DS_OK) - _PosRelative= mode; - else - nlwarning("SetMode failed"); - } - else - { - nlwarning("Requested setSourceRelativeMode on a non-3D source"); - } -} - - -// ****************************************************************** - -bool CSourceDSound::getSourceRelativeMode() const -{ - return _PosRelative; -} - - -// ****************************************************************** -void CSourceDSound::setMinMaxDistances( float mindist, float maxdist, bool deferred ) -{ - if (_3DBuffer != 0) - { - if (_3DBuffer->SetMinDistance(std::max(DS3D_DEFAULTMINDISTANCE, mindist), deferred ? DS3D_DEFERRED : DS3D_IMMEDIATE) != DS_OK) - { - nlwarning("SetMinDistance (%f) failed", mindist); - } - if (_3DBuffer->SetMaxDistance(std::min(DS3D_DEFAULTMAXDISTANCE, maxdist), deferred ? DS3D_DEFERRED : DS3D_IMMEDIATE) != DS_OK) - { - nlwarning("SetMaxDistance (%f) failed", maxdist); - } - } - else - { - nlwarning("Requested setMinMaxDistances on a non-3D source"); - } -} - - -// ****************************************************************** - -void CSourceDSound::getMinMaxDistances( float& mindist, float& maxdist ) const -{ - if (_3DBuffer != 0) - { - D3DVALUE min, max; - - if ((_3DBuffer->GetMinDistance(&min) != DS_OK) - || (_3DBuffer->GetMaxDistance(&max) != DS_OK)) - { - mindist = 0.0f; - maxdist = 0.0f; - nlwarning("GetMinDistance or GetMaxDistance failed"); - } - else - { - mindist = min; - maxdist = max; - } - } - else - { - mindist = 0.0f; - maxdist = 0.0f; - nlwarning("Requested getMinMaxDistances on a non-3D source"); - } -} - -// ****************************************************************** -void CSourceDSound::updateVolume( const NLMISC::CVector& listener ) -{ - if (!CSoundDriverDSound::instance()->getOption(ISoundDriver::OptionManualRolloff)) - { - // API controlled rolloff => return (just set the volume) - _SecondaryBuffer->SetVolume(_Volume); - } - else // manual rolloff - { - CVector pos = getPos(); - // make relative to listener (if not already!) - if(!_PosRelative) - pos -= listener; - float sqrdist = pos.sqrnorm(); - - float mindist, maxdist; - getMinMaxDistances(mindist, maxdist); - - // attenuate the volume according to distance and alpha - sint32 volumeDB = ISource::computeManualRollOff(_Volume, DSBVOLUME_MIN, DSBVOLUME_MAX, _Alpha, sqrdist, mindist, maxdist); - - // set attenuated volume - _SecondaryBuffer->SetVolume(volumeDB); - } -} - -// ****************************************************************** - -void CSourceDSound::setCone( float innerAngle, float outerAngle, float outerGain ) -{ - if (_3DBuffer != 0) - { - // Set the cone angles - - // Convert from radians to degrees - DWORD inner = (DWORD)(180.0 * innerAngle / Pi); - DWORD outer = (DWORD)(180.0 * outerAngle / Pi); - - - // Sanity check: wrap the angles in the [0,360] interval - if (outer < inner) - { - outer = inner; - } - - while (inner < DS3D_MINCONEANGLE) - { - inner += 360; - } - - while (inner > DS3D_MAXCONEANGLE) - { - inner -= 360; - } - - while (outer < DS3D_MINCONEANGLE) - { - outer += 360; - } - - while (outer > DS3D_MAXCONEANGLE) - { - outer -= 360; - } - - if (_3DBuffer->SetConeAngles(inner, outer, DS3D_DEFERRED) != DS_OK) - { - nlwarning("SetConeAngles failed"); - } - - // Set the outside volume - if (outerGain < 0.00001f) - { - outerGain = 0.00001f; - } - - // convert from linear amplitude to hundredths of decibels - LONG volume = (LONG)(100.0 * 20.0 * log10(outerGain)); - - if (volume < DSBVOLUME_MIN) - { - volume = DSBVOLUME_MIN; - } - else if (volume > DSBVOLUME_MAX) - { - volume = DSBVOLUME_MAX; - } - - if (_3DBuffer->SetConeOutsideVolume(volume, DS3D_DEFERRED) != DS_OK) - { - nlwarning("SetConeOutsideVolume failed"); - } - - } - else - { - nlwarning("Requested setCone on a non-3D source"); - } -} - -// ****************************************************************** - -void CSourceDSound::getCone( float& innerAngle, float& outerAngle, float& outerGain ) const -{ - if (_3DBuffer != 0) - { - DWORD inner, outer; - LONG volume; - - if (_3DBuffer->GetConeAngles(&inner, &outer) != DS_OK) - { - nlwarning("GetConeAngles failed"); - innerAngle = outerAngle = (float)(2.0 * Pi); - } - else - { - innerAngle = (float)(Pi * inner / 180.0); - outerAngle = (float)(Pi * outer / 180.0); - } - - if (_3DBuffer->GetConeOutsideVolume(&volume) != DS_OK) - { - nlwarning("GetConeOutsideVolume failed"); - outerGain = 0.0f; - } - else - { - outerGain = (float) pow((double)10, (double) volume / 20.0 / 100.0); - } - } - else - { - nlwarning("Requested getCone on a non-3D source"); - } -} - -// ****************************************************************** - -//void CSourceDSound::setEAXProperty( uint prop, void *value, uint valuesize ) -//{ -//#if EAX_AVAILABLE == 1 -// if (_EAXSource == 0) -// { -// _EAXSource = CSoundDriverDSound::instance()->createPropertySet(this); -// } -// if ( _EAXSource != NULL ) -// { -// H_AUTO(NLSOUND_EAXPropertySet_Set) -// HRESULT res = _EAXSource->Set( DSPROPSETID_EAX_BufferProperties, prop, NULL, 0, value, valuesize ); -// if (res != S_OK) -// { -//// nlwarning("Setting EAX Param #%u fail : %x", prop, res); -// } -// } -//#endif -//} - -/** Set the alpha value for the volume-distance curve - * - * Useful only with OptionManualRolloff. value from -1 to 1 (default 0) - * - * alpha.0: the volume will decrease linearly between 0dB and -100 dB - * alpha = 1.0: the volume will decrease linearly between 1.0 and 0.0 (linear scale) - * alpha = -1.0: the volume will decrease inversely with the distance (1/dist). This - * is the default used by DirectSound/OpenAL - * - * For any other value of alpha, an interpolation is be done between the two - * adjacent curves. For example, if alpha equals 0.5, the volume will be halfway between - * the linear dB curve and the linear amplitude curve. - */ -void CSourceDSound::setAlpha(double a) -{ - _Alpha = a; -} - -/// Enable or disable direct output [true/false], default: true -void CSourceDSound::setDirect(bool /* enable */) -{ - -} - -/// Return if the direct output is enabled -bool CSourceDSound::getDirect() const -{ - return true; -} - -/// Set the gain for the direct path -void CSourceDSound::setDirectGain(float /* gain */) -{ - -} - -/// Get the gain for the direct path -float CSourceDSound::getDirectGain() const -{ - return NLSOUND_DEFAULT_DIRECT_GAIN; -} - -/// Enable or disable the filter for the direct channel -void CSourceDSound::enableDirectFilter(bool /* enable */) -{ - -} - -/// Check if the filter on the direct channel is enabled -bool CSourceDSound::isDirectFilterEnabled() const -{ - return false; -} - -/// Set the filter parameters for the direct channel -void CSourceDSound::setDirectFilter(TFilter /*filterType*/, float /*lowFrequency*/, float /*highFrequency*/, float /*passGain*/) -{ - -} - -/// Get the filter parameters for the direct channel -void CSourceDSound::getDirectFilter(TFilter &filterType, float &lowFrequency, float &highFrequency, float &passGain) const -{ - filterType = FilterLowPass; - lowFrequency = NLSOUND_DEFAULT_FILTER_PASS_LF; - highFrequency = NLSOUND_DEFAULT_FILTER_PASS_HF; - passGain = NLSOUND_DEFAULT_FILTER_PASS_GAIN; -} - -/// Set the direct filter gain -void CSourceDSound::setDirectFilterPassGain(float /*passGain*/) -{ - -} - -/// Get the direct filter gain -float CSourceDSound::getDirectFilterPassGain() const -{ - return 0.0f; -} - -/// Set the effect send for this source, NULL to disable. [IEffect], default: NULL -void CSourceDSound::setEffect(IReverbEffect * /* reverbEffect */) -{ - -} - -/// Get the effect send for this source -IEffect *CSourceDSound::getEffect() const -{ - return NULL; -} - -/// Set the gain for the effect path -void CSourceDSound::setEffectGain(float /* gain */) -{ - -} - -/// Get the gain for the effect path -float CSourceDSound::getEffectGain() const -{ - return NLSOUND_DEFAULT_EFFECT_GAIN; -} - -/// Enable or disable the filter for the effect channel -void CSourceDSound::enableEffectFilter(bool /* enable */) -{ - -} - -/// Check if the filter on the effect channel is enabled -bool CSourceDSound::isEffectFilterEnabled() const -{ - return false; -} - -/// Set the filter parameters for the effect channel -void CSourceDSound::setEffectFilter(TFilter /*filterType*/, float /*lowFrequency*/, float /*highFrequency*/, float /*passGain*/) -{ - -} - -/// Get the filter parameters for the effect channel -void CSourceDSound::getEffectFilter(TFilter &filterType, float &lowFrequency, float &highFrequency, float &passGain) const -{ - filterType = FilterLowPass; - lowFrequency = NLSOUND_DEFAULT_FILTER_PASS_LF; - highFrequency = NLSOUND_DEFAULT_FILTER_PASS_HF; - passGain = NLSOUND_DEFAULT_FILTER_PASS_GAIN; -} - -/// Set the effect filter gain -void CSourceDSound::setEffectFilterPassGain(float /*passGain*/) -{ - -} - -/// Get the effect filter gain -float CSourceDSound::getEffectFilterPassGain() const -{ - return 0.0f; -} - -// ****************************************************************** - -IBuffer *CSourceDSound::getBuffer() -{ - return _Sample; -} - - -// ****************************************************************** - -bool CSourceDSound::lock(uint32 offset, uint32 size, TLockedBufferInfo &lbi) -{ - HRESULT hr = _SecondaryBuffer->Lock(offset, size, (LPVOID*) &lbi.Ptr1, (DWORD*) &lbi.Size1, (LPVOID*) &lbi.Ptr2, (DWORD*) &lbi.Size2, 0); - - if (hr == DSERR_BUFFERLOST) - { - // If the buffer got lost somehow, try to restore it. - if (FAILED(_SecondaryBuffer->Restore())) - { - nlwarning("Lock failed (1)"); - return false; - } - if (FAILED(_SecondaryBuffer->Lock(offset, size, (LPVOID*) &lbi.Ptr1, (DWORD*)&lbi.Size1, (LPVOID*) &lbi.Ptr2, (DWORD*)&lbi.Size2, 0))) - { - nlwarning("Lock failed (2)"); - return false; - } - } - else if (hr != DS_OK) - { - nlwarning("Lock failed (3)"); - return false; - } - - return true; -} -/* - -bool CSourceDSound::lock(uint32 writePos, uint32 size, uint8* &ptr1, DWORD &bytes1, uint8* &ptr2, DWORD &bytes2) -{ - HRESULT hr = _SecondaryBuffer->Lock(writePos, size, (LPVOID*) &ptr1, &bytes1, (LPVOID*) &ptr2, &bytes2, 0); - - if (hr == DSERR_BUFFERLOST) - { - // If the buffer got lost somehow, try to restore it. - if (FAILED(_SecondaryBuffer->Restore())) - { - nlwarning("Lock failed (1)"); - return false; - } - if (FAILED(_SecondaryBuffer->Lock(_NextWritePos, _UpdateCopySize, (LPVOID*) &ptr1, &bytes1, (LPVOID*) &ptr2, &bytes2, 0))) - { - nlwarning("Lock failed (2)"); - return false; - } - } - else if (hr != DS_OK) - { - nlwarning("Lock failed (3)"); - return false; - } - - return true; -} -*/ -// ****************************************************************** - -bool CSourceDSound::unlock(const TLockedBufferInfo &lbi) -{ - _SecondaryBuffer->Unlock(lbi.Ptr1, lbi.Size1, lbi.Ptr2, lbi.Size2); - return true; -} - - -/* -bool CSourceDSound::unlock(uint8* ptr1, DWORD bytes1, uint8* ptr2, DWORD bytes2) -{ - _SecondaryBuffer->Unlock(ptr1, bytes1, ptr2, bytes2); - return true; -} -*/ -/* -void CSourceDSound::copySampleTo16BitsTrack(void *dst, void *src, uint nbSample, TSampleFormat sourceFormat) -{ - if (sourceFormat == Mono8 || sourceFormat == Stereo8) - { - nlassert("8 bit mixing is not supported now !"); - return; - // convert sample from 8 to 16 inside the dst buffer - sint8 *psrc = (sint8*)src; - sint16 *pdst = (sint16*)dst; - sint8 *endSrc = psrc + nbSample; - - for (; psrc != endSrc; psrc += 2) - { - // write the high word - *pdst++ = sint16(*psrc++) * 256; - } - } - if (sourceFormat == Mono16ADPCM) - { - // unpack ADPCM data - nldebug("Mixing %u samples in ADPCM", nbSample); - IBuffer::decodeADPCM((uint8*)src, (sint16*)dst, nbSample, _ADPCMState); - } - else - { - // use the fastmem copy buffer - CFastMem::memcpy(dst, src, nbSample*2); - } -} -*/ -/*************************************************************************** - - - Buffer operations - - There are five buffer operation: fill, silence, fadeOut, crossFade - and fadeIn. fill and silence are called by the update function. The - others are called by the user state functions (play, stop, pause). - - - NW P W - +--------+------+---+-----------------------+ - |........| |xxx|.......................| - +--------+------+---+-----------------------+ - - The source maintains the next write position (_NextWritePos, NW in figure - above). That is the position at which new samples or silemce is written. - DirectSound maintaines a play cursor and a write cursor (P and W in figure). - The data between P and W is scheduled for playing and cannot be touched. - The data between W and NW are unplayed sample data that the source copied - into the DirectSound buffer. - - The update functions (fill, silence) refresh the buffer with new samples - or silence. That insert the sample data at the next write position NW. This - write position is maintained as closely behind the DirectSound play cursor - as possible to keep the buffer filled with data. - - The user functions (the fades) modify the sample data that is right after - the write cursor W maintained by DirectSound. The data has to be written - after W to hear the changes as soon as possible. When a fade is done, the - data already written in the buffer has to be overwritten. The function - getFadeOutSize() helps to found out how many samples are writen between - W and NW and to what section of the original audio data they correspond. - - All the buffer functions below have the same pattern: - - - get current play and write cursors (P and W) - - lock the buffer - - copy samples - - unlock buffer - - update state variables - - The differences between the functions are due to different operation - (fades), position and size of the buffer to lock, handling of silence - and looping. - - Enjoy! - - PH - - -************************************************************************/ -/* -uint32 getWritePosAndSpace(uint32 &nextWritePos, uint32 playPos, uint32 writePos, uint32 bufferSize) -{ - uint32 space; - if (playPos < writePos) //_NextWritePos) - { - // the 'forbiden' interval is continuous - if (nextWritePos > playPos && nextWritePos < writePos) - { - // We have a problem here because our write pointer is in the forbiden zone - // This is mainly due to cpu overload. - nextWritePos = writePos; - } -// space = playPos - _NextWritePos; - } - else - { - // The forbiden interval is wrapping - if (nextWritePos > playPos || nextWritePos < writePos) - { - // We have a problem here because our write pointer is in the forbiden zone - // This is mainly due to cpu overload. - nextWritePos = writePos; - } -// space = _SecondaryBufferSize + playPos - _NextWritePos; - } - - // compute the available space to write to - if (nextWritePos > playPos) - { - space = bufferSize + playPos - nextWritePos; - } - else - { - space = playPos - nextWritePos; - } - - return space; -} -*/ -/* -bool CSourceDSound::fill() -{ - bool res = false; - uint8 *ptr1, *ptr2; - DWORD bytes1, bytes2; - DWORD playPos, writePos; - uint32 space; - - - if (_Buffer == NULL) - { - _SecondaryBufferState = NL_DSOUND_SILENCING; - _UserState = NL_DSOUND_STOPPED; - return false; - } - - if (_SecondaryBuffer == 0) - { - return false; - } - - TSampleFormat sampleFormat; - uint freq; - _Buffer->getFormat(sampleFormat, freq); - - - INITTIME(startPos); - - - _SecondaryBuffer->GetCurrentPosition(&playPos, &writePos); - - if (playPos == _NextWritePos) - { - return false; - } - - uint32 nextWritePos = _NextWritePos; - space = getWritePosAndSpace(nextWritePos, playPos, writePos, _SecondaryBufferSize); - - // Don't bother if the number of samples that can be written is too small. - if (space < _UpdateCopySize) - { - return false; - } - - _NextWritePos = nextWritePos; - - uint8* data = ((CBufferDSound*) _Buffer)->getData(); - uint32 available = (_BytesWritten < _BufferSize) ? _BufferSize - _BytesWritten : 0; - - - // The number of samples bytes that will be copied. If bytes is 0 - // than write silence to the buffer. - uint32 bytes = std::min(_UpdateCopySize, available); -// uint32 clear = _UpdateCopySize - available; - - - // Lock the buffer - - INITTIME(startLock); - - - if (!lock(_NextWritePos, _UpdateCopySize, ptr1, bytes1, ptr2, bytes2)) - { - return false; - } - - - INITTIME(startCopy); - - // Start copying the samples - - - if (bytes1 <= bytes) { - -// CFastMem::memcpy(ptr1, data + _BytesWritten, bytes1); - copySampleTo16BitsTrack(ptr1, data + _BytesWritten, bytes1/2, sampleFormat); - _BytesWritten += bytes1; - bytes -= bytes1; - - if (ptr2) - { - if (bytes > 0) - { -// CFastMem::memcpy(ptr2, data + _BytesWritten, bytes); - copySampleTo16BitsTrack(ptr2, data + _BytesWritten, bytes/2, sampleFormat); - _BytesWritten += bytes; - } - - if (bytes < bytes2) - { - if (_Loop) - { - DBGPOS(("[%p] FILL: LOOP", this)); - - //CFastMem::memcpy(ptr2 + bytes, data, bytes2 - bytes); - copySampleTo16BitsTrack(ptr2 + bytes, data, (bytes2 - bytes)/2, sampleFormat); - _BytesWritten = bytes2 - bytes; - } - else - { - memset(ptr2 + bytes, 0, bytes2 - bytes); - _SilenceWritten = bytes2 - bytes; - } - } - } - } - else - { - if (bytes > 0) - { -// CFastMem::memcpy(ptr1, data + _BytesWritten, bytes); - copySampleTo16BitsTrack(ptr1, data + _BytesWritten, bytes/2, sampleFormat); - _BytesWritten += bytes; - } - - if (_Loop) - { - DBGPOS(("[%p] FILL: LOOP", this)); - -// CFastMem::memcpy(ptr1 + bytes, data, bytes1 - bytes); - copySampleTo16BitsTrack(ptr1 + bytes, data, (bytes1 - bytes)/2, sampleFormat); - _BytesWritten = bytes1 - bytes; - - if (ptr2) - { -// CFastMem::memcpy(ptr2, data + _BytesWritten, bytes2); - copySampleTo16BitsTrack(ptr2, data + _BytesWritten, bytes2 / 2, sampleFormat); - _BytesWritten += bytes2; - } - - } - else - { - memset(ptr1 + bytes, 0, bytes1 - bytes); - _SilenceWritten = bytes1 - bytes; - - if (ptr2) - { - memset(ptr2, 0, bytes2); - _SilenceWritten += bytes2; - } - } - - } - - - - - INITTIME(startUnlock); - - // Unlock the buffer - _SecondaryBuffer->Unlock(ptr1, bytes1, ptr2, bytes2); - - - // Update the state variables - - // Check if we've reached the end of the file - if (_BytesWritten == _BufferSize) - { - if (_Loop) - { - // If we're looping, start all over again - DBGPOS(("[%p] FILL: LOOP", this)); - _BytesWritten = 0; - } - else - { - _SecondaryBufferState = NL_DSOUND_SILENCING; - - // Keep track of where tha last sample was written and the position - // of the play cursor relative to the end position. if the _EndState - // is 0, the play cursor is after the end position, 1 otherwise. - _EndPosition = writePos + bytes; - if (_EndPosition >= _SecondaryBufferSize) - { - _EndPosition -= _SecondaryBufferSize; - } - - _EndState = (playPos > _EndPosition)? NL_DSOUND_TAIL1 : NL_DSOUND_TAIL2; - - DBGPOS(("[%p] FILL: SILENCING", this)); - DBGPOS(("[%p] FILL: ENDSTATE=%d, E=%d, P=%d", this, (int) _EndState, _EndPosition, playPos)); - } - } - - - // Update the write pointer - _NextWritePos += bytes1 + bytes2; - if (_NextWritePos >= _SecondaryBufferSize) - { - _NextWritePos -= _SecondaryBufferSize; - } - - DBGPOS(("[%p] FILL: P=%d, W=%d, NW=%d, SZ=%d, BW=%d, S=%d, B=%d", this, playPos, writePos, _NextWritePos, _BufferSize, _BytesWritten, _SilenceWritten, bytes1 + bytes2)); - - -#if NLSOUND_PROFILE - _TotalUpdateSize += bytes1 + bytes2; - _PosTime += CTime::ticksToSecond(startLock - startPos); - _LockTime += CTime::ticksToSecond(startCopy - startLock); - _CopyTime += CTime::ticksToSecond(startUnlock - startCopy); - _UnlockTime += CTime::ticksToSecond(CTime::getPerformanceTime() - startUnlock); - _CopyCount++; -#endif - - - return true; -} -*/ - - - -// ****************************************************************** -/* -bool CSourceDSound::silence() -{ - uint8 *ptr1, *ptr2; - DWORD bytes1, bytes2; - DWORD playPos, writePos; - uint32 space; - - if (_SecondaryBuffer == 0) - { - return false; - } - - INITTIME(startPos); - - _SecondaryBuffer->GetCurrentPosition(&playPos, &writePos); - - if (playPos == _NextWritePos) - { - return false; - } - - space = getWritePosAndSpace(_NextWritePos, playPos, writePos, _SecondaryBufferSize); -*/ -/* else if (playPos > _NextWritePos) - { - space = playPos - _NextWritePos; - } - else - { - space = _SecondaryBufferSize + playPos - _NextWritePos; - } -*/ -/* // Don't bother if the number of samples that can be written is too small. - if (space < _UpdateCopySize) - { - return false; - } - - // Lock the buffer - - INITTIME(startLock); - - if (!lock(_NextWritePos, _UpdateCopySize, ptr1, bytes1, ptr2, bytes2)) - { - return false; - } - - - INITTIME(startCopy); - - // Silence the buffer - memset(ptr1, 0, bytes1); - memset(ptr2, 0, bytes2); - - // Unlock the buffer - - INITTIME(startUnlock); - - _SecondaryBuffer->Unlock(ptr1, bytes1, ptr2, bytes2); - - - // Update the next write position - _NextWritePos += bytes1 + bytes2; - if (_NextWritePos >= _SecondaryBufferSize) - { - _NextWritePos -= _SecondaryBufferSize; - } - - - // Check if all the samples in the buffer are played - if ((playPos > _EndPosition) && (_EndState == NL_DSOUND_TAIL2)) - { - // The buffer played passed the last sample. Flag the source as stopped. - _EndState = NL_DSOUND_ENDED; - DBGPOS(("[%p] SLNC: ENDED", this)); - - // If the buffer was playing, mark it as stopped - if (_UserState == NL_DSOUND_PLAYING) - { - _UserState = NL_DSOUND_STOPPED; - DBGPOS(("[%p] SLNC: STOPPED", this)); - } - } - else if ((playPos < _EndPosition) && (_EndState == NL_DSOUND_TAIL1)) - { - // The play cursor wrapped around the buffer and is now before the end position - _EndState = NL_DSOUND_TAIL2; - DBGPOS(("[%p] FILL: ENDSTATE=%d, E=%d, P=%d", this, (int) _EndState, _EndPosition, playPos)); - } - - - // Update the amount of silence written - _SilenceWritten += bytes1 + bytes2; - if (_SilenceWritten >= _SecondaryBufferSize) - { - // The buffer is now completely filled with silence - _SecondaryBufferState = NL_DSOUND_SILENCED; - DBGPOS(("[%p] SLNC: SILENCED", this)); - - // If the buffer was playing, mark it as stopped - if (_UserState == NL_DSOUND_PLAYING) - { - _UserState = NL_DSOUND_STOPPED; - DBGPOS(("[%p] SLNC: STOPPED*", this)); - } - } - - DBGPOS(("[%p] SLNC: P=%d, W=%d, NW=%d, SZ=%d, BW=%d, S=%d, B=%d", this, playPos, writePos, _NextWritePos, _BufferSize, _BytesWritten, _SilenceWritten, bytes1 + bytes2)); - - -#if NLSOUND_PROFILE - _TotalUpdateSize += bytes1 + bytes2; - _PosTime += CTime::ticksToSecond(startLock - startPos); - _LockTime += CTime::ticksToSecond(startCopy - startLock); - _CopyTime += CTime::ticksToSecond(startUnlock - startCopy); - _UnlockTime += CTime::ticksToSecond(CTime::getPerformanceTime() - startUnlock); - _CopyCount++; -#endif - - return true; -} -*/ - -// ****************************************************************** - -/** - * Calculate the size of the crossfade and set the pointer in the sample buffer - * to the sample that comes after the write cursor in the DirectSound buffer. - * This method also returns the number of samples that have been written after - * the write cursor. - * - */ -/* -void CSourceDSound::getFadeOutSize(uint32 writePos, uint32 &xfadeSize, sint16* &in1, uint32 &writtenTooMuch) -{ - // The number of samples over which we will do the crossfade - xfadeSize = _XFadeSize; - - - // The tricky part of this method is to figger out how many samples of the old - // buffer were written after the write cursor and figger our with what position - // in the old buffer the write cursor corresponds. We have to consider the following - // cases: - // - // - the old buffer just looped, - // - the old buffer is finished, but stil has samples in the DirectSound buffer - // - the default case, i.e. the old buffer is playing somewhere in the middle. - // - - // How many bytes did we write after the write position? - - writtenTooMuch = NLSOUND_DISTANCE(writePos, _NextWritePos, _SecondaryBufferSize); - - DBGPOS(("[%p] FADE: TOO=%d", this, writtenTooMuch)); - - - uint8* data = ((CBufferDSound*) _Buffer)->getData(); - - // If the sound is finished and all the samples are written in the - // buffer, it's possible that there are still samples after the write - // position. If this is the case, we have to do a fade out. If there is - // only silence, we only need to copy without fade. - - if (_SilenceWritten > 0) - { - - if (writtenTooMuch > _SilenceWritten) - { - writtenTooMuch -= _SilenceWritten; - in1 = (sint16*) (data + _BufferSize - writtenTooMuch) ; - - if (writtenTooMuch < 2 * xfadeSize) - { - xfadeSize = writtenTooMuch / 2; - } - } - else - { - xfadeSize = 0; - } - - DBGPOS(("[%p] FADE: END, TOO=%d, S=%d, F=%d", this, writtenTooMuch, _SilenceWritten, xfadeSize)); - } - - // If the sound looped, it's possible that the number of samples - // written is small. In that case, the write cursor is still inside - // the previous loop. All we have to do is fade out the last part - // of the previous loop. - - else if (writtenTooMuch >= _BytesWritten) - { - - writtenTooMuch -= _BytesWritten; - - in1 = (sint16*) (data + _BufferSize - writtenTooMuch) ; - - if (writtenTooMuch < 2 * xfadeSize) - { - xfadeSize = writtenTooMuch / 2; - } - - DBGPOS(("[%p] FADE: LOOPED, TOO=%d, F=%d", this, writtenTooMuch, xfadeSize)); - - } - - // This is the default case. Simply fade from the previous to the next buffer. - // The variable writtenTooMuch tells us how much of the previous sound has - // been written after the current write cursor. We just have to check there - // are enough samples available for the fade. - - else - { - in1 = (sint16*) (data + (sint32) _BytesWritten - writtenTooMuch); - - if (xfadeSize > _BufferSize - _BytesWritten) - { - xfadeSize = _BufferSize - _BytesWritten; - } - - DBGPOS(("[%p] FADE: STD, TOO=%d, F=%d", this, writtenTooMuch, xfadeSize)); - } -} -*/ - - -// ****************************************************************** -/* -void CSourceDSound::crossFade() -{ - uint8 *ptr1, *ptr2; - DWORD bytes1, bytes2; - DWORD playPos, writePos; - uint32 i; - - - - if (_Buffer == NULL) - { - return; - } - - if (_SecondaryBuffer == 0) - { - return; - } - - - INITTIME(start); - - - EnterCriticalSection(&_CriticalSection); - - TSampleFormat sampleFormat; - uint freq; - _Buffer->getFormat(sampleFormat, freq); - - - // The source is currently playing another buffer. We will do a hot - // swap between the old and the new buffer. DirectSound maintains two - // cursors into the buffer: the play cursor and the write cursor. - // The write cursor indicates where we can start writing the new samples. - // To avoid clicks, we have to do a cross fade between the old buffer and - // the new buffer. - - _SecondaryBuffer->GetCurrentPosition(&playPos, &writePos); - - - // The number of bytes we will write to the DirectSound buffer - uint32 bytes = _SwapCopySize; - if (bytes > _SwapBuffer->getSize()) - { - bytes = _SwapBuffer->getSize(); - } - - - // Lock the DirectSound buffer - - if (FAILED(_SecondaryBuffer->Lock(writePos, bytes, (LPVOID*) &ptr1, &bytes1, (LPVOID*) &ptr2, &bytes2, 0))) - { - LeaveCriticalSection(&_CriticalSection); - throw ESoundDriver("Failed to lock the DirectSound secondary buffer"); - } - - - sint16* in1; - uint8* data1 = ((CBufferDSound*) _Buffer)->getData(); - uint8* data2 = ((CBufferDSound*) _SwapBuffer)->getData(); - sint16* in2 = (sint16*) data2; - sint16* out = (sint16*) ptr1; - - // The number of samples over which we will do the crossfade - uint32 xfadeSize; - uint32 xfadeByteSize; - uint32 writtenTooMuch; - - getFadeOutSize(writePos, xfadeSize, in1, writtenTooMuch); - xfadeByteSize = 2 * xfadeSize; - -#define MIX 1 - - -#if MIX - float incr, amp1, amp2; - - if (xfadeSize == 0) - { - amp1 = 0.0f; - amp2 = 1.0f; - incr = 0.0f; - } - else - { - amp1 = 1.0f; - amp2 = 0.0f; - incr = 1.0f / xfadeSize; - } - -#else - float incr, amp1; - - if (xfadeSize == 0) - { - amp1 = 0.0f; - incr = 0.0f; - } - else - { - amp1 = 1.0f; - incr = 1.0f / xfadeSize; - } - -#endif - - - // Start copying the samples - - - // In the first case, the cross fade is completely contained in the first buffer - // pointed to by ptr1. - if (xfadeByteSize < bytes1) - { - - // Do cross fade - - for (i = 0; i < xfadeSize; i++) - { -#if MIX - out[i] = (sint16) (amp1 * in1[i] + amp2 * in2[i]); - amp1 -= incr; - amp2 += incr; -#else - out[i] = (sint16) (amp1 * in1[i]); - amp1 -= incr; -#endif - } - - // Copy remaining samples - -#if MIX -// CFastMem::memcpy(ptr1 + xfadeByteSize, data2 + xfadeByteSize, bytes1 - xfadeByteSize); - copySampleTo16BitsTrack(ptr1 + xfadeByteSize, data2 + xfadeByteSize, (bytes1 - xfadeByteSize)/2, sampleFormat); - - _BytesWritten = bytes1; -#else -// CFastMem::memcpy(ptr1 + xfadeByteSize, data2, bytes1 - xfadeByteSize); - copySampleTo16BitsTrack(ptr1 + xfadeByteSize, data2, (bytes1 - xfadeByteSize)/2, sampleFormat); - _BytesWritten = bytes1 - xfadeByteSize; -#endif - - if (ptr2) - { - //CFastMem::memcpy(ptr2, data2 + _BytesWritten, bytes2); - copySampleTo16BitsTrack(ptr2, data2 + _BytesWritten, bytes2/2, sampleFormat); - _BytesWritten += bytes2; - } - - } - - // In the second case, the cross fade stretches over the first and the second buffers. - else - { - - uint32 fade1 = bytes1 / 2; - uint32 fade2 = xfadeSize - fade1; - - // Do cross fade - - // Part 1, start at ptr1 - for (i = 0; i < fade1; i++) - { -#if MIX - out[i] = (sint16) (amp1 * in1[i] + amp2 * in2[i]); - amp1 -= incr; - amp2 += incr; -#else - out[i] = (sint16) (amp1 * in1[i]); - amp1 -= incr; -#endif - } -#if MIX - _BytesWritten = bytes1; -#else - _BytesWritten = 0; -#endif - - - if (ptr2) - { - out = (sint16*) ptr2; - - // Part 2, ontinue at ptr2 - for (uint32 k = 0; i < xfadeSize; i++, k++) - { -#if MIX - out[k] = (sint16) (amp1 * in1[i] + amp2 * in2[i]); - amp1 -= incr; - amp2 += incr; -#else - out[k] = (sint16) (amp1 * in1[i]); - amp1 -= incr; -#endif - } - - // Copy remaining samples -#if MIX -// CFastMem::memcpy(ptr2 + 2 * k, data2 + _BytesWritten + 2 * k, bytes2 - 2 * k); - copySampleTo16BitsTrack(ptr2 + 2 * k, data2 + _BytesWritten + 2 * k, (bytes2 - 2 * k)/2, sampleFormat); - _BytesWritten += bytes2; -#else - //CFastMem::memcpy(ptr2 + 2 * k, data2, bytes2 - 2 * k); - copySampleTo16BitsTrack(ptr2 + 2 * k, data2, (bytes2 - 2 * k)/2, sampleFormat); - _BytesWritten = bytes2 - 2 * k; -#endif - } - } - - - // Unlock the DirectSound buffer - _SecondaryBuffer->Unlock(ptr1, bytes1, ptr2, bytes2); - - - // Update the state variables - - _SilenceWritten = 0; - - _NextWritePos = (writePos + bytes1 + bytes2); - if (_NextWritePos >= _SecondaryBufferSize) - { - _NextWritePos -= _SecondaryBufferSize; - } - - - - _SecondaryBufferState = NL_DSOUND_FILLING; - - - // Swap the two buffers - _BufferSize = _SwapBuffer->getSize(); - _Buffer = _SwapBuffer; - _SwapBuffer = 0; - - setPitch(_Freq); - - // Check if we've reached the end of the file - if (_BytesWritten == _BufferSize) - { - if (_Loop) - { - _BytesWritten = 0; - } - else - { - _SecondaryBufferState = NL_DSOUND_SILENCING; - } - } - - - DBGPOS(("[%p] XFADE", this)); - DBGPOS(("[%p] P=%d, W=%d, NW=%d, SZ=%d, BW=%d, B=%d", this, playPos, writePos, _NextWritePos, _BufferSize, _BytesWritten, bytes1 + bytes2)); - - - - LeaveCriticalSection(&_CriticalSection); - - -#if NLSOUND_PROFILE - _LastSwapTime = CTime::ticksToSecond(CTime::getPerformanceTime() - start); - _TotalSwapTime += _LastSwapTime; - _MaxSwapTime = (_LastSwapTime > _MaxSwapTime) ? _LastSwapTime : _MaxSwapTime; - _MinSwapTime = (_LastSwapTime < _MinSwapTime) ? _LastSwapTime : _MinSwapTime; - _SwapCount++; -#endif - -} -*/ - - -// ****************************************************************** -/* -void CSourceDSound::fadeOut() -{ - uint8 *ptr1, *ptr2; - DWORD bytes1, bytes2; - DWORD playPos, writePos; - uint32 i; - - - if (_Buffer == NULL) - { - _SecondaryBufferState = NL_DSOUND_SILENCING; - _UserState = NL_DSOUND_STOPPED; - return; - } - - if (_SecondaryBuffer == 0) - { - return; - } - - INITTIME(start); - - - _SecondaryBuffer->GetCurrentPosition(&playPos, &writePos); - - - // Lock the DirectSound buffer - - if (FAILED(_SecondaryBuffer->Lock(writePos, _SwapCopySize, (LPVOID*) &ptr1, &bytes1, (LPVOID*) &ptr2, &bytes2, 0))) - { - throw ESoundDriver("Failed to lock the DirectSound secondary buffer"); - } - - - - // in1 points to the position in the old buffer where the fade out starts - sint16* in1; - sint16* out = (sint16*) ptr1; - - // The number of samples over which we will do the crossfade - uint32 xfadeSize; - uint32 xfadeByteSize; - uint32 writtenTooMuch; - - getFadeOutSize(writePos, xfadeSize, in1, writtenTooMuch); - xfadeByteSize = 2 * xfadeSize; - - float amp1, incr; - - if (xfadeSize == 0) - { - amp1 = 0.0f; - incr = 0.0f; - } - else - { - amp1 = 1.0f; - incr = 1.0f / xfadeSize; - } - - - if (writtenTooMuch > _BytesWritten) - { - // The buffer looped. Count backwards from the end of the file. - _BytesWritten = _BufferSize - writtenTooMuch; - } - else - { - _BytesWritten -= writtenTooMuch; - } - - - // Start copying the samples - - - // In the first case, the fade out is completely contained in the first buffer - // pointed to by ptr1. - if (xfadeByteSize < bytes1) - { - - // Do cross fade - - for (i = 0; i < xfadeSize; i++) - { - out[i] = (sint16) (amp1 * in1[i]); - amp1 -= incr; - } - - // Copy remaining samples - - memset(ptr1 + xfadeByteSize, 0, bytes1 - xfadeByteSize); - _SilenceWritten = bytes1 - xfadeByteSize; - - if (ptr2) - { - memset(ptr2, 0, bytes2); - _SilenceWritten += bytes2; - } - - } - - // In the second case, the fade out stretches over the first and the second buffers. - else - { - - uint32 fade1 = bytes1 / 2; - uint32 fade2 = xfadeSize - fade1; - - // Do cross fade - - // Part 1, start at ptr1 - for (i = 0; i < fade1; i++) - { - out[i] = (sint16) (amp1 * in1[i]); - amp1 -= incr; - } - - - if (ptr2) - { - out = (sint16*) ptr2; - - // Part 2, continue at ptr2 - for (uint32 k = 0; i < xfadeSize; i++, k++) - { - out[k] = (sint16) (amp1 * in1[i]); - amp1 -= incr; - } - - // Clear remaining samples - memset(ptr2 + 2 * k, 0, bytes2 - 2 * k); - _SilenceWritten = bytes2 - 2 * k; - } - - } - - - _BytesWritten += xfadeByteSize; - - - // Unlock the DirectSound buffer - _SecondaryBuffer->Unlock(ptr1, bytes1, ptr2, bytes2); - - - // Update the next write position - _NextWritePos = (writePos + bytes1 + bytes2); - if (_NextWritePos >= _SecondaryBufferSize) - { - _NextWritePos -= _SecondaryBufferSize; - } - - - _SecondaryBufferState = NL_DSOUND_SILENCING; - DBGPOS(("[%p] FDOU: SILENCING", this)); - - // Keep track of where tha last sample was written and the position - // of the play cursor relative to the end position. if the _EndState - // is 0, the play cursor is after the end position, 1 otherwise. - _EndPosition = writePos + xfadeSize; - if (_EndPosition >= _SecondaryBufferSize) - { - _EndPosition -= _SecondaryBufferSize; - } - - _EndState = (playPos > _EndPosition)? NL_DSOUND_TAIL1 : NL_DSOUND_TAIL2; - DBGPOS(("[%p] FDOU: ENDSTATE=%d, E=%d, P=%d", this, (int) _EndState, _EndPosition, playPos)); - - - DBGPOS(("[%p] FDOU: P=%d, W=%d, NW=%d, SZ=%d, BW=%d, S=%d, B=%d", this, playPos, writePos, _NextWritePos, _BufferSize, _BytesWritten, _SilenceWritten, bytes1 + bytes2)); - - - -#if NLSOUND_PROFILE - _LastSwapTime = CTime::ticksToSecond(CTime::getPerformanceTime() - start); - _TotalSwapTime += _LastSwapTime; - _MaxSwapTime = (_LastSwapTime > _MaxSwapTime) ? _LastSwapTime : _MaxSwapTime; - _MinSwapTime = (_LastSwapTime < _MinSwapTime) ? _LastSwapTime : _MinSwapTime; - _SwapCount++; -#endif - -} -*/ -// ****************************************************************** -/* -void CSourceDSound::fadeIn() -{ - bool res = false; - uint8 *ptr1, *ptr2; - DWORD bytes1, bytes2; - DWORD playPos, writePos; - - - if (_Buffer == NULL) - { - _SecondaryBufferState = NL_DSOUND_SILENCING; - _UserState = NL_DSOUND_STOPPED; - return; - } - - if (_SecondaryBuffer == 0) - { - return; - } - - INITTIME(startPos); - - TSampleFormat sampleFormat; - uint freq; - _Buffer->getFormat(sampleFormat, freq); - - // Set the correct pitch for this sound -// setPitch(_Freq); -// setPitch(_SecondaryBuffer->GetFrequency()); - - // Set the correct volume - // FIXME: a bit of a hack - const CVector &pos = CListenerDSound::instance()->getPos(); - updateVolume(pos); - - - _SecondaryBuffer->GetCurrentPosition(&playPos, &writePos); - - uint8* data = ((CBufferDSound*) _Buffer)->getData(); - uint32 available = (_BytesWritten < _BufferSize) ? _BufferSize - _BytesWritten : 0; - uint32 bytes = NLSOUND_MIN(_SwapCopySize, available); -// uint32 clear = _SwapCopySize - available; - - - _SilenceWritten = 0; - - // Lock the buffer - - INITTIME(startLock); - - - if (!lock(writePos, _SwapCopySize, ptr1, bytes1, ptr2, bytes2)) - { - return; - } - - - INITTIME(startCopy); - - // Start copying the samples - - if (bytes1 <= bytes) { - -// CFastMem::memcpy(ptr1, data + _BytesWritten, bytes1); - copySampleTo16BitsTrack(ptr1, data + _BytesWritten, bytes1/2, sampleFormat); - _BytesWritten += bytes1; - bytes -= bytes1; - - if (ptr2) - { - if (bytes > 0) - { - //CFastMem::memcpy(ptr2, data + _BytesWritten, bytes); - copySampleTo16BitsTrack(ptr2, data + _BytesWritten, bytes/2, sampleFormat); - _BytesWritten += bytes; - } - - if (bytes < bytes2) - { - if (_Loop) - { - DBGPOS(("[%p] FDIN: LOOP", this)); - - //CFastMem::memcpy(ptr2 + bytes, data, bytes2 - bytes); - copySampleTo16BitsTrack(ptr2 + bytes, data, (bytes2 - bytes)/2, sampleFormat); - _BytesWritten = bytes2 - bytes; - } - else - { - memset(ptr2 + bytes, 0, bytes2 - bytes); - _SilenceWritten = bytes2 - bytes; - } - } - } - } - else - { - if (bytes > 0) - { - //CFastMem::memcpy(ptr1, data + _BytesWritten, bytes); - copySampleTo16BitsTrack(ptr1, data + _BytesWritten, bytes/2, sampleFormat); - _BytesWritten += bytes; - } - - if (_Loop) - { - DBGPOS(("[%p] FDIN: LOOP", this)); - - //CFastMem::memcpy(ptr1 + bytes, data, bytes1 - bytes); - copySampleTo16BitsTrack(ptr1 + bytes, data, (bytes1 - bytes) / 2, sampleFormat); - _BytesWritten = bytes1 - bytes; - - if (ptr2) - { - //CFastMem::memcpy(ptr2, data + _BytesWritten, bytes2); - copySampleTo16BitsTrack(ptr2, data + _BytesWritten, bytes2/2, sampleFormat); - _BytesWritten += bytes2; - } - } - else - { - memset(ptr1 + bytes, 0, bytes1 - bytes); - _SilenceWritten = bytes1 - bytes; - - if (ptr2) - { - memset(ptr2, 0, bytes2); - _SilenceWritten += bytes2; - } - } - } - - - INITTIME(startUnlock); - - // Unlock the buffer - _SecondaryBuffer->Unlock(ptr1, bytes1, ptr2, bytes2); - - - // Update the state variables - - _SecondaryBufferState = NL_DSOUND_FILLING; - DBGPOS(("[%p] FDIN: FILLING", this)); - - - // Check if we've reached the end of the file - if (_BytesWritten == _BufferSize) - { - if (_Loop) - { - // If we're looping, start all over again - DBGPOS(("[%p] FDIN: LOOP", this)); - _BytesWritten = 0; - } - else - { - _SecondaryBufferState = NL_DSOUND_SILENCING; - - // Keep track of where tha last sample was written and the position - // of the play cursor relative to the end position. if the _EndState - // is NL_DSOUND_TAIL1, the play cursor is after the end position, - // NL_DSOUND_TAIL2 otherwise. - _EndPosition = writePos + bytes; - if (_EndPosition >= _SecondaryBufferSize) - { - _EndPosition -= _SecondaryBufferSize; - } - - _EndState = (playPos > _EndPosition)? NL_DSOUND_TAIL1 : NL_DSOUND_TAIL2; - - DBGPOS(("[%p] FDIN: SILENCING", this)); - DBGPOS(("[%p] FDIN: ENDSTATE=%d, E=%d, P=%d", this, (int) _EndState, _EndPosition, playPos)); - } - } - - - // Update the write pointer - _NextWritePos = writePos + bytes1 + bytes2; - if (_NextWritePos >= _SecondaryBufferSize) - { - _NextWritePos -= _SecondaryBufferSize; - } - - DBGPOS(("[%p] FDIN: P=%d, W=%d, NW=%d, SZ=%d, BW=%d, S=%d, B=%d", this, playPos, writePos, _NextWritePos, _BufferSize, _BytesWritten, _SilenceWritten, bytes1 + bytes2)); - - -#if NLSOUND_PROFILE - _TotalUpdateSize += bytes1 + bytes2; - _PosTime += CTime::ticksToSecond(startLock - startPos); - _LockTime += CTime::ticksToSecond(startCopy - startLock); - _CopyTime += CTime::ticksToSecond(startUnlock - startCopy); - _UnlockTime += CTime::ticksToSecond(CTime::getPerformanceTime() - startUnlock); - _CopyCount++; -#endif - - -} - -*/ - -} // NLSOUND diff --git a/code/nel/src/sound/driver/dsound/source_dsound.h b/code/nel/src/sound/driver/dsound/source_dsound.h deleted file mode 100644 index 1aa2d5625..000000000 --- a/code/nel/src/sound/driver/dsound/source_dsound.h +++ /dev/null @@ -1,517 +0,0 @@ -// NeL - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as -// published by the Free Software Foundation, either version 3 of the -// License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -#ifndef NL_SOURCE_DSOUND_H -#define NL_SOURCE_DSOUND_H - -#include "nel/sound/driver/source.h" -#include "nel/sound/driver/sound_driver.h" -#include "nel/sound/driver/buffer.h" - -namespace NLSOUND { - -class CBufferDSound; - -/** Keep trace of following states of the DirectSound buffer: - * - the buffer is being filled with samples (filling), - * - the buffer still contains samples but silence is being written (silencing), - * - the buffer contains no samples but only silence (silenced) - */ -/*enum TSourceDSoundBufferState -{ - /// The buffer is being filled with samples (filling), - NL_DSOUND_FILLING, - /// The buffer still contains samples but silence is being written (silencing), - NL_DSOUND_SILENCING, - /// The buffer contains no samples but only silence (silenced) - NL_DSOUND_SILENCED -} ; -/* - -/** The state of the source as experienced by the user: playing, paused, and stopped. */ -/* -enum TSourceDSoundUserState -{ - /// The buffer is playing. - NL_DSOUND_PLAYING, - /// The buffer is paused. - NL_DSOUND_PAUSED, - /// The buffer is stopped. - NL_DSOUND_STOPPED -}; -*/ - -/** To figger out whether the sound device has played all the samples in the buffer, - * the position of the play cursor is traced relatively to the position of the last - * sample in the buffer. - */ -/* -enum TSourceDSoundEndState -{ - NL_DSOUND_TAIL1, - NL_DSOUND_TAIL2, - NL_DSOUND_ENDED -}; -*/ - -/** - * DirectSound sound source - * - - * For arguments as 3D vectors, use the NeL vector coordinate system - * - * \author Peter Hanappe - * \author Nevrax France - * \date 2002 - */ -class CSourceDSound : public ISource -{ - friend class CSoundDriverDSound; - -public: - /// Constructor - CSourceDSound(uint sourcename = 0); - /// Destructor - virtual ~CSourceDSound(); - - /// Initialize the DirectSound buffers. Called by the sound driver only. - void init(LPDIRECTSOUND directSound, bool useEax); - - /// \name Initialization - //@{ - /// Enable or disable streaming mode. Source must be stopped to call this. - virtual void setStreaming(bool streaming); - /** Set the buffer that will be played (no streaming) - * If the buffer is stereo, the source mode becomes stereo and the source relative mode is on, - * otherwise the source is considered as a 3D source. Use submitStreamingBuffer for streaming. - */ - virtual void setStaticBuffer(IBuffer *buffer); - /// Return the buffer, or NULL if streaming is used. Not available for streaming. - virtual IBuffer *getStaticBuffer(); - /// Add a buffer to the streaming queue. A buffer of 100ms length is optimal for streaming. - /// Should be called by a thread which checks countStreamingBuffers every 100ms. - virtual void submitStreamingBuffer(IBuffer *buffer); - /// Return the amount of buffers in the queue (playing and waiting). 3 buffers is optimal. - virtual uint countStreamingBuffers() const; - //@} - - /// \name Playback control - //@{ - /// Set looping on/off for future playbacks (default: off), not available for streaming - virtual void setLooping(bool l); - /// Return the looping state - virtual bool getLooping() const; - - /** Play the static buffer (or stream in and play). - * This method can return false if the sample for this sound is unloaded. - */ - virtual bool play(); - /// Stop playing - virtual void stop(); - /// Pause. Call play() to resume. - virtual void pause(); - /// Return true if play() or pause(), false if stop(). - virtual bool isPlaying() const; - /// Return true if playing is finished or stop() has been called. - virtual bool isStopped() const; - /// Return true if the playing source is paused - virtual bool isPaused() const; - /// Returns the number of milliseconds the source has been playing - virtual uint32 getTime(); - //@} - - /// \name Source properties - //@{ - /** Set the position vector (default: (0,0,0)). - * 3D mode -> 3D position - * st mode -> x is the pan value (from left (-1) to right (1)), set y and z to 0 - */ - virtual void setPos(const NLMISC::CVector& pos, bool deffered = true); - /** Get the position vector. - * See setPos() for details. - */ - virtual const NLMISC::CVector &getPos() const; - /// Set the velocity vector (3D mode only, ignored in stereo mode) (default: (0,0,0)) - virtual void setVelocity(const NLMISC::CVector& vel, bool deferred = true); - /// Get the velocity vector - virtual void getVelocity(NLMISC::CVector& vel) const; - /// Set the direction vector (3D mode only, ignored in stereo mode) (default: (0,0,0) as non-directional) - virtual void setDirection(const NLMISC::CVector& dir); - /// Get the direction vector - virtual void getDirection(NLMISC::CVector& dir) const; - /** Set the gain (volume value inside [0 , 1]). (default: 1) - * 0.0 -> silence - * 0.5 -> -6dB - * 1.0 -> no attenuation - * values > 1 (amplification) not supported by most drivers - */ - virtual void setGain(float gain); - /// Get the gain - virtual float getGain() const; - /** Shift the frequency. 1.0f equals identity, each reduction of 50% equals a pitch shift - * of one octave. 0 is not a legal value. - */ - virtual void setPitch(float pitch); - /// Get the pitch - virtual float getPitch() const; - /// Set the source relative mode. If true, positions are interpreted relative to the listener position - virtual void setSourceRelativeMode(bool mode); - /// Get the source relative mode - virtual bool getSourceRelativeMode() const; - /// Set the min and max distances (default: 1, MAX_FLOAT) (3D mode only) - virtual void setMinMaxDistances(float mindist, float maxdist, bool deferred = true); - /// Get the min and max distances - virtual void getMinMaxDistances(float& mindist, float& maxdist) const; - /// Set the cone angles (in radian) and gain (in [0 , 1]) (default: 2PI, 2PI, 0) - virtual void setCone(float innerAngle, float outerAngle, float outerGain); - /// Get the cone angles (in radian) - virtual void getCone(float& innerAngle, float& outerAngle, float& outerGain) const; - /** Set the alpha value for the volume-distance curve - * - * Useful only with OptionManualRolloff. value from -1 to 1 (default 0) - * - * alpha.0: the volume will decrease linearly between 0dB and -100 dB - * alpha = 1.0: the volume will decrease linearly between 1.0 and 0.0 (linear scale) - * alpha = -1.0: the volume will decrease inversely with the distance (1/dist). This - * is the default used by DirectSound/OpenAL - * - * For any other value of alpha, an interpolation is be done between the two - * adjacent curves. For example, if alpha equals 0.5, the volume will be halfway between - * the linear dB curve and the linear amplitude curve. - */ - virtual void setAlpha(double a); - //@} - - /// \name Direct output - //@{ - /// Enable or disable direct output [true/false], default: true - virtual void setDirect(bool enable = true); - /// Return if the direct output is enabled - virtual bool getDirect() const; - /// Set the gain for the direct path - virtual void setDirectGain(float gain); - /// Get the gain for the direct path - virtual float getDirectGain() const; - - /// Enable or disable the filter for the direct channel - virtual void enableDirectFilter(bool enable = true); - /// Check if the filter on the direct channel is enabled - virtual bool isDirectFilterEnabled() const; - /// Set the filter parameters for the direct channel - virtual void setDirectFilter(TFilter filter, float lowFrequency, float highFrequency, float passGain); - /// Get the filter parameters for the direct channel - virtual void getDirectFilter(TFilter &filterType, float &lowFrequency, float &highFrequency, float &passGain) const; - /// Set the direct filter gain - virtual void setDirectFilterPassGain(float passGain); - /// Get the direct filter gain - virtual float getDirectFilterPassGain() const; - //@} - - /// \name Effect output - //@{ - /// Set the effect send for this source, NULL to disable. [IEffect], default: NULL - virtual void setEffect(IReverbEffect *reverbEffect); - /// Get the effect send for this source - virtual IEffect *getEffect() const; - /// Set the gain for the effect path - virtual void setEffectGain(float gain); - /// Get the gain for the effect path - virtual float getEffectGain() const; - - /// Enable or disable the filter for the effect channel - virtual void enableEffectFilter(bool enable = true); - /// Check if the filter on the effect channel is enabled - virtual bool isEffectFilterEnabled() const; - /// Set the filter parameters for the effect channel - virtual void setEffectFilter(TFilter filter, float lowFrequency, float highFrequency, float passGain); - /// Get the filter parameters for the effect channel - virtual void getEffectFilter(TFilter &filterType, float &lowFrequency, float &highFrequency, float &passGain) const; - /// Set the effect filter gain - virtual void setEffectFilterPassGain(float passGain); - /// Get the effect filter gain - virtual float getEffectFilterPassGain() const; - //@} - - /// Return the OpenAL source name - uint sourceName() { return _SourceName; } - - /// Returns the buffer associated with this source. - IBuffer *getBuffer(); - - /// Reset the source before reuse - void reset(); - - /// Update the source (e.g. continue to stream the data in) - bool update(); - - /// Update the source's volume according to its distance and fade out curve. - /// It takes the current position of the listener as argument. - void updateVolume(const NLMISC::CVector& listener); - -private: - - void copySampleTo16BitsTrack(void *dst, void *src, uint nbSample, TSampleFormat sourceFormat); - - enum TSourceState - { - source_stopped, - source_playing, - source_silencing, - source_swap_pending - }; - - - /// Release all DirectSound resources - void release(); - - // The minimum size of available space in the DS buffer for update - static const uint32 _UpdateCopySize; - // The size of the samples that are copied when buffers are swapped - static const uint32 _SwapCopySize; - // The number of channels - static const uint _DefaultChannels; - // The default sample rate - static const uint _DefaultSampleRate; - // The default sample size - static const uint _DefaultSampleSize; - // The length of the crossfade, in samples - static const uint32 _XFadeSize; - - /// The play and write cursors - struct TCursors - { - uint32 PlayCursor; - uint32 WriteCursor; - uint32 WriteSize; - }; - - /// A locked buffer info. - struct TLockedBufferInfo - { - // First locked part. - sint16 *Ptr1; - uint32 Size1; - - // second locked part (or 0 if none) - sint16 *Ptr2; - uint32 Size2; - }; - - // Utility function that locks the DirectSound buffer and restores it if it was lost. -// bool lock(uint32 writePos, uint32 size, uint8* &ptr1, DWORD &bytes1, uint8* &ptr2, DWORD &bytes2); - bool lock(uint32 writePos, uint32 size, TLockedBufferInfo &lockedInfo); - - // Utility function that unlocks the DirectSound buffer -// bool unlock(uint8* ptr1, DWORD bytes1, uint8* ptr2, DWORD bytes2); - bool unlock(const TLockedBufferInfo &lockedInfo); - - void getCursors(TCursors &cursors); - uint32 checkFillCursor(); - - - void fillData(const TLockedBufferInfo &lbi, int nbSample); - void fillData(sint16 *dst, uint nbSample); - void fillSilence(const TLockedBufferInfo &lbi, int nbSample); - - void xfade(const TLockedBufferInfo &lbi, sint16 *src); - void fadeOut(const TLockedBufferInfo &lbi); - void fadeIn(const TLockedBufferInfo &lbi); - - void advanceFill(TLockedBufferInfo &lbi, uint nbSample); - - - - // Replace the current buffer with the swap buffer - void swap(); - // getFadeOutSize() calculates how many samples have been written after the - // write cursor in the DirectSound buffer. This value is returned in the - // writtenTooMuch variable. The xfadeSize contains the number of samples over - // which to do a xfade or fade out, and in1 points to the sample in the sample - // buffer where to start the fade. -// void getFadeOutSize(uint32 writePos, uint32& xfadeSize, sint16* &in1, uint32 &writtenTooMuch); - - // Fill the buffer with fresh samples. Should be called inside the critical zone. - bool fill(); - // Fill the buffer with sparkling silence. Should be called inside the critical zone. - bool silence(); - // Do a cross fade between the current buffer and the buffer stored in the _SwapBuffer - // variable. Call inside the critical zone. - void crossFade(); - // Fade out the current buffer. Call inside the critical zone. - void fadeOut(); - // Fade in the current buffer. Call inside the critical zone. - void fadeIn(); - /// Check whether the play position has advanced enough to require an update - bool needsUpdate(); - - - // Source name - uint _SourceName; - - - TSourceState _State; -// uint32 _FillCursor; - - // The size of the sound buffer, in bytes -// uint32 _BufferSize; - - IBuffer *_Sample; - // Size of the buffer in sample - uint _SampleSize; - // Position in the buffer in sample. - uint _SampleOffset; - // The number of sample realy played (depend on play cursor). - uint32 _PlayOffset; - TSampleFormat _Format; - uint _SampleFreq; - - - // The frequency of the source [0,10], i.e. slowed down or accelerated - float _Freq; - // The sample rate of the source (= _Freq * _Buffer sample rate) - uint32 _SampleRate; - - - IBuffer *_NextSample; - - uint32 _LastPlayPos; - uint32 _FillOffset; - uint32 _SilenceWriten; - - // The next sound buffer -// IBuffer *_SwapBuffer; - - // To loop or not to loop - bool _Loop; - - // The state of the source (playing, paused, stopped) -// TSourceDSoundUserState _UserState; - - // DirectSound secondary buffer - LPDIRECTSOUNDBUFFER _SecondaryBuffer; - // The byte size of the DirectSound secondary buffers - static const uint32 _SecondaryBufferSize; - // The mask for the buffer size - static const uint32 _SizeMask; - // 3D interface of the secondary buffer. - LPDIRECTSOUND3DBUFFER _3DBuffer; - // The critial section object to protect the swap and update functions - CRITICAL_SECTION _CriticalSection; - - // The state for ADPCM decompression. - IBuffer::TADPCMState _ADPCMState; - - - // The state of the DirectSound buffer (filling, silencing, silenced) -// TSourceDSoundBufferState _SecondaryBufferState; - - - - // The next position in the DirectSound buffer where we should write next -// uint32 _NextWritePos; - - // The total number of bytes written from the current sound buffer -// uint32 _BytesWritten; - - // The amount of silence written (in bytes) after the end of the current sound buffer -// uint32 _SilenceWritten; - - // The position of the last audio sample written. -// uint32 _EndPosition; - - - // The state of the buffer to reach the end of the audio samples. To flag the buffer as - // STOPPED, we have to make sure all the samples in the buffer are played. The play - // cursor in the DirectSound buffer is inspected and when it crosses the position of - // the last sample written (_EndPosition) the buffer is flagged as stopped. The _EndState - // field is used to keep a trace of the whereabouts of the play cursor. -// TSourceDSoundEndState _EndState; - - - // Has this source been handed out. -/* bool _IsUsed; - - // Set the 'used' state of the source. Managed by the driver. - void setUsed(bool v) { _IsUsed = v; } - - // Return the 'used' state of the source - bool isUsed() { return _IsUsed; } -*/ - sint32 _Volume; - float _Gain; - double _Alpha; - NLMISC::CVector _Pos; - bool _PosRelative; - -#if EAX_AVAILABLE == 1 - LPKSPROPERTYSET _EAXSource; -#endif - - -#if NLSOUND_PROFILE - -public: - - static double _LastSwapTime; - static double _TotalSwapTime; - static double _MaxSwapTime; - static double _MinSwapTime; - static uint32 _SwapCount; - - static double _TotalUpdateTime; - static double _MaxUpdateTime; - static double _MinUpdateTime; - static uint32 _UpdateCount; - static uint32 _TotalUpdateSize; - - static double _PosTime; - static double _LockTime; - static double _CopyTime; - static double _UnlockTime; - static uint32 _CopyCount; - -public: - - static double getTestLast() { return 1000.0f * _LastSwapTime; }; - static double getTestMax() { return 1000.0f * _MaxSwapTime; }; - static double getTestMin() { return 1000.0f * _MinSwapTime; }; - static double getTestAverage() { return (_SwapCount > 0) ? 1000.0f * _TotalSwapTime / _SwapCount : 0.0; }; - - static double getAveragePosTime() { return (_CopyCount > 0) ? 1000.0f * _PosTime / _CopyCount : 0.0; }; - static double getAverageLockTime() { return (_CopyCount > 0) ? 1000.0f * _LockTime / _CopyCount : 0.0; }; - static double getAverageCopyTime() { return (_CopyCount > 0) ? 1000.0f * _CopyTime / _CopyCount : 0.0; }; - static double getAverageUnlockTime() { return (_CopyCount > 0) ? 1000.0f * _UnlockTime / _CopyCount : 0.0; }; - static double getAverageCumulTime() { return (_CopyCount > 0) ? 1000.0f * (_PosTime + _LockTime + _CopyTime + _UnlockTime) / _CopyCount : 0.0; }; - static uint getAverageUpdateSize() { return (_CopyCount > 0) ? (uint) (_TotalUpdateSize / _CopyCount) : 0; }; - - static double getMaxUpdateTime() { return 1000.0f * _MaxUpdateTime; }; - static double getMinUpdateTime() { return 1000.0f * _MinUpdateTime; }; - static double getAverageUpdateTime() { return (_UpdateCount > 0) ? 1000.0f * _TotalUpdateTime / _UpdateCount : 0.0; }; - - static double getTotalUpdateTime() { return 1000.0f * _TotalUpdateTime; }; - static double getUpdateBytesPerMsec() { return (_UpdateCount > 0) ? _TotalUpdateSize / _TotalUpdateTime / 1000.0 : 0.0; } - -#endif - -}; - - -} // NLSOUND - - -#endif // NL_SOURCE_DSOUND_H - -/* End of source_al.h */ diff --git a/code/nel/src/sound/driver/dsound/stddsound.cpp b/code/nel/src/sound/driver/dsound/stddsound.cpp deleted file mode 100644 index f4dd1fa59..000000000 --- a/code/nel/src/sound/driver/dsound/stddsound.cpp +++ /dev/null @@ -1,17 +0,0 @@ -// NeL - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as -// published by the Free Software Foundation, either version 3 of the -// License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -#include "stddsound.h" diff --git a/code/nel/src/sound/driver/dsound/stddsound.h b/code/nel/src/sound/driver/dsound/stddsound.h deleted file mode 100644 index cb953e630..000000000 --- a/code/nel/src/sound/driver/dsound/stddsound.h +++ /dev/null @@ -1,58 +0,0 @@ -// NeL - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as -// published by the Free Software Foundation, either version 3 of the -// License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -#ifndef STDDSOUND_H -#define STDDSOUND_H - -#if defined(_MSC_VER) && defined(_DEBUG) -#define _CRTDBG_MAP_ALLOC -#include -#include -#define DEBUG_NEW new(_NORMAL_BLOCK, __FILE__, __LINE__) -#endif - -#include "nel/misc/types_nl.h" - -#define EAX_AVAILABLE 0 - -#if EAX_AVAILABLE -# include -#endif - -#include -#include - -#include -#include -#include - -#include "nel/misc/common.h" -#include "nel/misc/time_nl.h" -#include "nel/misc/fast_mem.h" -#include "nel/misc/debug.h" -#include "nel/misc/vector.h" -#include "nel/misc/path.h" -#include "nel/misc/file.h" -#include "nel/misc/log.h" -#include "nel/misc/hierarchical_timer.h" - -#include "nel/sound/driver/sound_driver.h" -#include "nel/sound/driver/buffer.h" -#include "nel/sound/driver/source.h" -#include "nel/sound/driver/listener.h" - -#endif -/* end of file */ diff --git a/code/nel/src/sound/driver/fmod/listener_fmod.cpp b/code/nel/src/sound/driver/fmod/listener_fmod.cpp index 776a23d70..cd25670b0 100644 --- a/code/nel/src/sound/driver/fmod/listener_fmod.cpp +++ b/code/nel/src/sound/driver/fmod/listener_fmod.cpp @@ -131,7 +131,6 @@ void CListenerFMod::setDopplerFactor( float f ) if( !CSoundDriverFMod::getInstance()->fmodOk() ) return; - // clamp as in DSound. clamp(f, 0.f, 10.f); // set @@ -150,7 +149,6 @@ void CListenerFMod::setRolloffFactor( float f ) if(!CSoundDriverFMod::getInstance()->fmodOk()) return; - // clamp as in DSound (FMod requirement) clamp(f, 0.f, 10.f); _RolloffFactor = f; diff --git a/code/nel/src/sound/driver/fmod/listener_fmod.h b/code/nel/src/sound/driver/fmod/listener_fmod.h index 772aab36d..542d2bc7c 100644 --- a/code/nel/src/sound/driver/fmod/listener_fmod.h +++ b/code/nel/src/sound/driver/fmod/listener_fmod.h @@ -105,7 +105,7 @@ public: private: - /// Release all DirectSound resources + /// Release all FMOD resources void release(); // Nel Basis @@ -128,4 +128,3 @@ private: #endif // NL_LISTENER_FMOD_H - diff --git a/code/nel/src/sound/driver/fmod/sound_driver_fmod.cpp b/code/nel/src/sound/driver/fmod/sound_driver_fmod.cpp index d98aa600f..56ea7fdfd 100644 --- a/code/nel/src/sound/driver/fmod/sound_driver_fmod.cpp +++ b/code/nel/src/sound/driver/fmod/sound_driver_fmod.cpp @@ -128,7 +128,7 @@ uint32 NLSOUND_interfaceVersion () CSoundDriverFMod::CSoundDriverFMod(ISoundDriver::IStringMapperProvider *stringMapper) : _StringMapper(stringMapper), _FModOk(false), _MasterGain(1.f), _ForceSoftwareBuffer(false) { - + } // ****************************************************************** @@ -187,7 +187,7 @@ void CSoundDriverFMod::initDevice(const std::string &device, TSoundOptions optio { // list of supported options in this driver // no adpcm, no effects, no buffer streaming - const sint supportedOptions = + const sint supportedOptions = OptionSoftwareBuffer | OptionManualRolloff | OptionLocalBufferCopy; @@ -199,9 +199,6 @@ void CSoundDriverFMod::initDevice(const std::string &device, TSoundOptions optio _Options = (TSoundOptions)(((sint)options & supportedOptions) | forcedOptions); uint initFlags = 0; -#ifdef NL_OS_WINDOWS - initFlags = FSOUND_INIT_DSOUND_DEFERRED; -#endif // Init with 32 channels, and deferred sound if (!FSOUND_Init(22050, 32, initFlags)) @@ -495,7 +492,7 @@ bool getTag (std::string &result, const char *tag, FSOUND_STREAM *stream) return false; } -/** Get music info. Returns false if the song is not found or the function is not implemented. +/** Get music info. Returns false if the song is not found or the function is not implemented. * \param filepath path to file, CPath::lookup done by driver * \param artist returns the song artist (empty if not available) * \param title returns the title (empty if not available) @@ -516,7 +513,7 @@ bool CSoundDriverFMod::getMusicInfo(const std::string &filepath, std::string &ar if (CBigFile::getInstance().getFileInfo(pathName, fileSize, fileOffset)) { // set pathname to bnp - pathName = pathName.substr(0, pathName.find('@')); + pathName = pathName.substr(0, pathName.find('@')); } else { diff --git a/code/nel/src/sound/driver/fmod/sound_driver_fmod.h b/code/nel/src/sound/driver/fmod/sound_driver_fmod.h index db82cde6e..b8d8345f9 100644 --- a/code/nel/src/sound/driver/fmod/sound_driver_fmod.h +++ b/code/nel/src/sound/driver/fmod/sound_driver_fmod.h @@ -35,7 +35,7 @@ namespace NLSOUND { - EAX is not supported (setEnvironnement() / setEAXProperty() no-op) - ADPCM is not supported (decompressed and the format change internaly ) - deffered param on ISource::setPos() etc... does not work. Always deffered. - - No cooperative level change in FMod as in DSOUND (default???) + - No cooperative level change in FMod (default???) */ @@ -49,7 +49,7 @@ public: CSoundDriverFMod(ISoundDriver::IStringMapperProvider *stringMapper); virtual ~CSoundDriverFMod(); - + /// Return a list of available devices for the user. The value at index 0 is empty, and is used for automatic device selection. virtual void getDevices(std::vector &devices); /// Initialize the driver with a user selected device. If device.empty(), the default or most appropriate device is used. @@ -110,7 +110,7 @@ public: /// Create a music channel, destroy with destroyMusicChannel virtual IMusicChannel *createMusicChannel(); - + /** Get music info. Returns false if the song is not found or the function is not implemented. * \param filepath path to file, CPath::lookup done by driver * \param artist returns the song artist (empty if not available) @@ -133,7 +133,7 @@ public: /// Return if a music extension is supported by the driver's music channel. virtual bool isMusicExtensionSupported(const std::string &extension) const; -private: +private: virtual void startBench(); virtual void endBench(); virtual void displayBench(NLMISC::CLog *log); diff --git a/code/nel/src/sound/driver/fmod/source_fmod.cpp b/code/nel/src/sound/driver/fmod/source_fmod.cpp index 1224d647d..e9bf60739 100644 --- a/code/nel/src/sound/driver/fmod/source_fmod.cpp +++ b/code/nel/src/sound/driver/fmod/source_fmod.cpp @@ -466,7 +466,7 @@ void CSourceFMod::updateVolume( const NLMISC::CVector& listener ) //// retransform to linear form //double attGain= pow((double)10.0, double(volumeDB)/2000.0); //clamp(attGain, 0.f, 1.f); - + float rolloff = ISource::computeManualRolloff(_Alpha, sqrdist, _MinDist, _MaxDist); float volume = _Gain * rolloff; @@ -495,7 +495,7 @@ void CSourceFMod::getCone( float& /* innerAngle */, float& /* outerAngle */, flo * alpha.0: the volume will decrease linearly between 0dB and -100 dB * alpha = 1.0: the volume will decrease linearly between 1.0 and 0.0 (linear scale) * alpha = -1.0: the volume will decrease inversely with the distance (1/dist). This - * is the default used by DirectSound/OpenAL + * is the default used by OpenAL * * For any other value of alpha, an interpolation is be done between the two * adjacent curves. For example, if alpha equals 0.5, the volume will be halfway between @@ -548,7 +548,7 @@ void CSourceFMod::updateFModPosIfRelative() /// Enable or disable direct output [true/false], default: true void CSourceFMod::setDirect(bool /* enable */) { - + } /// Return if the direct output is enabled @@ -560,7 +560,7 @@ bool CSourceFMod::getDirect() const /// Set the gain for the direct path void CSourceFMod::setDirectGain(float /* gain */) { - + } /// Get the gain for the direct path @@ -572,7 +572,7 @@ float CSourceFMod::getDirectGain() const /// Enable or disable the filter for the direct channel void CSourceFMod::enableDirectFilter(bool /* enable */) { - + } /// Check if the filter on the direct channel is enabled @@ -584,22 +584,22 @@ bool CSourceFMod::isDirectFilterEnabled() const /// Set the filter parameters for the direct channel void CSourceFMod::setDirectFilter(TFilter /*filterType*/, float /*lowFrequency*/, float /*highFrequency*/, float /*passGain*/) { - + } /// Get the filter parameters for the direct channel void CSourceFMod::getDirectFilter(TFilter &filterType, float &lowFrequency, float &highFrequency, float &passGain) const { filterType = FilterLowPass; - lowFrequency = NLSOUND_DEFAULT_FILTER_PASS_LF; - highFrequency = NLSOUND_DEFAULT_FILTER_PASS_HF; + lowFrequency = NLSOUND_DEFAULT_FILTER_PASS_LF; + highFrequency = NLSOUND_DEFAULT_FILTER_PASS_HF; passGain = NLSOUND_DEFAULT_FILTER_PASS_GAIN; } /// Set the direct filter gain void CSourceFMod::setDirectFilterPassGain(float /*passGain*/) { - + } /// Get the direct filter gain @@ -611,7 +611,7 @@ float CSourceFMod::getDirectFilterPassGain() const /// Set the effect send for this source, NULL to disable. [IEffect], default: NULL void CSourceFMod::setEffect(IReverbEffect * /* reverbEffect */) { - + } /// Get the effect send for this source @@ -623,7 +623,7 @@ IEffect *CSourceFMod::getEffect() const /// Set the gain for the effect path void CSourceFMod::setEffectGain(float /* gain */) { - + } /// Get the gain for the effect path @@ -635,7 +635,7 @@ float CSourceFMod::getEffectGain() const /// Enable or disable the filter for the effect channel void CSourceFMod::enableEffectFilter(bool /* enable */) { - + } /// Check if the filter on the effect channel is enabled @@ -647,22 +647,22 @@ bool CSourceFMod::isEffectFilterEnabled() const /// Set the filter parameters for the effect channel void CSourceFMod::setEffectFilter(TFilter /*filterType*/, float /*lowFrequency*/, float /*highFrequency*/, float /*passGain*/) { - + } /// Get the filter parameters for the effect channel void CSourceFMod::getEffectFilter(TFilter &filterType, float &lowFrequency, float &highFrequency, float &passGain) const { filterType = FilterLowPass; - lowFrequency = NLSOUND_DEFAULT_FILTER_PASS_LF; - highFrequency = NLSOUND_DEFAULT_FILTER_PASS_HF; + lowFrequency = NLSOUND_DEFAULT_FILTER_PASS_LF; + highFrequency = NLSOUND_DEFAULT_FILTER_PASS_HF; passGain = NLSOUND_DEFAULT_FILTER_PASS_GAIN; } /// Set the effect filter gain void CSourceFMod::setEffectFilterPassGain(float /*passGain*/) { - + } /// Get the effect filter gain diff --git a/code/nel/src/sound/driver/fmod/source_fmod.h b/code/nel/src/sound/driver/fmod/source_fmod.h index a8ef4fb57..900f4761a 100644 --- a/code/nel/src/sound/driver/fmod/source_fmod.h +++ b/code/nel/src/sound/driver/fmod/source_fmod.h @@ -25,11 +25,11 @@ namespace NLSOUND { class CBufferFMod; // TODO: Doc comments in FMod driver are wrong. -// Bad copy pastes from DSound & OpenAL drivers. +// Bad copy pastes from OpenAL drivers. // Fix drivername, author and date (2004?)! /** - * DirectSound sound source + * FMOD sound source * * For arguments as 3D vectors, use the NeL vector coordinate system @@ -41,16 +41,16 @@ namespace NLSOUND { class CSourceFMod : public ISource { friend class CSoundDriverFMod; - + public: /// Constructor CSourceFMod( uint sourcename = 0 ); /// Destructor virtual ~CSourceFMod(); - - /// Initialize the DirectSound buffers. Called by the sound driver only. + + /// Initialize the FMOD buffers. Called by the sound driver only. void init(); - + /// \name Initialization //@{ /// Enable or disable streaming mode. Source must be stopped to call this. @@ -68,14 +68,14 @@ public: /// Return the amount of buffers in the queue (playing and waiting). 3 buffers is optimal. virtual uint countStreamingBuffers() const; //@} - + /// \name Playback control //@{ /// Set looping on/off for future playbacks (default: off), not available for streaming virtual void setLooping(bool l); /// Return the looping state virtual bool getLooping() const; - + /** Play the static buffer (or stream in and play). * This method can return false if the sample for this sound is unloaded. */ @@ -93,7 +93,7 @@ public: /// Returns the number of milliseconds the source has been playing virtual uint32 getTime(); //@} - + /// \name Source properties //@{ /** Set the position vector (default: (0,0,0)). @@ -147,7 +147,7 @@ public: * alpha.0: the volume will decrease linearly between 0dB and -100 dB * alpha = 1.0: the volume will decrease linearly between 1.0 and 0.0 (linear scale) * alpha = -1.0: the volume will decrease inversely with the distance (1/dist). This - * is the default used by DirectSound/OpenAL + * is the default used by OpenAL * * For any other value of alpha, an interpolation is be done between the two * adjacent curves. For example, if alpha equals 0.5, the volume will be halfway between @@ -155,7 +155,7 @@ public: */ virtual void setAlpha(double a); //@} - + /// \name Direct output //@{ /// Enable or disable direct output [true/false], default: true @@ -166,7 +166,7 @@ public: virtual void setDirectGain(float gain); /// Get the gain for the direct path virtual float getDirectGain() const; - + /// Enable or disable the filter for the direct channel virtual void enableDirectFilter(bool enable = true); /// Check if the filter on the direct channel is enabled @@ -180,7 +180,7 @@ public: /// Get the direct filter gain virtual float getDirectFilterPassGain() const; //@} - + /// \name Effect output //@{ /// Set the effect send for this source, NULL to disable. [IEffect], default: NULL @@ -191,7 +191,7 @@ public: virtual void setEffectGain(float gain); /// Get the gain for the effect path virtual float getEffectGain() const; - + /// Enable or disable the filter for the effect channel virtual void enableEffectFilter(bool enable = true); /// Check if the filter on the effect channel is enabled @@ -205,29 +205,29 @@ public: /// Get the effect filter gain virtual float getEffectFilterPassGain() const; //@} - + /// Return the OpenAL source name uint sourceName() { return _SourceName; } - + /// Reset the source before reuse void reset(); - + /// Update the source (e.g. continue to stream the data in) bool update(); - + /** Update the source's volume according to its distance and fade out curve. * It takes the current position of the listener as argument. * Called only with OptionManualRolloff */ void updateVolume(const NLMISC::CVector& listener); - + bool needsUpdate(); - + void updateFModPosIfRelative(); - + private: void copySampleTo16BitsTrack(void *dst, void *src, uint nbSample, TSampleFormat sourceFormat); - + enum TSourceState { source_stopped, @@ -235,19 +235,19 @@ private: source_silencing, source_swap_pending }; - - /// Release all DirectSound resources + + /// Release all FMod resources void release(); - + // Source name uint _SourceName; - + TSourceState _State; - + IBuffer *_Sample; IBuffer *_NextSample; sint _FModChannel; - + // States bool _PosRelative; bool _Loop; @@ -258,9 +258,9 @@ private: NLMISC::CVector _Vel; NLMISC::CVector _Front; float _MinDist, _MaxDist; - + void updateFModPos(); - + }; diff --git a/code/nel/src/sound/driver/openal/sound_driver_al.cpp b/code/nel/src/sound/driver/openal/sound_driver_al.cpp index d237f533a..24caa7fe0 100644 --- a/code/nel/src/sound/driver/openal/sound_driver_al.cpp +++ b/code/nel/src/sound/driver/openal/sound_driver_al.cpp @@ -184,8 +184,8 @@ uint32 NLSOUND_interfaceVersion () /* * Constructor */ -CSoundDriverAL::CSoundDriverAL(ISoundDriver::IStringMapperProvider *stringMapper) -: _StringMapper(stringMapper), _AlDevice(NULL), _AlContext(NULL), +CSoundDriverAL::CSoundDriverAL(ISoundDriver::IStringMapperProvider *stringMapper) +: _StringMapper(stringMapper), _AlDevice(NULL), _AlContext(NULL), _NbExpBuffers(0), _NbExpSources(0), _RolloffFactor(1.f) { alExtInit(); @@ -196,9 +196,9 @@ _NbExpBuffers(0), _NbExpSources(0), _RolloffFactor(1.f) */ CSoundDriverAL::~CSoundDriverAL() { - // WARNING: Only internal resources are released here, + // WARNING: Only internal resources are released here, // the created instances must still be released by the user! - + // Remove the allocated (but not exported) source and buffer names- // Release internal resources of all remaining ISource instances if (!_Sources.empty()) @@ -208,7 +208,7 @@ CSoundDriverAL::~CSoundDriverAL() for (; it != end; ++it) (*it)->release(); // CSourceAL will be deleted by user _Sources.clear(); } - if (!_Buffers.empty()) alDeleteBuffers(compactAliveNames(_Buffers, alIsBuffer), &*_Buffers.begin()); + if (!_Buffers.empty()) alDeleteBuffers(compactAliveNames(_Buffers, alIsBuffer), &*_Buffers.begin()); // Release internal resources of all remaining IEffect instances if (!_Effects.empty()) { @@ -229,7 +229,7 @@ void CSoundDriverAL::getDevices(std::vector &devices) devices.push_back(""); // empty if (AlEnumerateAllExt) - { + { const ALchar* deviceNames = alcGetString(NULL, ALC_ALL_DEVICES_SPECIFIER); // const ALchar* defaultDevice = NULL; if(!strlen(deviceNames)) @@ -257,7 +257,7 @@ static const ALchar *getDeviceInternal(const std::string &device) { if (device.empty()) return NULL; if (AlEnumerateAllExt) - { + { const ALchar* deviceNames = alcGetString(NULL, ALC_ALL_DEVICES_SPECIFIER); if(!strlen(deviceNames)) { @@ -286,7 +286,7 @@ void CSoundDriverAL::initDevice(const std::string &device, ISoundDriver::TSoundO { // list of supported options in this driver // no adpcm, no manual rolloff (for now) - const sint supportedOptions = + const sint supportedOptions = OptionEnvironmentEffects | OptionSoftwareBuffer | OptionManualRolloff @@ -298,7 +298,7 @@ void CSoundDriverAL::initDevice(const std::string &device, ISoundDriver::TSoundO // set the options _Options = (TSoundOptions)(((sint)options & supportedOptions) | forcedOptions); - + /* TODO: multichannel */ // OpenAL initialization @@ -309,8 +309,8 @@ void CSoundDriverAL::initDevice(const std::string &device, ISoundDriver::TSoundO if (!_AlDevice) throw ESoundDriver("AL: Failed to open device"); nldebug("AL: ALC_DEVICE_SPECIFIER: '%s'", alcGetString(_AlDevice, ALC_DEVICE_SPECIFIER)); //int attrlist[] = { ALC_FREQUENCY, 48000, - // ALC_MONO_SOURCES, 12, - // ALC_STEREO_SOURCES, 4, + // ALC_MONO_SOURCES, 12, + // ALC_STEREO_SOURCES, 4, // ALC_INVALID }; _AlContext = alcCreateContext(_AlDevice, NULL); // attrlist); if (!_AlContext) { alcCloseDevice(_AlDevice); throw ESoundDriver("AL: Failed to create context"); } @@ -330,20 +330,20 @@ void CSoundDriverAL::initDevice(const std::string &device, ISoundDriver::TSoundO // Load and display extensions alExtInitDevice(_AlDevice); #if EAX_AVAILABLE - nlinfo("AL: EAX: %s, EAX-RAM: %s, ALC_EXT_EFX: %s", - AlExtEax ? "Present" : "Not available", - AlExtXRam ? "Present" : "Not available", + nlinfo("AL: EAX: %s, EAX-RAM: %s, ALC_EXT_EFX: %s", + AlExtEax ? "Present" : "Not available", + AlExtXRam ? "Present" : "Not available", AlExtEfx ? "Present" : "Not available"); #else - nldebug("AL: EAX-RAM: %s, ALC_EXT_EFX: %s", - AlExtXRam ? "Present" : "Not available", + nldebug("AL: EAX-RAM: %s, ALC_EXT_EFX: %s", + AlExtXRam ? "Present" : "Not available", AlExtEfx ? "Present" : "Not available"); #endif alTestError(); nldebug("AL: Max. sources: %u, Max. effects: %u", (uint32)countMaxSources(), (uint32)countMaxEffects()); - if (getOption(OptionEnvironmentEffects)) + if (getOption(OptionEnvironmentEffects)) { if (!AlExtEfx) { @@ -351,13 +351,13 @@ void CSoundDriverAL::initDevice(const std::string &device, ISoundDriver::TSoundO _Options = (TSoundOptions)((uint)_Options & ~OptionEnvironmentEffects); } else if (!countMaxEffects()) - { + { nlwarning("AL: No effects available, environment effects disabled"); _Options = (TSoundOptions)((uint)_Options & ~OptionEnvironmentEffects); } } - // Choose the I3DL2 model (same as DirectSound3D if not manual) + // Choose the I3DL2 model if (getOption(OptionManualRolloff)) alDistanceModel(AL_NONE); else alDistanceModel(AL_INVERSE_DISTANCE_CLAMPED); alTestError(); @@ -456,7 +456,7 @@ IReverbEffect *CSoundDriverAL::createReverbEffect() { IReverbEffect *ieffect = NULL; CEffectAL *effectal = NULL; - + ALuint slot = AL_NONE; alGenAuxiliaryEffectSlots(1, &slot); if (alGetError() != AL_NO_ERROR) @@ -464,7 +464,7 @@ IReverbEffect *CSoundDriverAL::createReverbEffect() nlwarning("AL: alGenAuxiliaryEffectSlots failed"); return NULL; } - + ALuint effect = AL_NONE; alGenEffects(1, &effect); if (alGetError() != AL_NO_ERROR) @@ -491,7 +491,7 @@ IReverbEffect *CSoundDriverAL::createReverbEffect() _Effects.insert(effectal); return ieffect; } -#endif +#endif alEffecti(effect, AL_EFFECT_TYPE, AL_EFFECT_REVERB); if (alGetError() != AL_NO_ERROR) @@ -520,16 +520,16 @@ static uint getMaxNumSourcesInternal() ALuint sources[256]; memset(sources, 0, sizeofarray(sources)); uint sourceCount = 0; - + alGetError(); - + for (; sourceCount < 256; ++sourceCount) { alGenSources(1, &sources[sourceCount]); if (alGetError() != AL_NO_ERROR) break; } - + alDeleteSources(sourceCount, sources); if (alGetError() != AL_NO_ERROR) { diff --git a/code/nel/src/sound/driver/openal/source_al.cpp b/code/nel/src/sound/driver/openal/source_al.cpp index 825d9f1e9..f82168582 100644 --- a/code/nel/src/sound/driver/openal/source_al.cpp +++ b/code/nel/src/sound/driver/openal/source_al.cpp @@ -35,20 +35,20 @@ namespace NLSOUND { CSourceAL::CSourceAL(CSoundDriverAL *soundDriver) : _SoundDriver(NULL), _Buffer(NULL), _Source(AL_NONE), -_DirectFilter(AL_FILTER_NULL), _EffectFilter(AL_FILTER_NULL), -_IsPlaying(false), _IsPaused(false), _StartTime(0), _IsStreaming(false), _RelativeMode(false), -_Pos(0.0f, 0.0f, 0.0f), _Gain(NLSOUND_DEFAULT_GAIN), _Alpha(1.0), -_MinDistance(1.0f), _MaxDistance(sqrt(numeric_limits::max())), -_Effect(NULL), _Direct(true), -_DirectGain(NLSOUND_DEFAULT_DIRECT_GAIN), _EffectGain(NLSOUND_DEFAULT_EFFECT_GAIN), -_DirectFilterType(ISource::FilterLowPass), _EffectFilterType(ISource::FilterLowPass), -_DirectFilterEnabled(false), _EffectFilterEnabled(false), +_DirectFilter(AL_FILTER_NULL), _EffectFilter(AL_FILTER_NULL), +_IsPlaying(false), _IsPaused(false), _StartTime(0), _IsStreaming(false), _RelativeMode(false), +_Pos(0.0f, 0.0f, 0.0f), _Gain(NLSOUND_DEFAULT_GAIN), _Alpha(1.0), +_MinDistance(1.0f), _MaxDistance(sqrt(numeric_limits::max())), +_Effect(NULL), _Direct(true), +_DirectGain(NLSOUND_DEFAULT_DIRECT_GAIN), _EffectGain(NLSOUND_DEFAULT_EFFECT_GAIN), +_DirectFilterType(ISource::FilterLowPass), _EffectFilterType(ISource::FilterLowPass), +_DirectFilterEnabled(false), _EffectFilterEnabled(false), _DirectFilterPassGain(NLSOUND_DEFAULT_FILTER_PASS_GAIN), _EffectFilterPassGain(NLSOUND_DEFAULT_FILTER_PASS_GAIN) { // create the al source alGenSources(1, &_Source); alTestError(); - + // configure rolloff if (soundDriver->getOption(ISoundDriver::OptionManualRolloff)) { @@ -60,7 +60,7 @@ _DirectFilterPassGain(NLSOUND_DEFAULT_FILTER_PASS_GAIN), _EffectFilterPassGain(N alSourcef(_Source, AL_ROLLOFF_FACTOR, soundDriver->getRolloffFactor()); alTestError(); } - + // create filters if (soundDriver->getOption(ISoundDriver::OptionEnvironmentEffects)) { @@ -75,7 +75,7 @@ _DirectFilterPassGain(NLSOUND_DEFAULT_FILTER_PASS_GAIN), _EffectFilterPassGain(N alFilterf(_EffectFilter, AL_LOWPASS_GAINHF, NLSOUND_DEFAULT_FILTER_PASS_GAIN); alTestError(); } - + // if everything went well, the source will be added in the sounddriver _SoundDriver = soundDriver; } @@ -166,17 +166,17 @@ void CSourceAL::submitStreamingBuffer(IBuffer *buffer) CBufferAL *bufferAL = static_cast(buffer); ALuint bufferName = bufferAL->bufferName(); nlassert(bufferName); - + if (!bufferAL->isBufferLoaded()) { nlwarning("AL: MUSICBUG: Streaming buffer was not loaded, skipping buffer. This should not happen."); return; } - + alSourceQueueBuffers(_Source, 1, &bufferName); alTestError(); _QueuedBuffers.push(bufferAL); - + // Resume playback if the internal OpenAL source stopped due to buffer underrun. ALint srcstate; alGetSourcei(_Source, AL_SOURCE_STATE, &srcstate); @@ -584,7 +584,7 @@ void CSourceAL::getCone( float& innerAngle, float& outerAngle, float& outerGain * alpha.0: the volume will decrease linearly between 0dB and -100 dB * alpha = 1.0: the volume will decrease linearly between 1.0 and 0.0 (linear scale) * alpha = -1.0: the volume will decrease inversely with the distance (1/dist). This - * is the default used by DirectSound/OpenAL + * is the default used by OpenAL * * For any other value of alpha, an interpolation is be done between the two * adjacent curves. For example, if alpha equals 0.5, the volume will be halfway between diff --git a/code/nel/src/sound/driver/openal/source_al.h b/code/nel/src/sound/driver/openal/source_al.h index 22cb3d67d..a0ad49158 100644 --- a/code/nel/src/sound/driver/openal/source_al.h +++ b/code/nel/src/sound/driver/openal/source_al.h @@ -50,11 +50,11 @@ private: /// Assigned buffer object CBufferAL *_Buffer; std::queue _QueuedBuffers; - + /// AL Handles ALuint _Source; ALuint _DirectFilter, _EffectFilter; - + /// Playing status bool _IsPlaying; bool _IsPaused; @@ -70,7 +70,7 @@ private: float _MinDistance; /// Maximum distance of sound. float _MaxDistance; - + /// Send paths CEffectAL *_Effect; bool _Direct; @@ -80,8 +80,8 @@ private: TFilter _DirectFilterType, _EffectFilterType; bool _DirectFilterEnabled, _EffectFilterEnabled; float _DirectFilterPassGain, _EffectFilterPassGain; - -public: + +public: /// Constructor CSourceAL(CSoundDriverAL *soundDriver); /// Destructor @@ -89,10 +89,10 @@ public: /// Release called by the driver to release internal AL handles. void release(); - + /// Return the OpenAL source name inline ALuint getSource() const { return _Source; } - + /// (Internal) Set the effect send for this source, NULL to disable. void setEffect(CEffectAL *effect); /// (Internal) Setup the direct send filter. @@ -101,7 +101,7 @@ public: void setupEffectFilter(); /// (Internal) Update the manual rolloff, only called when using manual rolloff. void updateManualRolloff(); - + /// \name Initialization //@{ /// Enable or disable streaming mode. Source must be stopped to call this. @@ -119,14 +119,14 @@ public: /// Return the amount of buffers in the queue (playing and waiting). 3 buffers is optimal. virtual uint countStreamingBuffers() const; //@} - + /// \name Playback control //@{ /// Set looping on/off for future playbacks (default: off), not available for streaming virtual void setLooping(bool l); /// Return the looping state virtual bool getLooping() const; - + /** Play the static buffer (or stream in and play). * This method can return false if the sample for this sound is unloaded. */ @@ -144,7 +144,7 @@ public: /// Returns the number of milliseconds the source has been playing virtual uint32 getTime(); //@} - + /// \name Source properties //@{ /** Set the position vector (default: (0,0,0)). @@ -198,7 +198,7 @@ public: * alpha.0: the volume will decrease linearly between 0dB and -100 dB * alpha = 1.0: the volume will decrease linearly between 1.0 and 0.0 (linear scale) * alpha = -1.0: the volume will decrease inversely with the distance (1/dist). This - * is the default used by DirectSound/OpenAL + * is the default used by OpenAL * * For any other value of alpha, an interpolation is be done between the two * adjacent curves. For example, if alpha equals 0.5, the volume will be halfway between @@ -206,7 +206,7 @@ public: */ virtual void setAlpha(double a); //@} - + /// \name Direct output //@{ /// Enable or disable direct output [true/false], default: true @@ -217,7 +217,7 @@ public: virtual void setDirectGain(float gain); /// Get the gain for the direct path virtual float getDirectGain() const; - + /// Enable or disable the filter for the direct channel virtual void enableDirectFilter(bool enable = true); /// Check if the filter on the direct channel is enabled @@ -231,7 +231,7 @@ public: /// Get the direct filter gain virtual float getDirectFilterPassGain() const; //@} - + /// \name Effect output //@{ /// Set the effect send for this source, NULL to disable. [IEffect], default: NULL @@ -242,7 +242,7 @@ public: virtual void setEffectGain(float gain); /// Get the gain for the effect path virtual float getEffectGain() const; - + /// Enable or disable the filter for the effect channel virtual void enableEffectFilter(bool enable = true); /// Check if the filter on the effect channel is enabled @@ -256,7 +256,7 @@ public: /// Get the effect filter gain virtual float getEffectFilterPassGain() const; //@} - + }; } // NLSOUND diff --git a/code/nel/src/sound/driver/sound_driver.cpp b/code/nel/src/sound/driver/sound_driver.cpp index 4c83d5a0d..e6da7f267 100644 --- a/code/nel/src/sound/driver/sound_driver.cpp +++ b/code/nel/src/sound/driver/sound_driver.cpp @@ -24,8 +24,6 @@ // Driver availability for NL_STATIC compilation. # undef NL_FMOD_AVAILABLE # undef NL_OPENAL_AVAILABLE -# undef NL_DSOUND_AVAILABLE -# undef NL_XAUDIO2_AVAILABLE # if defined( NL_OS_WINDOWS ) # define NL_FMOD_AVAILABLE # else @@ -69,12 +67,6 @@ const uint32 ISoundDriver::InterfaceVersion = 0x16; // Kaetemi #ifdef NL_OPENAL_AVAILABLE NLSOUND_DECLARE_DRIVER(OpenAl) #endif -#ifdef NL_DSOUND_AVAILABLE - NLSOUND_DECLARE_DRIVER(DSound) -#endif -#ifdef NL_XAUDIO2_AVAILABLE - NLSOUND_DECLARE_DRIVER(XAudio2) -#endif #else @@ -94,8 +86,6 @@ const char *ISoundDriver::getDriverName(TDriver driverType) case DriverAuto: return "AUTO"; case DriverFMod: return "FMod"; case DriverOpenAl: return "OpenAL"; - case DriverDSound: return "DSound"; - case DriverXAudio2: return "XAudio2"; default: return "UNKNOWN"; } } @@ -106,9 +96,9 @@ const char *ISoundDriver::getDriverName(TDriver driverType) ISoundDriver *ISoundDriver::createDriver(IStringMapperProvider *stringMapper, TDriver driverType) { #ifdef NL_STATIC - + nlinfo("Creating statically linked sound driver %s", getDriverName(driverType)); - + ISoundDriver *result = NULL; switch (driverType) { @@ -119,28 +109,18 @@ ISoundDriver *ISoundDriver::createDriver(IStringMapperProvider *stringMapper, TD # ifdef NL_OPENAL_AVAILABLE case DriverOpenAl: result = createISoundDriverInstanceOpenAl(stringMapper); break; # endif -# ifdef NL_DSOUND_AVAILABLE - case DriverDSound: result = createISoundDriverInstanceDSound(stringMapper); break; -# endif -# ifdef NL_XAUDIO2_AVAILABLE - case DriverXAudio2: result = createISoundDriverInstanceXAudio2(stringMapper); break; -# endif - // auto driver = first available in this order: FMod, OpenAl, XAudio2, DSound + // auto driver = first available in this order: FMod, OpenAl # if defined(NL_FMOD_AVAILABLE) case DriverAuto: result = createISoundDriverInstanceFMod(stringMapper); break; # elif defined(NL_OPENAL_AVAILABLE) case DriverAuto: result = createISoundDriverInstanceOpenAl(stringMapper); break; -# elif defined(NL_XAUDIO2_AVAILABLE) - case DriverAuto: result = createISoundDriverInstanceXAudio2(stringMapper); break; -# elif defined(NL_DSOUND_AVAILABLE) - case DriverAuto: result = createISoundDriverInstanceDSound(stringMapper); break; # endif // unavailable driver = FAIL default: throw ESoundDriverNotFound(getDriverName(driverType)); } - if (!result) throw ESoundDriverCantCreateDriver(getDriverName(driverType)); + if (!result) throw ESoundDriverCantCreateDriver(getDriverName(driverType)); return result; - + #else ISDRV_CREATE_PROC createSoundDriver = NULL; @@ -172,34 +152,10 @@ ISoundDriver *ISoundDriver::createDriver(IStringMapperProvider *stringMapper, TD dllName = "nel_drv_openal"; #else # error "Driver name not define for this platform" -#endif - break; - case DriverDSound: -#if defined (NL_COMP_MINGW) - dllName = "libnel_drv_dsound_win"; -#elif defined (NL_OS_WINDOWS) - dllName = "nel_drv_dsound_win"; -#elif defined (NL_OS_UNIX) - nlerror("DriverDSound doesn't exist on Unix because it requires DirectX"); -#else -# error "Driver name not define for this platform" -#endif - break; - case DriverXAudio2: -#if defined (NL_COMP_MINGW) - dllName = "libnel_drv_xaudio2_win"; -#elif defined (NL_OS_WINDOWS) - dllName = "nel_drv_xaudio2_win"; -#elif defined (NL_OS_UNIX) - nlerror("DriverXAudio2 doesn't exist on Unix because it requires DirectX"); -#else -# error "Driver name not define for this platform" #endif break; default: -#if defined (NL_COMP_MINGW) - dllName = "libnel_drv_xaudio2_win"; -#elif defined (NL_OS_WINDOWS) +#if defined (NL_OS_WINDOWS) dllName = "nel_drv_fmod_win"; #elif defined (NL_OS_UNIX) dllName = "nel_drv_openal"; diff --git a/code/nel/src/sound/driver/xaudio2/CMakeLists.txt b/code/nel/src/sound/driver/xaudio2/CMakeLists.txt deleted file mode 100644 index 62bbdcb55..000000000 --- a/code/nel/src/sound/driver/xaudio2/CMakeLists.txt +++ /dev/null @@ -1,48 +0,0 @@ -FILE(GLOB SRC *.cpp *.h *.def *.rc) - -SOURCE_GROUP(sfx FILES - buffer_xaudio2.cpp - buffer_xaudio2.h - listener_xaudio2.cpp - listener_xaudio2.h - source_xaudio2.cpp - source_xaudio2.h) - -SOURCE_GROUP(sfx\\utility FILES - adpcm_xaudio2.cpp - adpcm_xaudio2.h) - -SOURCE_GROUP(music_remove FILES - music_channel_xaudio2.cpp - music_channel_xaudio2.h) - -SOURCE_GROUP(music_remove\\utility FILES - music_buffer.cpp - music_buffer.h - music_buffer_vorbis.cpp - music_buffer_vorbis.h) - -SOURCE_GROUP(efx FILES - effect_xaudio2.cpp - effect_xaudio2.h) - -NL_TARGET_DRIVER(nel_drv_xaudio2_win ${SRC}) - -INCLUDE_DIRECTORIES(BEFORE ${DXSDK_INCLUDE_DIR}) - -TARGET_LINK_LIBRARIES(nel_drv_xaudio2_win nelmisc nelsnd_lowlevel ${DXSDK_XAUDIO_LIBRARY}) - -NL_DEFAULT_PROPS(nel_drv_xaudio2_win "NeL, Driver, Sound: XAudio2") -NL_ADD_RUNTIME_FLAGS(nel_drv_xaudio2_win) -NL_ADD_LIB_SUFFIX(nel_drv_xaudio2_win) - -IF(WITH_PCH) - ADD_NATIVE_PRECOMPILED_HEADER(nel_drv_xaudio2_win ${CMAKE_CURRENT_SOURCE_DIR}/stdxaudio2.h ${CMAKE_CURRENT_SOURCE_DIR}/stdxaudio2.cpp) -ENDIF() - -IF((WITH_INSTALL_LIBRARIES AND WITH_STATIC_DRIVERS) OR NOT WITH_STATIC_DRIVERS) - INSTALL(TARGETS nel_drv_xaudio2_win RUNTIME DESTINATION ${NL_DRIVER_PREFIX} LIBRARY DESTINATION ${NL_DRIVER_PREFIX} ARCHIVE DESTINATION ${NL_LIB_PREFIX} COMPONENT driverssound) - IF(WITH_MAXPLUGIN) - INSTALL(TARGETS nel_drv_xaudio2_win RUNTIME DESTINATION maxplugin COMPONENT driverssound) - ENDIF() -ENDIF() diff --git a/code/nel/src/sound/driver/xaudio2/adpcm_xaudio2.cpp b/code/nel/src/sound/driver/xaudio2/adpcm_xaudio2.cpp deleted file mode 100644 index e70fec076..000000000 --- a/code/nel/src/sound/driver/xaudio2/adpcm_xaudio2.cpp +++ /dev/null @@ -1,200 +0,0 @@ -// NeL - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as -// published by the Free Software Foundation, either version 3 of the -// License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -#include "stdxaudio2.h" - -// Project includes -#include "buffer_xaudio2.h" -#include "adpcm_xaudio2.h" - -#ifdef DEBUG_NEW -#define new DEBUG_NEW -#endif - -using namespace std; -// using namespace NLMISC; - -namespace NLSOUND { - -CAdpcmXAudio2::CAdpcmXAudio2(bool loop) -: _SourceVoice(NULL), _SourceData(NULL), _SourceSize(0), _SampleRate(0), -_Loop(loop), _BufferNext(0), _SampleNb(0), _AdpcmSize(0), -_AdpcmIndex(0), _LastBufferContext(0) -{ - _State.PreviousSample = 0; - _State.StepIndex = 0; - for (uint i = 0; i < _BufferNb; ++i) - _ValidBufferContext[i] = 0; -} - -CAdpcmXAudio2::~CAdpcmXAudio2() -{ - -} - -/// Submit the next ADPCM buffer, only 1 buffer can be submitted at a time! -void CAdpcmXAudio2::submitSourceBuffer(CBufferXAudio2 *buffer) -{ - _Mutex.enter(); - if (_SourceData) nlerror(NLSOUND_XAUDIO2_PREFIX "Only 1 ADPCM buffer can be submitted at a time! Call flushSourceBuffers first in CSourceXAudio2 stop()."); - _SourceSize = buffer->getSize(); - if (_SourceSize == 0) - { - nlwarning(NLSOUND_XAUDIO2_PREFIX "Empty ADPCM buffer!"); - } - else - { - _AdpcmSize = buffer->getFrequency() / 40; - _SampleNb = _AdpcmSize * 2; - nlassert(_SampleNb < _BufferMax); - _SourceData = buffer->getData(); - // nldebug("submit called!!!"); - processBuffers(); - } - _Mutex.leave(); -} - -/// Reset the decoder, clear the queued buffer -void CAdpcmXAudio2::flushSourceBuffers() -{ - _Mutex.enter(); - _SourceData = NULL; - for (uint i = 0; i < _BufferNb; ++i) - _ValidBufferContext[i] = 0; - //_SourceSize = 0; - _State.PreviousSample = 0; - _State.StepIndex = 0; - _AdpcmIndex = 0; - //_PcmSize = 0; - //_AdpcmSize = 0; - _Mutex.leave(); -} - -void CAdpcmXAudio2::processBuffers() -{ - if (_SourceData) - { - XAUDIO2_VOICE_STATE voice_state; - _SourceVoice->GetState(&voice_state); - while (voice_state.BuffersQueued < _BufferNb) - { - // ADPCM = 4bit, PCM = 16bit // 1 adpcm byte = 2 samples - - uint maxinbytes = _SourceSize - _AdpcmIndex; - uint inbytes = min(maxinbytes, _AdpcmSize); - - // nldebug("queue: %u", (uint32)voice_state.BuffersQueued); - // nldebug("yeah, i'm decoding adpcm! %s, the size is %u and I'm at index %u, run %u, do %u bytes, source data %s!!!", _Loop ? "it's LOOPING" : "it's NOT looping", (uint32)_SourceSize, (uint32)_AdpcmIndex, (uint32)0, (uint32)inbytes, _SourceData ? "EXISTS" : "does NOT exist"); - - if (inbytes > 0) - { - IBuffer::decodeADPCM(_SourceData + _AdpcmIndex, _Buffer[_BufferNext], inbytes * 2, _State); - - XAUDIO2_BUFFER xbuffer; - xbuffer.AudioBytes = inbytes * 4; - xbuffer.Flags = 0; - xbuffer.LoopBegin = 0; - xbuffer.LoopCount = 0; - xbuffer.LoopLength = 0; - xbuffer.pAudioData = (BYTE *)_Buffer[_BufferNext]; - xbuffer.pContext = (void *)(++_LastBufferContext); - xbuffer.PlayBegin = 0; - xbuffer.PlayLength = 0; - _SourceVoice->SubmitSourceBuffer(&xbuffer); - // nlwarning("submit %u", (uint32)xbuffer.pContext); - - _AdpcmIndex += inbytes; - _BufferNext = (_BufferNext + 1) % _BufferNb; - ++voice_state.BuffersQueued; - } - - if (inbytes != _AdpcmSize) // end of buffer - { - _State.PreviousSample = 0; - _State.StepIndex = 0; - _AdpcmIndex = 0; - if (!_Loop) - { - _SourceData = NULL; - return; - } - } - - nlassert(_SourceData); - } - } -} - -void CAdpcmXAudio2::OnVoiceProcessingPassStart(UINT32 /* BytesRequired */) -{ - -} - -void CAdpcmXAudio2::OnVoiceProcessingPassEnd() -{ - -} - -void CAdpcmXAudio2::OnStreamEnd() -{ - -} - -void CAdpcmXAudio2::OnBufferStart(void *pBufferContext) -{ - // set a flag that this buffer has started - // nlwarning("start %u", (uint32)pBufferContext); - for (uint i = 0; i < _BufferNb; ++i) if (!_ValidBufferContext[i]) - { - _ValidBufferContext[i] = pBufferContext; - return; - } - // nlwarning("No valid buffer context available for: %u", (uint32)pBufferContext); -} - -void CAdpcmXAudio2::OnBufferEnd(void *pBufferContext) -{ - // verify if this buffer has started - // nlwarning("end %u", (uint32)pBufferContext); - for (uint i = 0; i < _BufferNb; ++i) if (_ValidBufferContext[i] == pBufferContext) - { - _ValidBufferContext[i] = 0; - goto ProcessBuffers; - } - // nlwarning("Not a valid buffer context: %u", (uint32)pBufferContext); - return; -ProcessBuffers: - // The "correct" way would be to decode the buffer on a seperate thread, - // but since ADPCM decoding should be really fast, there is no problem - // with doing it here directly. - _Mutex.enter(); - processBuffers(); - _Mutex.leave(); -} - -void CAdpcmXAudio2::OnLoopEnd(void * /* pBufferContext */) -{ - -} - -void CAdpcmXAudio2::OnVoiceError(void * /* pBufferContext */, HRESULT /* Error */) -{ - -} - -} /* namespace NLSOUND */ - -/* end of file */ diff --git a/code/nel/src/sound/driver/xaudio2/adpcm_xaudio2.h b/code/nel/src/sound/driver/xaudio2/adpcm_xaudio2.h deleted file mode 100644 index 3b46d1b9a..000000000 --- a/code/nel/src/sound/driver/xaudio2/adpcm_xaudio2.h +++ /dev/null @@ -1,115 +0,0 @@ -// NeL - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as -// published by the Free Software Foundation, either version 3 of the -// License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -#ifndef NLSOUND_ADPCM_XAUDIO2_H -#define NLSOUND_ADPCM_XAUDIO2_H - -#include "nel/sound/driver/buffer.h" - -namespace NLSOUND { - class CBufferXAudio2; - -/** - * \brief CAdpcmXAudio2 - * \date 2008-09-07 03:53GMT - * \author Jan Boon (Kaetemi) - * CAdpcmXAudio2 is a utility class for realtime streaming and decoding of Intel ADPCM data to an XAudio2 source voice. - */ -class CAdpcmXAudio2 : public IXAudio2VoiceCallback -{ -protected: - // stuff - /// Source voice to which the data is sent. - IXAudio2SourceVoice *_SourceVoice; - /// ADPCM data. - const uint8 *_SourceData; - /// ADPCM data size. - uint32 _SourceSize; - /// Sample data rate. - uint _SampleRate; - /// Size in uint8 50ms ADPCM. (50ms 4bit ADPCM in uint8 = _SampleRate / 40) - uint _AdpcmSize; - /// Samples for 50ms. Also size in uint16 for 100ms PCM. (50ms 16bit PCM in uint16 = _SampleRate / 20) - uint _SampleNb; - /// Current position in ADPCM buffer in uint8. - uint _AdpcmIndex; - - // other stuff - IBuffer::TADPCMState _State; - /// Looping or not. - bool _Loop; - /// Number of buffers. - static const uint _BufferNb = 3; - /// Data in buffer (in uint16). - static const uint _BufferMax = 2400; - /// Three buffers of up to 50ms of 48kHz 16bit PCM data each. - sint16 _Buffer[_BufferNb][_BufferMax]; - /// Buffer that will be written to next. - uint _BufferNext; - /// Mutex for cross-thread access from XAudio2 callbacks. - NLMISC::CMutex _Mutex; - /// Unique id for buffer. - uintptr_t _LastBufferContext; - /// Current buffer. - void *_ValidBufferContext[_BufferNb]; -public: - CAdpcmXAudio2(bool loop); - virtual ~CAdpcmXAudio2(); - - /// Create the source voice, it must have this class as callback stuff. - inline void setSourceVoice(IXAudio2SourceVoice *sourceVoice) { _SourceVoice = sourceVoice; } - - /// Set looping state. - inline void setLooping(bool l) { _Loop = l; } - /// Submit the next ADPCM buffer, only 1 buffer can be submitted at a time! Plays as soon as submitted (if sourcevoice is playing). - void submitSourceBuffer(CBufferXAudio2 *buffer); - /// Reset the decoder, clear the queued buffer - void flushSourceBuffers(); - /// Returns NULL if the buffer has ended playing, never NULL for loops! - inline const uint8 *getSourceData() const { return _SourceData; } - -private: - /// (Internal) Process and submit the ADPCM data. - void processBuffers(); - - // XAudio2 Callbacks - // Called just before this voice's processing pass begins. - STDMETHOD_(void, OnVoiceProcessingPassStart) (THIS_ UINT32 BytesRequired); - // Called just after this voice's processing pass ends. - STDMETHOD_(void, OnVoiceProcessingPassEnd) (THIS); - // Called when this voice has just finished playing a buffer stream - // (as marked with the XAUDIO2_END_OF_STREAM flag on the last buffer). - STDMETHOD_(void, OnStreamEnd) (THIS); - // Called when this voice is about to start processing a new buffer. - STDMETHOD_(void, OnBufferStart) (THIS_ void* pBufferContext); - // Called when this voice has just finished processing a buffer. - // The buffer can now be reused or destroyed. - STDMETHOD_(void, OnBufferEnd) (THIS_ void* pBufferContext); - // Called when this voice has just reached the end position of a loop. - STDMETHOD_(void, OnLoopEnd) (THIS_ void* pBufferContext); - // Called in the event of a critical error during voice processing, - // such as a failing XAPO or an error from the hardware XMA decoder. - // The voice may have to be destroyed and re-created to recover from - // the error. The callback arguments report which buffer was being - // processed when the error occurred, and its HRESULT code. - STDMETHOD_(void, OnVoiceError) (THIS_ void* pBufferContext, HRESULT Error); -}; /* class CAdpcmXAudio2 */ - -} /* namespace NLSOUND */ - -#endif /* #ifndef NLSOUND_ADPCM_XAUDIO2_H */ - -/* end of file */ diff --git a/code/nel/src/sound/driver/xaudio2/buffer_xaudio2.cpp b/code/nel/src/sound/driver/xaudio2/buffer_xaudio2.cpp deleted file mode 100644 index acdb95ab4..000000000 --- a/code/nel/src/sound/driver/xaudio2/buffer_xaudio2.cpp +++ /dev/null @@ -1,200 +0,0 @@ -// NeL - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as -// published by the Free Software Foundation, either version 3 of the -// License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -#include "stdxaudio2.h" - -// Project includes -#include "buffer_xaudio2.h" -#include "sound_driver_xaudio2.h" - -#ifdef DEBUG_NEW -#define new DEBUG_NEW -#endif - -using namespace std; -using namespace NLMISC; - -namespace NLSOUND { - -CBufferXAudio2::CBufferXAudio2(CSoundDriverXAudio2 *soundDriver) -: _SoundDriver(soundDriver), _DataAligned(NULL), _DataPtr(NULL), -_Size(0), _Name(NULL), _Format((IBuffer::TBufferFormat)~0), -_Channels(0), _BitsPerSample(0), _Frequency(0), _Capacity(0) -{ - -} - -CBufferXAudio2::~CBufferXAudio2() -{ - release(); -} - -void CBufferXAudio2::release() -{ - if (_SoundDriver) - { - // Remove the buffer from the driver. - _SoundDriver->removeBuffer(this); - // Update stats. - _SoundDriver->performanceUnregisterBuffer(_Format, _Size); - _SoundDriver = NULL; - } - // Release possible _Data - if (_DataPtr) - { - delete[] _DataPtr; - _DataAligned = NULL; - _DataPtr = NULL; - } -} - -/// Get a writable pointer to the buffer of specified size. Returns NULL in case of failure. It is only guaranteed that the original data is still available when using StorageSoftware and the specified size is not larger than the available data. Call setStorageMode() and setFormat() first. -uint8 *CBufferXAudio2::lock(uint capacity) -{ - if (_DataPtr) - { - _SoundDriver->performanceUnregisterBuffer(_Format, _Size); - if (capacity > _Capacity) - { - delete[] _DataPtr; - _DataAligned = NULL; - _DataPtr = NULL; - } - } - - if (!_DataPtr) - { - _DataPtr = new uint8[capacity + 15]; - _DataAligned = (uint8 *)((size_t)_DataPtr + ((16 - ((size_t)_DataPtr % 16)) % 16)); - _Capacity = capacity; - if (_Size > capacity) - _Size = capacity; - } - _SoundDriver->performanceRegisterBuffer(_Format, _Size); - - return _DataAligned; -} - -/// Notify that you are done writing to this buffer, so it can be copied over to hardware if needed. Returns true if ok. -bool CBufferXAudio2::unlock(uint size) -{ - _SoundDriver->performanceUnregisterBuffer(_Format, _Size); - if (size > _Capacity) - { - _Size = _Capacity; - _SoundDriver->performanceRegisterBuffer(_Format, _Size); - return false; - } - else - { - _Size = size; - _SoundDriver->performanceRegisterBuffer(_Format, _Size); - return true; - } -} - -/// Copy the data with specified size into the buffer. A readable local copy is only guaranteed when OptionLocalBufferCopy is set. Returns true if ok. -bool CBufferXAudio2::fill(const uint8 *src, uint size) -{ - uint8 *dest = lock(size); - if (dest == NULL) return false; - CFastMem::memcpy(dest, src, size); - return unlock(size); -} - -/** Preset the name of the buffer. Used for async loading to give a name - * before the buffer is effectivly loaded. - * If the name after loading of the buffer doesn't match the preset name, - * the load will assert. - */ -void CBufferXAudio2::setName(NLMISC::TStringId bufferName) -{ - _Name = bufferName; -} - -void CBufferXAudio2::setFormat(TBufferFormat format, uint8 channels, uint8 bitsPerSample, uint32 frequency) -{ - _Format = format; - _Channels = channels; - _Frequency = frequency; - _BitsPerSample = bitsPerSample; -} - -/// Return the sample format information. -void CBufferXAudio2::getFormat(TBufferFormat &format, uint8 &channels, uint8 &bitsPerSample, uint32 &frequency) const -{ - format = _Format; - channels = _Channels; - bitsPerSample = _BitsPerSample; - frequency = _Frequency; -} - -/// Return the size of the buffer, in bytes -uint CBufferXAudio2::getSize() const -{ - return _Size; -} - -/// Return the duration (in ms) of the sample in the buffer -float CBufferXAudio2::getDuration() const -{ - switch (_Format) - { - case FormatDviAdpcm: - nlassert(_Channels == 1 && _BitsPerSample == 16); - return 1000.0f * ((float)_Size * 2.0f) / (float)_Frequency; - break; - case FormatPcm: - return 1000.0f * getDurationFromPCMSize(_Size, _Channels, _BitsPerSample, _Frequency); - break; - } - return 0.0f; -} - -/// Return true if the buffer is stereo, false if mono -bool CBufferXAudio2::isStereo() const -{ - return _Channels > 1; -} - -/// Return the name of this buffer -NLMISC::TStringId CBufferXAudio2::getName() const -{ - return _Name; -} - -/// Return true if the buffer is loaded. Used for async load/unload. -bool CBufferXAudio2::isBufferLoaded() const -{ - return _DataPtr != NULL; -} - -/// Set the storage mode of this buffer, call before filling this buffer. Storage mode is always software if OptionSoftwareBuffer is enabled. Default is auto. -void CBufferXAudio2::setStorageMode(IBuffer::TStorageMode /* storageMode */) -{ - // software buffering, no hardware storage mode available -} - -/// Get the storage mode of this buffer. -IBuffer::TStorageMode CBufferXAudio2::getStorageMode() -{ - // always uses software buffers - return IBuffer::StorageSoftware; -} - -} /* namespace NLSOUND */ - -/* end of file */ diff --git a/code/nel/src/sound/driver/xaudio2/buffer_xaudio2.h b/code/nel/src/sound/driver/xaudio2/buffer_xaudio2.h deleted file mode 100644 index 0094494ed..000000000 --- a/code/nel/src/sound/driver/xaudio2/buffer_xaudio2.h +++ /dev/null @@ -1,118 +0,0 @@ -// NeL - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as -// published by the Free Software Foundation, either version 3 of the -// License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -#ifndef NLSOUND_BUFFER_XAUDIO2_H -#define NLSOUND_BUFFER_XAUDIO2_H - -#include "nel/sound/driver/buffer.h" - -namespace NLSOUND { - class CSoundDriverXAudio2; - -/** - * \brief CBufferXAudio2 - * \date 2008-08-20 17:21GMT - * \author Jan Boon (Kaetemi) - * CBufferXAudio2 is an implementation of the IBuffer interface to run on XAudio2. - */ -class CBufferXAudio2 : public IBuffer -{ -protected: - // outside pointers - /// The sound driver that owns this buffer, used for stats. (artificial limit) - CSoundDriverXAudio2 *_SoundDriver; - - // pointers - /// The sample data in this buffer. Aligned 16 byte. - uint8 *_DataAligned; - /// The actual pointer used for deletion. - uint8 *_DataPtr; - // instances - // XAudio2 buffer structure, could have one pre-configured - // here for optimization (looping state unknown). - // XAUDIO2_BUFFER _Buffer; - - /// The capacity of the buffer - uint _Capacity; - /// The size of the data in the buffer - uint _Size; - /// The name of the buffer - NLMISC::TStringId _Name; - /// The sample format - TBufferFormat _Format; - /// The number of channels - uint8 _Channels; - /// Bits per sample - uint8 _BitsPerSample; - /// The sample frequency - uint _Frequency; -public: - CBufferXAudio2(CSoundDriverXAudio2 *soundDriver); - virtual ~CBufferXAudio2(); - void release(); - - /// Returns a pointer to the PCM or ADPCM bytes. - inline const uint8 *getData() { return _DataAligned; } - /// Returns the sample format. - inline TBufferFormat getFormat() { return _Format; } - /// Returns the number of channels - inline uint8 getChannels() { return _Channels; } - /// Returns the bits per sample - inline uint8 getBitsPerSample() { return _BitsPerSample; } - /// Returns the sample rate. - inline uint getFrequency() { return _Frequency; } - - /** Preset the name of the buffer. Used for async loading to give a name - * before the buffer is effectivly loaded. - * If the name after loading of the buffer doesn't match the preset name, - * the load will assert. - */ - virtual void setName(NLMISC::TStringId bufferName); - /// Return the name of this buffer - virtual NLMISC::TStringId getName() const; - - /// Set the sample format. (channels = 1, 2, ...; bitsPerSample = 8, 16; frequency = samples per second, 44100, ...) - virtual void setFormat(TBufferFormat format, uint8 channels, uint8 bitsPerSample, uint32 frequency); - /// Return the sample format information. - virtual void getFormat(TBufferFormat &format, uint8 &channels, uint8 &bitsPerSample, uint32 &frequency) const; - /// Set the storage mode of this buffer, call before filling this buffer. Storage mode is always software if OptionSoftwareBuffer is enabled. Default is auto. - virtual void setStorageMode(TStorageMode storageMode = IBuffer::StorageAuto); - /// Get the storage mode of this buffer. - virtual TStorageMode getStorageMode(); - - /// Get a writable pointer to the buffer of specified size. Use capacity to specify the required bytes. Returns NULL in case of failure. It is only guaranteed that the original data is still available when using StorageSoftware and the specified size is not larger than the size specified in the last lock. Call setStorageMode() and setFormat() first. - virtual uint8 *lock(uint capacity); - /// Notify that you are done writing to this buffer, so it can be copied over to hardware if needed. Set size to the number of bytes actually written to the buffer. Returns true if ok. - virtual bool unlock(uint size); - /// Copy the data with specified size into the buffer. A readable local copy is only guaranteed when OptionLocalBufferCopy is set. Returns true if ok. - virtual bool fill(const uint8 *src, uint size); - - /// Return the size of the buffer, in bytes. - virtual uint getSize() const; - /// Return the duration (in ms) of the sample in the buffer. - virtual float getDuration() const; - /// Return true if the buffer is stereo (multi-channel), false if mono. - virtual bool isStereo() const; - /// Return true if the buffer is loaded. Used for async load/unload. - virtual bool isBufferLoaded() const; - -}; /* class CBufferXAudio2 */ - -} /* namespace NLSOUND */ - -#endif /* #ifndef NLSOUND_BUFFER_XAUDIO2_H */ - -/* end of file */ diff --git a/code/nel/src/sound/driver/xaudio2/driver_xaudio2.def b/code/nel/src/sound/driver/xaudio2/driver_xaudio2.def deleted file mode 100644 index cf5a0aaf2..000000000 --- a/code/nel/src/sound/driver/xaudio2/driver_xaudio2.def +++ /dev/null @@ -1,5 +0,0 @@ -EXPORTS - NLSOUND_createISoundDriverInstance - NLSOUND_interfaceVersion - NLSOUND_outputProfile - NLSOUND_getDriverType \ No newline at end of file diff --git a/code/nel/src/sound/driver/xaudio2/effect_xaudio2.cpp b/code/nel/src/sound/driver/xaudio2/effect_xaudio2.cpp deleted file mode 100644 index ac3814226..000000000 --- a/code/nel/src/sound/driver/xaudio2/effect_xaudio2.cpp +++ /dev/null @@ -1,188 +0,0 @@ -// NeL - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as -// published by the Free Software Foundation, either version 3 of the -// License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -#include "stdxaudio2.h" - -// Project includes -#include "sound_driver_xaudio2.h" -#include "listener_xaudio2.h" -#include "effect_xaudio2.h" - -#ifdef DEBUG_NEW -#define new DEBUG_NEW -#endif - -using namespace std; -using namespace NLMISC; - -namespace NLSOUND { - -CEffectXAudio2::CEffectXAudio2(CSoundDriverXAudio2 *soundDriver, uint channels) : _SoundDriver(soundDriver), _DryVoice(NULL), _FilterVoice(NULL), _Effect(NULL) -{ - HRESULT hr; - - XAUDIO2_VOICE_DETAILS voice_details; - soundDriver->getListener()->getDryVoice()->GetVoiceDetails(&voice_details); - - if (channels == 0) - channels = voice_details.InputChannels; - - // Mix voice - { - if (FAILED(hr = soundDriver->getXAudio2()->CreateSubmixVoice(&_DryVoice, channels, voice_details.InputSampleRate, 0, 4510, NULL, NULL))) - { release(); _SoundDriver = NULL; nlwarning(NLSOUND_XAUDIO2_PREFIX "FAILED CreateSubmixVoice _DryVoice!"); return; } - - XAUDIO2_VOICE_SENDS voiceSends; - XAUDIO2_SEND_DESCRIPTOR sendDescriptor; - voiceSends.pSends = &sendDescriptor; - voiceSends.SendCount = 1; - sendDescriptor.Flags = 0; - sendDescriptor.pOutputVoice = soundDriver->getListener()->getDryVoice(); - _DryVoice->SetOutputVoices(&voiceSends); - - if (channels == 1) - { - FLOAT32 outputMatrix[32]; - for (uint32 i = 0; i < voice_details.InputChannels; ++i) - outputMatrix[i] = 1.0f; - _DryVoice->SetOutputMatrix(sendDescriptor.pOutputVoice, 1, voice_details.InputChannels, outputMatrix); - } - } - - // Filter dummy voice - { - if (FAILED(hr = soundDriver->getXAudio2()->CreateSubmixVoice(&_FilterVoice, channels, voice_details.InputSampleRate, 0, 4500, NULL, NULL))) - { release(); _SoundDriver = NULL; nlwarning(NLSOUND_XAUDIO2_PREFIX "FAILED CreateSubmixVoice _FilterVoice!"); return; } - - XAUDIO2_VOICE_SENDS voiceSends; - XAUDIO2_SEND_DESCRIPTOR sendDescriptor; - voiceSends.pSends = &sendDescriptor; - voiceSends.SendCount = 1; - sendDescriptor.Flags = 0; - sendDescriptor.pOutputVoice = _DryVoice; - _FilterVoice->SetOutputVoices(&voiceSends); - } -} - -CEffectXAudio2::~CEffectXAudio2() -{ - release(); - if (_SoundDriver) { _SoundDriver->removeEffect(this); _SoundDriver = NULL; } -} - -void CEffectXAudio2::release() -{ - if (_FilterVoice) { _FilterVoice->DestroyVoice(); _FilterVoice = NULL; } - if (_DryVoice) { _DryVoice->DestroyVoice(); _DryVoice = NULL; } -} - -CReverbEffectXAudio2::CReverbEffectXAudio2(CSoundDriverXAudio2 *soundDriver) : CEffectXAudio2(soundDriver, 1) -{ - if (_DryVoice) - { - HRESULT hr; - - uint flags = 0; - #ifdef NL_DEBUG - flags |= XAUDIO2FX_DEBUG; - #endif - if (FAILED(hr = XAudio2CreateReverb(&_Effect, flags))) - { release(); nlwarning(NLSOUND_XAUDIO2_PREFIX "XAudio2CreateReverb FAILED"); return; } - - XAUDIO2_VOICE_DETAILS voice_details; - _DryVoice->GetVoiceDetails(&voice_details); - XAUDIO2_EFFECT_DESCRIPTOR effect_descriptor; - effect_descriptor.InitialState = TRUE; - effect_descriptor.OutputChannels = voice_details.InputChannels; - effect_descriptor.pEffect = _Effect; - XAUDIO2_EFFECT_CHAIN effect_chain; - effect_chain.EffectCount = 1; - effect_chain.pEffectDescriptors = &effect_descriptor; - if (FAILED(hr = _DryVoice->SetEffectChain(&effect_chain))) - { release(); nlwarning(NLSOUND_XAUDIO2_PREFIX "SetEffectChain FAILED"); return; } - - setEnvironment(); - } -} - -CReverbEffectXAudio2::~CReverbEffectXAudio2() -{ - -} - -void CReverbEffectXAudio2::release() -{ - CEffectXAudio2::release(); - if (_Effect) { _Effect->Release(); _Effect = NULL; } -} - -/// Set the environment (you have full control now, have fun) -void CReverbEffectXAudio2::setEnvironment(const CEnvironment &environment, float roomSize) -{ - // unused params - _ReverbParams.LowEQCutoff = 4; - _ReverbParams.HighEQCutoff = 6; - _ReverbParams.RearDelay = XAUDIO2FX_REVERB_DEFAULT_REAR_DELAY; - _ReverbParams.PositionLeft = XAUDIO2FX_REVERB_DEFAULT_POSITION; - _ReverbParams.PositionRight = XAUDIO2FX_REVERB_DEFAULT_POSITION; - _ReverbParams.PositionMatrixLeft = XAUDIO2FX_REVERB_DEFAULT_POSITION_MATRIX; - _ReverbParams.PositionMatrixRight = XAUDIO2FX_REVERB_DEFAULT_POSITION_MATRIX; - _ReverbParams.RoomFilterFreq = 5000.0f; - _ReverbParams.WetDryMix = 100.0f; - - // directly mapped - _ReverbParams.Density = environment.Density; - _ReverbParams.RoomFilterMain = environment.RoomFilter; - _ReverbParams.RoomFilterHF = environment.RoomFilterHF; - _ReverbParams.ReverbGain = environment.LateReverb; - _ReverbParams.ReflectionsGain = environment.Reflections; - _ReverbParams.RoomSize = roomSize; - - // conversions, see ReverbConvertI3DL2ToNative in case of errors - if (environment.DecayHFRatio >= 1.0f) - { - _ReverbParams.HighEQGain = XAUDIO2FX_REVERB_DEFAULT_HIGH_EQ_GAIN; - sint32 index = (sint32)(log10(environment.DecayHFRatio) * -4.0f) + 8; - clamp(index, XAUDIO2FX_REVERB_MIN_LOW_EQ_GAIN, XAUDIO2FX_REVERB_MAX_LOW_EQ_GAIN); - _ReverbParams.LowEQGain = (BYTE)index; - _ReverbParams.DecayTime = environment.DecayTime * environment.DecayHFRatio; - } - else - { - _ReverbParams.LowEQGain = XAUDIO2FX_REVERB_DEFAULT_LOW_EQ_GAIN; - sint32 index = (sint32)(log10(environment.DecayHFRatio) * 4.0f) + 8; - clamp(index, XAUDIO2FX_REVERB_MIN_HIGH_EQ_GAIN, XAUDIO2FX_REVERB_MAX_HIGH_EQ_GAIN); - _ReverbParams.HighEQGain = (BYTE)index; - _ReverbParams.DecayTime = environment.DecayTime; - } - - sint32 reflections_delay = (sint32)(environment.ReflectionsDelay * 1000.0f); - clamp(reflections_delay, XAUDIO2FX_REVERB_MIN_REFLECTIONS_DELAY, XAUDIO2FX_REVERB_MAX_REFLECTIONS_DELAY); - _ReverbParams.ReflectionsDelay = (UINT32)reflections_delay; - - sint32 reverb_delay = (sint32)(environment.LateReverbDelay * 1000.0f); - clamp(reverb_delay, XAUDIO2FX_REVERB_MIN_REVERB_DELAY, XAUDIO2FX_REVERB_MAX_REVERB_DELAY); - _ReverbParams.ReverbDelay = (BYTE)reverb_delay; - - _ReverbParams.EarlyDiffusion = (BYTE)(environment.Diffusion * 0.15f); - _ReverbParams.LateDiffusion = _ReverbParams.EarlyDiffusion; - - _DryVoice->SetEffectParameters(0, &_ReverbParams, sizeof(_ReverbParams), 0); -} - -} /* namespace NLSOUND */ - -/* end of file */ diff --git a/code/nel/src/sound/driver/xaudio2/effect_xaudio2.h b/code/nel/src/sound/driver/xaudio2/effect_xaudio2.h deleted file mode 100644 index 97900b938..000000000 --- a/code/nel/src/sound/driver/xaudio2/effect_xaudio2.h +++ /dev/null @@ -1,78 +0,0 @@ -// NeL - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as -// published by the Free Software Foundation, either version 3 of the -// License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -#ifndef NLSOUND_EFFECT_XAUDIO2_H -#define NLSOUND_EFFECT_XAUDIO2_H - -namespace NLSOUND { - class CSoundDriverXAudio2; - -/** - * \brief CEffectXAudio2 - * \date 2008-09-25 07:46GMT - * \author Jan Boon (Kaetemi) - * CEffectXAudio2 - */ -class CEffectXAudio2 -{ -protected: - // outside pointers - CSoundDriverXAudio2 *_SoundDriver; - - // pointers - IXAudio2SubmixVoice *_DryVoice; - IXAudio2SubmixVoice *_FilterVoice; - IUnknown *_Effect; // set by subclass - -public: - CEffectXAudio2(CSoundDriverXAudio2 *soundDriver, uint channels); - virtual ~CEffectXAudio2(); - virtual void release(); - - inline IUnknown *getEffect() { return _Effect; } - inline IXAudio2Voice *getDryVoice() { return _DryVoice; } - inline IXAudio2Voice *getFilterVoice() { return _FilterVoice; } - -}; /* class CEffectXAudio2 */ - -/** - * \brief CReverbEffectXAudio2 - * \date 2008-09-17 17:27GMT - * \author Jan Boon (Kaetemi) - * CReverbEffectXAudio2 - */ -class CReverbEffectXAudio2 : public IReverbEffect, public CEffectXAudio2 -{ -protected: - // user data - /// Parameters of the reverb (eax environment) effect. - XAUDIO2FX_REVERB_PARAMETERS _ReverbParams; - -public: - CReverbEffectXAudio2(CSoundDriverXAudio2 *soundDriver); - virtual ~CReverbEffectXAudio2(); - virtual void release(); - - /// Set the environment (you have full control now, have fun) - virtual void setEnvironment(const CEnvironment &environment = CEnvironment(), float roomSize = 100.0f); - -}; /* class CReverbEffectXAudio2 */ - -} /* namespace NLSOUND */ - -#endif /* #ifndef NLSOUND_EFFECT_XAUDIO2_H */ - -/* end of file */ diff --git a/code/nel/src/sound/driver/xaudio2/listener_xaudio2.cpp b/code/nel/src/sound/driver/xaudio2/listener_xaudio2.cpp deleted file mode 100644 index c6b364046..000000000 --- a/code/nel/src/sound/driver/xaudio2/listener_xaudio2.cpp +++ /dev/null @@ -1,181 +0,0 @@ -// NeL - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as -// published by the Free Software Foundation, either version 3 of the -// License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -#include "stdxaudio2.h" - -// Project includes -#include "sound_driver_xaudio2.h" -#include "listener_xaudio2.h" - -#ifdef DEBUG_NEW -#define new DEBUG_NEW -#endif - -using namespace std; -using namespace NLMISC; - -namespace NLSOUND { - -CListenerXAudio2::CListenerXAudio2(CSoundDriverXAudio2 *soundDriver) -: _DryVoice(NULL), _FilterVoice(NULL), _ListenerOk(false), _SoundDriver(soundDriver), -_DopplerScaler(1.0f), _Pos(0.0f, 0.0f, 0.0f), _RolloffScaler(1.0f) -{ - nlwarning(NLSOUND_XAUDIO2_PREFIX "Initializing CListenerXAudio2"); - - HRESULT hr; - memset(&_Listener, 0, sizeof(_Listener)); - - _Listener.OrientFront.x = 0.0f; - _Listener.OrientFront.y = 0.0f; - _Listener.OrientFront.z = 1.0f; - _Listener.OrientTop.x = 0.0f; - _Listener.OrientTop.y = 1.0f; - _Listener.OrientTop.z = 0.0f; - _Listener.Position.x = 0.0f; - _Listener.Position.y = 0.0f; - _Listener.Position.z = 0.0f; - _Listener.Velocity.x = 0.0f; - _Listener.Velocity.y = 0.0f; - _Listener.Velocity.z = 0.0f; - - XAUDIO2_VOICE_DETAILS voice_details; - soundDriver->getMasteringVoice()->GetVoiceDetails(&voice_details); - - if (FAILED(hr = soundDriver->getXAudio2()->CreateSubmixVoice(&_DryVoice, voice_details.InputChannels, voice_details.InputSampleRate, 0, 9010, NULL, NULL))) - { release(); _SoundDriver = NULL; throw ESoundDriver(NLSOUND_XAUDIO2_PREFIX "FAILED CreateSubmixVoice _DryVoice!"); return; } - - if (FAILED(hr = soundDriver->getXAudio2()->CreateSubmixVoice(&_FilterVoice, voice_details.InputChannels, voice_details.InputSampleRate, 0, 9000, NULL, NULL))) - { release(); _SoundDriver = NULL; throw ESoundDriver(NLSOUND_XAUDIO2_PREFIX "FAILED CreateSubmixVoice _FilterVoice!"); return; } - - XAUDIO2_VOICE_SENDS voiceSends; - XAUDIO2_SEND_DESCRIPTOR sendDescriptor; - voiceSends.pSends = &sendDescriptor; - voiceSends.SendCount = 1; - sendDescriptor.Flags = 0; - sendDescriptor.pOutputVoice = _DryVoice; - _FilterVoice->SetOutputVoices(&voiceSends); - - _ListenerOk = true; -} - -CListenerXAudio2::~CListenerXAudio2() -{ - nlwarning(NLSOUND_XAUDIO2_PREFIX "Destroying CListenerXAudio2"); - CSoundDriverXAudio2 *soundDriver = _SoundDriver; - release(); - if (soundDriver) soundDriver->removeListener(this); -} - -#define NLSOUND_XAUDIO2_RELEASE_EX(pointer, command) if (_ListenerOk) nlassert(pointer); \ - if (pointer) { command; pointer = NULL; } - -void CListenerXAudio2::release() -{ - NLSOUND_XAUDIO2_RELEASE_EX(_FilterVoice, _FilterVoice->DestroyVoice()) - NLSOUND_XAUDIO2_RELEASE_EX(_DryVoice, _DryVoice->DestroyVoice()) - _SoundDriver = NULL; - _ListenerOk = false; -} - -/// \name Listener properties -//@{ -/// Set the position vector (default: (0,0,0)) (3D mode only) -void CListenerXAudio2::setPos(const NLMISC::CVector& pos) -{ - _Pos = pos; - NLSOUND_XAUDIO2_X3DAUDIO_VECTOR_FROM_VECTOR(_Listener.Position, pos); -} - -/** Get the position vector. - * See setPos() for details. - */ -const NLMISC::CVector &CListenerXAudio2::getPos() const -{ - return _Pos; -} - -/// Set the velocity vector (3D mode only, ignored in stereo mode) (default: (0,0,0)) -void CListenerXAudio2::setVelocity(const NLMISC::CVector& vel) -{ - NLSOUND_XAUDIO2_X3DAUDIO_VECTOR_FROM_VECTOR(_Listener.Velocity, vel); -} - -/// Get the velocity vector -void CListenerXAudio2::getVelocity(NLMISC::CVector& vel) const -{ - NLSOUND_XAUDIO2_VECTOR_FROM_X3DAUDIO_VECTOR(vel, _Listener.Velocity); -} - -/// Set the orientation vectors (3D mode only, ignored in stereo mode) (default: (0,1,0), (0,0,-1)) -void CListenerXAudio2::setOrientation(const NLMISC::CVector& front, const NLMISC::CVector& up) -{ - // nldebug("--- orientation --- %s --- %s ---", front.toString().c_str(), up.toString().c_str()); - - NLSOUND_XAUDIO2_X3DAUDIO_VECTOR_FROM_VECTOR(_Listener.OrientFront, front); - NLSOUND_XAUDIO2_X3DAUDIO_VECTOR_FROM_VECTOR(_Listener.OrientTop, up); -} - -/// Get the orientation vectors -void CListenerXAudio2::getOrientation(NLMISC::CVector& front, NLMISC::CVector& up) const -{ - NLSOUND_XAUDIO2_VECTOR_FROM_X3DAUDIO_VECTOR(front, _Listener.OrientFront); - NLSOUND_XAUDIO2_VECTOR_FROM_X3DAUDIO_VECTOR(up, _Listener.OrientTop); -} - -/** Set the gain (volume value inside [0 , 1]). (default: 1) - * 0.0 -> silence - * 0.5 -> -6dB - * 1.0 -> no attenuation - * values > 1 (amplification) not supported by most drivers - */ -void CListenerXAudio2::setGain(float gain) -{ - _DryVoice->SetVolume(gain); -} - -/// Get the gain -float CListenerXAudio2::getGain() const -{ - float gain; - _DryVoice->GetVolume(&gain); - return gain; -} - -//@} - -/// \name Global properties -//@{ -/// Set the doppler factor (default: 1) to exaggerate or not the doppler effect -void CListenerXAudio2::setDopplerFactor(float f) -{ - // nlinfo(NLSOUND_XAUDIO2_PREFIX "setDopplerFactor %f", f); - _DopplerScaler = f; -} - -/// Set the rolloff factor (default: 1) to scale the distance attenuation effect -void CListenerXAudio2::setRolloffFactor(float f) -{ - nlassert(!_SoundDriver->getOption(ISoundDriver::OptionManualRolloff)); - - // nlinfo(NLSOUND_XAUDIO2_PREFIX "setRolloffFactor %f", f); - _RolloffScaler = f; -} - -//@} - -} /* namespace NLSOUND */ - -/* end of file */ diff --git a/code/nel/src/sound/driver/xaudio2/listener_xaudio2.h b/code/nel/src/sound/driver/xaudio2/listener_xaudio2.h deleted file mode 100644 index 10a39ffe5..000000000 --- a/code/nel/src/sound/driver/xaudio2/listener_xaudio2.h +++ /dev/null @@ -1,110 +0,0 @@ -// NeL - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as -// published by the Free Software Foundation, either version 3 of the -// License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -#ifndef NLSOUND_LISTENER_XAUDIO2_H -#define NLSOUND_LISTENER_XAUDIO2_H - -#include "nel/sound/driver/listener.h" -#include "nel/sound/driver/sound_driver.h" - -namespace NLSOUND { - class CSoundDriverXAudio2; - -/** - * \brief CListenerXAudio2 - * \date 2008-08-20 12:32GMT - * \author Jan Boon (Kaetemi) - * CListenerXAudio2 is an implementation of the IListener interface to run on XAudio2. - * TODO: For occlusion reverb output gain must be controllable per voice (source send with lower gain to reverb submix). - */ -class CListenerXAudio2 : public IListener, public NLMISC::CManualSingleton -{ -protected: - // outside pointers - CSoundDriverXAudio2 *_SoundDriver; - - // pointers - /// Submix voice for volume change, also direct sample input. - IXAudio2SubmixVoice *_DryVoice; - /// Dummy passtrough submix voice for the setting up the filtered send - IXAudio2SubmixVoice *_FilterVoice; - - // instances - /// X3DAudio data for listener position in space. - X3DAUDIO_LISTENER _Listener; - /// NeL Position used for manual rolloff calculation. - NLMISC::CVector _Pos; - /// If the listener initialized correctly. - bool _ListenerOk; - - // user vars - /// Doppler scaler, set by user - float _DopplerScaler; - /// Distance/Roloff scaler - float _RolloffScaler; -public: - CListenerXAudio2(CSoundDriverXAudio2 *soundDriver); - virtual ~CListenerXAudio2(); - void release(); - - inline CSoundDriverXAudio2 *getSoundDriver() { return _SoundDriver; } - inline X3DAUDIO_LISTENER *getListener() { return &_Listener; } - inline IXAudio2SubmixVoice *getDryVoice() { return _DryVoice; } - inline IXAudio2SubmixVoice *getFilterVoice() { return _FilterVoice; } - inline float getDopplerScaler() { return _DopplerScaler; } - inline float getRolloffScaler() { return _RolloffScaler; } - - /// \name Listener properties - //@{ - /// Set the position vector (default: (0,0,0)) (3D mode only) - virtual void setPos(const NLMISC::CVector& pos); - /** Get the position vector. - * See setPos() for details. - */ - virtual const NLMISC::CVector &getPos() const; - /// Set the velocity vector (3D mode only, ignored in stereo mode) (default: (0,0,0)) - virtual void setVelocity(const NLMISC::CVector& vel); - /// Get the velocity vector - virtual void getVelocity(NLMISC::CVector& vel) const; - /// Set the orientation vectors (3D mode only, ignored in stereo mode) (default: (0,1,0), (0,0,-1)) - virtual void setOrientation(const NLMISC::CVector& front, const NLMISC::CVector& up); - /// Get the orientation vectors - virtual void getOrientation(NLMISC::CVector& front, NLMISC::CVector& up) const; - /** Set the gain (volume value inside [0 , 1]). (default: 1) - * 0.0 -> silence - * 0.5 -> -6dB - * 1.0 -> no attenuation - * values > 1 (amplification) not supported by most drivers - */ - virtual void setGain(float gain); - /// Get the gain - virtual float getGain() const; - //@} - - /// \name Global properties - //@{ - /// Set the doppler factor (default: 1) to exaggerate or not the doppler effect - virtual void setDopplerFactor(float f); - /// Set the rolloff factor (default: 1) to scale the distance attenuation effect - virtual void setRolloffFactor(float f); - //@} -}; /* class CListenerXAudio2 */ - -} /* namespace NLSOUND */ - -#endif /* #ifndef NLSOUND_LISTENER_XAUDIO2_H */ - -/* end of file */ diff --git a/code/nel/src/sound/driver/xaudio2/resources.rc b/code/nel/src/sound/driver/xaudio2/resources.rc deleted file mode 100644 index ef7165456..000000000 --- a/code/nel/src/sound/driver/xaudio2/resources.rc +++ /dev/null @@ -1,37 +0,0 @@ -#include -#include "config.h" - -VS_VERSION_INFO VERSIONINFO -FILEVERSION NL_VERSION_RC -PRODUCTVERSION NL_VERSION_RC -FILEFLAGSMASK VS_FFI_FILEFLAGSMASK -#ifdef _DEBUG -FILEFLAGS VS_FF_DEBUG -#else -FILEFLAGS 0x0L -#endif -FILEOS VOS_NT_WINDOWS32 -FILETYPE VFT_DLL -FILESUBTYPE 0x0L -BEGIN - BLOCK "StringFileInfo" - BEGIN - BLOCK "040904b0" - BEGIN - VALUE "FileDescription", "NeL XAudio2 driver" - VALUE "FileVersion", NL_VERSION - VALUE "LegalCopyright", COPYRIGHT -#ifdef _DEBUG - VALUE "OriginalFilename", "nel_drv_xaudio2_win_d.dll" -#else - VALUE "OriginalFilename", "nel_drv_xaudio2_win_r.dll" -#endif - VALUE "ProductName", "Ryzom Core" - VALUE "ProductVersion", NL_VERSION - END - END - BLOCK "VarFileInfo" - BEGIN - VALUE "Translation", 0x409, 1252 - END -END diff --git a/code/nel/src/sound/driver/xaudio2/sound_driver_xaudio2.cpp b/code/nel/src/sound/driver/xaudio2/sound_driver_xaudio2.cpp deleted file mode 100644 index 992f6c66d..000000000 --- a/code/nel/src/sound/driver/xaudio2/sound_driver_xaudio2.cpp +++ /dev/null @@ -1,544 +0,0 @@ -// NeL - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as -// published by the Free Software Foundation, either version 3 of the -// License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -#include "stdxaudio2.h" - -// Project includes -#include "listener_xaudio2.h" -#include "source_xaudio2.h" -#include "effect_xaudio2.h" -#include "sound_driver_xaudio2.h" - -#ifdef DEBUG_NEW -#define new DEBUG_NEW -#endif - -using namespace std; -using namespace NLMISC; - -/// Sample rate for master voice (device). -/// Default (0) under windows is 44100 (CD) or 48000 (DVD). -/// Note 1: OpenAL driver uses 22050 at the moment. -/// Note 2: 44100 seems to be the optimal value here. -//#define NLSOUND_XAUDIO2_MASTER_SAMPLE_RATE 44100 -#define NLSOUND_XAUDIO2_MASTER_SAMPLE_RATE XAUDIO2_DEFAULT_SAMPLERATE - -namespace NLSOUND { - -// ****************************************************************** - -#ifndef NL_STATIC -class CSoundDriverXAudio2NelLibrary : public NLMISC::INelLibrary { - void onLibraryLoaded(bool /* firstTime */) { } - void onLibraryUnloaded(bool /* lastTime */) { } -}; -NLMISC_DECL_PURE_LIB(CSoundDriverXAudio2NelLibrary) - -HINSTANCE CSoundDriverXAudio2DllHandle = NULL; -BOOL WINAPI DllMain(HANDLE hModule, DWORD /* ul_reason_for_call */, LPVOID /* lpReserved */) -{ - CSoundDriverXAudio2DllHandle = (HINSTANCE)hModule; - return TRUE; -} -#endif /* #ifndef NL_STATIC */ - -// *************************************************************************** - -#ifndef NL_STATIC -#ifdef NL_COMP_MINGW -extern "C" { -#endif -#endif - -// *************************************************************************** - -#ifdef NL_STATIC -ISoundDriver* createISoundDriverInstanceXAudio2 -#else -__declspec(dllexport) ISoundDriver *NLSOUND_createISoundDriverInstance -#endif - (ISoundDriver::IStringMapperProvider *stringMapper) -{ - return new CSoundDriverXAudio2(stringMapper); -} - -// ****************************************************************** - -#ifdef NL_STATIC -uint32 interfaceVersionXAudio2() -#else -__declspec(dllexport) uint32 NLSOUND_interfaceVersion() -#endif -{ - return ISoundDriver::InterfaceVersion; -} - -// ****************************************************************** - -#ifdef NL_STATIC -void outputProfileXAudio2 -#else -__declspec(dllexport) void NLSOUND_outputProfile -#endif - (string &out) -{ - CSoundDriverXAudio2::getInstance()->writeProfile(out); -} - -// ****************************************************************** - -#ifdef NL_STATIC -ISoundDriver::TDriver getDriverTypeXAudio2() -#else -__declspec(dllexport) ISoundDriver::TDriver NLSOUND_getDriverType() -#endif -{ - return ISoundDriver::DriverXAudio2; -} - -// ****************************************************************** - -#ifndef NL_STATIC -#ifdef NL_COMP_MINGW -} -#endif -#endif - -// ****************************************************************** - -#ifdef NL_DEBUG - -static XAUDIO2_DEBUG_CONFIGURATION NLSOUND_XAUDIO2_DEBUG_CONFIGURATION_DISABLED = { - 0, 0, true, true, true, true -}; - -NLMISC_CATEGORISED_COMMAND(nel, xa2DebugDisable, "", "") -{ - human; quiet; log; args; rawCommandString; - CSoundDriverXAudio2::getInstance()->getXAudio2()->SetDebugConfiguration(&NLSOUND_XAUDIO2_DEBUG_CONFIGURATION_DISABLED); - return true; -} - -static XAUDIO2_DEBUG_CONFIGURATION NLSOUND_XAUDIO2_DEBUG_CONFIGURATION_HEAVY = { - (UINT32)(~XAUDIO2_LOG_FUNC_CALLS & ~XAUDIO2_LOG_LOCKS & ~XAUDIO2_LOG_MEMORY), 0, true, true, true, true -}; - -NLMISC_CATEGORISED_COMMAND(nel, xa2DebugHeavy, "", "") -{ - human; quiet; log; args; rawCommandString; - CSoundDriverXAudio2::getInstance()->getXAudio2()->SetDebugConfiguration(&NLSOUND_XAUDIO2_DEBUG_CONFIGURATION_HEAVY); - return true; -} - -#endif /* NL_DEBUG */ - -// ****************************************************************** - -CSoundDriverXAudio2::CSoundDriverXAudio2(ISoundDriver::IStringMapperProvider * /* stringMapper */) - : _XAudio2(NULL), _MasteringVoice(NULL), _Listener(NULL), - _SoundDriverOk(false), _CoInitOk(false), _OperationSetCounter(65536), - _PerformanceCommit3DCounter(0), _PerformanceADPCMBufferSize(0), - _PerformancePCMBufferSize(0), _PerformanceSourcePlayCounter(0) -{ - nlwarning(NLSOUND_XAUDIO2_PREFIX "Creating CSoundDriverXAudio2"); - - memset(&_X3DAudioHandle, 0, sizeof(_X3DAudioHandle)); - memset(&_EmptyListener, 0, sizeof(_EmptyListener)); - - _EmptyListener.OrientFront.x = 0.0f; - _EmptyListener.OrientFront.y = 0.0f; - _EmptyListener.OrientFront.z = 1.0f; - _EmptyListener.OrientTop.x = 0.0f; - _EmptyListener.OrientTop.y = 1.0f; - _EmptyListener.OrientTop.z = 0.0f; - _EmptyListener.Position.x = 0.0f; - _EmptyListener.Position.y = 0.0f; - _EmptyListener.Position.z = 0.0f; - _EmptyListener.Velocity.x = 0.0f; - _EmptyListener.Velocity.y = 0.0f; - _EmptyListener.Velocity.z = 0.0f; - - HRESULT hr; - - // Windows -#ifdef NL_OS_WINDOWS // CoInitializeEx not on xbox, lol - hr = CoInitializeEx(NULL, COINIT_MULTITHREADED); - if (hr == RPC_E_CHANGED_MODE) { nlwarning(NLSOUND_XAUDIO2_PREFIX "CoInitializeEx COINIT_APARTMENTTHREADED"); hr = CoInitializeEx(NULL, COINIT_APARTMENTTHREADED); } - _CoInitOk = (hr == S_OK) || (hr == S_FALSE); - if (!_CoInitOk) { release(); throw ESoundDriver(NLSOUND_XAUDIO2_PREFIX "FAILED CoInitializeEx"); return; } -#endif - - uint32 flags = 0; -#ifdef NL_DEBUG -// flags |= XAUDIO2_DEBUG_ENGINE; // comment when done using this :) -#endif - - // XAudio2 - if (FAILED(hr = XAudio2Create(&_XAudio2, flags, XAUDIO2_DEFAULT_PROCESSOR))) - { release(); throw ESoundDriver(NLSOUND_XAUDIO2_PREFIX "XAudio2 failed to initialize. Please install the latest version of the DirectX End-User Runtimes."); return; } -} - -CSoundDriverXAudio2::~CSoundDriverXAudio2() -{ - release(); - - // Windows -#ifdef NL_OS_WINDOWS - if (_CoInitOk) CoUninitialize(); - _CoInitOk = false; -#else - nlassert(!_CoInitOk); -#endif - - nlinfo(NLSOUND_XAUDIO2_PREFIX "Destroying CSoundDriverXAudio2"); -} - -#define NLSOUND_XAUDIO2_RELEASE(pointer) if (_SoundDriverOk) nlassert(pointer); \ - /*if (pointer) {*/ delete pointer; pointer = NULL; /*}*/ -#define NLSOUND_XAUDIO2_RELEASE_EX(pointer, command) if (_SoundDriverOk) nlassert(pointer); \ - if (pointer) { command; pointer = NULL; } - -void CSoundDriverXAudio2::release() -{ - nlinfo(NLSOUND_XAUDIO2_PREFIX "Releasing CSoundDriverXAudio2"); - - // WARNING: Only internal resources are released here, - // the created instances must still be released by the user! - - // Release internal resources of all remaining ISource instances - if (!_Sources.empty()) - { - nlwarning(NLSOUND_XAUDIO2_PREFIX "_Sources.size(): '%u'", (uint32)_Sources.size()); - set::iterator it(_Sources.begin()), end(_Sources.end()); - for (; it != end; ++it) (*it)->release(); - _Sources.clear(); - } - // Release internal resources of all remaining IBuffer instances - if (!_Buffers.empty()) - { - nlwarning(NLSOUND_XAUDIO2_PREFIX "_Buffers.size(): '%u'", (uint32)_Buffers.size()); - set::iterator it(_Buffers.begin()), end(_Buffers.end()); - for (; it != end; ++it) (*it)->release(); - _Buffers.clear(); - } - // Release internal resources of all remaining IEffect instances - if (!_Effects.empty()) - { - nlwarning(NLSOUND_XAUDIO2_PREFIX "_Effects.size(): '%u'", (uint32)_Effects.size()); - set::iterator it(_Effects.begin()), end(_Effects.end()); - for (; it != end; ++it) (*it)->release(); - _Effects.clear(); - } - // Release internal resources of the IListener instance - if (_Listener) { nlwarning(NLSOUND_XAUDIO2_PREFIX "_Listener: !NULL"); _Listener->release(); _Listener = NULL; } - - // XAudio2 - NLSOUND_XAUDIO2_RELEASE_EX(_MasteringVoice, _MasteringVoice->DestroyVoice()); - NLSOUND_XAUDIO2_RELEASE_EX(_XAudio2, _XAudio2->Release()); - _SoundDriverOk = false; -} - -/// Return a list of available devices for the user. The value at index 0 is empty, and is used for automatic device selection. -void CSoundDriverXAudio2::getDevices(std::vector &devices) -{ - devices.push_back(""); // empty - - UINT32 deviceCount; - _XAudio2->GetDeviceCount(&deviceCount); - - if (deviceCount == 0) - { - nldebug("XA2: No audio devices"); - } - else - { - XAUDIO2_DEVICE_DETAILS deviceDetails; - nldebug("XA2: Listing devices: "); - for (uint i = 0; i < deviceCount; ++i) - { - _XAudio2->GetDeviceDetails(i, &deviceDetails); - std::string deviceName = wideToUtf8(deviceDetails.DisplayName); - nldebug("XA2: - %s", deviceName.c_str()); - devices.push_back(deviceName); - } - } -} - -/// (Internal) Get device index and details from string. -uint CSoundDriverXAudio2::getDeviceIndex(const std::string &device, XAUDIO2_DEVICE_DETAILS *deviceDetails) -{ - if (device.empty()) - { - _XAudio2->GetDeviceDetails(0, deviceDetails); - return 0; - } - - UINT32 deviceCount; - _XAudio2->GetDeviceCount(&deviceCount); - - for (uint i = 0; i < deviceCount; ++i) - { - _XAudio2->GetDeviceDetails(i, deviceDetails); - std::string deviceName = wideToUtf8(deviceDetails->DisplayName); - if (deviceName == device) - return i; - } - - nldebug("XA2: Device '%s' not found", device.c_str()); - return 0; -} - -/// Initialize the driver with a user selected device. If device.empty(), the default or most appropriate device is used. -void CSoundDriverXAudio2::initDevice(const std::string &device, TSoundOptions options) -{ - nlinfo(NLSOUND_XAUDIO2_PREFIX "Initializing CSoundDriverXAudio2"); - - // list of supported options in this driver - const sint supportedOptions = - OptionEnvironmentEffects - | OptionAllowADPCM - | OptionSoftwareBuffer - | OptionManualRolloff - | OptionLocalBufferCopy - | OptionHasBufferStreaming; - - // list of forced options in this driver - // always use software buffer, always have local copy - const sint forcedOptions = - OptionSoftwareBuffer - | OptionManualRolloff - | OptionLocalBufferCopy; - - // set the options - _Options = (TSoundOptions)(((sint)options & supportedOptions) | forcedOptions); - -#ifdef NL_OS_WINDOWS // CoInitializeEx not on xbox, lol - if (!_CoInitOk) { throw ESoundDriver(NLSOUND_XAUDIO2_PREFIX "FAILED CoInitializeEx"); return; } -#endif - - HRESULT hr; - - // XAudio2 - XAUDIO2_DEVICE_DETAILS deviceDetails; - uint deviceIndex = getDeviceIndex(device, &deviceDetails); - if (FAILED(hr = _XAudio2->CreateMasteringVoice(&_MasteringVoice, 0, NLSOUND_XAUDIO2_MASTER_SAMPLE_RATE, 0, deviceIndex, NULL))) - { release(); throw ESoundDriver(NLSOUND_XAUDIO2_PREFIX "FAILED CreateMasteringVoice _MasteringVoice!"); return; } - - // X3DAudio - // speed of sound in meters per second for dry air at approximately 20C, used with X3DAudioInitialize - // #define X3DAUDIO_SPEED_OF_SOUND 343.5f - X3DAudioInitialize(deviceDetails.OutputFormat.dwChannelMask, X3DAUDIO_SPEED_OF_SOUND, _X3DAudioHandle); - - _SoundDriverOk = true; -} - -/// Return options that are enabled (including those that cannot be disabled on this driver). -ISoundDriver::TSoundOptions CSoundDriverXAudio2::getOptions() -{ - return _Options; -} - -/// Return if an option is enabled (including those that cannot be disabled on this driver). -bool CSoundDriverXAudio2::getOption(ISoundDriver::TSoundOptions option) -{ - return ((uint)_Options & (uint)option) == (uint)option; -} - -/// Tell sources without voice about a format -void CSoundDriverXAudio2::initSourcesFormat(IBuffer::TBufferFormat bufferFormat, uint8 channels, uint8 bitsPerSample) -{ - std::set::iterator it(_Sources.begin()), end(_Sources.end()); - for (; it != end; ++it) { if (!(*it)->getSourceVoice()) { (*it)->initFormat(bufferFormat, channels, bitsPerSample); } } -} - -/// (Internal) Create an XAudio2 source voice of the specified format. -IXAudio2SourceVoice *CSoundDriverXAudio2::createSourceVoice(IBuffer::TBufferFormat bufferFormat, uint8 channels, uint8 bitsPerSample, IXAudio2VoiceCallback *callback) -{ - nlassert(_Listener); - - HRESULT hr; - - WAVEFORMATEX wfe; - wfe.cbSize = 0; - - if (bufferFormat == IBuffer::FormatDviAdpcm) - nlassert(channels == 1 && bitsPerSample == 16); - - wfe.wFormatTag = WAVE_FORMAT_PCM; // DVI_ADPCM is converted in the driver - - wfe.nChannels = channels; - wfe.wBitsPerSample = bitsPerSample; - - XAUDIO2_VOICE_DETAILS voice_details; - _Listener->getDryVoice()->GetVoiceDetails(&voice_details); - wfe.nSamplesPerSec = voice_details.InputSampleRate; - - wfe.nBlockAlign = wfe.nChannels * wfe.wBitsPerSample / 8; - wfe.nAvgBytesPerSec = wfe.nSamplesPerSec * wfe.nBlockAlign; - - // TODO: Set callback (in CSourceXAudio2 maybe) for when error happens on voice, so we can restart it! - IXAudio2SourceVoice *source_voice = NULL; - - if (FAILED(hr = _XAudio2->CreateSourceVoice(&source_voice, &wfe, 0, NLSOUND_MAX_PITCH, callback, NULL, NULL))) - { if (source_voice) source_voice->DestroyVoice(); nlerror(NLSOUND_XAUDIO2_PREFIX "FAILED CreateSourceVoice"); return NULL; } - - return source_voice; -} - -/// (Internal) Destroy an XAudio2 source voice. -void CSoundDriverXAudio2::destroySourceVoice(IXAudio2SourceVoice *sourceVoice) -{ - if (sourceVoice) sourceVoice->DestroyVoice(); -} - -/// Create the listener instance -IListener *CSoundDriverXAudio2::createListener() -{ - if (!_Listener) _Listener = new CListenerXAudio2(this); - return static_cast(_Listener); -} - -/// Create a source, destroy with delete -ISource *CSoundDriverXAudio2::createSource() -{ - CSourceXAudio2 *source = new CSourceXAudio2(this); - _Sources.insert(source); - return static_cast(source); -} - -/// Create a sound buffer, destroy with delete -IBuffer *CSoundDriverXAudio2::createBuffer() -{ - CBufferXAudio2 *buffer = new CBufferXAudio2(this); - _Buffers.insert(buffer); - return static_cast(buffer); -} - -/// Create a reverb effect -IReverbEffect *CSoundDriverXAudio2::createReverbEffect() -{ - CReverbEffectXAudio2 *reverb = new CReverbEffectXAudio2(this); - if (reverb->getEffect()) - { - _Effects.insert(reverb); - return static_cast(reverb); - } - else - { - delete reverb; - return NULL; - } -} - -/// Return the maximum number of sources that can created -uint CSoundDriverXAudio2::countMaxSources() -{ - // the only limit is the user's cpu - // keep similar to openal limit for now ... - return 128; -} - -/// Return the maximum number of effects that can be created -uint CSoundDriverXAudio2::countMaxEffects() -{ - // the only limit is the user's cpu - // openal only allows 1 in software ... - return 32; -} - -/// Commit all the changes made to 3D settings of listener and sources -void CSoundDriverXAudio2::commit3DChanges() -{ - performanceIncreaseCommit3DCounter(); - - // Sync up sources & listener 3d position. - { - std::set::iterator it(_Sources.begin()), end(_Sources.end()); - for (; it != end; ++it) { (*it)->updateState(); (*it)->update3DChanges(); } - } -} - -/// Write information about the driver to the output stream. -void CSoundDriverXAudio2::writeProfile(std::string& out) -{ - XAUDIO2_PERFORMANCE_DATA performance; - _XAudio2->GetPerformanceData(&performance); - - out = toString(NLSOUND_XAUDIO2_NAME) - + "\n\tPCMBufferSize: " + toString(_PerformancePCMBufferSize) - + "\n\tADPCMBufferSize: " + toString(_PerformanceADPCMBufferSize) - + "\n\tSourcePlayCounter: " + toString(_PerformanceSourcePlayCounter) - + "\n\tCommit3DCounter: " + toString(_PerformanceCommit3DCounter) - + "\nXAUDIO2_PERFORMANCE_DATA" - + "\n\tAudioCyclesSinceLastQuery: " + toString(performance.AudioCyclesSinceLastQuery) - + "\n\tTotalCyclesSinceLastQuery: " + toString(performance.TotalCyclesSinceLastQuery) - + "\n\tMinimumCyclesPerQuantum: " + toString(performance.MinimumCyclesPerQuantum) - + "\n\tMaximumCyclesPerQuantum: " + toString(performance.MaximumCyclesPerQuantum) - + "\n\tMemoryUsageInBytes: " + toString(performance.MemoryUsageInBytes) - + "\n\tCurrentLatencyInSamples: " + toString(performance.CurrentLatencyInSamples) - + "\n\tGlitchesSinceEngineStarted: " + toString(performance.GlitchesSinceEngineStarted) - + "\n\tActiveSourceVoiceCount: " + toString(performance.ActiveSourceVoiceCount) - + "\n\tTotalSourceVoiceCount: " + toString(performance.TotalSourceVoiceCount) - + "\n\tActiveSubmixVoiceCount: " + toString(performance.ActiveSubmixVoiceCount) - + "\n\tActiveXmaSourceVoices: " + toString(performance.ActiveXmaSourceVoices) - + "\n\tActiveXmaStreams: " + toString(performance.ActiveXmaStreams) - + "\n"; - return; -} - -// Does not create a sound loader .. what does it do then? -void CSoundDriverXAudio2::startBench() -{ - NLMISC::CHTimer::startBench(); -} - -void CSoundDriverXAudio2::endBench() -{ - NLMISC::CHTimer::endBench(); -} - -void CSoundDriverXAudio2::displayBench(NLMISC::CLog *log) -{ - NLMISC::CHTimer::displayHierarchicalByExecutionPathSorted(log, CHTimer::TotalTime, true, 48, 2); - NLMISC::CHTimer::displayHierarchical(log, true, 48, 2); - NLMISC::CHTimer::displayByExecutionPath(log, CHTimer::TotalTime); - NLMISC::CHTimer::display(log, CHTimer::TotalTime); -} - -/// Remove a buffer (should be called by the friend destructor of the buffer class) -void CSoundDriverXAudio2::removeBuffer(CBufferXAudio2 *buffer) -{ - if (_Buffers.find(buffer) != _Buffers.end()) _Buffers.erase(buffer); - else nlwarning("removeBuffer already called"); -} - -/// Remove a source (should be called by the friend destructor of the source class) -void CSoundDriverXAudio2::removeSource(CSourceXAudio2 *source) -{ - if (_Sources.find(source) != _Sources.end()) _Sources.erase(source); - else nlwarning("removeSource already called"); -} - -/// (Internal) Remove an effect (should be called by the destructor of the effect class) -void CSoundDriverXAudio2::removeEffect(CEffectXAudio2 *effect) -{ - if (_Effects.find(effect) != _Effects.end()) _Effects.erase(effect); - else nlwarning("removeEffect already called"); -} - -} /* namespace NLSOUND */ - -/* end of file */ diff --git a/code/nel/src/sound/driver/xaudio2/sound_driver_xaudio2.h b/code/nel/src/sound/driver/xaudio2/sound_driver_xaudio2.h deleted file mode 100644 index e3c999b26..000000000 --- a/code/nel/src/sound/driver/xaudio2/sound_driver_xaudio2.h +++ /dev/null @@ -1,191 +0,0 @@ -// NeL - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as -// published by the Free Software Foundation, either version 3 of the -// License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -#ifndef NLSOUND_SOUND_DRIVER_XAUDIO2_H //todo: support MAKEINTRESOURCE for music files? -#define NLSOUND_SOUND_DRIVER_XAUDIO2_H - -// Project includes -#include "source_xaudio2.h" -#include "buffer_xaudio2.h" -//#include "music_channel_xaudio2.h" - -namespace NLSOUND { - class IListener; - class ISource; - class IMusicChannel; - class IBuffer; - class CListenerXAudio2; - class CSampleVoiceXAudio2; - class CMusicChannelXAudio2; - class CEffectXAudio2; - -/** - * \brief CSoundDriverXAudio2 - * \date 2008-08-20 10:52GMT - * \author Jan Boon (Kaetemi) - * CSoundDriverXAudio2 is an implementation of the ISoundDriver interface to run on XAudio2. - */ -class CSoundDriverXAudio2 : public ISoundDriver, public NLMISC::CManualSingleton -{ -protected: - // pointers - /// Pointer to XAudio2. - IXAudio2 *_XAudio2; - /// Pointer to XAudio2 Mastering Voice. - IXAudio2MasteringVoice *_MasteringVoice; - - // system vars - /// If XAudio2 is fully initialized. - bool _SoundDriverOk; - /// If CoInitializeEx has been called. - bool _CoInitOk; - /// Empty 3D Listener. - X3DAUDIO_LISTENER _EmptyListener; - /// Listener created by client code. - CListenerXAudio2 *_Listener; - /// Array with the allocated buffers created by client code. - std::set _Buffers; - /// Array with the allocated sources created by client code. - std::set _Sources; - /// Array with the allocated effects created by client code. - std::set _Effects; - /// Initialization Handle of X3DAudio. - X3DAUDIO_HANDLE _X3DAudioHandle; //I - /// Operation set counter - uint32 _OperationSetCounter; - - // performance stats - uint _PerformancePCMBufferSize; - uint _PerformanceADPCMBufferSize; - uint _PerformanceSourcePlayCounter; - uint _PerformanceCommit3DCounter; - - // user init vars - /// Driver options - TSoundOptions _Options; - -public: - /// (Internal) Constructor for CSoundDriverXAudio2. - CSoundDriverXAudio2(ISoundDriver::IStringMapperProvider *stringMapper); - /// (Internal) Destructor for CSoundDriverXAudio2. - virtual ~CSoundDriverXAudio2(); - /// (Internal) Release all resources owned by CSoundDriverXAudio2. - void release(); - - /// (Internal) Register a data buffer with the performance counters. - inline void performanceRegisterBuffer(IBuffer::TBufferFormat bufferFormat, uint size) - { - switch (bufferFormat) - { - case IBuffer::FormatPcm: _PerformancePCMBufferSize += size; break; - case IBuffer::FormatDviAdpcm: _PerformanceADPCMBufferSize += size; break; - } - } - /// (Internal) Remove a data buffer from the performance counters. - inline void performanceUnregisterBuffer(IBuffer::TBufferFormat bufferFormat, uint size) - { - switch (bufferFormat) - { - case IBuffer::FormatPcm: _PerformancePCMBufferSize -= size; break; - case IBuffer::FormatDviAdpcm: _PerformanceADPCMBufferSize -= size; break; - } - } - /// (Internal) Increase the source play counter by one. - inline void performanceIncreaseSourcePlayCounter() { ++_PerformanceSourcePlayCounter; } - /// (Internal) Increase the commit 3d counter by one. - inline void performanceIncreaseCommit3DCounter() { ++_PerformanceCommit3DCounter; } - - /// (Internal) Initialize uninitialized sources with this format (so xaudio2 voices don't need to be created at runtime) - void initSourcesFormat(IBuffer::TBufferFormat bufferFormat, uint8 channels, uint8 bitsPerSample); - - /// (Internal) Returns the listener for this driver. - inline CListenerXAudio2 *getListener() { return _Listener; } - /// (Internal) Returns the XAudio2 interface. - inline IXAudio2 *getXAudio2() { return _XAudio2; } - /// (Internal) Returns the XAudio2 Mastering Voice interface. - inline IXAudio2MasteringVoice *getMasteringVoice() { return _MasteringVoice; } - /// (Internal) Returns the handle to X3DAudio. - inline X3DAUDIO_HANDLE &getX3DAudio() { return _X3DAudioHandle; } - /// (Internal) Returns an X3DAudio listener at 0 position. - inline X3DAUDIO_LISTENER *getEmptyListener() { return &_EmptyListener; } - /// (Internal) Returns if EAX is enabled. - inline bool useEax() { return getOption(OptionEnvironmentEffects); } - /// (Internal) Returns a unique operation set id. - inline uint32 getUniqueOperationSet() { return ++_OperationSetCounter; } - - /// (Internal) Create an XAudio2 source voice of the specified format. - IXAudio2SourceVoice *createSourceVoice(IBuffer::TBufferFormat bufferFormat, uint8 channels, uint8 bitsPerSample, IXAudio2VoiceCallback *callback); - /// (Internal) Destroy an XAudio2 source voice. - void destroySourceVoice(IXAudio2SourceVoice *sourceVoice); - - /// Return a list of available devices for the user. The value at index 0 is empty, and is used for automatic device selection. - virtual void getDevices(std::vector &devices); - /// Initialize the driver with a user selected device. If device.empty(), the default or most appropriate device is used. - virtual void initDevice(const std::string &device, TSoundOptions options); - - /// (Internal) Get device index and details from string. - uint getDeviceIndex(const std::string &device, XAUDIO2_DEVICE_DETAILS *deviceDetails); - - /// Return options that are enabled (including those that cannot be disabled on this driver). - virtual TSoundOptions getOptions(); - /// Return if an option is enabled (including those that cannot be disabled on this driver). - virtual bool getOption(TSoundOptions option); - - /// Create the listener instance - virtual IListener *createListener(); - /// Create a source, destroy with delete - virtual ISource *createSource(); - /// Create a sound buffer, destroy with delete - virtual IBuffer *createBuffer(); - /// Create a reverb effect - virtual IReverbEffect *createReverbEffect(); - /// Return the maximum number of sources that can created - virtual uint countMaxSources(); - /// Return the maximum number of effects that can be created - virtual uint countMaxEffects(); - - /// Commit all the changes made to 3D settings of listener and sources. - virtual void commit3DChanges(); - - /// Write information about the driver to the output stream. - virtual void writeProfile(std::string& out) ; - - /// Does not create a sound loader... that's really awesome but what does it do? - virtual void startBench(); - virtual void endBench(); - virtual void displayBench(NLMISC::CLog *log); - - /// Get audio/container extensions that are supported natively by the driver implementation. - virtual void getMusicExtensions(std::vector & /* extensions */) const { } - /// Return if a music extension is supported by the driver's music channel. - virtual bool isMusicExtensionSupported(const std::string & /* extension */) const { return false; } - - /// (Internal) Remove a buffer (should be called by the destructor of the buffer class). - void removeBuffer(CBufferXAudio2 *buffer); - /// (Internal) Remove a source (should be called by the destructor of the source class). - void removeSource(CSourceXAudio2 *source); - /// (Internal) Remove the listener (should be called by the destructor of the listener class) - inline void removeListener(CListenerXAudio2 *listener) { nlassert(_Listener == listener); _Listener = NULL; } - /// (Internal) Remove an effect (should be called by the destructor of the effect class) - void removeEffect(CEffectXAudio2 *effect); - -}; /* class CSoundDriverXAudio2 */ - -} /* namespace NLSOUND */ - -#endif /* #ifndef NLSOUND_SOUND_DRIVER_XAUDIO2_H */ - -/* end of file */ diff --git a/code/nel/src/sound/driver/xaudio2/source_xaudio2.cpp b/code/nel/src/sound/driver/xaudio2/source_xaudio2.cpp deleted file mode 100644 index 26566612c..000000000 --- a/code/nel/src/sound/driver/xaudio2/source_xaudio2.cpp +++ /dev/null @@ -1,1167 +0,0 @@ -// NeL - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as -// published by the Free Software Foundation, either version 3 of the -// License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -// curve cone eax time - -#include "stdxaudio2.h" - -// Project includes -#include "sound_driver_xaudio2.h" -#include "buffer_xaudio2.h" -#include "listener_xaudio2.h" -#include "adpcm_xaudio2.h" -#include "effect_xaudio2.h" -#include "source_xaudio2.h" - -#ifdef DEBUG_NEW -#define new DEBUG_NEW -#endif - -using namespace std; -using namespace NLMISC; - -namespace NLSOUND { - -CSourceXAudio2::CSourceXAudio2(CSoundDriverXAudio2 *soundDriver) -: _SoundDriver(soundDriver), _SourceVoice(NULL), _StaticBuffer(NULL), _LastPreparedBuffer(NULL), _OperationSet(soundDriver->getUniqueOperationSet()), -_Format(IBuffer::FormatUnknown), _Frequency(0), _PlayStart(0), -_Doppler(1.0f), _Pos(0.0f, 0.0f, 0.0f), _Relative(false), _Alpha(1.0), -_DirectDryVoice(NULL), _DirectFilterVoice(NULL), _EffectDryVoice(NULL), _EffectFilterVoice(NULL), -_DirectDryEnabled(false), _DirectFilterEnabled(false), _EffectDryEnabled(false), _EffectFilterEnabled(false), -_DirectGain(NLSOUND_DEFAULT_DIRECT_GAIN), _EffectGain(NLSOUND_DEFAULT_EFFECT_GAIN), -_DirectFilterPassGain(NLSOUND_DEFAULT_FILTER_PASS_GAIN), _EffectFilterPassGain(NLSOUND_DEFAULT_FILTER_PASS_GAIN), -_DirectFilterLowFrequency(NLSOUND_DEFAULT_FILTER_PASS_LF), _DirectFilterHighFrequency(NLSOUND_DEFAULT_FILTER_PASS_HF), -_EffectFilterLowFrequency(NLSOUND_DEFAULT_FILTER_PASS_LF), _EffectFilterHighFrequency(NLSOUND_DEFAULT_FILTER_PASS_HF), -_IsPlaying(false), _IsPaused(false), _IsLooping(false), _Pitch(1.0f), -_Gain(1.0f), _MinDistance(1.0f), _MaxDistance(sqrt(numeric_limits::max())), -_AdpcmUtility(NULL), _Channels(0), _BitsPerSample(0), _BufferStreaming(false) -{ - // nlwarning(NLSOUND_XAUDIO2_PREFIX "Inititializing CSourceXAudio2"); - nlassert(_SoundDriver->getListener()); - - memset(&_Emitter, 0, sizeof(_Emitter)); - memset(&_Cone, 0, sizeof(_Cone)); - memset(&_DirectFilter, 0, sizeof(_DirectFilter)); - memset(&_EffectFilter, 0, sizeof(_EffectFilter)); - - _Cone.InnerAngle = X3DAUDIO_2PI; - _Cone.OuterAngle = X3DAUDIO_2PI; - _Cone.InnerVolume = 1.0f; - _Cone.OuterVolume = 0.0f; - _Cone.InnerLPF = 1.0f; - _Cone.OuterLPF = 0.0f; - _Cone.InnerReverb = 1.0f; - _Cone.OuterReverb = 0.0f; - - _Emitter.OrientFront.x = 0.0f; - _Emitter.OrientFront.y = 0.0f; - _Emitter.OrientFront.z = 1.0f; - _Emitter.OrientTop.x = 0.0f; - _Emitter.OrientTop.y = 1.0f; - _Emitter.OrientTop.z = 0.0f; - _Emitter.Position.x = 0.0f; - _Emitter.Position.y = 0.0f; - _Emitter.Position.z = 0.0f; - _Emitter.Velocity.x = 0.0f; - _Emitter.Velocity.y = 0.0f; - _Emitter.Velocity.z = 0.0f; - _Emitter.ChannelCount = 1; - _Emitter.InnerRadius = 0.0f; - _Emitter.InnerRadiusAngle = 0.0f; - _Emitter.ChannelRadius = 0.0f; - _Emitter.CurveDistanceScaler = 1.0f; - _Emitter.DopplerScaler = 1.0f; - - _DirectFilter.Frequency = 1.0f; - _DirectFilter.OneOverQ = 1.0f; - _DirectFilter.Type = LowPassFilter; - - _EffectFilter.Frequency = 1.0f; - _EffectFilter.OneOverQ = 1.0f; - _EffectFilter.Type = LowPassFilter; - - _DirectDryVoice = _SoundDriver->getListener()->getDryVoice(); - _DirectDryEnabled = true; - _DirectFilterVoice = _SoundDriver->getListener()->getFilterVoice(); - _DirectFilterEnabled = false; -} - -CSourceXAudio2::~CSourceXAudio2() -{ - // nlwarning(NLSOUND_XAUDIO2_PREFIX "Destroying CSourceXAudio2"); - CSoundDriverXAudio2 *soundDriver = _SoundDriver; - release(); - if (soundDriver) soundDriver->removeSource(this); -} - -void CSourceXAudio2::release() // called by driver or destructor, whichever is first -{ - if (_AdpcmUtility) { _AdpcmUtility->flushSourceBuffers(); } - if (_SoundDriver) - { - _SoundDriver->getXAudio2()->CommitChanges(_OperationSet); - if (_SourceVoice) { _SoundDriver->destroySourceVoice(_SourceVoice); _SourceVoice = NULL; } - } - if (_AdpcmUtility) { delete _AdpcmUtility; _AdpcmUtility = NULL; } - stop(); - _SoundDriver = NULL; -} - -/// Commit all the changes made to 3D settings of listener and sources -void CSourceXAudio2::commit3DChanges() -{ - nlassert(_SourceVoice); - - // Only mono buffers get 3d sound, multi-channel buffers go directly to the speakers without any distance rolloff. - if (_Channels > 1) - { - // _SoundDriver->getDSPSettings()->DstChannelCount = 1; - // _Emitter.pVolumeCurve = NULL; // todo: everything - // calculate without doppler - // 1 result in matrix, use with setvolume - // todo: some more stuff... - // this isn't really used anyways - _SourceVoice->SetFrequencyRatio(_Pitch, _OperationSet); - // nlerror(NLSOUND_XAUDIO2_PREFIX "Stereo16 and Stereo8 not fully implemented, have fun! :)"); - } - else - { - XAUDIO2_VOICE_DETAILS voiceDetails; - _SoundDriver->getMasteringVoice()->GetVoiceDetails(&voiceDetails); - - FLOAT32 matrixCoefficients[32 * 32]; // technical limit is 32 speakers - X3DAUDIO_DSP_SETTINGS dspSettings = { 0 }; - dspSettings.pMatrixCoefficients = matrixCoefficients; - dspSettings.SrcChannelCount = 1; - dspSettings.DstChannelCount = voiceDetails.InputChannels; - // // nldebug(NLSOUND_XAUDIO2_PREFIX "_SampleVoice->getBuffer() %u", (uint32)_SampleVoice->getBuffer()); - - _Emitter.DopplerScaler = _SoundDriver->getListener()->getDopplerScaler(); - - X3DAUDIO_DISTANCE_CURVE_POINT curve_points[2]; - X3DAUDIO_DISTANCE_CURVE curve = { (X3DAUDIO_DISTANCE_CURVE_POINT *)&curve_points[0], 2 }; - - if (_SoundDriver->getOption(ISoundDriver::OptionManualRolloff)) - { - float sqrdist = _Relative - ? getPos().sqrnorm() - : (getPos() - _SoundDriver->getListener()->getPos()).sqrnorm(); - float rolloff = ISource::computeManualRolloff(_Alpha, sqrdist, _MinDistance, _MaxDistance); - curve_points[0].Distance = 0.f; - curve_points[0].DSPSetting = rolloff; - curve_points[1].Distance = 1.f; - curve_points[1].DSPSetting = rolloff; - _Emitter.pVolumeCurve = &curve; - _Emitter.pLFECurve = &curve; - } - else - { - // divide min distance (distance from where to start attenuation) with rolloff scaler (factor to get faster attenuation) - _Emitter.CurveDistanceScaler = _MinDistance / _SoundDriver->getListener()->getRolloffScaler(); - // _MaxDistance not implemented (basically should cut off sound beyond maxdistance) - } - - X3DAudioCalculate(_SoundDriver->getX3DAudio(), - _Relative - ? _SoundDriver->getEmptyListener() // position is relative to listener (we use 0pos listener) - : _SoundDriver->getListener()->getListener(), // position is absolute - &_Emitter, - X3DAUDIO_CALCULATE_MATRIX | X3DAUDIO_CALCULATE_DOPPLER, - &dspSettings); - - FLOAT32 outputMatrix[32 * 32]; - - if (_DirectDryEnabled) - { - float directDryGain = _DirectFilterEnabled - ? _DirectFilterPassGain * _DirectGain - : _DirectGain; - for (uint32 i = 0; i < dspSettings.DstChannelCount; ++i) - outputMatrix[i] = matrixCoefficients[i] * directDryGain; - _SourceVoice->SetOutputMatrix(_DirectDryVoice, 1, dspSettings.DstChannelCount, outputMatrix, _OperationSet); - if (_DirectFilterEnabled) - { - float directFilterGain = _DirectGain - directDryGain; - for (uint32 i = 0; i < dspSettings.DstChannelCount; ++i) - outputMatrix[i] = matrixCoefficients[i] * directFilterGain; - _SourceVoice->SetOutputMatrix(_DirectFilterVoice, 1, dspSettings.DstChannelCount, outputMatrix, _OperationSet); - } - } - - if (_EffectDryEnabled) - { - float monoRolloff = 0.0f; - for (uint32 i = 0; i < dspSettings.DstChannelCount; ++i) - monoRolloff += matrixCoefficients[i]; - monoRolloff /= (float)dspSettings.DstChannelCount; - - float effectDryGain = _EffectFilterEnabled - ? _EffectFilterPassGain * _EffectGain - : _EffectGain; - float outputSingle = monoRolloff * effectDryGain; - _SourceVoice->SetOutputMatrix(_EffectDryVoice, 1, 1, &outputSingle, _OperationSet); - if (_EffectFilterEnabled) - { - float effectFilterGain = _EffectGain - effectDryGain; - outputSingle = monoRolloff * effectFilterGain; - _SourceVoice->SetOutputMatrix(_EffectFilterVoice, 1, 1, &outputSingle, _OperationSet); - } - } - - // nldebug(NLSOUND_XAUDIO2_PREFIX "left: %f, right %f", _SoundDriver->getDSPSettings()->pMatrixCoefficients[0], _SoundDriver->getDSPSettings()->pMatrixCoefficients[1]); - _Doppler = dspSettings.DopplerFactor; - _SourceVoice->SetFrequencyRatio(_Pitch * _Doppler); - } - _SoundDriver->getXAudio2()->CommitChanges(_OperationSet); - // todo: delay? -} - -void CSourceXAudio2::update3DChanges() -{ - if (_IsPlaying) - { - commit3DChanges(); - } -} - -void CSourceXAudio2::updateState() -{ - if (_IsPlaying) - { - if (_AdpcmUtility) - { - if (!_AdpcmUtility->getSourceData()) - { - _SoundDriver->getXAudio2()->CommitChanges(_OperationSet); - if (!_BufferStreaming) - { - // nldebug(NLSOUND_XAUDIO2_PREFIX "Stop"); - if (FAILED(_SourceVoice->Stop(0))) - nlwarning(NLSOUND_XAUDIO2_PREFIX "FAILED Stop"); - _IsPlaying = false; - } - } - } - else - { - XAUDIO2_VOICE_STATE voice_state; - _SourceVoice->GetState(&voice_state); - if (!voice_state.BuffersQueued) - { - _SoundDriver->getXAudio2()->CommitChanges(_OperationSet); - if (!_BufferStreaming) - { - // nldebug(NLSOUND_XAUDIO2_PREFIX "Stop"); - if (FAILED(_SourceVoice->Stop(0))) - nlwarning(NLSOUND_XAUDIO2_PREFIX "FAILED Stop"); - _IsPlaying = false; - } - } - } - } -} - -/// (Internal) Submit a buffer to the XAudio2 source voice. -void CSourceXAudio2::submitBuffer(CBufferXAudio2 *ibuffer) -{ - // nldebug(NLSOUND_XAUDIO2_PREFIX "submitBuffer %u", (uint32)(void *)this); - - nlassert(_SourceVoice); - nlassert(ibuffer->getFormat() == _Format - && ibuffer->getChannels() == _Channels - && ibuffer->getBitsPerSample() == _BitsPerSample); - if (_AdpcmUtility) - { - nlassert(!_BufferStreaming); - _AdpcmUtility->submitSourceBuffer(ibuffer); - } - else - { - XAUDIO2_BUFFER buffer; - buffer.AudioBytes = ibuffer->getSize(); - buffer.Flags = (_IsLooping || _BufferStreaming) ? 0 : XAUDIO2_END_OF_STREAM; - buffer.LoopBegin = 0; - buffer.LoopCount = (_IsLooping && !_BufferStreaming) ? XAUDIO2_LOOP_INFINITE : 0; - buffer.LoopLength = 0; - buffer.pAudioData = const_cast(ibuffer->getData()); - buffer.pContext = ibuffer; - buffer.PlayBegin = 0; - buffer.PlayLength = 0; - - _SourceVoice->SubmitSourceBuffer(&buffer); - } -} - -/// (Internal) Update the send descriptor -void CSourceXAudio2::setupVoiceSends() -{ - XAUDIO2_SEND_DESCRIPTOR sendDescriptors[4]; - XAUDIO2_VOICE_SENDS voiceSends; - voiceSends.pSends = sendDescriptors; - voiceSends.SendCount = 0; - - if (_DirectDryEnabled) - { - sendDescriptors[0].Flags = 0; - sendDescriptors[0].pOutputVoice = _DirectDryVoice; - if (_DirectFilterEnabled) - { - sendDescriptors[1].Flags = XAUDIO2_SEND_USEFILTER; - sendDescriptors[1].pOutputVoice = _DirectFilterVoice; - voiceSends.SendCount = 2; - } - else voiceSends.SendCount = 1; - } - - if (_EffectDryEnabled) - { - sendDescriptors[voiceSends.SendCount].Flags = 0; - sendDescriptors[voiceSends.SendCount].pOutputVoice = _EffectDryVoice; - ++voiceSends.SendCount; - if (_EffectFilterEnabled) - { - sendDescriptors[voiceSends.SendCount].Flags = XAUDIO2_SEND_USEFILTER; - sendDescriptors[voiceSends.SendCount].pOutputVoice = _EffectFilterVoice; - ++voiceSends.SendCount; - } - } - - _SoundDriver->getXAudio2()->CommitChanges(_OperationSet); // SetOutputVoices does not support OperationSet - _SourceVoice->SetOutputVoices(&voiceSends); // SetOutputVoices does not support OperationSet - setupDirectFilter(); - setupEffectFilter(); - _SoundDriver->getXAudio2()->CommitChanges(_OperationSet); // SetOutputVoices does not support OperationSet -} - -/// Enable or disable streaming mode. Source must be stopped to call this. -void CSourceXAudio2::setStreaming(bool streaming) -{ - nlassert(!_IsPlaying); - - // nldebug(NLSOUND_XAUDIO2_PREFIX "setStreaming %i", (uint32)streaming); - - if (_SourceVoice) - { - XAUDIO2_VOICE_STATE voice_state; - _SourceVoice->GetState(&voice_state); - if (!voice_state.BuffersQueued) - { - nlwarning(NLSOUND_XAUDIO2_PREFIX "Switched streaming mode while buffer still queued!?! Flush"); - _SoundDriver->getXAudio2()->CommitChanges(_OperationSet); - if (FAILED(_SourceVoice->FlushSourceBuffers())) - nlwarning(NLSOUND_XAUDIO2_PREFIX "FAILED FlushSourceBuffers"); - } - } - - _BufferStreaming = streaming; - - // nldebug(NLSOUND_XAUDIO2_PREFIX "setStreaming done %i", (uint32)streaming); -} - -/// Set the buffer that will be played (no streaming) -void CSourceXAudio2::setStaticBuffer(IBuffer *buffer) -{ - nlassert(!_BufferStreaming); - - // nldebug(NLSOUND_XAUDIO2_PREFIX "setStaticBuffer"); - - // if (buffer) // nldebug(NLSOUND_XAUDIO2_PREFIX "setStaticBuffer %s", _SoundDriver->getStringMapper()->unmap(buffer->getName()).c_str()); - // else // nldebug(NLSOUND_XAUDIO2_PREFIX "setStaticBuffer NULL"); - - // if (_IsPlaying) nlwarning(NLSOUND_XAUDIO2_PREFIX "Called setStaticBuffer(IBuffer *buffer) while _IsPlaying == true!"); - - _StaticBuffer = static_cast(buffer); -} - -/// Return the buffer, or NULL if streaming is used. -IBuffer *CSourceXAudio2::getStaticBuffer() -{ - nlassert(!_BufferStreaming); // can be implemented trough voice_state.pCurrentBufferContext - - return _StaticBuffer; -} - -/// Add a buffer to the streaming queue. A buffer of 100ms length is optimal for streaming. -/// Should be called by a thread which checks countStreamingBuffers every 100ms. -void CSourceXAudio2::submitStreamingBuffer(IBuffer *buffer) -{ - // nldebug(NLSOUND_XAUDIO2_PREFIX "submitStreamingBuffer"); - - nlassert(_BufferStreaming); - - // allow to change the format if not playing - if (!_IsPlaying) - { - IBuffer::TBufferFormat bufferFormat; - uint8 channels; - uint8 bitsPerSample; - uint32 frequency; - buffer->getFormat(bufferFormat, channels, bitsPerSample, frequency); - preparePlay(bufferFormat, channels, bitsPerSample, frequency); - _LastPreparedBuffer = NULL; - } - - submitBuffer(static_cast(buffer)); -} - -/// Return the amount of buffers in the queue (playing and waiting). 3 buffers is optimal. -uint CSourceXAudio2::countStreamingBuffers() const -{ - nlassert(_BufferStreaming); - - if (_SourceVoice) - { - XAUDIO2_VOICE_STATE voice_state; - _SourceVoice->GetState(&voice_state); - return voice_state.BuffersQueued; - } - else - { - return 0; - } -} - -/// Set looping on/off for future playbacks (default: off) -void CSourceXAudio2::setLooping(bool l) -{ - // nldebug(NLSOUND_XAUDIO2_PREFIX "setLooping %u", (uint32)l); - - nlassert(!_BufferStreaming); - - if (_IsLooping != l) - { - _IsLooping = l; - if (_AdpcmUtility) - { - _AdpcmUtility->setLooping(l); - } - else - { - if (_SourceVoice) - { - if (_IsPlaying) - { - if (l) - { - // loop requested while already playing, flush any trash - if (FAILED(_SourceVoice->FlushSourceBuffers())) - nlwarning(NLSOUND_XAUDIO2_PREFIX "FAILED FlushSourceBuffers"); - // resubmit with updated looping settings - if (_LastPreparedBuffer == _StaticBuffer) - submitBuffer(_StaticBuffer); - } - else - { - // flush any queued buffers, keep playing current buffer - if (FAILED(_SourceVoice->FlushSourceBuffers())) - nlwarning(NLSOUND_XAUDIO2_PREFIX "FAILED FlushSourceBuffers"); - // exit loop of current buffer - if (FAILED(_SourceVoice->ExitLoop())) - nlwarning(NLSOUND_XAUDIO2_PREFIX "FAILED ExitLoop"); - } - } - else - { - // not playing but buffer already queued - XAUDIO2_VOICE_STATE voice_state; - _SourceVoice->GetState(&voice_state); - if (voice_state.BuffersQueued) - { - nlwarning(NLSOUND_XAUDIO2_PREFIX "Not playing but buffer already queued while switching loop mode!?! Flush and requeue"); - if (FAILED(_SourceVoice->FlushSourceBuffers())) - nlwarning(NLSOUND_XAUDIO2_PREFIX "FAILED FlushSourceBuffers"); - // queue buffer with correct looping parameters - if (_LastPreparedBuffer == _StaticBuffer) - submitBuffer(_StaticBuffer); - } - } - } - } - } -} - -/// Return the looping state -bool CSourceXAudio2::getLooping() const -{ - nlassert(!_BufferStreaming); - - return _IsLooping; -} - -/// (Internal) Initialize voice with this format, if no voice has been created yet. -bool CSourceXAudio2::initFormat(IBuffer::TBufferFormat bufferFormat, uint8 channels, uint8 bitsPerSample) -{ - // nlwarning(NLSOUND_XAUDIO2_PREFIX "New voice with format %u!", (uint32)_StaticBuffer->getFormat()); - - nlassert(!_SourceVoice); nlassert(!_AdpcmUtility); - // create adpcm utility callback if needed - if (bufferFormat == IBuffer::FormatDviAdpcm) _AdpcmUtility = new CAdpcmXAudio2(_IsLooping); - // create voice with adpcm utility callback or NULL callback - _SourceVoice = _SoundDriver->createSourceVoice(bufferFormat, channels, bitsPerSample, _AdpcmUtility); - if (_AdpcmUtility) _AdpcmUtility->setSourceVoice(_SourceVoice); - if (!_SourceVoice) return false; // fail - _Format = bufferFormat; - _Channels = channels; - _BitsPerSample = bitsPerSample; - _SourceVoice->SetVolume(_Gain, _OperationSet); - setupVoiceSends(); - _SoundDriver->getXAudio2()->CommitChanges(_OperationSet); - - // Also commit any 3D settings that were already done - commit3DChanges(); - - // test - //XAUDIO2_VOICE_DETAILS voice_details; - //_SourceVoice->GetVoiceDetails(&voice_details); - //_SendDescriptors[0].Flags = XAUDIO2_SEND_USEFILTER; - //_SourceVoice->SetOutputVoices(&_VoiceSends); - //XAUDIO2_FILTER_PARAMETERS _FilterParameters[2]; - //_FilterParameters[0].Type = LowPassFilter; - //nlinfo("voice_details.InputSampleRate: '%u'", voice_details.InputSampleRate); - //_FilterParameters[0].Frequency = XAudio2CutoffFrequencyToRadians(5000, voice_details.InputSampleRate); - //nlinfo("_FilterParameters[0].Frequency: '%f'", _FilterParameters[0].Frequency); - //_FilterParameters[0].OneOverQ = 1.0f; - //nlinfo("_FilterParameters[0].OneOverQ: '%f'", _FilterParameters[0].OneOverQ); - //_SourceVoice->SetOutputFilterParameters(_SendDescriptors[0].pOutputVoice, &_FilterParameters[0]); - // test - - - return true; -} - -/// (Internal) Prepare to play. Stop the currently playing buffers, and set the correct voice settings. -bool CSourceXAudio2::preparePlay(IBuffer::TBufferFormat bufferFormat, uint8 channels, uint8 bitsPerSample, uint32 frequency) -{ - if (_IsPlaying) - { - // nlwarning(NLSOUND_XAUDIO2_PREFIX "Called play() while _IsPlaying == true!"); - // stop the currently playing voice if it's of the same type as we need - if (bufferFormat == _Format && channels == _Channels && bitsPerSample == _BitsPerSample) - // cannot call stop directly before destroy voice, ms bug in xaudio2, see msdn docs - stop(); // sets _IsPlaying = false; - } - if (_SourceVoice && (bufferFormat != _Format || channels != _Channels || bitsPerSample != _BitsPerSample)) - { - nlwarning(NLSOUND_XAUDIO2_PREFIX "Switching format %u to %u!", (uint32)_Format, (uint32)bufferFormat); - // destroy existing voice - _SoundDriver->getXAudio2()->CommitChanges(_OperationSet); - _SoundDriver->destroySourceVoice(_SourceVoice); _SourceVoice = NULL; - // destroy adpcm utility (if it exists) - delete _AdpcmUtility; _AdpcmUtility = NULL; - // reset current stuff - _Format = IBuffer::FormatNotSet; - _Channels = 0; - _BitsPerSample = 0; - } - if (frequency != _Frequency) - { - if (_SourceVoice) - { - setupDirectFilter(); - setupEffectFilter(); - _SourceVoice->SetSourceSampleRate(frequency); - } - _Frequency = frequency; - } - if (!_SourceVoice) - { - // initialize a source voice with this format - if (!initFormat(bufferFormat, channels, bitsPerSample)) - { - nlwarning(NLSOUND_XAUDIO2_PREFIX "Fail to init voice!"); - return false; - } - _SourceVoice->SetSourceSampleRate(frequency); - if (!_BufferStreaming) - { - // notify other sources about this format, so they can make a voice in advance - // we know that there is a very high chance that all sources use same format - // so this gives better results at runtime (avoids sound clicks etc) - _SoundDriver->initSourcesFormat(_Format, _Channels, _BitsPerSample); - } - } - commit3DChanges(); // sets pitch etc - - // test - //XAUDIO2_VOICE_DETAILS voice_details; - //_SourceVoice->GetVoiceDetails(&voice_details); - //nlinfo("voice_details.InputSampleRate: '%u'", voice_details.InputSampleRate); - // test - - return true; -} - -/// Play the static buffer (or stream in and play). -bool CSourceXAudio2::play() -{ - // nldebug(NLSOUND_XAUDIO2_PREFIX "play"); - - // Commit 3D changes before starting play - if (_SourceVoice) - commit3DChanges(); - // else it is commit by the preparePlay > initFormat function - - if (_IsPaused) - { - if (SUCCEEDED(_SourceVoice->Start(0))) _IsPaused = false; - else nlwarning(NLSOUND_XAUDIO2_PREFIX "FAILED Play"); - return !_IsPaused; - } - else - { - _SoundDriver->performanceIncreaseSourcePlayCounter(); - - if (_BufferStreaming) - { - // preparePlay already called, - // stop already called before going into buffer streaming - nlassert(!_IsPlaying); - nlassert(_SourceVoice); - _PlayStart = CTime::getLocalTime(); - if (SUCCEEDED(_SourceVoice->Start(0))) _IsPlaying = true; - else nlwarning(NLSOUND_XAUDIO2_PREFIX "FAILED Play (_BufferStreaming)"); - } - else - { - if (_StaticBuffer) - { - preparePlay(_StaticBuffer->getFormat(), - _StaticBuffer->getChannels(), - _StaticBuffer->getBitsPerSample(), - _StaticBuffer->getFrequency()); - _LastPreparedBuffer = _StaticBuffer; - submitBuffer(_StaticBuffer); - _PlayStart = CTime::getLocalTime(); - if (SUCCEEDED(_SourceVoice->Start(0))) _IsPlaying = true; - else nlwarning(NLSOUND_XAUDIO2_PREFIX "FAILED Play"); - } - else - { - stop(); - } - } - return _IsPlaying; - } -} - -/// Stop playing -void CSourceXAudio2::stop() -{ - // nldebug(NLSOUND_XAUDIO2_PREFIX "stop"); - - _IsPlaying = false; - _IsPaused = false; - if (_SourceVoice) - { - // stop adpcm stream - if (_AdpcmUtility) _AdpcmUtility->flushSourceBuffers(); - - // stop source voice and remove pending buffers - _SoundDriver->getXAudio2()->CommitChanges(_OperationSet); - if (FAILED(_SourceVoice->ExitLoop())) - nlwarning(NLSOUND_XAUDIO2_PREFIX "FAILED ExitLoop"); - if (FAILED(_SourceVoice->Stop(0))) - nlwarning(NLSOUND_XAUDIO2_PREFIX "FAILED Stop"); - if (FAILED(_SourceVoice->FlushSourceBuffers())) - nlwarning(NLSOUND_XAUDIO2_PREFIX "FAILED FlushSourceBuffers"); - } -} - -/// Pause. Call play() to resume. -void CSourceXAudio2::pause() -{ - // nldebug(NLSOUND_XAUDIO2_PREFIX "pause"); - - if (_IsPaused) nlwarning(NLSOUND_XAUDIO2_PREFIX "Called pause() while _IsPaused == true!"); - - if (_IsPlaying) - { - _IsPaused = true; - if (FAILED(_SourceVoice->Stop(0))) - nlwarning(NLSOUND_XAUDIO2_PREFIX "FAILED Stop"); - } - else nlwarning(NLSOUND_XAUDIO2_PREFIX "Called pause() while _IsPlaying == false!"); -} - -/// Return true if play() or pause(), false if stop(). -bool CSourceXAudio2::isPlaying() const -{ - // nlinfo(NLSOUND_XAUDIO2_PREFIX "isPlaying?"); - - return _IsPlaying; -} - -/// Return true if playing is finished or stop() has been called. -bool CSourceXAudio2::isStopped() const -{ - // nldebug(NLSOUND_XAUDIO2_PREFIX "isStopped?"); - - return !_IsPlaying; -} - -/// Return the paused state -bool CSourceXAudio2::isPaused() const -{ - // nldebug(NLSOUND_XAUDIO2_PREFIX "isStopped?"); - - return _IsPaused; -} - -/// Returns the number of milliseconds the source has been playing -uint32 CSourceXAudio2::getTime() -{ - // nldebug(NLSOUND_XAUDIO2_PREFIX "getTime"); - - // ----------------------------- todo - - return _IsPlaying ? (uint32)(CTime::getLocalTime() - _PlayStart) : 0; -} - -/// Set the position vector (default: (0,0,0)). -void CSourceXAudio2::setPos(const NLMISC::CVector& pos, bool /* deffered */) // note: deferred with a different spelling -{ - // nldebug(NLSOUND_XAUDIO2_PREFIX "setPos %f %f %f", pos.x, pos.y, pos.z); - - _Pos = pos; - NLSOUND_XAUDIO2_X3DAUDIO_VECTOR_FROM_VECTOR(_Emitter.Position, pos); - - // !! todo if threaded: if (!deffered) { /* nlwarning(NLSOUND_XAUDIO2_PREFIX "!deffered"); */ commit3DChanges(); } -} - -/// Get the position vector. -const NLMISC::CVector &CSourceXAudio2::getPos() const -{ - return _Pos; -} - -/// Set the velocity vector (3D mode only, ignored in stereo mode) (default: (0,0,0)) -void CSourceXAudio2::setVelocity(const NLMISC::CVector& vel, bool /* deferred */) -{ - // nldebug(NLSOUND_XAUDIO2_PREFIX "setVelocity %f %f %f", vel.x, vel.y, vel.z); - - NLSOUND_XAUDIO2_X3DAUDIO_VECTOR_FROM_VECTOR(_Emitter.Velocity, vel); - - // !! todo if threaded: if (!deferred) { /* nlwarning(NLSOUND_XAUDIO2_PREFIX "!deferred"); */ commit3DChanges(); } -} - -/// Get the velocity vector -void CSourceXAudio2::getVelocity(NLMISC::CVector& vel) const -{ - NLSOUND_XAUDIO2_VECTOR_FROM_X3DAUDIO_VECTOR(vel, _Emitter.Velocity); -} - -/// Set the direction vector (3D mode only, ignored in stereo mode) (default: (0,0,0) as non-directional) -void CSourceXAudio2::setDirection(const NLMISC::CVector& dir) -{ - // nldebug(NLSOUND_XAUDIO2_PREFIX "setDirection %f %f %f", dir.x, dir.y, dir.z); - - NLSOUND_XAUDIO2_X3DAUDIO_VECTOR_FROM_VECTOR(_Emitter.OrientFront, dir); -} - -/// Get the direction vector -void CSourceXAudio2::getDirection(NLMISC::CVector& dir) const -{ - NLSOUND_XAUDIO2_VECTOR_FROM_X3DAUDIO_VECTOR(dir, _Emitter.OrientFront); -} - -/// Set the gain (volume value inside [0 , 1]). (default: 1) -void CSourceXAudio2::setGain(float gain) -{ - // nldebug(NLSOUND_XAUDIO2_PREFIX "setGain %f", gain); - - _Gain = std::min(std::max(gain, NLSOUND_MIN_GAIN), NLSOUND_MAX_GAIN); - if (_SourceVoice) _SourceVoice->SetVolume(_Gain, _OperationSet); -} - -/// Get the gain -float CSourceXAudio2::getGain() const -{ - return _Gain; -} - -/// Shift the frequency. -void CSourceXAudio2::setPitch(float pitch) -{ - // nldebug(NLSOUND_XAUDIO2_PREFIX "setPitch %f", pitch); - - _Pitch = std::min(std::max(pitch, NLSOUND_MIN_PITCH), NLSOUND_MAX_PITCH); - if (_SourceVoice) - { - if (_Channels > 1) _SourceVoice->SetFrequencyRatio(_Pitch, _OperationSet); - else _SourceVoice->SetFrequencyRatio(_Pitch * _Doppler, _OperationSet); - } -} - -/// Get the pitch -float CSourceXAudio2::getPitch() const -{ - return _Pitch; -} - -/// Set the source relative mode. If true, positions are interpreted relative to the listener position -void CSourceXAudio2::setSourceRelativeMode(bool mode) -{ - // nldebug(NLSOUND_XAUDIO2_PREFIX "setSourceRelativeMode %u", (uint32)mode); - - _Relative = mode; -} - -/// Get the source relative mode -bool CSourceXAudio2::getSourceRelativeMode() const -{ - return _Relative; -} - -/// Set the min and max distances (default: 1, MAX_FLOAT) (3D mode only) -void CSourceXAudio2::setMinMaxDistances(float mindist, float maxdist, bool /* deferred */) -{ - // nldebug(NLSOUND_XAUDIO2_PREFIX "setMinMaxDistances %f, %f", mindist, maxdist); - - static float maxSqrt = sqrt(std::numeric_limits::max()); - if (maxdist >= maxSqrt) - { - nlwarning("SOUND_DEV (XAudio2): Ridiculously high max distance set on source"); - maxdist = maxSqrt; - } - - _Emitter.InnerRadius = mindist; - _MinDistance = mindist; - _MaxDistance = maxdist; -} - -/// Get the min and max distances -void CSourceXAudio2::getMinMaxDistances(float& mindist, float& maxdist) const -{ - mindist = _MinDistance; - maxdist = _MaxDistance; -} - -/// Set the cone angles (in radian) and gain (in [0 , 1]) (default: 2PI, 2PI, 0) -void CSourceXAudio2::setCone(float innerAngle, float outerAngle, float outerGain) -{ - // nldebug(NLSOUND_XAUDIO2_PREFIX "setCone %f, %f ,%f", innerAngle, outerAngle, outerGain); - - if (innerAngle >= 6.283185f && outerAngle >= 6.283185f) - _Emitter.pCone = NULL; - else _Emitter.pCone = &_Cone; - if (innerAngle > outerAngle) - { - nlwarning(NLSOUND_XAUDIO2_PREFIX "innerAngle > outerAngle"); - innerAngle = outerAngle; - } - _Cone.InnerAngle = innerAngle; - _Cone.OuterAngle = outerAngle; - _Cone.OuterVolume = outerGain; -} - -/// Get the cone angles (in radian) -void CSourceXAudio2::getCone(float& innerAngle, float& outerAngle, float& outerGain) const -{ - innerAngle = _Cone.InnerAngle; - outerAngle = _Cone.OuterAngle; - outerGain = _Cone.OuterVolume; -} - -/// Set the alpha value for the volume-distance curve -void CSourceXAudio2::setAlpha(double a) -{ - nlassert(_SoundDriver->getOption(ISoundDriver::OptionManualRolloff)); - - // if (a != 1.0) // nldebug(NLSOUND_XAUDIO2_PREFIX "setAlpha %f", (float)a); - _Alpha = a; -} - -/// Enable or disable direct output [true/false], default: true -void CSourceXAudio2::setDirect(bool enable) -{ - if (_DirectDryEnabled != enable) - { - _DirectDryEnabled = enable; - if (_SourceVoice) setupVoiceSends(); - } -} - -/// Return if the direct output is enabled -bool CSourceXAudio2::getDirect() const -{ - return _DirectDryEnabled; -} - -/// Set the gain for the direct path -void CSourceXAudio2::setDirectGain(float gain) -{ - _DirectGain = min(max(gain, NLSOUND_MIN_GAIN), NLSOUND_MAX_GAIN); -} - -/// Get the gain for the direct path -float CSourceXAudio2::getDirectGain() const -{ - return _DirectGain; -} - -/// Enable or disable the filter for the direct channel -void CSourceXAudio2::enableDirectFilter(bool enable) -{ - if (_DirectFilterEnabled != enable) - { - _DirectFilterEnabled = enable; - if (_SourceVoice) setupVoiceSends(); - } -} - -/// Check if the filter on the direct channel is enabled -bool CSourceXAudio2::isDirectFilterEnabled() const -{ - return _DirectFilterEnabled; -} - -/// (Internal) Setup the direct send filter. -void CSourceXAudio2::setupDirectFilter() -{ - // todo: this sort of works and sounds sort of similar to the openal way, but still needs work - if (_DirectDryEnabled && _DirectFilterEnabled) - { - switch (_DirectFilter.Type) - { - case LowPassFilter: - _DirectFilter.Frequency = XAudio2CutoffFrequencyToRadians(_DirectFilterHighFrequency / 10.0f, _Frequency); - _DirectFilter.OneOverQ = 1.0f; - break; - case BandPassFilter: - _DirectFilter.Frequency = XAudio2CutoffFrequencyToRadians(((_DirectFilterLowFrequency * 10.0f) + (_DirectFilterHighFrequency / 10.0f)) / 2.0f, _Frequency); - _DirectFilter.OneOverQ = 1.5f; // todo: calculate OneOverQ from range between low and high frequency - break; - case HighPassFilter: - _DirectFilter.Frequency = XAudio2CutoffFrequencyToRadians(_DirectFilterLowFrequency * 10.0f, _Frequency); - _DirectFilter.OneOverQ = 1.0f; - break; - default: - _DirectFilter.Type = (XAUDIO2_FILTER_TYPE)~0; - break; - } - _SourceVoice->SetOutputFilterParameters(_DirectFilterVoice, &_DirectFilter, _OperationSet); - } -} - -/// Set the filter parameters for the direct channel -void CSourceXAudio2::setDirectFilter(TFilter filterType, float lowFrequency, float highFrequency, float passGain) -{ - switch (filterType) - { - case ISource::FilterLowPass: - _DirectFilter.Type = LowPassFilter; - break; - case ISource::FilterBandPass: - _DirectFilter.Type = BandPassFilter; - break; - case ISource::FilterHighPass: - _DirectFilter.Type = HighPassFilter; - break; - default: - _DirectFilter.Type = (XAUDIO2_FILTER_TYPE)~0; - break; - } - _DirectFilterLowFrequency = lowFrequency; - _DirectFilterHighFrequency = highFrequency; - _DirectFilterPassGain = passGain; - if (_SourceVoice) setupDirectFilter(); -} - -/// Get the filter parameters for the direct channel -void CSourceXAudio2::getDirectFilter(TFilter &filterType, float &lowFrequency, float &highFrequency, float &passGain) const -{ - switch (_DirectFilter.Type) - { - case LowPassFilter: - filterType = ISource::FilterLowPass; - break; - case BandPassFilter: - filterType = ISource::FilterBandPass; - break; - case HighPassFilter: - filterType = ISource::FilterHighPass; - break; - default: - filterType = (TFilter)~0; - break; - } - lowFrequency = _DirectFilterLowFrequency; - highFrequency = _DirectFilterHighFrequency; - passGain = _DirectFilterPassGain; -} - -/// Set the direct filter gain -void CSourceXAudio2::setDirectFilterPassGain(float passGain) -{ - _DirectFilterPassGain = min(max(passGain, NLSOUND_MIN_GAIN), NLSOUND_MAX_GAIN); -} - -/// Get the direct filter gain -float CSourceXAudio2::getDirectFilterPassGain() const -{ - return _DirectFilterPassGain; -} - -/// Set the effect send for this source, NULL to disable. [IEffect], default: NULL -void CSourceXAudio2::setEffect(CEffectXAudio2 *effect) -{ - // if (_Effect != effect) - { - if (effect) - { - _EffectDryEnabled = true; - _EffectDryVoice = effect->getDryVoice(); - _EffectFilterVoice = effect->getFilterVoice(); - } - else - { - _EffectDryEnabled = false; - _EffectDryVoice = NULL; - _EffectFilterVoice = NULL; - } - if (_SourceVoice) setupVoiceSends(); - } -} - -/// Set the effect send for this source, NULL to disable. -void CSourceXAudio2::setEffect(IReverbEffect *reverbEffect) -{ - setEffect(reverbEffect ? static_cast(static_cast(reverbEffect)) : NULL); -} - -/// Get the effect send for this source -IEffect *CSourceXAudio2::getEffect() const -{ - return NULL; -} - -/// Set the gain for the direct path -void CSourceXAudio2::setEffectGain(float gain) -{ - _EffectGain = min(max(gain, NLSOUND_MIN_GAIN), NLSOUND_MAX_GAIN); -} - -/// Get the gain for the direct path -float CSourceXAudio2::getEffectGain() const -{ - return _EffectGain; -} - -/// Enable or disable the filter for the effect channel -void CSourceXAudio2::enableEffectFilter(bool enable) -{ - if (_EffectFilterEnabled != enable) - { - _EffectFilterEnabled = enable; - if (_SourceVoice) setupVoiceSends(); - } -} - -/// Check if the filter on the effect channel is enabled -bool CSourceXAudio2::isEffectFilterEnabled() const -{ - return _EffectFilterEnabled; -} - -/// (Internal) Setup the direct send filter. -void CSourceXAudio2::setupEffectFilter() -{ - // todo: this sort of works and sounds sort of similar to the openal way, but still needs work - if (_EffectDryEnabled && _EffectFilterEnabled) - { - switch (_EffectFilter.Type) - { - case LowPassFilter: - _EffectFilter.Frequency = XAudio2CutoffFrequencyToRadians(_EffectFilterHighFrequency / 10.0f, _Frequency); - _EffectFilter.OneOverQ = 1.0f; - break; - case BandPassFilter: - _EffectFilter.Frequency = XAudio2CutoffFrequencyToRadians(((_EffectFilterLowFrequency * 10.0f) + (_EffectFilterHighFrequency / 10.0f)) / 2.0f, _Frequency); - _EffectFilter.OneOverQ = 1.5f; // todo: calculate OneOverQ from range between low and high frequency - break; - case HighPassFilter: - _EffectFilter.Frequency = XAudio2CutoffFrequencyToRadians(_EffectFilterLowFrequency * 10.0f, _Frequency); - _EffectFilter.OneOverQ = 1.0f; - default: - _EffectFilter.Type = (XAUDIO2_FILTER_TYPE)~0; - break; - } - _SourceVoice->SetOutputFilterParameters(_EffectFilterVoice, &_EffectFilter, _OperationSet); - } -} - -/// Set the filter parameters for the direct channel -void CSourceXAudio2::setEffectFilter(TFilter filterType, float lowFrequency, float highFrequency, float passGain) -{ - switch (filterType) - { - case ISource::FilterLowPass: - _EffectFilter.Type = LowPassFilter; - break; - case ISource::FilterBandPass: - _EffectFilter.Type = BandPassFilter; - break; - case ISource::FilterHighPass: - _EffectFilter.Type = HighPassFilter; - break; - default: - _EffectFilter.Type = (XAUDIO2_FILTER_TYPE)~0; - break; - } - _EffectFilterLowFrequency = lowFrequency; - _EffectFilterHighFrequency = highFrequency; - _EffectFilterPassGain = passGain; - if (_SourceVoice) setupEffectFilter(); -} - -/// Get the filter parameters for the direct channel -void CSourceXAudio2::getEffectFilter(TFilter &filterType, float &lowFrequency, float &highFrequency, float &passGain) const -{ - switch (_EffectFilter.Type) - { - case LowPassFilter: - filterType = ISource::FilterLowPass; - break; - case BandPassFilter: - filterType = ISource::FilterBandPass; - break; - case HighPassFilter: - filterType = ISource::FilterHighPass; - break; - default: - filterType = (TFilter)~0; - break; - } - lowFrequency = _EffectFilterLowFrequency; - highFrequency = _EffectFilterHighFrequency; - passGain = _EffectFilterPassGain; -} - -/// Set the effect filter gain -void CSourceXAudio2::setEffectFilterPassGain(float passGain) -{ - _EffectFilterPassGain = min(max(passGain, NLSOUND_MIN_GAIN), NLSOUND_MAX_GAIN); -} - -/// Get the effect filter gain -float CSourceXAudio2::getEffectFilterPassGain() const -{ - return _EffectFilterPassGain; -} - -} /* namespace NLSOUND */ - -/* end of file */ diff --git a/code/nel/src/sound/driver/xaudio2/source_xaudio2.h b/code/nel/src/sound/driver/xaudio2/source_xaudio2.h deleted file mode 100644 index 4e50774b2..000000000 --- a/code/nel/src/sound/driver/xaudio2/source_xaudio2.h +++ /dev/null @@ -1,305 +0,0 @@ -// NeL - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as -// published by the Free Software Foundation, either version 3 of the -// License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -#ifndef NLSOUND_SOURCE_XAUDIO2_H -#define NLSOUND_SOURCE_XAUDIO2_H - -#include "nel/sound/driver/source.h" -#include "nel/sound/driver/sound_driver.h" -#include "nel/sound/driver/buffer.h" - -namespace NLSOUND { - class CSoundDriverXAudio2; - class CBufferXAudio2; - class CAdpcmXAudio2; - class CEffectXAudio2; - -/** - * \brief CSourceXAudio2 - * \date 2008-08-20 15:53GMT - * \author Jan Boon (Kaetemi) - * CSourceXAudio2 is an implementation of the ISource interface to run on XAudio2. - */ -class CSourceXAudio2 : public ISource -{ -private: - // -- outside pointers -- - /// The sound driver, cannot change at runtime. - CSoundDriverXAudio2 *_SoundDriver; - /// Buffer that should be playing. - CBufferXAudio2 *_StaticBuffer; - /// Last buffer that was prepared for playing. - CBufferXAudio2 *_LastPreparedBuffer; - - // -- Pointers -- - /// Source voice, can be NULL! - IXAudio2SourceVoice *_SourceVoice; - /// Adpcm helper, can be NULL! - CAdpcmXAudio2 *_AdpcmUtility; - - // -- System vars 2d -- - /// Unique operation set - uint32 _OperationSet; - /// Format of the current source voice. - IBuffer::TBufferFormat _Format; - /// Number of channels in the current format - uint8 _Channels; - /// Bits per sample in the current format - uint8 _BitsPerSample; - /// Frequency of the current sample format - uint32 _Frequency; - /// Time when source started playing. - NLMISC::TTime _PlayStart; - /// Buffer loading system - bool _BufferStreaming; - - // -- System vars 3d -- - float _Doppler; - - // -- User vars 3d -- - X3DAUDIO_EMITTER _Emitter; - X3DAUDIO_CONE _Cone; - /// Minimum distance of sound at max volume. - float _MinDistance; - /// Maximum distance of sound. - float _MaxDistance; - /// Position of the source. - NLMISC::CVector _Pos; - /// Source relative to listener position (listener + source = actual source location). - bool _Relative; - /// Alpha for manual rolloff. - double _Alpha; - - // -- Output path vars -- - /// Voices - IXAudio2Voice *_DirectDryVoice, *_DirectFilterVoice, *_EffectDryVoice, *_EffectFilterVoice; - /// Path enabled settings - bool _DirectDryEnabled, _DirectFilterEnabled, _EffectDryEnabled, _EffectFilterEnabled; - /// Gain settings - float _DirectGain, _EffectGain; - float _DirectFilterPassGain, _EffectFilterPassGain; - /// Filter cutoff frequencies - float _DirectFilterLowFrequency, _DirectFilterHighFrequency; - /// Filter cutoff frequencies - float _EffectFilterLowFrequency, _EffectFilterHighFrequency; - /// Filter settings - XAUDIO2_FILTER_PARAMETERS _DirectFilter, _EffectFilter; - - // -- User vars 2d -- - /// True if play() or pause(), false if stop(). - bool _IsPlaying; - /// True if pause(), false if play() or stop(). - bool _IsPaused; - /// True if setLooping(true). - bool _IsLooping; - /// Pitch set by user. - float _Pitch; - /// Volume set by user. - float _Gain; - - // -- Combined vars -- - // _FreqRatio = (float)_StaticBuffer->getFreq() / _FreqVoice; - // 3D PITCH = (_FreqRatio * _Pitch * _Doppler) - // 2D PITCH = (_FreqRatio * _Pitch) -public: - // Internal functions - CSourceXAudio2(CSoundDriverXAudio2 *soundDriver); - virtual ~CSourceXAudio2(); - void release(); - - void commit3DChanges(); - void update3DChanges(); - void updateState(); - - /// (Internal) Initialize voice with this format, if no voice has been created yet. - bool initFormat(IBuffer::TBufferFormat bufferFormat, uint8 channels, uint8 bitsPerSample); - /// (Internal) Returns the XAudio2 source voice. - inline IXAudio2SourceVoice * getSourceVoice() { return _SourceVoice; } - /// (Internal) Submit a buffer to the XAudio2 source voice. - void submitBuffer(CBufferXAudio2 *ibuffer); - /// (Internal) Prepare to play. Stop the currently playing buffers, and set the correct voice settings. - bool preparePlay(IBuffer::TBufferFormat bufferFormat, uint8 channels, uint8 bitsPerSample, uint32 frequency); - /// (Internal) Set the effect send for this source, NULL to disable. - void setEffect(CEffectXAudio2 *effect); - /// (Internal) Update the send descriptor - void setupVoiceSends(); - /// (Internal) Setup the direct send filter. - void setupDirectFilter(); - /// (Internal) Setup the effect send filter. - void setupEffectFilter(); - - /// \name Initialization - //@{ - /// Enable or disable streaming mode. Source must be stopped to call this. - virtual void setStreaming(bool streaming); - /** Set the buffer that will be played (no streaming) - * If the buffer is stereo, the source mode becomes stereo and the source relative mode is on, - * otherwise the source is considered as a 3D source. Use submitStreamingBuffer for streaming. - */ - virtual void setStaticBuffer(IBuffer *buffer); - /// Return the buffer, or NULL if streaming is used. Not available for streaming. - virtual IBuffer *getStaticBuffer(); - /// Add a buffer to the streaming queue. A buffer of 100ms length is optimal for streaming. - /// Should be called by a thread which checks countStreamingBuffers every 100ms. - virtual void submitStreamingBuffer(IBuffer *buffer); - /// Return the amount of buffers in the queue (playing and waiting). 3 buffers is optimal. - virtual uint countStreamingBuffers() const; - //@} - - /// \name Playback control - //@{ - /// Set looping on/off for future playbacks (default: off), not available for streaming - virtual void setLooping(bool l); - /// Return the looping state - virtual bool getLooping() const; - - /** Play the static buffer (or stream in and play). - * This method can return false if the sample for this sound is unloaded. - */ - virtual bool play(); - /// Stop playing - virtual void stop(); - /// Pause. Call play() to resume. - virtual void pause(); - /// Return true if play() or pause(), false if stop(). - virtual bool isPlaying() const; - /// Return true if playing is finished or stop() has been called. - virtual bool isStopped() const; - /// Return true if the playing source is paused - virtual bool isPaused() const; - /// Returns the number of milliseconds the source has been playing - virtual uint32 getTime(); - //@} - - /// \name Source properties - //@{ - /** Set the position vector (default: (0,0,0)). - * 3D mode -> 3D position - * st mode -> x is the pan value (from left (-1) to right (1)), set y and z to 0 - */ - virtual void setPos(const NLMISC::CVector& pos, bool deffered = true); - /** Get the position vector. - * See setPos() for details. - */ - virtual const NLMISC::CVector &getPos() const; - /// Set the velocity vector (3D mode only, ignored in stereo mode) (default: (0,0,0)) - virtual void setVelocity(const NLMISC::CVector& vel, bool deferred = true); - /// Get the velocity vector - virtual void getVelocity(NLMISC::CVector& vel) const; - /// Set the direction vector (3D mode only, ignored in stereo mode) (default: (0,0,0) as non-directional) - virtual void setDirection(const NLMISC::CVector& dir); - /// Get the direction vector - virtual void getDirection(NLMISC::CVector& dir) const; - /** Set the gain (volume value inside [0 , 1]). (default: 1) - * 0.0 -> silence - * 0.5 -> -6dB - * 1.0 -> no attenuation - * values > 1 (amplification) not supported by most drivers - */ - virtual void setGain(float gain); - /// Get the gain - virtual float getGain() const; - /** Shift the frequency. 1.0f equals identity, each reduction of 50% equals a pitch shift - * of one octave. 0 is not a legal value. - */ - virtual void setPitch(float pitch); - /// Get the pitch - virtual float getPitch() const; - /// Set the source relative mode. If true, positions are interpreted relative to the listener position - virtual void setSourceRelativeMode(bool mode); - /// Get the source relative mode - virtual bool getSourceRelativeMode() const; - /// Set the min and max distances (default: 1, MAX_FLOAT) (3D mode only) - virtual void setMinMaxDistances(float mindist, float maxdist, bool deferred = true); - /// Get the min and max distances - virtual void getMinMaxDistances(float& mindist, float& maxdist) const; - /// Set the cone angles (in radian) and gain (in [0 , 1]) (default: 2PI, 2PI, 0) - virtual void setCone(float innerAngle, float outerAngle, float outerGain); - /// Get the cone angles (in radian) - virtual void getCone(float& innerAngle, float& outerAngle, float& outerGain) const; - /** Set the alpha value for the volume-distance curve - * - * Useful only with OptionManualRolloff. value from -1 to 1 (default 0) - * - * alpha.0: the volume will decrease linearly between 0dB and -100 dB - * alpha = 1.0: the volume will decrease linearly between 1.0 and 0.0 (linear scale) - * alpha = -1.0: the volume will decrease inversely with the distance (1/dist). This - * is the default used by DirectSound/OpenAL - * - * For any other value of alpha, an interpolation is be done between the two - * adjacent curves. For example, if alpha equals 0.5, the volume will be halfway between - * the linear dB curve and the linear amplitude curve. - */ - virtual void setAlpha(double a); - //@} - - /// \name Direct output - //@{ - /// Enable or disable direct output [true/false], default: true - virtual void setDirect(bool enable = true); - /// Return if the direct output is enabled - virtual bool getDirect() const; - /// Set the gain for the direct path - virtual void setDirectGain(float gain); - /// Get the gain for the direct path - virtual float getDirectGain() const; - - /// Enable or disable the filter for the direct channel - virtual void enableDirectFilter(bool enable = true); - /// Check if the filter on the direct channel is enabled - virtual bool isDirectFilterEnabled() const; - /// Set the filter parameters for the direct channel - virtual void setDirectFilter(TFilter filter, float lowFrequency, float highFrequency, float passGain); - /// Get the filter parameters for the direct channel - virtual void getDirectFilter(TFilter &filterType, float &lowFrequency, float &highFrequency, float &passGain) const; - /// Set the direct filter gain - virtual void setDirectFilterPassGain(float passGain); - /// Get the direct filter gain - virtual float getDirectFilterPassGain() const; - //@} - - /// \name Effect output - //@{ - /// Set the effect send for this source, NULL to disable. [IEffect], default: NULL - virtual void setEffect(IReverbEffect *reverbEffect); - /// Get the effect send for this source - virtual IEffect *getEffect() const; - /// Set the gain for the effect path - virtual void setEffectGain(float gain); - /// Get the gain for the effect path - virtual float getEffectGain() const; - - /// Enable or disable the filter for the effect channel - virtual void enableEffectFilter(bool enable = true); - /// Check if the filter on the effect channel is enabled - virtual bool isEffectFilterEnabled() const; - /// Set the filter parameters for the effect channel - virtual void setEffectFilter(TFilter filter, float lowFrequency, float highFrequency, float passGain); - /// Get the filter parameters for the effect channel - virtual void getEffectFilter(TFilter &filterType, float &lowFrequency, float &highFrequency, float &passGain) const; - /// Set the effect filter gain - virtual void setEffectFilterPassGain(float passGain); - /// Get the effect filter gain - virtual float getEffectFilterPassGain() const; - //@} - -}; /* class CSourceXAudio2 */ - -} /* namespace NLSOUND */ - -#endif /* #ifndef NLSOUND_SOURCE_XAUDIO2_H */ - -/* end of file */ diff --git a/code/nel/src/sound/driver/xaudio2/stdxaudio2.cpp b/code/nel/src/sound/driver/xaudio2/stdxaudio2.cpp deleted file mode 100644 index 61c258c63..000000000 --- a/code/nel/src/sound/driver/xaudio2/stdxaudio2.cpp +++ /dev/null @@ -1,17 +0,0 @@ -// NeL - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as -// published by the Free Software Foundation, either version 3 of the -// License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -#include "stdxaudio2.h" diff --git a/code/nel/src/sound/driver/xaudio2/stdxaudio2.h b/code/nel/src/sound/driver/xaudio2/stdxaudio2.h deleted file mode 100644 index f6e55d0aa..000000000 --- a/code/nel/src/sound/driver/xaudio2/stdxaudio2.h +++ /dev/null @@ -1,126 +0,0 @@ -// NeL - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as -// published by the Free Software Foundation, either version 3 of the -// License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -#ifndef NLSOUND_STDPCH_XAUDIO2_H -#define NLSOUND_STDPCH_XAUDIO2_H - -#if defined(_MSC_VER) && defined(_DEBUG) - #define _CRTDBG_MAP_ALLOC - #include - #include - #define DEBUG_NEW new(_NORMAL_BLOCK, __FILE__, __LINE__) -#endif - -// STL includes -#include -#include -#include -#include -#include -#include - -#include "nel/misc/types_nl.h" - -// 3rd Party Includes -#include -#define XAUDIO2_HELPER_FUNCTIONS - -#ifdef NL_COMP_MINGW -#define __in_bcount(x) -#define __in_bcount_opt(x) -#define __in_ecount(x) -#define __in_xcount(x) -#define __inout_bcount_full(x) -#define __inout_bcount_opt(x) -#define __out_bcount(x) -#define __out_bcount_full(x) -#define __out_bcount_opt(x) -#define __out_bcount_part_opt(x,y) -#define __out_ecount(x) -#define __out_xcount(x) -#define __deref_opt_inout_bcount_part_opt(x,y) -#define __deref_out_bcount(x) -#define __deref_out_bcount_opt(x) -#define __out -#define __in -#define __inout -#define __deref_out -#define __in_opt -#define __inout_opt -#define __out_opt -#define __deref -#define __deref_inout_opt -#define __reserved -#define __XMA2DEFS_INCLUDED__ -#endif /* NL_COMP_MINGW */ - -#include - -#ifdef NL_COMP_MINGW -#undef DEFINE_CLSID -#undef DEFINE_IID -#undef DECLSPEC_UUID_WRAPPER -#define DEFINE_CLSID(className, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) \ - class className; \ - __CRT_UUID_DECL(className, 0x##l, 0x##w1, 0x##w2, 0x##b1, 0x##b2, 0x##b3, 0x##b4, 0x##b5, 0x##b6, 0x##b7, 0x##b8) \ - EXTERN_C const GUID CLSID_##className -#define DEFINE_IID(interfaceName, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) \ - interface interfaceName; \ - __CRT_UUID_DECL(interfaceName, 0x##l, 0x##w1, 0x##w2, 0x##b1, 0x##b2, 0x##b3, 0x##b4, 0x##b5, 0x##b6, 0x##b7, 0x##b8) \ - EXTERN_C const GUID IID_##interfaceName -#endif /* NL_COMP_MINGW */ - -#include -#include -#include - -// NeL includes -#include "nel/misc/singleton.h" -#include "nel/misc/common.h" -#include "nel/misc/big_file.h" -#include "nel/misc/command.h" -#include "nel/misc/debug.h" -#include "nel/misc/dynloadlib.h" -#include "nel/misc/fast_mem.h" -#include "nel/misc/file.h" -#include "nel/misc/hierarchical_timer.h" -#include "nel/misc/log.h" -#include "nel/misc/matrix.h" -#include "nel/misc/mem_stream.h" -#include "nel/misc/mutex.h" -#include "nel/misc/path.h" -#include "nel/misc/stream.h" -#include "nel/misc/time_nl.h" -#include "nel/misc/variable.h" -#include "nel/misc/vector.h" - -#include "nel/sound/driver/buffer.h" -#include "nel/sound/driver/effect.h" -#include "nel/sound/driver/listener.h" -#include "nel/sound/driver/sound_driver.h" -#include "nel/sound/driver/source.h" - -// Defines -#define NLSOUND_XAUDIO2_NAME "NeLSound XAudio2 Driver" -// prefix for warnings and debug messages -#define NLSOUND_XAUDIO2_PREFIX "XA2: " -// swap y and z -#define NLSOUND_XAUDIO2_X3DAUDIO_VECTOR_FROM_VECTOR(to, from) (to).x = (from).x; (to).y = (from).z; (to).z = (from).y; -#define NLSOUND_XAUDIO2_VECTOR_FROM_X3DAUDIO_VECTOR(to, from) (to).x = (from).x; (to).y = (from).z; (to).z = (from).y; - -#endif /* #ifndef NLSOUND_STDPCH_XAUDIO2_H */ - -/* end of file */ diff --git a/code/nel/src/sound/simple_source.cpp b/code/nel/src/sound/simple_source.cpp index 9b9ee5950..5d3bbd14f 100644 --- a/code/nel/src/sound/simple_source.cpp +++ b/code/nel/src/sound/simple_source.cpp @@ -29,9 +29,9 @@ using namespace NLMISC; namespace NLSOUND { CSimpleSource::CSimpleSource(CSimpleSound *simpleSound, bool spawn, TSpawnEndCallback cb, void *cbUserParam, NL3D::CCluster *cluster, CGroupController *groupController) - : CSourceCommon(simpleSound, spawn, cb, cbUserParam, cluster, groupController), + : CSourceCommon(simpleSound, spawn, cb, cbUserParam, cluster, groupController), _SimpleSound(simpleSound), - _Track(NULL), + _Track(NULL), _PlayMuted(false), _WaitingForPlay(false) { @@ -139,7 +139,7 @@ void CSimpleSource::play() { if (_SpawnEndCb != 0) _SpawnEndCb(this, _CbUserParam); - + delete this; } // nldebug("CSimpleSource %p : play FAILED !", (CAudioMixerUser::IMixerEvent*)this); @@ -159,7 +159,7 @@ void CSimpleSource::play() // ok, we have a track to realy play, fill the data into the track pSource->setStaticBuffer(_SimpleSound->getBuffer()); - + // pSource->setPos( _Position, false); pSource->setPos(getVirtualPos(), false); if (!_SimpleSound->getBuffer()->isStereo()) @@ -173,9 +173,9 @@ void CSimpleSource::play() pSource->setLooping(_Looping); pSource->setPitch(_Pitch); pSource->setAlpha(_Alpha); - + // and play the sound - bool play = pSource->play(); + bool play = pSource->play(); #ifdef NL_DEBUG nlassert(play); @@ -214,13 +214,13 @@ void CSimpleSource::onEvent() // A muted play is terminated. if (!_Playing) - return; + return; // nlassert(_Playing); // nlassert(_Track == 0); _PlayMuted = false; CAudioMixerUser::instance()->decPlayingSourceMuted(); - + stop(); } @@ -251,7 +251,7 @@ void CSimpleSource::stop() mixer->decPlayingSourceMuted(); mixer->removeEvents(this); } - + CSourceCommon::stop(); if (_Spawn) @@ -314,7 +314,7 @@ void CSimpleSource::setDirection(const NLMISC::CVector& dir) if (dir.isNull()) // workaround { getPhysicalSource()->setCone(float(Pi * 2), float(Pi * 2), 1.0f); // because the direction with 0 is not enough for a non-directional source! - getPhysicalSource()->setDirection(CVector::I); // Don't send a 0 vector, DSound will complain. Send (1,0,0), it's omnidirectional anyway. + getPhysicalSource()->setDirection(CVector::I); // Don't send a 0 vector, Send (1,0,0), it's omnidirectional anyway. coneset = false; } else diff --git a/code/nel/src/sound/stream_source.cpp b/code/nel/src/sound/stream_source.cpp index 9bd48ff25..b65df63e2 100644 --- a/code/nel/src/sound/stream_source.cpp +++ b/code/nel/src/sound/stream_source.cpp @@ -31,10 +31,10 @@ using namespace NLMISC; namespace NLSOUND { CStreamSource::CStreamSource(CStreamSound *streamSound, bool spawn, TSpawnEndCallback cb, void *cbUserParam, NL3D::CCluster *cluster, CGroupController *groupController) - : CSourceCommon(streamSound, spawn, cb, cbUserParam, cluster, groupController), - m_StreamSound(streamSound), - m_Alpha(0.0f), - m_Track(NULL), + : CSourceCommon(streamSound, spawn, cb, cbUserParam, cluster, groupController), + m_StreamSound(streamSound), + m_Alpha(0.0f), + m_Track(NULL), m_FreeBuffers(3), m_NextBuffer(0), m_LastSize(0), @@ -47,7 +47,7 @@ CStreamSource::CStreamSource(CStreamSound *streamSound, bool spawn, TSpawnEndCal // get a local copy of the stream sound parameter m_Alpha = m_StreamSound->getAlpha();//m_Buffers m_PitchInv = 1.0f / _Pitch; - + // create the three buffer objects CAudioMixerUser *mixer = CAudioMixerUser::instance(); ISoundDriver *driver = mixer->getSoundDriver(); @@ -100,7 +100,7 @@ void CStreamSource::releasePhysicalSource() uint32 CStreamSource::getTime() { CAutoMutex autoMutex(m_BufferMutex); - + if (hasPhysicalSource()) return getPhysicalSource()->getTime(); else @@ -148,10 +148,10 @@ void CStreamSource::play() nlassert(!_Playing); bool play = false; CAudioMixerUser *mixer = CAudioMixerUser::instance(); - + { CAutoMutex autoMutex(m_BufferMutex); - + //if ((mixer->getListenPosVector() - _Position).sqrnorm() > m_StreamSound->getMaxDistance() * m_StreamSound->getMaxDistance()) if ((_RelativeMode ? getPos().sqrnorm() : (mixer->getListenPosVector() - getPos()).sqrnorm()) > m_StreamSound->getMaxDistance() * m_StreamSound->getMaxDistance()) { @@ -168,7 +168,7 @@ void CStreamSource::play() #endif return; } - + CAudioMixerUser *mixer = CAudioMixerUser::instance(); if (!hasPhysicalSource()) @@ -178,12 +178,12 @@ void CStreamSource::play() { ISource *pSource = getPhysicalSource(); nlassert(pSource != NULL); - + uint nbS = m_NextBuffer; if (!m_NextBuffer && !m_FreeBuffers) nbS = 3; for (uint i = 0; i < nbS; ++i) pSource->submitStreamingBuffer(m_Buffers[i]); - + // pSource->setPos( _Position, false); pSource->setPos(getVirtualPos(), false); pSource->setMinMaxDistances(m_StreamSound->getMinDistance(), m_StreamSound->getMaxDistance(), false); @@ -203,7 +203,7 @@ void CStreamSource::play() // pSource->setLooping(_Looping); pSource->setPitch(_Pitch); pSource->setAlpha(m_Alpha); - + // and play the sound nlassert(nbS); // must have buffered already! play = pSource->play(); @@ -225,13 +225,13 @@ void CStreamSource::play() if (_Spawn) { if (_SpawnEndCb != NULL) - _SpawnEndCb(this, _CbUserParam); + _SpawnEndCb(this, _CbUserParam); delete this; } return; } } - + if (play) { CSourceCommon::play(); @@ -278,7 +278,7 @@ void CStreamSource::play() void CStreamSource::stopInt() { CAutoMutex autoMutex(m_BufferMutex); - + // nldebug("CStreamSource %p : stop", (CAudioMixerUser::IMixerEvent*)this); // nlassert(_Playing); @@ -288,21 +288,21 @@ void CStreamSource::stopInt() CAudioMixerUser *mixer = CAudioMixerUser::instance(); mixer->removeSourceWaitingForPlay(this); } - + if (!_Playing) { m_WaitingForPlay = false; return; } - + if (hasPhysicalSource()) releasePhysicalSource(); - + CSourceCommon::stop(); m_FreeBuffers = 3; m_NextBuffer = 0; - + m_WaitingForPlay = false; } @@ -310,7 +310,7 @@ void CStreamSource::stopInt() void CStreamSource::stop() { stopInt(); - + if (_Spawn) { if (_SpawnEndCb != NULL) @@ -355,7 +355,7 @@ void CStreamSource::setDirection(const NLMISC::CVector& dir) if (dir.isNull()) // workaround // For what? { getPhysicalSource()->setCone(float(Pi * 2), float(Pi * 2), 1.0f); // because the direction with 0 is not enough for a non-directional source! - getPhysicalSource()->setDirection(CVector::I); // Don't send a 0 vector, DSound will complain. Send (1,0,0), it's omnidirectional anyway. + getPhysicalSource()->setDirection(CVector::I); // Don't send a 0 vector, Send (1,0,0), it's omnidirectional anyway. coneset = false; } else @@ -374,7 +374,7 @@ void CStreamSource::setDirection(const NLMISC::CVector& dir) void CStreamSource::updateFinalGain() { CAutoMutex autoMutex(m_BufferMutex); - + if (hasPhysicalSource()) getPhysicalSource()->setGain(getFinalGain()); } @@ -439,7 +439,7 @@ uint8 *CStreamSource::lock(uint capacity) bool CStreamSource::unlock(uint size) { nlassert(m_FreeBuffers > 0); - + CAutoMutex autoMutex(m_BufferMutex); IBuffer *buffer = m_Buffers[m_NextBuffer]; bool result = buffer->unlock(size); diff --git a/code/nel/tools/3d/crash_log_analyser/main.cpp b/code/nel/tools/3d/crash_log_analyser/main.cpp index 96e28bc45..2474050aa 100644 --- a/code/nel/tools/3d/crash_log_analyser/main.cpp +++ b/code/nel/tools/3d/crash_log_analyser/main.cpp @@ -55,7 +55,7 @@ void filterRyzomBug(const char *dirSrc, const char *dirDst, uint patchVersionWan uint numPatchVersion= 0; bool precUserId= false; bool ok= true; - bool filterFound= false; + bool filterFound= false; while(!f.eof()) { char tmp[1000]; @@ -67,7 +67,7 @@ void filterRyzomBug(const char *dirSrc, const char *dirDst, uint patchVersionWan if(precUserId) { nlwarning("Don't find a PatchVersion for all UserId in %s", fileFullPath.c_str()); - ok= false; + ok= false; break; } else @@ -79,7 +79,7 @@ void filterRyzomBug(const char *dirSrc, const char *dirDst, uint patchVersionWan if(!precUserId) { nlwarning("Don't find a PatchVersion for all UserId in %s", fileFullPath.c_str()); - ok= false; + ok= false; break; } else @@ -124,7 +124,7 @@ void filterRyzomBug(const char *dirSrc, const char *dirDst, uint patchVersionWan string dmpDirSrc= string(dirSrc) + "/" + fileNoExt; CFile::createDirectory(dirDest); - + // copy near the dmp CFile::copyFile(dirDest + "/" + fileNoDir, fileFullPath); @@ -206,7 +206,7 @@ void statRyzomBug(const char *dirSrc) TStatStrStrMap crashFileToSenderMap; uint totalCrash= 0; uint totalCrashDuplicate= 0; - + // **** parse all files for(uint i=0;ifirst&255; uint mode3d= it->first>>8; - - myinfo("**** %d Crashs for %s / Card %s", it->second.Val, - mode3d==0?"OpenGL":(mode3d==1?"Direct3D":"??? No Driver ???"), + + myinfo("**** %d Crashs for %s / Card %s", it->second.Val, + mode3d==0?"OpenGL":"??? No Driver ???", card3d==0?"NVIDIA":(card3d==1?"RADEON":"Misc")); } // crash by continent @@ -450,7 +448,7 @@ void statRyzomBug(const char *dirSrc) myinfo("**************************"); myinfo("**************************"); myinfo(""); - + // Stats per User myinfo(""); myinfo("**** Detailed Crashs per user:"); @@ -471,7 +469,7 @@ void statRyzomBug(const char *dirSrc) } } } - + // Stats per Crash File myinfo(""); myinfo("**** Detailed Crashs per crash Log:"); @@ -503,7 +501,7 @@ void statRyzomBug(const char *dirSrc) } } } - + // RAW userPos myinfo(""); myinfo("**** RAW Crashs Pos (copy in excel, and use insert/chart/(X/Y)Scatter):"); @@ -523,7 +521,7 @@ int main(int argc, char *argv[]) ok= true,statMode= true; if(argc >= 5 && argv[2]==string("-p")) ok= true,filterMode= true; - + if(!ok) { myinfo("Usage1 (stats):\n\t%s src_dir -s\n", CFile::getFilename(argv[0]).c_str()); @@ -536,7 +534,7 @@ int main(int argc, char *argv[]) myinfo("%s is not a directory", argv[1]); return 1; } - + if(filterMode) { string specialFilter; @@ -552,4 +550,3 @@ int main(int argc, char *argv[]) return 0; } - diff --git a/code/nel/tools/3d/ligo/plugin_max/script.cpp b/code/nel/tools/3d/ligo/plugin_max/script.cpp index 7083a22a7..9c801b564 100644 --- a/code/nel/tools/3d/ligo/plugin_max/script.cpp +++ b/code/nel/tools/3d/ligo/plugin_max/script.cpp @@ -126,10 +126,10 @@ CLigoError ScriptErrors[10]; // *************************************************************************** -bool MakeSnapShot (NLMISC::CBitmap &snapshot, const NL3D::CTileBank &tileBank, const NL3D::CTileFarBank &tileFarBank, +bool MakeSnapShot (NLMISC::CBitmap &snapshot, const NL3D::CTileBank &tileBank, const NL3D::CTileFarBank &tileFarBank, sint xmin, sint xmax, sint ymin, sint ymax, const CLigoConfig &config, bool errorInDialog); -bool MakeSnapShot (NLMISC::CBitmap &snapshot, const NL3D::CTileBank &tileBank, const NL3D::CTileFarBank &tileFarBank, +bool MakeSnapShot (NLMISC::CBitmap &snapshot, const NL3D::CTileBank &tileBank, const NL3D::CTileFarBank &tileFarBank, sint xmax, sint ymax, const CLigoConfig &config, bool errorInDialog); // *************************************************************************** @@ -164,7 +164,7 @@ Value* export_material_cf (Value** arg_list, int count) bool errorInDialog = (arg_list[3]->to_bool() != FALSE); // Get a Object pointer - ObjectState os=node->EvalWorldState(ip->GetTime()); + ObjectState os=node->EvalWorldState(ip->GetTime()); // Ok ? if (os.obj) @@ -178,7 +178,7 @@ Value* export_material_cf (Value** arg_list, int count) if (!CMaxToLigo::loadLigoConfigFile (config, *MAXScript_interface, errorInDialog)) { // Output an error - CMaxToLigo::errorMessage ("Error: can't load the config file ligoscape.cfg", "NeL Ligo export material", + CMaxToLigo::errorMessage ("Error: can't load the config file ligoscape.cfg", "NeL Ligo export material", *MAXScript_interface, errorInDialog); } else @@ -275,7 +275,7 @@ Value* export_material_cf (Value** arg_list, int count) else { // Error, zone can't be exported - CMaxToLigo::errorMessage ("Error: can't export the Nel zone, check bind errors.", "NeL Ligo export material", + CMaxToLigo::errorMessage ("Error: can't export the Nel zone, check bind errors.", "NeL Ligo export material", *MAXScript_interface, errorInDialog); } } @@ -287,7 +287,7 @@ Value* export_material_cf (Value** arg_list, int count) else { // Output an error - CMaxToLigo::errorMessage ("Error: can't convert the object in 3ds NeL patch mesh object", + CMaxToLigo::errorMessage ("Error: can't convert the object in 3ds NeL patch mesh object", "NeL Ligo export material", *MAXScript_interface, errorInDialog); } } @@ -349,7 +349,7 @@ Value* export_transition_cf (Value** arg_list, int count) if (!CMaxToLigo::loadLigoConfigFile (config, *MAXScript_interface, errorInDialog)) { // Output an error - CMaxToLigo::errorMessage ("Error: can't load the config file ligoscape.cfg", "NeL Ligo export transition", + CMaxToLigo::errorMessage ("Error: can't load the config file ligoscape.cfg", "NeL Ligo export transition", *MAXScript_interface, errorInDialog); } else @@ -371,9 +371,9 @@ Value* export_transition_cf (Value** arg_list, int count) arrayNode[i] = nodes->get (i+1)->to_node(); // Node builded ? bool builded = false; - + // Get a Object pointer - ObjectState os=arrayNode[i]->EvalWorldState(ip->GetTime()); + ObjectState os=arrayNode[i]->EvalWorldState(ip->GetTime()); // Ok ? if (os.obj) @@ -468,7 +468,7 @@ Value* export_transition_cf (Value** arg_list, int count) if (!arrayTri[zone]->rpatch->exportZone (arrayNode[zone], &arrayTri[zone]->patch, zones[zone], zoneSymmetry, 0, config.CellSize, config.Snap, false)) { // Error, zone can't be exported - CMaxToLigo::errorMessage ("Error: can't export the Nel zone, check bind errors.", "NeL Ligo export material", + CMaxToLigo::errorMessage ("Error: can't export the Nel zone, check bind errors.", "NeL Ligo export material", *MAXScript_interface, errorInDialog); ok = false; } @@ -574,7 +574,7 @@ Value* export_transition_cf (Value** arg_list, int count) else { // Output an error - CMaxToLigo::errorMessage ("Error: must have 9 cell in the node array", "NeL Ligo export transition", + CMaxToLigo::errorMessage ("Error: must have 9 cell in the node array", "NeL Ligo export transition", *MAXScript_interface, errorInDialog); } } @@ -584,7 +584,7 @@ Value* export_transition_cf (Value** arg_list, int count) } // *************************************************************************** - + Value* get_error_zone_template_cf (Value** arg_list, int count) { // Make sure we have the correct number of arguments (4) @@ -641,7 +641,7 @@ Value* get_error_zone_template_cf (Value** arg_list, int count) } // *************************************************************************** - + Value* get_snap_cf (Value** arg_list, int count) { // Make sure we have the correct number of arguments (0) @@ -658,7 +658,7 @@ Value* get_snap_cf (Value** arg_list, int count) } // *************************************************************************** - + Value* get_cell_size_cf (Value** arg_list, int count) { // Make sure we have the correct number of arguments (0) @@ -675,7 +675,7 @@ Value* get_cell_size_cf (Value** arg_list, int count) } // *************************************************************************** - + /// Check a ligo zone with a ligo material Value* check_zone_with_material_cf (Value** arg_list, int count) { @@ -702,7 +702,7 @@ Value* check_zone_with_material_cf (Value** arg_list, int count) bool errorInDialog = (arg_list[2]->to_bool() != FALSE); // Get a Object pointer - ObjectState os=node->EvalWorldState(ip->GetTime()); + ObjectState os=node->EvalWorldState(ip->GetTime()); // Ok ? if (os.obj) @@ -716,7 +716,7 @@ Value* check_zone_with_material_cf (Value** arg_list, int count) if (!CMaxToLigo::loadLigoConfigFile (config, *MAXScript_interface, errorInDialog)) { // Output an error - CMaxToLigo::errorMessage ("Error: can't load the config file ligoscape.cfg", "NeL Ligo check zone", + CMaxToLigo::errorMessage ("Error: can't load the config file ligoscape.cfg", "NeL Ligo check zone", *MAXScript_interface, errorInDialog); } else @@ -791,21 +791,21 @@ Value* check_zone_with_material_cf (Value** arg_list, int count) else { // Output an error - CMaxToLigo::errorMessage ("Error: can't convert the object in 3ds NeL patch mesh object", + CMaxToLigo::errorMessage ("Error: can't convert the object in 3ds NeL patch mesh object", "NeL Ligo check zone", *MAXScript_interface, errorInDialog); } } else { // Output an error - CMaxToLigo::errorMessage ("Error: can't convert the object in 3ds NeL patch mesh object", + CMaxToLigo::errorMessage ("Error: can't convert the object in 3ds NeL patch mesh object", "NeL Ligo check zone", *MAXScript_interface, errorInDialog); } // Return false return &false_value; } - + // *************************************************************************** @@ -839,7 +839,7 @@ Value* check_zone_with_transition_cf (Value** arg_list, int count) bool errorInDialog = (arg_list[3]->to_bool() != FALSE); // Get a Object pointer - ObjectState os=node->EvalWorldState(ip->GetTime()); + ObjectState os=node->EvalWorldState(ip->GetTime()); // Ok ? if (os.obj) @@ -853,7 +853,7 @@ Value* check_zone_with_transition_cf (Value** arg_list, int count) if (!CMaxToLigo::loadLigoConfigFile (config, *MAXScript_interface, errorInDialog)) { // Output an error - CMaxToLigo::errorMessage ("Error: can't load the config file ligoscape.cfg", "NeL Ligo check zone", + CMaxToLigo::errorMessage ("Error: can't load the config file ligoscape.cfg", "NeL Ligo check zone", *MAXScript_interface, errorInDialog); } else @@ -913,14 +913,14 @@ Value* check_zone_with_transition_cf (Value** arg_list, int count) else { // Output an error - CMaxToLigo::errorMessage ("Error: can't convert the object in 3ds NeL patch mesh object", + CMaxToLigo::errorMessage ("Error: can't convert the object in 3ds NeL patch mesh object", "NeL Ligo check zone", *MAXScript_interface, errorInDialog); } } else { // Output an error - CMaxToLigo::errorMessage ("Error: can't convert the object in 3ds NeL patch mesh object", + CMaxToLigo::errorMessage ("Error: can't convert the object in 3ds NeL patch mesh object", "NeL Ligo check zone", *MAXScript_interface, errorInDialog); } @@ -945,7 +945,7 @@ void getSquareMask (CZone &zone, std::vector &mask, uint &width, uint &hei for (i=0; isize != 2) { // Output an error - CMaxToLigo::errorMessage ("Error: category arguments are not 2 strings", "NeL Ligo export zone", + CMaxToLigo::errorMessage ("Error: category arguments are not 2 strings", "NeL Ligo export zone", *MAXScript_interface, errorInDialog); return &false_value; } @@ -1048,7 +1048,7 @@ Value* export_zone_cf (Value** arg_list, int count) } // Get a Object pointer - ObjectState os=node->EvalWorldState(ip->GetTime()); + ObjectState os=node->EvalWorldState(ip->GetTime()); // Ok ? if (os.obj) @@ -1062,7 +1062,7 @@ Value* export_zone_cf (Value** arg_list, int count) if (!CMaxToLigo::loadLigoConfigFile (config, *MAXScript_interface, errorInDialog)) { // Output an error - CMaxToLigo::errorMessage ("Error: can't load the config file ligoscape.cfg", "NeL Ligo export zone", + CMaxToLigo::errorMessage ("Error: can't load the config file ligoscape.cfg", "NeL Ligo export zone", *MAXScript_interface, errorInDialog); } else @@ -1086,7 +1086,7 @@ Value* export_zone_cf (Value** arg_list, int count) if (!tri->rpatch->exportZone (node, &tri->patch, zone, zoneSymmetry, 0, config.CellSize, config.Snap, false)) { // Error, zone can't be exported - CMaxToLigo::errorMessage ("Error: can't export the Nel zone, check bind errors.", "NeL Ligo export zone", + CMaxToLigo::errorMessage ("Error: can't export the Nel zone, check bind errors.", "NeL Ligo export zone", *MAXScript_interface, errorInDialog); } else @@ -1099,7 +1099,7 @@ Value* export_zone_cf (Value** arg_list, int count) // Calc zone mask or force bounding mask ? bool useBoundingBox = CExportNel::getScriptAppData (node, NEL3D_APPDATA_LIGO_USE_BOUNDINGBOX, 0) != 0; bool maskOk = false; - + if (useBoundingBox) { // Get the square zone @@ -1232,8 +1232,8 @@ Value* export_zone_cf (Value** arg_list, int count) uint j; for (j=0; j= mask.size()) { categories.push_back (pair ("filled", "yes")); @@ -1321,14 +1321,14 @@ Value* export_zone_cf (Value** arg_list, int count) else { // Output an error - CMaxToLigo::errorMessage ("Error: can't convert the object in 3ds NeL patch mesh object", + CMaxToLigo::errorMessage ("Error: can't convert the object in 3ds NeL patch mesh object", "NeL Ligo export zone", *MAXScript_interface, errorInDialog); } } else { // Output an error - CMaxToLigo::errorMessage ("Error: can't convert the object in 3ds NeL patch mesh object", + CMaxToLigo::errorMessage ("Error: can't convert the object in 3ds NeL patch mesh object", "NeL Ligo check zone", *MAXScript_interface, errorInDialog); } } @@ -1408,7 +1408,7 @@ Value* get_zone_mask_cf (Value** arg_list, int count) bool errorInDialog = (arg_list[4]->to_bool() != FALSE); // Get a Object pointer - ObjectState os=node->EvalWorldState(ip->GetTime()); + ObjectState os=node->EvalWorldState(ip->GetTime()); // Ok ? if (os.obj) @@ -1422,7 +1422,7 @@ Value* get_zone_mask_cf (Value** arg_list, int count) if (!CMaxToLigo::loadLigoConfigFile (config, *MAXScript_interface, errorInDialog)) { // Output an error - CMaxToLigo::errorMessage ("Error: can't load the config file ligoscape.cfg", "NeL Ligo export zone", + CMaxToLigo::errorMessage ("Error: can't load the config file ligoscape.cfg", "NeL Ligo export zone", *MAXScript_interface, errorInDialog); } else @@ -1433,7 +1433,7 @@ Value* get_zone_mask_cf (Value** arg_list, int count) if (!tri->rpatch->exportZone (node, &tri->patch, zone, zoneSymmetry, 0, config.CellSize, config.Snap, false)) { // Error, zone can't be exported - CMaxToLigo::errorMessage ("Error: can't export the Nel zone, check bind errors.", "NeL Ligo export zone", + CMaxToLigo::errorMessage ("Error: can't export the Nel zone, check bind errors.", "NeL Ligo export zone", *MAXScript_interface, errorInDialog); } else @@ -1518,14 +1518,14 @@ Value* get_zone_mask_cf (Value** arg_list, int count) else { // Output an error - CMaxToLigo::errorMessage ("Error: can't convert the object in 3ds NeL patch mesh object", + CMaxToLigo::errorMessage ("Error: can't convert the object in 3ds NeL patch mesh object", "NeL Ligo export zone", *MAXScript_interface, errorInDialog); } } else { // Output an error - CMaxToLigo::errorMessage ("Error: can't convert the object in 3ds NeL patch mesh object", + CMaxToLigo::errorMessage ("Error: can't convert the object in 3ds NeL patch mesh object", "NeL Ligo check zone", *MAXScript_interface, errorInDialog); } @@ -1572,7 +1572,7 @@ Value* get_zone_size_cf (Value** arg_list, int count) bool errorInDialog = (arg_list[5]->to_bool() != FALSE); // Get a Object pointer - ObjectState os=node->EvalWorldState(ip->GetTime()); + ObjectState os=node->EvalWorldState(ip->GetTime()); // Ok ? if (os.obj) @@ -1586,7 +1586,7 @@ Value* get_zone_size_cf (Value** arg_list, int count) if (!CMaxToLigo::loadLigoConfigFile (config, *MAXScript_interface, errorInDialog)) { // Output an error - CMaxToLigo::errorMessage ("Error: can't load the config file ligoscape.cfg", "NeL Ligo export zone", + CMaxToLigo::errorMessage ("Error: can't load the config file ligoscape.cfg", "NeL Ligo export zone", *MAXScript_interface, errorInDialog); } else @@ -1597,7 +1597,7 @@ Value* get_zone_size_cf (Value** arg_list, int count) if (!tri->rpatch->exportZone (node, &tri->patch, zone, zoneSymmetry, 0, config.CellSize, config.Snap, false)) { // Error, zone can't be exported - CMaxToLigo::errorMessage ("Error: can't export the Nel zone, check bind errors.", "NeL Ligo export zone", + CMaxToLigo::errorMessage ("Error: can't export the Nel zone, check bind errors.", "NeL Ligo export zone", *MAXScript_interface, errorInDialog); } else @@ -1661,14 +1661,14 @@ Value* get_zone_size_cf (Value** arg_list, int count) else { // Output an error - CMaxToLigo::errorMessage ("Error: can't convert the object in 3ds NeL patch mesh object", + CMaxToLigo::errorMessage ("Error: can't convert the object in 3ds NeL patch mesh object", "NeL Ligo export zone", *MAXScript_interface, errorInDialog); } } else { // Output an error - CMaxToLigo::errorMessage ("Error: can't convert the object in 3ds NeL patch mesh object", + CMaxToLigo::errorMessage ("Error: can't convert the object in 3ds NeL patch mesh object", "NeL Ligo check zone", *MAXScript_interface, errorInDialog); } @@ -1678,18 +1678,18 @@ Value* get_zone_size_cf (Value** arg_list, int count) // Make a snap shot of a zone -bool MakeSnapShot (NLMISC::CBitmap &snapshot, const NL3D::CTileBank &tileBank, const NL3D::CTileFarBank &tileFarBank, +bool MakeSnapShot (NLMISC::CBitmap &snapshot, const NL3D::CTileBank &tileBank, const NL3D::CTileFarBank &tileFarBank, sint xmax, sint ymax, const CLigoConfig &config, bool errorInDialog) { return MakeSnapShot (snapshot, tileBank, tileFarBank, 0, xmax, 0, ymax, config, errorInDialog); } -bool MakeSnapShot (NLMISC::CBitmap &snapshot, const NL3D::CTileBank &tileBank, const NL3D::CTileFarBank &tileFarBank, +bool MakeSnapShot (NLMISC::CBitmap &snapshot, const NL3D::CTileBank &tileBank, const NL3D::CTileFarBank &tileFarBank, sint xmin, sint xmax, sint ymin, sint ymax, const CLigoConfig &config, bool errorInDialog) { // Result bool result = false; - + try { // Resolution @@ -1704,7 +1704,7 @@ bool MakeSnapShot (NLMISC::CBitmap &snapshot, const NL3D::CTileBank &tileBank, c oversampledWidth = 2048; if (oversampledHeight > 2048) oversampledHeight = 2048; - + // Oversampled size should be < sreen size DEVMODE devMode; devMode.dmSize= sizeof(DEVMODE); @@ -1722,7 +1722,7 @@ bool MakeSnapShot (NLMISC::CBitmap &snapshot, const NL3D::CTileBank &tileBank, c float posY = config.CellSize * (float)ymin; // Use NELU - if (CNELU::init (oversampledWidth, oversampledHeight, CViewport(), 32, true, NULL, false, true)) // FIXME: OpenGL not working correctly, offscreen not available in Direct3D + if (CNELU::init (oversampledWidth, oversampledHeight, CViewport(), 32, true, NULL, false, true)) // FIXME: OpenGL not working correctly { // Setup the camera CNELU::Camera->setTransformMode (ITransformable::DirectMatrix); @@ -1834,7 +1834,7 @@ bool MakeSnapShot (NLMISC::CBitmap &snapshot, const NL3D::CTileBank &tileBank, c // *************************************************************************** - + /// Export a ligo zone Value* make_snapshot_cf (Value** arg_list, int count) { @@ -1871,7 +1871,7 @@ Value* make_snapshot_cf (Value** arg_list, int count) bool errorInDialog = (arg_list[6]->to_bool() != FALSE); // Get a Object pointer - ObjectState os=node->EvalWorldState(ip->GetTime()); + ObjectState os=node->EvalWorldState(ip->GetTime()); // Ok ? if (os.obj) @@ -1885,7 +1885,7 @@ Value* make_snapshot_cf (Value** arg_list, int count) if (!CMaxToLigo::loadLigoConfigFile (config, *MAXScript_interface, errorInDialog)) { // Output an error - CMaxToLigo::errorMessage ("Error: can't load the config file ligoscape.cfg", "NeL Ligo export zone", + CMaxToLigo::errorMessage ("Error: can't load the config file ligoscape.cfg", "NeL Ligo export zone", *MAXScript_interface, errorInDialog); } else @@ -1901,7 +1901,7 @@ Value* make_snapshot_cf (Value** arg_list, int count) if (!tri->rpatch->exportZone (node, &tri->patch, zone, zoneSymmetry, 0, config.CellSize, config.Snap, false)) { // Error, zone can't be exported - CMaxToLigo::errorMessage ("Error: can't export the Nel zone, check bind errors.", "NeL Ligo export zone", + CMaxToLigo::errorMessage ("Error: can't export the Nel zone, check bind errors.", "NeL Ligo export zone", *MAXScript_interface, errorInDialog); } else @@ -1933,7 +1933,7 @@ Value* make_snapshot_cf (Value** arg_list, int count) CMaxToLigo::errorMessage (tmp, "NeL Ligo export zone", *MAXScript_interface, errorInDialog); } } - + if (tileBank != NULL) { CIFile fileFarBank; @@ -1964,7 +1964,7 @@ Value* make_snapshot_cf (Value** arg_list, int count) // Some categories vector > categories; - // Add filled zone + // Add filled zone categories.push_back (pair ("filled", "yes")); // Add the zone categorie @@ -2060,14 +2060,14 @@ Value* make_snapshot_cf (Value** arg_list, int count) else { // Output an error - CMaxToLigo::errorMessage ("Error: can't convert the object in 3ds NeL patch mesh object", + CMaxToLigo::errorMessage ("Error: can't convert the object in 3ds NeL patch mesh object", "NeL Ligo export zone", *MAXScript_interface, errorInDialog); } } else { // Output an error - CMaxToLigo::errorMessage ("Error: can't convert the object in 3ds NeL patch mesh object", + CMaxToLigo::errorMessage ("Error: can't convert the object in 3ds NeL patch mesh object", "NeL Ligo check zone", *MAXScript_interface, errorInDialog); } @@ -2084,4 +2084,3 @@ Value* make_snapshot_cf (Value** arg_list, int count) __declspec( dllexport ) void LibInit() { } // *************************************************************************** - diff --git a/code/nel/tools/3d/object_viewer/object_viewer.cfg b/code/nel/tools/3d/object_viewer/object_viewer.cfg index 25e48d7fc..26c609598 100644 --- a/code/nel/tools/3d/object_viewer/object_viewer.cfg +++ b/code/nel/tools/3d/object_viewer/object_viewer.cfg @@ -1,7 +1,7 @@ // Config file for object_viewer.cfg. This file must be in the same directory than object_viewer.dll // your searhc pathes, (where to find textures, shapes, tiles, zones ...) -search_pathes = +search_pathes = { "w:\database\stuff\fyros\agents\_textures\actors", "w:\database\stuff\tryker\agents\_textures\actors", @@ -78,7 +78,7 @@ scene_light_sun_dir = {1, 0, -1}; // this is optional // scale the played position of all the skeletons by this value (default 1). character_scale_pos= 1; -// "opengl" (default) or "direct3d" +// "opengl" (default) driver = "opengl"; // Fog diff --git a/code/nel/tools/3d/object_viewer/object_viewer.cpp b/code/nel/tools/3d/object_viewer/object_viewer.cpp index f1f663e38..2dd168ed7 100644 --- a/code/nel/tools/3d/object_viewer/object_viewer.cpp +++ b/code/nel/tools/3d/object_viewer/object_viewer.cpp @@ -91,7 +91,7 @@ using namespace NLPACS; - + static std::string SPath; @@ -117,7 +117,7 @@ CSoundContext SoundContext; // // It is very important that this macro appear in each // function, prior to any calls into MFC. This means that -// it must appear as the first statement within the +// it must appear as the first statement within the // function, even before any object variable declarations // as their constructors may generate calls into the MFC // DLL. @@ -156,21 +156,21 @@ bool CObjectViewer::_InstanceRunning = false; class CObjView : public CView { public: - CObjView() + CObjView() { - MainFrame=NULL; + MainFrame=NULL; }; virtual ~CObjView() {} virtual void OnDraw (CDC *) {} - afx_msg BOOL OnEraseBkgnd(CDC* pDC) - { - return FALSE; + afx_msg BOOL OnEraseBkgnd(CDC* pDC) + { + return FALSE; } virtual LRESULT WindowProc(UINT message, WPARAM wParam, LPARAM lParam) { if ((CNELU::Driver) && MainFrame) MainFrame->DriverWindowProc (CNELU::Driver, m_hWnd, message, wParam, lParam); - + return CView::WindowProc(message, wParam, lParam); } DECLARE_DYNCREATE(CObjView) @@ -206,9 +206,9 @@ CObjectViewer::CObjectViewer () AFX_MANAGE_STATE(AfxGetStaticModuleState()); _SceneRoot= NULL; - + init3d (); - + // vl: is it really useful? i moved it from ov.exe init CScene::registerBasics (); @@ -258,7 +258,6 @@ CObjectViewer::CObjectViewer () _CharacterScalePos= 1; _CurrentCamera = -1; - _Direct3d = false; _Fog = false; _FogStart = 0; _FogEnd = 1; @@ -297,7 +296,6 @@ void CObjectViewer::loadDriverName() CConfigFile cf; cf.load (getModulePath()); CConfigFile::CVar *var = cf.getVarPtr("driver"); - _Direct3d = var && (var->asString() == "direct3d"); } // *************************************************************************** @@ -309,7 +307,7 @@ void CObjectViewer::loadConfigFile() // Load the config file CConfigFile cf; cf.load (getModulePath()); - + try { // Add search pathes @@ -347,7 +345,7 @@ void CObjectViewer::loadConfigFile() catch (const EUnknownVar &) { } - + // debug, display path //CPath::display(); @@ -460,7 +458,7 @@ void CObjectViewer::loadConfigFile() } catch (const EUnknownVar &) { - } + } // Load vegetable Landscape cfg. loadVegetableLandscapeCfg(cf); @@ -471,7 +469,7 @@ void CObjectViewer::loadConfigFile() CConfigFile::CVar &var = cf.getVar("automatic_animation_path"); CUniquePtr as(new CAnimationSet); // - bool loadingOk = as->loadFromFiles(var.asString(),true ,"anim",true); + bool loadingOk = as->loadFromFiles(var.asString(),true ,"anim",true); // if (!loadingOk) { @@ -494,7 +492,7 @@ void CObjectViewer::loadConfigFile() } catch (const EUnknownVar &) { - } + } // Fog CConfigFile::CVar *var = cf.getVarPtr("fog"); @@ -553,20 +551,20 @@ static void removeWindow(CWnd *wnd) CObjectViewer::~CObjectViewer () { AFX_MANAGE_STATE(AfxGetStaticModuleState()); - removeWindow(_MainFrame); - removeWindow(_SlotDlg); - removeWindow(_AnimationSetDlg); - removeWindow(_AnimationDlg); - removeWindow(_DayNightDlg); - removeWindow(_WaterPoolDlg); - removeWindow(_SoundAnimDlg); - removeWindow(_LightGroupDlg); - removeWindow(_ChooseBGColorDlg); - removeWindow(_VegetableDlg); - removeWindow(_GlobalWindDlg); - removeWindow(_SkeletonScaleDlg); - removeWindow(_TuneMRMDlg); - delete _FontGenerator; + removeWindow(_MainFrame); + removeWindow(_SlotDlg); + removeWindow(_AnimationSetDlg); + removeWindow(_AnimationDlg); + removeWindow(_DayNightDlg); + removeWindow(_WaterPoolDlg); + removeWindow(_SoundAnimDlg); + removeWindow(_LightGroupDlg); + removeWindow(_ChooseBGColorDlg); + removeWindow(_VegetableDlg); + removeWindow(_GlobalWindDlg); + removeWindow(_SkeletonScaleDlg); + removeWindow(_TuneMRMDlg); + delete _FontGenerator; } // *************************************************************************** @@ -594,12 +592,12 @@ void CObjectViewer::initCamera () namespace NL3D { CFontGenerator *newCFontGenerator(const std::string &fontFileName); } - + // *************************************************************************** bool CObjectViewer::initUI (HWND parent) { - AFX_MANAGE_STATE(AfxGetStaticModuleState()); + AFX_MANAGE_STATE(AfxGetStaticModuleState()); // initialize NeL context if needed if (!NLMISC::INelContext::isContextInitialised()) @@ -616,7 +614,7 @@ bool CObjectViewer::initUI (HWND parent) uint dSize = ::GetWindowsDirectory(NULL, 0); nlverify(dSize); - TCHAR *wd = new TCHAR[dSize]; + TCHAR *wd = new TCHAR[dSize]; nlverify(::GetWindowsDirectory(wd, dSize)); _FontPath = tStrToUtf8(wd) + "\\fonts\\arial.ttf"; delete[] wd; @@ -630,12 +628,12 @@ bool CObjectViewer::initUI (HWND parent) // Create the icon HICON hIcon = (HICON)LoadImage(theApp.m_hInstance, MAKEINTRESOURCE(IDI_APP_ICON), IMAGE_ICON, 16, 16, 0); - + // load name of the driver from the config file loadDriverName(); // Create a doomy driver - IDriver *driver= _Direct3d?CDRU::createD3DDriver():CDRU::createGlDriver(); + IDriver *driver= CDRU::createGlDriver(); // Get parent window CWnd parentWnd; @@ -653,7 +651,7 @@ bool CObjectViewer::initUI (HWND parent) _MainFrame->registerValue (true); // Create the window - _MainFrame->CFrameWnd::Create (AfxRegisterWndClass(0, 0, NULL, hIcon), + _MainFrame->CFrameWnd::Create (AfxRegisterWndClass(0, 0, NULL, hIcon), _T("NeL object viewer"), 0x00cfc000, /*WS_OVERLAPPEDWINDOW,*/ CFrameWnd::rectDefault, parentWndPtr, MAKEINTRESOURCE(IDR_OBJECT_VIEWER_MENU), 0x00000300 /*WS_EX_ACCEPTFILES*/ /*|WS_EX_CLIENTEDGE*/); @@ -688,12 +686,12 @@ bool CObjectViewer::initUI (HWND parent) RECT viewportRect; GetClientRect(view->m_hWnd, &viewportRect); - + // Init NELU - if (!CNELU::init (viewportRect.right, viewportRect.bottom, viewport, 32, true, view->m_hWnd, false, _Direct3d)) + if (!CNELU::init (viewportRect.right, viewportRect.bottom, viewport, 32, true, view->m_hWnd, false)) { return false; - } + } //CNELU::init (640, 480, viewport, 32, true, _MainFrame->m_hWnd); CNELU::Scene->setPolygonBalancingMode(CScene::PolygonBalancingClamp); @@ -704,7 +702,7 @@ bool CObjectViewer::initUI (HWND parent) CNELU::Driver->enableFog (_Fog); CNELU::Driver->setupFog (_FogStart, _FogEnd, _FogColor); - // init sound + // init sound CSoundSystem::initSoundSystem (); // Create a root. @@ -795,23 +793,23 @@ bool CObjectViewer::initUI (HWND parent) _TuneMRMDlg = new CTuneMrmDlg(this, CNELU::Scene, _MainFrame); _TuneMRMDlg->Create(IDD_TUNE_MRM_DLG, _MainFrame); getRegisterWindowState (_TuneMRMDlg, REGKEY_TUNE_MRM_DLG, false); - - + + _MainFrame->update (); - + // Set current frame setAnimTime (0.f, 100.f); // Add mouse listener to event server _MouseListener.addToServer(CNELU::EventServer); - + CNELU::Driver->activate (); // Enable sum of vram CNELU::Driver->enableUsedTextureMemorySum (); - // load the scheme bank if one is present + // load the scheme bank if one is present CIFile iF; std::string path = SPath + "default.scb"; if (iF.open(path)) @@ -827,7 +825,7 @@ bool CObjectViewer::initUI (HWND parent) } } iF.close(); - + // try to load a default config file for the viewer (for anitmation and particle edition setup) path = SPath + "default.ovcgf"; @@ -846,14 +844,14 @@ bool CObjectViewer::initUI (HWND parent) // Create the cloud scape _CS = new CCloudScape(CNELU::Driver); - _CS->init (&_CSS); + _CS->init (&_CSS); return true; } // *************************************************************************** -void CObjectViewer::addTransformation (CMatrix ¤t, CAnimation *anim, float begin, float end, ITrack *posTrack, ITrack *rotquatTrack, +void CObjectViewer::addTransformation (CMatrix ¤t, CAnimation *anim, float begin, float end, ITrack *posTrack, ITrack *rotquatTrack, ITrack *nextPosTrack, ITrack *nextRotquatTrack, bool removeLast) { // In place ? @@ -956,7 +954,7 @@ void CObjectViewer::setupPlaylist (float time) _ListInstance[i]->Playlist.setupMixer (_ListInstance[i]->ChannelMixer, _AnimationDlg->getTime()); } else - { + { // Some animation in the list ? if (_ListInstance[i]->Saved.PlayList.size()>0) { @@ -1046,7 +1044,7 @@ void CObjectViewer::setupPlaylist (float time) addTransformation (current, anim, 0, anim->getBeginTime() + time - startTime, posTrack, rotquatTrack, NULL, NULL, false); // Good index - choosedIndex = _ListInstance[i]->AnimationSet.getAnimationIdByName (_ListInstance[i]->Saved.PlayList[index]); + choosedIndex = _ListInstance[i]->AnimationSet.getAnimationIdByName (_ListInstance[i]->Saved.PlayList[index]); // Get the animation anim=_ListInstance[i]->AnimationSet.getAnimation (choosedIndex); @@ -1055,7 +1053,7 @@ void CObjectViewer::setupPlaylist (float time) startTime -= anim->getBeginTime (); } - // Set the slot + // Set the slot _ListInstance[i]->Playlist.setTimeOrigin (0, startTime); _ListInstance[i]->Playlist.setWrapMode (0, CAnimationPlaylist::Clamp); _ListInstance[i]->Playlist.setStartWeight (0, 1, 0); @@ -1141,11 +1139,11 @@ void CObjectViewer::go () CGraph graph("ms", 10, 10, 200, 100, CRGBA(64, 64, 64), 20, 200); do - { + { _CrtCheckMemory(); if (isParentWnd(_MainFrame->m_hWnd, GetForegroundWindow())) { - CNELU::Driver->activate (); + CNELU::Driver->activate (); // Handle animation _AnimationDlg->handle (); @@ -1168,18 +1166,18 @@ void CObjectViewer::go () // Animate the automatic animation in the scene //CNELU::Scene->animate( (float) + NLMISC::CTime::ticksToSecond( NLMISC::CTime::getPerformanceTime() ) ); - + // Eval channel mixer for transform for (uint i=0; i<_ListInstance.size(); i++) - + _ListInstance[i]->ChannelMixer.eval (false); - animateCNELUScene (_CS); + animateCNELUScene (_CS); // Clear the buffers - CNELU::clearBuffers(_BackGroundColor); + CNELU::clearBuffers(_BackGroundColor); + - //if (_CS) _CS->setDebugQuad(true); // call of callback list @@ -1191,11 +1189,11 @@ void CObjectViewer::go () } } // Render the CS - if (_CS) _CS->render (); - - // Draw the scene - CNELU::Scene->render(); - + if (_CS) _CS->render (); + + // Draw the scene + CNELU::Scene->render(); + // call of callback list { std::vector copyVect(_CallBackList.begin(), _CallBackList.end()); @@ -1204,9 +1202,9 @@ void CObjectViewer::go () (*it)->goPostRender(); } } - + if (_OcclusionTestMeshsVisible) - { + { CNELU::Scene->renderOcclusionTestMeshs(); } @@ -1245,8 +1243,8 @@ void CObjectViewer::go () // draw various matrix if (_FXMatrixVisible) drawFXMatrix(); if (_FXUserMatrixVisible) drawFXUserMatrix(); - if (_SceneMatrixVisible) drawSceneMatrix(); - + if (_SceneMatrixVisible) drawSceneMatrix(); + // draw Skeleton Scale Dlg selection if(_SkeletonScaleDlg) _SkeletonScaleDlg->drawSelection(); @@ -1301,11 +1299,11 @@ void CObjectViewer::go () // Display std info. std::string msgBar = toString("%s - Nb tri: %u - Texture used (MiB): %5.2f - Texture allocated (MiB): %5.2f - Distance: %5.0f - Sounds: %u/%u - Fps: %03.1f", - _Direct3d ? "Direct3d":"OpenGL", + "OpenGL", in.NLines+in.NPoints+in.NQuads*2+in.NTriangles+in.NTriangleStrips, - (float)CNELU::Driver->getUsedTextureMemory () / (float)(1024*1024), - (float)CNELU::Driver->profileAllocatedTextureMemory () / (float)(1024*1024), - (_SceneCenter-CNELU::Camera->getMatrix().getPos()).norm(), + (float)CNELU::Driver->getUsedTextureMemory () / (float)(1024*1024), + (float)CNELU::Driver->profileAllocatedTextureMemory () / (float)(1024*1024), + (_SceneCenter-CNELU::Camera->getMatrix().getPos()).norm(), nbPlayingSources, nbSources, fps @@ -1362,14 +1360,14 @@ void CObjectViewer::go () _MouseListener.setSpeed (_MainFrame->MoveSpeed); } - + // Reset camera aspect ratio initCamera (); if (_MainFrame->isMoveElement()) { - // for now we apply a transform on the selected object in the particle system + // for now we apply a transform on the selected object in the particle system _ParticleDlg->moveElement(_MouseListener.getModelMatrix()); } else if (_MainFrame->isMoveFX()) @@ -1447,11 +1445,11 @@ void CObjectViewer::go () TranslateMessage(&msg); DispatchMessage(&msg); } - + CSoundSystem::setListenerMatrix(_MouseListener.getViewMatrix()); CSoundSystem::poll(); - + // simulate frame delay if (_FrameDelay) @@ -1475,11 +1473,11 @@ void CObjectViewer::go () if (!IsWindow (_MainFrame->m_hWnd)) break; - // Get the foreground window + // Get the foreground window if (isParentWnd(_MainFrame->m_hWnd, GetForegroundWindow())) break; } - } + } } while (!CNELU::AsyncListener.isKeyPushed(KeyESCAPE)&&CNELU::Driver->isActive()); _InstanceRunning = false; @@ -1492,8 +1490,8 @@ void CObjectViewer::releaseUI () AFX_MANAGE_STATE(AfxGetStaticModuleState()); // Release particles - removeWindow(_ChooseFrameDelayDlg); - removeWindow(_ParticleDlg); + removeWindow(_ChooseFrameDelayDlg); + removeWindow(_ParticleDlg); // release sound CSoundSystem::releaseSoundSystem(); @@ -1509,7 +1507,7 @@ void CObjectViewer::releaseUI () // Write register if (_MainFrame) - { + { _MainFrame->registerValue (false); // Remove the main frame if (::IsWindow(*_MainFrame)) @@ -1544,7 +1542,7 @@ void CObjectViewer::releaseUI () _VegetableLandscape= NULL; } - + // Release all instances and all Igs. removeAllInstancesFromScene(); @@ -1562,7 +1560,7 @@ void CObjectViewer::releaseUI () // release other 3D. CNELU::release(); - + } // *************************************************************************** @@ -1633,7 +1631,7 @@ void CObjectViewer::resetSlots (uint instance) // Reset the skeleton list _ListInstance[instance]->Saved.SWTFileName.clear (); - // Update + // Update _AnimationSetDlg->refresh (TRUE); _SlotDlg->refresh (TRUE); _SoundAnimDlg->refresh (TRUE); @@ -1741,7 +1739,7 @@ void CObjectViewer::serial (NLMISC::IStream& f) if (f.isReading()) { if (ver <=3) - { + { ParticleWorkspaceFilename.clear(); } // First instance @@ -1879,13 +1877,13 @@ bool CObjectViewer::loadInstanceGroup(const std::string &igFilename) // Add search path for the mesh CPath::addSearchPath (NLMISC::CFile::getPath(igFilename)); - + // Open a file CIFile file; if (file.open (igFilename)) - { + { // Shape pointer - NL3D::CInstanceGroup *ig = new NL3D::CInstanceGroup; + NL3D::CInstanceGroup *ig = new NL3D::CInstanceGroup; try { @@ -1911,9 +1909,9 @@ bool CObjectViewer::loadInstanceGroup(const std::string &igFilename) return false; } - - return true; + + return true; } @@ -2121,7 +2119,7 @@ uint CObjectViewer::addMesh (NL3D::IShape* pMeshShape, const std::string &meshNa iInfo->MustDelete = true; iInfo->Saved.ShapeFilename = meshName; iInfo->Saved.SkeletonId = skelIndex; - _ListInstance.push_back (iInfo); + _ListInstance.push_back (iInfo); // *** Bind to the skeleton @@ -2134,12 +2132,12 @@ uint CObjectViewer::addMesh (NL3D::IShape* pMeshShape, const std::string &meshNa // Get the skeleton NL3D::CSkeletonModel *transformSkel = dynamic_cast(_ListInstance[skelIndex]->TransformShape); nlassert (transformSkel); - + // It is a skinned mesh ? CMesh *mesh = dynamic_cast(pMeshShape); CMeshMRM *meshMrm = dynamic_cast(pMeshShape); CMeshMRMSkinned *meshMrmSkinned = dynamic_cast(pMeshShape); - if ( (mesh && mesh->getMeshGeom().isSkinned()) || + if ( (mesh && mesh->getMeshGeom().isSkinned()) || (meshMrm && meshMrm->getMeshGeom().isSkinned()) || meshMrmSkinned) { @@ -2152,7 +2150,7 @@ uint CObjectViewer::addMesh (NL3D::IShape* pMeshShape, const std::string &meshNa uint bindBone = 0xffffffff; std::string boneName; - // Name is passed, look for bone + // Name is passed, look for bone if (bindSkelName) { // Make a list of bones @@ -2231,7 +2229,7 @@ bool CObjectViewer::chooseBone(const std::string &caption, NL3D::CSkeletonModel CSelectString dialogSelect (listBones, caption.c_str(), _MainFrame, false); if (dialogSelect.DoModal ()==IDOK) { - boneIndex = dialogSelect.Selection; + boneIndex = dialogSelect.Selection; skel = transformSkel; if (skelName) { @@ -2243,7 +2241,7 @@ bool CObjectViewer::chooseBone(const std::string &caption, NL3D::CSkeletonModel } return true; } - return false; + return false; } } return false; @@ -2342,7 +2340,7 @@ uint CObjectViewer::addSkel (NL3D::IShape* pSkelShape, const std::string &skelNa iInfo->Saved.ShapeFilename = skelName; iInfo->Saved.IsSkeleton = true; iInfo->Saved.SkeletonId = 0xffffffff; - _ListInstance.push_back (iInfo); + _ListInstance.push_back (iInfo); // set this skeleton for Skeleton Scale edition _SkeletonScaleDlg->setSkeletonToEdit(skelModel, skelName); @@ -2386,7 +2384,7 @@ void CObjectViewer::setSingleAnimation (NL3D::CAnimation* pAnim, const std::stri if (instance < _ListInstance.size()) { - // Set active + // Set active _SelectedObject = instance; // Add the animation @@ -2461,7 +2459,7 @@ void CObjectViewer::removeMainLoopCallBack(IMainLoopCallBack *i) { std::vector::iterator it = std::find(_CallBackList.begin(), _CallBackList.end(), i); nlassert(it != _CallBackList.end()); // this object wasn't registered - _CallBackList.erase(it); + _CallBackList.erase(it); } // *************************************************************************** @@ -2476,8 +2474,8 @@ void CObjectViewer::activateTextureSet(uint index) if (dynamic_cast(trShape)) { static_cast(trShape)->selectTextureSet(index); - } - } + } + } } // *************************************************************************** @@ -2492,8 +2490,8 @@ void CObjectViewer::shuffleTextureSet() if (dynamic_cast(trShape)) { static_cast(trShape)->selectTextureSet(rand() % 8); - } - } + } + } } @@ -2571,8 +2569,8 @@ void CObjectViewer::enableFXs(bool enabled) if (enabled) sr->start(); else sr->stop(); } - } - } + } + } } // *************************************************************************** @@ -2605,7 +2603,7 @@ void CObjectViewer::evalSoundTrack (float lastTime, float currentTime) // setup the sound context DWORD tab[] = {IDC_ARG0, IDC_ARG1, IDC_ARG2, IDC_ARG3, }; - + for (uint i = 0; i < 4; i++) { CEdit *edit = (CEdit*) _SoundAnimDlg->GetDlgItem(tab[i]); @@ -2701,14 +2699,14 @@ void CObjectViewer::evalSoundTrack (float lastTime, float currentTime) // Process sounds NLSOUND::UAudioMixer *audioMixer = CSoundSystem::getAudioMixer (); if( audioMixer ) - { + { vector::iterator itResult; - for( itResult = result.begin(); itResult != result.end(); ++itResult ) + for( itResult = result.begin(); itResult != result.end(); ++itResult ) { string soundName; double keyTime = *itResult; nlinfo("keyTime = %f result size : %d",*itResult,result.size()); - + if( !track->interpolate( *itResult, soundName) ) { nlwarning("The key at offset %f is not a string",*itResult); @@ -2770,7 +2768,7 @@ uint CObjectViewer::addInstanceGroup(NL3D::CInstanceGroup *ig) // First instance uint first = (uint)_ListInstance.size(); - // Add all models to the scene + // Add all models to the scene ig->addToScene(*CNELU::Scene, CNELU::Driver); // Unfreeze all objects from HRC. ig->unfreezeHRC(); @@ -2846,7 +2844,7 @@ void CObjectViewer::enableDynamicObjectLightingTest(NLPACS::CGlobalRetriever *gl else { if (!_ObjectLightTestShape.empty()) - { + { string str= string("Path not found for Light Test Shape: ") + _ObjectLightTestShape; ::MessageBox(NULL, utf8ToTStr(str.c_str()), _T("Dynamic Object Light Test"), MB_OK|MB_ICONEXCLAMATION); } @@ -2861,9 +2859,9 @@ void CObjectViewer::enableDynamicObjectLightingTest(NLPACS::CGlobalRetriever *gl // *************************************************************************** void CObjectViewer::COVLogicInfo::getStaticLightSetup(NLMISC::CRGBA sunAmbient, std::vector &pointLightList, uint8 &sunContribution, CRGBA &ambient) { - Ig->getStaticLightSetup(sunAmbient, GlobalRetriever->getLocalRetrieverId(GPos), + Ig->getStaticLightSetup(sunAmbient, GlobalRetriever->getLocalRetrieverId(GPos), GPos.LocalPosition.Surface, - GPos.LocalPosition.Estimation, + GPos.LocalPosition.Estimation, pointLightList, sunContribution, ambient); } @@ -3426,7 +3424,7 @@ void CInstanceInfo::setAnimationPlaylist (float frameRate) uint animId = AnimationSet.getAnimationIdByName (Saved.SlotInfo[id].Animation); if (animId == CAnimationSet::NotFound) Playlist.setAnimation (id, CAnimationPlaylist::empty); - else + else Playlist.setAnimation (id, animId); // Set the skeleton weight @@ -3664,7 +3662,7 @@ float CObjectViewer::getGlobalWindPower() const } -void CObjectViewer::shootScene() +void CObjectViewer::shootScene() { static const TCHAR BASED_CODE szFilter[] = _T("PNG Files (*.png)|*.png|Targa Files (*.tga)|*.tga|Jpeg Files (*.jpg)|*.jpg|All Files (*.*)|*.*||"); CFileDialog fileDlg ( FALSE, _T(".tga"), _T("*.tga"), OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT, szFilter); @@ -3683,7 +3681,7 @@ void CObjectViewer::shootScene() window.right += movieSize.Width - width; window.bottom += movieSize.Height - height; _MainFrame->SetWindowPos (NULL, 0, 0, window.right-window.left, window.bottom-window.top, SWP_NOMOVE|SWP_NOZORDER); - + // Swap the buffers CNELU::swapBuffers(); @@ -3731,11 +3729,11 @@ void CObjectViewer::shootScene() } } // Render the CS - if (_CS) _CS->render (); - - // Draw the scene - CNELU::Scene->render(); - + if (_CS) _CS->render (); + + // Draw the scene + CNELU::Scene->render(); + // call of callback list { std::vector copyVect(_CallBackList.begin(), _CallBackList.end()); @@ -3744,7 +3742,7 @@ void CObjectViewer::shootScene() (*it)->goPostRender(); } } - + // Swap the buffers @@ -3792,7 +3790,7 @@ void CObjectViewer::drawFXUserMatrix() static std::string fxUserMatrixStr; static bool stringRetrieved = false; if (!stringRetrieved) - { + { CString fxUserMatrix; fxUserMatrix.LoadString(IDS_FX_USER_MATRIX); fxUserMatrixStr = tStrToUtf8(fxUserMatrix); @@ -3807,7 +3805,7 @@ void CObjectViewer::drawFXMatrix() static std::string fxStr; static bool stringRetrieved = false; if (!stringRetrieved) - { + { CString fx; fx.LoadString(IDS_FX_MATRIX); fxStr = tStrToUtf8(fx); @@ -3821,7 +3819,7 @@ void CObjectViewer::drawSceneMatrix() static std::string sceneMatrixStr; static bool stringRetrieved = false; if (!stringRetrieved) - { + { CString sceneMatrix; sceneMatrix.LoadString(IDS_SCENE_MATRIX); sceneMatrixStr = tStrToUtf8(sceneMatrix); @@ -3833,7 +3831,7 @@ void CObjectViewer::drawSceneMatrix() void CObjectViewer::drawNamedMatrix(const NLMISC::CMatrix &matrix, const std::string &name, NLMISC::CRGBA color, float textZOffset, float testSize) { - CPSUtil::displayBasis(CNELU::Driver, matrix, NLMISC::CMatrix::Identity, 1.f, *_FontGenerator, _FontManager); + CPSUtil::displayBasis(CNELU::Driver, matrix, NLMISC::CMatrix::Identity, 1.f, *_FontGenerator, _FontManager); CPSUtil::print(CNELU::Driver, name, *_FontGenerator, _FontManager, matrix.getPos() + NLMISC::CVector(0.f, 0.f, textZOffset), testSize, color); } @@ -3843,13 +3841,13 @@ sint CObjectViewer::getCurrentCamera () const { return _CurrentCamera; } - + void CObjectViewer::setCurrentCamera (sint currentCamera) { nlassert ((currentCamera == -1) ||(currentCamera < (sint)_Cameras.size ())); _CurrentCamera = currentCamera; } - + uint CObjectViewer::getCameraInstance (uint cameraId) const { return _Cameras[cameraId]; @@ -3872,8 +3870,8 @@ int localizedMessageBox(HWND parentWindow, int messageStringID, int captionStrin int localizedMessageBox(HWND parentWindow, const TCHAR *message, int captionStringID, UINT nType) { - CString caption; - caption.LoadString(captionStringID); + CString caption; + caption.LoadString(captionStringID); return MessageBox(parentWindow, message, (LPCTSTR) caption, nType); } @@ -3887,8 +3885,8 @@ CString getStrRsc(uint stringID) bool browseFolder(const CString &caption, CString &destFolder, HWND parent) { TCHAR chosenPath[MAX_PATH]; - // browse folder - BROWSEINFO bi; + // browse folder + BROWSEINFO bi; bi.hwndOwner = parent; bi.pidlRoot = NULL; bi.pszDisplayName = chosenPath; @@ -3905,5 +3903,3 @@ bool browseFolder(const CString &caption, CString &destFolder, HWND parent) } return false; } - - diff --git a/code/nel/tools/3d/object_viewer/object_viewer.h b/code/nel/tools/3d/object_viewer/object_viewer.h index c00c5490d..f73974135 100644 --- a/code/nel/tools/3d/object_viewer/object_viewer.h +++ b/code/nel/tools/3d/object_viewer/object_viewer.h @@ -205,7 +205,7 @@ public: // Set an animation playlist void setAnimationPlaylist (float frameRate); - + }; ///////////////////////////////////////////////////////////////////////////// @@ -223,7 +223,7 @@ public: // Init the UI bool initUI (HWND parent=NULL); - + // Go void go (); @@ -245,14 +245,14 @@ public: // Add a camera uint addCamera (const NL3D::CCameraInfo &cameraInfo, const std::string &cameraName); - // Add a skel + // Add a skel uint addSkel (NL3D::IShape* pSkelShape, const std::string &skelName); // remove all instances from the scene void removeAllInstancesFromScene(); // Start / stop fxs (remanence for now..) - void enableFXs(bool enabled); + void enableFXs(bool enabled); /// Force all the instances of the scene to use the given texture set (if available) @@ -278,7 +278,7 @@ public: // Set edited object, 0xffffffff if no object edited void setEditedObject (uint selected); - + // Get an instance CInstanceInfo *getInstance (uint instance); @@ -302,7 +302,7 @@ public: const NL3D::CEvent3dMouseListener &getMouseListener(void) const { return _MouseListener ; } // get the particle dialog - CParticleDlg *getParticleDialog(void) const { return _ParticleDlg ; } + CParticleDlg *getParticleDialog(void) const { return _ParticleDlg ; } // get the frame delay dialog CChooseFrameDelay *getFrameDelayDlg() const { return _ChooseFrameDelayDlg; } @@ -361,7 +361,7 @@ public: /// remove an object that was registered with registerMainLoopCallBack() void removeMainLoopCallBack(IMainLoopCallBack *i) ; - + /// set the lag in milliseconds between each frame; 0 is the default void setFrameDelay(uint32 milliSec) { _FrameDelay = milliSec; } @@ -373,15 +373,15 @@ public: /// Setup the playlist with the playlist void setupPlaylist (float time); - + /// Enable disable channels void enableChannels (); - + /// Setup transform positions void setupPositions (); /// Manage matrix increment - void addTransformation (NLMISC::CMatrix ¤t, NL3D::CAnimation *anim, float begin, float end, NL3D::ITrack *posTrack, NL3D::ITrack *rotquatTrack, + void addTransformation (NLMISC::CMatrix ¤t, NL3D::CAnimation *anim, float begin, float end, NL3D::ITrack *posTrack, NL3D::ITrack *rotquatTrack, NL3D::ITrack *nextPosTrack, NL3D::ITrack *nextRotquatTrack, bool removeLast); /// inherited from CObjectViewerInterface @@ -457,7 +457,7 @@ public: // -1 If no current camera void setCurrentCamera (sint currentCamera); - + // Get the instance id of a camera uint getCameraInstance (uint cameraId) const; @@ -476,7 +476,7 @@ public: bool isSkeletonPresent() const; // get the main frame - CMainFrame *getMainFrame() const { return _MainFrame; } + CMainFrame *getMainFrame() const { return _MainFrame; } const NLMISC::CMatrix &getFXUserMatrix() const { return _FXUserMatrix; } void setFXUserMatrix(const NLMISC::CMatrix &fxUserMatrix) { _FXUserMatrix = fxUserMatrix; } @@ -490,7 +490,7 @@ public: void setOcclusionTestMeshsVisible(bool visible) { _OcclusionTestMeshsVisible = visible; } bool getOcclusionTestMeshsVisible() const { return _OcclusionTestMeshsVisible; } - + private: @@ -532,11 +532,11 @@ private: // Font mgt NL3D::CFontManager _FontManager; - NL3D::CFontGenerator *_FontGenerator; + NL3D::CFontGenerator *_FontGenerator; std::string _FontPath; std::vector _CallBackList; - uint32 _FrameDelay; - float _CameraFocal; + uint32 _FrameDelay; + float _CameraFocal; float _LastTime; NL3D::CWaterPoolManager *_Wpm; @@ -618,9 +618,6 @@ private: // Scale the pos of the skeleton float _CharacterScalePos; - // Driver in direct3d ? - bool _Direct3d; - // Fog bool _Fog; float _FogStart; @@ -634,7 +631,7 @@ private: // The root of all objects added to the scene. Rotated for user convenience NL3D::CTransform *_SceneRoot; - + // load the config file void loadConfigFile(); @@ -643,7 +640,7 @@ private: // load driver name from the config file void loadDriverName(); - void drawFXUserMatrix(); + void drawFXUserMatrix(); void drawFXMatrix(); void drawSceneMatrix(); diff --git a/code/nel/tools/3d/object_viewer_widget/src/interfaces.h b/code/nel/tools/3d/object_viewer_widget/src/interfaces.h index e47f5875f..f4ad52b21 100644 --- a/code/nel/tools/3d/object_viewer_widget/src/interfaces.h +++ b/code/nel/tools/3d/object_viewer_widget/src/interfaces.h @@ -24,17 +24,17 @@ along with this program. If not, see . #include -namespace NL3D +namespace NL3D { class UPlayListManager; class UDriver; class UScene; } -namespace NLQT +namespace NLQT { - class IObjectViewer + class IObjectViewer { public: @@ -54,7 +54,7 @@ namespace NLQT virtual bool loadMesh (const std::string &meshFileName, const std::string &skelFileName) = 0; virtual void resetScene() = 0; virtual void setBackgroundColor(NLMISC::CRGBA backgroundColor) = 0; - virtual void setGraphicsDriver(bool Direct3D) = 0; + virtual void setGraphicsDriver() = 0; virtual void setSizeViewport(uint16 w, uint16 h) = 0; virtual void setBloomEffect(bool enabled) = 0; virtual void setCurrentObject(const std::string &name) = 0; @@ -62,7 +62,6 @@ namespace NLQT virtual CEntity& getEntity(const std::string &name) = 0; virtual void getListObjects(std::vector &listObj) = 0; virtual NLMISC::CRGBA getBackgroundColor() = 0; - virtual bool getDirect3D() = 0; virtual bool getBloomEffect() const = 0; virtual NL3D::UDriver *getDriver() = 0; virtual NL3D::UScene *getScene() = 0; @@ -80,4 +79,4 @@ namespace NLQT Q_DECLARE_INTERFACE(NLQT::IObjectViewer,"com.ryzom.dev.IObjectViewer/0.1") -#endif \ No newline at end of file +#endif diff --git a/code/nel/tools/3d/object_viewer_widget/src/object_viewer_widget.cpp b/code/nel/tools/3d/object_viewer_widget/src/object_viewer_widget.cpp index fbc379d95..248643914 100644 --- a/code/nel/tools/3d/object_viewer_widget/src/object_viewer_widget.cpp +++ b/code/nel/tools/3d/object_viewer_widget/src/object_viewer_widget.cpp @@ -132,13 +132,11 @@ namespace NLQT // set graphics driver from config //NLMISC::CConfigFile::CVar v2 = Modules::config().getConfigFile().getVar("GraphicsDriver"); - // Choose driver opengl to work correctly under Linux example - _Direct3D = false; //_Driver = OpenGL; + _Driver = OpenGL; #ifdef NL_OS_WINDOWS //std::string driver = v2.asString(); - //if (driver == "Direct3D") _Direct3D = true; //m_Driver = Direct3D; - //else if (driver == "OpenGL") _Direct3D = false; //m_Driver = OpenGL; + //if (driver == "OpenGL") m_Driver = OpenGL; //else nlwarning("Invalid driver specified, defaulting to OpenGL"); #endif @@ -148,7 +146,7 @@ namespace NLQT // create the driver nlassert(!_Driver); - _Driver = UDriver::createDriver(0, _Direct3D, 0); + _Driver = UDriver::createDriver(0, 0); nlassert(_Driver); // initialize the window with config file values @@ -517,12 +515,9 @@ namespace NLQT //Modules::config().getConfigFile().getVar("BackgroundColor").setAsInt(_BackgroundColor.B, 2); } - void CObjectViewerWidget::setGraphicsDriver(bool Direct3D) + void CObjectViewerWidget::setGraphicsDriver() { - //_Direct3D = Direct3D; - - //if (_Direct3D) Modules::config().getConfigFile().getVar("GraphicsDriver").setAsString("Direct3D"); - //else Modules::config().getConfigFile().getVar("GraphicsDriver").setAsString("OpenGL"); + //Modules::config().getConfigFile().getVar("GraphicsDriver").setAsString("OpenGL"); } void CObjectViewerWidget::setSizeViewport(uint16 w, uint16 h) diff --git a/code/nel/tools/3d/object_viewer_widget/src/object_viewer_widget.h b/code/nel/tools/3d/object_viewer_widget/src/object_viewer_widget.h index 69629ef40..4a3d82841 100644 --- a/code/nel/tools/3d/object_viewer_widget/src/object_viewer_widget.h +++ b/code/nel/tools/3d/object_viewer_widget/src/object_viewer_widget.h @@ -106,8 +106,7 @@ namespace NLQT void setBackgroundColor(NLMISC::CRGBA backgroundColor); /// Set type driver. - /// @param Direct3D - type driver (true - Direct3D) or (false -OpenGL) - void setGraphicsDriver(bool Direct3D); + void setGraphicsDriver(); /// Set size viewport for correct set perspective /// @param w - width window. @@ -136,10 +135,6 @@ namespace NLQT /// @return background color. NLMISC::CRGBA getBackgroundColor() { return _BackgroundColor; } - /// Get type driver. - /// @return true if have used Direct3D driver, false OpenGL driver. - inline bool getDirect3D() { return _Direct3D; } - inline bool getBloomEffect() const { return _BloomEffect; } /// Get a pointer to the driver. @@ -220,7 +215,6 @@ namespace NLQT float _phi, _psi, _dist; float _CameraFocal; - bool _Direct3D; bool _BloomEffect; std::string _CurrentInstance; diff --git a/code/nel/tools/3d/zviewer/zviewer.cpp b/code/nel/tools/3d/zviewer/zviewer.cpp index fc8e00a4c..dffcb98a7 100644 --- a/code/nel/tools/3d/zviewer/zviewer.cpp +++ b/code/nel/tools/3d/zviewer/zviewer.cpp @@ -972,7 +972,7 @@ int main(int /* argc */, char ** /* argv */) initViewerConfig("zviewer.cfg"); // Init NELU - NL3D::CNELU::init(ViewerCfg.Width, ViewerCfg.Height, CViewport(), ViewerCfg.Depth, ViewerCfg.Windowed, EmptyWindow, false, false); + NL3D::CNELU::init(ViewerCfg.Width, ViewerCfg.Height, CViewport(), ViewerCfg.Depth, ViewerCfg.Windowed, EmptyWindow, false); NL3D::CNELU::Driver->setWindowTitle(ucstring("NeL ZViewer")); NL3D::CNELU::Camera->setTransformMode(ITransformable::DirectMatrix); diff --git a/code/nel/tools/sound/build_sound/build_sound.cpp b/code/nel/tools/sound/build_sound/build_sound.cpp index e5a7a0022..ddec60422 100644 --- a/code/nel/tools/sound/build_sound/build_sound.cpp +++ b/code/nel/tools/sound/build_sound/build_sound.cpp @@ -106,9 +106,8 @@ int main(int nNbArg, char **ppArgs) // this here does the magic, we actually don't need the driver but whatever try { audioMixer->init(0, false, false, NULL, true, UAudioMixer::DriverOpenAl); } catch (...) { - try { audioMixer->init(0, false, false, NULL, true, UAudioMixer::DriverXAudio2); } catch (...) { try { audioMixer->init(0, false, false, NULL, true, UAudioMixer::DriverFMod); } - catch (...) { return EXIT_FAILURE; } } } + catch (...) { return EXIT_FAILURE; } } // and that's all folks delete audioMixer; diff --git a/code/ryzom/client/client_default.cfg b/code/ryzom/client/client_default.cfg index d63d5361d..95de60c3d 100644 --- a/code/ryzom/client/client_default.cfg +++ b/code/ryzom/client/client_default.cfg @@ -13,7 +13,7 @@ SaveConfig = 1; // WINDOW CONFIG // /////////////////// -Driver3D="Auto"; // Valid values are "Auto" or "0", "OpengGL" or "1" & "Direct3D" or "2" +Driver3D="Auto"; // Valid values are "Auto" or "0", "OpengGL" or "1" // "Auto" will choose the best suited driver depending on hardware FullScreen = 0; Width = 0; diff --git a/code/ryzom/client/src/bug_report/StdAfx.h b/code/ryzom/client/src/bug_report/StdAfx.h index bf9a6e687..41e862c9c 100644 --- a/code/ryzom/client/src/bug_report/StdAfx.h +++ b/code/ryzom/client/src/bug_report/StdAfx.h @@ -41,7 +41,6 @@ #define WIN32_LEAN_AND_MEAN #include -#include #include #include diff --git a/code/ryzom/client/src/bug_report/bug_reportDlg.cpp b/code/ryzom/client/src/bug_report/bug_reportDlg.cpp index 322b494f8..bac70a460 100644 --- a/code/ryzom/client/src/bug_report/bug_reportDlg.cpp +++ b/code/ryzom/client/src/bug_report/bug_reportDlg.cpp @@ -316,14 +316,7 @@ BOOL CALLBACK CSoundDriverDSoundEnumCallback(LPGUID guid, LPCSTR description, PC string getSoundCardInformation() { - soundCards= ""; - - if (FAILED(DirectSoundEnumerate(CSoundDriverDSoundEnumCallback, NULL))) - { - return "no sound card found"; - } - - return soundCards; + return "no sound card found"; } diff --git a/code/ryzom/client/src/client_cfg.cpp b/code/ryzom/client/src/client_cfg.cpp index c5bc0e585..8470dc0cd 100644 --- a/code/ryzom/client/src/client_cfg.cpp +++ b/code/ryzom/client/src/client_cfg.cpp @@ -836,7 +836,6 @@ void CClientConfig::setValues() { if (nlstricmp(varPtr->asString(), "Auto") == 0 || nlstricmp(varPtr->asString(), "0") == 0) ClientCfg.Driver3D = CClientConfig::DrvAuto; else if (nlstricmp(varPtr->asString(), "OpenGL") == 0 || nlstricmp(varPtr->asString(), "1") == 0) ClientCfg.Driver3D = CClientConfig::OpenGL; - else if (nlstricmp(varPtr->asString(), "Direct3D") == 0 || nlstricmp(varPtr->asString(), "2") == 0) ClientCfg.Driver3D = CClientConfig::Direct3D; else if (nlstricmp(varPtr->asString(), "OpenGLES") == 0 || nlstricmp(varPtr->asString(), "3") == 0) ClientCfg.Driver3D = CClientConfig::OpenGLES; } else @@ -1186,8 +1185,6 @@ void CClientConfig::setValues() if (nlstricmp(varPtr->asString(), "Auto") == 0) ClientCfg.DriverSound = CClientConfig::SoundDrvAuto; else if (nlstricmp(varPtr->asString(), "FMod") == 0) ClientCfg.DriverSound = CClientConfig::SoundDrvFMod; else if (nlstricmp(varPtr->asString(), "OpenAL") == 0) ClientCfg.DriverSound = CClientConfig::SoundDrvOpenAL; - else if (nlstricmp(varPtr->asString(), "DirectSound") == 0) ClientCfg.DriverSound = CClientConfig::SoundDrvDirectSound; - else if (nlstricmp(varPtr->asString(), "XAudio2") == 0) ClientCfg.DriverSound = CClientConfig::SoundDrvXAudio2; } else cfgWarning ("Default value used for 'DriverSound' !!!"); diff --git a/code/ryzom/client/src/client_cfg.h b/code/ryzom/client/src/client_cfg.h index 4d4d746e0..1edcf6263 100644 --- a/code/ryzom/client/src/client_cfg.h +++ b/code/ryzom/client/src/client_cfg.h @@ -53,8 +53,8 @@ using std::string; //--------------------------------------------------- struct CClientConfig { - enum TDriver3D { DrvAuto = 0, OpenGL, Direct3D, OpenGLES }; - enum TDriverSound { SoundDrvAuto = 0, SoundDrvFMod, SoundDrvOpenAL, SoundDrvDirectSound, SoundDrvXAudio2 }; + enum TDriver3D { DrvAuto = 0, OpenGL, OpenGLES = 3 }; + enum TDriverSound { SoundDrvAuto = 0, SoundDrvFMod, SoundDrvOpenAL }; enum TStageLCTUsage { StageUseNoLCT = 0, StageUseAllLCT, StageUsePosOnlyLCT }; // the config file must be always be available @@ -876,5 +876,3 @@ extern const std::string ConfigFileName; #endif // CL_CLIENT_CFG_H /* End of client_cfg.h */ - - diff --git a/code/ryzom/client/src/init.cpp b/code/ryzom/client/src/init.cpp index 6fc794d52..c86f420fa 100644 --- a/code/ryzom/client/src/init.cpp +++ b/code/ryzom/client/src/init.cpp @@ -838,7 +838,7 @@ void initLog() rlp2.rlim_cur = std::min(value, rlp.rlim_max); rlp2.rlim_max = rlp.rlim_max; - + if (setrlimit(RLIMIT_NOFILE, &rlp2)) { if (errno == EINVAL) @@ -1023,11 +1023,6 @@ void prelogInit() switch(ClientCfg.Driver3D) { -#ifdef NL_OS_WINDOWS - case CClientConfig::Direct3D: - driver = UDriver::Direct3d; - break; -#endif // NL_OS_WINDOWS case CClientConfig::DrvAuto: case CClientConfig::OpenGL: driver = UDriver::OpenGl; @@ -1097,7 +1092,7 @@ void prelogInit() UDriver::CMode mode; bool forceWindowed1024x768 = true; - + if (Driver->getCurrentScreenMode(mode)) { // if screen mode lower than 1024x768, use same mode in fullscreen diff --git a/code/ryzom/client/src/init_main_loop.cpp b/code/ryzom/client/src/init_main_loop.cpp index 9c26c1876..2d38b1006 100644 --- a/code/ryzom/client/src/init_main_loop.cpp +++ b/code/ryzom/client/src/init_main_loop.cpp @@ -1329,11 +1329,6 @@ void initMainLoop() // Re-initialise the keyboard, now in low-level mode, if required // NB nico : done at end of loading -/* - if (!ClientCfg.DisableDirectInput) - { - Driver->enableLowLevelKeyboard (true); // the return value has already been tested at startup - }*/ SetMouseCursor (); SetMouseSpeed (ClientCfg.CursorSpeed); diff --git a/code/ryzom/client/src/landscape_poly_drawer.cpp b/code/ryzom/client/src/landscape_poly_drawer.cpp index 714684e26..46d7dec37 100644 --- a/code/ryzom/client/src/landscape_poly_drawer.cpp +++ b/code/ryzom/client/src/landscape_poly_drawer.cpp @@ -337,7 +337,7 @@ CLandscapePolyDrawer::infiniteFrustum() // initial projection matrix CMatrix frustumMatrix = Driver->getFrustumMatrix(); - // epsilon depends from OpenGL or Direct3D use + // epsilon depends from driver use double factor = Driver->getClipSpaceZMin() == -1.f ? 2 : 1; double epsilon = factor*(1 - _MaxDepthRange*(zfar/(zfar - znear))); @@ -349,12 +349,6 @@ CLandscapePolyDrawer::infiniteFrustum() frustumMatrix.setCoefficient((float)(epsilon-1), 2, 2); frustumMatrix.setCoefficient((float)(znear*(epsilon-2)), 2, 3); } - // Direct3D - else - { - frustumMatrix.setCoefficient((float)(1-epsilon), 2, 2); - frustumMatrix.setCoefficient((float)(znear*(epsilon-1)), 3, 2); - } // initial projection matrix Driver->setFrustumMatrix(frustumMatrix); @@ -720,4 +714,3 @@ void CLandscapePolyDrawer::computeBBoxFromPolygon(const NLMISC::CPolygon2D &poly } //----------------------------------------------------------------------------------------------------------- - diff --git a/code/ryzom/client/src/main_loop.cpp b/code/ryzom/client/src/main_loop.cpp index fe96d4da3..8a83e40dc 100644 --- a/code/ryzom/client/src/main_loop.cpp +++ b/code/ryzom/client/src/main_loop.cpp @@ -553,10 +553,7 @@ void clearBuffers() // Sky is used to clear the frame buffer now, but if in line or point polygon mode, we should draw it if (Driver->getPolygonMode() != UDriver::Filled) { - if (!Driver->isLost()) - { - Driver->clearBuffers (CRGBA(127, 127, 127)); - } + Driver->clearBuffers (CRGBA(127, 127, 127)); } } else @@ -1875,17 +1872,15 @@ bool mainLoop() // Display interface v3 Driver->enableFog (false); - if (!Driver->isLost()) - { - if(ShowInterface) - pIMinstance->updateFrameViews (MainCam); - if(DebugUIView) - pIMinstance->displayUIViewBBoxs(DebugUIFilter); - if(DebugUICtrl) - pIMinstance->displayUICtrlBBoxs(DebugUIFilter); - if(DebugUIGroup) - pIMinstance->displayUIGroupBBoxs(DebugUIFilter); - } + + if(ShowInterface) + pIMinstance->updateFrameViews (MainCam); + if(DebugUIView) + pIMinstance->displayUIViewBBoxs(DebugUIFilter); + if(DebugUICtrl) + pIMinstance->displayUICtrlBBoxs(DebugUIFilter); + if(DebugUIGroup) + pIMinstance->displayUIGroupBBoxs(DebugUIFilter); // special case in OpenGL : all scene has been display in render target, // now, final texture is display with a quad @@ -1901,60 +1896,58 @@ bool mainLoop() { H_AUTO_USE ( RZ_Client_Main_Loop_Debug ) - if (!Driver->isLost()) + + // If show information is Active. + if(ShowInfos == 1) + displayDebug(); + + // If show information is Active. + if(ShowInfos == 2) + displayNetDebug(); + + // If show information is Active. + if(ShowInfos == 4) + displayDebugFps(); + + // If show information is Active. + if(ShowInfos == 5) + displayDebugUIUnderMouse(); + + // If show information is Active. + displayStreamingDebug(); + + // If Show Help is active -> Display an help. + if(ShowHelp) + displayHelp(); + + // Yoyo: indicate profiling state + if( Profiling ) + displaySpecialTextProgress("Profiling"); + + // Display frame rate + + // Create a shadow when displaying a text. + TextContext->setShaded(true); + TextContext->setShadeOutline(false); + // Set the font size. + TextContext->setFontSize(10); + // Set the text color + TextContext->setColor(CRGBA(255,255,255)); + + // temporary values for conversions + float x, y, width, height; + + for(uint i = 0; i < ClientCfg.Logos.size(); i++) { - // If show information is Active. - if(ShowInfos == 1) - displayDebug(); - - // If show information is Active. - if(ShowInfos == 2) - displayNetDebug(); - - // If show information is Active. - if(ShowInfos == 4) - displayDebugFps(); - - // If show information is Active. - if(ShowInfos == 5) - displayDebugUIUnderMouse(); - - // If show information is Active. - displayStreamingDebug(); - - // If Show Help is active -> Display an help. - if(ShowHelp) - displayHelp(); - - // Yoyo: indicate profiling state - if( Profiling ) - displaySpecialTextProgress("Profiling"); - - // Display frame rate - - // Create a shadow when displaying a text. - TextContext->setShaded(true); - TextContext->setShadeOutline(false); - // Set the font size. - TextContext->setFontSize(10); - // Set the text color - TextContext->setColor(CRGBA(255,255,255)); - - // temporary values for conversions - float x, y, width, height; - - for(uint i = 0; i < ClientCfg.Logos.size(); i++) + std::vector res; + explode(ClientCfg.Logos[i],std::string(":"), res); + if(res.size()==9 && i res; - explode(ClientCfg.Logos[i],std::string(":"), res); - if(res.size()==9 && idrawBitmap(x/(float)ClientCfg.Width, y/(float)ClientCfg.Height, width/(float)ClientCfg.Width, height/(float)ClientCfg.Height, *LogoBitmaps[i]); - } + fromString(res[5], x); + fromString(res[6], y); + fromString(res[7], width); + fromString(res[8], height); + Driver->drawBitmap(x/(float)ClientCfg.Width, y/(float)ClientCfg.Height, width/(float)ClientCfg.Width, height/(float)ClientCfg.Height, *LogoBitmaps[i]); } } } @@ -2143,10 +2136,7 @@ bool mainLoop() // Ctrl-AltGR-Z show timed FXs if (ShowTimedFX) { - if (!Driver->isLost()) - { - CTimedFXManager::getInstance().displayFXBoxes(ShowTimedFXMode); - } + CTimedFXManager::getInstance().displayFXBoxes(ShowTimedFXMode); } #if !FINAL_VERSION @@ -2295,13 +2285,6 @@ bool mainLoop() WantProfiling = true; } } - - // If the device is lost then no rendering will occur, so let some time to other applications - if (Driver->isLost()) - { - nlSleep(50); - nldebug("lost device"); - } } else { diff --git a/code/ryzom/client/src/seven_zip/LzFind.cpp b/code/ryzom/client/src/seven_zip/LzFind.cpp index 2d05fa395..2c8ca7f26 100644 --- a/code/ryzom/client/src/seven_zip/LzFind.cpp +++ b/code/ryzom/client/src/seven_zip/LzFind.cpp @@ -18,11 +18,8 @@ static void LzInWindow_Free(CMatchFinder *p, ISzAlloc *alloc) { - if (!p->directInput) - { alloc->Free(alloc, p->bufferBase); p->bufferBase = NULL; - } } /* keepSizeBefore + keepSizeAfter + keepSizeReserv must be < 4G) */ @@ -30,11 +27,6 @@ static void LzInWindow_Free(CMatchFinder *p, ISzAlloc *alloc) static int LzInWindow_Create(CMatchFinder *p, UInt32 keepSizeReserv, ISzAlloc *alloc) { UInt32 blockSize = p->keepSizeBefore + p->keepSizeAfter + keepSizeReserv; - if (p->directInput) - { - p->blockSize = blockSize; - return 1; - } if (!p->bufferBase || p->blockSize != blockSize) { LzInWindow_Free(p, alloc); @@ -62,18 +54,6 @@ static void MatchFinder_ReadBlock(CMatchFinder *p) /* We use (p->streamPos - p->pos) value. (p->streamPos < p->pos) is allowed. */ - if (p->directInput) - { - UInt32 curSize = 0xFFFFFFFF - (p->streamPos - p->pos); - if (curSize > p->directInputRem) - curSize = (UInt32)p->directInputRem; - p->directInputRem -= curSize; - p->streamPos += curSize; - if (p->directInputRem == 0) - p->streamEndWasReached = 1; - return; - } - for (;;) { Byte *dest = p->buffer + (p->streamPos - p->pos); @@ -105,8 +85,6 @@ void MatchFinder_MoveBlock(CMatchFinder *p) int MatchFinder_NeedMove(CMatchFinder *p) { - if (p->directInput) - return 0; /* if (p->streamEndWasReached) return 0; */ return ((size_t)(p->bufferBase + p->blockSize - p->buffer) <= p->keepSizeAfter); } @@ -140,7 +118,6 @@ void MatchFinder_Construct(CMatchFinder *p) { UInt32 i; p->bufferBase = NULL; - p->directInput = 0; p->hash = NULL; MatchFinder_SetDefaultSettings(p); @@ -179,24 +156,24 @@ int MatchFinder_Create(CMatchFinder *p, UInt32 historySize, ISzAlloc *alloc) { UInt32 sizeReserv; - + if (historySize > kMaxHistorySize) { MatchFinder_Free(p, alloc); return 0; } - + sizeReserv = historySize >> 1; if (historySize >= ((UInt32)3 << 30)) sizeReserv = historySize >> 3; else if (historySize >= ((UInt32)2 << 30)) sizeReserv = historySize >> 2; - + sizeReserv += (keepAddBufferBefore + matchMaxLen + keepAddBufferAfter) / 2 + (1 << 19); p->keepSizeBefore = historySize + keepAddBufferBefore + 1; p->keepSizeAfter = matchMaxLen + keepAddBufferAfter; - + /* we need one additional byte, since we use MoveBlock after pos++ and before dictionary using */ - + if (LzInWindow_Create(p, sizeReserv, alloc)) { UInt32 newCyclicBufferSize = historySize + 1; @@ -238,7 +215,7 @@ int MatchFinder_Create(CMatchFinder *p, UInt32 historySize, p->historySize = historySize; p->hashSizeSum = hs; p->cyclicBufferSize = newCyclicBufferSize; - + numSons = newCyclicBufferSize; if (p->btMode) numSons <<= 1; @@ -246,11 +223,11 @@ int MatchFinder_Create(CMatchFinder *p, UInt32 historySize, if (p->hash && p->numRefs == newSize) return 1; - + MatchFinder_FreeThisClassMemory(p, alloc); p->numRefs = newSize; p->hash = AllocRefs(newSize, alloc); - + if (p->hash) { p->son = p->hash + p->hashSizeSum; @@ -267,11 +244,11 @@ static void MatchFinder_SetLimits(CMatchFinder *p) { UInt32 limit = kMaxValForNormalize - p->pos; UInt32 limit2 = p->cyclicBufferSize - p->cyclicBufferPos; - + if (limit2 < limit) limit = limit2; limit2 = p->streamPos - p->pos; - + if (limit2 <= p->keepSizeAfter) { if (limit2 > 0) @@ -279,10 +256,10 @@ static void MatchFinder_SetLimits(CMatchFinder *p) } else limit2 -= p->keepSizeAfter; - + if (limit2 < limit) limit = limit2; - + { UInt32 lenLimit = p->streamPos - p->pos; if (lenLimit > p->matchMaxLen) @@ -299,16 +276,16 @@ void MatchFinder_Init_2(CMatchFinder *p, int readData) UInt32 num = p->hashSizeSum; for (i = 0; i < num; i++) hash[i] = kEmptyHashValue; - + p->cyclicBufferPos = 0; p->buffer = p->bufferBase; p->pos = p->streamPos = p->cyclicBufferSize; p->result = SZ_OK; p->streamEndWasReached = 0; - + if (readData) MatchFinder_ReadBlock(p); - + MatchFinder_SetLimits(p); } @@ -316,7 +293,7 @@ void MatchFinder_Init(CMatchFinder *p) { MatchFinder_Init_2(p, True); } - + static UInt32 MatchFinder_GetSubValue(CMatchFinder *p) { return (p->pos - p->historySize - 1) & kNormalizeMask; @@ -559,7 +536,7 @@ static UInt32 Bt3_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances) d2 = pos - hash[h2]; curMatch = hash[kFix3HashSize + hv]; - + hash[h2] = pos; hash[kFix3HashSize + hv] = pos; @@ -578,7 +555,7 @@ static UInt32 Bt3_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances) MOVE_POS_RET; } } - + GET_MATCHES_FOOTER(offset, maxLen) } @@ -604,14 +581,14 @@ static UInt32 Bt4_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances) maxLen = 0; offset = 0; - + if (d2 < p->cyclicBufferSize && *(cur - d2) == *cur) { distances[0] = maxLen = 2; distances[1] = d2 - 1; offset = 2; } - + if (d2 != d3 && d3 < p->cyclicBufferSize && *(cur - d3) == *cur) { maxLen = 3; @@ -619,7 +596,7 @@ static UInt32 Bt4_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances) offset += 2; d2 = d3; } - + if (offset != 0) { UPDATE_maxLen @@ -630,10 +607,10 @@ static UInt32 Bt4_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances) MOVE_POS_RET; } } - + if (maxLen < 3) maxLen = 3; - + GET_MATCHES_FOOTER(offset, maxLen) } @@ -685,7 +662,7 @@ static UInt32 Bt5_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances) offset = 2; d2 = d3; } - + if (d2 != d4 && d4 < p->cyclicBufferSize && *(cur - d4) == *cur && *(cur - d4 + 3) == *(cur + 3)) @@ -695,7 +672,7 @@ static UInt32 Bt5_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances) offset += 2; d2 = d4; } - + if (offset != 0) { UPDATE_maxLen @@ -709,7 +686,7 @@ static UInt32 Bt5_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances) if (maxLen < 4) maxLen = 4; - + GET_MATCHES_FOOTER(offset, maxLen) } */ @@ -724,10 +701,10 @@ static UInt32 Hc4_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances) hash = p->hash; pos = p->pos; - + d2 = pos - hash[ h2]; d3 = pos - hash[kFix3HashSize + h3]; - + curMatch = hash[kFix4HashSize + hv]; hash[ h2] = pos; @@ -743,7 +720,7 @@ static UInt32 Hc4_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances) distances[1] = d2 - 1; offset = 2; } - + if (d2 != d3 && d3 < p->cyclicBufferSize && *(cur - d3) == *cur) { maxLen = 3; @@ -751,7 +728,7 @@ static UInt32 Hc4_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances) offset += 2; d2 = d3; } - + if (offset != 0) { UPDATE_maxLen @@ -762,7 +739,7 @@ static UInt32 Hc4_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances) MOVE_POS_RET; } } - + if (maxLen < 3) maxLen = 3; @@ -782,7 +759,7 @@ static UInt32 Hc5_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances) hash = p->hash; pos = p->pos; - + d2 = pos - hash[ h2]; d3 = pos - hash[kFix3HashSize + h3]; d4 = pos - hash[kFix4HashSize + h4]; @@ -819,7 +796,7 @@ static UInt32 Hc5_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances) offset = 2; d2 = d3; } - + if (d2 != d4 && d4 < p->cyclicBufferSize && *(cur - d4) == *cur && *(cur - d4 + 3) == *(cur + 3)) @@ -829,7 +806,7 @@ static UInt32 Hc5_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances) offset += 2; d2 = d4; } - + if (offset != 0) { UPDATE_maxLen @@ -840,7 +817,7 @@ static UInt32 Hc5_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances) MOVE_POS_RET; } } - + if (maxLen < 4) maxLen = 4; diff --git a/code/ryzom/client/src/seven_zip/LzFind.h b/code/ryzom/client/src/seven_zip/LzFind.h index d119944f4..27c574d3e 100644 --- a/code/ryzom/client/src/seven_zip/LzFind.h +++ b/code/ryzom/client/src/seven_zip/LzFind.h @@ -24,7 +24,6 @@ typedef struct _CMatchFinder Byte streamEndWasReached; Byte btMode; Byte bigHash; - Byte directInput; UInt32 matchMaxLen; CLzRef *hash; @@ -34,13 +33,12 @@ typedef struct _CMatchFinder Byte *bufferBase; ISeqInStream *stream; - + UInt32 blockSize; UInt32 keepSizeBefore; UInt32 keepSizeAfter; UInt32 numHashBytes; - size_t directInputRem; UInt32 historySize; UInt32 fixedHashSize; UInt32 hashSizeSum; @@ -55,9 +53,8 @@ typedef struct _CMatchFinder #define Inline_MatchFinder_IsFinishedOK(p) \ ((p)->streamEndWasReached \ - && (p)->streamPos == (p)->pos \ - && (!(p)->directInput || (p)->directInputRem == 0)) - + && (p)->streamPos == (p)->pos) + int MatchFinder_NeedMove(CMatchFinder *p); Byte *MatchFinder_GetPointerToCurrentPos(CMatchFinder *p); void MatchFinder_MoveBlock(CMatchFinder *p); diff --git a/code/ryzom/client/src/seven_zip/LzmaEnc.cpp b/code/ryzom/client/src/seven_zip/LzmaEnc.cpp index 0845691cf..17689eb47 100644 --- a/code/ryzom/client/src/seven_zip/LzmaEnc.cpp +++ b/code/ryzom/client/src/seven_zip/LzmaEnc.cpp @@ -63,7 +63,7 @@ void LzmaEncProps_Normalize(CLzmaEncProps *p) int level = p->level; if (level < 0) level = 5; p->level = level; - + if (p->dictSize == 0) p->dictSize = (level <= 5 ? (1 << (level * 2 + 14)) : (level == 6 ? (1 << 25) : (1 << 26))); if (p->dictSize > p->reduceSize) { @@ -84,7 +84,7 @@ void LzmaEncProps_Normalize(CLzmaEncProps *p) if (p->btMode < 0) p->btMode = (p->algo == 0 ? 0 : 1); if (p->numHashBytes < 0) p->numHashBytes = 4; if (p->mc == 0) p->mc = (16 + (p->fb >> 1)) >> (p->btMode ? 0 : 1); - + if (p->numThreads < 0) p->numThreads = #ifndef _7ZIP_ST @@ -134,7 +134,7 @@ static void LzmaEnc_FastPosInit(Byte *g_FastPos) g_FastPos[0] = 0; g_FastPos[1] = 1; g_FastPos += 2; - + for (slot = 2; slot < kNumLogBits * 2; slot++) { size_t k = ((size_t)1 << ((slot >> 1) - 1)); @@ -292,7 +292,7 @@ typedef struct CLzmaProb posSlotEncoder[kNumLenToPosStates][1 << kNumPosSlotBits]; CLzmaProb posEncoders[kNumFullDistances - kEndPosModelIndex]; CLzmaProb posAlignEncoder[1 << kNumAlignBits]; - + CLenPriceEnc lenEnc; CLenPriceEnc repLenEnc; } CSaveState; @@ -328,7 +328,7 @@ typedef struct Bool needInit; UInt64 nowPos64; - + UInt32 matchPriceCount; UInt32 alignPriceCount; @@ -349,9 +349,9 @@ typedef struct #ifndef _7ZIP_ST Byte pad[128]; #endif - + COptimal opt[kNumOpts]; - + #ifndef LZMA_LOG_BSR Byte g_FastPos[1 << kNumLogBits]; #endif @@ -373,7 +373,7 @@ typedef struct CLzmaProb posSlotEncoder[kNumLenToPosStates][1 << kNumPosSlotBits]; CLzmaProb posEncoders[kNumFullDistances - kEndPosModelIndex]; CLzmaProb posAlignEncoder[1 << kNumAlignBits]; - + CLenPriceEnc lenEnc; CLenPriceEnc repLenEnc; @@ -858,7 +858,7 @@ static void MovePos(CLzmaEnc *p, UInt32 num) g_STAT_OFFSET += num; printf("\n MovePos %u", num); #endif - + if (num != 0) { p->additionalOffset += num; @@ -871,7 +871,7 @@ static UInt32 ReadMatchDistances(CLzmaEnc *p, UInt32 *numDistancePairsRes) UInt32 lenRes = 0, numPairs; p->numAvail = p->matchFinder.GetNumAvailableBytes(p->matchFinderObj); numPairs = p->matchFinder.GetMatches(p->matchFinderObj, p->matches); - + #ifdef SHOW_STAT printf("\n i = %u numPairs = %u ", g_STAT_OFFSET, numPairs / 2); g_STAT_OFFSET++; @@ -881,7 +881,7 @@ static UInt32 ReadMatchDistances(CLzmaEnc *p, UInt32 *numDistancePairsRes) printf("%2u %6u | ", p->matches[i], p->matches[i + 1]); } #endif - + if (numPairs > 0) { lenRes = p->matches[numPairs - 2]; @@ -966,10 +966,10 @@ static UInt32 Backward(CLzmaEnc *p, UInt32 *backRes, UInt32 cur) { UInt32 posPrev = posMem; UInt32 backCur = backMem; - + backMem = p->opt[posPrev].backPrev; posMem = p->opt[posPrev].posPrev; - + p->opt[posPrev].backPrev = backCur; p->opt[posPrev].posPrev = cur; cur = posPrev; @@ -1005,7 +1005,7 @@ static UInt32 GetOptimum(CLzmaEnc *p, UInt32 position, UInt32 *backRes) return lenRes; } p->optimumCurrentIndex = p->optimumEndIndex = 0; - + if (p->additionalOffset == 0) mainLen = ReadMatchDistances(p, &numPairs); else @@ -1306,7 +1306,7 @@ static UInt32 GetOptimum(CLzmaEnc *p, UInt32 position, UInt32 *backRes) matchPrice = curPrice + GET_PRICE_1(p->isMatch[state][posState]); repMatchPrice = matchPrice + GET_PRICE_1(p->isRep[state]); - + if (matchByte == curByte && !(nextOpt->posPrev < cur && nextOpt->backPrev == 0)) { UInt32 shortRepPrice = repMatchPrice + GetRepLen1Price(p, state, posState); @@ -1368,7 +1368,7 @@ static UInt32 GetOptimum(CLzmaEnc *p, UInt32 position, UInt32 *backRes) } } } - + startLen = 2; /* speed optimization */ { UInt32 repIndex; @@ -1399,10 +1399,10 @@ static UInt32 GetOptimum(CLzmaEnc *p, UInt32 position, UInt32 *backRes) } while (--lenTest >= 2); lenTest = lenTestTemp; - + if (repIndex == 0) startLen = lenTest + 1; - + /* if (_maxMode) */ { UInt32 lenTest2 = lenTest + 1; @@ -1426,7 +1426,7 @@ static UInt32 GetOptimum(CLzmaEnc *p, UInt32 position, UInt32 *backRes) nextRepMatchPrice = curAndLenCharPrice + GET_PRICE_1(p->isMatch[state2][posStateNext]) + GET_PRICE_1(p->isRep[state2]); - + /* for (; lenTest2 >= 2; lenTest2--) */ { UInt32 curAndLenPrice; @@ -1482,7 +1482,7 @@ static UInt32 GetOptimum(CLzmaEnc *p, UInt32 position, UInt32 *backRes) curAndLenPrice += p->distancesPrices[lenToPosState][curBack]; else curAndLenPrice += p->posSlotPrices[lenToPosState][posSlot] + p->alignPrices[curBack & kAlignMask]; - + opt = &p->opt[cur + lenTest]; if (curAndLenPrice < opt->price) { @@ -1517,7 +1517,7 @@ static UInt32 GetOptimum(CLzmaEnc *p, UInt32 position, UInt32 *backRes) nextRepMatchPrice = curAndLenCharPrice + GET_PRICE_1(p->isMatch[state2][posStateNext]) + GET_PRICE_1(p->isRep[state2]); - + /* for (; lenTest2 >= 2; lenTest2--) */ { UInt32 offset = cur + lenTest + 1 + lenTest2; @@ -1629,7 +1629,7 @@ static UInt32 GetOptimumFast(CLzmaEnc *p, UInt32 *backRes) MovePos(p, repLen - 1); return repLen; } - + if (mainLen < 2 || numAvail <= 2) return 1; @@ -1643,7 +1643,7 @@ static UInt32 GetOptimumFast(CLzmaEnc *p, UInt32 *backRes) (p->longestMatchLength + 1 >= mainLen && mainLen >= 3 && ChangePair(newDistance, mainDist))) return 1; } - + data = p->matchFinder.GetPointerToCurrentPos(p->matchFinderObj) - 1; for (i = 0; i < LZMA_NUM_REPS; i++) { @@ -1743,7 +1743,7 @@ void LzmaEnc_Construct(CLzmaEnc *p) { RangeEnc_Construct(&p->rc); MatchFinder_Construct(&p->matchFinderBase); - + #ifndef _7ZIP_ST MatchFinderMt_Construct(&p->matchFinderMt); p->matchFinderMt.MatchFinder = &p->matchFinderBase; @@ -1786,7 +1786,7 @@ void LzmaEnc_Destruct(CLzmaEnc *p, ISzAlloc *alloc, ISzAlloc *allocBig) #ifndef _7ZIP_ST MatchFinderMt_Destruct(&p->matchFinderMt, allocBig); #endif - + MatchFinder_Free(&p->matchFinderBase, allocBig); LzmaEnc_FreeLits(p, alloc); RangeEnc_Free(&p->rc, alloc); @@ -1905,7 +1905,7 @@ static SRes LzmaEnc_CodeOneBlock(CLzmaEnc *p, Bool useLimits, UInt32 maxPackSize pos -= LZMA_NUM_REPS; GetPosSlot(pos, posSlot); RcTree_Encode(&p->rc, p->posSlotEncoder[GetLenToPosState(len)], kNumPosSlotBits, posSlot); - + if (posSlot >= kStartPosModelIndex) { UInt32 footerBits = ((posSlot >> 1) - 1); @@ -2008,7 +2008,7 @@ static SRes LzmaEnc_Alloc(CLzmaEnc *p, UInt32 keepWindowSize, ISzAlloc *alloc, I p->matchFinderObj = &p->matchFinderBase; MatchFinder_CreateVTable(&p->matchFinderBase, &p->matchFinder); } - + return SZ_OK; } @@ -2125,9 +2125,7 @@ SRes LzmaEnc_PrepareForLzma2(CLzmaEncHandle pp, static void LzmaEnc_SetInputBuf(CLzmaEnc *p, const Byte *src, SizeT srcLen) { - p->matchFinderBase.directInput = 1; p->matchFinderBase.bufferBase = (Byte *)src; - p->matchFinderBase.directInputRem = srcLen; } SRes LzmaEnc_MemPrepare(CLzmaEncHandle pp, const Byte *src, SizeT srcLen, @@ -2214,7 +2212,7 @@ SRes LzmaEnc_CodeOneMemBlock(CLzmaEncHandle pp, Bool reInit, p->rc.outStream = &outStream.funcTable; res = LzmaEnc_CodeOneBlock(p, True, desiredPackSize, *unpackSize); - + *unpackSize = (UInt32)(p->nowPos64 - nowPos64); *destLen -= outStream.rem; if (outStream.overflow) @@ -2249,7 +2247,7 @@ static SRes LzmaEnc_Encode2(CLzmaEnc *p, ICompressProgress *progress) } } } - + LzmaEnc_Finish(p); /* @@ -2315,7 +2313,7 @@ SRes LzmaEnc_MemEncode(CLzmaEncHandle pp, Byte *dest, SizeT *destLen, const Byte p->rc.outStream = &outStream.funcTable; res = LzmaEnc_MemPrepare(pp, src, srcLen, 0, alloc, allocBig); - + if (res == SZ_OK) { res = LzmaEnc_Encode2(p, progress); diff --git a/code/ryzom/client/src/sound_manager.cpp b/code/ryzom/client/src/sound_manager.cpp index 8a91c81ff..102c72212 100644 --- a/code/ryzom/client/src/sound_manager.cpp +++ b/code/ryzom/client/src/sound_manager.cpp @@ -468,10 +468,6 @@ void CSoundManager::init(IProgressCallback *progressCallBack) driverType= UAudioMixer::DriverFMod; else if(ClientCfg.DriverSound==CClientConfig::SoundDrvOpenAL) driverType= UAudioMixer::DriverOpenAl; - else if(ClientCfg.DriverSound==CClientConfig::SoundDrvDirectSound) - driverType= UAudioMixer::DriverDSound; - else if(ClientCfg.DriverSound==CClientConfig::SoundDrvXAudio2) - driverType= UAudioMixer::DriverXAudio2; _AudioMixer->init(ClientCfg.MaxTrack, ClientCfg.UseEax, ClientCfg.UseADPCM, progressCallBack, false, driverType, ClientCfg.SoundForceSoftwareBuffer); /* int nbVoice = _AudioMixer->getPolyphony(); _AudioMixer->setPriorityReserve(HighPri, max(1, nbVoice /2)); @@ -844,7 +840,7 @@ void CSoundManager::removeEntity( const CEntityId &id) TMultiMapEntityToSource::iterator it; const std::pair range = _AttachedSources.equal_range( id ); - + for ( it = range.first; it != range.second ; ++it) { TSourceId sourceId = (*it).second; @@ -1162,7 +1158,7 @@ void CSoundManager::playPositionedSounds( const CVector& /* pos */ ) { nlwarning(" : The source %d is unknown",*itPSnd); } - else + else { /* if( (pos - (*itSrc).second.getPos()).norm() < ...) diff --git a/code/ryzom/tools/client/client_config/StdAfx.h b/code/ryzom/tools/client/client_config/StdAfx.h index ae8b23f92..97f4fc161 100644 --- a/code/ryzom/tools/client/client_config/StdAfx.h +++ b/code/ryzom/tools/client/client_config/StdAfx.h @@ -42,7 +42,6 @@ #undef max #include -#include #include "nel/misc/config_file.h" #include "nel/misc/system_info.h" diff --git a/code/ryzom/tools/client/client_config/cfg_file.cpp b/code/ryzom/tools/client/client_config/cfg_file.cpp index 8d66ff4f9..cf7c591aa 100644 --- a/code/ryzom/tools/client/client_config/cfg_file.cpp +++ b/code/ryzom/tools/client/client_config/cfg_file.cpp @@ -130,7 +130,7 @@ void SetString (const char *var, const char *value) else { theApp.error ("The variable "+(ucstring)var+" is not a string "CONFIG_FILE_NAME); - } + } } else { @@ -157,7 +157,7 @@ void SetBool (const char *var, bool value) else { theApp.error ("The variable "+(ucstring)var+" is not a string "CONFIG_FILE_NAME); - } + } } else { @@ -245,7 +245,6 @@ void SetToConfigFile () SetInt ("FullScreen", !display.Windowed); switch(display.DriverChoiceMode) { - case CDisplayDlg::DrvChooseDirect3D: SetString("Driver3D", "Direct3D"); break; case CDisplayDlg::DrvChooseOpenGL: SetString("Driver3D", "OpenGL"); break; case CDisplayDlg::DrvChooseAuto: SetString("Driver3D", "Auto"); break; } @@ -257,7 +256,7 @@ void SetToConfigFile () } else { - // Mode valid ? + // Mode valid ? if (display.DriverChoiceMode != CDisplayDlg::DrvChooseUnknwown) { const CVideoMode &videoMode = VideoModes[display.getActualDriver()][display.Mode]; @@ -357,8 +356,7 @@ void GetFromConfigFile () display.PositionY = GetInt ("PositionY"); std::string driverMode = GetString("Driver3D"); if (nlstricmp(driverMode, "Auto") == 0 || nlstricmp(driverMode, "0") == 0) display.DriverChoiceMode = CDisplayDlg::DrvChooseAuto; - else if (nlstricmp(driverMode, "OpenGL") == 0 || nlstricmp(driverMode, "1") == 0) display.DriverChoiceMode = CDisplayDlg::DrvChooseOpenGL; - else if (nlstricmp(driverMode, "Direct3D") == 0 || nlstricmp(driverMode, "2") == 0) display.DriverChoiceMode = CDisplayDlg::DrvChooseDirect3D; + else if (nlstricmp(driverMode, "OpenGL") == 0 || nlstricmp(driverMode, "1") == 0) display.DriverChoiceMode = CDisplayDlg::DrvChooseOpenGL; else display.DriverChoiceMode = CDisplayDlg::DrvChooseAuto; display.Mode = -1; // The video mode @@ -387,7 +385,7 @@ void GetFromConfigFile () mode.Height = 768; mode.ColorDepth = 32; mode.Frequency = 60; - + display.updateState (); display.UpdateData (FALSE); @@ -588,7 +586,7 @@ void ResetConfigFileToDefault () { // Get the destination variable CConfigFile::CVar *dest = ConfigFile.getVar (i); - + // Temp: avoid changing this variable (debug: binded to the actual texture set installed) if(dest->Name=="HDTextureInstalled") continue; @@ -597,7 +595,7 @@ void ResetConfigFileToDefault () CConfigFile::CVar *src = ConfigFileDefault.getVarPtr (dest->Name); // if default exist and cur not already default - if ( src && !dest->Root && + if ( src && !dest->Root && ((src->Type == CConfigFile::CVar::T_INT) && (dest->Type == CConfigFile::CVar::T_INT) || (src->Type == CConfigFile::CVar::T_REAL) && (dest->Type == CConfigFile::CVar::T_INT) || (src->Type == CConfigFile::CVar::T_INT) && (dest->Type == CConfigFile::CVar::T_REAL) || @@ -658,7 +656,7 @@ void localizeWindowsRec (CWnd *cwnd, bool useMap) std::map::iterator ite = HwndMap.find (*cwnd); if (ite != HwndMap.end()) { - ucstring ucName = CI18N::get (ite->second); + ucstring ucName = CI18N::get (ite->second); setWindowText(ite->first, (WCHAR*)ucName.c_str()); } } @@ -685,7 +683,7 @@ std::string GetStringDriverSound() { // Get the variable pointer CConfigFile::CVar *variable = ConfigFile.getVarPtr ("DriverSound"); - + // Available ? if (variable) return variable->asString (); @@ -699,7 +697,7 @@ sint GetIntForceLanguage() { // Get the variable pointer CConfigFile::CVar *variable = ConfigFile.getVarPtr ("ForceLanguage"); - + // Available ? if (variable) return variable->asInt (); @@ -713,7 +711,7 @@ sint GetIntTestConfig() { // Get the variable pointer CConfigFile::CVar *variable = ConfigFile.getVarPtr ("TestConfig"); - + // Available ? if (variable) return variable->asInt (); @@ -727,7 +725,7 @@ void SetStringDriverSound(const char *value) { // Get the variable pointer CConfigFile::CVar *variable = ConfigFile.getVarPtr ("DriverSound"); - + // Available ? if (variable) { @@ -739,11 +737,10 @@ void SetStringDriverSound(const char *value) else { theApp.error (ucstring("The variable DriverSound is not a string "CONFIG_FILE_NAME)); - } + } } else { // no op (FMod should be forced) } } - diff --git a/code/ryzom/tools/client/client_config/client_config.cpp b/code/ryzom/tools/client/client_config/client_config.cpp index da434171a..0561de174 100644 --- a/code/ryzom/tools/client/client_config/client_config.cpp +++ b/code/ryzom/tools/client/client_config/client_config.cpp @@ -79,7 +79,7 @@ class CMyCommandLineInfo : public CCommandLineInfo if ((strnicmp (lpszParam, "hwsb", 4) == 0) && bFlag) HardwareSoundBuffer = atoi (lpszParam+4); if ((strcmp (lpszParam, "?") == 0) && bFlag) - MessageBoxW(NULL, + MessageBoxW(NULL, "\t/gpuGPUNAME\t\tSet GPU name to GPUNAME\n" "\t/cpuCPUFREQUENCY\t\tSet CPU frequency to CPUFREQENCY\n" "\t/ramAMOUNTRAM\t\tSet the amount of ram to AMOUNTRAM\n" @@ -117,7 +117,7 @@ INT_PTR CALLBACK MyDialogProc( BOOL CClientConfigApp::InitInstance() { HANDLE mutex = CreateMutex (NULL, false, "RyzomConfig"); - if (mutex && GetLastError() == ERROR_ALREADY_EXISTS) + if (mutex && GetLastError() == ERROR_ALREADY_EXISTS) exit (0); // Get the bitmap size @@ -147,12 +147,9 @@ BOOL CClientConfigApp::InitInstance() // Create drivers IDriver *glDriver = CDRU::createGlDriver(); - IDriver *d3dDriver = CDRU::createD3DDriver(); // Get some information about the system RegisterVideoModes (0, glDriver); - RegisterVideoModes (1, d3dDriver); - GetSystemInformation (d3dDriver); // Load the config file if (!LoadConfigFile ()) @@ -261,15 +258,14 @@ CString GetString (uint res) // *************************************************************************** void setWindowText(HWND hwnd, LPCWSTR lpText) -{ +{ if (CSystemUtils::supportUnicode()) { SetWindowTextW(hwnd, lpText); } else { - ucstring text((const ucchar *) lpText); + ucstring text((const ucchar *) lpText); SetWindowTextA(hwnd, (LPCTSTR) text.toString().c_str()); - } + } } - diff --git a/code/ryzom/tools/client/client_config/client_config.rc b/code/ryzom/tools/client/client_config/client_config.rc index dc0ccfd39..c8e5e8efe 100644 --- a/code/ryzom/tools/client/client_config/client_config.rc +++ b/code/ryzom/tools/client/client_config/client_config.rc @@ -27,18 +27,18 @@ LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US // TEXTINCLUDE // -1 TEXTINCLUDE DISCARDABLE +1 TEXTINCLUDE DISCARDABLE BEGIN "resource.h\0" END -2 TEXTINCLUDE DISCARDABLE +2 TEXTINCLUDE DISCARDABLE BEGIN "#include ""afxres.h""\r\n" "\0" END -3 TEXTINCLUDE DISCARDABLE +3 TEXTINCLUDE DISCARDABLE BEGIN "#define _AFX_NO_SPLITTER_RESOURCES\r\n" "#define _AFX_NO_OLE_RESOURCES\r\n" @@ -95,10 +95,10 @@ FONT 8, "MS Sans Serif" BEGIN CONTROL "uiConfigSaveConfig",IDC_SAVE_CONFIG,"Button", BS_AUTOCHECKBOX | WS_TABSTOP,7,41,181,10 - CONTROL "uiConfigSlowDown",IDC_SLEEP,"Button",BS_AUTOCHECKBOX | + CONTROL "uiConfigSlowDown",IDC_SLEEP,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,20,245,224,10 GROUPBOX "uiConfigAdvanced",IDC_STATIC,5,230,270,30 - COMBOBOX IDC_LANGUAGE,7,17,95,110,CBS_DROPDOWNLIST | WS_VSCROLL | + COMBOBOX IDC_LANGUAGE,7,17,95,110,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP LTEXT "uiConfigLanguage",IDC_DISPLAY_FS_TEXT0,7,7,68,10 END @@ -111,13 +111,11 @@ BEGIN BS_AUTORADIOBUTTON | WS_GROUP,20,34,90,10 CONTROL "uiConfigOpenGL",IDC_OPENGL,"Button",BS_AUTORADIOBUTTON, 20,46,90,10 - CONTROL "uiConfigDirect3D",IDC_DIRECT3D,"Button", - BS_AUTORADIOBUTTON,20,58,115,10 CONTROL "uiConfigFullscreen",IDC_FULLSCREEN,"Button", BS_AUTORADIOBUTTON | WS_GROUP,20,105,90,10 CONTROL "uiConfigWindowed",IDC_WINDOW,"Button", BS_AUTORADIOBUTTON,20,150,70,10 - COMBOBOX IDC_MODE,40,130,95,110,CBS_DROPDOWNLIST | CBS_SORT | + COMBOBOX IDC_MODE,40,130,95,110,CBS_DROPDOWNLIST | CBS_SORT | WS_VSCROLL | WS_TABSTOP EDITTEXT IDC_WIDTH,85,165,50,12,ES_AUTOHSCROLL EDITTEXT IDC_HEIGHT,85,185,50,12,ES_AUTOHSCROLL @@ -125,7 +123,6 @@ BEGIN EDITTEXT IDC_POSITION_Y,85,225,50,12,ES_AUTOHSCROLL LTEXT "uiConfigWindowedOrFullscreen",IDC_STATIC,20,90,235,10 LTEXT "uiConfigVideoMode",IDC_DISPLAY_FS_TEXT0,40,120,145,10 - LTEXT "uiConfigOpenGLOrD3D",IDC_STATIC,20,20,245,10 GROUPBOX "uiConfigDriver",IDC_STATIC,5,5,270,65 GROUPBOX "uiConfigParameters",IDC_STATIC,5,75,270,185 LTEXT "uiConfigWidth",IDC_DISPLAY_WND_TEXT0,40,165,25,12, @@ -155,7 +152,7 @@ BEGIN CONTROL "",IDC_FMOD,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,70,90, 181,10 LTEXT "uiConfigEnableFMod",IDC_SOUND_TEXT_FMOD,5,90,55,15 - CONTROL "",IDC_FORCESOUNDSOFT,"Button",BS_AUTOCHECKBOX | + CONTROL "",IDC_FORCESOUNDSOFT,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,70,45,181,10 LTEXT "uiConfigSoundForceSoftware",IDC_SOUND_TEXT_FORCESOFT,5, 45,55,15 @@ -201,7 +198,7 @@ BEGIN CONTROL "uiConfigDisableAGP",IDC_DISABLE_AGP_VERTICES,"Button", BS_AUTOCHECKBOX | WS_TABSTOP,5,55,160,10 CONTROL "uiConfigDisableTextureShader", - IDC_DISABLE_TEXTURE_SHADERS,"Button",BS_AUTOCHECKBOX | + IDC_DISABLE_TEXTURE_SHADERS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,5,70,160,10 LTEXT "uiConfigAdvancedComment",IDC_STATIC,5,5,255,15 END @@ -217,8 +214,8 @@ BEGIN LTEXT "",IDC_GL_RENDERER,80,35,190,10 LTEXT "uiConfigVersion",IDC_STATIC,15,50,55,10 LTEXT "",IDC_GL_VERSION,80,50,185,10 - LISTBOX IDC_EXTENSION,15,80,170,170,LBS_SORT | - LBS_NOINTEGRALHEIGHT | LBS_NOSEL | WS_VSCROLL | + LISTBOX IDC_EXTENSION,15,80,170,170,LBS_SORT | + LBS_NOINTEGRALHEIGHT | LBS_NOSEL | WS_VSCROLL | WS_TABSTOP LTEXT "uiConfigExtensions",IDC_STATIC,15,70,40,10 END @@ -233,7 +230,7 @@ BEGIN LTEXT "CPU frequency :",IDC_STATIC,20,65,115,12,SS_CENTERIMAGE LTEXT "",IDC_CPU_FREQUENCY,135,65,135,12,SS_CENTERIMAGE LTEXT "Video card :",IDC_STATIC,20,80,115,12,SS_CENTERIMAGE - COMBOBOX IDC_VIDEO_CARD,135,80,130,215,CBS_DROPDOWNLIST | + COMBOBOX IDC_VIDEO_CARD,135,80,130,215,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP LTEXT "Video memory :",IDC_STATIC,20,95,115,12,SS_CENTERIMAGE DEFPUSHBUTTON "&OK",IDOK,175,140,50,14 @@ -248,19 +245,6 @@ BEGIN IDC_STATIC,5,5,275,25 END -IDD_DISPLAY_D3D DIALOG DISCARDABLE 0, 0, 283, 268 -STYLE WS_CHILD -FONT 8, "MS Sans Serif" -BEGIN - GROUPBOX "uiConfigDirect3D",IDC_STATIC,5,5,270,255 - LTEXT "uiConfigDescription",IDC_STATIC,15,20,55,10 - LTEXT "",IDC_D3D_DESCRIPTION,80,20,185,10 - LTEXT "uiConfigDriverDesc",IDC_STATIC,15,35,55,10 - LTEXT "",IDC_D3D_DRIVER,80,35,190,10 - LTEXT "uiConfigDriverVersion",IDC_STATIC,15,50,54,10 - LTEXT "",IDC_D3D_DRIVER_VERSION,80,50,185,10 -END - IDD_SYSTEM_INFO DIALOG DISCARDABLE 0, 0, 283, 268 STYLE WS_CHILD FONT 8, "MS Sans Serif" @@ -331,7 +315,7 @@ END // #ifdef APSTUDIO_INVOKED -GUIDELINES DESIGNINFO DISCARDABLE +GUIDELINES DESIGNINFO DISCARDABLE BEGIN IDD_ABOUTBOX, DIALOG BEGIN @@ -405,14 +389,6 @@ BEGIN BOTTOMMARGIN, 154 END - IDD_DISPLAY_D3D, DIALOG - BEGIN - LEFTMARGIN, 7 - RIGHTMARGIN, 276 - TOPMARGIN, 7 - BOTTOMMARGIN, 261 - END - IDD_SYSTEM_INFO, DIALOG BEGIN LEFTMARGIN, 7 @@ -458,11 +434,11 @@ IDR_MAINFRAME ICON DISCARDABLE "res\\client_config.ico" IDD_GENERAL DLGINIT BEGIN IDC_LANGUAGE, 0x403, 8, 0 -0x6e45, 0x6c67, 0x7369, 0x0068, +0x6e45, 0x6c67, 0x7369, 0x0068, IDC_LANGUAGE, 0x403, 9, 0 -0x7246, 0x6e61, 0x61e7, 0x7369, "\000" +0x7246, 0x6e61, 0x61e7, 0x7369, "\000" IDC_LANGUAGE, 0x403, 7, 0 -0x6544, 0x7475, 0x6863, "\000" +0x6544, 0x7475, 0x6863, "\000" 0 END @@ -499,7 +475,7 @@ END // #ifdef APSTUDIO_INVOKED -GUIDELINES DESIGNINFO DISCARDABLE +GUIDELINES DESIGNINFO DISCARDABLE BEGIN IDD_SLASH_SCREEN, DIALOG BEGIN @@ -544,4 +520,3 @@ LANGUAGE 9, 1 ///////////////////////////////////////////////////////////////////////////// #endif // not APSTUDIO_INVOKED - diff --git a/code/ryzom/tools/client/client_config/client_configDlg.cpp b/code/ryzom/tools/client/client_config/client_configDlg.cpp index 28ad963c5..1fe7b1da8 100644 --- a/code/ryzom/tools/client/client_config/client_configDlg.cpp +++ b/code/ryzom/tools/client/client_config/client_configDlg.cpp @@ -124,7 +124,6 @@ CClient_configDlg::CClient_configDlg(CWnd* pParent /*=NULL*/) Dialogs[PageDisplayAdvanced] = &DisplayAdvancedDlg; Dialogs[PageDisplaySysInfo] = &SystemInformationDlg; Dialogs[PageDisplayOpenGLInfo] = &DisplayInformationGLDlg; - Dialogs[PageDisplayOpenD3DInfo] = &DisplayInformationD3DDlg; Dialogs[PageSound] = &SoundDlg; _CurrentPage = 0; } @@ -188,7 +187,7 @@ BOOL CClient_configDlg::OnInitDialog() { Bitmaps[i].LoadBitmap (BitmapId[i].ResId); } - + // Create others controls nlverify (Left.Create (NULL, WS_CHILD|WS_VISIBLE|SS_BITMAP, CRect (0, 0, LEFT_WIDTH, LEFT_HEIGHT), this)); Left.SetBitmap (LoadBitmap (theApp.m_hInstance, MAKEINTRESOURCE (IDB_LEFT_0))); @@ -200,13 +199,13 @@ BOOL CClient_configDlg::OnInitDialog() nlverify (Bottom.Create (CRect (0, LEFT_HEIGHT, LEFT_WIDTH+ICON_ZONE_WIDTH+BAR_WIDTH, LEFT_HEIGHT+1), this)); // Create the tree - nlverify (Tree.Create ( WS_CHILD|WS_VISIBLE|TVS_NOSCROLL|TVS_TRACKSELECT|TVS_HASLINES|TVS_HASBUTTONS|TVS_SHOWSELALWAYS, - CRect (LEFT_WIDTH+TREE_OFFSET_LEFT, BAR_HEIGHT+2+TREE_OFFSET_TOP, + nlverify (Tree.Create ( WS_CHILD|WS_VISIBLE|TVS_NOSCROLL|TVS_TRACKSELECT|TVS_HASLINES|TVS_HASBUTTONS|TVS_SHOWSELALWAYS, + CRect (LEFT_WIDTH+TREE_OFFSET_LEFT, BAR_HEIGHT+2+TREE_OFFSET_TOP, LEFT_WIDTH+TREE_ZONE_WIDTH, BAR_HEIGHT+LEFT_HEIGHT-BAR_HEIGHT), this, TreeId)); Tree.SetFont (GetFont ()); // Create fonts - nlverify (BarFont.CreateFont (LARGE_LABEL_HEIGHT, 0, 0, 0, FW_BOLD, TRUE, FALSE, 0, DEFAULT_CHARSET, OUT_TT_PRECIS, CLIP_DEFAULT_PRECIS, ANTIALIASED_QUALITY, + nlverify (BarFont.CreateFont (LARGE_LABEL_HEIGHT, 0, 0, 0, FW_BOLD, TRUE, FALSE, 0, DEFAULT_CHARSET, OUT_TT_PRECIS, CLIP_DEFAULT_PRECIS, ANTIALIASED_QUALITY, TMPF_TRUETYPE | DEFAULT_PITCH | FF_MODERN, "Arial")); // Create dialog @@ -261,7 +260,7 @@ BOOL CClient_configDlg::OnInitDialog() theApp.Modified = false; - // Build the localisation map + // Build the localisation map backupWindowHandleRec (); // Localize the windows @@ -301,7 +300,7 @@ void CClient_configDlg::changeLanguage (const char *language) if (pSysMenu) { if (NLMISC::CSystemUtils::supportUnicode()) - { + { nlverify (::ModifyMenuW(*pSysMenu, IDM_ABOUTBOX, MF_BYCOMMAND|MF_STRING, IDM_ABOUTBOX, (WCHAR*)NLMISC::CI18N::get ("uiConfigMenuAbout").c_str())); } else @@ -321,9 +320,9 @@ void CClient_configDlg::translateTree () { // Set the item text uint page = (uint)Tree.GetItemData (item); - ucstring name = NLMISC::CI18N::get (Pages[page].Name); - if (NLMISC::CSystemUtils::supportUnicode()) - { + ucstring name = NLMISC::CI18N::get (Pages[page].Name); + if (NLMISC::CSystemUtils::supportUnicode()) + { TVITEMEXW itemDesc; memset (&itemDesc, 0, sizeof(TVITEMEXW)); itemDesc.hItem = item; @@ -338,7 +337,7 @@ void CClient_configDlg::translateTree () itemDesc.hItem = item; itemDesc.mask = TVIF_TEXT; std::string tmpStr = name.toString(); - itemDesc.pszText = (LPSTR) tmpStr.c_str(); + itemDesc.pszText = (LPSTR) tmpStr.c_str(); nlverify (::SendMessageA(Tree, TVM_SETITEMA, 0 , (LPARAM)&itemDesc)); } // Next item @@ -380,7 +379,7 @@ void CClient_configDlg::OnSysCommand(UINT nID, LPARAM lParam) // to draw the icon. For MFC applications using the document/view model, // this is automatically done for you by the framework. -void CClient_configDlg::OnPaint() +void CClient_configDlg::OnPaint() { if (IsIconic()) { @@ -409,7 +408,7 @@ void CClient_configDlg::OnPaint() dc.FillSolidRect( LEFT_WIDTH, 0, ICON_ZONE_WIDTH, BAR_HEIGHT, RGB (255,255,255)); CDC bitmapDC; bitmapDC.CreateCompatibleDC (&dc); - bitmapDC.SelectObject (&Bitmaps[BitmapTopRight]); + bitmapDC.SelectObject (&Bitmaps[BitmapTopRight]); nlverify (dc.BitBlt( LEFT_WIDTH + ICON_ZONE_WIDTH, 0, BAR_WIDTH, BAR_HEIGHT, &bitmapDC, 0, 0, SRCCOPY)); // Draw some text @@ -452,11 +451,11 @@ void CClient_configDlg::setPage (uint pageId) // *************************************************************************** -BOOL CClient_configDlg::OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult) +BOOL CClient_configDlg::OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult) { // TODO: Add your specialized code here and/or call the base class - int idCtrl = (int) wParam; - LPNMHDR pnmh = (LPNMHDR) lParam; + int idCtrl = (int) wParam; + LPNMHDR pnmh = (LPNMHDR) lParam; switch (idCtrl) { @@ -508,7 +507,7 @@ BOOL CClient_configDlg::UpdateData ( BOOL bSaveAndValidate ) // *************************************************************************** -void CClient_configDlg::OnApply() +void CClient_configDlg::OnApply() { // Update config file SetToConfigFile (); @@ -526,7 +525,7 @@ void CClient_configDlg::OnApply() // *************************************************************************** -void CClient_configDlg::OnCancel() +void CClient_configDlg::OnCancel() { // Modified ? if (theApp.Modified) @@ -543,7 +542,7 @@ void CClient_configDlg::OnCancel() // *************************************************************************** -void CClient_configDlg::OnOK() +void CClient_configDlg::OnOK() { if (theApp.Modified) { @@ -556,13 +555,13 @@ void CClient_configDlg::OnOK() // Doc is validated theApp.Modified = false; } - + CDialog::OnOK(); } // *************************************************************************** -void CClient_configDlg::OnDefault() +void CClient_configDlg::OnDefault() { /* Yoyo: Don't use the preset dlg for now cause doesn't work everywhere // Open the preset dialog @@ -571,10 +570,10 @@ void CClient_configDlg::OnDefault() { // Reset the CFG to default ResetConfigFile(); - + // invalidate InvalidateConfig (); - + // Update widgets GetFromConfigFile (); } @@ -584,7 +583,7 @@ void CClient_configDlg::OnDefault() { // Reset the CFG to default ResetConfigFileToDefault(); - + // invalidate InvalidateConfig (); @@ -595,16 +594,16 @@ void CClient_configDlg::OnDefault() // *************************************************************************** -void CClient_configDlg::OnLaunch() +void CClient_configDlg::OnLaunch() { if (theApp.Modified) { // Update config file SetToConfigFile (); - + // Save the config file SaveConfigFile (); - + // Doc is validated theApp.Modified = false; } @@ -617,12 +616,12 @@ void CClient_configDlg::OnLaunch() // *************************************************************************** -BOOL CAboutDlg::OnInitDialog() +BOOL CAboutDlg::OnInitDialog() { CDialog::OnInitDialog(); - + localizeWindowsRec (this, false); - + return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE } diff --git a/code/ryzom/tools/client/client_config/client_configDlg.h b/code/ryzom/tools/client/client_config/client_configDlg.h index 88277f934..924e68aef 100644 --- a/code/ryzom/tools/client/client_config/client_configDlg.h +++ b/code/ryzom/tools/client/client_config/client_configDlg.h @@ -32,7 +32,6 @@ #include "display_advanced_dlg.h" #include "system_information_dlg.h" #include "display_information_gl_dlg.h" -#include "display_information_d3d_dlg.h" #include "sound_dlg.h" // *************************************************************************** @@ -74,7 +73,6 @@ public: CSoundDlg SoundDlg; CSystemInformationDlg SystemInformationDlg; CDisplayInformationGlDlg DisplayInformationGLDlg; - CDisplayInformationD3DDlg DisplayInformationD3DDlg; // Large label top bar string ucstring TopLargeLabel; @@ -83,7 +81,7 @@ public: void InvalidateBar (); // Overrided - virtual + virtual BOOL UpdateData ( BOOL bSaveAndValidate ); void setPage (uint pageId); diff --git a/code/ryzom/tools/client/client_config/database.cpp b/code/ryzom/tools/client/client_config/database.cpp index 18ec56f63..24a556b63 100644 --- a/code/ryzom/tools/client/client_config/database.cpp +++ b/code/ryzom/tools/client/client_config/database.cpp @@ -63,7 +63,6 @@ void CreateDataBase () Pages[PageSound].init (PageSound, "uiConfigSound", true, BitmapSound, IDD_SOUND, &Root); Pages[PageDisplaySysInfo].init (PageDisplaySysInfo, "uiConfigDisplaySysInfo", true, BitmapGeneral, IDD_SYSTEM_INFO, &Root); Pages[PageDisplayOpenGLInfo].init (PageDisplayOpenGLInfo, "uiConfigDisplayOpenGLInfo", false, BitmapCard, IDD_DISPLAY_INFO, &Pages[PageDisplaySysInfo]); - Pages[PageDisplayOpenD3DInfo].init (PageDisplayOpenD3DInfo, "uiConfigDisplayD3DInfo", false, BitmapCard, IDD_DISPLAY_D3D, &Pages[PageDisplaySysInfo]); }; // *************************************************************************** @@ -93,7 +92,7 @@ void CPage::init (uint id, const char *name, bool bold, uint icon, uint resid, C void CPage::select () { - + } // *************************************************************************** @@ -217,4 +216,3 @@ const int QualityToFxNbMaxPoly[QUALITY_STEP] = }; // *************************************************************************** - diff --git a/code/ryzom/tools/client/client_config/database.h b/code/ryzom/tools/client/client_config/database.h index b02fc0ded..8709cee2d 100644 --- a/code/ryzom/tools/client/client_config/database.h +++ b/code/ryzom/tools/client/client_config/database.h @@ -24,7 +24,7 @@ // *************************************************************************** enum -{ +{ BitmapDisplay = 0, BitmapDisplayDetails, BitmapDisplayAdvanced, @@ -63,7 +63,6 @@ enum PageSound, PageDisplaySysInfo, PageDisplayOpenGLInfo, - PageDisplayOpenD3DInfo, PageCount }; diff --git a/code/ryzom/tools/client/client_config/display_dlg.cpp b/code/ryzom/tools/client/client_config/display_dlg.cpp index 71faa2a58..ef41ad13b 100644 --- a/code/ryzom/tools/client/client_config/display_dlg.cpp +++ b/code/ryzom/tools/client/client_config/display_dlg.cpp @@ -33,11 +33,6 @@ std::vector GLExtensions; std::string GLRenderer; std::string GLVendor; std::string GLVersion; -std::string D3DDescription; -std::string D3DDeviceName; -std::string D3DDriver; -std::string D3DDriverVersion; -std::string D3DVendor; uint VideoMemory; uint HardwareSoundBuffer; @@ -68,7 +63,7 @@ bool GetGLInformation () wc.hbrBackground = WHITE_BRUSH; wc.lpszClassName = "RyzomGetGlInformation"; wc.lpszMenuName = NULL; - if ( !RegisterClass(&wc) ) + if ( !RegisterClass(&wc) ) return false; // Create a window @@ -87,7 +82,7 @@ bool GetGLInformation () NULL, GetModuleHandle(NULL), NULL); - if (!hWnd) + if (!hWnd) return false; HDC hDC = GetDC(hWnd); @@ -115,7 +110,7 @@ bool GetGLInformation () int pf=ChoosePixelFormat(hDC, &pfd); if (!pf) return false; - if ( !SetPixelFormat(hDC, pf, &pfd) ) + if ( !SetPixelFormat(hDC, pf, &pfd) ) return false; // Create final context @@ -168,26 +163,6 @@ bool GetGLInformation () // *************************************************************************** -bool GetD3DInformation (NL3D::IDriver *d3dDriver) -{ - IDriver::CAdapter desc; - if (d3dDriver->getAdapter (0xffffffff, desc)) - { - D3DDescription = desc.Description; - D3DDeviceName = desc.DeviceName; - D3DDriver = desc.Driver; - D3DDriverVersion = toString ((uint16)(desc.DriverVersion>>48))+"."+ - toString ((uint16)(desc.DriverVersion>>32))+"."+ - toString ((uint16)(desc.DriverVersion>>16))+"."+ - toString ((uint16)(desc.DriverVersion&0xffff)); - D3DVendor = desc.Vendor; - return true; - } - return false; -} - -// *************************************************************************** - bool GetVideoMemory () { VideoMemory = 0; @@ -216,50 +191,12 @@ bool GetVideoMemory () bool GetHardwareSoundBuffer () { bool ret = false; - HardwareSoundBuffer = 0; - // The DirectSound object -#if (DIRECTSOUND_VERSION >= 0x0800) - LPDIRECTSOUND8 _DirectSound; -#else - LPDIRECTSOUND _DirectSound; -#endif - -#if (DIRECTSOUND_VERSION >= 0x0800) - if (DirectSoundCreate8(NULL, &_DirectSound, NULL) == DS_OK) -#else - if (DirectSoundCreate(NULL, &_DirectSound, NULL) == DS_OK) -#endif - { - DSCAPS caps; - memset (&caps, 0, sizeof (DSCAPS)); - caps.dwSize = sizeof (DSCAPS); - - HRESULT result = _DirectSound->GetCaps (&caps); - if (result == DS_OK) - { - HardwareSoundBuffer = caps.dwFreeHw3DStaticBuffers; - ret = true; - } - _DirectSound->Release (); - } return ret; } // *************************************************************************** -bool GetSystemInformation (IDriver *d3dDriver) -{ - bool result = GetGLInformation (); - result |= GetD3DInformation (d3dDriver); - result |= GetVideoMemory (); - result |= GetHardwareSoundBuffer (); - SystemMemory = CSystemInfo::totalPhysicalMemory (); - CPUFrequency = (uint)(CSystemInfo::getProcessorFrequency () / (uint64)1000000); - return result; -} -// *************************************************************************** - std::vector VideoModes[2]; // *************************************************************************** @@ -337,7 +274,6 @@ BEGIN_MESSAGE_MAP(CDisplayDlg, CDialog) //{{AFX_MSG_MAP(CDisplayDlg) ON_BN_CLICKED(IDC_FULLSCREEN, OnFullscreen) ON_BN_CLICKED(IDC_WINDOW, OnWindow) - ON_BN_CLICKED(IDC_DIRECT3D, OnDirect3d) ON_BN_CLICKED(IDC_DRV3D_AUTO, OnDrv3DAuto) ON_EN_CHANGE(IDC_HEIGHT, OnChangeHeight) ON_BN_CLICKED(IDC_OPENGL, OnOpengl) @@ -352,7 +288,7 @@ END_MESSAGE_MAP() // CDisplayDlg message handlers // *************************************************************************** -void CDisplayDlg::OnFullscreen() +void CDisplayDlg::OnFullscreen() { UpdateData (TRUE); updateState (); @@ -362,7 +298,7 @@ void CDisplayDlg::OnFullscreen() // *************************************************************************** -void CDisplayDlg::OnWindow() +void CDisplayDlg::OnWindow() { UpdateData (TRUE); updateState (); @@ -393,8 +329,8 @@ void CDisplayDlg::updateState () TDriver actualDriver = getActualDriver(); for (i=0; i GLExtensions; extern std::string GLRenderer; extern std::string GLVendor; extern std::string GLVersion; -extern std::string D3DDescription; -extern std::string D3DDeviceName; -extern std::string D3DDriver; -extern std::string D3DDriverVersion; -extern std::string D3DVendor; extern uint VideoMemory; extern uint HardwareSoundBuffer; extern uint64 SystemMemory; @@ -153,14 +146,9 @@ extern uint CPUFrequency; // Register video modes void RegisterVideoModes (uint mode, NL3D::IDriver *driver); -// Get opengl information -bool GetSystemInformation (NL3D::IDriver *d3dDriver); - // *************************************************************************** //{{AFX_INSERT_LOCATION}} // Microsoft Visual C++ will insert additional declarations immediately before the previous line. #endif // !defined(AFX_DISPLAY_DLG_H__1287701D_07D1_48F0_8F13_3FCE937DA3A2__INCLUDED_) - - diff --git a/code/ryzom/tools/client/client_config/display_information_d3d_dlg.cpp b/code/ryzom/tools/client/client_config/display_information_d3d_dlg.cpp deleted file mode 100644 index acbbff87e..000000000 --- a/code/ryzom/tools/client/client_config/display_information_d3d_dlg.cpp +++ /dev/null @@ -1,73 +0,0 @@ -// Ryzom - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as -// published by the Free Software Foundation, either version 3 of the -// License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -// display_information_d3d_dlg.cpp : implementation file -// - -#include "stdafx.h" -#include "client_config.h" -#include "display_information_d3d_dlg.h" -#include "display_dlg.h" - -// *************************************************************************** -// CDisplayInformationD3DDlg dialog -// *************************************************************************** - -CDisplayInformationD3DDlg::CDisplayInformationD3DDlg(CWnd* pParent /*=NULL*/) - : CBaseDialog(CDisplayInformationD3DDlg::IDD, pParent) -{ - //{{AFX_DATA_INIT(CDisplayInformationD3DDlg) - //}}AFX_DATA_INIT -} - -// *************************************************************************** - -void CDisplayInformationD3DDlg::DoDataExchange(CDataExchange* pDX) -{ - CDialog::DoDataExchange(pDX); - //{{AFX_DATA_MAP(CDisplayInformationD3DDlg) - DDX_Control(pDX, IDC_D3D_DRIVER_VERSION, DriverVersion); - DDX_Control(pDX, IDC_D3D_DRIVER, Driver); - DDX_Control(pDX, IDC_D3D_DESCRIPTION, Description); - //}}AFX_DATA_MAP -} - -// *************************************************************************** - -BEGIN_MESSAGE_MAP(CDisplayInformationD3DDlg, CDialog) - //{{AFX_MSG_MAP(CDisplayInformationD3DDlg) - //}}AFX_MSG_MAP -END_MESSAGE_MAP() - -// *************************************************************************** -// CDisplayInformationD3DDlg message handlers -// *************************************************************************** - -BOOL CDisplayInformationD3DDlg::OnInitDialog() -{ - CDialog::OnInitDialog(); - - Description.SetWindowText (D3DDescription.c_str ()); - Driver.SetWindowText (D3DDriver.c_str ()); - DriverVersion.SetWindowText (D3DDriverVersion.c_str ()); - - UpdateData (TRUE); - - return TRUE; // return TRUE unless you set the focus to a control - // EXCEPTION: OCX Property Pages should return FALSE -} - -// *************************************************************************** diff --git a/code/ryzom/tools/client/client_config/display_information_d3d_dlg.h b/code/ryzom/tools/client/client_config/display_information_d3d_dlg.h deleted file mode 100644 index 63ccf0eba..000000000 --- a/code/ryzom/tools/client/client_config/display_information_d3d_dlg.h +++ /dev/null @@ -1,66 +0,0 @@ -// Ryzom - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as -// published by the Free Software Foundation, either version 3 of the -// License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -#if !defined(AFX_DISPLAY_INFORMATION_D3D_DLG_H__90FE554C_8224_4A68_94CE_65D71FED52F8__INCLUDED_) -#define AFX_DISPLAY_INFORMATION_D3D_DLG_H__90FE554C_8224_4A68_94CE_65D71FED52F8__INCLUDED_ - -#if _MSC_VER > 1000 -#pragma once -#endif // _MSC_VER > 1000 -// display_information_d3d_dlg.h : header file -// - -#include "base_dialog.h" - -///////////////////////////////////////////////////////////////////////////// -// CDisplayInformationD3DDlg dialog - -class CDisplayInformationD3DDlg : public CBaseDialog -{ -// Construction -public: - CDisplayInformationD3DDlg(CWnd* pParent = NULL); // standard constructor - -// Dialog Data - //{{AFX_DATA(CDisplayInformationD3DDlg) - enum { IDD = IDD_DISPLAY_D3D }; - CStatic DriverVersion; - CStatic Driver; - CStatic Description; - //}}AFX_DATA - - -// Overrides - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(CDisplayInformationD3DDlg) - protected: - virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support - //}}AFX_VIRTUAL - -// Implementation -protected: - - // Generated message map functions - //{{AFX_MSG(CDisplayInformationD3DDlg) - virtual BOOL OnInitDialog(); - //}}AFX_MSG - DECLARE_MESSAGE_MAP() -}; - -//{{AFX_INSERT_LOCATION}} -// Microsoft Visual C++ will insert additional declarations immediately before the previous line. - -#endif // !defined(AFX_DISPLAY_INFORMATION_D3D_DLG_H__90FE554C_8224_4A68_94CE_65D71FED52F8__INCLUDED_) diff --git a/code/ryzom/tools/client/client_config/resource.h b/code/ryzom/tools/client/client_config/resource.h index 5e23b5a4d..57b42b905 100644 --- a/code/ryzom/tools/client/client_config/resource.h +++ b/code/ryzom/tools/client/client_config/resource.h @@ -96,8 +96,6 @@ #define IDD_DISPLAY_ADVANCED 147 #define IDD_DISPLAY_INFO 148 #define IDD_PRESET 149 -#define IDD_DISPLAY_D3D 150 -#define IDS_DISPLAY_D3D_INFO 151 #define IDS_Q_RESTAURE_DEFAULT 152 #define IDD_SYSTEM_INFO 153 #define IDB_SLASH_SCREEN 155 @@ -133,8 +131,6 @@ #define IDC_GL_RENDERER 1028 #define IDC_GL_VERSION 1029 #define IDC_EXTENSION 1030 -#define IDC_D3D_DRIVER 1030 -#define IDC_D3D_DRIVER_VERSION 1031 #define IDC_VIDEO_CARD 1033 #define IDC_BUTTON1 1035 #define IDC_RESET 1035 @@ -163,9 +159,6 @@ #define IDC_DISPLAY_WND_TEXT2 1052 #define IDC_DISPLAY_WND_TEXT3 1053 #define IDC_DISPLAY_FS_TEXT0 1054 -#define IDC_D3D_VENDOR 1055 -#define IDC_D3D_DEVICE_NAME 1056 -#define IDC_D3D_DESCRIPTION 1057 #define IDC_LANGUAGE 1058 #define IDC_SYS_INFO_PHY_MEM 1059 #define IDC_SYS_INFO_OS 1060 @@ -173,11 +166,10 @@ #define IDC_SYS_INFO_VIDEO 1062 #define IDC_SYS_INFO_VIDEO_DRIVER 1063 #define IDC_DRV3D_AUTO 1100 -#define IDC_DIRECT3D 1101 #define IDC_OPENGL 1102 // Next default values for new objects -// +// #ifdef APSTUDIO_INVOKED #ifndef APSTUDIO_READONLY_SYMBOLS #define _APS_NEXT_RESOURCE_VALUE 156 diff --git a/code/ryzom/tools/client/client_config_qt/src/client_config_dialog.cpp b/code/ryzom/tools/client/client_config_qt/src/client_config_dialog.cpp index 388f70a52..5ffeb0540 100644 --- a/code/ryzom/tools/client/client_config_qt/src/client_config_dialog.cpp +++ b/code/ryzom/tools/client/client_config_qt/src/client_config_dialog.cpp @@ -24,7 +24,6 @@ #include "sound_settings_widget.h" #include "sys_info_widget.h" #include "sys_info_opengl_widget.h" -#include "sys_info_d3d_widget.h" #include "system.h" @@ -77,15 +76,6 @@ CClientConfigDialog::CClientConfigDialog( QWidget *parent ) : item = treeWidget->topLevelItem( 3 )->child( 0 ); item->setData( 0, Qt::UserRole, 6 ); - // Direct3D info - item = treeWidget->topLevelItem( 3 )->child( 1 ); - item->setData( 0, Qt::UserRole, 7 ); - -#ifndef Q_OS_WIN - // Hide Direct3D page under Linux and OS X - item->setHidden(true); -#endif - #ifdef RZ_USE_STEAM // Hide Play Ryzom button if using Steam because we need to launch it from Steam playButton->setHidden(true); @@ -99,10 +89,6 @@ CClientConfigDialog::CClientConfigDialog( QWidget *parent ) : CategoryStackedWidget->addWidget( new CSysInfoWidget( CategoryStackedWidget ) ); CategoryStackedWidget->addWidget( new CSysInfoOpenGLWidget( CategoryStackedWidget ) ); -#ifdef Q_OS_WIN - // Add Direct3D widget only under Windows - CategoryStackedWidget->addWidget( new CSysInfoD3DWidget( CategoryStackedWidget ) ); -#endif for( sint32 i = 0; i < CategoryStackedWidget->count(); i++ ) { @@ -271,4 +257,3 @@ bool CClientConfigDialog::isOKToQuit() return true; } - diff --git a/code/ryzom/tools/client/client_config_qt/src/display_settings_widget.cpp b/code/ryzom/tools/client/client_config_qt/src/display_settings_widget.cpp index 7e05f83bd..250fd705e 100644 --- a/code/ryzom/tools/client/client_config_qt/src/display_settings_widget.cpp +++ b/code/ryzom/tools/client/client_config_qt/src/display_settings_widget.cpp @@ -30,13 +30,8 @@ CDisplaySettingsWidget::CDisplaySettingsWidget( QWidget *parent ) : ypositionLineEdit->setValidator( new QRegExpValidator( QRegExp( "[0-9]{1,6}" ), ypositionLineEdit ) ); load(); -#ifndef Q_OS_WIN32 - direct3dRadioButton->setEnabled(false); -#endif - connect( autoRadioButton, SIGNAL( clicked( bool ) ), this, SLOT( onSomethingChanged() ) ); connect( openglRadioButton, SIGNAL( clicked( bool ) ), this, SLOT( onSomethingChanged() ) ); - connect( direct3dRadioButton, SIGNAL( clicked( bool ) ), this, SLOT( onSomethingChanged() ) ); connect( fullscreenRadioButton, SIGNAL( clicked( bool ) ), this, SLOT( onSomethingChanged() ) ); connect( windowedRadioButton, SIGNAL( clicked( bool ) ), this, SLOT( onSomethingChanged() ) ); connect( widthLineEdit, SIGNAL( textChanged( const QString & ) ), this, SLOT( onSomethingChanged() ) ); @@ -46,7 +41,6 @@ CDisplaySettingsWidget::CDisplaySettingsWidget( QWidget *parent ) : connect( videomodeComboBox, SIGNAL( currentIndexChanged( int ) ), this, SLOT( onSomethingChanged() ) ); connect( autoRadioButton, SIGNAL( clicked( bool ) ), this, SLOT( updateVideoModes() ) ); connect( openglRadioButton, SIGNAL( clicked( bool ) ), this, SLOT( updateVideoModes() ) ); - connect( direct3dRadioButton, SIGNAL( clicked( bool ) ), this, SLOT( updateVideoModes() ) ); } CDisplaySettingsWidget::~CDisplaySettingsWidget() @@ -66,9 +60,6 @@ void CDisplaySettingsWidget::load() case DRV_OPENGL: openglRadioButton->setChecked( true ); break; - case DRV_DIRECT3D: - direct3dRadioButton->setChecked( true ); - break; } updateVideoModes(); @@ -103,10 +94,6 @@ void CDisplaySettingsWidget::save() if( openglRadioButton->isChecked() ) s.config.setString( "Driver3D", std::string( "OpenGL" ) ); -#ifdef Q_OS_WIN32 - else if( direct3dRadioButton->isChecked() ) - s.config.setString( "Driver3D", std::string( "Direct3D" ) ); -#endif else s.config.setString( "Driver3D", std::string( "Auto" ) ); @@ -117,13 +104,7 @@ void CDisplaySettingsWidget::save() sint32 index = videomodeComboBox->currentIndex(); CVideoMode mode; - // OpenGL should be available everywhere! -#ifdef Q_OS_WIN32 - if( direct3dRadioButton->isChecked() ) - mode = s.d3dInfo.modes[ index ]; - else -#endif - mode = s.openglInfo.modes[ index ]; + mode = s.openglInfo.modes[ index ]; s.config.setInt( "Width", mode.width ); s.config.setInt( "Height", mode.height ); @@ -150,19 +131,8 @@ void CDisplaySettingsWidget::updateVideoModes() std::vector< CVideoMode >::iterator itr, iend; -#ifdef Q_OS_WIN32 - if( direct3dRadioButton->isChecked() ) - { - itr = s.d3dInfo.modes.begin(); - iend = s.d3dInfo.modes.end(); - } - else -#endif - { - // OpenGL should be available everywhere! - itr = s.openglInfo.modes.begin(); - iend = s.openglInfo.modes.end(); - } + itr = s.openglInfo.modes.begin(); + iend = s.openglInfo.modes.end(); while(itr != iend) { @@ -194,7 +164,6 @@ uint32 CDisplaySettingsWidget::findVideoModeIndex( CVideoMode *mode ) //| --------------------------------------| //| Auto | OpenGL modes | //| OpenGL | OpenGL modes | - //| Direct3D | Direct3D modes | //| --------------------------------------| // // @@ -203,21 +172,9 @@ uint32 CDisplaySettingsWidget::findVideoModeIndex( CVideoMode *mode ) CVideoMode &m = *mode; CSystem &s = CSystem::GetInstance(); -#ifdef Q_OS_WIN32 - if( direct3dRadioButton->isChecked() ) - { - for( uint32 i = 0; i < s.d3dInfo.modes.size(); i++ ) - if( s.d3dInfo.modes[ i ] == m ) - return i; - } - else -#endif - { - // Again OpenGL should be available everywhere! - for( uint32 i = 0; i < s.openglInfo.modes.size(); i++ ) - if( s.openglInfo.modes[ i ] == m ) - return i; - } + for( uint32 i = 0; i < s.openglInfo.modes.size(); i++ ) + if( s.openglInfo.modes[ i ] == m ) + return i; return 0; } @@ -228,12 +185,8 @@ E3DDriver CDisplaySettingsWidget::getDriverFromConfigString(std::string &str) co return DRV_AUTO; if( str.compare( "1" ) == 0 ) return DRV_OPENGL; - if( str.compare( "2" ) == 0 ) - return DRV_DIRECT3D; if( str.compare( "OpenGL" ) == 0 ) return DRV_OPENGL; - if( str.compare( "Direct3D" ) == 0) - return DRV_DIRECT3D; return DRV_AUTO; diff --git a/code/ryzom/tools/client/client_config_qt/src/display_settings_widget.h b/code/ryzom/tools/client/client_config_qt/src/display_settings_widget.h index b1bb04a48..deef93e58 100644 --- a/code/ryzom/tools/client/client_config_qt/src/display_settings_widget.h +++ b/code/ryzom/tools/client/client_config_qt/src/display_settings_widget.h @@ -26,8 +26,7 @@ struct CVideoMode; enum E3DDriver { DRV_AUTO, - DRV_OPENGL, - DRV_DIRECT3D + DRV_OPENGL }; /** diff --git a/code/ryzom/tools/client/client_config_qt/src/sound_settings_widget.cpp b/code/ryzom/tools/client/client_config_qt/src/sound_settings_widget.cpp index 49348d38b..dbcf2c5c8 100644 --- a/code/ryzom/tools/client/client_config_qt/src/sound_settings_widget.cpp +++ b/code/ryzom/tools/client/client_config_qt/src/sound_settings_widget.cpp @@ -28,8 +28,6 @@ CSoundSettingsWidget::CSoundSettingsWidget( QWidget *parent ) : connect(autoRadioButton, SIGNAL(clicked(bool)), this, SLOT(onSomethingChanged())); connect(openalRadioButton, SIGNAL(clicked(bool)), this, SLOT(onSomethingChanged())); connect(fmodRadioButton, SIGNAL(clicked(bool)), this, SLOT(onSomethingChanged())); - connect(xaudio2RadioButton, SIGNAL(clicked(bool)), this, SLOT(onSomethingChanged())); - connect(directsoundRadioButton, SIGNAL(clicked(bool)), this, SLOT(onSomethingChanged())); connect( tracksSlider, SIGNAL( valueChanged( int ) ), this, SLOT( onTracksSliderChange() ) ); connect( soundCheckBox, SIGNAL( clicked( bool ) ), this, SLOT( onSomethingChanged() ) ); @@ -73,12 +71,8 @@ void CSoundSettingsWidget::load() #ifdef Q_OS_WIN32 fmodRadioButton->setEnabled(true); - xaudio2RadioButton->setEnabled(true); - directsoundRadioButton->setEnabled(true); #else fmodRadioButton->setEnabled(false); - xaudio2RadioButton->setEnabled(false); - directsoundRadioButton->setEnabled(false); #endif if (soundDriver.compare("openal") == 0) @@ -89,14 +83,6 @@ void CSoundSettingsWidget::load() { fmodRadioButton->setChecked(true); } - else if (soundDriver.compare("xaudio2") == 0) - { - xaudio2RadioButton->setChecked(true); - } - else if (soundDriver.compare("directsound") == 0) - { - directsoundRadioButton->setChecked(true); - } else { autoRadioButton->setChecked(true); @@ -123,10 +109,6 @@ void CSoundSettingsWidget::save() #ifdef Q_OS_WIN32 else if (fmodRadioButton->isChecked()) s.config.setString("DriverSound", std::string("FMod")); - else if (xaudio2RadioButton->isChecked()) - s.config.setString("DriverSound", std::string("XAudio2")); - else if (directsoundRadioButton->isChecked()) - s.config.setString("DriverSound", std::string("DirectSound")); #endif else s.config.setString("DriverSound", std::string("Auto")); @@ -135,4 +117,4 @@ void CSoundSettingsWidget::save() void CSoundSettingsWidget::updateTracksLabel() { tracksLabel->setText( tr( "%1 tracks" ).arg( tracksSlider->value() * 4 ) ); -} \ No newline at end of file +} diff --git a/code/ryzom/tools/client/client_config_qt/src/sys_info_d3d_widget.cpp b/code/ryzom/tools/client/client_config_qt/src/sys_info_d3d_widget.cpp deleted file mode 100644 index ddc001d4c..000000000 --- a/code/ryzom/tools/client/client_config_qt/src/sys_info_d3d_widget.cpp +++ /dev/null @@ -1,36 +0,0 @@ -// Ryzom - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as -// published by the Free Software Foundation, either version 3 of the -// License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -#include "stdpch.h" -#include "sys_info_d3d_widget.h" - -#include "system.h" - -CSysInfoD3DWidget::CSysInfoD3DWidget( QWidget *parent ) : - QWidget( parent ) -{ - setupUi( this ); - -#ifdef Q_OS_WIN32 - descriptionLabel->setText(QString::fromUtf8(CSystem::GetInstance().d3dInfo.device.c_str())); - driverLabel->setText(QString::fromUtf8(CSystem::GetInstance().d3dInfo.driver.c_str())); - versionLabel->setText(QString::fromUtf8(CSystem::GetInstance().d3dInfo.driverVersion.c_str())); -#endif -} - -CSysInfoD3DWidget::~CSysInfoD3DWidget() -{ -} diff --git a/code/ryzom/tools/client/client_config_qt/src/sys_info_d3d_widget.h b/code/ryzom/tools/client/client_config_qt/src/sys_info_d3d_widget.h deleted file mode 100644 index 875112234..000000000 --- a/code/ryzom/tools/client/client_config_qt/src/sys_info_d3d_widget.h +++ /dev/null @@ -1,35 +0,0 @@ -// Ryzom - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as -// published by the Free Software Foundation, either version 3 of the -// License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -#ifndef SYSINFOD3DWIDGET_H -#define SYSINFOD3DWIDGET_H - -#include "ui_sys_info_d3d_widget.h" - - -/** - @brief The Direct3D information page of the configuration tool -*/ -class CSysInfoD3DWidget : public QWidget, public Ui::sys_info_d3d_widget -{ - Q_OBJECT -public: - CSysInfoD3DWidget( QWidget *parent = NULL ); - virtual ~CSysInfoD3DWidget(); -}; - - -#endif // SYSINFOD3DWIDGET_H diff --git a/code/ryzom/tools/client/client_config_qt/src/system.cpp b/code/ryzom/tools/client/client_config_qt/src/system.cpp index 635800878..e06443227 100644 --- a/code/ryzom/tools/client/client_config_qt/src/system.cpp +++ b/code/ryzom/tools/client/client_config_qt/src/system.cpp @@ -24,9 +24,6 @@ CSystem::CSystem() { GatherSysInfo(); -#ifdef Q_OS_WIN32 - GatherD3DInfo(); -#endif GatherOpenGLInfo(); } @@ -82,36 +79,6 @@ void CSystem::GatherSysInfo() sysInfo.totalRAM /= ( 1024 * 1024 ); } -#ifdef Q_OS_WIN32 -void CSystem::GatherD3DInfo() -{ - NL3D::IDriver *driver = NULL; - try - { - driver = NL3D::CDRU::createD3DDriver(); - - NL3D::IDriver::CAdapter adapter; - - if( driver->getAdapter( 0xffffffff, adapter ) ) - { - d3dInfo.device = adapter.Description; - d3dInfo.driver = adapter.Driver; - - CSystem::parseDriverVersion(d3dInfo.device, adapter.DriverVersion, d3dInfo.driverVersion); - } - - GetVideoModes( d3dInfo.modes, driver ); - - driver->release(); - } - - catch(const NLMISC::Exception &e) - { - nlwarning( e.what() ); - } -} -#endif - void CSystem::GatherOpenGLInfo() { QGLWidget *gl = new QGLWidget(); diff --git a/code/ryzom/tools/client/client_config_qt/src/system.h b/code/ryzom/tools/client/client_config_qt/src/system.h index 1cc25a4bf..bd70b66a2 100644 --- a/code/ryzom/tools/client/client_config_qt/src/system.h +++ b/code/ryzom/tools/client/client_config_qt/src/system.h @@ -74,17 +74,6 @@ public: } sysInfo; -#ifdef Q_OS_WIN32 - struct CD3DInfo - { - std::string device; - std::string driver; - std::string driverVersion; - std::vector< CVideoMode > modes; - } - d3dInfo; -#endif - struct COpenGLInfo { std::string vendor; @@ -99,9 +88,6 @@ public: private: void GatherSysInfo(); -#ifdef Q_OS_WIN32 - void GatherD3DInfo(); -#endif void GatherOpenGLInfo(); void GetVideoModes(std::vector &dst, NL3D::IDriver *driver) const; @@ -110,4 +96,3 @@ private: }; #endif // SYSTEM_H - diff --git a/code/ryzom/tools/client/client_config_qt/translations/ryzom_configuration_de.ts b/code/ryzom/tools/client/client_config_qt/translations/ryzom_configuration_de.ts index 579d169ec..f8d9a9ab8 100644 --- a/code/ryzom/tools/client/client_config_qt/translations/ryzom_configuration_de.ts +++ b/code/ryzom/tools/client/client_config_qt/translations/ryzom_configuration_de.ts @@ -130,11 +130,6 @@ OpenGL information OpenGL-Information - - - Direct3D information - Direct3D-Information - Apply @@ -240,16 +235,6 @@ Driver Treiber - - Specify if Ryzom is to be run in OpenGL or Direct3D. - there's a period (full stop) at the end opposed to the other "specify"-sentece about full screen ending with a colon... - Wähle, ob Ryzom in OpenGL oder Direct3D laufen soll: - - - - Specify if Ryzom is to be run in OpenGL or Direct3D: - Wähle, ob Ryzom in OpenGL oder Direct3D laufen soll: - Auto @@ -260,11 +245,6 @@ OpenGL OpenGL - - - Direct3D - Direct3D - Parameters @@ -395,16 +375,6 @@ FMod - - - XAudio2 - - - - - DirectSound - - Parameters @@ -446,34 +416,6 @@ 8 Spuren - - sys_info_d3d_widget - - - Direct3D information - Direct3D-Information - - - - Direct3D - Direct3D - - - - Description - Beschreibung - - - - Driver - Treiber - - - - Driver version - Treiber-Version - - sys_info_opengl_widget diff --git a/code/ryzom/tools/client/client_config_qt/translations/ryzom_configuration_es.ts b/code/ryzom/tools/client/client_config_qt/translations/ryzom_configuration_es.ts index c38ddd51b..cf07c97a5 100644 --- a/code/ryzom/tools/client/client_config_qt/translations/ryzom_configuration_es.ts +++ b/code/ryzom/tools/client/client_config_qt/translations/ryzom_configuration_es.ts @@ -128,11 +128,6 @@ OpenGL information Información OpenGL - - - Direct3D information - Información Direct3D - Apply @@ -238,15 +233,6 @@ Driver Driver - - Specify if Ryzom is to be run in OpenGL or Direct3D. - Especificar si Ryzom debe ser ejecutado con OpenGL o Direct3D. - - - - Specify if Ryzom is to be run in OpenGL or Direct3D: - Especificar si Ryzom debe ser ejecutado con OpenGL o Direct3D: - Auto @@ -257,11 +243,6 @@ OpenGL OpenGL - - - Direct3D - Direct3D - Parameters @@ -390,16 +371,6 @@ FMod - - - XAudio2 - - - - - DirectSound - - Parameters @@ -439,34 +410,6 @@ 8 pistas - - sys_info_d3d_widget - - - Direct3D information - Información Direct3D - - - - Direct3D - Direct3D - - - - Description - Descripcción - - - - Driver - Driver - - - - Driver version - Versión del driver - - sys_info_opengl_widget diff --git a/code/ryzom/tools/client/client_config_qt/translations/ryzom_configuration_fr.ts b/code/ryzom/tools/client/client_config_qt/translations/ryzom_configuration_fr.ts index d2f7bc47e..3a52fd89f 100644 --- a/code/ryzom/tools/client/client_config_qt/translations/ryzom_configuration_fr.ts +++ b/code/ryzom/tools/client/client_config_qt/translations/ryzom_configuration_fr.ts @@ -128,11 +128,6 @@ OpenGL information Informations OpenGL - - - Direct3D information - Informations Direct3D - Apply @@ -242,15 +237,6 @@ Driver Pilote - - Specify if Ryzom is to be run in OpenGL or Direct3D. - Spécifier si Ryzom doit utiliser OpenGL ou Direct3D. - - - - Specify if Ryzom is to be run in OpenGL or Direct3D: - Spécifier si Ryzom doit utiliser OpenGL ou Direct3D : - Auto @@ -261,11 +247,6 @@ OpenGL OpenGL - - - Direct3D - Direct3D - Parameters @@ -394,16 +375,6 @@ FMod FMod - - - XAudio2 - XAudio2 - - - - DirectSound - DirectSound - Parameters @@ -443,34 +414,6 @@ 8 pistes - - sys_info_d3d_widget - - - Direct3D information - Informations Direct3D - - - - Direct3D - Direct3D - - - - Description - Description - - - - Driver - Pilote - - - - Driver version - Version du pilote - - sys_info_opengl_widget diff --git a/code/ryzom/tools/client/client_config_qt/translations/ryzom_configuration_hu.ts b/code/ryzom/tools/client/client_config_qt/translations/ryzom_configuration_hu.ts index 4172f68f5..71e4107d5 100644 --- a/code/ryzom/tools/client/client_config_qt/translations/ryzom_configuration_hu.ts +++ b/code/ryzom/tools/client/client_config_qt/translations/ryzom_configuration_hu.ts @@ -118,10 +118,6 @@ OpenGL information OpenGL információk - - Direct3D information - Direct3D információk - Apply Alkalmaz @@ -239,10 +235,6 @@ Auto Automatikus - - Specify if Ryzom is to be run in OpenGL or Direct3D. - Határozza meg, hogy a Ryzom OpenGL-t vagy Direct3D-t használjon. - Parameters Paraméterek @@ -373,25 +365,6 @@ %1 sáv - - SysInfoD3DWidget - - Direct3D information - Direct3D információk - - - Description - Leírás - - - Driver - Meghajtó - - - Driver version - Meghajtó verziószám - - SysInfoOpenGLWidget @@ -494,11 +467,6 @@ OpenGL information OpenGL információk - - - Direct3D information - Direct3D információk - Apply @@ -608,15 +576,6 @@ Driver Meghajtó - - Specify if Ryzom is to be run in OpenGL or Direct3D. - Határozza meg, hogy a Ryzom OpenGL-t vagy Direct3D-t használjon. - - - - Specify if Ryzom is to be run in OpenGL or Direct3D: - - Auto @@ -627,11 +586,6 @@ OpenGL - - - Direct3D - - Parameters @@ -760,16 +714,6 @@ FMod - - - XAudio2 - - - - - DirectSound - - Parameters @@ -809,34 +753,6 @@ 8 sáv - - sys_info_d3d_widget - - - Direct3D information - Direct3D információk - - - - Direct3D - - - - - Description - Leírás - - - - Driver - Meghajtó - - - - Driver version - Meghajtó verziószám - - sys_info_opengl_widget diff --git a/code/ryzom/tools/client/client_config_qt/translations/ryzom_configuration_ru.ts b/code/ryzom/tools/client/client_config_qt/translations/ryzom_configuration_ru.ts index a61aad20e..43d380f7d 100644 --- a/code/ryzom/tools/client/client_config_qt/translations/ryzom_configuration_ru.ts +++ b/code/ryzom/tools/client/client_config_qt/translations/ryzom_configuration_ru.ts @@ -124,11 +124,6 @@ OpenGL information - - - Direct3D information - - Apply @@ -234,11 +229,6 @@ Driver - - - Specify if Ryzom is to be run in OpenGL or Direct3D: - - Auto @@ -249,11 +239,6 @@ OpenGL - - - Direct3D - - Parameters @@ -370,16 +355,6 @@ FMod - - - XAudio2 - - - - - DirectSound - - Parameters @@ -411,34 +386,6 @@ - - sys_info_d3d_widget - - - Direct3D information - - - - - Direct3D - - - - - Description - - - - - Driver - - - - - Driver version - - - sys_info_opengl_widget diff --git a/code/ryzom/tools/client/client_config_qt/ui/client_config_dialog.ui b/code/ryzom/tools/client/client_config_qt/ui/client_config_dialog.ui index 177c9a143..fd49730b4 100644 --- a/code/ryzom/tools/client/client_config_qt/ui/client_config_dialog.ui +++ b/code/ryzom/tools/client/client_config_qt/ui/client_config_dialog.ui @@ -188,11 +188,6 @@ OpenGL information - - - Direct3D information - - diff --git a/code/ryzom/tools/client/client_config_qt/ui/display_settings_widget.ui b/code/ryzom/tools/client/client_config_qt/ui/display_settings_widget.ui index a17beac88..1258b5a14 100644 --- a/code/ryzom/tools/client/client_config_qt/ui/display_settings_widget.ui +++ b/code/ryzom/tools/client/client_config_qt/ui/display_settings_widget.ui @@ -20,13 +20,6 @@ Driver - - - - Specify if Ryzom is to be run in OpenGL or Direct3D: - - - @@ -41,13 +34,6 @@ - - - - Direct3D - - - diff --git a/code/ryzom/tools/client/client_config_qt/ui/sound_settings_widget.ui b/code/ryzom/tools/client/client_config_qt/ui/sound_settings_widget.ui index 35ec96b89..dee312602 100644 --- a/code/ryzom/tools/client/client_config_qt/ui/sound_settings_widget.ui +++ b/code/ryzom/tools/client/client_config_qt/ui/sound_settings_widget.ui @@ -41,20 +41,6 @@ - - - - XAudio2 - - - - - - - DirectSound - - - diff --git a/code/ryzom/tools/client/client_config_qt/ui/sys_info_d3d_widget.ui b/code/ryzom/tools/client/client_config_qt/ui/sys_info_d3d_widget.ui deleted file mode 100644 index b60d753b2..000000000 --- a/code/ryzom/tools/client/client_config_qt/ui/sys_info_d3d_widget.ui +++ /dev/null @@ -1,156 +0,0 @@ - - - sys_info_d3d_widget - - - - 0 - 0 - 391 - 429 - - - - Direct3D information - - - - - - Direct3D - - - - - - - - - - Description - - - - - - - - 0 - 0 - - - - - - - - - - - - - - - - - - - S3 Trio 64 - - - - - - - Driver - - - - - - - - 0 - 0 - - - - - - - - - - - - - - - - - - - s3trio64_d3d.dll - - - - - - - Driver version - - - - - - - - 0 - 0 - - - - - - - - - - - - - - - - - - - 66.6 - - - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - - - - - - diff --git a/code/ryzom/tools/client/r2_islands_textures/screenshot_islands.cpp b/code/ryzom/tools/client/r2_islands_textures/screenshot_islands.cpp index db8481453..79a1e66a7 100644 --- a/code/ryzom/tools/client/r2_islands_textures/screenshot_islands.cpp +++ b/code/ryzom/tools/client/r2_islands_textures/screenshot_islands.cpp @@ -86,7 +86,7 @@ CScreenshotIslands::CScreenshotIslands() void CScreenshotIslands::init() { // Create a driver - driver = UDriver::createDriver(0, true); + driver = UDriver::createDriver(0); nlassert(driver); sceneMaterial = driver->createMaterial(); diff --git a/code/ryzom/tools/leveldesign/georges_editor_qt/data/georges_editor_default.cfg b/code/ryzom/tools/leveldesign/georges_editor_qt/data/georges_editor_default.cfg index 8ff9f6c7a..b633cacbb 100644 --- a/code/ryzom/tools/leveldesign/georges_editor_qt/data/georges_editor_default.cfg +++ b/code/ryzom/tools/leveldesign/georges_editor_qt/data/georges_editor_default.cfg @@ -30,9 +30,9 @@ SaveConfig = 1; // Graphics ////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////// -// Use OpenGL or Direct3D (Windows) +// Use OpenGL (Windows) GraphicsEnabled = 1; -GraphicsDrivers = { "OpenGL", "Direct3D" }; +GraphicsDrivers = { "OpenGL" }; GraphicsDriver = "OpenGL"; // Font name used for all text in the client (it can be a .ttf, .fon, .pfb) @@ -58,46 +58,46 @@ FpsSmoothing = 64; ////////////////////////////////////////////////////////////////////////////// // This setting is used to bind keys to actions. -// "key_handler", "args", "***", "Key1|Key2", +// "key_handler", "args", "***", "Key1|Key2", // *** -> CTRL, SHIFT, ALT don't matter // --- -> CTRL, SHIFT, ALT must all be disabled // -+- -> only SHIFT must be down KeySettings = { - "screenshot", "", "***", "KeyF5", - "command", "set_state Exit", "-+-", "KeyESCAPE", - "command", "set_state Login", "+--", "KeyESCAPE", - "command", "set_state Unload", "***", "KeyF8", - "command", "set_state Demo", "***", "KeyF7", - "move_forward", "", "***", "KeyUP|KeyZ|KeyW", - "move_backward", "", "***", "KeyDOWN|KeyS", - "move_left", "", "***", "KeyLEFT|KeyQ|KeyA", - "move_right", "", "***", "KeyRIGHT|KeyD", - "move_forward", "", "***", "KeyZ|KeyW", - "move_backward", "", "***", "KeyS", - "move_left", "", "***", "KeyQ|KeyA", - "move_right", "", "***", "KeyD", - "chat_begin", "", "***", "KeyT", - "chat_send", "", "***", "KeyENTER", - "chat_leave", "", "***", "KeyESCAPE", - "display_test", "", "***", "KeyTAB", - "send_action", "0", "---", "Key1", - "send_action", "1", "---", "Key2", - "send_action", "2", "---", "Key3", - "send_action", "3", "---", "Key4", - "send_action", "4", "---", "Key5", - "send_action", "5", "---", "Key6", - "send_action", "6", "---", "Key7", - "send_action", "7", "---", "Key8", - "send_action", "8", "---", "Key9", - "send_action", "9", "---", "Key0", - "demo_crystal_spawn", "", "---", "KeyO", - "demo_crystal_explode", "", "---", "KeyP", - "free_camera_forward", "", "---", "KeyNUMPAD8", - "free_camera_backward", "", "---", "KeyNUMPAD2", - "free_camera_left", "", "---", "KeyNUMPAD4", - "free_camera_right", "", "---", "KeyNUMPAD6", - "switch_camera", "", "---", "KeyF4", - "switch_ui_visible" ,"", "---", "KeyF6", + "screenshot", "", "***", "KeyF5", + "command", "set_state Exit", "-+-", "KeyESCAPE", + "command", "set_state Login", "+--", "KeyESCAPE", + "command", "set_state Unload", "***", "KeyF8", + "command", "set_state Demo", "***", "KeyF7", + "move_forward", "", "***", "KeyUP|KeyZ|KeyW", + "move_backward", "", "***", "KeyDOWN|KeyS", + "move_left", "", "***", "KeyLEFT|KeyQ|KeyA", + "move_right", "", "***", "KeyRIGHT|KeyD", + "move_forward", "", "***", "KeyZ|KeyW", + "move_backward", "", "***", "KeyS", + "move_left", "", "***", "KeyQ|KeyA", + "move_right", "", "***", "KeyD", + "chat_begin", "", "***", "KeyT", + "chat_send", "", "***", "KeyENTER", + "chat_leave", "", "***", "KeyESCAPE", + "display_test", "", "***", "KeyTAB", + "send_action", "0", "---", "Key1", + "send_action", "1", "---", "Key2", + "send_action", "2", "---", "Key3", + "send_action", "3", "---", "Key4", + "send_action", "4", "---", "Key5", + "send_action", "5", "---", "Key6", + "send_action", "6", "---", "Key7", + "send_action", "7", "---", "Key8", + "send_action", "8", "---", "Key9", + "send_action", "9", "---", "Key0", + "demo_crystal_spawn", "", "---", "KeyO", + "demo_crystal_explode", "", "---", "KeyP", + "free_camera_forward", "", "---", "KeyNUMPAD8", + "free_camera_backward", "", "---", "KeyNUMPAD2", + "free_camera_left", "", "---", "KeyNUMPAD4", + "free_camera_right", "", "---", "KeyNUMPAD6", + "switch_camera", "", "---", "KeyF4", + "switch_ui_visible" ,"", "---", "KeyF6", }; // end of file diff --git a/code/ryzom/tools/leveldesign/georges_editor_qt/src/configuration.cpp b/code/ryzom/tools/leveldesign/georges_editor_qt/src/configuration.cpp index cd937688a..0e1b8fb0f 100644 --- a/code/ryzom/tools/leveldesign/georges_editor_qt/src/configuration.cpp +++ b/code/ryzom/tools/leveldesign/georges_editor_qt/src/configuration.cpp @@ -50,13 +50,13 @@ namespace NLQT { } void CConfiguration::init() - { + { // load config QFile file(NLQT_CONFIG_FILE); if (!file.exists()) { file.open( QIODevice::WriteOnly | QIODevice::Text ); - file.write("GraphicsDrivers = { \"OpenGL\", \"Direct3D\" };"); + file.write("GraphicsDrivers = { \"OpenGL\" };"); file.write("\nSearchPaths = {\"\"};"); file.write("\nRemapExtensions = { \"png\", \"tga\" };"); file.write("\nBackgroundColor = { 0, 0, 0 };"); @@ -83,7 +83,7 @@ namespace NLQT { //Modules::config().dropCallback("SearchPaths"); // save and release the config file - if (ConfigFile.exists("SaveConfig") && ConfigFile.getVarPtr("SaveConfig")->asBool()) + if (ConfigFile.exists("SaveConfig") && ConfigFile.getVarPtr("SaveConfig")->asBool()) { ConfigFile.save(); } @@ -119,7 +119,7 @@ namespace NLQT { { if (ConfigFile.exists(varName)) return ConfigFile.getVar(varName).asFloat(); CConfigFile::CVar varToCopy; - varToCopy.forceAsDouble((double)defaultValue); + varToCopy.forceAsDouble((double)defaultValue); ConfigFile.insertVar(varName, varToCopy); return defaultValue; } @@ -128,7 +128,7 @@ namespace NLQT { { if (ConfigFile.exists(varName)) return ConfigFile.getVar(varName).asDouble(); CConfigFile::CVar varToCopy; - varToCopy.forceAsDouble(defaultValue); + varToCopy.forceAsDouble(defaultValue); ConfigFile.insertVar(varName, varToCopy); return defaultValue; } @@ -137,7 +137,7 @@ namespace NLQT { { if (ConfigFile.exists(varName)) return ConfigFile.getVar(varName).asInt(); CConfigFile::CVar varToCopy; - varToCopy.forceAsInt(defaultValue); + varToCopy.forceAsInt(defaultValue); ConfigFile.insertVar(varName, varToCopy); return defaultValue; } @@ -164,14 +164,14 @@ namespace NLQT { { if (ConfigFile.exists(varName)) return ConfigFile.getVar(varName).asBool(); CConfigFile::CVar varToCopy; - varToCopy.forceAsInt(defaultValue ? 1 : 0); + varToCopy.forceAsInt(defaultValue ? 1 : 0); ConfigFile.insertVar(varName, varToCopy); return defaultValue; } CRGBA CConfiguration::getValue(const string &varName, const CRGBA &defaultValue) { - if (ConfigFile.exists(varName)) + if (ConfigFile.exists(varName)) { return getValue(ConfigFile.getVar(varName), defaultValue); } @@ -195,7 +195,7 @@ namespace NLQT { if (var.size() > 4) nlwarning("RGBA value in config value '%s' is too long, ignoring unused values"); return CRGBA((uint8)var.asInt(0), (uint8)var.asInt(1), (uint8)var.asInt(2), var.size() >= 4 ? (uint8)var.asInt(3) : 255); } - nlwarning("Invalid RGBA value in config value '%s', reverting to default { %i, %i, %i, %i }", var.Name.c_str(), (sint)defaultValue.R, (sint)defaultValue.G, (sint)defaultValue.B, (sint)defaultValue.A); + nlwarning("Invalid RGBA value in config value '%s', reverting to default { %i, %i, %i, %i }", var.Name.c_str(), (sint)defaultValue.R, (sint)defaultValue.G, (sint)defaultValue.B, (sint)defaultValue.A); return defaultValue; } @@ -215,7 +215,7 @@ namespace NLQT { } uint listsize = tmpList->size(); - for (uint i = 0; i < listsize; ++i) + for (uint i = 0; i < listsize; ++i) { if(_progressCB) { @@ -239,4 +239,4 @@ namespace NLQT { _progressCB = cb; } -} /* namespace NLQT */ \ No newline at end of file +} /* namespace NLQT */ diff --git a/code/ryzom/tools/leveldesign/georges_editor_qt/src/objectviewer_dialog.cpp b/code/ryzom/tools/leveldesign/georges_editor_qt/src/objectviewer_dialog.cpp index e3c3d24e2..b1259c1b0 100644 --- a/code/ryzom/tools/leveldesign/georges_editor_qt/src/objectviewer_dialog.cpp +++ b/code/ryzom/tools/leveldesign/georges_editor_qt/src/objectviewer_dialog.cpp @@ -46,7 +46,7 @@ namespace NLQT { _ui.setupUi(this); - if (Modules::objViewInt()) + if (Modules::objViewInt()) { _nlw = dynamic_cast(Modules::objViewInt()->getWidget()); //_nlw->setObjectName(QString::fromUtf8("nlwidget")); @@ -107,7 +107,6 @@ namespace NLQT Modules::objViewInt()->setSizeViewport(resizeEvent->size().width(), resizeEvent->size().height()); } // The OpenGL driver does not resize automatically. - // The Direct3D driver breaks the window mode to include window borders when calling setMode windowed. // Resizing the window after switching drivers a few times becomes slow. // There is probably something inside the drivers not being released properly. diff --git a/code/ryzom/tools/leveldesign/georges_plugin_sound/CMakeLists.txt b/code/ryzom/tools/leveldesign/georges_plugin_sound/CMakeLists.txt index 026548d56..224053fc1 100644 --- a/code/ryzom/tools/leveldesign/georges_plugin_sound/CMakeLists.txt +++ b/code/ryzom/tools/leveldesign/georges_plugin_sound/CMakeLists.txt @@ -5,7 +5,7 @@ ADD_LIBRARY(georges_plugin_sound SHARED ${SRC}) INCLUDE_DIRECTORIES(georges_plugin_sound ${NEL_INCLUDE_DIR} ${DXSDK_INCLUDE_DIR}) -TARGET_LINK_LIBRARIES(georges_plugin_sound nelmisc nelgeorges nelsound nelligo nelsnd_lowlevel georges_dll ${DXSDK_DSOUND_LIBRARY}) +TARGET_LINK_LIBRARIES(georges_plugin_sound nelmisc nelgeorges nelsound nelligo nelsnd_lowlevel georges_dll) NL_DEFAULT_PROPS(georges_plugin_sound "Ryzom, Tools, Georges: Georges Plugin Sound") NL_ADD_RUNTIME_FLAGS(georges_plugin_sound) NL_ADD_LIB_SUFFIX(georges_plugin_sound) diff --git a/code/ryzom/tools/leveldesign/georges_plugin_sound/sound_plugin.h b/code/ryzom/tools/leveldesign/georges_plugin_sound/sound_plugin.h index 021749d15..74c8c355b 100644 --- a/code/ryzom/tools/leveldesign/georges_plugin_sound/sound_plugin.h +++ b/code/ryzom/tools/leveldesign/georges_plugin_sound/sound_plugin.h @@ -21,7 +21,6 @@ #include #include -#include #ifdef min #undef min @@ -40,7 +39,6 @@ #include "nel/sound/driver/sound_driver.h" #include "nel/sound/driver/source.h" #include "nel/sound/driver/listener.h" -// #include "sound/driver/dsound/source_dsound.h" #include "nel/sound/u_audio_mixer.h" #include "nel/sound/u_listener.h" @@ -62,7 +60,7 @@ class CSoundPlugin : public IEditPlugin { public: // From IEditPlugin - CSoundPlugin(NLGEORGES::IEdit *globalInterface); + CSoundPlugin(NLGEORGES::IEdit *globalInterface); virtual ~CSoundPlugin(); // Overriden methods @@ -70,12 +68,12 @@ public: virtual bool pretranslateMessage(MSG *pMsg); virtual void onCreateDocument(IEditDocument *document); virtual void activate(bool activate); - virtual void getPluginName(std::string &name); + virtual void getPluginName(std::string &name); // Source control - virtual void play(std::string &filename); - virtual void play() { play(_Filename); }; - virtual void stop(); + virtual void play(std::string &filename); + virtual void play() { play(_Filename); }; + virtual void stop(); virtual uint32 getTime(); void update(); @@ -154,4 +152,4 @@ private: } // namespace NLGEORGES -#endif // _NLGEORGES_SOUND_PLUGIN_H \ No newline at end of file +#endif // _NLGEORGES_SOUND_PLUGIN_H diff --git a/code/ryzom/tools/leveldesign/install/world_editor_plugin.cfg b/code/ryzom/tools/leveldesign/install/world_editor_plugin.cfg index 1fb7d40c6..dc43c9ae9 100644 --- a/code/ryzom/tools/leveldesign/install/world_editor_plugin.cfg +++ b/code/ryzom/tools/leveldesign/install/world_editor_plugin.cfg @@ -1,4 +1,4 @@ -/* List the plusgin to load, note that mode spec (_d, _df, _rd and _r) as +/* List the plusgin to load, note that mode spec (_d, _df, _rd and _r) as * well as '.dll' are automaticaly added to the plugin name according to the * exe compilation mode. */ @@ -14,14 +14,14 @@ PluginsLibrary = { // Var related to sound plugin ///////////////////////////////////////////////////////// // "fmod" for FMod/Software (eax not available, faster, music available) -// "auto" or anything else for DSound/Hardware (eax available, but music not available). +// "auto" or anything else for Hardware (eax available, but music not available). DriverSound= "fmod"; MaxTrack = 32; SamplePath = "r:/code/ryzom/data/sound/samplebanks"; -PackedSheetPath = "r:/code/ryzom/data/sound"; +PackedSheetPath = "r:/code/ryzom/data/sound"; SearchPath = { "r:/code/ryzom/data/sound/" }; -UserVarSim = +UserVarSim = { "clouds1", "0", "clouds2", "0", @@ -51,7 +51,7 @@ PrimitivePluginSheetId = "l:/leveldesign/Game_elem/sheet_id.bin"; // Var related to shard monitor ///////////////////////////////////////////////////////// // WARNING : the following path are not recursive -ShardMonitorPath = +ShardMonitorPath = { "L:/leveldesign/Game_elem" // path where to find sheet_id.bin. }; diff --git a/code/ryzom/tools/leveldesign/world_editor/world_editor_sound_plugin/sound_plugin.cpp b/code/ryzom/tools/leveldesign/world_editor/world_editor_sound_plugin/sound_plugin.cpp index c92e90918..3e3d7f496 100644 --- a/code/ryzom/tools/leveldesign/world_editor/world_editor_sound_plugin/sound_plugin.cpp +++ b/code/ryzom/tools/leveldesign/world_editor/world_editor_sound_plugin/sound_plugin.cpp @@ -57,7 +57,7 @@ CSoundPlugin::CSoundPlugin() AssertLog->addDisplayer (SoundPluginLogDisplayer); nlinfo("Starting sound plugin..."); - + } @@ -137,7 +137,7 @@ void CSoundPlugin::ReInit() std::string packedSheetPath; CConfigFile::CVar *ppackedSheetPath = cf.getVarPtr("PackedSheetPath"); packedSheetPath = ppackedSheetPath->asString(); - + LoadDlg = new CLoadDialog; LoadDlg->Create(IDD_DIALOG_LOAD); LoadDlg->Message = "Initializing Audio Mixer"; @@ -153,7 +153,7 @@ void CSoundPlugin::ReInit() delete _Mixer; _Mixer = NULL; } - + // get maxtrack int maxTrack; try @@ -189,7 +189,7 @@ void CSoundPlugin::ReInit() } else { - // init DSound, hardware, eax + // init hardware, eax _Mixer->init(maxTrack, true, false, this, false, UAudioMixer::DriverAuto, false); } } @@ -198,7 +198,7 @@ void CSoundPlugin::ReInit() MessageBox(NULL, _T("Error while initializing audio mixer.\n"), _T("ERROR"), MB_ICONERROR); exit(1); } - + // Force reinit of all the primitives if reload if(mustReloadPrimitives) { @@ -340,16 +340,16 @@ void CSoundPlugin::update() } const NLSOUND::UAudioMixer::TBackgroundFlags &flags = _Mixer->getBackgroundFlags();; - _Mixer->update(); + _Mixer->update(); } std::string CSoundPlugin::getStatusString() { char tmp[1024]; - sprintf(tmp, "Sample mem : %7.3f Mo\nTrks/Mut/Ply/Inst : %2u/%2u/%2u/%2u", - _Mixer->getLoadedSampleSize()/(1024.0f*1024.0f), - _Mixer->getUsedTracksCount(), + sprintf(tmp, "Sample mem : %7.3f Mo\nTrks/Mut/Ply/Inst : %2u/%2u/%2u/%2u", + _Mixer->getLoadedSampleSize()/(1024.0f*1024.0f), + _Mixer->getUsedTracksCount(), _Mixer->getMutedPlayingSourcesCount(), _Mixer->getPlayingSourcesCount(), _Mixer->getSourcesInstanceCount() @@ -383,7 +383,7 @@ bool CSoundPlugin::activatePlugin() { AFX_MANAGE_STATE(AfxGetStaticModuleState()); AfxEnableControlContainer(); - + //_DialogFlag->Create(IDD_DIALOG_FLAGS, CWnd::FromHandle(_PluginAccess->getMainWindow()->m_hWnd)); _DialogFlag->ShowWindow(TRUE); //_DialogFlag->init(this); @@ -403,4 +403,4 @@ bool CSoundPlugin::closePlugin() return true; } return false; -} \ No newline at end of file +} diff --git a/code/ryzom/tools/server/build_world_packed_col/packed_world_builder.cpp b/code/ryzom/tools/server/build_world_packed_col/packed_world_builder.cpp index 779e4102d..21b0f9baa 100644 --- a/code/ryzom/tools/server/build_world_packed_col/packed_world_builder.cpp +++ b/code/ryzom/tools/server/build_world_packed_col/packed_world_builder.cpp @@ -401,7 +401,7 @@ void CPackedWorldBuilder::fly(std::vector &islands, float camSpeed // fly into scene try { - CNELU::init(1024, 768, CViewport(), 32, true, EmptyWindow, false, true); + CNELU::init(1024, 768, CViewport(), 32, true, EmptyWindow, false); } catch(const Exception &e) { diff --git a/code/ryzom/tools/translation/translated/de.uxt b/code/ryzom/tools/translation/translated/de.uxt index ea79f855a..fbfc1b3a8 100644 --- a/code/ryzom/tools/translation/translated/de.uxt +++ b/code/ryzom/tools/translation/translated/de.uxt @@ -20639,7 +20639,6 @@ uiConfigDisplayOpenGLInfo [OpenGL-Information] // HASH_VALUE 594A7C3DA0352B89 // INDEX 4900 -uiConfigDisplayD3DInfo [Direct3D-Information] // HASH_VALUE EC687094A7C8549A // INDEX 4901 @@ -20691,7 +20690,6 @@ uiConfigDriver [Treiber] // HASH_VALUE 66A22AF0BCD16D2F // INDEX 4913 -uiConfigOpenGLOrD3D [Wähle, ob Ryzom in OpenGL oder Direct3D laufen soll: ] // HASH_VALUE E59A7CA362496CA1 // INDEX 4914 @@ -20735,7 +20733,6 @@ uiConfigOpenGL [OpenGL] // HASH_VALUE 649C941064CC448C // INDEX 4924 -uiConfigDirect3D [Direct3D] // HASH_VALUE 6C1C54046C1C5404 // INDEX 4925 @@ -20907,7 +20904,6 @@ uiUpdateDisplayDriversCard [Gerät: ] // HASH_VALUE 6860E97D0D56362B // INDEX 4967 -uiUseATID3D [Ryzom läuft aktuell unter OpenGL mit einer ATI-Karte. Wir empfehlen dringend, auf D3D zu wechseln. Willst du jetzt zu D3D wechseln?] // HASH_VALUE 89273CA24287DB48 // INDEX 4968 @@ -27356,4 +27352,3 @@ uiPlaylistRefresh [Aktualisieren] // HASH_VALUE 570A63956CA078B7 // INDEX 6493 uiFreeViewTablet [Tablet oder Touchscreen] - diff --git a/code/ryzom/tools/translation/translated/en.uxt b/code/ryzom/tools/translation/translated/en.uxt index 31414770f..a50d73bf4 100644 --- a/code/ryzom/tools/translation/translated/en.uxt +++ b/code/ryzom/tools/translation/translated/en.uxt @@ -20624,7 +20624,6 @@ uiConfigDisplayOpenGLInfo [OpenGL information] // HASH_VALUE 594A7C3DA0352B89 // INDEX 4900 -uiConfigDisplayD3DInfo [Direct3D information] // HASH_VALUE EC687094A7C8549A // INDEX 4901 @@ -20676,7 +20675,6 @@ uiConfigDriver [Driver] // HASH_VALUE 66A22AF0BCD16D2F // INDEX 4913 -uiConfigOpenGLOrD3D [Specify if Ryzom is to be run in OpenGL or Direct3D:] // HASH_VALUE E59A7CA362496CA1 // INDEX 4914 @@ -20720,7 +20718,6 @@ uiConfigOpenGL [OpenGL] // HASH_VALUE 649C941064CC448C // INDEX 4924 -uiConfigDirect3D [Direct3D] // HASH_VALUE 6C1C54046C1C5404 // INDEX 4925 @@ -20892,7 +20889,6 @@ uiUpdateDisplayDriversCard [Device: ] // HASH_VALUE 6860E97D0D56362B // INDEX 4967 -uiUseATID3D [You are running with an ATI under OpenGL. We strongly recommend D3D. Do you want to change to D3D?] // HASH_VALUE 89273CA24287DB48 // INDEX 4968 @@ -27454,4 +27450,3 @@ uiMacroItemGroupMove [Move an item group] // HASH_VALUE A7A1CC916E59E066 // INDEX 6521 uiMacroItemGroupDestination [Item group destination] - diff --git a/code/ryzom/tools/translation/translated/es.uxt b/code/ryzom/tools/translation/translated/es.uxt index f6eeb3b20..37ffca4c4 100644 --- a/code/ryzom/tools/translation/translated/es.uxt +++ b/code/ryzom/tools/translation/translated/es.uxt @@ -20621,7 +20621,6 @@ uiConfigDisplayOpenGLInfo [Información OpenGL] // HASH_VALUE 594A7C3DA0352B89 // INDEX 4900 -uiConfigDisplayD3DInfo [Información Direct3D] // HASH_VALUE EC687094A7C8549A // INDEX 4901 @@ -20673,7 +20672,6 @@ uiConfigDriver [Driver] // HASH_VALUE 66A22AF0BCD16D2F // INDEX 4913 -uiConfigOpenGLOrD3D [Especificar si Ryzom debe ser ejecutado con OpenGL o Direct3D:] // HASH_VALUE E59A7CA362496CA1 // INDEX 4914 @@ -20717,7 +20715,6 @@ uiConfigOpenGL [OpenGL] // HASH_VALUE 649C941064CC448C // INDEX 4924 -uiConfigDirect3D [Direct3D] // HASH_VALUE 6C1C54046C1C5404 // INDEX 4925 @@ -20889,7 +20886,6 @@ uiUpdateDisplayDriversCard [Dispositivo: ] // HASH_VALUE 6860E97D0D56362B // INDEX 4967 -uiUseATID3D [Está ejecutando con ATI bajo OpenGL. Le recomendamos D3D. ¿Desea cambiar a D3D?] // HASH_VALUE 89273CA24287DB48 // INDEX 4968 @@ -27335,4 +27331,3 @@ uiPlayedTime [Has jugado con este personaje %time.] // HASH_VALUE EB1A8C8F22674C92 // INDEX 6492 uiPlaylistRefresh [Volver a cargar] - diff --git a/code/ryzom/tools/translation/translated/fr.uxt b/code/ryzom/tools/translation/translated/fr.uxt index 140a93052..d9c00e2bb 100644 --- a/code/ryzom/tools/translation/translated/fr.uxt +++ b/code/ryzom/tools/translation/translated/fr.uxt @@ -20610,7 +20610,6 @@ uiConfigDisplayOpenGLInfo [Informations OpenGL] // HASH_VALUE 594A7C3DA0352B89 // INDEX 4900 -uiConfigDisplayD3DInfo [Informations Direct3D] // HASH_VALUE EC687094A7C8549A // INDEX 4901 @@ -20662,7 +20661,6 @@ uiConfigDriver [Pilote] // HASH_VALUE 66A22AF0BCD16D2F // INDEX 4913 -uiConfigOpenGLOrD3D [Précisez si Ryzom doit être exécuté en OpenGL ou en Direct3D :] // HASH_VALUE E59A7CA362496CA1 // INDEX 4914 @@ -20706,7 +20704,6 @@ uiConfigOpenGL [OpenGL] // HASH_VALUE 649C941064CC448C // INDEX 4924 -uiConfigDirect3D [Direct3D] // HASH_VALUE 6C1C54046C1C5404 // INDEX 4925 @@ -20878,7 +20875,6 @@ uiUpdateDisplayDriversCard [Matériel : ] // HASH_VALUE 6860E97D0D56362B // INDEX 4967 -uiUseATID3D [Votre installation fonctionne avec un ATI sous OpenGL. Nous vous recommandons fortement D3D. Souhaitez-vous passer maintenant à D3D ?] // HASH_VALUE 89273CA24287DB48 // INDEX 4968 @@ -27428,4 +27424,3 @@ uiMacroItemGroupMove [Déplacer un groupe d'objets] // HASH_VALUE A7A1CC916E59E066 // INDEX 6521 uiMacroItemGroupDestination [Destination du groupe d'objets] - diff --git a/code/ryzom/tools/translation/translated/ru.uxt b/code/ryzom/tools/translation/translated/ru.uxt index 17df52d4e..95ce1f8fe 100644 --- a/code/ryzom/tools/translation/translated/ru.uxt +++ b/code/ryzom/tools/translation/translated/ru.uxt @@ -20636,7 +20636,6 @@ uiConfigDisplayOpenGLInfo [Информация об OpenGL] // HASH_VALUE 594A7C3DA0352B89 // INDEX 4900 -uiConfigDisplayD3DInfo [Информация о Direct3D] // HASH_VALUE EC687094A7C8549A // INDEX 4901 @@ -20688,7 +20687,6 @@ uiConfigDriver [Драйвер] // HASH_VALUE 66A22AF0BCD16D2F // INDEX 4913 -uiConfigOpenGLOrD3D [Указать, в каком режиме следует запустить Ризом (OpenGL или Direct3D):] // HASH_VALUE E59A7CA362496CA1 // INDEX 4914 @@ -20732,7 +20730,6 @@ uiConfigOpenGL [OpenGL] // HASH_VALUE 649C941064CC448C // INDEX 4924 -uiConfigDirect3D [Direct3d] // HASH_VALUE 6C1C54046C1C5404 // INDEX 4925 @@ -20904,7 +20901,6 @@ uiUpdateDisplayDriversCard [Адаптер: ] // HASH_VALUE 6860E97D0D56362B // INDEX 4967 -uiUseATID3D [Вы запускаете игру в режиме OpenGL, используя виедокарту ATI. Настояльно рекомендуем перейти в режим D3D. Вы хотите перейти в режим D3D?] // HASH_VALUE 89273CA24287DB48 // INDEX 4968 @@ -26970,4 +26966,3 @@ uiThousandsSeparator [ ] // HASH_VALUE FA309F21F9211A09 // INDEX 6398 uiRaceBold [РАСА: ] - diff --git a/code/ryzom/tools/translation/translated/wk.uxt b/code/ryzom/tools/translation/translated/wk.uxt index 74146e4e7..f86540356 100644 --- a/code/ryzom/tools/translation/translated/wk.uxt +++ b/code/ryzom/tools/translation/translated/wk.uxt @@ -4607,7 +4607,7 @@ uiBuildingEmpty [no building] // INDEX 1136 uiBuildingState0 [building] -// The guild building is building +// The guild building is building // HASH_VALUE A6F8BCAC6A59848F // INDEX 1137 uiBuildingState1 [builded] @@ -10110,7 +10110,7 @@ uiSHOUT [SHOUT] // ************************************************************************************ // ************************************************************************************ // ************************************************************************************ -// HELP +// HELP // ************************************************************************************ // ************************************************************************************ // ************************************************************************************ @@ -12617,7 +12617,7 @@ uiBeast [ANIMALS] // INDEX 2918 uiAggro [Aggressiveness] -// +// // HASH_VALUE 73A634607114247F // INDEX 2919 uiFrozenSkill [Frozen] @@ -20770,7 +20770,6 @@ uiConfigDisplayOpenGLInfo [OpenGL informations] // HASH_VALUE 594A7C3DA0352B89 // INDEX 4900 -uiConfigDisplayD3DInfo [Direct3D informations] // HASH_VALUE EC687094A7C8549A // INDEX 4901 @@ -20823,7 +20822,6 @@ uiConfigDriver [Driver] // HASH_VALUE 66A22AF0BCD16D2F // INDEX 4913 -uiConfigOpenGLOrD3D [Specify if Ryzom must be run in OpenGL or Direct3D :] // HASH_VALUE E59A7CA362496CA1 // INDEX 4914 @@ -20867,7 +20865,6 @@ uiConfigOpenGL [OpenGL] // HASH_VALUE 649C941064CC448C // INDEX 4924 -uiConfigDirect3D [Direct3d] // HASH_VALUE 6C1C54046C1C5404 // INDEX 4925 @@ -21039,10 +21036,8 @@ uiUpdateDisplayDriversVendor [Vendor : ] // INDEX 4966 uiUpdateDisplayDriversCard [Device : ] -// Question, ATI and D3D // HASH_VALUE 6860E97D0D56362B // INDEX 4967 -uiUseATID3D [You are running with an ATI under OpenGL. We strongly recommend D3D. Do you want to change to D3D?] // Error // HASH_VALUE 89273CA24287DB48 @@ -21423,7 +21418,7 @@ uiawrSFR2ARL [Living Rifle] // INDEX 5060 uiawrSFR2ARM [Rifle] -// Multiple Skill composition. NB: IMPORTANT: order of OR definition (SFM1B_SFM2B...) +// Multiple Skill composition. NB: IMPORTANT: order of OR definition (SFM1B_SFM2B...) // must be sorted by skill enum else won't match // HASH_VALUE 98A54E854608B892 // INDEX 5061 @@ -27562,4 +27557,3 @@ uiPlayedTime [You played with this character for %time.] // HASH_VALUE EB1A8C8F22674C92 // INDEX 6492 uiPlaylistRefresh [Refresh] - diff --git a/code/ryzom/tools/translation/work/wk.uxt b/code/ryzom/tools/translation/work/wk.uxt index e3902ac75..67a67e80e 100644 --- a/code/ryzom/tools/translation/work/wk.uxt +++ b/code/ryzom/tools/translation/work/wk.uxt @@ -2366,7 +2366,7 @@ uiBuildingEmpty [no building] // The guild building is not build uiBuildingState0 [building] -// The guild building is building +// The guild building is building uiBuildingState1 [builded] @@ -2497,7 +2497,7 @@ Toutes les dépenses faites pendant cette guerre ont été remboursées aux guil uiOutpostWarStatus [STATUT DE LA GUERRE] uiOutpostLvlThreshold [Seuil Minimum : ] -uittOutpostLvlThreshold +uittOutpostLvlThreshold [ @{6F6F}Seuil Minimum@{FFFF}\n C'est le @{6F6F}Niveau de Round@{FFFF} que les attaquants doivent dépasser lors de leur @{6F6F}Période d'Attaque@{FFFF}.\n @@ -2511,20 +2511,20 @@ uittOutpostLvlMaxAttacker C'est le @{6F6F}Niveau de Round@{FFFF} maximum que les attaquants ont pu valider pendant leur période d'Attaque.\n ] uiOutpostLvlMaxDefender [Niveau Max. des Défenseurs : ] -uittOutpostLvlMaxDefender +uittOutpostLvlMaxDefender [ @{6F6F}Niveau de Round@{FFFF} maximum Atteint par les défenseurs.\n C'est le @{6F6F}Niveau de Round@{FFFF} maximum que les défenseurs ont pu valider pendant leur période de Défense.\n ] uiOutpostLvlCurrent [Niveau de Round Courant : ] -uittOutpostLvlCurrent +uittOutpostLvlCurrent [ @{6F6F}Niveau de Round@{FFFF} courant.\n Pendant une période d'attaque ou de défense, C'est le @{6F6F}Niveau de Round@{FFFF} courant atteint par le camp qui attaque les escouades.\n ] uiOutpostRoundCur [Round Courant : ] -uittOutpostRoundCur +uittOutpostRoundCur [ Round courant.\n Pendant une période d'attaque ou de défense, C'est le numéro de Round courant / nombre de round maximum.\n @@ -2543,7 +2543,7 @@ uittOutpostDefHourError [ @{6F6F}Horaire de Défense@{FFFF}\n Horaire à laquelle la guilde veut défendre sont avant-poste (Horaire @{6F6F}LOCAL@{FFFF} au fuseau horaire sélectionné).\n -@{F80F}L'horaire sélectionné n'a pu être appliqué car la plage horaire doit rentrer en entier dans la phase de défense. +@{F80F}L'horaire sélectionné n'a pu être appliqué car la plage horaire doit rentrer en entier dans la phase de défense. Par conséquent l'heure de défense a été avancée. ] @@ -2573,7 +2573,7 @@ uiOutpostPeriodFormat [%dayname %daynumber %month de %timestart à %timeend] uiOutpostPeriodEnded [Attaque terminée] uiOutpostTimeZone [Fuseau Horaire : ] -uittOutpostTimeZone +uittOutpostTimeZone [ Choisissez le fuseau horaire de votre pays pour un affichage correct des heures.\n @{6F6F}Attention!@{FFFF} Il vous faut prendre en compte aussi l'heure d'été dans ce choix.\n @@ -2603,7 +2603,7 @@ uittOutpostAttHourError [ @{6F6F}Horaire d' Attaque@{FFFF}\n Horaire à laquelle la guilde veut attaquer sont avant-poste (Horaire @{6F6F}LOCAL@{FFFF} au fuseau horaire sélectionné).\n -@{F80F}L'horaire sélectionné n'a pu être appliqué car la plage horaire doit rentrer en entier dans la phase d'attaque. +@{F80F}L'horaire sélectionné n'a pu être appliqué car la plage horaire doit rentrer en entier dans la phase d'attaque. Par conséquent l'heure d'attaque a été avancée. ] @@ -2633,7 +2633,7 @@ Escouades sorties et défendant l'avant-poste.\n Au total, le nombre de squads sorties dépend directement du @{6F6F}Niveau de Round@{FFFF}.\n ] uiOutpostTSquad [ESCOUADES EN ATTENTE] -uittOutpostTSquad +uittOutpostTSquad [ Escouades prêtes à combattre et en attente pour le prochain Round.\n Suivant le @{6F6F}Niveau de Round@{FFFF}, seules les 'X' premières sortiront.\n @@ -5216,7 +5216,7 @@ uiSHOUT [SHOUT] // ************************************************************************************ // ************************************************************************************ // ************************************************************************************ -// HELP +// HELP // ************************************************************************************ // ************************************************************************************ // ************************************************************************************ @@ -5233,21 +5233,21 @@ uittKeepInfo [Keep the info in this window] // ************** // HELP - ITEM - magic bonus // ************** -uihelpItemMagicBonusAll +uihelpItemMagicBonusAll [ @{FFF9}Bonus For All Magic:\n @{T3}Cast Speed:@{T14}@{FFFF}%cs%@{FFF9}\n @{T3}Power:@{T14}@{FFFF}%mp%\n ] -uihelpItemMagicBonusOffElemental +uihelpItemMagicBonusOffElemental [ @{FFF9}Bonus For Offensive Elemental Magic:\n @{T3}Cast Speed:@{T14}@{FFFF}%cs%@{FFF9}\n @{T3}Power:@{T14}@{FFFF}%mp%\n ] -uihelpItemMagicBonusOffAffliction +uihelpItemMagicBonusOffAffliction [ @{FFF9}Bonus For Offensive Affliction Magic:\n @{T3}Cast Speed:@{T14}@{FFFF}%cs%@{FFF9}\n @@ -5255,14 +5255,14 @@ uihelpItemMagicBonusOffAffliction ] -uihelpItemMagicBonusDefHeal +uihelpItemMagicBonusDefHeal [ @{FFF9}Bonus For Defensive Heal Magic:\n @{T3}Cast Speed:@{T14}@{FFFF}%cs%@{FFF9}\n @{T3}Power:@{T14}@{FFFF}%mp%\n ] -uihelpItemMagicBonusDefAffliction +uihelpItemMagicBonusDefAffliction [ @{FFF9}Bonus For Defensive Affliction Magic:\n @@ -5378,7 +5378,7 @@ uihelpItemNoRentDesc [@{F80B}Cet item sera détruit lorsque vous vous deconnecte // HELP - ITEM - Cosmetic // ************** -uihelpItemCosmetic +uihelpItemCosmetic [ \n \n @@ -6765,7 +6765,7 @@ uiBeast [ANIMALS] uiAggro [Aggressiveness] -// +// uiFrozenSkill [Frozen] uiInitHelp1 [These buttons represents your 4 virtual desktops.] @@ -10923,8 +10923,6 @@ uiConfigDisplaySysInfo [System informations] uiConfigDisplayOpenGLInfo [OpenGL informations] -uiConfigDisplayD3DInfo [Direct3D informations] - uiConfigSound [Sound] uiConfigPoor [Low] @@ -10950,8 +10948,6 @@ uiConfigTracks [Tracks] uiConfigDriver [Driver] -uiConfigOpenGLOrD3D [Specify if Ryzom must be run in OpenGL or Direct3D :] - uiConfigParameters [Parameters] uiConfigWindowedOrFullscreen [Specify if Ryzom must be run in fullscreen or window mode :] @@ -10972,8 +10968,6 @@ uiConfigWindowed [Windowed] uiConfigOpenGL [OpenGL] -uiConfigDirect3D [Direct3d] - uiConfigAuto [Auto] uiConfigLandscape [Landscape] @@ -11063,9 +11057,6 @@ uiUpdateDisplayDriversVendor [Vendor : ] uiUpdateDisplayDriversCard [Device : ] -// Question, ATI and D3D -uiUseATID3D [You are running with an ATI under OpenGL. We strongly recommend D3D. Do you want to change to D3D?] - // Error uiDesktopNotIn32 [To run Ryzom in windowed mode, the desktop must be set in a 32 bits mode.] @@ -11266,7 +11257,7 @@ uiawrSFR2ARL [Living Rifle] uiawrSFR2ARM [Rifle] -// Multiple Skill composition. NB: IMPORTANT: order of OR definition (SFM1B_SFM2B...) +// Multiple Skill composition. NB: IMPORTANT: order of OR definition (SFM1B_SFM2B...) // must be sorted by skill enum else won't match uiawrSFM1B_SFM2B [Any Blunt Melee Weapon] @@ -11791,7 +11782,7 @@ gn_zorai_voluteer_f [zorai_voluteer] uimwEncyclopedia [ENCYCLOPEDIA] uiEncyclopedia [ENCYCLOPEDIA] -uiEncyExplanation +uiEncyExplanation [ This is your encyclopedia.\n This window is to be used for collecting the knowledge you have found on atys. The amber cube correspond to a thema. And themas are grouped in albums. @@ -11825,7 +11816,7 @@ uiItemMpNoCraft [Cannot be used to Craft] uiItemMpCraftRequirement [Requis pour l'artisanat de certains objets] uiQuitingRyzom [Leaving Ryzom...] -uiQuitingRules +uiQuitingRules [ Note: If you move or are hit, the leave will be canceled.\n Note: If you 'Quit Now' your avatar will still be connected for 30 seconds. @@ -11867,7 +11858,7 @@ uiBCNotAvailable [Not Available] uiBCDestroy [Destroy] uiBCAutoReset [Réinitialiser les Filtres à l'ouverture] -uittBCAutoReset +uittBCAutoReset [ Si coché, tous les @{6F6F}filtres@{FFFF} seront réinitialisés à l'ouverture de cette fenêtre.\n Décochez cette option pour conserver les filtres de @{6F6F}Prix@{FFFF}, @{6F6F}Qualité@{FFFF} et @{6F6F}Classe@{FFFF} entre deux ouvertures de cette fenêtre. @@ -11949,7 +11940,7 @@ uittProtect_MaxAbsorb [Maximum des Dommages Magiques absorbés.\nSomme de @{6F // Resists uiResistsTable [RESISTS] -uittMagicResistTable +uittMagicResistTable [ Les sorts des créatures et des joueurs peuvent être complètement @{6F6F}résistés@{FFFF}.\n Le @{6F6F}pourcentage de chance@{FFFF} de résistance dépend:\n @@ -12403,7 +12394,7 @@ uiMk_action3_1 [Course] uiMk_action3_1_tt [Vous êtes en mode @{6F6F}Course@{FFFF}.\nCliquez pour marcher] uiMk_action4_0 [Esquive] -uiMk_action4_0_tt +uiMk_action4_0_tt [ Vous êtes en mode @{6F6F}Esquive@{FFFF}.\n Vos chances d'esquiver dépendent de votre score d'esquive et en particulier de votre équipement (voir fenêtre @{6F6F}Identité@{FFFF}).\n @@ -12538,7 +12529,7 @@ uittInventoryWeight [@{6F6F}Poids @{FFFF}total du sac] uittFriendsOnline [Connected on the same Mainland or Ring Scenario] uittFriendsOnlineAbroad [Connected on another Mainland or Ring Scenario] -uittFriendsOffline [Not connected] +uittFriendsOffline [Not connected] uittGuildMemberOnline [Connected on the same Mainland or Ring Scenario] uittGuildMemberOnlineAbroad [Connected on another Mainland or Ring Scenario] @@ -12796,7 +12787,7 @@ uiRAP_ST_2 [Story telling] uiRAP_ST_3 [Mistery] uiRAP_ST_4 [Hack'n'Slash] uiRAP_ST_5 [Guild training] -uiRAP_ST_6 [Other] +uiRAP_ST_6 [Other] uiCP_InRingSession [The Ring Scenario that this character launched was left running. Click @{6F6F}'Resume Scenario' @{FFFF}to continue] uiCharSel_ResumeSession [Resume Scenario] @@ -13141,7 +13132,7 @@ uiBGD_NormalPriority [Normal priority] uiBGD_PriorityTooltip [Select the priority of the Ryzom Downloader. You may want to @{6F6F}Pause@{FFFF} the downloader if you experience slowdown. If you have a fast machine, or want to speed up the patching process, you select choose @{6F6F}Normal Priority@{FFFF}] uiBGD_NotUsed [Not used] // background downloader is not used, standard downloader is used instead -> this is displayed in the bg downloader window in-game - + uiBGD_ShutdownFailed [Failed to shutdown the Ryzom Downloader, you may need to restart your computer to solve the problem] uiBGD_InGamePatchIncomplete [Access to the Atys mainland and Ryzom Ring requires patching to have been finished. The patching progress is indicated in the Patch Window.] @@ -13315,7 +13306,7 @@ uittTabBuyPower [Learn new powers and auras] uittTabBuyCarac [Increase your caracteristics] uittSeconds [ second(s) ] // spell cast time (displayed in the tooltip of actions) -uittMinutes [ minutes(s) ] +uittMinutes [ minutes(s) ] uittHours [ hour(s) ] uittSecondsShort [ s ] // 'seconds' (abreviated) diff --git a/code/snowballs2/CMakePackaging.txt b/code/snowballs2/CMakePackaging.txt index 4e5ce380c..594052b3a 100644 --- a/code/snowballs2/CMakePackaging.txt +++ b/code/snowballs2/CMakePackaging.txt @@ -63,7 +63,7 @@ IF(WIN32) INSTALL(FILES ${NELNS_NEL_LAUNCHER_BIN} DESTINATION bin COMPONENT snowballsclient) # Install the sound/video drivers - INSTALL(FILES ${NELDRVOPENGL_DLL} ${NELDRVDIRECT3D_DLL} DESTINATION bin COMPONENT snowballsclient) + INSTALL(FILES ${NELDRVOPENGL_DLL} DESTINATION bin COMPONENT snowballsclient) ENDIF() IF(BUILD_SERVER) @@ -110,4 +110,3 @@ cpack_add_component(services DESCRIPTION "Snowballs Services" GROUP Server INSTALL_TYPES Full) - diff --git a/code/snowballs2/client/client.cfg.in b/code/snowballs2/client/client.cfg.in index 29409ad9b..c887fdbe5 100644 --- a/code/snowballs2/client/client.cfg.in +++ b/code/snowballs2/client/client.cfg.in @@ -60,7 +60,7 @@ StartPoint = { 1840.0, -970.0, 0.0 }; // Sound Variables /////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////// -// The sound driver, choose between "Auto", "FMod", "DSound" and "OpenAl" +// The sound driver, choose between "Auto", "FMod" and "OpenAl" SoundDriver = "FMod"; SoundMaxTracks = 32; SoundUseEax = 1; @@ -272,6 +272,6 @@ CompassColor = { 150, 50, 255, 150 }; ////////////////////////////////////////////////////////////////////////////// InstanceGroups = { -"3_AN.ig", "4_AP.ig", "5_AD.ig", "5_AK.ig", "5_AL.ig", "5_AP.ig", "5_AQ.ig", "6_AG.ig", "6_AI.ig", "6_AL.ig", "6_AN.ig", "6_AO.ig", "6_AQ.ig", "7_AJ.ig", "7_AN.ig", "7_AO.ig", "8_AL.ig", "8_AN.ig", "3_AF.ig", "8_AR.ig", "3_AG.ig", "3_AI.ig", "3_AJ.ig", "3_AL.ig", "3_AO.ig", "3_AQ.ig", "3_AR.ig", "4_AH.ig", "4_AI.ig", "4_AJ.ig", "4_AK.ig", "4_AM.ig", "4_AN.ig", "4_AQ.ig", "4_AR.ig", "5_AF.ig", "5_AI.ig", "5_AJ.ig", "5_AN.ig", "5_AO.ig", +"3_AN.ig", "4_AP.ig", "5_AD.ig", "5_AK.ig", "5_AL.ig", "5_AP.ig", "5_AQ.ig", "6_AG.ig", "6_AI.ig", "6_AL.ig", "6_AN.ig", "6_AO.ig", "6_AQ.ig", "7_AJ.ig", "7_AN.ig", "7_AO.ig", "8_AL.ig", "8_AN.ig", "3_AF.ig", "8_AR.ig", "3_AG.ig", "3_AI.ig", "3_AJ.ig", "3_AL.ig", "3_AO.ig", "3_AQ.ig", "3_AR.ig", "4_AH.ig", "4_AI.ig", "4_AJ.ig", "4_AK.ig", "4_AM.ig", "4_AN.ig", "4_AQ.ig", "4_AR.ig", "5_AF.ig", "5_AI.ig", "5_AJ.ig", "5_AN.ig", "5_AO.ig", "6_AH.ig", "6_AJ.ig", "6_AR.ig", "7_AK.ig", "7_AM.ig", "7_AR.ig", "8_AG.ig", "8_AJ.ig", "8_AK.ig" }; diff --git a/code/snowballs2/client/src/snowballs_client.cpp b/code/snowballs2/client/src/snowballs_client.cpp index 059960922..9d53a03fd 100644 --- a/code/snowballs2/client/src/snowballs_client.cpp +++ b/code/snowballs2/client/src/snowballs_client.cpp @@ -740,7 +740,6 @@ void loopIngame() // 13. Update Debug (stuff for dev) // ... - // if driver is lost (d3d) do nothing for a while if (Driver->isLost()) nlSleep(10); else { @@ -776,7 +775,7 @@ void loopIngame() { StereoDisplay->beginRenderTarget(); } - + if (!StereoDisplay || StereoDisplay->wantClear()) { effectRender = haveEffects; @@ -786,7 +785,7 @@ void loopIngame() } if (!StereoDisplay || StereoDisplay->wantScene()) - { + { // 02. Render Sky (sky scene) updateSky(); // Render the sky scene before the main scene @@ -812,7 +811,7 @@ void loopIngame() } // 06. Render Interface 3D (player names) - // ... + // ... } if (!StereoDisplay || StereoDisplay->wantInterface2D()) @@ -1049,7 +1048,7 @@ void renderLoadingState(ucstring state, bool logo3d) Driver->clearBuffers(CRGBA(0,0,0)); Driver->setMatrixMode2D(CFrustum(0.0f, ScreenWidth, 0.0f, ScreenHeight, 0.0f, 1.0f, false)); - + if (SnowballsBackground != NULL) { float imageAspect = 16.0f / 9.0f; // 1.777 @@ -1059,11 +1058,11 @@ void renderLoadingState(ucstring state, bool logo3d) float newWidth = ScreenWidth * transform; Driver->drawBitmap((newWidth - ScreenWidth) * -0.5f, 0, newWidth, ScreenHeight, *SnowballsBackground); } - + /*if (logo3d) update3dLogo(); else */ if (NelLogo != NULL) Driver->drawBitmap(16, 32 - 42, 128, 128, *NelLogo); // if (NevraxLogo != NULL) Driver->drawBitmap(ScreenWidth - 128 - 16, 32, 128, 16, *NevraxLogo); - + if (!TextContext) return; TextContext->setColor(CRGBA(255, 255, 255)); diff --git a/code/snowballs2/client/src/sound.cpp b/code/snowballs2/client/src/sound.cpp index 7ad802e03..738bf6cac 100644 --- a/code/snowballs2/client/src/sound.cpp +++ b/code/snowballs2/client/src/sound.cpp @@ -90,7 +90,7 @@ using namespace NLSOUND; //// AudioMixer = UAudioMixer::createAudioMixer (); //// std::string driverName; //// NLSOUND::UAudioMixer::TDriver driverType; -//// if (!ConfigFile->exists("SoundDriver")) +//// if (!ConfigFile->exists("SoundDriver")) ////#ifdef NL_OS_WINDOWS //// driverType = NLSOUND::UAudioMixer::DriverFMod; ////#elif defined (NL_OS_UNIX) @@ -98,12 +98,11 @@ using namespace NLSOUND; ////#else //// driverType = NLSOUND::UAudioMixer::DriverAuto; ////#endif -//// else +//// else //// { //// driverName = ConfigFile->getVar("SoundDriver").asString(); //// if (driverName == "Auto") driverType = NLSOUND::UAudioMixer::DriverAuto; //// else if (driverName == "FMod") driverType = NLSOUND::UAudioMixer::DriverFMod; -//// else if (driverName == "DSound") driverType = NLSOUND::UAudioMixer::DriverDSound; //// else if (driverName == "OpenAl") driverType = NLSOUND::UAudioMixer::DriverOpenAl; //// else nlerror("SoundDriver value '%s' is invalid.", driverName.c_str()); //// } @@ -131,7 +130,7 @@ using namespace NLSOUND; //// nlassert( SoundIdArray->size() == 2 ); //// SoundId = (*SoundIdArray)[0]; //// // StSoundId = (*SoundIdArray)[1]; */ -//// +//// //// SoundEnabled = true; ////} ////#endif @@ -176,7 +175,7 @@ using namespace NLSOUND; // ////#ifdef NL_OS_WINDOWS ////void releaseSound2() -////{ +////{ //// SoundEnabled = false; //// ConfigFile->setCallback("SoundMaxTracks", NULL); //// ConfigFile->setCallback("SoundUseEax", NULL); @@ -240,6 +239,6 @@ using namespace NLSOUND; //// return true; ////} //// -////#endif +////#endif #endif // SBCLIENT_WITH_SOUND diff --git a/code/studio/src/plugins/object_viewer/graphics_settings_page.ui b/code/studio/src/plugins/object_viewer/graphics_settings_page.ui index e6b4952a5..9f9c6e0ee 100644 --- a/code/studio/src/plugins/object_viewer/graphics_settings_page.ui +++ b/code/studio/src/plugins/object_viewer/graphics_settings_page.ui @@ -105,11 +105,6 @@ OpenGL - - - Direct3D - - diff --git a/code/studio/src/plugins/object_viewer/object_viewer.cpp b/code/studio/src/plugins/object_viewer/object_viewer.cpp index 240a0d9e9..bae6fe58c 100644 --- a/code/studio/src/plugins/object_viewer/object_viewer.cpp +++ b/code/studio/src/plugins/object_viewer/object_viewer.cpp @@ -410,11 +410,6 @@ void CObjectViewer::setBackgroundColor(NLMISC::CRGBA backgroundColor) _BackgroundColor = backgroundColor; } -void CObjectViewer::setGraphicsDriver(bool Direct3D) -{ - _Direct3D = Direct3D; -} - void CObjectViewer::setSizeViewport(uint16 w, uint16 h) { _Scene->getCam().setPerspective(_CameraFocal * (float)NLMISC::Pi/180.f, (float)w/h, 0.1f, 1000); @@ -450,12 +445,11 @@ void CObjectViewer::loadConfig() color = settings->value("BackgroundColor", QColor(80, 80, 80)).value(); _BackgroundColor = NLMISC::CRGBA(color.red(), color.green(), color.blue(), color.alpha()); - _Direct3D = false; //_Driver = OpenGL; + _Driver = OpenGL; #ifdef NL_OS_WINDOWS QString driver = settings->value(Constants::GRAPHICS_DRIVER, "OpenGL").toString(); - if (driver == "Direct3D") _Direct3D = true; //m_Driver = Direct3D; - else if (driver == "OpenGL") _Direct3D = false; //m_Driver = OpenGL; + if (driver == "OpenGL") m_Driver = OpenGL; else nlwarning("Invalid driver specified, defaulting to OpenGL"); #endif diff --git a/code/studio/src/plugins/object_viewer/object_viewer.h b/code/studio/src/plugins/object_viewer/object_viewer.h index e8cc7304e..4c7fb4672 100644 --- a/code/studio/src/plugins/object_viewer/object_viewer.h +++ b/code/studio/src/plugins/object_viewer/object_viewer.h @@ -53,7 +53,7 @@ namespace NLQT /** @class CObjectViewer @brief The class initializes the driver and creates a scene, provides basic control functions over the stage driver. -@details The class initializes the driver (by choosing OpenGL or Direct3D), and creates a scene (set an aspect), respectively +@details The class initializes the driver (by choosing OpenGL), and creates a scene (set an aspect), respectively creates a light as well, load the font that is available further for all other subsystems (eg: the signature of the coordinate axes) and Mouse Listener. Settings are loaded from the configuration file. @@ -125,10 +125,6 @@ public: /// @param backgroundColor - background color. void setBackgroundColor(NLMISC::CRGBA backgroundColor); - /// Set type driver. - /// @param Direct3D - type driver (true - Direct3D) or (false -OpenGL) - void setGraphicsDriver(bool Direct3D); - /// Set size viewport for correct set perspective /// @param w - width window. /// @param h - height window. @@ -165,13 +161,6 @@ public: return _BackgroundColor; } - /// Get type driver. - /// @return true if have used Direct3D driver, false OpenGL driver. - inline bool getDirect3D() const - { - return _Direct3D; - } - inline bool getBloomEffect() const { return _BloomEffect; @@ -250,7 +239,6 @@ private: std::string _FontName; - bool _Direct3D; bool _BloomEffect; int _BloomDensity; bool _BloomSquare; diff --git a/code/studio/src/plugins/object_viewer/sound_settings_page.ui b/code/studio/src/plugins/object_viewer/sound_settings_page.ui index bcb29b060..0a58d7763 100644 --- a/code/studio/src/plugins/object_viewer/sound_settings_page.ui +++ b/code/studio/src/plugins/object_viewer/sound_settings_page.ui @@ -54,21 +54,11 @@ OpenAL - - - XAudio2 - - FMod - - - DSound - - diff --git a/code/studio/src/translations/object_viewer_qt_de.ts b/code/studio/src/translations/object_viewer_qt_de.ts index 696013950..e85cb703b 100644 --- a/code/studio/src/translations/object_viewer_qt_de.ts +++ b/code/studio/src/translations/object_viewer_qt_de.ts @@ -3121,11 +3121,6 @@ Reason: %3 OpenGL - - - Direct3D - - Qt Style @@ -4685,21 +4680,11 @@ Reason: %3 OpenAL - - - XAudio2 - - FMod - - - DSound - - SoundAutoLoadSample diff --git a/code/studio/src/translations/object_viewer_qt_en.ts b/code/studio/src/translations/object_viewer_qt_en.ts index 4e1e28ab8..58f94c592 100644 --- a/code/studio/src/translations/object_viewer_qt_en.ts +++ b/code/studio/src/translations/object_viewer_qt_en.ts @@ -3121,11 +3121,6 @@ Reason: %3 OpenGL - - - Direct3D - - Qt Style @@ -4685,21 +4680,11 @@ Reason: %3 OpenAL - - - XAudio2 - - FMod - - - DSound - - SoundAutoLoadSample diff --git a/code/studio/src/translations/object_viewer_qt_fr.ts b/code/studio/src/translations/object_viewer_qt_fr.ts index 3d2b9f8bd..af536e74f 100644 --- a/code/studio/src/translations/object_viewer_qt_fr.ts +++ b/code/studio/src/translations/object_viewer_qt_fr.ts @@ -3121,11 +3121,6 @@ Reason: %3 OpenGL OpenGL - - - Direct3D - Direct3D - Qt Style @@ -4685,21 +4680,11 @@ Reason: %3 OpenAL - - - XAudio2 - - FMod - - - DSound - - SoundAutoLoadSample diff --git a/code/studio/src/translations/object_viewer_qt_ru.ts b/code/studio/src/translations/object_viewer_qt_ru.ts index f86ccaa90..df1863b70 100644 --- a/code/studio/src/translations/object_viewer_qt_ru.ts +++ b/code/studio/src/translations/object_viewer_qt_ru.ts @@ -3121,11 +3121,6 @@ Reason: %3 OpenGL - - - Direct3D - - Qt Style @@ -3498,7 +3493,7 @@ Reason: %3 Can't perform operation : the system is flagged with 'No max nb steps' or uses the preset 'Spell FX', and thus, should have a finite duration. Please remove that flag first. - Невозможно выполнить операцию: система частиц помечен флагом "No max nb steps" или использует "Spell FX, + Невозможно выполнить операцию: система частиц помечен флагом "No max nb steps" или использует "Spell FX, и, таким образом, должна иметь конечную длительность. Пожалуйста, удалите этот флаг в первую очередь. @@ -3641,7 +3636,7 @@ Reason: %3 Can't perform operation : the system is flagged with 'No max nb steps' or uses the preset 'Spell FX', and thus, should have a finite duration. Please remove that flag first. - Невозможно выполнить операцию: система помечена "No max nb steps" или использует "Spell FX, + Невозможно выполнить операцию: система помечена "No max nb steps" или использует "Spell FX, и, таким образом, должна иметь конечную длительность. Пожалуйста, удалите этот флаг в первую очередь. @@ -3832,7 +3827,7 @@ Reason: %3 Can't perform operation : the system is flagged with 'No max nb steps' or uses the preset 'Spell FX', and thus, should have a finite duration. Please remove that flag first. - Невозможно выполнить операцию: система помечена "No max nb steps" или использует "Spell FX, + Невозможно выполнить операцию: система помечена "No max nb steps" или использует "Spell FX, и, таким образом, должна иметь конечную длительность. Пожалуйста, удалите этот флаг в первую очередь. @@ -4019,7 +4014,7 @@ Reason: %3 Can't perform operation : the system is flagged with 'No max nb steps' or uses the preset 'Spell FX', and thus, should have a finite duration. Please remove that flag first. - Невозможно выполнить операцию: система помечена "No max nb steps" или использует "Spell FX, + Невозможно выполнить операцию: система помечена "No max nb steps" или использует "Spell FX, и, таким образом, должна иметь конечную длительность. Пожалуйста, удалите этот флаг в первую очередь. @@ -4690,21 +4685,11 @@ Reason: %3 OpenAL - - - XAudio2 - - FMod - - - DSound - - SoundAutoLoadSample diff --git a/dist/debian/jessie/debian/client_default.cfg b/dist/debian/jessie/debian/client_default.cfg index d09cbbb9c..745c6c20a 100644 --- a/dist/debian/jessie/debian/client_default.cfg +++ b/dist/debian/jessie/debian/client_default.cfg @@ -5,7 +5,7 @@ ////////////////////////// -// If you set this variable to 1, your client.cfg will be overwritten when you quit the client. +// If you set this variable to 1, your client.cfg will be overwritten when you quit the client. // You will loose all the comments and identation in this file. SaveConfig = 1; @@ -13,7 +13,7 @@ SaveConfig = 1; // WINDOW CONFIG // /////////////////// -Driver3D="Auto"; // Valid values are "Auto" or "0", "OpengGL" or "1" & "Direct3D" or "2" +Driver3D="Auto"; // Valid values are "Auto" or "0", "OpengGL" or "1" // "Auto" will choose the best suited driver depending on hardware FullScreen = 0; Width = 1024; @@ -59,21 +59,21 @@ LanguageCode = "en"; // english XMLInputFile = "input_config_v3.xml"; -XMLLoginInterfaceFiles = { - "login_config.xml", - "login_widgets.xml", +XMLLoginInterfaceFiles = { + "login_config.xml", + "login_widgets.xml", "login_main.xml", "login_keys.xml", }; -XMLOutGameInterfaceFiles = { - "out_v2_config.xml", - "out_v2_widgets.xml", +XMLOutGameInterfaceFiles = { + "out_v2_config.xml", + "out_v2_widgets.xml", "out_v2_connect.xml", "out_v2_intro.xml", "out_v2_select.xml", "out_v2_appear.xml", - "out_v2_location.xml", + "out_v2_location.xml", "out_v2_crash.xml", "out_v2_hierarchy.xml", "out_v2_keys.xml", @@ -338,8 +338,8 @@ ScreenShotHeight = 0; ScreenShotFullDetail = 1; // 1 to switch full detail mode for characters (both standard & big screenshots) // Read : "ID", "R G B A MODE [FX]" -SystemInfoColors = -{ +SystemInfoColors = +{ // OLD STUFF Here for compatibility "RG", "0 0 0 255 normal", // Black to see when there is an error "BC", "0 0 0 255 normal", // Black to see when there is an error @@ -384,22 +384,22 @@ SystemInfoColors = }; PrintfCommands = { - "52", "15", "55 55 0 255", "28", "uiChapterV", "624", - "428", "0 0 0 255", "18", "", "624", "378", - "0 0 0 255", "14", "", "644", "278", "0 0 0 255", - "18", "", "52", "17", "255 255 255 255", "28", - "uiChapterV", "622", "430", "255 255 255 255", "18", "", - "622", "380", "255 255 255 255", "14", "", "642", + "52", "15", "55 55 0 255", "28", "uiChapterV", "624", + "428", "0 0 0 255", "18", "", "624", "378", + "0 0 0 255", "14", "", "644", "278", "0 0 0 255", + "18", "", "52", "17", "255 255 255 255", "28", + "uiChapterV", "622", "430", "255 255 255 255", "18", "", + "622", "380", "255 255 255 255", "14", "", "642", "280", "255 255 255 255", "18", "" }; PrintfCommandsFreeTrial = { - "52", "15", "55 55 0 255", "28", "uiChapterV", "624", - "428", "0 0 0 255", "18", "", "624", "378", - "0 0 0 255", "14", "", "644", "278", "0 0 0 255", - "18", "", "52", "17", "255 255 255 255", "28", - "uiChapterV", "622", "430", "255 255 255 255", "18", "", - "622", "380", "255 255 255 255", "14", "", "642", + "52", "15", "55 55 0 255", "28", "uiChapterV", "624", + "428", "0 0 0 255", "18", "", "624", "378", + "0 0 0 255", "14", "", "644", "278", "0 0 0 255", + "18", "", "52", "17", "255 255 255 255", "28", + "uiChapterV", "622", "430", "255 255 255 255", "18", "", + "622", "380", "255 255 255 255", "14", "", "642", "280", "255 255 255 255", "18", "" }; @@ -429,11 +429,11 @@ R2EDReloadFiles = { "r2_components.lua", "r2_core.lua", "r2_features_default.lua", - "r2_features_fauna.lua", + "r2_features_fauna.lua", "r2_features_npc_groups.lua", "r2_palette.lua", "r2_scenario.lua", - "r2_ui.lua" + "r2_ui.lua" }; XMLInterfaceFiles = { @@ -469,21 +469,21 @@ XMLInterfaceFiles = { }; XMLR2EDInterfaceFiles = -{ +{ "r2ed.xml", "r2_triggers.xml", "r2_logic_entities.xml", "r2ed_acts.xml", "r2ed_scenario.xml", "r2ed_connect.xml" -}; +}; FogDistAndDepthLookupBias = 20; // bias for lookup of fog distance and depth -// Hardware cursor textures +// Hardware cursor textures // These will be extracted from the corresponding packed ui .tga files when they are loaded -// * +// * // * individual .tga files for hardware cursor bitmap not looked for, and not supported yet HardwareCursors = { @@ -548,7 +548,7 @@ ScenarioTypes = {"so_newbie_training","so_story_telling","so_mistery","so_hack_s ScenarioLanguages = {"fr","de","en","other_lang"}; // Map each language to a forum help page -HelpPages = +HelpPages = { "fr=http://forums.ryzom.com/forum/showthread.php?t=29130", "en=http://forums.ryzom.com/forum/showthread.php?t=29129", @@ -558,7 +558,7 @@ HelpPages = WebIgMainDomain = "app.ryzom.com"; WebIgTrustedDomains = { - "api.ryzom.com", "app.ryzom.com" + "api.ryzom.com", "app.ryzom.com" }; PatchletUrl = "http://app.ryzom.com/app_patchlet/index.php?patch=preload"; diff --git a/dist/debian/precise/debian/client_default.cfg b/dist/debian/precise/debian/client_default.cfg index d09cbbb9c..745c6c20a 100644 --- a/dist/debian/precise/debian/client_default.cfg +++ b/dist/debian/precise/debian/client_default.cfg @@ -5,7 +5,7 @@ ////////////////////////// -// If you set this variable to 1, your client.cfg will be overwritten when you quit the client. +// If you set this variable to 1, your client.cfg will be overwritten when you quit the client. // You will loose all the comments and identation in this file. SaveConfig = 1; @@ -13,7 +13,7 @@ SaveConfig = 1; // WINDOW CONFIG // /////////////////// -Driver3D="Auto"; // Valid values are "Auto" or "0", "OpengGL" or "1" & "Direct3D" or "2" +Driver3D="Auto"; // Valid values are "Auto" or "0", "OpengGL" or "1" // "Auto" will choose the best suited driver depending on hardware FullScreen = 0; Width = 1024; @@ -59,21 +59,21 @@ LanguageCode = "en"; // english XMLInputFile = "input_config_v3.xml"; -XMLLoginInterfaceFiles = { - "login_config.xml", - "login_widgets.xml", +XMLLoginInterfaceFiles = { + "login_config.xml", + "login_widgets.xml", "login_main.xml", "login_keys.xml", }; -XMLOutGameInterfaceFiles = { - "out_v2_config.xml", - "out_v2_widgets.xml", +XMLOutGameInterfaceFiles = { + "out_v2_config.xml", + "out_v2_widgets.xml", "out_v2_connect.xml", "out_v2_intro.xml", "out_v2_select.xml", "out_v2_appear.xml", - "out_v2_location.xml", + "out_v2_location.xml", "out_v2_crash.xml", "out_v2_hierarchy.xml", "out_v2_keys.xml", @@ -338,8 +338,8 @@ ScreenShotHeight = 0; ScreenShotFullDetail = 1; // 1 to switch full detail mode for characters (both standard & big screenshots) // Read : "ID", "R G B A MODE [FX]" -SystemInfoColors = -{ +SystemInfoColors = +{ // OLD STUFF Here for compatibility "RG", "0 0 0 255 normal", // Black to see when there is an error "BC", "0 0 0 255 normal", // Black to see when there is an error @@ -384,22 +384,22 @@ SystemInfoColors = }; PrintfCommands = { - "52", "15", "55 55 0 255", "28", "uiChapterV", "624", - "428", "0 0 0 255", "18", "", "624", "378", - "0 0 0 255", "14", "", "644", "278", "0 0 0 255", - "18", "", "52", "17", "255 255 255 255", "28", - "uiChapterV", "622", "430", "255 255 255 255", "18", "", - "622", "380", "255 255 255 255", "14", "", "642", + "52", "15", "55 55 0 255", "28", "uiChapterV", "624", + "428", "0 0 0 255", "18", "", "624", "378", + "0 0 0 255", "14", "", "644", "278", "0 0 0 255", + "18", "", "52", "17", "255 255 255 255", "28", + "uiChapterV", "622", "430", "255 255 255 255", "18", "", + "622", "380", "255 255 255 255", "14", "", "642", "280", "255 255 255 255", "18", "" }; PrintfCommandsFreeTrial = { - "52", "15", "55 55 0 255", "28", "uiChapterV", "624", - "428", "0 0 0 255", "18", "", "624", "378", - "0 0 0 255", "14", "", "644", "278", "0 0 0 255", - "18", "", "52", "17", "255 255 255 255", "28", - "uiChapterV", "622", "430", "255 255 255 255", "18", "", - "622", "380", "255 255 255 255", "14", "", "642", + "52", "15", "55 55 0 255", "28", "uiChapterV", "624", + "428", "0 0 0 255", "18", "", "624", "378", + "0 0 0 255", "14", "", "644", "278", "0 0 0 255", + "18", "", "52", "17", "255 255 255 255", "28", + "uiChapterV", "622", "430", "255 255 255 255", "18", "", + "622", "380", "255 255 255 255", "14", "", "642", "280", "255 255 255 255", "18", "" }; @@ -429,11 +429,11 @@ R2EDReloadFiles = { "r2_components.lua", "r2_core.lua", "r2_features_default.lua", - "r2_features_fauna.lua", + "r2_features_fauna.lua", "r2_features_npc_groups.lua", "r2_palette.lua", "r2_scenario.lua", - "r2_ui.lua" + "r2_ui.lua" }; XMLInterfaceFiles = { @@ -469,21 +469,21 @@ XMLInterfaceFiles = { }; XMLR2EDInterfaceFiles = -{ +{ "r2ed.xml", "r2_triggers.xml", "r2_logic_entities.xml", "r2ed_acts.xml", "r2ed_scenario.xml", "r2ed_connect.xml" -}; +}; FogDistAndDepthLookupBias = 20; // bias for lookup of fog distance and depth -// Hardware cursor textures +// Hardware cursor textures // These will be extracted from the corresponding packed ui .tga files when they are loaded -// * +// * // * individual .tga files for hardware cursor bitmap not looked for, and not supported yet HardwareCursors = { @@ -548,7 +548,7 @@ ScenarioTypes = {"so_newbie_training","so_story_telling","so_mistery","so_hack_s ScenarioLanguages = {"fr","de","en","other_lang"}; // Map each language to a forum help page -HelpPages = +HelpPages = { "fr=http://forums.ryzom.com/forum/showthread.php?t=29130", "en=http://forums.ryzom.com/forum/showthread.php?t=29129", @@ -558,7 +558,7 @@ HelpPages = WebIgMainDomain = "app.ryzom.com"; WebIgTrustedDomains = { - "api.ryzom.com", "app.ryzom.com" + "api.ryzom.com", "app.ryzom.com" }; PatchletUrl = "http://app.ryzom.com/app_patchlet/index.php?patch=preload"; diff --git a/dist/debian/trusty/debian/client_default.cfg b/dist/debian/trusty/debian/client_default.cfg index d09cbbb9c..745c6c20a 100644 --- a/dist/debian/trusty/debian/client_default.cfg +++ b/dist/debian/trusty/debian/client_default.cfg @@ -5,7 +5,7 @@ ////////////////////////// -// If you set this variable to 1, your client.cfg will be overwritten when you quit the client. +// If you set this variable to 1, your client.cfg will be overwritten when you quit the client. // You will loose all the comments and identation in this file. SaveConfig = 1; @@ -13,7 +13,7 @@ SaveConfig = 1; // WINDOW CONFIG // /////////////////// -Driver3D="Auto"; // Valid values are "Auto" or "0", "OpengGL" or "1" & "Direct3D" or "2" +Driver3D="Auto"; // Valid values are "Auto" or "0", "OpengGL" or "1" // "Auto" will choose the best suited driver depending on hardware FullScreen = 0; Width = 1024; @@ -59,21 +59,21 @@ LanguageCode = "en"; // english XMLInputFile = "input_config_v3.xml"; -XMLLoginInterfaceFiles = { - "login_config.xml", - "login_widgets.xml", +XMLLoginInterfaceFiles = { + "login_config.xml", + "login_widgets.xml", "login_main.xml", "login_keys.xml", }; -XMLOutGameInterfaceFiles = { - "out_v2_config.xml", - "out_v2_widgets.xml", +XMLOutGameInterfaceFiles = { + "out_v2_config.xml", + "out_v2_widgets.xml", "out_v2_connect.xml", "out_v2_intro.xml", "out_v2_select.xml", "out_v2_appear.xml", - "out_v2_location.xml", + "out_v2_location.xml", "out_v2_crash.xml", "out_v2_hierarchy.xml", "out_v2_keys.xml", @@ -338,8 +338,8 @@ ScreenShotHeight = 0; ScreenShotFullDetail = 1; // 1 to switch full detail mode for characters (both standard & big screenshots) // Read : "ID", "R G B A MODE [FX]" -SystemInfoColors = -{ +SystemInfoColors = +{ // OLD STUFF Here for compatibility "RG", "0 0 0 255 normal", // Black to see when there is an error "BC", "0 0 0 255 normal", // Black to see when there is an error @@ -384,22 +384,22 @@ SystemInfoColors = }; PrintfCommands = { - "52", "15", "55 55 0 255", "28", "uiChapterV", "624", - "428", "0 0 0 255", "18", "", "624", "378", - "0 0 0 255", "14", "", "644", "278", "0 0 0 255", - "18", "", "52", "17", "255 255 255 255", "28", - "uiChapterV", "622", "430", "255 255 255 255", "18", "", - "622", "380", "255 255 255 255", "14", "", "642", + "52", "15", "55 55 0 255", "28", "uiChapterV", "624", + "428", "0 0 0 255", "18", "", "624", "378", + "0 0 0 255", "14", "", "644", "278", "0 0 0 255", + "18", "", "52", "17", "255 255 255 255", "28", + "uiChapterV", "622", "430", "255 255 255 255", "18", "", + "622", "380", "255 255 255 255", "14", "", "642", "280", "255 255 255 255", "18", "" }; PrintfCommandsFreeTrial = { - "52", "15", "55 55 0 255", "28", "uiChapterV", "624", - "428", "0 0 0 255", "18", "", "624", "378", - "0 0 0 255", "14", "", "644", "278", "0 0 0 255", - "18", "", "52", "17", "255 255 255 255", "28", - "uiChapterV", "622", "430", "255 255 255 255", "18", "", - "622", "380", "255 255 255 255", "14", "", "642", + "52", "15", "55 55 0 255", "28", "uiChapterV", "624", + "428", "0 0 0 255", "18", "", "624", "378", + "0 0 0 255", "14", "", "644", "278", "0 0 0 255", + "18", "", "52", "17", "255 255 255 255", "28", + "uiChapterV", "622", "430", "255 255 255 255", "18", "", + "622", "380", "255 255 255 255", "14", "", "642", "280", "255 255 255 255", "18", "" }; @@ -429,11 +429,11 @@ R2EDReloadFiles = { "r2_components.lua", "r2_core.lua", "r2_features_default.lua", - "r2_features_fauna.lua", + "r2_features_fauna.lua", "r2_features_npc_groups.lua", "r2_palette.lua", "r2_scenario.lua", - "r2_ui.lua" + "r2_ui.lua" }; XMLInterfaceFiles = { @@ -469,21 +469,21 @@ XMLInterfaceFiles = { }; XMLR2EDInterfaceFiles = -{ +{ "r2ed.xml", "r2_triggers.xml", "r2_logic_entities.xml", "r2ed_acts.xml", "r2ed_scenario.xml", "r2ed_connect.xml" -}; +}; FogDistAndDepthLookupBias = 20; // bias for lookup of fog distance and depth -// Hardware cursor textures +// Hardware cursor textures // These will be extracted from the corresponding packed ui .tga files when they are loaded -// * +// * // * individual .tga files for hardware cursor bitmap not looked for, and not supported yet HardwareCursors = { @@ -548,7 +548,7 @@ ScenarioTypes = {"so_newbie_training","so_story_telling","so_mistery","so_hack_s ScenarioLanguages = {"fr","de","en","other_lang"}; // Map each language to a forum help page -HelpPages = +HelpPages = { "fr=http://forums.ryzom.com/forum/showthread.php?t=29130", "en=http://forums.ryzom.com/forum/showthread.php?t=29129", @@ -558,7 +558,7 @@ HelpPages = WebIgMainDomain = "app.ryzom.com"; WebIgTrustedDomains = { - "api.ryzom.com", "app.ryzom.com" + "api.ryzom.com", "app.ryzom.com" }; PatchletUrl = "http://app.ryzom.com/app_patchlet/index.php?patch=preload"; diff --git a/dist/debian/utopic/debian/client_default.cfg b/dist/debian/utopic/debian/client_default.cfg index d09cbbb9c..745c6c20a 100644 --- a/dist/debian/utopic/debian/client_default.cfg +++ b/dist/debian/utopic/debian/client_default.cfg @@ -5,7 +5,7 @@ ////////////////////////// -// If you set this variable to 1, your client.cfg will be overwritten when you quit the client. +// If you set this variable to 1, your client.cfg will be overwritten when you quit the client. // You will loose all the comments and identation in this file. SaveConfig = 1; @@ -13,7 +13,7 @@ SaveConfig = 1; // WINDOW CONFIG // /////////////////// -Driver3D="Auto"; // Valid values are "Auto" or "0", "OpengGL" or "1" & "Direct3D" or "2" +Driver3D="Auto"; // Valid values are "Auto" or "0", "OpengGL" or "1" // "Auto" will choose the best suited driver depending on hardware FullScreen = 0; Width = 1024; @@ -59,21 +59,21 @@ LanguageCode = "en"; // english XMLInputFile = "input_config_v3.xml"; -XMLLoginInterfaceFiles = { - "login_config.xml", - "login_widgets.xml", +XMLLoginInterfaceFiles = { + "login_config.xml", + "login_widgets.xml", "login_main.xml", "login_keys.xml", }; -XMLOutGameInterfaceFiles = { - "out_v2_config.xml", - "out_v2_widgets.xml", +XMLOutGameInterfaceFiles = { + "out_v2_config.xml", + "out_v2_widgets.xml", "out_v2_connect.xml", "out_v2_intro.xml", "out_v2_select.xml", "out_v2_appear.xml", - "out_v2_location.xml", + "out_v2_location.xml", "out_v2_crash.xml", "out_v2_hierarchy.xml", "out_v2_keys.xml", @@ -338,8 +338,8 @@ ScreenShotHeight = 0; ScreenShotFullDetail = 1; // 1 to switch full detail mode for characters (both standard & big screenshots) // Read : "ID", "R G B A MODE [FX]" -SystemInfoColors = -{ +SystemInfoColors = +{ // OLD STUFF Here for compatibility "RG", "0 0 0 255 normal", // Black to see when there is an error "BC", "0 0 0 255 normal", // Black to see when there is an error @@ -384,22 +384,22 @@ SystemInfoColors = }; PrintfCommands = { - "52", "15", "55 55 0 255", "28", "uiChapterV", "624", - "428", "0 0 0 255", "18", "", "624", "378", - "0 0 0 255", "14", "", "644", "278", "0 0 0 255", - "18", "", "52", "17", "255 255 255 255", "28", - "uiChapterV", "622", "430", "255 255 255 255", "18", "", - "622", "380", "255 255 255 255", "14", "", "642", + "52", "15", "55 55 0 255", "28", "uiChapterV", "624", + "428", "0 0 0 255", "18", "", "624", "378", + "0 0 0 255", "14", "", "644", "278", "0 0 0 255", + "18", "", "52", "17", "255 255 255 255", "28", + "uiChapterV", "622", "430", "255 255 255 255", "18", "", + "622", "380", "255 255 255 255", "14", "", "642", "280", "255 255 255 255", "18", "" }; PrintfCommandsFreeTrial = { - "52", "15", "55 55 0 255", "28", "uiChapterV", "624", - "428", "0 0 0 255", "18", "", "624", "378", - "0 0 0 255", "14", "", "644", "278", "0 0 0 255", - "18", "", "52", "17", "255 255 255 255", "28", - "uiChapterV", "622", "430", "255 255 255 255", "18", "", - "622", "380", "255 255 255 255", "14", "", "642", + "52", "15", "55 55 0 255", "28", "uiChapterV", "624", + "428", "0 0 0 255", "18", "", "624", "378", + "0 0 0 255", "14", "", "644", "278", "0 0 0 255", + "18", "", "52", "17", "255 255 255 255", "28", + "uiChapterV", "622", "430", "255 255 255 255", "18", "", + "622", "380", "255 255 255 255", "14", "", "642", "280", "255 255 255 255", "18", "" }; @@ -429,11 +429,11 @@ R2EDReloadFiles = { "r2_components.lua", "r2_core.lua", "r2_features_default.lua", - "r2_features_fauna.lua", + "r2_features_fauna.lua", "r2_features_npc_groups.lua", "r2_palette.lua", "r2_scenario.lua", - "r2_ui.lua" + "r2_ui.lua" }; XMLInterfaceFiles = { @@ -469,21 +469,21 @@ XMLInterfaceFiles = { }; XMLR2EDInterfaceFiles = -{ +{ "r2ed.xml", "r2_triggers.xml", "r2_logic_entities.xml", "r2ed_acts.xml", "r2ed_scenario.xml", "r2ed_connect.xml" -}; +}; FogDistAndDepthLookupBias = 20; // bias for lookup of fog distance and depth -// Hardware cursor textures +// Hardware cursor textures // These will be extracted from the corresponding packed ui .tga files when they are loaded -// * +// * // * individual .tga files for hardware cursor bitmap not looked for, and not supported yet HardwareCursors = { @@ -548,7 +548,7 @@ ScenarioTypes = {"so_newbie_training","so_story_telling","so_mistery","so_hack_s ScenarioLanguages = {"fr","de","en","other_lang"}; // Map each language to a forum help page -HelpPages = +HelpPages = { "fr=http://forums.ryzom.com/forum/showthread.php?t=29130", "en=http://forums.ryzom.com/forum/showthread.php?t=29129", @@ -558,7 +558,7 @@ HelpPages = WebIgMainDomain = "app.ryzom.com"; WebIgTrustedDomains = { - "api.ryzom.com", "app.ryzom.com" + "api.ryzom.com", "app.ryzom.com" }; PatchletUrl = "http://app.ryzom.com/app_patchlet/index.php?patch=preload"; diff --git a/dist/debian/vivid/debian/client_default.cfg b/dist/debian/vivid/debian/client_default.cfg index d09cbbb9c..745c6c20a 100644 --- a/dist/debian/vivid/debian/client_default.cfg +++ b/dist/debian/vivid/debian/client_default.cfg @@ -5,7 +5,7 @@ ////////////////////////// -// If you set this variable to 1, your client.cfg will be overwritten when you quit the client. +// If you set this variable to 1, your client.cfg will be overwritten when you quit the client. // You will loose all the comments and identation in this file. SaveConfig = 1; @@ -13,7 +13,7 @@ SaveConfig = 1; // WINDOW CONFIG // /////////////////// -Driver3D="Auto"; // Valid values are "Auto" or "0", "OpengGL" or "1" & "Direct3D" or "2" +Driver3D="Auto"; // Valid values are "Auto" or "0", "OpengGL" or "1" // "Auto" will choose the best suited driver depending on hardware FullScreen = 0; Width = 1024; @@ -59,21 +59,21 @@ LanguageCode = "en"; // english XMLInputFile = "input_config_v3.xml"; -XMLLoginInterfaceFiles = { - "login_config.xml", - "login_widgets.xml", +XMLLoginInterfaceFiles = { + "login_config.xml", + "login_widgets.xml", "login_main.xml", "login_keys.xml", }; -XMLOutGameInterfaceFiles = { - "out_v2_config.xml", - "out_v2_widgets.xml", +XMLOutGameInterfaceFiles = { + "out_v2_config.xml", + "out_v2_widgets.xml", "out_v2_connect.xml", "out_v2_intro.xml", "out_v2_select.xml", "out_v2_appear.xml", - "out_v2_location.xml", + "out_v2_location.xml", "out_v2_crash.xml", "out_v2_hierarchy.xml", "out_v2_keys.xml", @@ -338,8 +338,8 @@ ScreenShotHeight = 0; ScreenShotFullDetail = 1; // 1 to switch full detail mode for characters (both standard & big screenshots) // Read : "ID", "R G B A MODE [FX]" -SystemInfoColors = -{ +SystemInfoColors = +{ // OLD STUFF Here for compatibility "RG", "0 0 0 255 normal", // Black to see when there is an error "BC", "0 0 0 255 normal", // Black to see when there is an error @@ -384,22 +384,22 @@ SystemInfoColors = }; PrintfCommands = { - "52", "15", "55 55 0 255", "28", "uiChapterV", "624", - "428", "0 0 0 255", "18", "", "624", "378", - "0 0 0 255", "14", "", "644", "278", "0 0 0 255", - "18", "", "52", "17", "255 255 255 255", "28", - "uiChapterV", "622", "430", "255 255 255 255", "18", "", - "622", "380", "255 255 255 255", "14", "", "642", + "52", "15", "55 55 0 255", "28", "uiChapterV", "624", + "428", "0 0 0 255", "18", "", "624", "378", + "0 0 0 255", "14", "", "644", "278", "0 0 0 255", + "18", "", "52", "17", "255 255 255 255", "28", + "uiChapterV", "622", "430", "255 255 255 255", "18", "", + "622", "380", "255 255 255 255", "14", "", "642", "280", "255 255 255 255", "18", "" }; PrintfCommandsFreeTrial = { - "52", "15", "55 55 0 255", "28", "uiChapterV", "624", - "428", "0 0 0 255", "18", "", "624", "378", - "0 0 0 255", "14", "", "644", "278", "0 0 0 255", - "18", "", "52", "17", "255 255 255 255", "28", - "uiChapterV", "622", "430", "255 255 255 255", "18", "", - "622", "380", "255 255 255 255", "14", "", "642", + "52", "15", "55 55 0 255", "28", "uiChapterV", "624", + "428", "0 0 0 255", "18", "", "624", "378", + "0 0 0 255", "14", "", "644", "278", "0 0 0 255", + "18", "", "52", "17", "255 255 255 255", "28", + "uiChapterV", "622", "430", "255 255 255 255", "18", "", + "622", "380", "255 255 255 255", "14", "", "642", "280", "255 255 255 255", "18", "" }; @@ -429,11 +429,11 @@ R2EDReloadFiles = { "r2_components.lua", "r2_core.lua", "r2_features_default.lua", - "r2_features_fauna.lua", + "r2_features_fauna.lua", "r2_features_npc_groups.lua", "r2_palette.lua", "r2_scenario.lua", - "r2_ui.lua" + "r2_ui.lua" }; XMLInterfaceFiles = { @@ -469,21 +469,21 @@ XMLInterfaceFiles = { }; XMLR2EDInterfaceFiles = -{ +{ "r2ed.xml", "r2_triggers.xml", "r2_logic_entities.xml", "r2ed_acts.xml", "r2ed_scenario.xml", "r2ed_connect.xml" -}; +}; FogDistAndDepthLookupBias = 20; // bias for lookup of fog distance and depth -// Hardware cursor textures +// Hardware cursor textures // These will be extracted from the corresponding packed ui .tga files when they are loaded -// * +// * // * individual .tga files for hardware cursor bitmap not looked for, and not supported yet HardwareCursors = { @@ -548,7 +548,7 @@ ScenarioTypes = {"so_newbie_training","so_story_telling","so_mistery","so_hack_s ScenarioLanguages = {"fr","de","en","other_lang"}; // Map each language to a forum help page -HelpPages = +HelpPages = { "fr=http://forums.ryzom.com/forum/showthread.php?t=29130", "en=http://forums.ryzom.com/forum/showthread.php?t=29129", @@ -558,7 +558,7 @@ HelpPages = WebIgMainDomain = "app.ryzom.com"; WebIgTrustedDomains = { - "api.ryzom.com", "app.ryzom.com" + "api.ryzom.com", "app.ryzom.com" }; PatchletUrl = "http://app.ryzom.com/app_patchlet/index.php?patch=preload"; diff --git a/dist/debian/xenial/debian/client_default.cfg b/dist/debian/xenial/debian/client_default.cfg index d09cbbb9c..745c6c20a 100644 --- a/dist/debian/xenial/debian/client_default.cfg +++ b/dist/debian/xenial/debian/client_default.cfg @@ -5,7 +5,7 @@ ////////////////////////// -// If you set this variable to 1, your client.cfg will be overwritten when you quit the client. +// If you set this variable to 1, your client.cfg will be overwritten when you quit the client. // You will loose all the comments and identation in this file. SaveConfig = 1; @@ -13,7 +13,7 @@ SaveConfig = 1; // WINDOW CONFIG // /////////////////// -Driver3D="Auto"; // Valid values are "Auto" or "0", "OpengGL" or "1" & "Direct3D" or "2" +Driver3D="Auto"; // Valid values are "Auto" or "0", "OpengGL" or "1" // "Auto" will choose the best suited driver depending on hardware FullScreen = 0; Width = 1024; @@ -59,21 +59,21 @@ LanguageCode = "en"; // english XMLInputFile = "input_config_v3.xml"; -XMLLoginInterfaceFiles = { - "login_config.xml", - "login_widgets.xml", +XMLLoginInterfaceFiles = { + "login_config.xml", + "login_widgets.xml", "login_main.xml", "login_keys.xml", }; -XMLOutGameInterfaceFiles = { - "out_v2_config.xml", - "out_v2_widgets.xml", +XMLOutGameInterfaceFiles = { + "out_v2_config.xml", + "out_v2_widgets.xml", "out_v2_connect.xml", "out_v2_intro.xml", "out_v2_select.xml", "out_v2_appear.xml", - "out_v2_location.xml", + "out_v2_location.xml", "out_v2_crash.xml", "out_v2_hierarchy.xml", "out_v2_keys.xml", @@ -338,8 +338,8 @@ ScreenShotHeight = 0; ScreenShotFullDetail = 1; // 1 to switch full detail mode for characters (both standard & big screenshots) // Read : "ID", "R G B A MODE [FX]" -SystemInfoColors = -{ +SystemInfoColors = +{ // OLD STUFF Here for compatibility "RG", "0 0 0 255 normal", // Black to see when there is an error "BC", "0 0 0 255 normal", // Black to see when there is an error @@ -384,22 +384,22 @@ SystemInfoColors = }; PrintfCommands = { - "52", "15", "55 55 0 255", "28", "uiChapterV", "624", - "428", "0 0 0 255", "18", "", "624", "378", - "0 0 0 255", "14", "", "644", "278", "0 0 0 255", - "18", "", "52", "17", "255 255 255 255", "28", - "uiChapterV", "622", "430", "255 255 255 255", "18", "", - "622", "380", "255 255 255 255", "14", "", "642", + "52", "15", "55 55 0 255", "28", "uiChapterV", "624", + "428", "0 0 0 255", "18", "", "624", "378", + "0 0 0 255", "14", "", "644", "278", "0 0 0 255", + "18", "", "52", "17", "255 255 255 255", "28", + "uiChapterV", "622", "430", "255 255 255 255", "18", "", + "622", "380", "255 255 255 255", "14", "", "642", "280", "255 255 255 255", "18", "" }; PrintfCommandsFreeTrial = { - "52", "15", "55 55 0 255", "28", "uiChapterV", "624", - "428", "0 0 0 255", "18", "", "624", "378", - "0 0 0 255", "14", "", "644", "278", "0 0 0 255", - "18", "", "52", "17", "255 255 255 255", "28", - "uiChapterV", "622", "430", "255 255 255 255", "18", "", - "622", "380", "255 255 255 255", "14", "", "642", + "52", "15", "55 55 0 255", "28", "uiChapterV", "624", + "428", "0 0 0 255", "18", "", "624", "378", + "0 0 0 255", "14", "", "644", "278", "0 0 0 255", + "18", "", "52", "17", "255 255 255 255", "28", + "uiChapterV", "622", "430", "255 255 255 255", "18", "", + "622", "380", "255 255 255 255", "14", "", "642", "280", "255 255 255 255", "18", "" }; @@ -429,11 +429,11 @@ R2EDReloadFiles = { "r2_components.lua", "r2_core.lua", "r2_features_default.lua", - "r2_features_fauna.lua", + "r2_features_fauna.lua", "r2_features_npc_groups.lua", "r2_palette.lua", "r2_scenario.lua", - "r2_ui.lua" + "r2_ui.lua" }; XMLInterfaceFiles = { @@ -469,21 +469,21 @@ XMLInterfaceFiles = { }; XMLR2EDInterfaceFiles = -{ +{ "r2ed.xml", "r2_triggers.xml", "r2_logic_entities.xml", "r2ed_acts.xml", "r2ed_scenario.xml", "r2ed_connect.xml" -}; +}; FogDistAndDepthLookupBias = 20; // bias for lookup of fog distance and depth -// Hardware cursor textures +// Hardware cursor textures // These will be extracted from the corresponding packed ui .tga files when they are loaded -// * +// * // * individual .tga files for hardware cursor bitmap not looked for, and not supported yet HardwareCursors = { @@ -548,7 +548,7 @@ ScenarioTypes = {"so_newbie_training","so_story_telling","so_mistery","so_hack_s ScenarioLanguages = {"fr","de","en","other_lang"}; // Map each language to a forum help page -HelpPages = +HelpPages = { "fr=http://forums.ryzom.com/forum/showthread.php?t=29130", "en=http://forums.ryzom.com/forum/showthread.php?t=29129", @@ -558,7 +558,7 @@ HelpPages = WebIgMainDomain = "app.ryzom.com"; WebIgTrustedDomains = { - "api.ryzom.com", "app.ryzom.com" + "api.ryzom.com", "app.ryzom.com" }; PatchletUrl = "http://app.ryzom.com/app_patchlet/index.php?patch=preload"; diff --git a/dist/debian/yaketty/debian/client_default.cfg b/dist/debian/yaketty/debian/client_default.cfg index d09cbbb9c..745c6c20a 100644 --- a/dist/debian/yaketty/debian/client_default.cfg +++ b/dist/debian/yaketty/debian/client_default.cfg @@ -5,7 +5,7 @@ ////////////////////////// -// If you set this variable to 1, your client.cfg will be overwritten when you quit the client. +// If you set this variable to 1, your client.cfg will be overwritten when you quit the client. // You will loose all the comments and identation in this file. SaveConfig = 1; @@ -13,7 +13,7 @@ SaveConfig = 1; // WINDOW CONFIG // /////////////////// -Driver3D="Auto"; // Valid values are "Auto" or "0", "OpengGL" or "1" & "Direct3D" or "2" +Driver3D="Auto"; // Valid values are "Auto" or "0", "OpengGL" or "1" // "Auto" will choose the best suited driver depending on hardware FullScreen = 0; Width = 1024; @@ -59,21 +59,21 @@ LanguageCode = "en"; // english XMLInputFile = "input_config_v3.xml"; -XMLLoginInterfaceFiles = { - "login_config.xml", - "login_widgets.xml", +XMLLoginInterfaceFiles = { + "login_config.xml", + "login_widgets.xml", "login_main.xml", "login_keys.xml", }; -XMLOutGameInterfaceFiles = { - "out_v2_config.xml", - "out_v2_widgets.xml", +XMLOutGameInterfaceFiles = { + "out_v2_config.xml", + "out_v2_widgets.xml", "out_v2_connect.xml", "out_v2_intro.xml", "out_v2_select.xml", "out_v2_appear.xml", - "out_v2_location.xml", + "out_v2_location.xml", "out_v2_crash.xml", "out_v2_hierarchy.xml", "out_v2_keys.xml", @@ -338,8 +338,8 @@ ScreenShotHeight = 0; ScreenShotFullDetail = 1; // 1 to switch full detail mode for characters (both standard & big screenshots) // Read : "ID", "R G B A MODE [FX]" -SystemInfoColors = -{ +SystemInfoColors = +{ // OLD STUFF Here for compatibility "RG", "0 0 0 255 normal", // Black to see when there is an error "BC", "0 0 0 255 normal", // Black to see when there is an error @@ -384,22 +384,22 @@ SystemInfoColors = }; PrintfCommands = { - "52", "15", "55 55 0 255", "28", "uiChapterV", "624", - "428", "0 0 0 255", "18", "", "624", "378", - "0 0 0 255", "14", "", "644", "278", "0 0 0 255", - "18", "", "52", "17", "255 255 255 255", "28", - "uiChapterV", "622", "430", "255 255 255 255", "18", "", - "622", "380", "255 255 255 255", "14", "", "642", + "52", "15", "55 55 0 255", "28", "uiChapterV", "624", + "428", "0 0 0 255", "18", "", "624", "378", + "0 0 0 255", "14", "", "644", "278", "0 0 0 255", + "18", "", "52", "17", "255 255 255 255", "28", + "uiChapterV", "622", "430", "255 255 255 255", "18", "", + "622", "380", "255 255 255 255", "14", "", "642", "280", "255 255 255 255", "18", "" }; PrintfCommandsFreeTrial = { - "52", "15", "55 55 0 255", "28", "uiChapterV", "624", - "428", "0 0 0 255", "18", "", "624", "378", - "0 0 0 255", "14", "", "644", "278", "0 0 0 255", - "18", "", "52", "17", "255 255 255 255", "28", - "uiChapterV", "622", "430", "255 255 255 255", "18", "", - "622", "380", "255 255 255 255", "14", "", "642", + "52", "15", "55 55 0 255", "28", "uiChapterV", "624", + "428", "0 0 0 255", "18", "", "624", "378", + "0 0 0 255", "14", "", "644", "278", "0 0 0 255", + "18", "", "52", "17", "255 255 255 255", "28", + "uiChapterV", "622", "430", "255 255 255 255", "18", "", + "622", "380", "255 255 255 255", "14", "", "642", "280", "255 255 255 255", "18", "" }; @@ -429,11 +429,11 @@ R2EDReloadFiles = { "r2_components.lua", "r2_core.lua", "r2_features_default.lua", - "r2_features_fauna.lua", + "r2_features_fauna.lua", "r2_features_npc_groups.lua", "r2_palette.lua", "r2_scenario.lua", - "r2_ui.lua" + "r2_ui.lua" }; XMLInterfaceFiles = { @@ -469,21 +469,21 @@ XMLInterfaceFiles = { }; XMLR2EDInterfaceFiles = -{ +{ "r2ed.xml", "r2_triggers.xml", "r2_logic_entities.xml", "r2ed_acts.xml", "r2ed_scenario.xml", "r2ed_connect.xml" -}; +}; FogDistAndDepthLookupBias = 20; // bias for lookup of fog distance and depth -// Hardware cursor textures +// Hardware cursor textures // These will be extracted from the corresponding packed ui .tga files when they are loaded -// * +// * // * individual .tga files for hardware cursor bitmap not looked for, and not supported yet HardwareCursors = { @@ -548,7 +548,7 @@ ScenarioTypes = {"so_newbie_training","so_story_telling","so_mistery","so_hack_s ScenarioLanguages = {"fr","de","en","other_lang"}; // Map each language to a forum help page -HelpPages = +HelpPages = { "fr=http://forums.ryzom.com/forum/showthread.php?t=29130", "en=http://forums.ryzom.com/forum/showthread.php?t=29129", @@ -558,7 +558,7 @@ HelpPages = WebIgMainDomain = "app.ryzom.com"; WebIgTrustedDomains = { - "api.ryzom.com", "app.ryzom.com" + "api.ryzom.com", "app.ryzom.com" }; PatchletUrl = "http://app.ryzom.com/app_patchlet/index.php?patch=preload"; diff --git a/dist/debian/zesty/debian/client_default.cfg b/dist/debian/zesty/debian/client_default.cfg index d09cbbb9c..745c6c20a 100644 --- a/dist/debian/zesty/debian/client_default.cfg +++ b/dist/debian/zesty/debian/client_default.cfg @@ -5,7 +5,7 @@ ////////////////////////// -// If you set this variable to 1, your client.cfg will be overwritten when you quit the client. +// If you set this variable to 1, your client.cfg will be overwritten when you quit the client. // You will loose all the comments and identation in this file. SaveConfig = 1; @@ -13,7 +13,7 @@ SaveConfig = 1; // WINDOW CONFIG // /////////////////// -Driver3D="Auto"; // Valid values are "Auto" or "0", "OpengGL" or "1" & "Direct3D" or "2" +Driver3D="Auto"; // Valid values are "Auto" or "0", "OpengGL" or "1" // "Auto" will choose the best suited driver depending on hardware FullScreen = 0; Width = 1024; @@ -59,21 +59,21 @@ LanguageCode = "en"; // english XMLInputFile = "input_config_v3.xml"; -XMLLoginInterfaceFiles = { - "login_config.xml", - "login_widgets.xml", +XMLLoginInterfaceFiles = { + "login_config.xml", + "login_widgets.xml", "login_main.xml", "login_keys.xml", }; -XMLOutGameInterfaceFiles = { - "out_v2_config.xml", - "out_v2_widgets.xml", +XMLOutGameInterfaceFiles = { + "out_v2_config.xml", + "out_v2_widgets.xml", "out_v2_connect.xml", "out_v2_intro.xml", "out_v2_select.xml", "out_v2_appear.xml", - "out_v2_location.xml", + "out_v2_location.xml", "out_v2_crash.xml", "out_v2_hierarchy.xml", "out_v2_keys.xml", @@ -338,8 +338,8 @@ ScreenShotHeight = 0; ScreenShotFullDetail = 1; // 1 to switch full detail mode for characters (both standard & big screenshots) // Read : "ID", "R G B A MODE [FX]" -SystemInfoColors = -{ +SystemInfoColors = +{ // OLD STUFF Here for compatibility "RG", "0 0 0 255 normal", // Black to see when there is an error "BC", "0 0 0 255 normal", // Black to see when there is an error @@ -384,22 +384,22 @@ SystemInfoColors = }; PrintfCommands = { - "52", "15", "55 55 0 255", "28", "uiChapterV", "624", - "428", "0 0 0 255", "18", "", "624", "378", - "0 0 0 255", "14", "", "644", "278", "0 0 0 255", - "18", "", "52", "17", "255 255 255 255", "28", - "uiChapterV", "622", "430", "255 255 255 255", "18", "", - "622", "380", "255 255 255 255", "14", "", "642", + "52", "15", "55 55 0 255", "28", "uiChapterV", "624", + "428", "0 0 0 255", "18", "", "624", "378", + "0 0 0 255", "14", "", "644", "278", "0 0 0 255", + "18", "", "52", "17", "255 255 255 255", "28", + "uiChapterV", "622", "430", "255 255 255 255", "18", "", + "622", "380", "255 255 255 255", "14", "", "642", "280", "255 255 255 255", "18", "" }; PrintfCommandsFreeTrial = { - "52", "15", "55 55 0 255", "28", "uiChapterV", "624", - "428", "0 0 0 255", "18", "", "624", "378", - "0 0 0 255", "14", "", "644", "278", "0 0 0 255", - "18", "", "52", "17", "255 255 255 255", "28", - "uiChapterV", "622", "430", "255 255 255 255", "18", "", - "622", "380", "255 255 255 255", "14", "", "642", + "52", "15", "55 55 0 255", "28", "uiChapterV", "624", + "428", "0 0 0 255", "18", "", "624", "378", + "0 0 0 255", "14", "", "644", "278", "0 0 0 255", + "18", "", "52", "17", "255 255 255 255", "28", + "uiChapterV", "622", "430", "255 255 255 255", "18", "", + "622", "380", "255 255 255 255", "14", "", "642", "280", "255 255 255 255", "18", "" }; @@ -429,11 +429,11 @@ R2EDReloadFiles = { "r2_components.lua", "r2_core.lua", "r2_features_default.lua", - "r2_features_fauna.lua", + "r2_features_fauna.lua", "r2_features_npc_groups.lua", "r2_palette.lua", "r2_scenario.lua", - "r2_ui.lua" + "r2_ui.lua" }; XMLInterfaceFiles = { @@ -469,21 +469,21 @@ XMLInterfaceFiles = { }; XMLR2EDInterfaceFiles = -{ +{ "r2ed.xml", "r2_triggers.xml", "r2_logic_entities.xml", "r2ed_acts.xml", "r2ed_scenario.xml", "r2ed_connect.xml" -}; +}; FogDistAndDepthLookupBias = 20; // bias for lookup of fog distance and depth -// Hardware cursor textures +// Hardware cursor textures // These will be extracted from the corresponding packed ui .tga files when they are loaded -// * +// * // * individual .tga files for hardware cursor bitmap not looked for, and not supported yet HardwareCursors = { @@ -548,7 +548,7 @@ ScenarioTypes = {"so_newbie_training","so_story_telling","so_mistery","so_hack_s ScenarioLanguages = {"fr","de","en","other_lang"}; // Map each language to a forum help page -HelpPages = +HelpPages = { "fr=http://forums.ryzom.com/forum/showthread.php?t=29130", "en=http://forums.ryzom.com/forum/showthread.php?t=29129", @@ -558,7 +558,7 @@ HelpPages = WebIgMainDomain = "app.ryzom.com"; WebIgTrustedDomains = { - "api.ryzom.com", "app.ryzom.com" + "api.ryzom.com", "app.ryzom.com" }; PatchletUrl = "http://app.ryzom.com/app_patchlet/index.php?patch=preload"; diff --git a/dist/nsis/ryzom_setup.nsi b/dist/nsis/ryzom_setup.nsi index 9322ca143..96de62bb0 100644 --- a/dist/nsis/ryzom_setup.nsi +++ b/dist/nsis/ryzom_setup.nsi @@ -135,7 +135,7 @@ LangString MSG_SUPPORT_URL_TITLE ${LANG_GERMAN} "Support" LangString MSG_SUPPORT_URL ${LANG_GERMAN} "http://app.ryzom.com/app_forum/index.php?page=topic/view/22047/1&post149889=de#1" LangString MSG_HOME_URL_TITLE ${LANG_GERMAN} "${Product} im Internet" LangString MSG_HOME_URL ${LANG_GERMAN} "http://ryzom.de" -LangString MSG_CONFIRM_DELETE_BACKUPS ${LANG_GERMAN} "Gespeicherte Dateien lschen? Klicke Ja um die eigenen Dateien zu lschen." +LangString MSG_CONFIRM_DELETE_BACKUPS ${LANG_GERMAN} "Gespeicherte Dateien l�schen? Klicke Ja um die eigenen Dateien zu l�schen." ;-------------------------------- ;Installer Sections @@ -171,14 +171,11 @@ Section File "${SrcDir}\client_default.cfg" File "${SrcDir}\${Executable}" File "${SrcDir}\configure.bat" - File "${SrcDir}\d3dcompiler_43.dll" - File "${SrcDir}\d3dx9_43.dll" File "${SrcDir}\fmod.dll" File "${SrcDir}\forum.url" File "${SrcDir}\launch.bat" File "${SrcDir}\msvcp100.dll" File "${SrcDir}\msvcr100.dll" - File "${SrcDir}\nel_drv_direct3d_win_r.dll" File "${SrcDir}\nel_drv_fmod_win_r.dll" File "${SrcDir}\nel_drv_opengl_win_r.dll" File "${SrcDir}\ryzom.ico" @@ -238,14 +235,11 @@ Section "Uninstall" Delete "$INSTDIR\client_default.cfg" Delete "$INSTDIR\${Executable}" Delete "$INSTDIR\configure.bat" - Delete "$INSTDIR\d3dcompiler_43.dll" - Delete "$INSTDIR\d3dx9_43.dll" Delete "$INSTDIR\fmod.dll" Delete "$INSTDIR\forum.url" Delete "$INSTDIR\launch.bat" Delete "$INSTDIR\msvcp100.dll" Delete "$INSTDIR\msvcr100.dll" - Delete "$INSTDIR\nel_drv_direct3d_win_r.dll" Delete "$INSTDIR\nel_drv_fmod_win_r.dll" Delete "$INSTDIR\nel_drv_opengl_win_r.dll" Delete "$INSTDIR\ryzom.ico"