Hate to talk again and have to re post...... but.
isValid() is telling me that all of my video modes in my vector are invalid...
void EngineWindow::PrimeResolutionList()
{
//Store initial resolutions.
sf::VideoMode SVGA;
SVGA.width=800;
SVGA.height=600;
SVGA.bitsPerPixel=4;
sf::VideoMode XGAP1;
XGAP1.width=1152;
XGAP1.height=864;
XGAP1.bitsPerPixel=16;
sf::VideoMode XGAP2;
XGAP2.width=1152;
XGAP2.height=900;
XGAP2.bitsPerPixel=16;
sf::VideoMode HD;
HD.width=1360;
HD.height=768;
HD.bitsPerPixel=24;
sf::VideoMode HD2;
HD2.width=1366;
HD2.height=768;
HD2.bitsPerPixel=24;
sf::VideoMode WXGA;
WXGA.width=1280;
WXGA.height=800;
WXGA.bitsPerPixel=24;
sf::VideoMode HDP;
HDP.width=1600;
HDP.height=900;
HDP.bitsPerPixel=24;
sf::VideoMode SXGA;
SXGA.width=1280;
SXGA.height=1024;
SXGA.bitsPerPixel=24;
sf::VideoMode SXGAP;
WXGA.width=1400;
WXGA.height=1050;
WXGA.bitsPerPixel=24;
sf::VideoMode WSXGA;
WSXGA.width=1440;
WSXGA.height=900;
WSXGA.bitsPerPixel=24;
sf::VideoMode UXGA;
WXGA.width=1600;
WXGA.height=1200;
WXGA.bitsPerPixel=24;
sf::VideoMode WSXGAP;
WXGA.width=1680;
WXGA.height=1050;
WXGA.bitsPerPixel=24;
sf::VideoMode FULLHD;
FULLHD.width=1920;
FULLHD.height=1080;
FULLHD.bitsPerPixel=24;
sf::VideoMode WUXGA;
WXGA.width=1920;
WXGA.height=1200;
WXGA.bitsPerPixel=24;
//Add to the vector.
reslist.push_back(SVGA);
reslist.push_back(XGAP1);
reslist.push_back(XGAP2);
reslist.push_back(HD);
reslist.push_back(HD2);
reslist.push_back(WXGA);
reslist.push_back(HDP);
reslist.push_back(SXGA);
reslist.push_back(SXGAP);
reslist.push_back(WSXGA);
reslist.push_back(UXGA);
reslist.push_back(WSXGAP);
reslist.push_back(FULLHD);
reslist.push_back(WUXGA);
//Iterate through the vector removing incompatable resolutions.
std::vector<sf::VideoMode>::iterator it;
for(it=reslist.begin(); it != reslist.end(); it++)
{
if(!(*it).isValid())
{
it = reslist.erase(it);
}
}
}
Any ideas? o.O
Just a side note, I added in the bpp because otherwise if I try to use a VideoMode without a bpp defined, it claims its incompatible. *that is if it actually makes it past that final loop*
I mean. My current resolution is 1920 x 1080, so I don't see why its calling FULLHD invalid... Or a lot of the other ones for that matter.
bpp should be 32 (what are you trying to do with other bpps??), or omitted since it's the default.
Oh, I was just copying them from a video chart I had found on Wikipedia. ^^;; I'll set them all to 32.
But say, if I make a quickie video mode like....
sf::VideoMode MyMode;
MyMode.Width=800;
MyMode.Height=600;
create(MyMode,"MyWindow",sf::Style::Fullscreen);
Will create an error since the bpp was not defined. However
sf::VideoMode MyMode;
MyMode.Width=800;
MyMode.Height=600;
MyMode.BitsPerPixel=32;
create(MyMode,"MyWindow",sf::Style::Fullscreen);
Will work perfectly. So thats why I have the bpp for each video mode. :)
Still unsure as to why they are all invalid...
Oh well, I'll just use
reslist = sf::VideoMode::getFullscreenModes();
Instead of making my own list, after all, its likely to save me time and be more efficient. ^^;
isValid() is telling me that all of my video modes in my vector are invalid...
//Iterate through the vector removing incompatable resolutions.
std::vector<sf::VideoMode>::iterator it;
for(it=reslist.begin(); it != reslist.end(); it++)
{
if(!(*it).isValid())
{
it = reslist.erase(it);
}
}
If all of your video modes were invalid, this loop would only be capable of removing half of them. An element is skipped for every one removed, with the exception of the last element if it happens to be removed -- undefined behavior is invoked in that case.
Just in case you wonder, this would be a proper way:
std::vector<sf::VideoMode>::iterator it = relist.begin();
while(it != relist.end())
{
if(!it->isValid())
it = relist.erase(it);
else
++it;
}
Since erase removes the current element, the iterator points at the next one. That's why you only have to increase it when nothing gets removed, or else you'd skip elements.