Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: help setting fullscreen resolution with view.  (Read 9627 times)

0 Members and 1 Guest are viewing this topic.

Elgan

  • Jr. Member
  • **
  • Posts: 77
    • AOL Instant Messenger - Flat+1,+17+st+Cl
    • View Profile
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;
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?

Elgan

  • Jr. Member
  • **
  • Posts: 77
    • AOL Instant Messenger - Flat+1,+17+st+Cl
    • View Profile
help setting fullscreen resolution with view.
« Reply #1 on: March 01, 2012, 07:41:16 pm »
Any ideas?

so I can set it up like so for windowed mode (which works anyway)

Code: [Select]



////////////////////////////////////////////////////////////
// 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

Code: [Select]

sf::Vector2f CGameEngine::GetSize()
{
return Window.ConvertCoords(Window.GetWidth() / 2 , Window.GetHeight() / 2);


The above returns place my sprites exactly where I want them :\

Elgan

  • Jr. Member
  • **
  • Posts: 77
    • AOL Instant Messenger - Flat+1,+17+st+Cl
    • View Profile
help setting fullscreen resolution with view.
« Reply #2 on: March 08, 2012, 03:44:26 pm »
i still really need some help on this guys

Code: [Select]


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.

Tex Killer

  • Full Member
  • ***
  • Posts: 242
    • View Profile
help setting fullscreen resolution with view.
« Reply #3 on: March 08, 2012, 04:13:17 pm »
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.

Elgan

  • Jr. Member
  • **
  • Posts: 77
    • AOL Instant Messenger - Flat+1,+17+st+Cl
    • View Profile
help setting fullscreen resolution with view.
« Reply #4 on: March 08, 2012, 04:17:10 pm »
been messing about for ages now.

Code: [Select]
//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)

Ptlomej

  • Newbie
  • *
  • Posts: 48
    • ICQ Messenger - 353167418
    • View Profile
    • Local
help setting fullscreen resolution with view.
« Reply #5 on: March 08, 2012, 04:53:17 pm »
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.

Elgan

  • Jr. Member
  • **
  • Posts: 77
    • AOL Instant Messenger - Flat+1,+17+st+Cl
    • View Profile
help setting fullscreen resolution with view.
« Reply #6 on: March 08, 2012, 05:35:46 pm »
sorry , I don't understand?

Tex Killer

  • Full Member
  • ***
  • Posts: 242
    • View Profile
help setting fullscreen resolution with view.
« Reply #7 on: March 08, 2012, 11:02:03 pm »
Elgan, I meant for you to mess with your monitor options.

Elgan

  • Jr. Member
  • **
  • Posts: 77
    • AOL Instant Messenger - Flat+1,+17+st+Cl
    • View Profile
help setting fullscreen resolution with view.
« Reply #8 on: March 08, 2012, 11:32:45 pm »
Quote from: "Tex Killer"
Elgan, I meant for you to mess with your monitor options.


tried that too, thank you tho :\

I cant make em bigger though, 2550x1440

Elgan

  • Jr. Member
  • **
  • Posts: 77
    • AOL Instant Messenger - Flat+1,+17+st+Cl
    • View Profile
help setting fullscreen resolution with view.
« Reply #9 on: March 15, 2012, 01:50:57 pm »
still stuck :(

 

anything