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

Author Topic: Fullscreen Stopped Stretching?  (Read 4456 times)

0 Members and 1 Guest are viewing this topic.

Andershizzle

  • Newbie
  • *
  • Posts: 16
    • View Profile
Fullscreen Stopped Stretching?
« on: September 03, 2009, 05:27:22 am »
So yeah I was programming my code and everything was going well.

I was rendering a 800x600 fullscreen window which would go full-screen and stretched out to fit my widescreen laptop (with a 1024x600 resolution normally.)

However, after adding a few libraries and a lot more code and moving things around, it STOPPED stretching. Now it goes fullscreen and draws 800x600 in the CENTER of the screen instead of stretching to fit the whole screen.

Any ideas how to fix this? Thanks!

Here's my code. (getting long)

Code: [Select]


////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include <iostream>
#include <string>
#include <SFML/System.hpp>
#include <SFML/Window.hpp>
#include <SFML/Graphics.hpp>
#include <SFML/Network.hpp>
#include <SFML/Audio.hpp>
#include "cpGUI.h"

using namespace std;

////////////////////////////////////////////////////////////
/// Entry point of application
///
/// \return Application exit code
///
////////////////////////////////////////////////////////////


// Functions For Different Screens
int ShowLoginScreen();
int ShowGameScreen();




// Global Variables
string CurrentGameScreen = "LoginScreen";
string g_username;


// Define 'App'
sf::RenderWindow App;

int main()
{
// Render The Window
App.Create(sf::VideoMode(800, 600, 32), "Wonderful Game", sf::Style::Fullscreen);
    // Get a reference to the input manager associated to our window, and store it for later use
    const sf::Input& Input = App.GetInput();

    // Start main loop
    while (App.IsOpened())
    {
if (CurrentGameScreen == "LoginScreen")
{
ShowLoginScreen();
}
if (CurrentGameScreen == "GameScreen")
{
App.ShowMouseCursor(false);
ShowGameScreen();
}

if (CurrentGameScreen == "Exit")
{
App.Close();
}

    }

    return EXIT_SUCCESS;

}


///////////////////////////////////////
///////////////////////////////////////
//////ShowLoginScreen Function
///////////////////////////////////////
///////////////////////////////////////


int ShowLoginScreen()
{

// Load Variables
int LoginScreenIsLoaded = 0;
string username;
string password;
int rememberMe = 0;

// Load Images
sf::Image LoginBackImg;
if(!LoginBackImg.LoadFromFile("img/LoginBack.png"))
//ERROR
LoginBackImg.SetSmooth(false);

sf::Sprite LoginBack(LoginBackImg);
LoginBack.SetPosition(0.f, 0.f);

// Start Main Game Screen Loop
LoginScreenIsLoaded = 1;

while (LoginScreenIsLoaded == 1)
{

        // Process events
        sf::Event Event;
        while (App.GetEvent(Event))
        {
            // Close window : exit
            if (Event.Type == sf::Event::Closed)
{
CurrentGameScreen = "Exit";
LoginScreenIsLoaded = 0;
}

            // Escape key : exit
            if ((Event.Type == sf::Event::KeyPressed) && (Event.Key.Code == sf::Key::Escape))
{
CurrentGameScreen = "Exit";
LoginScreenIsLoaded = 0;
}
}


// Get elapsed time
float ElapsedTime = App.GetFrameTime();





//Clear Screen
App.Clear();

// Draw LoginBack
App.Draw(LoginBack);

// Display Window On Screen
App.Display();
}
}






///////////////////////////////////////
///////////////////////////////////////
//////ShowGameScreen Function
///////////////////////////////////////
///////////////////////////////////////

