Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replacing OIS with SDL input (using OGRE14 + Bites component) #2983

Draft
wants to merge 12 commits into
base: master
Choose a base branch
from

Conversation

ohlidalp
Copy link
Member

@ohlidalp ohlidalp commented Dec 11, 2022

This is a first step in migrating from self-shipped OIS library to standard SDL2 and OGRE's builtin DearIMGUI integration. I've based it on our (pretty mature already) OGRE13 port to get the latest tech and support.

Only mouse+keyboard are working, controllers and joysticks (+ force feedback) are temporarily disabled.

OGRE provides Bites component with generic ApplicationContext that runs on many platforms and powers OGRE SampleBrowser. It includes DearIMGUI integration, RTSS setup, window creation and generic input API for all devices. I tried replacing our OIS events + API calls 1:1 with Bites events and SDL API calls and it turns out to work just fine. I had to also replace the function which opens render window, as SDL input events don't work otherwise. Everything else remains unchanged. Also our (very outdated) DearIMGUI integration remains in place, with only updated input processing (based on OgreBites code, anyway).

@ohlidalp
Copy link
Member Author

ohlidalp commented Jan 1, 2023

I tried replacing our DearIMGUI integration (v 1.75 - very outdated) with OGRE's builtin DearImguiOverlay component. UPDATE: It's a success, just some finishing touches are needed, see below.

Status:

  • game builds and runs
  • UI draws correctly except it uses the builtin font UPDATE: font fixed.
  • Under Debug I get asserts about NewFrame()/EndFrame() mismatches. UPDATE: fixed.
  • The GUI interferes with Renderdash dashboard again - I'm not sure how to selectively disable it. UPDATE: Fixed using Overlay::setVisible().
  • [FIXED] The VehicleAI panel glitches out in some cases and makes all UI invisible.
  • The vehicle-buttons side-panel isn't working - headers cannot be expanded.
  • OGRE's integrated imgui uses 16-bit indices (ours used 32-bit) so I get Debug asserts about too many vertices - I asked Paroj to add a build option for this: DearIMGUI: support for 32-bit indices OGRECave/ogre#2772

Joint effort by @ohlidalp, @tritonas00, @AnotherFoxGuy, @CuriousMike56

⬆️ Updated mygui, pagedgeometry and caelum
🐛 Fixed missing MyGUI shaders
🐛 Fixed MyGUI rendering issue
🔧 Build OGRE with resourcemanager_strict=off
updated rtshader media
🐛 Fixed cmake not accepting `CMAKE_CONFIGURATION_TYPES`
fixed odef lights scenenode
🐛 Fixed Caelum not loading os files
Caelum time slider: restored original code (it works with latest Ogre master branch)
🐛 Fixed Imgui inverted colours on DirectX 9
fixed survey map texture updating
⬆️ Update OGRE to 13.5
updated rtshader media for Ogre 13.5
🔧 Implement PSSM3 properly
⬆️ Update OGRE to 13.5.1
Fixed crash on loading 2nd terrain w/envmap enabled
⬆️ Update OGRE to 13.5.3
Fixed crash on 2nd map load (procedural road material conflict)
Media: fix corrupted DDS texture crashing under D3D9
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.
STATUS:
- ogre imgui port: keyboard/mouse input working!
- ogre imgui port: FIXME: hacked Renderdash to build, but imgui will likely render into it - how to disable??
- ogre imgui port: builds and runs with default font.
- under Debug I get asserts about NewFrame()/EndFrame() mismatches, to be fixed later.

CODECHANGES:
* imgui deprecated - renamed ImGui::AlignFirstTextHeightToWidgets() to ImGui::AlignTextToFramePadding()
* imgui deprecated - ImGui::GetContentRegionAvailWidth() -> use ImGui::GetContentRegionAvail().x
* imgui deprecated -  GetWindowContentRegionWidth() function. -> 'GetWindowContentRegionMax().x
* imgui deprecated - SetScrollHere() -> SetScrollHereX() + SetScollHereY()
* imgui deprecated - ImGui::TreeAdvanceToLabelPos()      -> use ImGui::SetCursorPosX(ImGui::GetCursorPosX() + ImGui::GetTreeNodeToLabelSpacing());
* imgui deprecated - renamed SetNextTreeNodeOpen() to SetNextItemOpen().
* imgui deprecated - renamed ListBoxHeader(const char* label, ImVec2 size) to BeginListBox().
* imgui deprecated - removed BeginPopupContextWindow(const char*, int mouse_button, bool also_over_items) in favor of BeginPopupContextWindow(const char*, ImGuiPopupFlags flags) with ImGuiPopupFlags_NoOverItems.
* imgui deprecated - removed CalcListClipping() function. Prefer using ImGuiListClipper which can return non-contiguous ranges.
* imgui deprecated - ImGuiCol_ChildWindowBg              -> use ImGuiCol_ChildBg
* imgui deprecated - style: renamed ImGuiCol_ModalWindowDarkening to ImGuiCol_ModalWindowDimBg
* imgui deprecated - GetItemsLineHeightWithSpacing()     -> use GetFrameHeightWithSpacing()
* imgui deprecated - InputText: Renamed  ImGuiTextEditCallbackData to ImGuiInputTextCallbackData
* imgui deprecated - SetNextWindowContentWidth(float w)    ->    SetNextWindowContentSize(ImVec2(w, 0.0f))
* imgui deprecated - SetNextWindowPosCenter(ImGuiCond c=0) { SetNextWindowPos(GetMainViewport()->GetCenter(), c, ImVec2(0.5f,0.5f));
* ogre imgui port: use public `GetFont()/GetFontSize()` instead of internal `ImGuiContext->Font/FontSize`
* VehicleAI panel: `Push/PopItemFlag(Disabled)` (imgui_internal) -> `Begin/EndDisabled()` (public BETA API)
…of screen.

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.
Codechanges:
* GUIUtils, InputEngine: `getModifierKeyName()` replaced OIS keycodes with OgreBites/SDL keycodes
* ImGuiAngelscript: commented out some dead items, added (ImGuiKey) casts where needed, see ocornut/imgui#4921
* GUI_VehicleButtons: build fix for `ImGui::ImageButton()` - added parameter ID-string.
* GUI_RepositorySelector: updated thumbnail downloading to use new OGRE WorkQueue API, see https://github.com/OGRECave/ogre/blob/master/Docs/14-Notes.md#task-based-workqueue
* Application.h, main.cpp: added ✉️ `MSG_NET_DOWNLOAD_REPOTHUMB_SUCCESS`, used instead of OGRE WorkQueue's `addMainThreadTask` for consistency across the various background threads in the codebase.
* GodRaysManager: build fix - RENDER_QUEUE_9 was removed from OGRE, using 8.
* RttManager: rendersystem-specific `getProjectionMatrixRS()` was removed from OGRE, using portable  `getProjectionMatrix()`
@ohlidalp ohlidalp changed the title Replacing OIS with SDL input (using OGRE13 + Bites component) Replacing OIS with SDL input (using OGRE14 + Bites component) Sep 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant