SFML community forums
Help => Window => Topic started by: Elgan 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;
////////////////////////////////////////////////////////////
// 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
[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?
-
Any ideas?
so I can set it up like so for windowed mode (which works anyway)
////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Graphics.hpp>
#include <SFML/Window.hpp>
#include <SFML/OpenGl.hpp>
#include <iostream>
////////////////////////////////////////////////////////////
/// Entry point of application
///
/// \return Application exit code
///
////////////////////////////////////////////////////////////
int main()
{
sf::Texture texBack; //640 ,480 size
texBack.LoadFromFile("introback.bmp");
sf::Sprite sprBack;
sprBack.SetTexture(texBack);
//current video mode
sf::VideoMode DesktopMode = sf::VideoMode::GetDesktopMode();
std::vector<sf::VideoMode> modes = sf::VideoMode::GetFullscreenModes();
for (std::size_t i = 0; i < modes.size(); ++i)
{
sf::VideoMode mode = modes[i];
std::cout << "Mode #" << i << ": "
<< mode.Width << "x" << mode.Height << " - "
<< mode.BitsPerPixel << " bpp" << std::endl;
}
// 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);
//App.Create(sf::VideoMode(DesktopMode.Width / 2, DesktopMode.Height / 2, DesktopMode.BitsPerPixel), "SFML Graphics", sf::Style::Fullscreen);
//App.Create(sf::VideoMode(1024, 720, DesktopMode.BitsPerPixel), "SFML Graphics", sf::Style::None );
App.Create(sf::VideoMode(DesktopMode.Width , DesktopMode.Height , DesktopMode.BitsPerPixel), "SFML Graphics", sf::Style::Fullscreen);
view = App.GetView();
//App.Create(sf::VideoMode(DesktopMode.Width , DesktopMode.Height, DesktopMode.BitsPerPixel), "SFML Graphics", sf::Style::Fullscreen);
view.SetSize(640 ,480 );
view.SetCenter(640 / 2 ,480/ 2 );
App.SetView(view);
//
// 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();
// Resize event : adjust viewport
if (Event.Type == sf::Event::Resized)
{
//glViewport(0, 0, 640, 480);
view = App.GetView();
//App.Create(sf::VideoMode(DesktopMode.Width , DesktopMode.Height, DesktopMode.BitsPerPixel), "SFML Graphics", sf::Style::Fullscreen);
view.SetSize(640 ,480 );
view.SetCenter(640 / 2 ,480/ 2 );
App.SetView(view);
}
}
// Clear the screen with red color
App.Clear();
App.Draw(sprBack);
// Display window contents on screen
App.Display();
}
return EXIT_SUCCESS;
}
Setting the rest, and then setting the view to the size of the image.
BUT the image is too big for the screen when I do this....what?! surly it should be fine? it makes no sense to me? the image should thus match the view
sf::Vector2f CGameEngine::GetSize()
{
return Window.ConvertCoords(Window.GetWidth() / 2 , Window.GetHeight() / 2);
The above returns place my sprites exactly where I want them :\
-
i still really need some help on this guys
Window.Create(sf::VideoMode(DesktopMode.Width , DesktopMode.Height , DesktopMode.BitsPerPixel), "SFML Graphics", sf::Style::Fullscreen);
sf::View view;
view = Window.GetView();
view.SetSize(640 , 480 );
view.SetCenter(640 /2 , 480 / 2);
Window.SetView(view);
how can i set it up, so that my 640x480 image is fullscreen?
windows-no problem.
fullscreen - image is zoomed in, never right.
-
It may be that your monitor is showing only a fraction of the screen for the resolution you are trying to use. Try to mess with its options and see if there was something hidden.
-
been messing about for ages now.
//Window.Create(sf::VideoMode(DesktopMode.Width / devide, DesktopMode.Height / devide, DesktopMode.BitsPerPixel), "SFML Graphics", style);
Window.Create(sf::VideoMode(DesktopMode.Width , DesktopMode.Height , DesktopMode.BitsPerPixel), "SFML Graphics", sf::Style::Fullscreen);
should be "my screen size" though, right?
edit:
but, even: Window.Create(sf::VideoMode(800, 600 , DesktopMode.BitsPerPixel), "SFML Graphics", sf::Style::Fullscreen);
doesnt show the 800x600 pic properly.
-going to try a minimal again, but I'm sure I had the same problems before (code first,2nd post)
-
If view.SetSize(640 ,480 ); everytime equal the window size then the view is correct and you dont have resized images or background or anything else.
-
sorry , I don't understand?
-
Elgan, I meant for you to mess with your monitor options.
-
Elgan, I meant for you to mess with your monitor options.
tried that too, thank you tho :\
I cant make em bigger though, 2550x1440
-
still stuck :(