1
Window / help setting fullscreen resolution with view.
« on: February 29, 2012, 07:44:17 pm »
Hello,
In window mode, I create the window, then I can scale it with setsize, and it scales the internal view perfectly. Allowing me to initially create a window to the size of my background and images, then have them all scaled up. In full screen mode I am struggling to do the same.
Here is my code;
The image is 320, 220, and I want it, so when I go to full screen, it scales with the window, no matter what resolution.
now I can not get it to do this, it always just rebuilds the view and my background is tiny,
UNLESS... I add these
320 * 2 is not even my monitor res.....which is 2560x1440
which make no sense to me? and mess up window sizing anyway.
Also if I want to place a sprite at the edge of the window...should I use ;
return Window.ConvertCoords(Window.GetWidth() , Window.GetHeight());
or the view size?
In window mode, I create the window, then I can scale it with setsize, and it scales the internal view perfectly. Allowing me to initially create a window to the size of my background and images, then have them all scaled up. In full screen mode I am struggling to do the same.
Here is my code;
Code: [Select]
////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Graphics.hpp>
#include <SFML/Window.hpp>
////////////////////////////////////////////////////////////
/// Entry point of application
///
/// \return Application exit code
///
////////////////////////////////////////////////////////////
int main()
{
sf::Texture texBack;
texBack.LoadFromFile("introback.bmp");
sf::Sprite sprBack;
sprBack.SetTexture(texBack);
//current video mode
sf::VideoMode DesktopMode = sf::VideoMode::GetDesktopMode();
// Create the main rendering window
sf::RenderWindow App; //(sf::VideoMode(320, 224, 32), "SFML Graphics", sf::Style::None);
sf::View view;
App.Create(sf::VideoMode(320, 220, DesktopMode.BitsPerPixel), "SFML Graphics", sf::Style::None);
view = App.GetView();
//App.Create(sf::VideoMode(DesktopMode.Width / 2, DesktopMode.Height / 2, DesktopMode.BitsPerPixel), "SFML Graphics", sf::Style::Fullscreen);
App.Create(sf::VideoMode(DesktopMode.Width, DesktopMode.Height, DesktopMode.BitsPerPixel), "SFML Graphics", sf::Style::Fullscreen);
[color=red] view.SetSize(320 * 2, 220 * 2);
view.SetCenter(320 , 220 );
App.SetView(view);[/color]
// Start game loop
while (App.IsOpened())
{
// Process events
sf::Event Event;
while (App.PollEvent(Event))
{
// Close window : exit
if (Event.Type == sf::Event::Closed)
App.Close();
}
// Clear the screen with red color
App.Clear();
App.Draw(sprBack);
// Display window contents on screen
App.Display();
}
return EXIT_SUCCESS;
}
The image is 320, 220, and I want it, so when I go to full screen, it scales with the window, no matter what resolution.
now I can not get it to do this, it always just rebuilds the view and my background is tiny,
UNLESS... I add these
Code: [Select]
[color=red] view.SetSize(320 * 2, 220 * 2);
view.SetCenter(320 , 220 );
App.SetView(view);[/color]
320 * 2 is not even my monitor res.....which is 2560x1440
which make no sense to me? and mess up window sizing anyway.
Also if I want to place a sprite at the edge of the window...should I use ;
return Window.ConvertCoords(Window.GetWidth() , Window.GetHeight());
or the view size?