int ShowGameScreen()
{

//Load Variables
int CurrentFrame = 1;
int FrameWidth = 50;
int FrameHeight = 80;
int CharSubRectY1 = 0;
int CharSubRectY2 = FrameHeight;
int CharIsWalking = 0;
int isAnimating = 0;
float FPS;
float CurrentFPS;
int TotalFrames;
int GameScreenIsLoaded = 0;

// Load Images
sf::Image MaleBaseSheet;
if(!MaleBaseSheet.LoadFromFile("img/MaleBaseSheet.png"))
//ERROR
MaleBaseSheet.SetSmooth(false);

sf::Sprite MaleBase(MaleBaseSheet);
MaleBase.SetPosition(300.f, 200.f);

// Start Main Game Screen Loop
GameScreenIsLoaded = 1;


while (GameScreenIsLoaded == 1)
{


        // Process events
        sf::Event Event;
        while (App.GetEvent(Event))
        {
            // Close window : exit
            if (Event.Type == sf::Event::Closed)
{
CurrentGameScreen = "Exit";
GameScreenIsLoaded = 0;
}

            // Escape key : exit
            if ((Event.Type == sf::Event::KeyPressed) && (Event.Key.Code == sf::Key::Escape))
{
CurrentGameScreen = "Exit";
GameScreenIsLoaded = 0;
}
}


// Get elapsed time
float ElapsedTime = App.GetFrameTime();



// Movement
CharIsWalking = 0;
if (App.GetInput().IsKeyDown(sf::Key::Left))
{
CharIsWalking = 1;
MaleBase.Move(-80 * ElapsedTime, 0);
CharSubRectY1 = 80;
CharSubRectY2 = 160;
}
if (App.GetInput().IsKeyDown(sf::Key::Right))
{
CharIsWalking = 1;
MaleBase.Move( 80 * ElapsedTime, 0);
CharSubRectY1 = 160;
CharSubRectY2 = 240;
}
if (App.GetInput().IsKeyDown(sf::Key::Up))
{
CharIsWalking = 1;
MaleBase.Move(0, -80 * ElapsedTime);
CharSubRectY1 = 240;
CharSubRectY2 = 320;
}
if (App.GetInput().IsKeyDown(sf::Key::Down))
{
CharIsWalking = 1;
MaleBase.Move(0,  80 * ElapsedTime);
CharSubRectY1 = 0;
CharSubRectY2 = 80;
}


if (CharIsWalking == 1)
{
if(isAnimating == 0)
{

FPS = 3;
TotalFrames = 4;
CurrentFPS = FPS;
isAnimating = 1;
}

if(isAnimating == 1)
{
CurrentFPS = CurrentFPS - 10 * ElapsedTime;
if(CurrentFPS < 1)
{
if(CurrentFrame < TotalFrames)
{
CurrentFrame = CurrentFrame + 1;
}
else
{
CurrentFrame = 1;
}

isAnimating = 0;
}
}
}

else
{
CurrentFrame = 1;
}


//Set Sub Rect
MaleBase.SetSubRect(sf::IntRect(CurrentFrame * FrameWidth - FrameWidth, CharSubRectY1, CurrentFrame * FrameWidth, CharSubRectY2));

//Clear Screen
App.Clear();

// Draw MaleBase
App.Draw(MaleBase);

// Display Window On Screen
App.Display();



}

}



Andershizzle

  • Newbie
  • *
  • Posts: 16
    • View Profile
Fullscreen Stopped Stretching?
« Reply #1 on: September 03, 2009, 05:30:19 am »
Shoot, it suddenly fixed itself randomly? Nevermind this >.<. Sorriez. Mod?

Astrof

  • Full Member
  • ***
  • Posts: 135
    • View Profile
Fullscreen Stopped Stretching?
« Reply #2 on: September 03, 2009, 05:34:59 am »
I think I'd rather have it center than stretch.  In fact I'm trying to figure out how to manually do that (but maybe draw some stripes or something to reduce burn in)

julen26

  • Jr. Member
  • **
  • Posts: 89
    • View Profile
    • http://julen26.blogspot.com
Fullscreen Stopped Stretching?
« Reply #3 on: September 04, 2009, 10:35:06 pm »
It depends of your graphic card configuration. With an ATI for example you can change that on the control panel.  :wink:

 

anything