Run clang-format

This commit is contained in:
Chris Thrasher 2022-07-04 11:20:58 -05:00 committed by Lukas Dürrenberger
parent 88e9f82bee
commit 4f52793f7d
416 changed files with 9918 additions and 9447 deletions

View File

@ -4,14 +4,14 @@
////////////////////////////////////////////////////////////
#include <SFML/Window.hpp>
#include <X11/Xlib.h>
#define GLAD_GL_IMPLEMENTATION
#include <gl.h>
#include <X11/Xlib.h>
#include <array>
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <iostream>
////////////////////////////////////////////////////////////
/// Initialize OpenGL states into the specified view
@ -171,31 +171,49 @@ int main()
XSetWindowAttributes attributes;
attributes.background_pixel = BlackPixel(display, screen);
attributes.event_mask = KeyPressMask;
Window window = XCreateWindow(display, RootWindow(display, screen),
0, 0, 650, 330, 0,
Window window = XCreateWindow(display,
RootWindow(display, screen),
0,
0,
650,
330,
0,
DefaultDepth(display, screen),
InputOutput,
DefaultVisual(display, screen),
CWBackPixel | CWEventMask, &attributes);
CWBackPixel | CWEventMask,
&attributes);
if (!window)
return EXIT_FAILURE;
// Set the window's name
XStoreName(display, window , "SFML Window");
XStoreName(display, window, "SFML Window");
// Let's create the windows which will serve as containers for our SFML views
Window view1 = XCreateWindow(display, window,
10, 10, 310, 310, 0,
Window view1 = XCreateWindow(display,
window,
10,
10,
310,
310,
0,
DefaultDepth(display, screen),
InputOutput,
DefaultVisual(display, screen),
0, nullptr);
Window view2 = XCreateWindow(display, window,
330, 10, 310, 310, 0,
0,
nullptr);
Window view2 = XCreateWindow(display,
window,
330,
10,
310,
310,
0,
DefaultDepth(display, screen),
InputOutput,
DefaultVisual(display, screen),
0, nullptr);
0,
nullptr);
// Show our windows
XMapWindow(display, window);

View File

