Weird, I got no screen tearing.
I actually got extremely bad screen tearing. It looked like there was a drastic FPS drop, but the fps was apparently a constant 60, so I'm not sure what that's about.
Ive noticed that at set "Screen resolution" and VerticalSync set on, on some systems the screen tearing occurs.
What i have noticed is that "Screen resolution" is not valid for their system (but it shouldn't mother since its not fullscreen) well one case i had one person help me test it.
I have made code so that it checks if the screen resolution is valid.
If valid apply the default one.
Else check witch screen resolution that is the least bigger is valid and apply that and there would be black borders.
And with that the tearing was gone, so if i add that i fixed the error.
About the code request: I save each build i make. Each build is made each time i finish/start programing so there is allot of builds.
The issue is that i do not know witch build this error was occurring at, and i messed with the renderWindow and openGL states before and after so the code may be incorrect.
I suggest open a new thread for this issue, (The windows saves witch date/time the file was modified) by that i can check when first post was made and i will get you the code very close to the time of the post.
CODE
//"Control.h"
const bool WINDOW_FPS_CAP = false;
const int WINDOW_FPS_CAP_AMOUNT = 60;
const bool WINDOW_VSYNC = true;
const int WINDOW_WIDTH = 800;
const int WINDOW_HEIGHT = 600;
const int WINDOW_BPP = 32;
//"time.h"
#include <SFML/System.hpp>
class Time
{
public:
Time();
void UpdateLoopTime();
int timePerLoop;
int dt;
private:
sf::Clock mainClock;
};
//"time.cpp"
Time::Time()
{
timePerLoop = 0;
dt = 0;
}
void Time::UpdateLoopTime()
{
dt = mainClock.getElapsedTime().asMilliseconds();
if(dt < 0)
dt = 1;
else if(dt > 50)
dt = 50;
timePerLoop = mainClock.restart().asMilliseconds();
}
//"FPS.h"
#include <SFML/Graphics.hpp>
#include <SFML/System.hpp>
class FPS
{
public:
FPS(sf::Font & font);
void Update();
void Display(sf::RenderWindow & renWin);
private:
sf::Clock clock;
sf::Text txt;
int loopAmount;
int totalAmount;
};
//"FPS.cpp"
FPS::FPS(sf::Font & font)
{
loopAmount = 0;
totalAmount = 0;
txt.setFont(font);
txt.setCharacterSize(12);
txt.setColor(sf::Color::White);
txt.setPosition(0, 0);
txt.setString("FPS:0");
}
void FPS::Update()
{
loopAmount ++;
if(clock.getElapsedTime().asMilliseconds() > 1000)
{
clock.restart();
totalAmount = loopAmount;
loopAmount = 0;
txt.setString("FPS:" + std::to_string(totalAmount));
}
}
void FPS::Display(sf::RenderWindow & renWin)
{
renWin.draw(txt);
}
//"Window.h"
class Window
{
public:
Window(int Width, int Height, int BPP, std::string string = "", int style = sf::Style::Default);
sf::VideoMode vidMod;
sf::RenderWindow renWin;
private:
void CreateWindow(std::string string, int style);
};
//"Window.cpp"
Window::Window(int Width, int Height, int BPP, std::string string, int style)
{
vidMod.width = Width;
vidMod.height = Height;
vidMod.bitsPerPixel = BPP;
CreateWindow(string, style);
}
void Window::CreateWindow(std::string string, int style)
{
sf::ContextSettings constSetting = sf::ContextSettings();
constSetting.antialiasingLevel = 0;
constSetting.depthBits = 32;
constSetting.majorVersion = 0;
constSetting.minorVersion = 0;
constSetting.stencilBits = 0;
renWin.create(vidMod, string, style, constSetting);
//If cap fps then cap fps
//else if VSync true then VSync on
if(WINDOW_FPS_CAP == true)
{
renWin.setFramerateLimit(WINDOW_FPS_CAP_AMOUNT);
}
else if(WINDOW_VSYNC == true)
{
renWin.setVerticalSyncEnabled(true);
}
}
//"main.cpp"
int main()
{
//Creation of objects
Window objWindow( WINDOW_WIDTH, WINDOW_HEIGHT, 32, "YoFat^^", sf::Style::Default);
Camera objCam(objWindow.renWin);
Time objTime;
FPS objFPS(objFon.arial);
...
//Main loop
{
objTime.UpdateLoopTime();//Delta time
objFPS.Update();
//Logic, drawing...
objCam.SetViewDefault();
objFPS.Display(objWindow.renWin);//Fps draw
objWindow.renWin.display();
objWindow.renWin.clear();
}
If you want to contact me send me a message...