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

query SDL for video modes #3144

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions Components/Bites/src/OgreApplicationContextSDL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,13 @@ void ApplicationContextSDL::removeInputListener(NativeWindowType* win, InputList
mInputListeners.erase(std::make_pair(SDL_GetWindowID(win), lis));
}

static void removeDuplicates(std::vector<Ogre::String>& c)
{
std::sort(c.begin(), c.end());
auto p = std::unique(c.begin(), c.end());
c.erase(p, c.end());
}

NativeWindowPair ApplicationContextSDL::createWindow(const Ogre::String& name, Ogre::uint32 w, Ogre::uint32 h, Ogre::NameValuePairList miscParams)
{
NativeWindowPair ret = {NULL, NULL};
Expand All @@ -39,6 +46,18 @@ NativeWindowPair ApplicationContextSDL::createWindow(const Ogre::String& name, O
Ogre::LogManager::getSingleton().logMessage("[SDL] gamecontrollerdb.txt loaded");

SDL_InitSubSystem(SDL_INIT_VIDEO | SDL_INIT_GAMECONTROLLER);

// For now we consider primary display only
int numDispModes = SDL_GetNumDisplayModes(0);
std::vector<Ogre::String> modes;
for(int i = 0; i < numDispModes; i++) {
SDL_DisplayMode mode;
SDL_GetDisplayMode(0, i, &mode);
modes.push_back(Ogre::StringUtil::format("%4d x %4d", mode.w, mode.h));
}
removeDuplicates(modes);
for(auto rs : mRoot->getAvailableRenderers())
const_cast<Ogre::ConfigOption&>(rs->getConfigOptions().at("Video Mode")).possibleValues = modes;
}

auto p = mRoot->getRenderSystem()->getRenderWindowDescription();
Expand Down