@ -1,8 +1,8 @@
#include <SFML/Audio.hpp>
#include <SFML/Graphics.hpp>
#include <SFML/Network.hpp>
#include <SFML/System.hpp>
#include <SFML/Window.hpp>
#include <SFML/Graphics.hpp>
#include <SFML/Audio.hpp>
#include <SFML/Network.hpp>
// Do we want to showcase direct JNI/NDK interaction?
// Undefine this to get real cross-platform code.
@ -11,8 +11,8 @@
#if defined(USE_JNI)
// These headers are only needed for direct NDK/JDK interaction
#include <jni.h>
#include <android/native_activity.h>
#include <jni.h>
// Since we want to get the native activity from SFML, we'll have to use an
// extra header here:
@ -22,7 +22,7 @@
int vibrate(sf::Time duration)
{
// First we'll need the native activity handle
ANativeActivity *activity = sf::getNativeActivity();
ANativeActivity* activity = sf::getNativeActivity();
// Retrieve the JVM and JNI environment
JavaVM* vm = activity->vm;
@ -75,7 +75,7 @@ int vibrate(sf::Time duration)
// This is the actual Android example. You don't have to write any platform
// specific code, unless you want to use things not directly exposed.
// ('vibrate()' in this example; undefine 'USE_JNI' above to disable it)
int main(int argc, char *argv[])
int main(int argc, char* argv[])
{
sf::VideoMode screen(sf::VideoMode::getDesktopMode());
@ -83,7 +83,7 @@ int main(int argc, char *argv[])
window.setFramerateLimit(30);
sf::Texture texture;
if(!texture.loadFromFile("image.png"))
if (!texture.loadFromFile("image.png"))
return EXIT_FAILURE;
sf::Sprite image(texture);
@ -159,7 +159,8 @@ int main(int argc, char *argv[])
window.draw(text);
window.display();
}
else {
else
{
sf::sleep(sf::milliseconds(100));
}
}

View File

@ -23,9 +23,10 @@
//
////////////////////////////////////////////////////////////
#import <Cocoa/Cocoa.h>
#import <SFML/Graphics.hpp>
#import <Cocoa/Cocoa.h>
/*
* NB: We need pointers for C++ objects fields in Obj-C interface !
* The recommended way is to use PIMPL idiom.
@ -36,7 +37,7 @@
struct SFMLmainWindow;
@interface CocoaAppDelegate : NSObject <NSApplicationDelegate>
@interface CocoaAppDelegate : NSObject<NSApplicationDelegate>
{
@private
NSWindow* m_window;
@ -54,11 +55,11 @@ struct SFMLmainWindow;
@property (assign) IBOutlet NSTextField* textField;
-(IBAction)colorChanged:(NSPopUpButton*)sender;
-(IBAction)rotationChanged:(NSSlider*)sender;
-(IBAction)visibleChanged:(NSButton*)sender;
-(IBAction)textChanged:(NSTextField*)sender;
-(IBAction)updateText:(NSButton*)sender;
- (IBAction)colorChanged:(NSPopUpButton*)sender;
- (IBAction)rotationChanged:(NSSlider*)sender;
- (IBAction)visibleChanged:(NSButton*)sender;
- (IBAction)textChanged:(NSTextField*)sender;
- (IBAction)updateText:(NSButton*)sender;
@end
@ -68,6 +69,6 @@ struct SFMLmainWindow;
*/
@interface SilentWindow : NSWindow
-(void)keyDown:(NSEvent*)theEvent;
- (void)keyDown:(NSEvent*)theEvent;
@end

View File

@ -24,6 +24,7 @@
////////////////////////////////////////////////////////////
#import "CocoaAppDelegate.h"
#import "NSString+stdstring.h"
// These define are used for converting the color of the NSPopUpButton
@ -32,19 +33,17 @@
#define RED @"Red"
#if defined(__APPLE__)
#if defined(__clang__)
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
#elif defined(__GNUC__)
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
#endif
#if defined(__clang__)
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
#elif defined(__GNUC__)
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
#endif
#endif
// Our PIMPL
struct SFMLmainWindow
{
SFMLmainWindow(sf::WindowHandle win) :
renderWindow(win),
background(sf::Color::Blue)
SFMLmainWindow(sf::WindowHandle win) : renderWindow(win), background(sf::Color::Blue)
{
std::string resPath = [[[NSBundle mainBundle] resourcePath] tostdstring];
if (!logo.loadFromFile(resPath + "/logo.png"))
@ -86,7 +85,7 @@ struct SFMLmainWindow
@property (assign) BOOL initialized;
-(void)renderMainWindow:(NSTimer*)aTimer;
- (void)renderMainWindow:(NSTimer*)aTimer;
@end
@ -113,7 +112,7 @@ struct SFMLmainWindow
return self;
}
-(void)applicationDidFinishLaunching:(NSNotification*)aNotification
- (void)applicationDidFinishLaunching:(NSNotification*)aNotification
{
(void)aNotification;
@ -125,15 +124,14 @@ struct SFMLmainWindow
self.visible = YES;
// Launch the timer to periodically display our stuff into the Cocoa view.
self.renderTimer = [NSTimer timerWithTimeInterval:1.0/60.0
self.renderTimer = [NSTimer
timerWithTimeInterval:1.0 / 60.0
target:self
selector:@selector(renderMainWindow:)
userInfo:nil
repeats:YES];
[[NSRunLoop mainRunLoop] addTimer:self.renderTimer
forMode:NSDefaultRunLoopMode];
[[NSRunLoop mainRunLoop] addTimer:self.renderTimer
forMode:NSEventTrackingRunLoopMode];
[[NSRunLoop mainRunLoop] addTimer:self.renderTimer forMode:NSDefaultRunLoopMode];
[[NSRunLoop mainRunLoop] addTimer:self.renderTimer forMode:NSEventTrackingRunLoopMode];
/*
* This is really some ugly code but in order to have the timer fired
* periodically we need to add it to the two above runloop mode.
@ -147,7 +145,7 @@ struct SFMLmainWindow
}
}
-(void)dealloc
- (void)dealloc
{
[self.renderTimer invalidate];
self.mainWindow->renderWindow.close();
@ -163,7 +161,7 @@ struct SFMLmainWindow
[super dealloc];
}
-(void)renderMainWindow:(NSTimer*)aTimer
- (void)renderMainWindow:(NSTimer*)aTimer
{
(void)aTimer;
@ -187,7 +185,7 @@ struct SFMLmainWindow
self.mainWindow->renderWindow.display();
}
-(IBAction)colorChanged:(NSPopUpButton*)sender
- (IBAction)colorChanged:(NSPopUpButton*)sender
{
if (self.initialized)
{
@ -202,7 +200,7 @@ struct SFMLmainWindow
}
}
-(IBAction)rotationChanged:(NSSlider*)sender
- (IBAction)rotationChanged:(NSSlider*)sender
{
if (self.initialized)
{
@ -211,13 +209,13 @@ struct SFMLmainWindow
}
}
-(IBAction)visibleChanged:(NSButton*)sender
- (IBAction)visibleChanged:(NSButton*)sender
{
if (self.initialized)
self.visible = [sender state] == NSOnState;
}
-(IBAction)textChanged:(NSTextField*)sender
- (IBAction)textChanged:(NSTextField*)sender
{
if (self.initialized)
self.mainWindow->text.setString([[sender stringValue] tostdwstring]);
@ -235,7 +233,7 @@ struct SFMLmainWindow
@implementation SilentWindow
-(void)keyDown:(NSEvent*)theEvent
- (void)keyDown:(NSEvent*)theEvent
{
(void)theEvent;
// Do nothing except preventing this alert.

View File

@ -23,17 +23,17 @@
//
////////////////////////////////////////////////////////////
#import <string>
#import <Foundation/Foundation.h>
#import <string>
@interface NSString (NSString_stdstring)
+(id)stringWithstdstring:(const std::string&)string;
+ (id)stringWithstdstring:(const std::string&)string;
+(id)stringWithstdwstring:(const std::wstring&)string;
+ (id)stringWithstdwstring:(const std::wstring&)string;
-(std::string)tostdstring;
- (std::string)tostdstring;
-(std::wstring)tostdwstring;
- (std::wstring)tostdwstring;
@end

View File

@ -23,24 +23,24 @@
//
////////////////////////////////////////////////////////////
#import "NSString+stdstring.h"
#include <SFML/System/Utf.hpp>
#import "NSString+stdstring.h"
@implementation NSString (NSString_stdstring)
+(id)stringWithstdstring:(const std::string&)string
+ (id)stringWithstdstring:(const std::string&)string
{
std::string utf8;
utf8.reserve(string.size() + 1);
sf::Utf8::fromAnsi(string.begin(), string.end(), std::back_inserter(utf8));
NSString* str = [NSString stringWithCString:utf8.c_str()
encoding:NSUTF8StringEncoding];
NSString* str = [NSString stringWithCString:utf8.c_str() encoding:NSUTF8StringEncoding];
return str;
}
+(id)stringWithstdwstring:(const std::wstring&)string
+ (id)stringWithstdwstring:(const std::wstring&)string
{
const void* data = static_cast<const void*>(string.data());
unsigned size = static_cast<unsigned>(string.size() * sizeof(wchar_t));
@ -50,11 +50,11 @@
return str;
}
-(std::string)tostdstring
- (std::string)tostdstring
{
// Not sure about the encoding to use. Using [self UTF8String] doesn't
// work for characters like é or à.
const char *cstr = [self cStringUsingEncoding:NSISOLatin1StringEncoding];
const char* cstr = [self cStringUsingEncoding:NSISOLatin1StringEncoding];
if (cstr != nullptr)
return std::string(cstr);
@ -62,7 +62,7 @@
return "";
}
-(std::wstring)tostdwstring
- (std::wstring)tostdwstring
{
// According to Wikipedia, Mac OS X is Little Endian on x86 and x86-64
// https://en.wikipedia.org/wiki/Endianness

View File

@ -3,6 +3,7 @@
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Network.hpp>
#include <fstream>
#include <iostream>
#include <optional>
@ -12,7 +13,7 @@
/// Print a FTP response into a standard output stream
///
////////////////////////////////////////////////////////////
std::ostream& operator <<(std::ostream& stream, const sf::Ftp::Response& response)
std::ostream& operator<<(std::ostream& stream, const sf::Ftp::Response& response)
{
return stream << response.getStatus() << response.getMessage();
}
@ -32,8 +33,7 @@ int main()
{
std::cout << "Enter the FTP server address: ";
std::cin >> address;
}
while (!address.has_value());
} while (!address.has_value());
// Connect to the server
sf::Ftp server;
@ -93,8 +93,7 @@ int main()
{
// Print the current server directory
sf::Ftp::DirectoryResponse response = server.getWorkingDirectory();
std::cout << response << '\n'
<< "Current directory is " << response.getDirectory() << std::endl;
std::cout << response << '\n' << "Current directory is " << response.getDirectory() << std::endl;
break;
}
@ -195,8 +194,7 @@ int main()
} while (choice != 0);
// Disconnect from the server
std::cout << "Disconnecting from server...\n"
<< server.disconnect() << '\n';
std::cout << "Disconnecting from server...\n" << server.disconnect() << '\n';
// Wait until the user presses 'enter' key
std::cout << "Press enter to exit..." << std::endl;

View File

@ -2,13 +2,16 @@
////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Graphics.hpp>
#define STB_PERLIN_IMPLEMENTATION
#include <stb_perlin.h>
#include <SFML/Graphics.hpp>
#include <algorithm>
#include <array>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iostream>
#include <mutex>
@ -16,62 +19,58 @@
#include <thread>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <cstring>
namespace
{
// Width and height of the application window
const unsigned int windowWidth = 800;
const unsigned int windowHeight = 600;
// Width and height of the application window
const unsigned int windowWidth = 800;
const unsigned int windowHeight = 600;
// Resolution of the generated terrain
const unsigned int resolutionX = 800;
const unsigned int resolutionY = 600;
// Resolution of the generated terrain
const unsigned int resolutionX = 800;
const unsigned int resolutionY = 600;
// Thread pool parameters
const unsigned int threadCount = 4;
const unsigned int blockCount = 32;
// Thread pool parameters
const unsigned int threadCount = 4;
const unsigned int blockCount = 32;
struct WorkItem
{
struct WorkItem
{
sf::Vertex* targetBuffer;
unsigned int index;
};
};
std::deque<WorkItem> workQueue;
std::vector<std::thread> threads;
int pendingWorkCount = 0;
bool workPending = true;
bool bufferUploadPending = false;
std::recursive_mutex workQueueMutex;
std::deque<WorkItem> workQueue;
std::vector<std::thread> threads;
int pendingWorkCount = 0;
bool workPending = true;
bool bufferUploadPending = false;
std::recursive_mutex workQueueMutex;
struct Setting
{
struct Setting
{
const char* name;
float* value;
};
};
// Terrain noise parameters
const int perlinOctaves = 3;
// Terrain noise parameters
const int perlinOctaves = 3;
float perlinFrequency = 7.0f;
float perlinFrequencyBase = 4.0f;
float perlinFrequency = 7.0f;
float perlinFrequencyBase = 4.0f;
// Terrain generation parameters
float heightBase = 0.0f;
float edgeFactor = 0.9f;
float edgeDropoffExponent = 1.5f;
// Terrain generation parameters
float heightBase = 0.0f;
float edgeFactor = 0.9f;
float edgeDropoffExponent = 1.5f;
float snowcapHeight = 0.6f;
float snowcapHeight = 0.6f;
// Terrain lighting parameters
float heightFactor = windowHeight / 2.0f;
float heightFlatten = 3.0f;
float lightFactor = 0.7f;
}
// Terrain lighting parameters
float heightFactor = windowHeight / 2.0f;
float heightFlatten = 3.0f;
float lightFactor = 0.7f;
} // namespace
// Forward declarations of the functions we define further down
@ -88,8 +87,7 @@ void generateTerrain(sf::Vertex* vertexBuffer);
int main()
{
// Create the window of the application
sf::RenderWindow window(sf::VideoMode({windowWidth, windowHeight}), "SFML Island",
sf::Style::Titlebar | sf::Style::Close);
sf::RenderWindow window(sf::VideoMode({windowWidth, windowHeight}), "SFML Island", sf::Style::Titlebar | sf::Style::Close);
window.setVerticalSyncEnabled(true);
sf::Font font;
@ -159,12 +157,12 @@ int main()
}
// Center the status text
statusText.setPosition({(windowWidth - statusText.getLocalBounds().width) / 2.f, (windowHeight - statusText.getLocalBounds().height) / 2.f});
statusText.setPosition({(windowWidth - statusText.getLocalBounds().width) / 2.f,
(windowHeight - statusText.getLocalBounds().height) / 2.f});
// Set up an array of pointers to our settings for arrow navigation
constexpr std::array<Setting, 9> settings =
{{
{"perlinFrequency", &perlinFrequency},
constexpr std::array<Setting, 9> settings = {
{{"perlinFrequency", &perlinFrequency},
{"perlinFrequencyBase", &perlinFrequencyBase},
{"heightBase", &heightBase},
{"edgeFactor", &edgeFactor},
@ -172,8 +170,7 @@ int main()
{"snowcapHeight", &snowcapHeight},
{"heightFactor", &heightFactor},
{"heightFlatten", &heightFlatten},
{"lightFactor", &lightFactor}
}};
{"lightFactor", &lightFactor}}};
std::size_t currentSetting = 0;
@ -198,12 +195,23 @@ int main()
{
switch (event.key.code)
{
case sf::Keyboard::Enter: generateTerrain(terrainStagingBuffer.data()); break;
case sf::Keyboard::Down: currentSetting = (currentSetting + 1) % settings.size(); break;
case sf::Keyboard::Up: currentSetting = (currentSetting + settings.size() - 1) % settings.size(); break;
case sf::Keyboard::Left: *(settings[currentSetting].value) -= 0.1f; break;
case sf::Keyboard::Right: *(settings[currentSetting].value) += 0.1f; break;
default: break;
case sf::Keyboard::Enter:
generateTerrain(terrainStagingBuffer.data());
break;
case sf::Keyboard::Down:
currentSetting = (currentSetting + 1) % settings.size();
break;
case sf::Keyboard::Up:
currentSetting = (currentSetting + settings.size() - 1) % settings.size();
break;
case sf::Keyboard::Left:
*(settings[currentSetting].value) -= 0.1f;
break;
case sf::Keyboard::Right:
*(settings[currentSetting].value) += 0.1f;
break;
default:
break;
}
}
}
@ -245,7 +253,8 @@ int main()
<< "Use the arrow keys to change the values.\nUse the return key to regenerate the terrain.\n\n";
for (std::size_t i = 0; i < settings.size(); ++i)
osstr << ((i == currentSetting) ? ">> " : " ") << settings[i].name << ": " << *(settings[i].value) << '\n';
osstr << ((i == currentSetting) ? ">> " : " ") << settings[i].name << ": "
<< *(settings[i].value) << '\n';
hudText.setString(osstr.str());
@ -285,11 +294,13 @@ float getElevation(float x, float y)
for (int i = 0; i < perlinOctaves; ++i)
{
elevation += stb_perlin_noise3(
x * perlinFrequency * static_cast<float>(std::pow(perlinFrequencyBase, i)),
elevation += stb_perlin_noise3(x * perlinFrequency * static_cast<float>(std::pow(perlinFrequencyBase, i)),
y * perlinFrequency * static_cast<float>(std::pow(perlinFrequencyBase, i)),
0, 0, 0, 0
) * static_cast<float>(std::pow(perlinFrequencyBase, -i));
0,
0,
0,
0) *
static_cast<float>(std::pow(perlinFrequencyBase, -i));
}
elevation = (elevation + 1.f) / 2.f;
@ -316,11 +327,7 @@ float getMoisture(float x, float y)
x = x / resolutionX - 0.5f;
y = y / resolutionY - 0.5f;
float moisture = stb_perlin_noise3(
x * 4.f + 0.5f,
y * 4.f + 0.5f,
0, 0, 0, 0
);
float moisture = stb_perlin_noise3(x * 4.f + 0.5f, y * 4.f + 0.5f, 0, 0, 0, 0);
return (moisture + 1.f) / 2.f;
}
@ -337,21 +344,22 @@ float getMoisture(unsigned int x, unsigned int y)
////////////////////////////////////////////////////////////
sf::Color colorFromFloats(float r, float g, float b)
{
return sf::Color(static_cast<sf::Uint8>(r),
static_cast<sf::Uint8>(g),
static_cast<sf::Uint8>(b));
return sf::Color(static_cast<sf::Uint8>(r), static_cast<sf::Uint8>(g), static_cast<sf::Uint8>(b));
}
sf::Color getLowlandsTerrainColor(float moisture)
{
sf::Color color =
moisture < 0.27f ? colorFromFloats(240, 240, 180) :
moisture < 0.3f ? colorFromFloats(240 - (240 * (moisture - 0.27f) / 0.03f), 240 - (40 * (moisture - 0.27f) / 0.03f), 180 - (180 * (moisture - 0.27f) / 0.03f)) :
moisture < 0.4f ? colorFromFloats(0, 200, 0) :
moisture < 0.48f ? colorFromFloats(0, 200 - (40 * (moisture - 0.4f) / 0.08f), 0) :
moisture < 0.6f ? colorFromFloats(0, 160, 0) :
moisture < 0.7f ? colorFromFloats((34 * (moisture - 0.6f) / 0.1f), 160 - (60 * (moisture - 0.6f) / 0.1f), (34 * (moisture - 0.6f) / 0.1f)) :
colorFromFloats(34, 100, 34);
sf::Color color = moisture < 0.27f ? colorFromFloats(240, 240, 180)
: moisture < 0.3f ? colorFromFloats(240 - (240 * (moisture - 0.27f) / 0.03f),
240 - (40 * (moisture - 0.27f) / 0.03f),
180 - (180 * (moisture - 0.27f) / 0.03f))
: moisture < 0.4f ? colorFromFloats(0, 200, 0)
: moisture < 0.48f ? colorFromFloats(0, 200 - (40 * (moisture - 0.4f) / 0.08f), 0)
: moisture < 0.6f ? colorFromFloats(0, 160, 0)
: moisture < 0.7f ? colorFromFloats((34 * (moisture - 0.6f) / 0.1f),
160 - (60 * (moisture - 0.6f) / 0.1f),
(34 * (moisture - 0.6f) / 0.1f))
: colorFromFloats(34, 100, 34);
return color;
}
@ -366,9 +374,10 @@ sf::Color getHighlandsTerrainColor(float elevation, float moisture)
{
sf::Color lowlandsColor = getLowlandsTerrainColor(moisture);
sf::Color color =
moisture < 0.6f ? sf::Color(112, 128, 144) :
colorFromFloats(112 + (110 * (moisture - 0.6f) / 0.4f), 128 + (56 * (moisture - 0.6f) / 0.4f), 144 - (9 * (moisture - 0.6f) / 0.4f));
sf::Color color = moisture < 0.6f ? sf::Color(112, 128, 144)
: colorFromFloats(112 + (110 * (moisture - 0.6f) / 0.4f),
128 + (56 * (moisture - 0.6f) / 0.4f),
144 - (9 * (moisture - 0.6f) / 0.4f));
float factor = std::min((elevation - 0.4f) / 0.1f, 1.f);
@ -408,14 +417,19 @@ sf::Color getSnowcapTerrainColor(float elevation, float moisture)
////////////////////////////////////////////////////////////
sf::Color getTerrainColor(float elevation, float moisture)
{
sf::Color color =
elevation < 0.11f ? sf::Color(0, 0, static_cast<sf::Uint8>(elevation / 0.11f * 74.f + 181.0f)) :
elevation < 0.14f ? sf::Color(static_cast<sf::Uint8>(std::pow((elevation - 0.11f) / 0.03f, 0.3f) * 48.f), static_cast<sf::Uint8>(std::pow((elevation - 0.11f) / 0.03f, 0.3f) * 48.f), 255) :
elevation < 0.16f ? sf::Color(static_cast<sf::Uint8>((elevation - 0.14f) * 128.f / 0.02f + 48.f), static_cast<sf::Uint8>((elevation - 0.14f) * 128.f / 0.02f + 48.f), static_cast<sf::Uint8>(127.0f + (0.16f - elevation) * 128.f / 0.02f)) :
elevation < 0.17f ? sf::Color(240, 230, 140) :
elevation < 0.4f ? getLowlandsTerrainColor(moisture) :
elevation < snowcapHeight ? getHighlandsTerrainColor(elevation, moisture) :
getSnowcapTerrainColor(elevation, moisture);
sf::Color color = elevation < 0.11f ? sf::Color(0, 0, static_cast<sf::Uint8>(elevation / 0.11f * 74.f + 181.0f))
: elevation < 0.14f
? sf::Color(static_cast<sf::Uint8>(std::pow((elevation - 0.11f) / 0.03f, 0.3f) * 48.f),
static_cast<sf::Uint8>(std::pow((elevation - 0.11f) / 0.03f, 0.3f) * 48.f),
255)
: elevation < 0.16f
? sf::Color(static_cast<sf::Uint8>((elevation - 0.14f) * 128.f / 0.02f + 48.f),
static_cast<sf::Uint8>((elevation - 0.14f) * 128.f / 0.02f + 48.f),
static_cast<sf::Uint8>(127.0f + (0.16f - elevation) * 128.f / 0.02f))
: elevation < 0.17f ? sf::Color(240, 230, 140)
: elevation < 0.4f ? getLowlandsTerrainColor(moisture)
: elevation < snowcapHeight ? getHighlandsTerrainColor(elevation, moisture)
: getSnowcapTerrainColor(elevation, moisture);
return color;
}
@ -432,11 +446,9 @@ sf::Vector2f computeNormal(float left, float right, float bottom, float top)
sf::Vector3f deltaX(1, 0, (std::pow(right, heightFlatten) - std::pow(left, heightFlatten)) * heightFactor);
sf::Vector3f deltaY(0, 1, (std::pow(top, heightFlatten) - std::pow(bottom, heightFlatten)) * heightFactor);
sf::Vector3f crossProduct(
deltaX.y * deltaY.z - deltaX.z * deltaY.y,
sf::Vector3f crossProduct(deltaX.y * deltaY.z - deltaX.z * deltaY.y,
deltaX.z * deltaY.x - deltaX.x * deltaY.z,
deltaX.x * deltaY.y - deltaX.y * deltaY.x
);
deltaX.x * deltaY.y - deltaX.y * deltaY.x);
// Scale cross product to make z component 1.0f so we can drop it
crossProduct /= crossProduct.z;
@ -483,9 +495,13 @@ void processWorkItem(std::vector<sf::Vertex>& vertices, const WorkItem& workItem
}
else
{
vertices[arrayIndexBase + 0].position = sf::Vector2f(static_cast<float>(x) * scalingFactorX, static_cast<float>(y) * scalingFactorY);
vertices[arrayIndexBase + 0].position = sf::Vector2f(static_cast<float>(x) * scalingFactorX,
static_cast<float>(y) * scalingFactorY);
vertices[arrayIndexBase + 0].color = getTerrainColor(getElevation(x, y), getMoisture(x, y));
vertices[arrayIndexBase + 0].texCoords = computeNormal(getElevation(x - 1, y), getElevation(x + 1, y), getElevation(x, y + 1), getElevation(x, y - 1));
vertices[arrayIndexBase + 0].texCoords = computeNormal(getElevation(x - 1, y),
getElevation(x + 1, y),
getElevation(x, y + 1),
getElevation(x, y - 1));
}
// Bottom left corner (first triangle)
@ -495,15 +511,23 @@ void processWorkItem(std::vector<sf::Vertex>& vertices, const WorkItem& workItem
}
else
{
vertices[arrayIndexBase + 1].position = sf::Vector2f(static_cast<float>(x) * scalingFactorX, static_cast<float>(y + 1) * scalingFactorY);
vertices[arrayIndexBase + 1].position = sf::Vector2f(static_cast<float>(x) * scalingFactorX,
static_cast<float>(y + 1) * scalingFactorY);
vertices[arrayIndexBase + 1].color = getTerrainColor(getElevation(x, y + 1), getMoisture(x, y + 1));
vertices[arrayIndexBase + 1].texCoords = computeNormal(getElevation(x - 1, y + 1), getElevation(x + 1, y + 1), getElevation(x, y + 2), getElevation(x, y));
vertices[arrayIndexBase + 1].texCoords = computeNormal(getElevation(x - 1, y + 1),
getElevation(x + 1, y + 1),
getElevation(x, y + 2),
getElevation(x, y));
}
// Bottom right corner (first triangle)
vertices[arrayIndexBase + 2].position = sf::Vector2f(static_cast<float>(x + 1) * scalingFactorX, static_cast<float>(y + 1) * scalingFactorY);
vertices[arrayIndexBase + 2].position = sf::Vector2f(static_cast<float>(x + 1) * scalingFactorX,
static_cast<float>(y + 1) * scalingFactorY);
vertices[arrayIndexBase + 2].color = getTerrainColor(getElevation(x + 1, y + 1), getMoisture(x + 1, y + 1));
vertices[arrayIndexBase + 2].texCoords = computeNormal(getElevation(x, y + 1), getElevation(x + 2, y + 1), getElevation(x + 1, y + 2), getElevation(x + 1, y));
vertices[arrayIndexBase + 2].texCoords = computeNormal(getElevation(x, y + 1),
getElevation(x + 2, y + 1),
getElevation(x + 1, y + 2),
getElevation(x + 1, y));
// Top left corner (second triangle)
vertices[arrayIndexBase + 3] = vertices[arrayIndexBase + 0];
@ -518,15 +542,21 @@ void processWorkItem(std::vector<sf::Vertex>& vertices, const WorkItem& workItem
}
else
{
vertices[arrayIndexBase + 5].position = sf::Vector2f(static_cast<float>(x + 1) * scalingFactorX, static_cast<float>(y) * scalingFactorY);
vertices[arrayIndexBase + 5].position = sf::Vector2f(static_cast<float>(x + 1) * scalingFactorX,
static_cast<float>(y) * scalingFactorY);
vertices[arrayIndexBase + 5].color = getTerrainColor(getElevation(x + 1, y), getMoisture(x + 1, y));
vertices[arrayIndexBase + 5].texCoords = computeNormal(getElevation(x, y), getElevation(x + 2, y), getElevation(x + 1, y + 1), getElevation(x + 1, y - 1));
vertices[arrayIndexBase + 5].texCoords = computeNormal(getElevation(x, y),
getElevation(x + 2, y),
getElevation(x + 1, y + 1),
getElevation(x + 1, y - 1));
}
}
}
// Copy the resulting geometry from our thread-local buffer into the target buffer
std::memcpy(workItem.targetBuffer + (resolutionX * rowStart * 6), vertices.data(), sizeof(sf::Vertex) * resolutionX * rowCount * 6);
std::memcpy(workItem.targetBuffer + (resolutionX * rowStart * 6),
vertices.data(),
sizeof(sf::Vertex) * resolutionX * rowCount * 6);
}

View File

@ -3,6 +3,7 @@
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Graphics.hpp>
#include <algorithm>
#include <array>
#include <sstream>
@ -12,51 +13,51 @@
namespace
{
struct JoystickObject
{
struct JoystickObject
{
sf::Text label;
sf::Text value;
};
};
using Texts = std::unordered_map<std::string, JoystickObject>;
Texts texts;
std::ostringstream sstr;
float threshold = 0.1f;
using Texts = std::unordered_map<std::string, JoystickObject>;
Texts texts;
std::ostringstream sstr;
float threshold = 0.1f;
// Axes labels in as C strings
constexpr std::array axislabels = {"X", "Y", "Z", "R", "U", "V", "PovX", "PovY"};
// Axes labels in as C strings
constexpr std::array axislabels = {"X", "Y", "Z", "R", "U", "V", "PovX", "PovY"};
// Helper to set text entries to a specified value
template<typename T>
void set(const char* label, const T& value)
{
// Helper to set text entries to a specified value
template <typename T>
void set(const char* label, const T& value)
{
sstr.str("");
sstr << value;
texts[label].value.setString(sstr.str());
}
}
// Update joystick identification
void updateIdentification(unsigned int index)
{
// Update joystick identification
void updateIdentification(unsigned int index)
{
sstr.str("");
sstr << "Joystick " << index << ":";
texts["ID"].label.setString(sstr.str());
texts["ID"].value.setString(sf::Joystick::getIdentification(index).name);
}
}
// Update joystick axes
void updateAxes(unsigned int index)
{
// Update joystick axes
void updateAxes(unsigned int index)
{
for (unsigned int j = 0; j < sf::Joystick::AxisCount; ++j)
{
if (sf::Joystick::hasAxis(index, static_cast<sf::Joystick::Axis>(j)))
set(axislabels[j], sf::Joystick::getAxisPosition(index, static_cast<sf::Joystick::Axis>(j)));
}
}
}
// Update joystick buttons
void updateButtons(unsigned int index)
{
// Update joystick buttons
void updateButtons(unsigned int index)
{
for (unsigned int j = 0; j < sf::Joystick::getButtonCount(index); ++j)
{
sstr.str("");
@ -64,19 +65,20 @@ namespace
set(sstr.str().c_str(), sf::Joystick::isButtonPressed(index, j));
}
}
}
// Helper to update displayed joystick values
void updateValues(unsigned int index)
// Helper to update displayed joystick values
void updateValues(unsigned int index)
{
if (sf::Joystick::isConnected(index))
{
if (sf::Joystick::isConnected(index)) {
// Update the label-value sf::Text objects based on the current joystick state
updateIdentification(index);
updateAxes(index);
updateButtons(index);
}
}
}
} // namespace
////////////////////////////////////////////////////////////
@ -135,10 +137,12 @@ int main()
sstr << "Button " << i;
JoystickObject& object = texts[sstr.str()];
object.label.setPosition({5.f, 5.f + (static_cast<float>(sf::Joystick::AxisCount + i + 4) * font.getLineSpacing(14))});
object.label.setPosition(
{5.f, 5.f + (static_cast<float>(sf::Joystick::AxisCount + i + 4) * font.getLineSpacing(14))});
object.label.setString(sstr.str() + ":");
object.value.setPosition({80.f, 5.f + (static_cast<float>(sf::Joystick::AxisCount + i + 4) * font.getLineSpacing(14))});
object.value.setPosition(
{80.f, 5.f + (static_cast<float>(sf::Joystick::AxisCount + i + 4) * font.getLineSpacing(14))});
object.value.setString("N/A");
}
@ -175,10 +179,8 @@ int main()
window.close();
break;
}
else if ((event.type == sf::Event::JoystickButtonPressed) ||
(event.type == sf::Event::JoystickButtonReleased) ||
(event.type == sf::Event::JoystickMoved) ||
(event.type == sf::Event::JoystickConnected))
else if ((event.type == sf::Event::JoystickButtonPressed) || (event.type == sf::Event::JoystickButtonReleased) ||
(event.type == sf::Event::JoystickMoved) || (event.type == sf::Event::JoystickConnected))
{
// Update displayed joystick values
updateValues(event.joystickConnect.joystickId);

View File

@ -3,9 +3,10 @@
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Graphics.hpp>
#include <array>
#include <iostream>
#include <cstdlib>
#include <iostream>
#define GLAD_GL_IMPLEMENTATION
#include <gl.h>
@ -79,7 +80,7 @@ int main()
// Attempt to generate a mipmap for our cube texture
// We don't check the return value here since
// mipmapping is purely optional in this example
(void) texture.generateMipmap();
(void)texture.generateMipmap();
// Make the window the active window for OpenGL calls
if (!window.setActive(true))
@ -295,11 +296,11 @@ int main()
// We get the position of the mouse cursor (or touch), so that we can move the box accordingly
sf::Vector2i pos;
#ifdef SFML_SYSTEM_IOS
#ifdef SFML_SYSTEM_IOS
pos = sf::Touch::getPosition(0);
#else
#else
pos = sf::Mouse::getPosition(window);
#endif
#endif
float x = static_cast<float>(pos.x) * 200.f / static_cast<float>(window.getSize().x) - 100.f;
float y = -static_cast<float>(pos.y) * 200.f / static_cast<float>(window.getSize().y) + 100.f;

View File

@ -5,6 +5,7 @@
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Graphics.hpp>
#include <cassert>
#include <string>
@ -15,7 +16,6 @@
class Effect : public sf::Drawable
{
public:
~Effect() override
{
}
@ -57,10 +57,7 @@ public:
}
protected:
Effect(const std::string& name) :
m_name(name),
m_isLoaded(false)
Effect(const std::string& name) : m_name(name), m_isLoaded(false)
{
}
@ -71,14 +68,12 @@ protected:
}
private:
// Virtual functions to be implemented in derived effects
virtual bool onLoad() = 0;
virtual void onUpdate(float time, float x, float y) = 0;
virtual void onDraw(sf::RenderTarget& target, const sf::RenderStates& states) const = 0;
private:
std::string m_name;
bool m_isLoaded;

View File

@ -2,16 +2,17 @@
////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include "Effect.hpp"
#include <array>
#include <random>
#include "Effect.hpp"
namespace
{
std::random_device rd;
std::mt19937 rng(rd());
}
std::random_device rd;
std::mt19937 rng(rd());
} // namespace
const sf::Font* Effect::s_font = nullptr;
@ -21,9 +22,7 @@ const sf::Font* Effect::s_font = nullptr;
class Pixelate : public Effect
{
public:
Pixelate() :
Effect("Pixelate")
Pixelate() : Effect("Pixelate")
{
}
@ -55,7 +54,6 @@ public:
}
private:
sf::Texture m_texture;
sf::Sprite m_sprite;
sf::Shader m_shader;
@ -68,16 +66,15 @@ private:
class WaveBlur : public Effect
{
public:
WaveBlur() :
Effect("Wave + Blur")
WaveBlur() : Effect("Wave + Blur")
{
}
bool onLoad() override
{
// Create the text
m_text.setString("Praesent suscipit augue in velit pulvinar hendrerit varius purus aliquam.\n"
m_text.setString(
"Praesent suscipit augue in velit pulvinar hendrerit varius purus aliquam.\n"
"Mauris mi odio, bibendum quis fringilla a, laoreet vel orci. Proin vitae vulputate tortor.\n"
"Praesent cursus ultrices justo, ut feugiat ante vehicula quis.\n"
"Donec fringilla scelerisque mauris et viverra.\n"
@ -121,7 +118,6 @@ public:
}
private:
sf::Text m_text;
sf::Shader m_shader;
};
@ -133,9 +129,7 @@ private:
class StormBlink : public Effect
{
public:
StormBlink() :
Effect("Storm + Blink")
StormBlink() : Effect("Storm + Blink")
{
}
@ -181,7 +175,6 @@ public:
}
private:
sf::VertexArray m_points;
sf::Shader m_shader;
};
@ -193,9 +186,7 @@ private:
class Edge : public Effect
{
public:
Edge() :
Effect("Edge Post-effect")
Edge() : Effect("Edge Post-effect")
{
}
@ -241,8 +232,10 @@ public:
for (std::size_t i = 0; i < m_entities.size(); ++i)
{
sf::Vector2f position;
position.x = std::cos(0.25f * (time * static_cast<float>(i) + static_cast<float>(m_entities.size() - i))) * 300 + 350;
position.y = std::sin(0.25f * (time * static_cast<float>(m_entities.size() - i) + static_cast<float>(i))) * 200 + 250;
position.x = std::cos(0.25f * (time * static_cast<float>(i) + static_cast<float>(m_entities.size() - i))) * 300 +
350;
position.y = std::sin(0.25f * (time * static_cast<float>(m_entities.size() - i) + static_cast<float>(i))) * 200 +
250;
m_entities[i].setPosition(position);
}
@ -262,7 +255,6 @@ public:
}
private:
sf::RenderTexture m_surface;
sf::Texture m_backgroundTexture;
sf::Texture m_entityTexture;
@ -278,10 +270,7 @@ private:
class Geometry : public Effect
{
public:
Geometry() :
Effect("Geometry Shader Billboards"),
m_pointCloud(sf::Points, 10000)
Geometry() : Effect("Geometry Shader Billboards"), m_pointCloud(sf::Points, 10000)
{
}
@ -345,7 +334,6 @@ public:
}
private:
sf::Texture m_logoTexture;
sf::Transform m_transform;
sf::Shader m_shader;
@ -362,8 +350,7 @@ private:
int main()
{
// Create the main window
sf::RenderWindow window(sf::VideoMode({800, 600}), "SFML Shader",
sf::Style::Titlebar | sf::Style::Close);
sf::RenderWindow window(sf::VideoMode({800, 600}), "SFML Shader", sf::Style::Titlebar | sf::Style::Close);
window.setVerticalSyncEnabled(true);
// Load the application font and pass it to the Effect class
@ -379,13 +366,7 @@ int main()
Edge edgeEffect;
Geometry geometryEffect;
const std::array<Effect*, 5> effects{
&pixelateEffect,
&waveBlurEffect,
&stormBlinkEffect,
&edgeEffect,
&geometryEffect
};
const std::array<Effect*, 5> effects{&pixelateEffect, &waveBlurEffect, &stormBlinkEffect, &edgeEffect, &geometryEffect};
std::size_t current = 0;
@ -461,9 +442,12 @@ int main()
effects[current]->update(clock.getElapsedTime().asSeconds(), x, y);
// Clear the window
if(effects[current]->getName() == "Edge Post-effect"){
if (effects[current]->getName() == "Edge Post-effect")
{
window.clear(sf::Color::White);
} else {
}
else
{
window.clear(sf::Color(50, 50, 50));
}

View File

@ -2,8 +2,8 @@
////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include <iostream>
#include <cstdlib>
#include <iostream>
void runTcpServer(unsigned short port);

View File

@ -3,6 +3,7 @@
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Network.hpp>
#include <iomanip>
#include <iostream>
@ -56,8 +57,7 @@ void runTcpClient(unsigned short port)
{
std::cout << "Type the address or name of the server to connect to: ";
std::cin >> server;
}
while (!server.has_value());
} while (!server.has_value());
// Create a socket for communicating with the server
sf::TcpSocket socket;

View File

@ -3,6 +3,7 @@
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Network.hpp>
#include <iomanip>
#include <iostream>
#include <optional>
@ -51,8 +52,7 @@ void runUdpClient(unsigned short port)
{
std::cout << "Type the address or name of the server to connect to: ";
std::cin >> server;
}
while (!server.has_value());
} while (!server.has_value());
// Create a socket for communicating with the server
sf::UdpSocket socket;

View File

@ -3,6 +3,7 @@
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Audio.hpp>
#include <iostream>
#include <string>

View File

@ -3,8 +3,9 @@
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Audio.hpp>
#include <iostream>
#include <cstdlib>
#include <iostream>
////////////////////////////////////////////////////////////

View File

@ -2,8 +2,9 @@
////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Graphics.hpp>
#include <SFML/Audio.hpp>
#include <SFML/Graphics.hpp>
#include <random>
#ifdef SFML_SYSTEM_IOS
@ -37,7 +38,8 @@ int main()
float ballRadius = 10.f;
// Create the window of the application
sf::RenderWindow window(sf::VideoMode({static_cast<unsigned int>(gameWidth), static_cast<unsigned int>(gameHeight)}, 32), "SFML Tennis",
sf::RenderWindow window(sf::VideoMode({static_cast<unsigned int>(gameWidth), static_cast<unsigned int>(gameHeight)}, 32),
"SFML Tennis",
sf::Style::Titlebar | sf::Style::Close);
window.setVerticalSyncEnabled(true);
@ -49,7 +51,7 @@ int main()
// Create the SFML logo texture:
sf::Texture sfmlLogoTexture;
if(!sfmlLogoTexture.loadFromFile(resourcesDir() / "sfml_logo.png"))
if (!sfmlLogoTexture.loadFromFile(resourcesDir() / "sfml_logo.png"))
return EXIT_FAILURE;
sf::Sprite sfmlLogo;
sfmlLogo.setTexture(sfmlLogoTexture);
@ -91,11 +93,11 @@ int main()
pauseMessage.setPosition({170.f, 200.f});
pauseMessage.setFillColor(sf::Color::White);
#ifdef SFML_SYSTEM_IOS
#ifdef SFML_SYSTEM_IOS
pauseMessage.setString("Welcome to SFML Tennis!\nTouch the screen to start the game.");
#else
#else
pauseMessage.setString("Welcome to SFML Tennis!\n\nPress space to start the game.");
#endif
#endif
// Define the paddles properties
sf::Clock AITimer;
@ -140,8 +142,7 @@ int main()
{
// Make sure the ball initial angle is not too much vertical
ballAngle = sf::degrees(std::uniform_real_distribution<float>(0, 360)(rng));
}
while (std::abs(std::cos(ballAngle.asRadians())) < 0.7f);
} while (std::abs(std::cos(ballAngle.asRadians())) < 0.7f);
}
}
@ -160,8 +161,7 @@ int main()
float deltaTime = clock.restart().asSeconds();
// Move the player's paddle
if (sf::Keyboard::isKeyPressed(sf::Keyboard::Up) &&
(leftPaddle.getPosition().y - paddleSize.y / 2 > 5.f))
if (sf::Keyboard::isKeyPressed(sf::Keyboard::Up) && (leftPaddle.getPosition().y - paddleSize.y / 2 > 5.f))
{
leftPaddle.move({0.f, -paddleSpeed * deltaTime});
}
@ -200,11 +200,11 @@ int main()
// Move the ball
ball.move({ballSpeed * deltaTime, ballAngle});
#ifdef SFML_SYSTEM_IOS
#ifdef SFML_SYSTEM_IOS
const std::string inputString = "Touch the screen to restart.";
#else
#else
const std::string inputString = "Press space to restart or\nescape to exit.";
#endif
#endif
// Check collisions between the ball and the screen
if (ball.getPosition().x - ballRadius < 0.f)

View File

@ -4,6 +4,7 @@
////////////////////////////////////////////////////////////
#include <SFML/Audio.hpp>
#include <SFML/Network.hpp>
#include <iostream>
@ -18,7 +19,6 @@ const sf::Uint8 clientEndOfStream = 2;
class NetworkRecorder : public sf::SoundRecorder
{
public:
////////////////////////////////////////////////////////////
/// Constructor
///
@ -26,9 +26,7 @@ public:
/// \param port Port of the remote host
///
////////////////////////////////////////////////////////////
NetworkRecorder(const sf::IpAddress& host, unsigned short port) :
m_host(host),
m_port(port)
NetworkRecorder(const sf::IpAddress& host, unsigned short port) : m_host(host), m_port(port)
{
}
@ -45,7 +43,6 @@ public:
}
private:
////////////////////////////////////////////////////////////
/// \see SoundRecorder::onStart
///
@ -126,8 +123,7 @@ void doClient(unsigned short port)
{
std::cout << "Type address or name of the server to connect to: ";
std::cin >> server;
}
while (!server.has_value());
} while (!server.has_value());
// Create an instance of our custom recorder
NetworkRecorder recorder(server.value(), port);

View File

@ -4,6 +4,7 @@
////////////////////////////////////////////////////////////
#include <SFML/Audio.hpp>
#include <SFML/Network.hpp>
#include <cstring>
#include <iostream>
#include <iterator>
@ -21,14 +22,11 @@ const sf::Uint8 serverEndOfStream = 2;
class NetworkAudioStream : public sf::SoundStream
{
public:
////////////////////////////////////////////////////////////
/// Default constructor
///
////////////////////////////////////////////////////////////
NetworkAudioStream() :
m_offset (0),
m_hasFinished(false)
NetworkAudioStream() : m_offset(0), m_hasFinished(false)
{
// Set the sound parameters
initialize(1, 44100);
@ -66,7 +64,6 @@ public:
}
private:
////////////////////////////////////////////////////////////
/// /see SoundStream::OnGetData
///
@ -85,7 +82,8 @@ private:
// (don't forget that we run in two separate threads)
{
std::scoped_lock lock(m_mutex);
m_tempBuffer.assign(m_samples.begin() + static_cast<std::vector<sf::Int64>::difference_type>(m_offset), m_samples.end());
m_tempBuffer.assign(m_samples.begin() + static_cast<std::vector<sf::Int64>::difference_type>(m_offset),
m_samples.end());
}
// Fill audio data to pass to the stream
@ -135,7 +133,9 @@ private:
std::scoped_lock lock(m_mutex);
std::size_t oldSize = m_samples.size();
m_samples.resize(oldSize + sampleCount);
std::memcpy(&(m_samples[oldSize]), static_cast<const char*>(packet.getData()) + 1, sampleCount * sizeof(sf::Int16));
std::memcpy(&(m_samples[oldSize]),
static_cast<const char*>(packet.getData()) + 1,
sampleCount * sizeof(sf::Int16));
}
}
else if (id == serverEndOfStream)

View File

@ -2,8 +2,8 @@
////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include <iostream>
#include <cstdlib>
#include <iostream>
////////////////////////////////////////////////////////////

View File

@ -7,14 +7,14 @@
// Include graphics because we use sf::Image for loading images
#include <SFML/Graphics.hpp>
#include <SFML/Window.hpp>
#include <array>
#include <cmath>
#include <cstring>
#include <iostream>
#include <limits>
#include <vector>
#include <cmath>
#include <cstring>
////////////////////////////////////////////////////////////
@ -22,26 +22,27 @@
////////////////////////////////////////////////////////////
namespace
{
using Vec3 = float[3];
using Matrix = float[4][4];
using Vec3 = float[3];
using Matrix = float[4][4];
// Multiply 2 matrices
void matrixMultiply(Matrix& result, const Matrix& left, const Matrix& right)
{
// Multiply 2 matrices
void matrixMultiply(Matrix& result, const Matrix& left, const Matrix& right)
{
Matrix temp;
for (int i = 0; i < 4; ++i)
{
for (int j = 0; j < 4; ++j)
temp[i][j] = left[0][j] * right[i][0] + left[1][j] * right[i][1] + left[2][j] * right[i][2] + left[3][j] * right[i][3];
temp[i][j] = left[0][j] * right[i][0] + left[1][j] * right[i][1] + left[2][j] * right[i][2] +
left[3][j] * right[i][3];
}
std::memcpy(result, temp, sizeof(Matrix));
}
}
// Rotate a matrix around the x-axis
void matrixRotateX(Matrix& result, sf::Angle angle)
{
// Rotate a matrix around the x-axis
void matrixRotateX(Matrix& result, sf::Angle angle)
{
float rad = angle.asRadians();
// clang-format off
@ -54,11 +55,11 @@ namespace
// clang-format on
matrixMultiply(result, result, matrix);
}
}
// Rotate a matrix around the y-axis
void matrixRotateY(Matrix& result, sf::Angle angle)
{
// Rotate a matrix around the y-axis
void matrixRotateY(Matrix& result, sf::Angle angle)
{
float rad = angle.asRadians();
// clang-format off
@ -71,11 +72,11 @@ namespace
// clang-format on
matrixMultiply(result, result, matrix);
}
}
// Rotate a matrix around the z-axis
void matrixRotateZ(Matrix& result, sf::Angle angle)
{
// Rotate a matrix around the z-axis
void matrixRotateZ(Matrix& result, sf::Angle angle)
{
float rad = angle.asRadians();
// clang-format off
@ -88,11 +89,11 @@ namespace
// clang-format on
matrixMultiply(result, result, matrix);
}
}
// Construct a lookat view matrix
void matrixLookAt(Matrix& result, const Vec3& eye, const Vec3& center, const Vec3& up)
{
// Construct a lookat view matrix
void matrixLookAt(Matrix& result, const Vec3& eye, const Vec3& center, const Vec3& up)
{
// Forward-looking vector
// clang-format off
Vec3 forward = {
@ -105,7 +106,7 @@ namespace
// Normalize
float factor = 1.0f / std::sqrt(forward[0] * forward[0] + forward[1] * forward[1] + forward[2] * forward[2]);
for(float& f : forward)
for (float& f : forward)
f *= factor;
// Side vector (Forward cross product Up)
@ -120,7 +121,7 @@ namespace
// Normalize
factor = 1.0f / std::sqrt(side[0] * side[0] + side[1] * side[1] + side[2] * side[2]);
for(float& f : side)
for (float& f : side)
f *= factor;
result[0][0] = side[0];
@ -142,11 +143,11 @@ namespace
result[3][1] = (-eye[0]) * result[0][1] + (-eye[1]) * result[1][1] + (-eye[2]) * result[2][1];
result[3][2] = (-eye[0]) * result[0][2] + (-eye[1]) * result[1][2] + (-eye[2]) * result[2][2];
result[3][3] = (-eye[0]) * result[0][3] + (-eye[1]) * result[1][3] + (-eye[2]) * result[2][3] + 1.0f;
}
}
// Construct a perspective projection matrix
void matrixPerspective(Matrix& result, sf::Angle fov, float aspect, float nearPlane, float farPlane)
{
// Construct a perspective projection matrix
void matrixPerspective(Matrix& result, sf::Angle fov, float aspect, float nearPlane, float farPlane)
{
const float a = 1.f / std::tan(fov.asRadians() / 2.f);
result[0][0] = a / aspect;
@ -168,29 +169,30 @@ namespace
result[3][1] = 0.f;
result[3][2] = -((2.f * farPlane * nearPlane) / (farPlane - nearPlane));
result[3][3] = 0.f;
}
}
// Clamp a value between low and high values
template<typename T>
T clamp(T value, T low, T high)
{
// Clamp a value between low and high values
template <typename T>
T clamp(T value, T low, T high)
{
return (value <= low) ? low : ((value >= high) ? high : value);
}
}
// Helper function we pass to GLAD to load Vulkan functions via SFML
GLADapiproc getVulkanFunction(const char* name)
{
// Helper function we pass to GLAD to load Vulkan functions via SFML
GLADapiproc getVulkanFunction(const char* name)
{
return sf::Vulkan::getFunction(name);
}
}
// Debug we pass to Vulkan to call when it detects warnings or errors
VKAPI_ATTR VkBool32 VKAPI_CALL debugCallback(VkDebugReportFlagsEXT, VkDebugReportObjectTypeEXT, uint64_t, size_t, int32_t, const char*, const char* pMessage, void*)
{
// Debug we pass to Vulkan to call when it detects warnings or errors
VKAPI_ATTR VkBool32 VKAPI_CALL
debugCallback(VkDebugReportFlagsEXT, VkDebugReportObjectTypeEXT, uint64_t, size_t, int32_t, const char*, const char* pMessage, void*)
{
std::cerr << pMessage << std::endl;
return VK_FALSE;
}
}
} // namespace
////////////////////////////////////////////////////////////
@ -238,34 +240,62 @@ public:
descriptorPool(0)
{
// Vulkan setup procedure
if (vulkanAvailable) setupInstance();
if (vulkanAvailable) setupDebugReportCallback();
if (vulkanAvailable) setupSurface();
if (vulkanAvailable) setupPhysicalDevice();
if (vulkanAvailable) setupLogicalDevice();
if (vulkanAvailable) setupSwapchain();
if (vulkanAvailable) setupSwapchainImages();
if (vulkanAvailable) setupShaders();
if (vulkanAvailable) setupRenderpass();
if (vulkanAvailable) setupDescriptorSetLayout();
if (vulkanAvailable) setupPipelineLayout();
if (vulkanAvailable) setupPipeline();
if (vulkanAvailable) setupCommandPool();
if (vulkanAvailable) setupVertexBuffer();
if (vulkanAvailable) setupIndexBuffer();
if (vulkanAvailable) setupUniformBuffers();
if (vulkanAvailable) setupDepthImage();
if (vulkanAvailable) setupDepthImageView();
if (vulkanAvailable) setupTextureImage();
if (vulkanAvailable) setupTextureImageView();
if (vulkanAvailable) setupTextureSampler();
if (vulkanAvailable) setupFramebuffers();
if (vulkanAvailable) setupDescriptorPool();
if (vulkanAvailable) setupDescriptorSets();
if (vulkanAvailable) setupCommandBuffers();
if (vulkanAvailable) setupDraw();
if (vulkanAvailable) setupSemaphores();
if (vulkanAvailable) setupFences();
if (vulkanAvailable)
setupInstance();
if (vulkanAvailable)
setupDebugReportCallback();
if (vulkanAvailable)
setupSurface();
if (vulkanAvailable)
setupPhysicalDevice();
if (vulkanAvailable)
setupLogicalDevice();
if (vulkanAvailable)
setupSwapchain();
if (vulkanAvailable)
setupSwapchainImages();
if (vulkanAvailable)
setupShaders();
if (vulkanAvailable)
setupRenderpass();
if (vulkanAvailable)
setupDescriptorSetLayout();
if (vulkanAvailable)
setupPipelineLayout();
if (vulkanAvailable)
setupPipeline();
if (vulkanAvailable)
setupCommandPool();
if (vulkanAvailable)
setupVertexBuffer();
if (vulkanAvailable)
setupIndexBuffer();
if (vulkanAvailable)
setupUniformBuffers();
if (vulkanAvailable)
setupDepthImage();
if (vulkanAvailable)
setupDepthImageView();
if (vulkanAvailable)
setupTextureImage();
if (vulkanAvailable)
setupTextureImageView();
if (vulkanAvailable)
setupTextureSampler();
if (vulkanAvailable)
setupFramebuffers();
if (vulkanAvailable)
setupDescriptorPool();
if (vulkanAvailable)
setupDescriptorSets();
if (vulkanAvailable)
setupCommandBuffers();
if (vulkanAvailable)
setupDraw();
if (vulkanAvailable)
setupSemaphores();
if (vulkanAvailable)
setupFences();
// If something went wrong, notify the user by setting the window title
if (!vulkanAvailable)
@ -405,16 +435,26 @@ public:
cleanupSwapchain();
// Swapchain setup procedure
if (vulkanAvailable) setupSwapchain();
if (vulkanAvailable) setupSwapchainImages();
if (vulkanAvailable) setupPipelineLayout();
if (vulkanAvailable) setupRenderpass();
if (vulkanAvailable) setupPipeline();
if (vulkanAvailable) setupDepthImage();
if (vulkanAvailable) setupDepthImageView();
if (vulkanAvailable) setupFramebuffers();
if (vulkanAvailable) setupCommandBuffers();
if (vulkanAvailable) setupDraw();
if (vulkanAvailable)
setupSwapchain();
if (vulkanAvailable)
setupSwapchainImages();
if (vulkanAvailable)
setupPipelineLayout();
if (vulkanAvailable)
setupRenderpass();
if (vulkanAvailable)
setupPipeline();
if (vulkanAvailable)
setupDepthImage();
if (vulkanAvailable)
setupDepthImageView();
if (vulkanAvailable)
setupFramebuffers();
if (vulkanAvailable)
setupCommandBuffers();
if (vulkanAvailable)
setupDraw();
}
// Setup Vulkan instance
@ -530,7 +570,8 @@ public:
// Register for warnings and errors
VkDebugReportCallbackCreateInfoEXT debugReportCallbackCreateInfo = VkDebugReportCallbackCreateInfoEXT();
debugReportCallbackCreateInfo.sType = VK_STRUCTURE_TYPE_DEBUG_REPORT_CALLBACK_CREATE_INFO_EXT;
debugReportCallbackCreateInfo.flags = VK_DEBUG_REPORT_WARNING_BIT_EXT | VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT | VK_DEBUG_REPORT_ERROR_BIT_EXT;
debugReportCallbackCreateInfo.flags = VK_DEBUG_REPORT_WARNING_BIT_EXT |
VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT | VK_DEBUG_REPORT_ERROR_BIT_EXT;
debugReportCallbackCreateInfo.pfnCallback = debugCallback;
// Create the debug callback
@ -639,21 +680,24 @@ public:
vkGetPhysicalDeviceFormatProperties(gpu, VK_FORMAT_D24_UNORM_S8_UINT, &formatProperties);
if (formatProperties.optimalTilingFeatures & VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT) {
if (formatProperties.optimalTilingFeatures & VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT)
{
depthFormat = VK_FORMAT_D24_UNORM_S8_UINT;
}
else
{
vkGetPhysicalDeviceFormatProperties(gpu, VK_FORMAT_D32_SFLOAT_S8_UINT, &formatProperties);
if (formatProperties.optimalTilingFeatures & VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT) {
if (formatProperties.optimalTilingFeatures & VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT)
{
depthFormat = VK_FORMAT_D32_SFLOAT_S8_UINT;
}
else
{
vkGetPhysicalDeviceFormatProperties(gpu, VK_FORMAT_D32_SFLOAT, &formatProperties);
if (formatProperties.optimalTilingFeatures & VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT) {
if (formatProperties.optimalTilingFeatures & VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT)
{
depthFormat = VK_FORMAT_D32_SFLOAT;
}
else
@ -707,7 +751,7 @@ public:
deviceQueueCreateInfo.pQueuePriorities = &queuePriority;
// Enable the swapchain extension
const char* extentions[1] = { VK_KHR_SWAPCHAIN_EXTENSION_NAME };
const char* extentions[1] = {VK_KHR_SWAPCHAIN_EXTENSION_NAME};
// Enable anisotropic filtering
VkPhysicalDeviceFeatures physicalDeviceFeatures = VkPhysicalDeviceFeatures();
@ -763,7 +807,8 @@ public:
{
for (VkSurfaceFormatKHR& surfaceFormat : surfaceFormats)
{
if ((surfaceFormat.format == VK_FORMAT_B8G8R8A8_UNORM) && (surfaceFormat.colorSpace == VK_COLOR_SPACE_SRGB_NONLINEAR_KHR))
if ((surfaceFormat.format == VK_FORMAT_B8G8R8A8_UNORM) &&
(surfaceFormat.colorSpace == VK_COLOR_SPACE_SRGB_NONLINEAR_KHR))
{
swapchainFormat.format = VK_FORMAT_B8G8R8A8_UNORM;
swapchainFormat.colorSpace = VK_COLOR_SPACE_SRGB_NONLINEAR_KHR;
@ -819,8 +864,12 @@ public:
return;
}
swapchainExtent.width = clamp<uint32_t>(window.getSize().x, surfaceCapabilities.minImageExtent.width, surfaceCapabilities.maxImageExtent.width);
swapchainExtent.height = clamp<uint32_t>(window.getSize().y, surfaceCapabilities.minImageExtent.height, surfaceCapabilities.maxImageExtent.height);
swapchainExtent.width = clamp<uint32_t>(window.getSize().x,
surfaceCapabilities.minImageExtent.width,
surfaceCapabilities.maxImageExtent.width);
swapchainExtent.height = clamp<uint32_t>(window.getSize().y,
surfaceCapabilities.minImageExtent.height,
surfaceCapabilities.maxImageExtent.height);
auto imageCount = clamp<uint32_t>(2, surfaceCapabilities.minImageCount, surfaceCapabilities.maxImageCount);
@ -959,13 +1008,13 @@ public:
}
// Prepare the shader stage information for later pipeline creation
shaderStages[0]= VkPipelineShaderStageCreateInfo();
shaderStages[0] = VkPipelineShaderStageCreateInfo();
shaderStages[0].sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO;
shaderStages[0].stage = VK_SHADER_STAGE_VERTEX_BIT;
shaderStages[0].module = vertexShaderModule;
shaderStages[0].pName = "main";
shaderStages[1]= VkPipelineShaderStageCreateInfo();
shaderStages[1] = VkPipelineShaderStageCreateInfo();
shaderStages[1].sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO;
shaderStages[1].stage = VK_SHADER_STAGE_FRAGMENT_BIT;
shaderStages[1].module = fragmentShaderModule;
@ -1190,7 +1239,8 @@ public:
pipelineColorBlendAttachmentState.srcAlphaBlendFactor = VK_BLEND_FACTOR_ONE;
pipelineColorBlendAttachmentState.dstAlphaBlendFactor = VK_BLEND_FACTOR_ONE_MINUS_SRC_ALPHA;
pipelineColorBlendAttachmentState.alphaBlendOp = VK_BLEND_OP_ADD;
pipelineColorBlendAttachmentState.colorWriteMask = VK_COLOR_COMPONENT_R_BIT | VK_COLOR_COMPONENT_G_BIT | VK_COLOR_COMPONENT_B_BIT | VK_COLOR_COMPONENT_A_BIT;
pipelineColorBlendAttachmentState.colorWriteMask = VK_COLOR_COMPONENT_R_BIT | VK_COLOR_COMPONENT_G_BIT |
VK_COLOR_COMPONENT_B_BIT | VK_COLOR_COMPONENT_A_BIT;
VkPipelineColorBlendStateCreateInfo pipelineColorBlendStateCreateInfo = VkPipelineColorBlendStateCreateInfo();
pipelineColorBlendStateCreateInfo.sType = VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO;
@ -1214,7 +1264,8 @@ public:
graphicsPipelineCreateInfo.subpass = 0;
// Create our graphics pipeline
if (vkCreateGraphicsPipelines(device, VK_NULL_HANDLE, 1, &graphicsPipelineCreateInfo, 0, &graphicsPipeline) != VK_SUCCESS)
if (vkCreateGraphicsPipelines(device, VK_NULL_HANDLE, 1, &graphicsPipelineCreateInfo, 0, &graphicsPipeline) !=
VK_SUCCESS)
{
vulkanAvailable = false;
return;
@ -1268,7 +1319,11 @@ public:
}
// Helper to create a generic buffer with the specified size, usage and memory flags
bool createBuffer(VkDeviceSize size, VkBufferUsageFlags usage, VkMemoryPropertyFlags properties, VkBuffer& buffer, VkDeviceMemory& memory)
bool createBuffer(VkDeviceSize size,
VkBufferUsageFlags usage,
VkMemoryPropertyFlags properties,
VkBuffer& buffer,
VkDeviceMemory& memory)
{
// We only have a single queue so we can request exclusive access
VkBufferCreateInfo bufferCreateInfo = VkBufferCreateInfo();
@ -1423,13 +1478,11 @@ public:
VkBuffer stagingBuffer = 0;
VkDeviceMemory stagingBufferMemory = 0;
if (!createBuffer(
sizeof(vertexData),
if (!createBuffer(sizeof(vertexData),
VK_BUFFER_USAGE_TRANSFER_SRC_BIT,
VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT,
stagingBuffer,
stagingBufferMemory
))
stagingBufferMemory))
{
vulkanAvailable = false;
return;
@ -1454,13 +1507,11 @@ public:
vkUnmapMemory(device, stagingBufferMemory);
// Create the GPU local vertex buffer
if (!createBuffer(
sizeof(vertexData),
if (!createBuffer(sizeof(vertexData),
VK_BUFFER_USAGE_TRANSFER_DST_BIT | VK_BUFFER_USAGE_VERTEX_BUFFER_BIT,
VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT,
vertexBuffer,
vertexBufferMemory
))
vertexBufferMemory))
{
vkFreeMemory(device, stagingBufferMemory, 0);
vkDestroyBuffer(device, stagingBuffer, 0);
@ -1506,13 +1557,11 @@ public:
VkBuffer stagingBuffer = 0;
VkDeviceMemory stagingBufferMemory = 0;
if (!createBuffer(
sizeof(indexData),
if (!createBuffer(sizeof(indexData),
VK_BUFFER_USAGE_TRANSFER_SRC_BIT,
VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT,
stagingBuffer,
stagingBufferMemory
))
stagingBufferMemory))
{
vulkanAvailable = false;
return;
@ -1537,13 +1586,11 @@ public:
vkUnmapMemory(device, stagingBufferMemory);
// Create the GPU local index buffer
if (!createBuffer(
sizeof(indexData),
if (!createBuffer(sizeof(indexData),
VK_BUFFER_USAGE_TRANSFER_DST_BIT | VK_BUFFER_USAGE_INDEX_BUFFER_BIT,
VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT,
indexBuffer,
indexBufferMemory
))
indexBufferMemory))
{
vkFreeMemory(device, stagingBufferMemory, 0);
vkDestroyBuffer(device, stagingBuffer, 0);
@ -1570,13 +1617,11 @@ public:
uniformBuffersMemory.push_back(0);
// The uniform buffer will be host visible and coherent since we use it for streaming data every frame
if (!createBuffer(
sizeof(Matrix) * 3,
if (!createBuffer(sizeof(Matrix) * 3,
VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT,
VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT,
uniformBuffers[i],
uniformBuffersMemory[i]
))
uniformBuffersMemory[i]))
{
vulkanAvailable = false;
return;
@ -1585,7 +1630,14 @@ public:
}
// Helper to create a generic image with the specified size, format, usage and memory flags
bool createImage(uint32_t width, uint32_t height, VkFormat format, VkImageTiling tiling, VkImageUsageFlags usage, VkMemoryPropertyFlags properties, VkImage& image, VkDeviceMemory& imageMemory)
bool createImage(uint32_t width,
uint32_t height,
VkFormat format,
VkImageTiling tiling,
VkImageUsageFlags usage,
VkMemoryPropertyFlags properties,
VkImage& image,
VkDeviceMemory& imageMemory)
{
// We only have a single queue so we can request exclusive access
VkImageCreateInfo imageCreateInfo = VkImageCreateInfo();
@ -1647,16 +1699,14 @@ public:
void setupDepthImage()
{
// Create our depth image
if (!createImage(
swapchainExtent.width,
if (!createImage(swapchainExtent.width,
swapchainExtent.height,
depthFormat,
VK_IMAGE_TILING_OPTIMAL,
VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT,
VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT,
depthImage,
depthImageMemory
))
depthImageMemory))
{
vulkanAvailable = false;
return;
@ -1703,7 +1753,8 @@ public:
barrier.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED;
barrier.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED;
barrier.image = depthImage;
barrier.subresourceRange.aspectMask = VK_IMAGE_ASPECT_DEPTH_BIT | ((depthFormat == VK_FORMAT_D32_SFLOAT) ? 0 : VK_IMAGE_ASPECT_STENCIL_BIT);
barrier.subresourceRange.aspectMask = VK_IMAGE_ASPECT_DEPTH_BIT |
((depthFormat == VK_FORMAT_D32_SFLOAT) ? 0 : VK_IMAGE_ASPECT_STENCIL_BIT);
barrier.subresourceRange.baseMipLevel = 0;
barrier.subresourceRange.levelCount = 1;
barrier.subresourceRange.baseArrayLayer = 0;
@ -1711,7 +1762,16 @@ public:
barrier.srcAccessMask = 0;
barrier.dstAccessMask = VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_READ_BIT | VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT;
vkCmdPipelineBarrier(commandBuffer, VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT, 0, 0, 0, 0, 0, 1, &barrier);
vkCmdPipelineBarrier(commandBuffer,
VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT,
VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT,
0,
0,
0,
0,
0,
1,
&barrier);
// End and submit the command buffer
if (vkEndCommandBuffer(commandBuffer) != VK_SUCCESS)
@ -1751,7 +1811,9 @@ public:
imageViewCreateInfo.image = depthImage;
imageViewCreateInfo.viewType = VK_IMAGE_VIEW_TYPE_2D;
imageViewCreateInfo.format = depthFormat;
imageViewCreateInfo.subresourceRange.aspectMask = VK_IMAGE_ASPECT_DEPTH_BIT | ((depthFormat == VK_FORMAT_D32_SFLOAT) ? 0 : VK_IMAGE_ASPECT_STENCIL_BIT);
imageViewCreateInfo.subresourceRange
.aspectMask = VK_IMAGE_ASPECT_DEPTH_BIT |
((depthFormat == VK_FORMAT_D32_SFLOAT) ? 0 : VK_IMAGE_ASPECT_STENCIL_BIT);
imageViewCreateInfo.subresourceRange.baseMipLevel = 0;
imageViewCreateInfo.subresourceRange.levelCount = 1;
imageViewCreateInfo.subresourceRange.baseArrayLayer = 0;
@ -1782,7 +1844,11 @@ public:
VkBuffer stagingBuffer;
VkDeviceMemory stagingBufferMemory;
createBuffer(imageSize, VK_BUFFER_USAGE_TRANSFER_SRC_BIT, VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT, stagingBuffer, stagingBufferMemory);
createBuffer(imageSize,
VK_BUFFER_USAGE_TRANSFER_SRC_BIT,
VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT,
stagingBuffer,
stagingBufferMemory);
void* ptr;
@ -1803,16 +1869,14 @@ public:
vkUnmapMemory(device, stagingBufferMemory);
// Create a GPU local image
if (!createImage(
imageData.getSize().x,
if (!createImage(imageData.getSize().x,
imageData.getSize().y,
VK_FORMAT_R8G8B8A8_UNORM,
VK_IMAGE_TILING_OPTIMAL,
VK_IMAGE_USAGE_TRANSFER_DST_BIT | VK_IMAGE_USAGE_SAMPLED_BIT,
VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT,
textureImage,
textureImageMemory
))
textureImageMemory))
{
vkFreeMemory(device, stagingBufferMemory, 0);
vkDestroyBuffer(device, stagingBuffer, 0);
@ -1995,7 +2059,16 @@ public:
barrier.srcAccessMask = VK_ACCESS_TRANSFER_WRITE_BIT;
barrier.dstAccessMask = VK_ACCESS_SHADER_READ_BIT;
vkCmdPipelineBarrier(commandBuffer, VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT, 0, 0, 0, 0, 0, 1, &barrier);
vkCmdPipelineBarrier(commandBuffer,
VK_PIPELINE_STAGE_TRANSFER_BIT,
VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT,
0,
0,
0,
0,
0,
1,
&barrier);
// End and submit the command buffer
if (vkEndCommandBuffer(commandBuffer) != VK_SUCCESS)
@ -2262,7 +2335,14 @@ public:
vkCmdBindIndexBuffer(commandBuffers[i], indexBuffer, 0, VK_INDEX_TYPE_UINT16);
// Bind our descriptor sets
vkCmdBindDescriptorSets(commandBuffers[i], VK_PIPELINE_BIND_POINT_GRAPHICS, pipelineLayout, 0, 1, &descriptorSets[i], 0, 0);
vkCmdBindDescriptorSets(commandBuffers[i],
VK_PIPELINE_BIND_POINT_GRAPHICS,
pipelineLayout,
0,
1,
&descriptorSets[i],
0,
0);
// Draw our primitives
vkCmdDrawIndexed(commandBuffers[i], 36, 1, 0, 0, 0);
@ -2338,12 +2418,7 @@ public:
void updateUniformBuffer(float elapsed)
{
// Construct the model matrix
Matrix model = {
{ 1.0f, 0.0f, 0.0f, 0.0f },
{ 0.0f, 1.0f, 0.0f, 0.0f },
{ 0.0f, 0.0f, 1.0f, 0.0f },
{ 0.0f, 0.0f, 0.0f, 1.0f }
};
Matrix model = {{1.0f, 0.0f, 0.0f, 0.0f}, {0.0f, 1.0f, 0.0f, 0.0f}, {0.0f, 0.0f, 1.0f, 0.0f}, {0.0f, 0.0f, 0.0f, 1.0f}};
matrixRotateX(model, sf::degrees(elapsed * 59.0f));
matrixRotateY(model, sf::degrees(elapsed * 83.0f));
@ -2352,7 +2427,7 @@ public:
// Translate the model based on the mouse position
sf::Vector2f mousePosition = sf::Vector2f(sf::Mouse::getPosition(window));
sf::Vector2f windowSize = sf::Vector2f(window.getSize());
float x = clamp( mousePosition.x * 2.f / windowSize.x - 1.f, -1.0f, 1.0f) * 2.0f;
float x = clamp(mousePosition.x * 2.f / windowSize.x - 1.f, -1.0f, 1.0f) * 2.0f;
float y = clamp(-mousePosition.y * 2.f / windowSize.y + 1.f, -1.0f, 1.0f) * 1.5f;
model[3][0] -= x;
@ -2380,7 +2455,8 @@ public:
char* ptr;
// Map the current frame's uniform buffer into our address space
if (vkMapMemory(device, uniformBuffersMemory[currentFrame], 0, sizeof(Matrix) * 3, 0, reinterpret_cast<void**>(&ptr)) != VK_SUCCESS)
if (vkMapMemory(device, uniformBuffersMemory[currentFrame], 0, sizeof(Matrix) * 3, 0, reinterpret_cast<void**>(&ptr)) !=
VK_SUCCESS)
{
vulkanAvailable = false;
return;
@ -2404,7 +2480,12 @@ public:
{
// Get the next image in the swapchain
VkResult result = vkAcquireNextImageKHR(device, swapchain, std::numeric_limits<uint64_t>::max(), imageAvailableSemaphores[currentFrame], VK_NULL_HANDLE, &imageIndex);
VkResult result = vkAcquireNextImageKHR(device,
swapchain,
std::numeric_limits<uint64_t>::max(),
imageAvailableSemaphores[currentFrame],
VK_NULL_HANDLE,
&imageIndex);
// Check if we need to re-create the swapchain (e.g. if the window was resized)
if (result == VK_ERROR_OUT_OF_DATE_KHR)
@ -2414,7 +2495,8 @@ public:
return;
}
if ((result != VK_SUCCESS) && (result != VK_TIMEOUT) && (result != VK_NOT_READY) && (result != VK_SUBOPTIMAL_KHR))
if ((result != VK_SUCCESS) && (result != VK_TIMEOUT) && (result != VK_NOT_READY) &&
(result != VK_SUBOPTIMAL_KHR))
{
vulkanAvailable = false;
return;

View File

@ -6,8 +6,8 @@
#ifndef WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN
#endif
#include <windows.h>
#include <cmath>
#include <windows.h>
HWND button;
@ -69,14 +69,44 @@ int main()
RegisterClass(&windowClass);
// Let's create the main window
HWND window = CreateWindow(TEXT("SFML App"), TEXT("SFML Win32"), WS_SYSMENU | WS_VISIBLE, 200, 200, 660, 520, nullptr, nullptr, instance, nullptr);
HWND window = CreateWindow(TEXT("SFML App"),
TEXT("SFML Win32"),
WS_SYSMENU | WS_VISIBLE,
200,
200,
660,
520,
nullptr,
nullptr,
instance,
nullptr);
// Add a button for exiting
button = CreateWindow(TEXT("BUTTON"), TEXT("Quit"), WS_CHILD | WS_VISIBLE, 560, 440, 80, 40, window, nullptr, instance, nullptr);
// Let's create two SFML views
HWND view1 = CreateWindow(TEXT("STATIC"), nullptr, WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS, 20, 20, 300, 400, window, nullptr, instance, nullptr);
HWND view2 = CreateWindow(TEXT("STATIC"), nullptr, WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS, 340, 20, 300, 400, window, nullptr, instance, nullptr);
HWND view1 = CreateWindow(TEXT("STATIC"),
nullptr,
WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS,
20,
20,
300,
400,
window,
nullptr,
instance,
nullptr);
HWND view2 = CreateWindow(TEXT("STATIC"),
nullptr,
WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS,
340,
20,
300,
400,
window,
nullptr,
instance,
nullptr);
sf::RenderWindow SFMLView1(view1);
sf::RenderWindow SFMLView2(view2);

View File

@ -2,6 +2,7 @@
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Window.hpp>
#include <cstdlib>
#define GLAD_GL_IMPLEMENTATION
@ -12,8 +13,8 @@
#endif
#include <array>
#include <iostream>
#include <cstdlib>
#include <iostream>
////////////////////////////////////////////////////////////
/// Entry point of application

View File

@ -29,7 +29,6 @@
// Headers
////////////////////////////////////////////////////////////
#include <SFML/System.hpp>
#include <SFML/Audio/InputSoundFile.hpp>
#include <SFML/Audio/Listener.hpp>
#include <SFML/Audio/Music.hpp>
@ -43,6 +42,7 @@
#include <SFML/Audio/SoundRecorder.hpp>
#include <SFML/Audio/SoundSource.hpp>
#include <SFML/Audio/SoundStream.hpp>
#include <SFML/System.hpp>
#endif // SFML_AUDIO_HPP

View File

@ -40,7 +40,6 @@ namespace sf
class SFML_AUDIO_API AlResource
{
protected:
////////////////////////////////////////////////////////////
/// \brief Default constructor
///

View File

@ -36,11 +36,11 @@
////////////////////////////////////////////////////////////
#if defined(SFML_AUDIO_EXPORTS)
#define SFML_AUDIO_API SFML_API_EXPORT
#define SFML_AUDIO_API SFML_API_EXPORT
#else
#define SFML_AUDIO_API SFML_API_IMPORT
#define SFML_AUDIO_API SFML_API_IMPORT
#endif

View File

@ -29,10 +29,11 @@
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Audio/Export.hpp>
#include <cstddef>
#include <filesystem>
#include <memory>
#include <string>
#include <cstddef>
namespace sf
@ -48,7 +49,6 @@ class SoundFileReader;
class SFML_AUDIO_API InputSoundFile
{
public:
////////////////////////////////////////////////////////////
/// \brief Default constructor
///

View File

@ -29,6 +29,7 @@
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Audio/Export.hpp>
#include <SFML/System/Vector3.hpp>
@ -42,7 +43,6 @@ namespace sf
class SFML_AUDIO_API Listener
{
public:
////////////////////////////////////////////////////////////
/// \brief Change the global volume of all the sounds and musics
///

View File

@ -29,8 +29,10 @@
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Audio/Export.hpp>
#include <SFML/Audio/SoundStream.hpp>
#include <SFML/Audio/InputSoundFile.hpp>
#include <SFML/Audio/SoundStream.hpp>
#include <filesystem>
#include <string>
#include <vector>
@ -48,7 +50,6 @@ class InputStream;
class SFML_AUDIO_API Music : public SoundStream
{
public:
////////////////////////////////////////////////////////////
/// \brief Structure defining a time range using the template type
///
@ -62,7 +63,6 @@ public:
////////////////////////////////////////////////////////////
Span()
{
}
////////////////////////////////////////////////////////////
@ -72,11 +72,8 @@ public:
/// \param len Initial Length
///
////////////////////////////////////////////////////////////
Span(T off, T len):
offset(off),
length(len)
Span(T off, T len) : offset(off), length(len)
{
}
T offset; //!< The beginning offset of the time range
@ -211,7 +208,6 @@ public:
void setLoopPoints(TimeSpan timePoints);
protected:
////////////////////////////////////////////////////////////
/// \brief Request a new chunk of audio samples from the stream source
///
@ -246,7 +242,6 @@ protected:
Int64 onLoop() override;
private:
////////////////////////////////////////////////////////////
/// \brief Initialize the internal state after loading a new music
///

View File

@ -29,6 +29,7 @@
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Audio/Export.hpp>
#include <filesystem>
#include <memory>
#include <string>
@ -45,7 +46,6 @@ class SoundFileWriter;
class SFML_AUDIO_API OutputSoundFile
{
public:
////////////////////////////////////////////////////////////
/// \brief Default constructor
///
@ -102,7 +102,6 @@ public:
void close();
private:
////////////////////////////////////////////////////////////
// Member data
////////////////////////////////////////////////////////////

View File

@ -29,7 +29,9 @@
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Audio/Export.hpp>
#include <SFML/Audio/SoundSource.hpp>
#include <cstdlib>
@ -45,7 +47,6 @@ class SoundBuffer;
class SFML_AUDIO_API Sound : public SoundSource
{
public:
////////////////////////////////////////////////////////////
/// \brief Default constructor
///
@ -199,7 +200,7 @@ public:
/// \return Reference to self
///
////////////////////////////////////////////////////////////
Sound& operator =(const Sound& right);
Sound& operator=(const Sound& right);
////////////////////////////////////////////////////////////
/// \brief Reset the internal buffer of the sound
@ -213,7 +214,6 @@ public:
void resetBuffer();
private:
////////////////////////////////////////////////////////////
// Member data
////////////////////////////////////////////////////////////

View File

@ -29,12 +29,14 @@
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Audio/Export.hpp>
#include <SFML/Audio/AlResource.hpp>
#include <SFML/System/Time.hpp>
#include <filesystem>
#include <string>
#include <vector>
#include <unordered_set>
#include <vector>
namespace sf
@ -50,7 +52,6 @@ class InputStream;
class SFML_AUDIO_API SoundBuffer : AlResource
{
public:
////////////////////////////////////////////////////////////
/// \brief Default constructor
///
@ -222,10 +223,9 @@ public:
/// \return Reference to self
///
////////////////////////////////////////////////////////////
SoundBuffer& operator =(const SoundBuffer& right);
SoundBuffer& operator=(const SoundBuffer& right);
private:
friend class Sound;
////////////////////////////////////////////////////////////
@ -268,7 +268,7 @@ private:
////////////////////////////////////////////////////////////
// Types
////////////////////////////////////////////////////////////
using SoundList = std::unordered_set<Sound *>; //!< Set of unique sound instances
using SoundList = std::unordered_set<Sound*>; //!< Set of unique sound instances
////////////////////////////////////////////////////////////
// Member data

View File

@ -29,8 +29,10 @@
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Audio/Export.hpp>
#include <SFML/Audio/SoundBuffer.hpp>
#include <SFML/Audio/SoundRecorder.hpp>
#include <vector>
@ -44,7 +46,6 @@ namespace sf
class SFML_AUDIO_API SoundBufferRecorder : public SoundRecorder
{
public:
////////////////////////////////////////////////////////////
/// \brief destructor
///
@ -65,7 +66,6 @@ public:
const SoundBuffer& getBuffer() const;
protected:
////////////////////////////////////////////////////////////
/// \brief Start capturing audio data
///
@ -92,7 +92,6 @@ protected:
void onStop() override;
private:
////////////////////////////////////////////////////////////
// Member data
////////////////////////////////////////////////////////////

View File

@ -29,6 +29,7 @@
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Audio/Export.hpp>
#include <filesystem>
#include <memory>
#include <string>
@ -48,7 +49,6 @@ class SoundFileWriter;
class SFML_AUDIO_API SoundFileFactory
{
public:
////////////////////////////////////////////////////////////
/// \brief Register a new reader
///
@ -133,7 +133,6 @@ public:
static std::unique_ptr<SoundFileWriter> createWriterFromFilename(const std::filesystem::path& filename);
private:
////////////////////////////////////////////////////////////
// Types
////////////////////////////////////////////////////////////

View File

@ -31,9 +31,17 @@ namespace sf
{
namespace priv
{
template <typename T> std::unique_ptr<SoundFileReader> createReader() { return std::make_unique<T>(); }
template <typename T> std::unique_ptr<SoundFileWriter> createWriter() { return std::make_unique<T>(); }
template <typename T>
std::unique_ptr<SoundFileReader> createReader()
{
return std::make_unique<T>();
}
template <typename T>
std::unique_ptr<SoundFileWriter> createWriter()
{
return std::make_unique<T>();
}
} // namespace priv
////////////////////////////////////////////////////////////
template <typename T>

View File

@ -57,7 +57,9 @@ public:
/// \brief Virtual destructor
///
////////////////////////////////////////////////////////////
virtual ~SoundFileReader() {}
virtual ~SoundFileReader()
{
}
////////////////////////////////////////////////////////////
/// \brief Open a sound file for reading

View File

@ -29,6 +29,7 @@
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Audio/Export.hpp>
#include <filesystem>
#include <string>
@ -42,12 +43,13 @@ namespace sf
class SFML_AUDIO_API SoundFileWriter
{
public:
////////////////////////////////////////////////////////////
/// \brief Virtual destructor
///
////////////////////////////////////////////////////////////
virtual ~SoundFileWriter() {}
virtual ~SoundFileWriter()
{
}
////////////////////////////////////////////////////////////
/// \brief Open a sound file for writing
@ -59,7 +61,9 @@ public:
/// \return True if the file was successfully opened
///
////////////////////////////////////////////////////////////
[[nodiscard]] virtual bool open(const std::filesystem::path& filename, unsigned int sampleRate, unsigned int channelCount) = 0;
[[nodiscard]] virtual bool open(const std::filesystem::path& filename,
unsigned int sampleRate,
unsigned int channelCount) = 0;
////////////////////////////////////////////////////////////
/// \brief Write audio samples to the open file

View File

@ -29,11 +29,13 @@
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Audio/Export.hpp>
#include <SFML/Audio/AlResource.hpp>
#include <SFML/System/Time.hpp>
#include <vector>
#include <string>
#include <thread>
#include <vector>
namespace sf
@ -45,7 +47,6 @@ namespace sf
class SFML_AUDIO_API SoundRecorder : AlResource
{
public:
////////////////////////////////////////////////////////////
/// \brief destructor
///
@ -186,7 +187,6 @@ public:
static bool isAvailable();
protected:
////////////////////////////////////////////////////////////
/// \brief Default constructor
///
@ -254,7 +254,6 @@ protected:
virtual void onStop();
private:
////////////////////////////////////////////////////////////
/// \brief Function called as the entry point of the thread
///

View File

@ -29,6 +29,7 @@
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Audio/Export.hpp>
#include <SFML/Audio/AlResource.hpp>
#include <SFML/System/Vector3.hpp>
@ -42,7 +43,6 @@ namespace sf
class SFML_AUDIO_API SoundSource : AlResource
{
public:
////////////////////////////////////////////////////////////
/// \brief Enumeration of the sound source states
///
@ -232,7 +232,7 @@ public:
/// \return Reference to self
///
////////////////////////////////////////////////////////////
SoundSource& operator =(const SoundSource& right);
SoundSource& operator=(const SoundSource& right);
////////////////////////////////////////////////////////////
/// \brief Start or resume playing the sound source
@ -278,7 +278,6 @@ public:
virtual Status getStatus() const;
protected:
////////////////////////////////////////////////////////////
/// \brief Default constructor
///

View File

@ -29,8 +29,10 @@
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Audio/Export.hpp>
#include <SFML/Audio/SoundSource.hpp>
#include <SFML/System/Time.hpp>
#include <cstdlib>
#include <mutex>
#include <thread>
@ -45,7 +47,6 @@ namespace sf
class SFML_AUDIO_API SoundStream : public SoundSource
{
public:
////////////////////////////////////////////////////////////
/// \brief Structure defining a chunk of audio data to stream
///
@ -179,7 +180,6 @@ public:
bool getLoop() const;
protected:
enum
{
NoLoop = -1 //!< "Invalid" endSeeks value, telling us to continue uninterrupted
@ -266,7 +266,6 @@ protected:
void setProcessingInterval(Time interval);
private:
////////////////////////////////////////////////////////////
/// \brief Function called as the entry point of the thread
///

View File

@ -47,73 +47,73 @@
////////////////////////////////////////////////////////////
#if defined(_WIN32)
// Windows
#define SFML_SYSTEM_WINDOWS
#ifndef NOMINMAX
#define NOMINMAX
#endif
// Windows
#define SFML_SYSTEM_WINDOWS
#ifndef NOMINMAX
#define NOMINMAX
#endif
#elif defined(__APPLE__) && defined(__MACH__)
// Apple platform, see which one it is
#include "TargetConditionals.h"
// Apple platform, see which one it is
#include "TargetConditionals.h"
#if TARGET_OS_IPHONE || TARGET_IPHONE_SIMULATOR
#if TARGET_OS_IPHONE || TARGET_IPHONE_SIMULATOR
// iOS
#define SFML_SYSTEM_IOS
// iOS
#define SFML_SYSTEM_IOS
#elif TARGET_OS_MAC
#elif TARGET_OS_MAC
// MacOS
#define SFML_SYSTEM_MACOS
#else
// Unsupported Apple system
#error This Apple operating system is not supported by SFML library
#endif
#elif defined(__unix__)
// UNIX system, see which one it is
#if defined(__ANDROID__)
// Android
#define SFML_SYSTEM_ANDROID
#elif defined(__linux__)
// Linux
#define SFML_SYSTEM_LINUX
#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
// FreeBSD
#define SFML_SYSTEM_FREEBSD
#elif defined(__OpenBSD__)
// OpenBSD
#define SFML_SYSTEM_OPENBSD
#elif defined(__NetBSD__)
// NetBSD
#define SFML_SYSTEM_NETBSD
#else
// Unsupported UNIX system
#error This UNIX operating system is not supported by SFML library
#endif
// MacOS
#define SFML_SYSTEM_MACOS
#else
// Unsupported system
#error This operating system is not supported by SFML library
// Unsupported Apple system
#error This Apple operating system is not supported by SFML library
#endif
#elif defined(__unix__)
// UNIX system, see which one it is
#if defined(__ANDROID__)
// Android
#define SFML_SYSTEM_ANDROID
#elif defined(__linux__)
// Linux
#define SFML_SYSTEM_LINUX
#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
// FreeBSD
#define SFML_SYSTEM_FREEBSD
#elif defined(__OpenBSD__)
// OpenBSD
#define SFML_SYSTEM_OPENBSD
#elif defined(__NetBSD__)
// NetBSD
#define SFML_SYSTEM_NETBSD
#else
// Unsupported UNIX system
#error This UNIX operating system is not supported by SFML library
#endif
#else
// Unsupported system
#error This operating system is not supported by SFML library
#endif
@ -123,7 +123,7 @@
////////////////////////////////////////////////////////////
#if !defined(NDEBUG)
#define SFML_DEBUG
#define SFML_DEBUG
#endif
@ -133,31 +133,31 @@
////////////////////////////////////////////////////////////
#if !defined(SFML_STATIC)
#if defined(SFML_SYSTEM_WINDOWS)
#if defined(SFML_SYSTEM_WINDOWS)
// Windows compilers need specific (and different) keywords for export and import
#define SFML_API_EXPORT __declspec(dllexport)
#define SFML_API_IMPORT __declspec(dllimport)
// Windows compilers need specific (and different) keywords for export and import
#define SFML_API_EXPORT __declspec(dllexport)
#define SFML_API_IMPORT __declspec(dllimport)
// For Visual C++ compilers, we also need to turn off this annoying C4251 warning
#ifdef _MSC_VER
// For Visual C++ compilers, we also need to turn off this annoying C4251 warning
#ifdef _MSC_VER
#pragma warning(disable: 4251)
#pragma warning(disable : 4251)
#endif
#endif
#else // Linux, FreeBSD, Mac OS X
#else // Linux, FreeBSD, Mac OS X
#define SFML_API_EXPORT __attribute__ ((__visibility__ ("default")))
#define SFML_API_IMPORT __attribute__ ((__visibility__ ("default")))
#define SFML_API_EXPORT __attribute__((__visibility__("default")))
#define SFML_API_IMPORT __attribute__((__visibility__("default")))
#endif
#endif
#else
// Static build doesn't need import/export macros
#define SFML_API_EXPORT
#define SFML_API_IMPORT
// Static build doesn't need import/export macros
#define SFML_API_EXPORT
#define SFML_API_IMPORT
#endif
@ -167,21 +167,21 @@
////////////////////////////////////////////////////////////
namespace sf
{
// 8 bits integer types
using Int8 = std::int8_t;
using Uint8 = std::uint8_t;
// 8 bits integer types
using Int8 = std::int8_t;
using Uint8 = std::uint8_t;
// 16 bits integer types
using Int16 = std::int16_t;
using Uint16 = std::uint16_t;
// 16 bits integer types
using Int16 = std::int16_t;
using Uint16 = std::uint16_t;
// 32 bits integer types
using Int32 = std::int32_t;
using Uint32 = std::uint32_t;
// 32 bits integer types
using Int32 = std::int32_t;
using Uint32 = std::uint32_t;
// 64 bits integer types
using Int64 = std::int64_t;
using Uint64 = std::uint64_t;
// 64 bits integer types
using Int64 = std::int64_t;
using Uint64 = std::uint64_t;
} // namespace sf

View File

@ -60,13 +60,13 @@
////////////////////////////////////////////////////////////
#if defined(SFML_SYSTEM_WINDOWS)
#define SFML_DEFINE_DISCRETE_GPU_PREFERENCE \
#define SFML_DEFINE_DISCRETE_GPU_PREFERENCE \
extern "C" __declspec(dllexport) unsigned long NvOptimusEnablement = 1; \
extern "C" __declspec(dllexport) unsigned long AmdPowerXpressRequestHighPerformance = 1;
#else
#define SFML_DEFINE_DISCRETE_GPU_PREFERENCE
#define SFML_DEFINE_DISCRETE_GPU_PREFERENCE
#endif

View File

@ -29,7 +29,6 @@
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Window.hpp>
#include <SFML/Graphics/BlendMode.hpp>
#include <SFML/Graphics/CircleShape.hpp>
#include <SFML/Graphics/Color.hpp>
@ -56,6 +55,7 @@
#include <SFML/Graphics/VertexArray.hpp>
#include <SFML/Graphics/VertexBuffer.hpp>
#include <SFML/Graphics/View.hpp>
#include <SFML/Window.hpp>
#endif // SFML_GRAPHICS_HPP

View File

@ -107,9 +107,12 @@ struct SFML_GRAPHICS_API BlendMode
/// \param alphaBlendEquation Specifies how to combine the source and destination alphas.
///
////////////////////////////////////////////////////////////
BlendMode(Factor colorSourceFactor, Factor colorDestinationFactor,
Equation colorBlendEquation, Factor alphaSourceFactor,
Factor alphaDestinationFactor, Equation alphaBlendEquation);
BlendMode(Factor colorSourceFactor,
Factor colorDestinationFactor,
Equation colorBlendEquation,
Factor alphaSourceFactor,
Factor alphaDestinationFactor,
Equation alphaBlendEquation);
////////////////////////////////////////////////////////////
// Member Data
@ -132,7 +135,7 @@ struct SFML_GRAPHICS_API BlendMode
/// \return True if blending modes are equal, false if they are different
///
////////////////////////////////////////////////////////////
SFML_GRAPHICS_API bool operator ==(const BlendMode& left, const BlendMode& right);
SFML_GRAPHICS_API bool operator==(const BlendMode& left, const BlendMode& right);
////////////////////////////////////////////////////////////
/// \relates BlendMode
@ -144,7 +147,7 @@ SFML_GRAPHICS_API bool operator ==(const BlendMode& left, const BlendMode& right
/// \return True if blending modes are different, false if they are equal
///
////////////////////////////////////////////////////////////
SFML_GRAPHICS_API bool operator !=(const BlendMode& left, const BlendMode& right);
SFML_GRAPHICS_API bool operator!=(const BlendMode& left, const BlendMode& right);
////////////////////////////////////////////////////////////
// Commonly used blending modes

View File

@ -29,6 +29,7 @@
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Graphics/Export.hpp>
#include <SFML/Graphics/Shape.hpp>
@ -41,7 +42,6 @@ namespace sf
class SFML_GRAPHICS_API CircleShape : public Shape
{
public:
////////////////////////////////////////////////////////////
/// \brief Default constructor
///
@ -107,7 +107,6 @@ public:
Vector2f getPoint(std::size_t index) const override;
private:
////////////////////////////////////////////////////////////
// Member data
////////////////////////////////////////////////////////////

View File

@ -40,7 +40,6 @@ namespace sf
class Color
{
public:
////////////////////////////////////////////////////////////
/// \brief Default constructor
///
@ -111,7 +110,7 @@ public:
/// \return True if colors are equal, false if they are different
///
////////////////////////////////////////////////////////////
[[nodiscard]] constexpr bool operator ==(const Color& left, const Color& right);
[[nodiscard]] constexpr bool operator==(const Color& left, const Color& right);
////////////////////////////////////////////////////////////
/// \relates Color
@ -125,7 +124,7 @@ public:
/// \return True if colors are different, false if they are equal
///
////////////////////////////////////////////////////////////
[[nodiscard]] constexpr bool operator !=(const Color& left, const Color& right);
[[nodiscard]] constexpr bool operator!=(const Color& left, const Color& right);
////////////////////////////////////////////////////////////
/// \relates Color
@ -140,7 +139,7 @@ public:
/// \return Result of \a left + \a right
///
////////////////////////////////////////////////////////////
[[nodiscard]] constexpr Color operator +(const Color& left, const Color& right);
[[nodiscard]] constexpr Color operator+(const Color& left, const Color& right);
////////////////////////////////////////////////////////////
/// \relates Color
@ -155,7 +154,7 @@ public:
/// \return Result of \a left - \a right
///
////////////////////////////////////////////////////////////
[[nodiscard]] constexpr Color operator -(const Color& left, const Color& right);
[[nodiscard]] constexpr Color operator-(const Color& left, const Color& right);
////////////////////////////////////////////////////////////
/// \relates Color
@ -172,7 +171,7 @@ public:
/// \return Result of \a left * \a right
///
////////////////////////////////////////////////////////////
[[nodiscard]] constexpr Color operator *(const Color& left, const Color& right);
[[nodiscard]] constexpr Color operator*(const Color& left, const Color& right);
////////////////////////////////////////////////////////////
/// \relates Color
@ -188,7 +187,7 @@ public:
/// \return Reference to \a left
///
////////////////////////////////////////////////////////////
constexpr Color& operator +=(Color& left, const Color& right);
constexpr Color& operator+=(Color& left, const Color& right);
////////////////////////////////////////////////////////////
/// \relates Color
@ -204,7 +203,7 @@ constexpr Color& operator +=(Color& left, const Color& right);
/// \return Reference to \a left
///
////////////////////////////////////////////////////////////
constexpr Color& operator -=(Color& left, const Color& right);
constexpr Color& operator-=(Color& left, const Color& right);
////////////////////////////////////////////////////////////
/// \relates Color
@ -222,7 +221,7 @@ constexpr Color& operator -=(Color& left, const Color& right);
/// \return Reference to \a left
///
////////////////////////////////////////////////////////////
constexpr Color& operator *=(Color& left, const Color& right);
constexpr Color& operator*=(Color& left, const Color& right);
#include <SFML/Graphics/Color.inl>

View File

@ -24,24 +24,14 @@
////////////////////////////////////////////////////////////
constexpr Color::Color() :
r(0),
g(0),
b(0),
a(255)
constexpr Color::Color() : r(0), g(0), b(0), a(255)
{
}
////////////////////////////////////////////////////////////
constexpr Color::Color(Uint8 red, Uint8 green, Uint8 blue, Uint8 alpha) :
r(red),
g(green),
b(blue),
a(alpha)
constexpr Color::Color(Uint8 red, Uint8 green, Uint8 blue, Uint8 alpha) : r(red), g(green), b(blue), a(alpha)
{
}
@ -52,7 +42,6 @@ g(static_cast<Uint8>((color & 0x00ff0000) >> 16)),
b(static_cast<Uint8>((color & 0x0000ff00) >> 8)),
a(static_cast<Uint8>(color & 0x000000ff))
{
}
@ -64,24 +53,21 @@ constexpr Uint32 Color::toInteger() const
////////////////////////////////////////////////////////////
constexpr bool operator ==(const Color& left, const Color& right)
constexpr bool operator==(const Color& left, const Color& right)
{
return (left.r == right.r) &&
(left.g == right.g) &&
(left.b == right.b) &&
(left.a == right.a);
return (left.r == right.r) && (left.g == right.g) && (left.b == right.b) && (left.a == right.a);
}
////////////////////////////////////////////////////////////
constexpr bool operator !=(const Color& left, const Color& right)
constexpr bool operator!=(const Color& left, const Color& right)
{
return !(left == right);
}
////////////////////////////////////////////////////////////
constexpr Color operator +(const Color& left, const Color& right)
constexpr Color operator+(const Color& left, const Color& right)
{
const auto clampedAdd = [](Uint8 lhs, Uint8 rhs) -> Uint8
{
@ -97,7 +83,7 @@ constexpr Color operator +(const Color& left, const Color& right)
////////////////////////////////////////////////////////////
constexpr Color operator -(const Color& left, const Color& right)
constexpr Color operator-(const Color& left, const Color& right)
{
const auto clampedSub = [](Uint8 lhs, Uint8 rhs) -> Uint8
{
@ -113,7 +99,7 @@ constexpr Color operator -(const Color& left, const Color& right)
////////////////////////////////////////////////////////////
constexpr Color operator *(const Color& left, const Color& right)
constexpr Color operator*(const Color& left, const Color& right)
{
const auto scaledMul = [](Uint8 lhs, Uint8 rhs) -> Uint8
{
@ -129,21 +115,21 @@ constexpr Color operator *(const Color& left, const Color& right)
////////////////////////////////////////////////////////////
constexpr Color& operator +=(Color& left, const Color& right)
constexpr Color& operator+=(Color& left, const Color& right)
{
return left = left + right;
}
////////////////////////////////////////////////////////////
constexpr Color& operator -=(Color& left, const Color& right)
constexpr Color& operator-=(Color& left, const Color& right)
{
return left = left - right;
}
////////////////////////////////////////////////////////////
constexpr Color& operator *=(Color& left, const Color& right)
constexpr Color& operator*=(Color& left, const Color& right)
{
return left = left * right;
}

View File

@ -29,7 +29,9 @@
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Graphics/Export.hpp>
#include <SFML/Graphics/Shape.hpp>
#include <vector>
@ -42,7 +44,6 @@ namespace sf
class SFML_GRAPHICS_API ConvexShape : public Shape
{
public:
////////////////////////////////////////////////////////////
/// \brief Default constructor
///
@ -112,7 +113,6 @@ public:
Vector2f getPoint(std::size_t index) const override;
private:
////////////////////////////////////////////////////////////
// Member data
////////////////////////////////////////////////////////////

View File

@ -44,15 +44,15 @@ class RenderStates;
class SFML_GRAPHICS_API Drawable
{
public:
////////////////////////////////////////////////////////////
/// \brief Virtual destructor
///
////////////////////////////////////////////////////////////
virtual ~Drawable() {}
virtual ~Drawable()
{
}
protected:
friend class RenderTarget;
////////////////////////////////////////////////////////////

View File

@ -36,11 +36,11 @@
////////////////////////////////////////////////////////////
#if defined(SFML_GRAPHICS_EXPORTS)
#define SFML_GRAPHICS_API SFML_API_EXPORT
#define SFML_GRAPHICS_API SFML_API_EXPORT
#else
#define SFML_GRAPHICS_API SFML_API_IMPORT
#define SFML_GRAPHICS_API SFML_API_IMPORT
#endif

View File

@ -29,9 +29,11 @@
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Graphics/Export.hpp>
#include <SFML/Graphics/Glyph.hpp>
#include <SFML/Graphics/Texture.hpp>
#include <SFML/Graphics/Rect.hpp>
#include <SFML/Graphics/Texture.hpp>
#include <memory>
#include <string>
#include <unordered_map>
@ -56,7 +58,6 @@ class InputStream;
class SFML_GRAPHICS_API Font
{
public:
////////////////////////////////////////////////////////////
/// \brief Holds various information about a font
///
@ -67,7 +68,6 @@ public:
};
public:
////////////////////////////////////////////////////////////
/// \brief Default constructor
///
@ -327,17 +327,18 @@ public:
/// \return Reference to self
///
////////////////////////////////////////////////////////////
Font& operator =(const Font& right);
Font& operator=(const Font& right);
private:
////////////////////////////////////////////////////////////
/// \brief Structure defining a row of glyphs
///
////////////////////////////////////////////////////////////
struct Row
{
Row(unsigned int rowTop, unsigned int rowHeight) : width(0), top(rowTop), height(rowHeight) {}
Row(unsigned int rowTop, unsigned int rowHeight) : width(0), top(rowTop), height(rowHeight)
{
}
unsigned int width; //!< Current width of the row
unsigned int top; //!< Y position of the row into the texture
@ -427,9 +428,9 @@ private:
Info m_info; //!< Information about the font
mutable PageTable m_pages; //!< Table containing the glyphs pages by character size
mutable std::vector<Uint8> m_pixelBuffer; //!< Pixel buffer holding a glyph's pixels before being written to the texture
#ifdef SFML_SYSTEM_ANDROID
#ifdef SFML_SYSTEM_ANDROID
std::unique_ptr<priv::ResourceStream> m_stream; //!< Asset file streamer (if loaded from file)
#endif
#endif
};
} // namespace sf

View File

@ -28,10 +28,11 @@
////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Graphics/Transform.hpp>
#include <SFML/Graphics/Color.hpp>
#include <SFML/Graphics/Transform.hpp>
#include <SFML/System/Vector2.hpp>
#include <SFML/System/Vector3.hpp>
#include <cstddef>
@ -39,12 +40,12 @@ namespace sf
{
namespace priv
{
// Forward declarations
template <std::size_t Columns, std::size_t Rows>
struct Matrix;
// Forward declarations
template <std::size_t Columns, std::size_t Rows>
struct Matrix;
template <typename T>
struct Vector4;
template <typename T>
struct Vector4;
#include <SFML/Graphics/Glsl.inl>
@ -58,136 +59,136 @@ namespace priv
namespace Glsl
{
////////////////////////////////////////////////////////////
/// \brief 2D float vector (\p vec2 in GLSL)
///
////////////////////////////////////////////////////////////
using Vec2 = Vector2<float>;
////////////////////////////////////////////////////////////
/// \brief 2D float vector (\p vec2 in GLSL)
///
////////////////////////////////////////////////////////////
using Vec2 = Vector2<float>;
////////////////////////////////////////////////////////////
/// \brief 2D int vector (\p ivec2 in GLSL)
///
////////////////////////////////////////////////////////////
using Ivec2 = Vector2<int>;
////////////////////////////////////////////////////////////
/// \brief 2D int vector (\p ivec2 in GLSL)
///
////////////////////////////////////////////////////////////
using Ivec2 = Vector2<int>;
////////////////////////////////////////////////////////////
/// \brief 2D bool vector (\p bvec2 in GLSL)
///
////////////////////////////////////////////////////////////
using Bvec2 = Vector2<bool>;
////////////////////////////////////////////////////////////
/// \brief 2D bool vector (\p bvec2 in GLSL)
///
////////////////////////////////////////////////////////////
using Bvec2 = Vector2<bool>;
////////////////////////////////////////////////////////////
/// \brief 3D float vector (\p vec3 in GLSL)
///
////////////////////////////////////////////////////////////
using Vec3 = Vector3<float>;
////////////////////////////////////////////////////////////
/// \brief 3D float vector (\p vec3 in GLSL)
///
////////////////////////////////////////////////////////////
using Vec3 = Vector3<float>;
////////////////////////////////////////////////////////////
/// \brief 3D int vector (\p ivec3 in GLSL)
///
////////////////////////////////////////////////////////////
using Ivec3 = Vector3<int>;
////////////////////////////////////////////////////////////
/// \brief 3D int vector (\p ivec3 in GLSL)
///
////////////////////////////////////////////////////////////
using Ivec3 = Vector3<int>;
////////////////////////////////////////////////////////////
/// \brief 3D bool vector (\p bvec3 in GLSL)
///
////////////////////////////////////////////////////////////
using Bvec3 = Vector3<bool>;
////////////////////////////////////////////////////////////
/// \brief 3D bool vector (\p bvec3 in GLSL)
///
////////////////////////////////////////////////////////////
using Bvec3 = Vector3<bool>;
#ifdef SFML_DOXYGEN
////////////////////////////////////////////////////////////
/// \brief 4D float vector (\p vec4 in GLSL)
///
/// 4D float vectors can be implicitly converted from sf::Color
/// instances. Each color channel is normalized from integers
/// in [0, 255] to floating point values in [0, 1].
/// \code
/// sf::Glsl::Vec4 zeroVector;
/// sf::Glsl::Vec4 vector(1.f, 2.f, 3.f, 4.f);
/// sf::Glsl::Vec4 color = sf::Color::Cyan;
/// \endcode
////////////////////////////////////////////////////////////
using Vec4 = implementation-defined;
////////////////////////////////////////////////////////////
/// \brief 4D float vector (\p vec4 in GLSL)
///
/// 4D float vectors can be implicitly converted from sf::Color
/// instances. Each color channel is normalized from integers
/// in [0, 255] to floating point values in [0, 1].
/// \code
/// sf::Glsl::Vec4 zeroVector;
/// sf::Glsl::Vec4 vector(1.f, 2.f, 3.f, 4.f);
/// sf::Glsl::Vec4 color = sf::Color::Cyan;
/// \endcode
////////////////////////////////////////////////////////////
using Vec4 = ImplementationDefined;
////////////////////////////////////////////////////////////
/// \brief 4D int vector (\p ivec4 in GLSL)
///
/// 4D int vectors can be implicitly converted from sf::Color
/// instances. Each color channel remains unchanged inside
/// the integer interval [0, 255].
/// \code
/// sf::Glsl::Ivec4 zeroVector;
/// sf::Glsl::Ivec4 vector(1, 2, 3, 4);
/// sf::Glsl::Ivec4 color = sf::Color::Cyan;
/// \endcode
////////////////////////////////////////////////////////////
using Ivec4 = implementation-defined;
////////////////////////////////////////////////////////////
/// \brief 4D int vector (\p ivec4 in GLSL)
///
/// 4D int vectors can be implicitly converted from sf::Color
/// instances. Each color channel remains unchanged inside
/// the integer interval [0, 255].
/// \code
/// sf::Glsl::Ivec4 zeroVector;
/// sf::Glsl::Ivec4 vector(1, 2, 3, 4);
/// sf::Glsl::Ivec4 color = sf::Color::Cyan;
/// \endcode
////////////////////////////////////////////////////////////
using Ivec4 = ImplementationDefined;
////////////////////////////////////////////////////////////
/// \brief 4D bool vector (\p bvec4 in GLSL)
///
////////////////////////////////////////////////////////////
using Bvec4 = implementation-defined;
////////////////////////////////////////////////////////////
/// \brief 4D bool vector (\p bvec4 in GLSL)
///
////////////////////////////////////////////////////////////
using Bvec4 = ImplementationDefined;
////////////////////////////////////////////////////////////
/// \brief 3x3 float matrix (\p mat3 in GLSL)
///
/// The matrix can be constructed from an array with 3x3
/// elements, aligned in column-major order. For example,
/// a translation by (x, y) looks as follows:
/// \code
/// float array[9] =
/// {
/// 1, 0, 0,
/// 0, 1, 0,
/// x, y, 1
/// };
///
/// sf::Glsl::Mat3 matrix(array);
/// \endcode
///
/// Mat3 can also be implicitly converted from sf::Transform:
/// \code
/// sf::Transform transform;
/// sf::Glsl::Mat3 matrix = transform;
/// \endcode
////////////////////////////////////////////////////////////
using Mat3 = implementation-defined;
////////////////////////////////////////////////////////////
/// \brief 3x3 float matrix (\p mat3 in GLSL)
///
/// The matrix can be constructed from an array with 3x3
/// elements, aligned in column-major order. For example,
/// a translation by (x, y) looks as follows:
/// \code
/// float array[9] =
/// {
/// 1, 0, 0,
/// 0, 1, 0,
/// x, y, 1
/// };
///
/// sf::Glsl::Mat3 matrix(array);
/// \endcode
///
/// Mat3 can also be implicitly converted from sf::Transform:
/// \code
/// sf::Transform transform;
/// sf::Glsl::Mat3 matrix = transform;
/// \endcode
////////////////////////////////////////////////////////////
using Mat3 = ImplementationDefined;
////////////////////////////////////////////////////////////
/// \brief 4x4 float matrix (\p mat4 in GLSL)
///
/// The matrix can be constructed from an array with 4x4
/// elements, aligned in column-major order. For example,
/// a translation by (x, y, z) looks as follows:
/// \code
/// float array[16] =
/// {
/// 1, 0, 0, 0,
/// 0, 1, 0, 0,
/// 0, 0, 1, 0,
/// x, y, z, 1
/// };
///
/// sf::Glsl::Mat4 matrix(array);
/// \endcode
///
/// Mat4 can also be implicitly converted from sf::Transform:
/// \code
/// sf::Transform transform;
/// sf::Glsl::Mat4 matrix = transform;
/// \endcode
////////////////////////////////////////////////////////////
using Mat4 = implementation-defined;
////////////////////////////////////////////////////////////
/// \brief 4x4 float matrix (\p mat4 in GLSL)
///
/// The matrix can be constructed from an array with 4x4
/// elements, aligned in column-major order. For example,
/// a translation by (x, y, z) looks as follows:
/// \code
/// float array[16] =
/// {
/// 1, 0, 0, 0,
/// 0, 1, 0, 0,
/// 0, 0, 1, 0,
/// x, y, z, 1
/// };
///
/// sf::Glsl::Mat4 matrix(array);
/// \endcode
///
/// Mat4 can also be implicitly converted from sf::Transform:
/// \code
/// sf::Transform transform;
/// sf::Glsl::Mat4 matrix = transform;
/// \endcode
////////////////////////////////////////////////////////////
using Mat4 = ImplementationDefined;
#else // SFML_DOXYGEN
using Vec4 = priv::Vector4<float>;
using Ivec4 = priv::Vector4<int>;
using Bvec4 = priv::Vector4<bool>;
using Mat3 = priv::Matrix<3, 3>;
using Mat4 = priv::Matrix<4, 4>;
using Vec4 = priv::Vector4<float>;
using Ivec4 = priv::Vector4<int>;
using Bvec4 = priv::Vector4<bool>;
using Mat3 = priv::Matrix<3, 3>;
using Mat4 = priv::Matrix<4, 4>;
#endif // SFML_DOXYGEN

View File

@ -95,11 +95,7 @@ struct Vector4
/// \brief Default constructor, creates a zero vector
///
////////////////////////////////////////////////////////////
Vector4() :
x(0),
y(0),
z(0),
w(0)
Vector4() : x(0), y(0), z(0), w(0)
{
}
@ -112,11 +108,7 @@ struct Vector4
/// \param W Component of the 4D vector
///
////////////////////////////////////////////////////////////
Vector4(T X, T Y, T Z, T W) :
x(X),
y(Y),
z(Z),
w(W)
Vector4(T X, T Y, T Z, T W) : x(X), y(Y), z(Z), w(W)
{
}

View File

@ -29,6 +29,7 @@
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Graphics/Export.hpp>
#include <SFML/Graphics/Rect.hpp>
@ -41,12 +42,13 @@ namespace sf
class SFML_GRAPHICS_API Glyph
{
public:
////////////////////////////////////////////////////////////
/// \brief Default constructor
///
////////////////////////////////////////////////////////////
Glyph() : advance(0), lsbDelta(0), rsbDelta(0) {}
Glyph() : advance(0), lsbDelta(0), rsbDelta(0)
{
}
////////////////////////////////////////////////////////////
// Member data

View File

@ -29,8 +29,10 @@
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Graphics/Export.hpp>
#include <SFML/Graphics/Color.hpp>
#include <SFML/Graphics/Rect.hpp>
#include <filesystem>
#include <string>
#include <vector>
@ -47,7 +49,6 @@ class InputStream;
class SFML_GRAPHICS_API Image
{
public:
////////////////////////////////////////////////////////////
/// \brief Create the image and fill it with a unique color
///
@ -211,7 +212,10 @@ public:
/// \return True if the operation was successful, false otherwise
///
////////////////////////////////////////////////////////////
[[nodiscard]] bool copy(const Image& source, const Vector2u& dest, const IntRect& sourceRect = IntRect({0, 0}, {0, 0}), bool applyAlpha = false);
[[nodiscard]] bool copy(const Image& source,
const Vector2u& dest,
const IntRect& sourceRect = IntRect({0, 0}, {0, 0}),
bool applyAlpha = false);
////////////////////////////////////////////////////////////
/// \brief Change the color of a pixel
@ -272,7 +276,6 @@ public:
void flipVertically();
private:
////////////////////////////////////////////////////////////
// Member data
////////////////////////////////////////////////////////////

View File

@ -29,6 +29,7 @@
// Headers
////////////////////////////////////////////////////////////
#include <SFML/System/Vector2.hpp>
#include <optional>
@ -42,7 +43,6 @@ template <typename T>
class Rect
{
public:
////////////////////////////////////////////////////////////
/// \brief Default constructor
///
@ -147,7 +147,7 @@ public:
///
////////////////////////////////////////////////////////////
template <typename T>
[[nodiscard]] constexpr bool operator ==(const Rect<T>& left, const Rect<T>& right);
[[nodiscard]] constexpr bool operator==(const Rect<T>& left, const Rect<T>& right);
////////////////////////////////////////////////////////////
/// \relates Rect
@ -162,7 +162,7 @@ template <typename T>
///
////////////////////////////////////////////////////////////
template <typename T>
[[nodiscard]] constexpr bool operator !=(const Rect<T>& left, const Rect<T>& right);
[[nodiscard]] constexpr bool operator!=(const Rect<T>& left, const Rect<T>& right);
#include <SFML/Graphics/Rect.inl>

View File

@ -25,25 +25,19 @@
////////////////////////////////////////////////////////////
template <typename T>
constexpr Rect<T>::Rect() :
left (0),
top (0),
width (0),
height(0)
constexpr Rect<T>::Rect() : left(0), top(0), width(0), height(0)
{
}
////////////////////////////////////////////////////////////
template <typename T>
constexpr Rect<T>::Rect(const Vector2<T>& position, const Vector2<T>& size) :
left (position.x),
top (position.y),
width (size.x),
left(position.x),
top(position.y),
width(size.x),
height(size.y)
{
}
@ -51,9 +45,9 @@ height(size.y)
template <typename T>
template <typename U>
constexpr Rect<T>::Rect(const Rect<U>& rectangle) :
left (static_cast<T>(rectangle.left)),
top (static_cast<T>(rectangle.top)),
width (static_cast<T>(rectangle.width)),
left(static_cast<T>(rectangle.left)),
top(static_cast<T>(rectangle.top)),
width(static_cast<T>(rectangle.width)),
height(static_cast<T>(rectangle.height))
{
}
@ -64,8 +58,8 @@ template <typename T>
constexpr bool Rect<T>::contains(const Vector2<T>& point) const
{
// Not using 'std::min' and 'std::max' to avoid depending on '<algorithm>'
const auto min = [](T a, T b){ return (a < b) ? a : b; };
const auto max = [](T a, T b){ return (a < b) ? b : a; };
const auto min = [](T a, T b) { return (a < b) ? a : b; };
const auto max = [](T a, T b) { return (a < b) ? b : a; };
// Rectangles with negative dimensions are allowed, so we must handle them correctly
@ -84,8 +78,8 @@ template <typename T>
constexpr std::optional<Rect<T>> Rect<T>::findIntersection(const Rect<T>& rectangle) const
{
// Not using 'std::min' and 'std::max' to avoid depending on '<algorithm>'
const auto min = [](T a, T b){ return (a < b) ? a : b; };
const auto max = [](T a, T b){ return (a < b) ? b : a; };
const auto min = [](T a, T b) { return (a < b) ? a : b; };
const auto max = [](T a, T b) { return (a < b) ? b : a; };
// Rectangles with negative dimensions are allowed, so we must handle them correctly
@ -137,16 +131,16 @@ constexpr Vector2<T> Rect<T>::getSize() const
////////////////////////////////////////////////////////////
template <typename T>
constexpr bool operator ==(const Rect<T>& left, const Rect<T>& right)
constexpr bool operator==(const Rect<T>& left, const Rect<T>& right)
{
return (left.left == right.left) && (left.width == right.width) &&
(left.top == right.top) && (left.height == right.height);
return (left.left == right.left) && (left.width == right.width) && (left.top == right.top) &&
(left.height == right.height);
}
////////////////////////////////////////////////////////////
template <typename T>
constexpr bool operator !=(const Rect<T>& left, const Rect<T>& right)
constexpr bool operator!=(const Rect<T>& left, const Rect<T>& right)
{
return !(left == right);
}

View File

@ -29,6 +29,7 @@
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Graphics/Export.hpp>
#include <SFML/Graphics/Shape.hpp>
@ -41,7 +42,6 @@ namespace sf
class SFML_GRAPHICS_API RectangleShape : public Shape
{
public:
////////////////////////////////////////////////////////////
/// \brief Default constructor
///
@ -95,7 +95,6 @@ public:
Vector2f getPoint(std::size_t index) const override;
private:
////////////////////////////////////////////////////////////
// Member data
////////////////////////////////////////////////////////////

View File

@ -29,6 +29,7 @@
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Graphics/Export.hpp>
#include <SFML/Graphics/BlendMode.hpp>
#include <SFML/Graphics/Transform.hpp>
@ -45,7 +46,6 @@ class Texture;
class SFML_GRAPHICS_API RenderStates
{
public:
////////////////////////////////////////////////////////////
/// \brief Default constructor
///
@ -101,8 +101,7 @@ public:
/// \param theShader Shader to use
///
////////////////////////////////////////////////////////////
RenderStates(const BlendMode& theBlendMode, const Transform& theTransform,
const Texture* theTexture, const Shader* theShader);
RenderStates(const BlendMode& theBlendMode, const Transform& theTransform, const Texture* theTexture, const Shader* theShader);
////////////////////////////////////////////////////////////
// Static member data

View File

@ -29,13 +29,15 @@
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Graphics/Export.hpp>
#include <SFML/Graphics/Color.hpp>
#include <SFML/Graphics/Rect.hpp>
#include <SFML/Graphics/View.hpp>
#include <SFML/Graphics/BlendMode.hpp>
#include <SFML/Graphics/RenderStates.hpp>
#include <SFML/Graphics/Color.hpp>
#include <SFML/Graphics/PrimitiveType.hpp>
#include <SFML/Graphics/Rect.hpp>
#include <SFML/Graphics/RenderStates.hpp>
#include <SFML/Graphics/Vertex.hpp>
#include <SFML/Graphics/View.hpp>
#include <cstddef>
@ -52,7 +54,6 @@ class Transform;
class SFML_GRAPHICS_API RenderTarget
{
public:
////////////////////////////////////////////////////////////
/// \brief Destructor
///
@ -257,8 +258,10 @@ public:
/// \param states Render states to use for drawing
///
////////////////////////////////////////////////////////////
void draw(const Vertex* vertices, std::size_t vertexCount,
PrimitiveType type, const RenderStates& states = RenderStates::Default);
void draw(const Vertex* vertices,
std::size_t vertexCount,
PrimitiveType type,
const RenderStates& states = RenderStates::Default);
////////////////////////////////////////////////////////////
/// \brief Draw primitives defined by a vertex buffer
@ -278,7 +281,10 @@ public:
/// \param states Render states to use for drawing
///
////////////////////////////////////////////////////////////
void draw(const VertexBuffer& vertexBuffer, std::size_t firstVertex, std::size_t vertexCount, const RenderStates& states = RenderStates::Default);
void draw(const VertexBuffer& vertexBuffer,
std::size_t firstVertex,
std::size_t vertexCount,
const RenderStates& states = RenderStates::Default);
////////////////////////////////////////////////////////////
/// \brief Return the size of the rendering region of the target
@ -387,7 +393,6 @@ public:
void resetGLStates();
protected:
////////////////////////////////////////////////////////////
/// \brief Default constructor
///
@ -404,7 +409,6 @@ protected:
void initialize();
private:
////////////////////////////////////////////////////////////
/// \brief Apply the current view
///
@ -476,7 +480,10 @@ private:
////////////////////////////////////////////////////////////
struct StatesCache
{
enum {VertexCacheSize = 4};
enum
{
VertexCacheSize = 4
};
bool enable; //!< Is the cache enabled?
bool glStatesSet; //!< Are our internal GL states set yet?

View File

@ -29,9 +29,11 @@
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Graphics/Export.hpp>
#include <SFML/Graphics/Texture.hpp>
#include <SFML/Graphics/RenderTarget.hpp>
#include <SFML/Graphics/Texture.hpp>
#include <SFML/Window/ContextSettings.hpp>
#include <memory>
@ -39,7 +41,7 @@ namespace sf
{
namespace priv
{
class RenderTextureImpl;
class RenderTextureImpl;
}
////////////////////////////////////////////////////////////
@ -49,7 +51,6 @@ namespace priv
class SFML_GRAPHICS_API RenderTexture : public RenderTarget
{
public:
////////////////////////////////////////////////////////////
/// \brief Default constructor
///
@ -224,7 +225,6 @@ public:
const Texture& getTexture() const;
private:
////////////////////////////////////////////////////////////
// Member data
////////////////////////////////////////////////////////////

View File

@ -29,6 +29,7 @@
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Graphics/Export.hpp>
#include <SFML/Graphics/RenderTarget.hpp>
#include <SFML/Window/Window.hpp>
@ -42,7 +43,6 @@ namespace sf
class SFML_GRAPHICS_API RenderWindow : public Window, public RenderTarget
{
public:
////////////////////////////////////////////////////////////
/// \brief Default constructor
///
@ -71,7 +71,10 @@ public:
/// \param settings Additional settings for the underlying OpenGL context
///
////////////////////////////////////////////////////////////
RenderWindow(VideoMode mode, const String& title, Uint32 style = Style::Default, const ContextSettings& settings = ContextSettings());
RenderWindow(VideoMode mode,
const String& title,
Uint32 style = Style::Default,
const ContextSettings& settings = ContextSettings());
////////////////////////////////////////////////////////////
/// \brief Construct the window from an existing control
@ -140,7 +143,6 @@ public:
[[nodiscard]] bool setActive(bool active = true) override;
protected:
////////////////////////////////////////////////////////////
/// \brief Function called after the window has been created
///
@ -161,7 +163,6 @@ protected:
void onResize() override;
private:
////////////////////////////////////////////////////////////
// Member data
////////////////////////////////////////////////////////////

View File

@ -29,10 +29,12 @@
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Graphics/Export.hpp>
#include <SFML/Graphics/Glsl.hpp>
#include <SFML/Window/GlResource.hpp>
#include <SFML/System/Vector2.hpp>
#include <SFML/System/Vector3.hpp>
#include <SFML/Window/GlResource.hpp>
#include <filesystem>
#include <string>
#include <unordered_map>
@ -52,7 +54,6 @@ class Transform;
class SFML_GRAPHICS_API Shader : GlResource
{
public:
////////////////////////////////////////////////////////////
/// \brief Types of shaders
///
@ -71,7 +72,9 @@ public:
/// \see setUniform(const std::string&, CurrentTextureType)
///
////////////////////////////////////////////////////////////
struct CurrentTextureType {};
struct CurrentTextureType
{
};
////////////////////////////////////////////////////////////
/// \brief Represents the texture of the object being drawn
@ -82,7 +85,6 @@ public:
static CurrentTextureType CurrentTexture;
public:
////////////////////////////////////////////////////////////
/// \brief Default constructor
///
@ -149,7 +151,8 @@ public:
/// \see loadFromMemory, loadFromStream
///
////////////////////////////////////////////////////////////
[[nodiscard]] bool loadFromFile(const std::filesystem::path& vertexShaderFilename, const std::filesystem::path& fragmentShaderFilename);
[[nodiscard]] bool loadFromFile(const std::filesystem::path& vertexShaderFilename,
const std::filesystem::path& fragmentShaderFilename);
////////////////////////////////////////////////////////////
/// \brief Load the vertex, geometry and fragment shaders from files
@ -171,7 +174,9 @@ public:
/// \see loadFromMemory, loadFromStream
///
////////////////////////////////////////////////////////////
[[nodiscard]] bool loadFromFile(const std::filesystem::path& vertexShaderFilename, const std::filesystem::path& geometryShaderFilename, const std::filesystem::path& fragmentShaderFilename);
[[nodiscard]] bool loadFromFile(const std::filesystem::path& vertexShaderFilename,
const std::filesystem::path& geometryShaderFilename,
const std::filesystem::path& fragmentShaderFilename);
////////////////////////////////////////////////////////////
/// \brief Load the vertex, geometry or fragment shader from a source code in memory
@ -234,7 +239,9 @@ public:
/// \see loadFromFile, loadFromStream
///
////////////////////////////////////////////////////////////
[[nodiscard]] bool loadFromMemory(const std::string& vertexShader, const std::string& geometryShader, const std::string& fragmentShader);
[[nodiscard]] bool loadFromMemory(const std::string& vertexShader,
const std::string& geometryShader,
const std::string& fragmentShader);
////////////////////////////////////////////////////////////
/// \brief Load the vertex, geometry or fragment shader from a custom stream
@ -297,7 +304,9 @@ public:
/// \see loadFromFile, loadFromMemory
///
////////////////////////////////////////////////////////////
[[nodiscard]] bool loadFromStream(InputStream& vertexShaderStream, InputStream& geometryShaderStream, InputStream& fragmentShaderStream);
[[nodiscard]] bool loadFromStream(InputStream& vertexShaderStream,
InputStream& geometryShaderStream,
InputStream& fragmentShaderStream);
////////////////////////////////////////////////////////////
/// \brief Specify value for \p float uniform
@ -624,7 +633,6 @@ public:
static bool isGeometryAvailable();
private:
////////////////////////////////////////////////////////////
/// \brief Compile the shader(s) and create the program
///
@ -671,7 +679,7 @@ private:
////////////////////////////////////////////////////////////
// Types
////////////////////////////////////////////////////////////
using TextureTable = std::unordered_map<int, const Texture *>;
using TextureTable = std::unordered_map<int, const Texture*>;
using UniformTable = std::unordered_map<std::string, int>;
////////////////////////////////////////////////////////////

View File

@ -29,6 +29,7 @@
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Graphics/Export.hpp>
#include <SFML/Graphics/Drawable.hpp>
#include <SFML/Graphics/Transformable.hpp>
#include <SFML/Graphics/VertexArray.hpp>
@ -46,7 +47,6 @@ class Texture;
class SFML_GRAPHICS_API Shape : public Drawable, public Transformable
{
public:
////////////////////////////////////////////////////////////
/// \brief Virtual destructor
///
@ -250,7 +250,6 @@ public:
FloatRect getGlobalBounds() const;
protected:
////////////////////////////////////////////////////////////
/// \brief Default constructor
///
@ -268,7 +267,6 @@ protected:
void update();
private:
////////////////////////////////////////////////////////////
/// \brief Draw the shape to a render target
///
@ -303,7 +301,6 @@ private:
void updateOutlineColors();
private:
////////////////////////////////////////////////////////////
// Member data
////////////////////////////////////////////////////////////

View File

@ -29,10 +29,11 @@
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Graphics/Export.hpp>
#include <SFML/Graphics/Drawable.hpp>
#include <SFML/Graphics/Rect.hpp>
#include <SFML/Graphics/Transformable.hpp>
#include <SFML/Graphics/Vertex.hpp>
#include <SFML/Graphics/Rect.hpp>
namespace sf
@ -47,7 +48,6 @@ class Texture;
class SFML_GRAPHICS_API Sprite : public Drawable, public Transformable
{
public:
////////////////////////////////////////////////////////////
/// \brief Default constructor
///
@ -190,7 +190,6 @@ public:
FloatRect getGlobalBounds() const;
private:
////////////////////////////////////////////////////////////
/// \brief Draw the sprite to a render target
///

View File

@ -29,11 +29,13 @@
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Graphics/Export.hpp>
#include <SFML/Graphics/Drawable.hpp>
#include <SFML/Graphics/Transformable.hpp>
#include <SFML/Graphics/Rect.hpp>
#include <SFML/Graphics/Transformable.hpp>
#include <SFML/Graphics/VertexArray.hpp>
#include <SFML/System/String.hpp>
#include <string>
#include <vector>
@ -49,7 +51,6 @@ class Font;
class SFML_GRAPHICS_API Text : public Drawable, public Transformable
{
public:
////////////////////////////////////////////////////////////
/// \brief Enumeration of the string drawing styles
///
@ -406,7 +407,6 @@ public:
FloatRect getGlobalBounds() const;
private:
////////////////////////////////////////////////////////////
/// \brief Draw the text to a render target
///

View File

@ -29,8 +29,10 @@
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Graphics/Export.hpp>
#include <SFML/Window/GlResource.hpp>
#include <SFML/Graphics/Rect.hpp>
#include <SFML/Window/GlResource.hpp>
#include <filesystem>
@ -50,7 +52,6 @@ class Image;
class SFML_GRAPHICS_API Texture : GlResource
{
public:
////////////////////////////////////////////////////////////
/// \brief Types of texture coordinates that can be used for rendering
///
@ -62,7 +63,6 @@ public:
};
public:
////////////////////////////////////////////////////////////
/// \brief Default constructor
///
@ -512,7 +512,7 @@ public:
/// \return Reference to self
///
////////////////////////////////////////////////////////////
Texture& operator =(const Texture& right);
Texture& operator=(const Texture& right);
////////////////////////////////////////////////////////////
/// \brief Swap the contents of this texture with those of another
@ -580,7 +580,6 @@ public:
static unsigned int getMaximumSize();
private:
friend class Text;
friend class RenderTexture;
friend class RenderTarget;

View File

@ -29,6 +29,7 @@
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Graphics/Export.hpp>
#include <SFML/Graphics/Rect.hpp>
#include <SFML/System/Vector2.hpp>
@ -44,7 +45,6 @@ class Angle;
class Transform
{
public:
////////////////////////////////////////////////////////////
/// \brief Default constructor
///
@ -67,9 +67,7 @@ public:
/// \param a22 Element (2, 2) of the matrix
///
////////////////////////////////////////////////////////////
constexpr Transform(float a00, float a01, float a02,
float a10, float a11, float a12,
float a20, float a21, float a22);
constexpr Transform(float a00, float a01, float a02, float a10, float a11, float a12, float a20, float a21, float a22);
////////////////////////////////////////////////////////////
/// \brief Return the transform as a 4x4 matrix
@ -264,7 +262,6 @@ public:
static const Transform Identity; //!< The identity transform (does nothing)
private:
////////////////////////////////////////////////////////////
// Member data
////////////////////////////////////////////////////////////
@ -283,7 +280,7 @@ private:
/// \return New combined transform
///
////////////////////////////////////////////////////////////
constexpr Transform operator *(const Transform& left, const Transform& right);
constexpr Transform operator*(const Transform& left, const Transform& right);
////////////////////////////////////////////////////////////
/// \relates sf::Transform
@ -297,7 +294,7 @@ constexpr Transform operator *(const Transform& left, const Transform& right);
/// \return The combined transform
///
////////////////////////////////////////////////////////////
constexpr Transform& operator *=(Transform& left, const Transform& right);
constexpr Transform& operator*=(Transform& left, const Transform& right);
////////////////////////////////////////////////////////////
/// \relates sf::Transform
@ -311,7 +308,7 @@ constexpr Transform& operator *=(Transform& left, const Transform& right);
/// \return New transformed point
///
////////////////////////////////////////////////////////////
constexpr Vector2f operator *(const Transform& left, const Vector2f& right);
constexpr Vector2f operator*(const Transform& left, const Vector2f& right);
////////////////////////////////////////////////////////////
/// \relates sf::Transform
@ -326,7 +323,7 @@ constexpr Vector2f operator *(const Transform& left, const Vector2f& right);
/// \return true if the transforms are equal, false otherwise
///
////////////////////////////////////////////////////////////
[[nodiscard]] constexpr bool operator ==(const Transform& left, const Transform& right);
[[nodiscard]] constexpr bool operator==(const Transform& left, const Transform& right);
////////////////////////////////////////////////////////////
/// \relates sf::Transform
@ -340,7 +337,7 @@ constexpr Vector2f operator *(const Transform& left, const Vector2f& right);
/// \return true if the transforms are not equal, false otherwise
///
////////////////////////////////////////////////////////////
[[nodiscard]] constexpr bool operator !=(const Transform& left, const Transform& right);
[[nodiscard]] constexpr bool operator!=(const Transform& left, const Transform& right);
#include <SFML/Graphics/Transform.inl>

View File

@ -102,13 +102,10 @@ constexpr Vector2f Transform::transformPoint(const Vector2f& point) const
constexpr FloatRect Transform::transformRect(const FloatRect& rectangle) const
{
// Transform the 4 corners of the rectangle
const Vector2f points[] =
{
transformPoint({rectangle.left, rectangle.top}),
const Vector2f points[] = {transformPoint({rectangle.left, rectangle.top}),
transformPoint({rectangle.left, rectangle.top + rectangle.height}),
transformPoint({rectangle.left + rectangle.width, rectangle.top}),
transformPoint({rectangle.left + rectangle.width, rectangle.top + rectangle.height})
};
transformPoint({rectangle.left + rectangle.width, rectangle.top + rectangle.height})};
// Compute the bounding rectangle of the transformed points
float left = points[0].x;
@ -193,28 +190,28 @@ constexpr Transform& Transform::scale(const Vector2f& factors, const Vector2f& c
////////////////////////////////////////////////////////////
constexpr Transform operator *(const Transform& left, const Transform& right)
constexpr Transform operator*(const Transform& left, const Transform& right)
{
return Transform(left).combine(right);
}
////////////////////////////////////////////////////////////
constexpr Transform& operator *=(Transform& left, const Transform& right)
constexpr Transform& operator*=(Transform& left, const Transform& right)
{
return left.combine(right);
}
////////////////////////////////////////////////////////////
constexpr Vector2f operator *(const Transform& left, const Vector2f& right)
constexpr Vector2f operator*(const Transform& left, const Vector2f& right)
{
return left.transformPoint(right);
}
////////////////////////////////////////////////////////////
constexpr bool operator ==(const Transform& left, const Transform& right)
constexpr bool operator==(const Transform& left, const Transform& right)
{
const float* a = left.getMatrix();
const float* b = right.getMatrix();
@ -228,7 +225,7 @@ constexpr bool operator ==(const Transform& left, const Transform& right)
////////////////////////////////////////////////////////////
constexpr bool operator !=(const Transform& left, const Transform& right)
constexpr bool operator!=(const Transform& left, const Transform& right)
{
return !(left == right);
}

View File

@ -29,6 +29,7 @@
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Graphics/Export.hpp>
#include <SFML/Graphics/Transform.hpp>
#include <SFML/System/Angle.hpp>
@ -42,7 +43,6 @@ namespace sf
class SFML_GRAPHICS_API Transformable
{
public:
////////////////////////////////////////////////////////////
/// \brief Default constructor
///
@ -227,7 +227,6 @@ public:
const Transform& getInverseTransform() const;
private:
////////////////////////////////////////////////////////////
// Member data
////////////////////////////////////////////////////////////

View File

@ -41,7 +41,6 @@ namespace sf
class Vertex
{
public:
////////////////////////////////////////////////////////////
/// \brief Default constructor
///

View File

@ -24,27 +24,21 @@
////////////////////////////////////////////////////////////
constexpr Vertex::Vertex() :
position (0, 0),
color (255, 255, 255),
texCoords(0, 0)
constexpr Vertex::Vertex() : position(0, 0), color(255, 255, 255), texCoords(0, 0)
{
}
////////////////////////////////////////////////////////////
constexpr Vertex::Vertex(const Vector2f& thePosition) :
position (thePosition),
color (255, 255, 255),
texCoords(0, 0)
constexpr Vertex::Vertex(const Vector2f& thePosition) : position(thePosition), color(255, 255, 255), texCoords(0, 0)
{
}
////////////////////////////////////////////////////////////
constexpr Vertex::Vertex(const Vector2f& thePosition, const Color& theColor) :
position (thePosition),
color (theColor),
position(thePosition),
color(theColor),
texCoords(0, 0)
{
}
@ -52,8 +46,8 @@ texCoords(0, 0)
////////////////////////////////////////////////////////////
constexpr Vertex::Vertex(const Vector2f& thePosition, const Vector2f& theTexCoords) :
position (thePosition),
color (255, 255, 255),
position(thePosition),
color(255, 255, 255),
texCoords(theTexCoords)
{
}
@ -61,8 +55,8 @@ texCoords(theTexCoords)
////////////////////////////////////////////////////////////
constexpr Vertex::Vertex(const Vector2f& thePosition, const Color& theColor, const Vector2f& theTexCoords) :
position (thePosition),
color (theColor),
position(thePosition),
color(theColor),
texCoords(theTexCoords)
{
}

View File

@ -29,10 +29,12 @@
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Graphics/Export.hpp>
#include <SFML/Graphics/Vertex.hpp>
#include <SFML/Graphics/Drawable.hpp>
#include <SFML/Graphics/PrimitiveType.hpp>
#include <SFML/Graphics/Rect.hpp>
#include <SFML/Graphics/Drawable.hpp>
#include <SFML/Graphics/Vertex.hpp>
#include <vector>
@ -45,7 +47,6 @@ namespace sf
class SFML_GRAPHICS_API VertexArray : public Drawable
{
public:
////////////////////////////////////////////////////////////
/// \brief Default constructor
///
@ -85,7 +86,7 @@ public:
/// \see getVertexCount
///
////////////////////////////////////////////////////////////
Vertex& operator [](std::size_t index);
Vertex& operator[](std::size_t index);
////////////////////////////////////////////////////////////
/// \brief Get a read-only access to a vertex by its index
@ -101,7 +102,7 @@ public:
/// \see getVertexCount
///
////////////////////////////////////////////////////////////
const Vertex& operator [](std::size_t index) const;
const Vertex& operator[](std::size_t index) const;
////////////////////////////////////////////////////////////
/// \brief Clear the vertex array
@ -171,7 +172,6 @@ public:
FloatRect getBounds() const;
private:
////////////////////////////////////////////////////////////
/// \brief Draw the vertex array to a render target
///
@ -182,7 +182,6 @@ private:
void draw(RenderTarget& target, const RenderStates& states) const override;
private:
////////////////////////////////////////////////////////////
// Member data
////////////////////////////////////////////////////////////

View File

@ -29,9 +29,11 @@
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Graphics/Export.hpp>
#include <SFML/Graphics/PrimitiveType.hpp>
#include <SFML/Graphics/Drawable.hpp>
#include <SFML/Graphics/PrimitiveType.hpp>
#include <SFML/Window/GlResource.hpp>
#include <cstddef>
@ -47,7 +49,6 @@ class Vertex;
class SFML_GRAPHICS_API VertexBuffer : public Drawable, private GlResource
{
public:
////////////////////////////////////////////////////////////
/// \brief Usage specifiers
///
@ -216,7 +217,7 @@ public:
/// \return Reference to self
///
////////////////////////////////////////////////////////////
VertexBuffer& operator =(const VertexBuffer& right);
VertexBuffer& operator=(const VertexBuffer& right);
////////////////////////////////////////////////////////////
/// \brief Swap the contents of this vertex buffer with those of another
@ -320,7 +321,6 @@ public:
static bool isAvailable();
private:
////////////////////////////////////////////////////////////
/// \brief Draw the vertex buffer to a render target
///
@ -331,7 +331,6 @@ private:
void draw(RenderTarget& target, const RenderStates& states) const override;
private:
////////////////////////////////////////////////////////////
// Member data
////////////////////////////////////////////////////////////

View File

@ -29,6 +29,7 @@
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Graphics/Export.hpp>
#include <SFML/Graphics/Rect.hpp>
#include <SFML/Graphics/Transform.hpp>
#include <SFML/System/Angle.hpp>
@ -44,7 +45,6 @@ namespace sf
class SFML_GRAPHICS_API View
{
public:
////////////////////////////////////////////////////////////
/// \brief Default constructor
///
@ -233,7 +233,6 @@ public:
const Transform& getInverseTransform() const;
private:
////////////////////////////////////////////////////////////
// Member data
////////////////////////////////////////////////////////////

View File

@ -33,9 +33,9 @@
#if defined(SFML_SYSTEM_IOS)
// On iOS, we have no choice but to have our own main,
// so we need to rename the user one and call it later
#define main sfmlMain
// On iOS, we have no choice but to have our own main,
// so we need to rename the user one and call it later
#define main sfmlMain
#endif

View File

@ -29,7 +29,6 @@
// Headers
////////////////////////////////////////////////////////////
#include <SFML/System.hpp>
#include <SFML/Network/Ftp.hpp>
#include <SFML/Network/Http.hpp>
#include <SFML/Network/IpAddress.hpp>
@ -40,6 +39,7 @@
#include <SFML/Network/TcpListener.hpp>
#include <SFML/Network/TcpSocket.hpp>
#include <SFML/Network/UdpSocket.hpp>
#include <SFML/System.hpp>
#endif // SFML_NETWORK_HPP

View File

@ -36,11 +36,11 @@
////////////////////////////////////////////////////////////
#if defined(SFML_NETWORK_EXPORTS)
#define SFML_NETWORK_API SFML_API_EXPORT
#define SFML_NETWORK_API SFML_API_EXPORT
#else
#define SFML_NETWORK_API SFML_API_IMPORT
#define SFML_NETWORK_API SFML_API_IMPORT
#endif

View File

@ -29,8 +29,10 @@
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Network/Export.hpp>
#include <SFML/Network/TcpSocket.hpp>
#include <SFML/System/Time.hpp>
#include <filesystem>
#include <string>
#include <vector>
@ -47,7 +49,6 @@ class IpAddress;
class SFML_NETWORK_API Ftp
{
public:
////////////////////////////////////////////////////////////
/// \brief Enumeration of transfer modes
///
@ -66,7 +67,6 @@ public:
class SFML_NETWORK_API Response
{
public:
////////////////////////////////////////////////////////////
/// \brief Status codes possibly returned by a FTP response
///
@ -173,7 +173,6 @@ public:
const std::string& getMessage() const;
private:
////////////////////////////////////////////////////////////
// Member data
////////////////////////////////////////////////////////////
@ -188,7 +187,6 @@ public:
class SFML_NETWORK_API DirectoryResponse : public Response
{
public:
////////////////////////////////////////////////////////////
/// \brief Default constructor
///
@ -206,7 +204,6 @@ public:
const std::filesystem::path& getDirectory() const;
private:
////////////////////////////////////////////////////////////
// Member data
////////////////////////////////////////////////////////////
@ -221,7 +218,6 @@ public:
class SFML_NETWORK_API ListingResponse : public Response
{
public:
////////////////////////////////////////////////////////////
/// \brief Default constructor
///
@ -240,7 +236,6 @@ public:
const std::vector<std::string>& getListing() const;
private:
////////////////////////////////////////////////////////////
// Member data
////////////////////////////////////////////////////////////
@ -482,7 +477,9 @@ public:
/// \see upload
///
////////////////////////////////////////////////////////////
[[nodiscard]] Response download(const std::filesystem::path& remoteFile, const std::filesystem::path& localPath, TransferMode mode = Binary);
[[nodiscard]] Response download(const std::filesystem::path& remoteFile,
const std::filesystem::path& localPath,
TransferMode mode = Binary);
////////////////////////////////////////////////////////////
/// \brief Upload a file to the server
@ -505,7 +502,10 @@ public:
/// \see download
///
////////////////////////////////////////////////////////////
[[nodiscard]] Response upload(const std::string& localFile, const std::string& remotePath, TransferMode mode = Binary, bool append = false);
[[nodiscard]] Response upload(const std::string& localFile,
const std::string& remotePath,
TransferMode mode = Binary,
bool append = false);
////////////////////////////////////////////////////////////
/// \brief Send a command to the FTP server
@ -526,7 +526,6 @@ public:
[[nodiscard]] Response sendCommand(const std::string& command, const std::string& parameter = "");
private:
////////////////////////////////////////////////////////////
/// \brief Receive a response from the server
///

View File

@ -29,9 +29,11 @@
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Network/Export.hpp>
#include <SFML/Network/IpAddress.hpp>
#include <SFML/Network/TcpSocket.hpp>
#include <SFML/System/Time.hpp>
#include <map>
#include <optional>
#include <string>
@ -46,7 +48,6 @@ namespace sf
class SFML_NETWORK_API Http
{
public:
////////////////////////////////////////////////////////////
/// \brief Define a HTTP request
///
@ -54,7 +55,6 @@ public:
class SFML_NETWORK_API Request
{
public:
////////////////////////////////////////////////////////////
/// \brief Enumerate the available HTTP methods for a request
///
@ -144,7 +144,6 @@ public:
void setBody(const std::string& body);
private:
friend class Http;
////////////////////////////////////////////////////////////
@ -193,7 +192,6 @@ public:
class SFML_NETWORK_API Response
{
public:
////////////////////////////////////////////////////////////
/// \brief Enumerate all the valid status codes for a response
///
@ -304,7 +302,6 @@ public:
const std::string& getBody() const;
private:
friend class Http;
////////////////////////////////////////////////////////////
@ -328,7 +325,7 @@ public:
/// \param in String stream containing the header values
///
////////////////////////////////////////////////////////////
void parseFields(std::istream &in);
void parseFields(std::istream& in);
////////////////////////////////////////////////////////////
// Types
@ -417,7 +414,6 @@ public:
[[nodiscard]] Response sendRequest(const Request& request, Time timeout = Time::Zero);
private:
////////////////////////////////////////////////////////////
// Member data
////////////////////////////////////////////////////////////

View File

@ -29,11 +29,13 @@
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Network/Export.hpp>
#include <SFML/System/Time.hpp>
#include <iosfwd>
#include <optional>
#include <string_view>
#include <string>
#include <string_view>
namespace sf
@ -164,8 +166,7 @@ public:
static const IpAddress Broadcast; //!< The "broadcast" address (for sending UDP messages to everyone on a local network)
private:
friend SFML_NETWORK_API bool operator <(const IpAddress& left, const IpAddress& right);
friend SFML_NETWORK_API bool operator<(const IpAddress& left, const IpAddress& right);
////////////////////////////////////////////////////////////
// Member data
@ -182,7 +183,7 @@ private:
/// \return True if both addresses are equal
///
////////////////////////////////////////////////////////////
SFML_NETWORK_API bool operator ==(const IpAddress& left, const IpAddress& right);
SFML_NETWORK_API bool operator==(const IpAddress& left, const IpAddress& right);
////////////////////////////////////////////////////////////
/// \brief Overload of != operator to compare two IP addresses
@ -193,7 +194,7 @@ SFML_NETWORK_API bool operator ==(const IpAddress& left, const IpAddress& right)
/// \return True if both addresses are different
///
////////////////////////////////////////////////////////////
SFML_NETWORK_API bool operator !=(const IpAddress& left, const IpAddress& right);
SFML_NETWORK_API bool operator!=(const IpAddress& left, const IpAddress& right);
////////////////////////////////////////////////////////////
/// \brief Overload of < operator to compare two IP addresses
@ -204,7 +205,7 @@ SFML_NETWORK_API bool operator !=(const IpAddress& left, const IpAddress& right)
/// \return True if \a left is lesser than \a right
///
////////////////////////////////////////////////////////////
SFML_NETWORK_API bool operator <(const IpAddress& left, const IpAddress& right);
SFML_NETWORK_API bool operator<(const IpAddress& left, const IpAddress& right);
////////////////////////////////////////////////////////////
/// \brief Overload of > operator to compare two IP addresses
@ -215,7 +216,7 @@ SFML_NETWORK_API bool operator <(const IpAddress& left, const IpAddress& right);
/// \return True if \a left is greater than \a right
///
////////////////////////////////////////////////////////////
SFML_NETWORK_API bool operator >(const IpAddress& left, const IpAddress& right);
SFML_NETWORK_API bool operator>(const IpAddress& left, const IpAddress& right);
////////////////////////////////////////////////////////////
/// \brief Overload of <= operator to compare two IP addresses
@ -226,7 +227,7 @@ SFML_NETWORK_API bool operator >(const IpAddress& left, const IpAddress& right);
/// \return True if \a left is lesser or equal than \a right
///
////////////////////////////////////////////////////////////
SFML_NETWORK_API bool operator <=(const IpAddress& left, const IpAddress& right);
SFML_NETWORK_API bool operator<=(const IpAddress& left, const IpAddress& right);
////////////////////////////////////////////////////////////
/// \brief Overload of >= operator to compare two IP addresses
@ -237,7 +238,7 @@ SFML_NETWORK_API bool operator <=(const IpAddress& left, const IpAddress& right)
/// \return True if \a left is greater or equal than \a right
///
////////////////////////////////////////////////////////////
SFML_NETWORK_API bool operator >=(const IpAddress& left, const IpAddress& right);
SFML_NETWORK_API bool operator>=(const IpAddress& left, const IpAddress& right);
////////////////////////////////////////////////////////////
/// \brief Overload of >> operator to extract an IP address from an input stream
@ -248,7 +249,7 @@ SFML_NETWORK_API bool operator >=(const IpAddress& left, const IpAddress& right)
/// \return Reference to the input stream
///
////////////////////////////////////////////////////////////
SFML_NETWORK_API std::istream& operator >>(std::istream& stream, std::optional<IpAddress>& address);
SFML_NETWORK_API std::istream& operator>>(std::istream& stream, std::optional<IpAddress>& address);
////////////////////////////////////////////////////////////
/// \brief Overload of << operator to print an IP address to an output stream
@ -259,7 +260,7 @@ SFML_NETWORK_API std::istream& operator >>(std::istream& stream, std::optional<I
/// \return Reference to the output stream
///
////////////////////////////////////////////////////////////
SFML_NETWORK_API std::ostream& operator <<(std::ostream& stream, const IpAddress& address);
SFML_NETWORK_API std::ostream& operator<<(std::ostream& stream, const IpAddress& address);
} // namespace sf

View File

@ -29,9 +29,10 @@
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Network/Export.hpp>
#include <cstddef>
#include <string>
#include <vector>
#include <cstddef>
namespace sf
@ -48,7 +49,6 @@ class UdpSocket;
class SFML_NETWORK_API Packet
{
public:
////////////////////////////////////////////////////////////
/// \brief Default constructor
///
@ -164,7 +164,6 @@ public:
bool endOfPacket() const;
public:
////////////////////////////////////////////////////////////
/// \brief Test the validity of the packet, for reading
///
@ -209,166 +208,165 @@ public:
/// Overload of operator >> to read data from the packet
///
////////////////////////////////////////////////////////////
Packet& operator >>(bool& data);
Packet& operator>>(bool& data);
////////////////////////////////////////////////////////////
/// \overload
////////////////////////////////////////////////////////////
Packet& operator >>(Int8& data);
Packet& operator>>(Int8& data);
////////////////////////////////////////////////////////////
/// \overload
////////////////////////////////////////////////////////////
Packet& operator >>(Uint8& data);
Packet& operator>>(Uint8& data);
////////////////////////////////////////////////////////////
/// \overload
////////////////////////////////////////////////////////////
Packet& operator >>(Int16& data);
Packet& operator>>(Int16& data);
////////////////////////////////////////////////////////////
/// \overload
////////////////////////////////////////////////////////////
Packet& operator >>(Uint16& data);
Packet& operator>>(Uint16& data);
////////////////////////////////////////////////////////////
/// \overload
////////////////////////////////////////////////////////////
Packet& operator >>(Int32& data);
Packet& operator>>(Int32& data);
////////////////////////////////////////////////////////////
/// \overload
////////////////////////////////////////////////////////////
Packet& operator >>(Uint32& data);
Packet& operator>>(Uint32& data);
////////////////////////////////////////////////////////////
/// \overload
////////////////////////////////////////////////////////////
Packet& operator >>(Int64& data);
Packet& operator>>(Int64& data);
////////////////////////////////////////////////////////////
/// \overload
////////////////////////////////////////////////////////////
Packet& operator >>(Uint64& data);
Packet& operator>>(Uint64& data);
////////////////////////////////////////////////////////////
/// \overload
////////////////////////////////////////////////////////////
Packet& operator >>(float& data);
Packet& operator>>(float& data);
////////////////////////////////////////////////////////////
/// \overload
////////////////////////////////////////////////////////////
Packet& operator >>(double& data);
Packet& operator>>(double& data);
////////////////////////////////////////////////////////////
/// \overload
////////////////////////////////////////////////////////////
Packet& operator >>(char* data);
Packet& operator>>(char* data);
////////////////////////////////////////////////////////////
/// \overload
////////////////////////////////////////////////////////////
Packet& operator >>(std::string& data);
Packet& operator>>(std::string& data);
////////////////////////////////////////////////////////////
/// \overload
////////////////////////////////////////////////////////////
Packet& operator >>(wchar_t* data);
Packet& operator>>(wchar_t* data);
////////////////////////////////////////////////////////////
/// \overload
////////////////////////////////////////////////////////////
Packet& operator >>(std::wstring& data);
Packet& operator>>(std::wstring& data);
////////////////////////////////////////////////////////////
/// \overload
////////////////////////////////////////////////////////////
Packet& operator >>(String& data);
Packet& operator>>(String& data);
////////////////////////////////////////////////////////////
/// Overload of operator << to write data into the packet
///
////////////////////////////////////////////////////////////
Packet& operator <<(bool data);
Packet& operator<<(bool data);
////////////////////////////////////////////////////////////
/// \overload
////////////////////////////////////////////////////////////
Packet& operator <<(Int8 data);
Packet& operator<<(Int8 data);
////////////////////////////////////////////////////////////
/// \overload
////////////////////////////////////////////////////////////
Packet& operator <<(Uint8 data);
Packet& operator<<(Uint8 data);
////////////////////////////////////////////////////////////
/// \overload
////////////////////////////////////////////////////////////
Packet& operator <<(Int16 data);
Packet& operator<<(Int16 data);
////////////////////////////////////////////////////////////
/// \overload
////////////////////////////////////////////////////////////
Packet& operator <<(Uint16 data);
Packet& operator<<(Uint16 data);
////////////////////////////////////////////////////////////
/// \overload
////////////////////////////////////////////////////////////
Packet& operator <<(Int32 data);
Packet& operator<<(Int32 data);
////////////////////////////////////////////////////////////
/// \overload
////////////////////////////////////////////////////////////
Packet& operator <<(Uint32 data);
Packet& operator<<(Uint32 data);
////////////////////////////////////////////////////////////
/// \overload
////////////////////////////////////////////////////////////
Packet& operator <<(Int64 data);
Packet& operator<<(Int64 data);
////////////////////////////////////////////////////////////
/// \overload
////////////////////////////////////////////////////////////
Packet& operator <<(Uint64 data);
Packet& operator<<(Uint64 data);
////////////////////////////////////////////////////////////
/// \overload
////////////////////////////////////////////////////////////
Packet& operator <<(float data);
Packet& operator<<(float data);
////////////////////////////////////////////////////////////
/// \overload
////////////////////////////////////////////////////////////
Packet& operator <<(double data);
Packet& operator<<(double data);
////////////////////////////////////////////////////////////
/// \overload
////////////////////////////////////////////////////////////
Packet& operator <<(const char* data);
Packet& operator<<(const char* data);
////////////////////////////////////////////////////////////
/// \overload
////////////////////////////////////////////////////////////
Packet& operator <<(const std::string& data);
Packet& operator<<(const std::string& data);
////////////////////////////////////////////////////////////
/// \overload
////////////////////////////////////////////////////////////
Packet& operator <<(const wchar_t* data);
Packet& operator<<(const wchar_t* data);
////////////////////////////////////////////////////////////
/// \overload
////////////////////////////////////////////////////////////
Packet& operator <<(const std::wstring& data);
Packet& operator<<(const std::wstring& data);
////////////////////////////////////////////////////////////
/// \overload
////////////////////////////////////////////////////////////
Packet& operator <<(const String& data);
Packet& operator<<(const String& data);
protected:
friend class TcpSocket;
friend class UdpSocket;
@ -412,13 +410,12 @@ protected:
virtual void onReceive(const void* data, std::size_t size);
private:
////////////////////////////////////////////////////////////
/// Disallow comparisons between packets
///
////////////////////////////////////////////////////////////
bool operator ==(const Packet& right) const;
bool operator !=(const Packet& right) const;
bool operator==(const Packet& right) const;
bool operator!=(const Packet& right) const;
////////////////////////////////////////////////////////////
/// \brief Check if the packet can extract a given number of bytes

View File

@ -29,7 +29,9 @@
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Network/Export.hpp>
#include <SFML/Network/SocketHandle.hpp>
#include <vector>
@ -44,7 +46,6 @@ class SocketSelector;
class SFML_NETWORK_API Socket
{
public:
////////////////////////////////////////////////////////////
/// \brief Status codes that may be returned by socket functions
///
@ -68,7 +69,6 @@ public:
};
public:
////////////////////////////////////////////////////////////
/// \brief Destructor
///
@ -117,7 +117,6 @@ public:
bool isBlocking() const;
protected:
////////////////////////////////////////////////////////////
/// \brief Types of protocols that the socket can use
///
@ -178,7 +177,6 @@ protected:
void close();
private:
friend class SocketSelector;
////////////////////////////////////////////////////////////

View File

@ -31,7 +31,7 @@
#include <SFML/Config.hpp>
#if defined(SFML_SYSTEM_WINDOWS)
#include <basetsd.h>
#include <basetsd.h>
#endif
@ -43,11 +43,11 @@ namespace sf
////////////////////////////////////////////////////////////
#if defined(SFML_SYSTEM_WINDOWS)
using SocketHandle = UINT_PTR;
using SocketHandle = UINT_PTR;
#else
using SocketHandle = int;
using SocketHandle = int;
#endif

View File

@ -29,7 +29,9 @@
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Network/Export.hpp>
#include <SFML/System/Time.hpp>
#include <memory>
@ -44,7 +46,6 @@ class Socket;
class SFML_NETWORK_API SocketSelector
{
public:
////////////////////////////////////////////////////////////
/// \brief Default constructor
///
@ -150,10 +151,9 @@ public:
/// \return Reference to self
///
////////////////////////////////////////////////////////////
SocketSelector& operator =(const SocketSelector& right);
SocketSelector& operator=(const SocketSelector& right);
private:
struct SocketSelectorImpl;
////////////////////////////////////////////////////////////

View File

@ -29,8 +29,9 @@
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Network/Export.hpp>
#include <SFML/Network/Socket.hpp>
#include <SFML/Network/IpAddress.hpp>
#include <SFML/Network/Socket.hpp>
namespace sf
@ -44,7 +45,6 @@ class TcpSocket;
class SFML_NETWORK_API TcpListener : public Socket
{
public:
////////////////////////////////////////////////////////////
/// \brief Default constructor
///

View File

@ -29,8 +29,10 @@
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Network/Export.hpp>
#include <SFML/Network/Socket.hpp>
#include <SFML/System/Time.hpp>
#include <optional>
@ -47,7 +49,6 @@ class Packet;
class SFML_NETWORK_API TcpSocket : public Socket
{
public:
////////////////////////////////////////////////////////////
/// \brief Default constructor
///
@ -210,7 +211,6 @@ public:
[[nodiscard]] Status receive(Packet& packet);
private:
friend class TcpListener;
////////////////////////////////////////////////////////////

View File

@ -29,8 +29,10 @@
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Network/Export.hpp>
#include <SFML/Network/Socket.hpp>
#include <SFML/Network/IpAddress.hpp>
#include <SFML/Network/Socket.hpp>
#include <optional>
#include <vector>
@ -46,7 +48,6 @@ class Packet;
class SFML_NETWORK_API UdpSocket : public Socket
{
public:
////////////////////////////////////////////////////////////
// Constants
////////////////////////////////////////////////////////////
@ -153,7 +154,11 @@ public:
/// \see send
///
////////////////////////////////////////////////////////////
[[nodiscard]] Status receive(void* data, std::size_t size, std::size_t& received, std::optional<IpAddress>& remoteAddress, unsigned short& remotePort);
[[nodiscard]] Status receive(void* data,
std::size_t size,
std::size_t& received,
std::optional<IpAddress>& remoteAddress,
unsigned short& remotePort);
////////////////////////////////////////////////////////////
/// \brief Send a formatted packet of data to a remote peer
@ -191,7 +196,6 @@ public:
[[nodiscard]] Status receive(Packet& packet, std::optional<IpAddress>& remoteAddress, unsigned short& remotePort);
private:
////////////////////////////////////////////////////////////
// Member data
////////////////////////////////////////////////////////////

View File

@ -38,42 +38,43 @@
////////////////////////////////////////////////////////////
#if defined(SFML_SYSTEM_WINDOWS)
// The Visual C++ version of gl.h uses WINGDIAPI and APIENTRY but doesn't define them
#ifdef _MSC_VER
#ifndef WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN
#endif
#include <windows.h>
#endif
// The Visual C++ version of gl.h uses WINGDIAPI and APIENTRY but doesn't define them
#ifdef _MSC_VER
#ifndef WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN
#endif
#include <windows.h>
#endif
#include <GL/gl.h>
#include <GL/gl.h>
#elif defined(SFML_SYSTEM_LINUX) || defined(SFML_SYSTEM_FREEBSD) || defined(SFML_SYSTEM_OPENBSD) || defined(SFML_SYSTEM_NETBSD)
#elif defined(SFML_SYSTEM_LINUX) || defined(SFML_SYSTEM_FREEBSD) || defined(SFML_SYSTEM_OPENBSD) || \
defined(SFML_SYSTEM_NETBSD)
#if defined(SFML_OPENGL_ES)
#include <GLES/gl.h>
#include <GLES/glext.h>
#else
#include <GL/gl.h>
#endif
#if defined(SFML_OPENGL_ES)
#include <GLES/gl.h>
#include <GLES/glext.h>
#else
#include <GL/gl.h>
#endif
#elif defined(SFML_SYSTEM_MACOS)
#include <OpenGL/gl.h>
#include <OpenGL/gl.h>
#elif defined (SFML_SYSTEM_IOS)
#elif defined(SFML_SYSTEM_IOS)
#include <OpenGLES/ES1/gl.h>
#include <OpenGLES/ES1/glext.h>
#include <OpenGLES/ES1/gl.h>
#include <OpenGLES/ES1/glext.h>
#elif defined (SFML_SYSTEM_ANDROID)
#elif defined(SFML_SYSTEM_ANDROID)
#include <GLES/gl.h>
#include <GLES/glext.h>
#include <GLES/gl.h>
#include <GLES/glext.h>
// We're not using OpenGL ES 2+ yet, but we can use the sRGB extension
#include <GLES2/gl2platform.h>
#include <GLES2/gl2ext.h>
// We're not using OpenGL ES 2+ yet, but we can use the sRGB extension
#include <GLES2/gl2ext.h>
#include <GLES2/gl2platform.h>
#endif

View File

@ -30,6 +30,7 @@
////////////////////////////////////////////////////////////
#include <SFML/Config.hpp>
#include <SFML/System/Angle.hpp>
#include <SFML/System/Clock.hpp>
#include <SFML/System/Err.hpp>

View File

@ -29,6 +29,7 @@
// Headers
////////////////////////////////////////////////////////////
#include <SFML/System/Export.hpp>
#include <cassert>
@ -41,7 +42,6 @@ namespace sf
class Angle
{
public:
////////////////////////////////////////////////////////////
/// \brief Default constructor
///
@ -142,7 +142,6 @@ public:
static const Angle Zero; //!< Predefined 0 degree angle value
private:
friend constexpr Angle degrees(float angle);
friend constexpr Angle radians(float angle);
@ -158,7 +157,6 @@ private:
constexpr explicit Angle(float degrees);
private:
////////////////////////////////////////////////////////////
// Member data
////////////////////////////////////////////////////////////
@ -199,7 +197,7 @@ private:
/// \return True if both angle values are equal
///
////////////////////////////////////////////////////////////
[[nodiscard]] constexpr bool operator ==(Angle left, Angle right);
[[nodiscard]] constexpr bool operator==(Angle left, Angle right);
////////////////////////////////////////////////////////////
/// \relates Angle
@ -211,7 +209,7 @@ private:
/// \return True if both angle values are different
///
////////////////////////////////////////////////////////////
[[nodiscard]] constexpr bool operator !=(Angle left, Angle right);
[[nodiscard]] constexpr bool operator!=(Angle left, Angle right);
////////////////////////////////////////////////////////////
/// \relates Angle
@ -223,7 +221,7 @@ private:
/// \return True if \a left is less than \a right
///
////////////////////////////////////////////////////////////
[[nodiscard]] constexpr bool operator <(Angle left, Angle right);
[[nodiscard]] constexpr bool operator<(Angle left, Angle right);
////////////////////////////////////////////////////////////
/// \relates Angle
@ -235,7 +233,7 @@ private:
/// \return True if \a left is greater than \a right
///
////////////////////////////////////////////////////////////
[[nodiscard]] constexpr bool operator >(Angle left, Angle right);
[[nodiscard]] constexpr bool operator>(Angle left, Angle right);
////////////////////////////////////////////////////////////
/// \relates Angle
@ -247,7 +245,7 @@ private:
/// \return True if \a left is less than or equal to \a right
///
////////////////////////////////////////////////////////////
[[nodiscard]] constexpr bool operator <=(Angle left, Angle right);
[[nodiscard]] constexpr bool operator<=(Angle left, Angle right);
////////////////////////////////////////////////////////////
/// \relates Angle
@ -259,7 +257,7 @@ private:
/// \return True if \a left is greater than or equal to \a right
///
////////////////////////////////////////////////////////////
[[nodiscard]] constexpr bool operator >=(Angle left, Angle right);
[[nodiscard]] constexpr bool operator>=(Angle left, Angle right);
////////////////////////////////////////////////////////////
/// \relates Angle
@ -272,7 +270,7 @@ private:
/// \return Negative of the angle value
///
////////////////////////////////////////////////////////////
[[nodiscard]] constexpr Angle operator -(Angle right);
[[nodiscard]] constexpr Angle operator-(Angle right);
////////////////////////////////////////////////////////////
/// \relates Angle
@ -284,7 +282,7 @@ private:
/// \return Sum of the two angle values
///
////////////////////////////////////////////////////////////
[[nodiscard]] constexpr Angle operator +(Angle left, Angle right);
[[nodiscard]] constexpr Angle operator+(Angle left, Angle right);
////////////////////////////////////////////////////////////
/// \relates Angle
@ -296,7 +294,7 @@ private:
/// \return Sum of the two angle values
///
////////////////////////////////////////////////////////////
constexpr Angle& operator +=(Angle& left, Angle right);
constexpr Angle& operator+=(Angle& left, Angle right);
////////////////////////////////////////////////////////////
/// \relates Angle
@ -308,7 +306,7 @@ constexpr Angle& operator +=(Angle& left, Angle right);
/// \return Difference of the two angle values
///
////////////////////////////////////////////////////////////
[[nodiscard]] constexpr Angle operator -(Angle left, Angle right);
[[nodiscard]] constexpr Angle operator-(Angle left, Angle right);
////////////////////////////////////////////////////////////
/// \relates Angle
@ -320,7 +318,7 @@ constexpr Angle& operator +=(Angle& left, Angle right);
/// \return Difference of the two angle values
///
////////////////////////////////////////////////////////////
constexpr Angle& operator -=(Angle& left, Angle right);
constexpr Angle& operator-=(Angle& left, Angle right);
////////////////////////////////////////////////////////////
/// \relates Angle
@ -332,7 +330,7 @@ constexpr Angle& operator -=(Angle& left, Angle right);
/// \return \a left multiplied by \a right
///
////////////////////////////////////////////////////////////
[[nodiscard]] constexpr Angle operator *(Angle left, float right);
[[nodiscard]] constexpr Angle operator*(Angle left, float right);
////////////////////////////////////////////////////////////
/// \relates Angle
@ -344,7 +342,7 @@ constexpr Angle& operator -=(Angle& left, Angle right);
/// \return \a left multiplied by \a right
///
////////////////////////////////////////////////////////////
[[nodiscard]] constexpr Angle operator *(float left, Angle right);
[[nodiscard]] constexpr Angle operator*(float left, Angle right);
////////////////////////////////////////////////////////////
/// \relates Angle
@ -356,7 +354,7 @@ constexpr Angle& operator -=(Angle& left, Angle right);
/// \return \a left multiplied by \a right
///
////////////////////////////////////////////////////////////
constexpr Angle& operator *=(Angle& left, float right);
constexpr Angle& operator*=(Angle& left, float right);
////////////////////////////////////////////////////////////
/// \relates Angle
@ -368,7 +366,7 @@ constexpr Angle& operator *=(Angle& left, float right);
/// \return \a left divided by \a right
///
////////////////////////////////////////////////////////////
[[nodiscard]] constexpr Angle operator /(Angle left, float right);
[[nodiscard]] constexpr Angle operator/(Angle left, float right);
////////////////////////////////////////////////////////////
/// \relates Angle
@ -380,7 +378,7 @@ constexpr Angle& operator *=(Angle& left, float right);
/// \return \a left divided by \a right
///
////////////////////////////////////////////////////////////
constexpr Angle& operator /=(Angle& left, float right);
constexpr Angle& operator/=(Angle& left, float right);
////////////////////////////////////////////////////////////
/// \relates Angle
@ -392,7 +390,7 @@ constexpr Angle& operator /=(Angle& left, float right);
/// \return \a left divided by \a right
///
////////////////////////////////////////////////////////////
[[nodiscard]] constexpr float operator /(Angle left, Angle right);
[[nodiscard]] constexpr float operator/(Angle left, Angle right);
////////////////////////////////////////////////////////////
/// \relates Angle
@ -412,7 +410,7 @@ constexpr Angle& operator /=(Angle& left, float right);
/// \return \a left modulo \a right
///
////////////////////////////////////////////////////////////
[[nodiscard]] constexpr Angle operator %(Angle left, Angle right);
[[nodiscard]] constexpr Angle operator%(Angle left, Angle right);
////////////////////////////////////////////////////////////
/// \relates Angle
@ -424,7 +422,7 @@ constexpr Angle& operator /=(Angle& left, float right);
/// \return \a left modulo \a right
///
////////////////////////////////////////////////////////////
constexpr Angle& operator %=(Angle& left, Angle right);
constexpr Angle& operator%=(Angle& left, Angle right);
namespace Literals
{
@ -438,7 +436,7 @@ namespace Literals
/// \return \a Angle
///
////////////////////////////////////////////////////////////
[[nodiscard]] constexpr Angle operator "" _deg(long double angle);
[[nodiscard]] constexpr Angle operator"" _deg(long double angle);
////////////////////////////////////////////////////////////
/// \relates sf::Angle
@ -449,7 +447,7 @@ namespace Literals
/// \return \a Angle
///
////////////////////////////////////////////////////////////
[[nodiscard]] constexpr Angle operator "" _deg(unsigned long long int angle);
[[nodiscard]] constexpr Angle operator"" _deg(unsigned long long int angle);
////////////////////////////////////////////////////////////
/// \relates sf::Angle
@ -460,7 +458,7 @@ namespace Literals
/// \return \a Angle
///
////////////////////////////////////////////////////////////
[[nodiscard]] constexpr Angle operator "" _rad(long double angle);
[[nodiscard]] constexpr Angle operator"" _rad(long double angle);
////////////////////////////////////////////////////////////
/// \relates sf::Angle
@ -471,7 +469,7 @@ namespace Literals
/// \return \a Angle
///
////////////////////////////////////////////////////////////
[[nodiscard]] constexpr Angle operator "" _rad(unsigned long long int angle);
[[nodiscard]] constexpr Angle operator"" _rad(unsigned long long int angle);
} // namespace Literals

View File

@ -24,23 +24,22 @@
namespace priv
{
constexpr float pi = 3.141592654f;
constexpr float pi = 3.141592654f;
constexpr float positiveRemainder(float a, float b)
{
constexpr float positiveRemainder(float a, float b)
{
assert(b > 0.0f);
const float val = a - static_cast<float>(static_cast<int>(a / b)) * b;
if (val >= 0.f)
return val;
else
return val + b;
}
}
} // namespace priv
////////////////////////////////////////////////////////////
constexpr Angle::Angle() :
m_degrees(0.0f)
constexpr Angle::Angle() : m_degrees(0.0f)
{
}
@ -74,8 +73,7 @@ constexpr Angle Angle::wrapUnsigned() const
////////////////////////////////////////////////////////////
constexpr Angle::Angle(float degrees) :
m_degrees(degrees)
constexpr Angle::Angle(float degrees) : m_degrees(degrees)
{
}
@ -95,133 +93,133 @@ constexpr Angle radians(float angle)
////////////////////////////////////////////////////////////
constexpr bool operator ==(Angle left, Angle right)
constexpr bool operator==(Angle left, Angle right)
{
return left.asDegrees() == right.asDegrees();
}
////////////////////////////////////////////////////////////
constexpr bool operator !=(Angle left, Angle right)
constexpr bool operator!=(Angle left, Angle right)
{
return left.asDegrees() != right.asDegrees();
}
////////////////////////////////////////////////////////////
constexpr bool operator <(Angle left, Angle right)
constexpr bool operator<(Angle left, Angle right)
{
return left.asDegrees() < right.asDegrees();
}
////////////////////////////////////////////////////////////
constexpr bool operator >(Angle left, Angle right)
constexpr bool operator>(Angle left, Angle right)
{
return left.asDegrees() > right.asDegrees();
}
////////////////////////////////////////////////////////////
constexpr bool operator <=(Angle left, Angle right)
constexpr bool operator<=(Angle left, Angle right)
{
return left.asDegrees() <= right.asDegrees();
}
////////////////////////////////////////////////////////////
constexpr bool operator >=(Angle left, Angle right)
constexpr bool operator>=(Angle left, Angle right)
{
return left.asDegrees() >= right.asDegrees();
}
////////////////////////////////////////////////////////////
constexpr Angle operator -(Angle right)
constexpr Angle operator-(Angle right)
{
return degrees(-right.asDegrees());
}
////////////////////////////////////////////////////////////
constexpr Angle operator +(Angle left, Angle right)
constexpr Angle operator+(Angle left, Angle right)
{
return degrees(left.asDegrees() + right.asDegrees());
}
////////////////////////////////////////////////////////////
constexpr Angle& operator +=(Angle& left, Angle right)
constexpr Angle& operator+=(Angle& left, Angle right)
{
return left = left + right;
}
////////////////////////////////////////////////////////////
constexpr Angle operator -(Angle left, Angle right)
constexpr Angle operator-(Angle left, Angle right)
{
return degrees(left.asDegrees() - right.asDegrees());
}
////////////////////////////////////////////////////////////
constexpr Angle& operator -=(Angle& left, Angle right)
constexpr Angle& operator-=(Angle& left, Angle right)
{
return left = left - right;
}
////////////////////////////////////////////////////////////
constexpr Angle operator *(Angle left, float right)
constexpr Angle operator*(Angle left, float right)
{
return degrees(left.asDegrees() * right);
}
////////////////////////////////////////////////////////////
constexpr Angle operator *(float left, Angle right)
constexpr Angle operator*(float left, Angle right)
{
return right * left;
}
////////////////////////////////////////////////////////////
constexpr Angle& operator *=(Angle& left, float right)
constexpr Angle& operator*=(Angle& left, float right)
{
return left = left * right;
}
////////////////////////////////////////////////////////////
constexpr Angle operator /(Angle left, float right)
constexpr Angle operator/(Angle left, float right)
{
return degrees(left.asDegrees() / right);
}
////////////////////////////////////////////////////////////
constexpr Angle& operator /=(Angle& left, float right)
constexpr Angle& operator/=(Angle& left, float right)
{
return left = left / right;
}
////////////////////////////////////////////////////////////
constexpr float operator /(Angle left, Angle right)
constexpr float operator/(Angle left, Angle right)
{
return left.asDegrees() / right.asDegrees();
}
////////////////////////////////////////////////////////////
constexpr Angle operator %(Angle left, Angle right)
constexpr Angle operator%(Angle left, Angle right)
{
return degrees(priv::positiveRemainder(left.asDegrees(), right.asDegrees()));
}
////////////////////////////////////////////////////////////
constexpr Angle& operator %=(Angle& left, Angle right)
constexpr Angle& operator%=(Angle& left, Angle right)
{
return left = left % right;
}
@ -230,28 +228,28 @@ namespace Literals
{
////////////////////////////////////////////////////////////
constexpr Angle operator "" _deg(long double angle)
constexpr Angle operator"" _deg(long double angle)
{
return degrees(static_cast<float>(angle));
}
////////////////////////////////////////////////////////////
constexpr Angle operator "" _deg(unsigned long long angle)
constexpr Angle operator"" _deg(unsigned long long angle)
{
return degrees(static_cast<float>(angle));
}
////////////////////////////////////////////////////////////
constexpr Angle operator "" _rad(long double angle)
constexpr Angle operator"" _rad(long double angle)
{
return radians(static_cast<float>(angle));
}
////////////////////////////////////////////////////////////
constexpr Angle operator "" _rad(unsigned long long angle)
constexpr Angle operator"" _rad(unsigned long long angle)
{
return radians(static_cast<float>(angle));
}

View File

@ -29,6 +29,7 @@
// Headers
////////////////////////////////////////////////////////////
#include <SFML/System/Export.hpp>
#include <chrono>
#include <ratio>
#include <type_traits>
@ -69,10 +70,9 @@ namespace priv
///
////////////////////////////////////////////////////////////
#if defined(SFML_SYSTEM_ANDROID) && defined(SFML_ANDROID_USE_SUSPEND_AWARE_CLOCK)
using MostSuitableClock = SuspendAwareClock;
using MostSuitableClock = SuspendAwareClock;
#else
using MostSuitableClock = std::conditional_t<
std::chrono::high_resolution_clock::is_steady,
using MostSuitableClock = std::conditional_t<std::chrono::high_resolution_clock::is_steady,
std::chrono::high_resolution_clock,
std::chrono::steady_clock>;
#endif
@ -88,7 +88,6 @@ class Time;
class SFML_SYSTEM_API Clock
{
public:
////////////////////////////////////////////////////////////
/// \brief Default constructor
///
@ -123,8 +122,7 @@ public:
private:
using ClockImpl = priv::MostSuitableClock;
static_assert(ClockImpl::is_steady,
"Provided implementation is not a monotonic clock");
static_assert(ClockImpl::is_steady, "Provided implementation is not a monotonic clock");
static_assert(std::ratio_less_equal<ClockImpl::period, std::micro>::value,
"Clock resolution is too low. Expecting at least a microsecond precision");

View File

@ -29,6 +29,7 @@
// Headers
////////////////////////////////////////////////////////////
#include <SFML/System/Export.hpp>
#include <iosfwd>

View File

@ -36,11 +36,11 @@
////////////////////////////////////////////////////////////
#if defined(SFML_SYSTEM_EXPORTS)
#define SFML_SYSTEM_API SFML_API_EXPORT
#define SFML_SYSTEM_API SFML_API_EXPORT
#else
#define SFML_SYSTEM_API SFML_API_IMPORT
#define SFML_SYSTEM_API SFML_API_IMPORT
#endif

View File

@ -29,12 +29,15 @@
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Config.hpp>
#include <SFML/System/Export.hpp>
#include <SFML/System/InputStream.hpp>
#include <memory>
#include <string>
#include <cstdio>
#include <filesystem>
#include <memory>
#include <string>
#ifdef SFML_SYSTEM_ANDROID
namespace sf::priv
@ -140,7 +143,6 @@ public:
Int64 getSize() override;
private:
////////////////////////////////////////////////////////////
// Member data
////////////////////////////////////////////////////////////

View File

@ -29,6 +29,7 @@
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Config.hpp>
#include <SFML/System/Export.hpp>
@ -41,12 +42,13 @@ namespace sf
class SFML_SYSTEM_API InputStream
{
public:
////////////////////////////////////////////////////////////
/// \brief Virtual destructor
///
////////////////////////////////////////////////////////////
virtual ~InputStream() {}
virtual ~InputStream()
{
}
////////////////////////////////////////////////////////////
/// \brief Read data from the stream

View File

@ -29,8 +29,11 @@
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Config.hpp>
#include <SFML/System/InputStream.hpp>
#include <SFML/System/Export.hpp>
#include <SFML/System/InputStream.hpp>
#include <cstdlib>
@ -43,7 +46,6 @@ namespace sf
class SFML_SYSTEM_API MemoryInputStream : public InputStream
{
public:
////////////////////////////////////////////////////////////
/// \brief Default constructor
///
@ -100,7 +102,6 @@ public:
Int64 getSize() override;
private:
////////////////////////////////////////////////////////////
// Member data
////////////////////////////////////////////////////////////

View File

@ -29,7 +29,9 @@
// Headers
////////////////////////////////////////////////////////////
#include <SFML/System/Export.hpp>
#include <SFML/System/Utf.hpp>
#include <iterator>
#include <locale>
#include <string>
@ -45,7 +47,6 @@ namespace sf
class SFML_SYSTEM_API String
{
public:
////////////////////////////////////////////////////////////
// Types
////////////////////////////////////////////////////////////
@ -318,7 +319,7 @@ public:
/// \return Reference to self
///
////////////////////////////////////////////////////////////
String& operator =(const String& right);
String& operator=(const String& right);
////////////////////////////////////////////////////////////
/// \brief Overload of += operator to append an UTF-32 string
@ -328,7 +329,7 @@ public:
/// \return Reference to self
///
////////////////////////////////////////////////////////////
String& operator +=(const String& right);
String& operator+=(const String& right);
////////////////////////////////////////////////////////////
/// \brief Overload of [] operator to access a character by its position
@ -341,7 +342,7 @@ public:
/// \return Character at position \a index
///
////////////////////////////////////////////////////////////
Uint32 operator [](std::size_t index) const;
Uint32 operator[](std::size_t index) const;
////////////////////////////////////////////////////////////
/// \brief Overload of [] operator to access a character by its position
@ -354,7 +355,7 @@ public:
/// \return Reference to the character at position \a index
///
////////////////////////////////////////////////////////////
Uint32& operator [](std::size_t index);
Uint32& operator[](std::size_t index);
////////////////////////////////////////////////////////////
/// \brief Clear the string
@ -529,9 +530,8 @@ public:
ConstIterator end() const;
private:
friend SFML_SYSTEM_API bool operator ==(const String& left, const String& right);
friend SFML_SYSTEM_API bool operator <(const String& left, const String& right);
friend SFML_SYSTEM_API bool operator==(const String& left, const String& right);
friend SFML_SYSTEM_API bool operator<(const String& left, const String& right);
////////////////////////////////////////////////////////////
// Member data
@ -549,7 +549,7 @@ private:
/// \return True if both strings are equal
///
////////////////////////////////////////////////////////////
SFML_SYSTEM_API bool operator ==(const String& left, const String& right);
SFML_SYSTEM_API bool operator==(const String& left, const String& right);
////////////////////////////////////////////////////////////
/// \relates String
@ -561,7 +561,7 @@ SFML_SYSTEM_API bool operator ==(const String& left, const String& right);
/// \return True if both strings are different
///
////////////////////////////////////////////////////////////
SFML_SYSTEM_API bool operator !=(const String& left, const String& right);
SFML_SYSTEM_API bool operator!=(const String& left, const String& right);
////////////////////////////////////////////////////////////
/// \relates String
@ -573,7 +573,7 @@ SFML_SYSTEM_API bool operator !=(const String& left, const String& right);
/// \return True if \a left is lexicographically before \a right
///
////////////////////////////////////////////////////////////
SFML_SYSTEM_API bool operator <(const String& left, const String& right);
SFML_SYSTEM_API bool operator<(const String& left, const String& right);
////////////////////////////////////////////////////////////
/// \relates String
@ -585,7 +585,7 @@ SFML_SYSTEM_API bool operator <(const String& left, const String& right);
/// \return True if \a left is lexicographically after \a right
///
////////////////////////////////////////////////////////////
SFML_SYSTEM_API bool operator >(const String& left, const String& right);
SFML_SYSTEM_API bool operator>(const String& left, const String& right);
////////////////////////////////////////////////////////////
/// \relates String
@ -597,7 +597,7 @@ SFML_SYSTEM_API bool operator >(const String& left, const String& right);
/// \return True if \a left is lexicographically before or equivalent to \a right
///
////////////////////////////////////////////////////////////
SFML_SYSTEM_API bool operator <=(const String& left, const String& right);
SFML_SYSTEM_API bool operator<=(const String& left, const String& right);
////////////////////////////////////////////////////////////
/// \relates String
@ -609,7 +609,7 @@ SFML_SYSTEM_API bool operator <=(const String& left, const String& right);
/// \return True if \a left is lexicographically after or equivalent to \a right
///
////////////////////////////////////////////////////////////
SFML_SYSTEM_API bool operator >=(const String& left, const String& right);
SFML_SYSTEM_API bool operator>=(const String& left, const String& right);
////////////////////////////////////////////////////////////
/// \relates String
@ -621,7 +621,7 @@ SFML_SYSTEM_API bool operator >=(const String& left, const String& right);
/// \return Concatenated string
///
////////////////////////////////////////////////////////////
SFML_SYSTEM_API String operator +(const String& left, const String& right);
SFML_SYSTEM_API String operator+(const String& left, const String& right);
#include <SFML/System/String.inl>

Some files were not shown because too many files have changed in this diff Show More