SDL - #3431
Conversation
Joint effort by @ohlidalp, @tritonas00, @CuriousMike56 and @AnotherFoxGuy (Edgar) This is a minimal viable port - no RTSS, no change to existing Cg shaders (nicemetal, Caelum, PSSM). NOTE: under Dx11 be sure to have 'diag_warning_texture=Yes' otherwise you get crash at startup. Changes made: * OgreAngelscript.cpp: fixed build error - with OGRE_FAST_MATH defined functions `isNAN()` aren't present. * TerrainGeometryManager.cpp: OTC file format: made normalheight texture optional. * Update dependency fmt to v12 * Building OGRE with resourcemanager_strict=off * Disabled OGRE build option `OGRE_NODELESS_POSITIONING` (no longer needed - scene nodes are used everywhere) * Media: fix corrupted DDS texture crashing under D3D9 * Caelum time slider: restored original code (it works with latest Ogre master branch) * Fixed Imgui inverted colours on DirectX 9 * Fixed missing MyGUI shaders and rendering issues * MyGUI RTT layers, originally removed, got restored and extended. Changes to OGRE-AngelScript bindings, reflecting changes in OGRE API: * OverlayManager::getTemplates() // removed * OverlayManager::isTemplate() // removed * SceneNode::getAttachedObject() // now const * SceneNode::hideBoundingBox() // removed * SceneNode::getAutoTrackTarget() // now const * SceneNode::getAutoTrackOffset() // now const * SceneNode::getAutoTrackLocalDirection() // now const * SceneNode::setVisible() // now const * SceneNode::flipVisibility() // now const * SceneNode::setDebugDisplayEnabled() // now const Co-authored-by: Edgar <Edgar@AnotherFoxGuy.com> Co-authored-by: tritonas00 <tritonas00@gmail.com> Co-authored-by: CuriousMike56 <46073351+CuriousMike56@users.noreply.github.com>
User-facing features: - new cvar `diag_profiler_enabled` (bool) - always false on startup, can be activated via console `set diag_profiler_enabled 1` - new cvar `diag_profiler_rate` (int) - sampling rate of the profiler, defaults to 10 frames. Strored in RoR.cfg.
Notes: - '3d_*.overlay' files were unused - leftovers from recent removal of renderdash, see RigsOfRods#3423 - file 'managed_submesh.material' was unused - '*.asm' shaders are no longer supported by OGRE
Leftovers from unused truck & boat overlays were deleted - both from resources and code. Materials of remaining overlays (aerial, pressure, directionarrow, racing) were split from 'materials/ror.material' to 'overlays/*.material', one to one with overlay files. All material/overlay warnings in RoR.log were adressed.
Turns out I've misunderstood the 'inGlobalPool' flag - I thought it exposed the resources to every other group, but it only creates single "virtual supergroup" where all files must be unique. Thus for most of our gamefiles loading to global pool has no meaning - to make them visible to mods without mods clashing, each mod must have private RG and all game data must be loaded into it. This wastes some memory and processing time to repeatedly parse OGRE scripts, but simplifies usage - only one lookup covers all. All present code works this way. In contrast, using global pool for game data would require game to do 2 lookups: in the per-actor RG first and then fallback to global pool - technically feasible but not worth the work (?). CHANGES: * I've manually distributed this flag to all RGs we create, so now we don't rely on OGRE_RESOURCEGROUP_STRICT=OFF for the global fallback - we may still need this option for case-insensitivity though. * I've also created new RGN_UI_ICONS resource group which merges 'icons','famicons' and 'flags' resource dirs. This prompted me to delete duplicate images from '/icons' that came from '/famicons'. * In 'ContentManager.h/cpp', I removed the per-resourcepack RGs, all RGs are now covered by `RGN_*` defs in Application.h; Some gamefiles are loaded to `Ogre::RGN_DEFAULT`, others are commented ad-hoc. * Managed materials for actors were split to 'nicemetal' and 'alternate' dirs, because OGRE complained we can't have `EnvironmentTexture` both use shaders (nicemetal) and not use shaders (alternate). RoR.log: `Error: ScriptCompiler - invalid parameters in texture_manager.material(16): overriding previous declarations of texture 'EnvironmentTexture' with different parameters` * Finally, I added a new docs page to clarify how the stuff works and why we use it the way we do.
BEWARE: MyGUI::UString has a constructor that takes a char[N] and buffers up all N chars, even if NULLs. This breaks rendering.
ror.log:
```
00:59:10: Initialising resource group {bundle BIN:\resources\dashboards.zip}
00:59:10: Parsing scripts for resource group {bundle BIN:\resources\dashboards.zip}
00:59:10: Parsing script pssm_shared.program
00:59:10: [RoR] Error while loading 'D:\!RoR builds\ror-win-ogre14minupgrade\resources\dashboards.zip', message: Ogre::InvalidParametersException::InvalidParametersException: The shared parameter set 'pssm_params' already exists! in GpuProgramManager::createSharedParameters at C:\Users\runneradmin\.conan2\p\b\ogre3c74730b67b947\b\OgreMain\src\OgreGpuProgramManager.cpp (line 244)
00:59:10: Destroying resource group {bundle BIN:\resources\dashboards.zip}
```
also:
```
00:59:09: Parsing script pssm_shared.program
00:59:09: Warning: ScriptCompiler - deprecated symbol in pssm_shared.program(3): shared_param_named is deprecated. Use param_named instead
```
Base is initialized for all mod types, Actor only for actors ;) This also fixes imperfections in the nicemetal/alternate split - common actor materials were separated out, specific labeled accordingly.
Majority of data in 'meshes'/'materials'/'textures' resource dirs were terrain objects, it makes no sense to add them to per-actor resource groups. Also removed RoR.log message "[RoR|ContentManager] Loading resource pack ..." because it just duplicates OGRE's own "Added resource location ..."
Status: builds and runs OK, but there is no input. This is a brainless 1:1 replacement of OIS API and events with SDL API and OgreBites input events. I preserved our (very outdated) DearIMGUI integration. All our (quite convoluted) input processing stayed mostly intact. Only mouse/keyboard input is handled, joysticks + controllers + forcefeedback are temporarily disabled.
Status: build and runs, keyboard+mouse working, window is somehow oversized but responsive. Codechanges: * creating render window via OgreBites::ApplicationContext instead of OGRE Root directly - needed to receive events * overriding OgreBites::ApplicationContext::createRoot() with our pre-existing setup code, to initialize `mRoot` as expected. * calling `OgreBites::ApplicationContext::addInputListener()` to receive events.
Deleted the windows-specific code setting ["monitorIndex"]- apparently OGRE does it by itself in `ApplicationContextSDL::createWindow()`, see OgreApplicationContextSDL.cpp line 56. Original commit: 128a8e2 - "Attempt to fix the 'Rendering Device' setting" - Ulteq, 4 years ago (29.12.2018 13:53:57) Also deleted setting ["windowProc"] - doesn't seem to have any effect, perhaps an OIS leftover.
…center()` Googling https://www.google.com/search?q=%22SDL_HapticSetAutocenterEnabled%22 returns 0 hits - not sure where that alias came from.
|
I took the liberty to rebase & force-push, adding minor fixes (to fixup later).
|
|
THINK the new commit is a fix, will you push changes for the camera work? |
|
Keys are fixed: menu navigations, Enter/Backspace in input boxes, all works. I've looked to the camera and it turns out I've also hooked my vintage Thrustmaster T100 wheel and... I'm seeing a pattern here... at least under Windows10 x64 using sdl/2.30.9 we can't rely on direct input querying and have to listen to OgreBites events exclusively. I take it that under your system at least the mouse camera orbit worked? Update: |
It did! So where does this leave us on the PR? |
…'t reliable. at least under Windows10 x64 using sdl/2.30.9, `SDL_GetMouseState()` constantly returns zero.
The mouse button states are actually queried from InputEngine.
|
I've worked around the mouse buttons by caching states from events. Next, we need to scavenge for info.
I need to create some test app with just OGRE+SDL and see if it works there. It may be RoR, but it may be windows, too. |
|
@AnotherFoxGuy How can I make sure there's no mixup happening between OGRE conan package and my game devbuild?
I didn't find a way to match a conan build dir to a package, so by trial and error I landed at "c:\Users\ohlidalp.conan2\p\b\ogre3900a2f6d0d7de\b\build" which shows "14-5-2" in 'version.txt'
Finally I opened RoR project properties and saw this: Removing 'maind' had no effect. Removing '-staticd' caused linking errors because apparently the headers I'm pulling in (C:\Users\ohlidalp.conan2\p\b\sdl2b5f435e448f5\p\include\SDL2\SDL_mouse.h) don't have Also https://github.com/libsdl-org/SDL/blob/main/docs/README-dynapi.md linked from https://wiki.libsdl.org/SDL2/Installation. Complicated stuff. @philocalyst For the time being, I say let's fall back to using |

No description provided.