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,36 +22,36 @@
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;
JavaVM* vm = activity->vm;
JNIEnv* env = activity->env;
// First, attach this thread to the main thread
JavaVMAttachArgs attachargs;
attachargs.version = JNI_VERSION_1_6;
attachargs.name = "NativeThread";
attachargs.group = nullptr;
jint res = vm->AttachCurrentThread(&env, &attachargs);
attachargs.name = "NativeThread";
attachargs.group = nullptr;
jint res = vm->AttachCurrentThread(&env, &attachargs);
if (res == JNI_ERR)
return EXIT_FAILURE;
// Retrieve class information
jclass natact = env->FindClass("android/app/NativeActivity");
jclass natact = env->FindClass("android/app/NativeActivity");
jclass context = env->FindClass("android/content/Context");
// Get the value of a constant
jfieldID fid = env->GetStaticFieldID(context, "VIBRATOR_SERVICE", "Ljava/lang/String;");
jobject svcstr = env->GetStaticObjectField(context, fid);
jfieldID fid = env->GetStaticFieldID(context, "VIBRATOR_SERVICE", "Ljava/lang/String;");
jobject svcstr = env->GetStaticObjectField(context, fid);
// Get the method 'getSystemService' and call it
jmethodID getss = env->GetMethodID(natact, "getSystemService", "(Ljava/lang/String;)Ljava/lang/Object;");
jobject vib_obj = env->CallObjectMethod(activity->clazz, getss, svcstr);
jmethodID getss = env->GetMethodID(natact, "getSystemService", "(Ljava/lang/String;)Ljava/lang/Object;");
jobject vib_obj = env->CallObjectMethod(activity->clazz, getss, svcstr);
// Get the object's class and retrieve the member name
jclass vib_cls = env->GetObjectClass(vib_obj);
jclass vib_cls = env->GetObjectClass(vib_obj);
jmethodID vibrate = env->GetMethodID(vib_cls, "vibrate", "(J)V");
// Determine the timeframe
@ -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;
@ -48,17 +49,17 @@ struct SFMLmainWindow;
BOOL m_initialized;
}
@property (retain) IBOutlet NSWindow* window;
@property (retain) IBOutlet NSWindow* window;
@property (assign) IBOutlet NSView* sfmlView;
@property (assign) IBOutlet NSView* sfmlView;
@property (assign) IBOutlet NSTextField* textField;
@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,27 +24,26 @@
////////////////////////////////////////////////////////////
#import "CocoaAppDelegate.h"
#import "NSString+stdstring.h"
// These define are used for converting the color of the NSPopUpButton
#define BLUE @"Blue"
#define GREEN @"Green"
#define RED @"Red"
#define BLUE @"Blue"
#define GREEN @"Green"
#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"))
@ -54,7 +53,7 @@ struct SFMLmainWindow
sprite.setTexture(logo, true);
sf::FloatRect rect = sprite.getLocalBounds();
sf::Vector2f size(rect.width, rect.height);
sf::Vector2f size(rect.width, rect.height);
sprite.setOrigin(size / 2.f);
sprite.scale({0.3f, 0.3f});
@ -69,24 +68,24 @@ struct SFMLmainWindow
text.setFont(font);
}
sf::RenderWindow renderWindow;
sf::Font font;
sf::Text text;
sf::Texture logo;
sf::Sprite sprite;
sf::Color background;
sf::RenderWindow renderWindow;
sf::Font font;
sf::Text text;
sf::Texture logo;
sf::Sprite sprite;
sf::Color background;
};
// Private stuff
@interface CocoaAppDelegate ()
@property (assign) SFMLmainWindow* mainWindow;
@property (retain) NSTimer* renderTimer;
@property (assign) BOOL visible;
@property (assign) SFMLmainWindow* mainWindow;
@property (retain) NSTimer* renderTimer;
@property (assign) BOOL visible;
@property (assign) BOOL initialized;
@property (assign) BOOL initialized;
-(void)renderMainWindow:(NSTimer*)aTimer;
- (void)renderMainWindow:(NSTimer*)aTimer;
@end
@ -94,15 +93,15 @@ struct SFMLmainWindow
// Finally, the implementation
@implementation CocoaAppDelegate
@synthesize window = m_window;
@synthesize sfmlView = m_sfmlView;
@synthesize textField = m_textField;
@synthesize window = m_window;
@synthesize sfmlView = m_sfmlView;
@synthesize textField = m_textField;
@synthesize mainWindow = m_mainWindow;
@synthesize renderTimer = m_renderTimer;
@synthesize visible = m_visible;
@synthesize mainWindow = m_mainWindow;
@synthesize renderTimer = m_renderTimer;
@synthesize visible = m_visible;
@synthesize initialized = m_initialized;
@synthesize initialized = m_initialized;
- (id)init
{
@ -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
target:self
selector:@selector(renderMainWindow:)
userInfo:nil
repeats:YES];
[[NSRunLoop mainRunLoop] addTimer:self.renderTimer
forMode:NSDefaultRunLoopMode];
[[NSRunLoop mainRunLoop] addTimer:self.renderTimer
forMode:NSEventTrackingRunLoopMode];
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];
/*
* 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,23 +145,23 @@ struct SFMLmainWindow
}
}
-(void)dealloc
- (void)dealloc
{
[self.renderTimer invalidate];
self.mainWindow->renderWindow.close();
self.window = nil;
self.sfmlView = nil;
self.textField = nil;
self.window = nil;
self.sfmlView = nil;
self.textField = nil;
delete static_cast<SFMLmainWindow*>(self.mainWindow);
self.mainWindow = 0;
self.renderTimer = nil;
self.mainWindow = 0;
self.renderTimer = nil;
[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,38 +23,38 @@
//
////////////////////////////////////////////////////////////
#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));
unsigned size = static_cast<unsigned>(string.size() * sizeof(wchar_t));
NSString* str = [[[NSString alloc] initWithBytes:data length:size
encoding:NSUTF32LittleEndianStringEncoding] autorelease];
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();
}
@ -31,12 +32,11 @@ int main()
do
{
std::cout << "Enter the FTP server address: ";
std::cin >> address;
}
while (!address.has_value());
std::cin >> address;
} while (!address.has_value());
// Connect to the server
sf::Ftp server;
sf::Ftp server;
sf::Ftp::Response connectResponse = server.connect(address.value());
std::cout << connectResponse << std::endl;
if (!connectResponse.isOk())
@ -45,9 +45,9 @@ int main()
// Ask for user name and password
std::string user, password;
std::cout << "User name: ";
std::cin >> user;
std::cin >> user;
std::cout << "Password: ";
std::cin >> password;
std::cin >> password;
// Login to the server
sf::Ftp::Response loginResponse = server.login(user, password);
@ -75,7 +75,7 @@ int main()
<< std::endl;
std::cout << "Your choice: ";
std::cin >> choice;
std::cin >> choice;
std::cout << std::endl;
switch (choice)
@ -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;
}
@ -114,7 +113,7 @@ int main()
// Change the current directory
std::string directory;
std::cout << "Choose a directory: ";
std::cin >> directory;
std::cin >> directory;
std::cout << server.changeDirectory(directory) << std::endl;
break;
}
@ -124,7 +123,7 @@ int main()
// Create a new directory
std::string directory;
std::cout << "Name of the directory to create: ";
std::cin >> directory;
std::cin >> directory;
std::cout << server.createDirectory(directory) << std::endl;
break;
}
@ -134,7 +133,7 @@ int main()
// Remove an existing directory
std::string directory;
std::cout << "Name of the directory to remove: ";
std::cin >> directory;
std::cin >> directory;
std::cout << server.deleteDirectory(directory) << std::endl;
break;
}
@ -144,9 +143,9 @@ int main()
// Rename a file
std::string source, destination;
std::cout << "Name of the file to rename: ";
std::cin >> source;
std::cin >> source;
std::cout << "New name: ";
std::cin >> destination;
std::cin >> destination;
std::cout << server.renameFile(source, destination) << std::endl;
break;
}
@ -156,7 +155,7 @@ int main()
// Remove an existing directory
std::string filename;
std::cout << "Name of the file to remove: ";
std::cin >> filename;
std::cin >> filename;
std::cout << server.deleteFile(filename) << std::endl;
break;
}
@ -166,9 +165,9 @@ int main()
// Download a file from server
std::string filename, directory;
std::cout << "Filename of the file to download (relative to current directory): ";
std::cin >> filename;
std::cin >> filename;
std::cout << "Directory to download the file to: ";
std::cin >> directory;
std::cin >> directory;
std::cout << server.download(filename, directory) << std::endl;
break;
}
@ -178,9 +177,9 @@ int main()
// Upload a file to server
std::string filename, directory;
std::cout << "Path of the file to upload (absolute or relative to working directory): ";
std::cin >> filename;
std::cin >> filename;
std::cout << "Directory to upload the file to (relative to current directory): ";
std::cin >> directory;
std::cin >> directory;
std::cout << server.upload(filename, directory) << 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
{
sf::Vertex* targetBuffer;
unsigned int index;
};
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
{
const char* name;
float* value;
};
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;
@ -97,9 +95,9 @@ int main()
return EXIT_FAILURE;
// Create all of our graphics resources
sf::Text hudText;
sf::Text statusText;
sf::Shader terrainShader;
sf::Text hudText;
sf::Text statusText;
sf::Shader terrainShader;
sf::RenderStates terrainStates(&terrainShader);
sf::VertexBuffer terrain(sf::Triangles, sf::VertexBuffer::Static);
@ -159,26 +157,25 @@ 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},
{"perlinFrequencyBase", &perlinFrequencyBase},
{"heightBase", &heightBase},
{"edgeFactor", &edgeFactor},
{"edgeDropoffExponent", &edgeDropoffExponent},
{"snowcapHeight", &snowcapHeight},
{"heightFactor", &heightFactor},
{"heightFlatten", &heightFlatten},
{"lightFactor", &lightFactor}
}};
constexpr std::array<Setting, 9> settings = {
{{"perlinFrequency", &perlinFrequency},
{"perlinFrequencyBase", &perlinFrequencyBase},
{"heightBase", &heightBase},
{"edgeFactor", &edgeFactor},
{"edgeDropoffExponent", &edgeDropoffExponent},
{"snowcapHeight", &snowcapHeight},
{"heightFactor", &heightFactor},
{"heightFlatten", &heightFlatten},
{"lightFactor", &lightFactor}}};
std::size_t currentSetting = 0;
std::ostringstream osstr;
sf::Clock clock;
sf::Clock clock;
while (window.isOpen())
{
@ -187,7 +184,7 @@ int main()
{
// Window closed or escape key pressed: exit
if ((event.type == sf::Event::Closed) ||
((event.type == sf::Event::KeyPressed) && (event.key.code == sf::Keyboard::Escape)))
((event.type == sf::Event::KeyPressed) && (event.key.code == sf::Keyboard::Escape)))
{
window.close();
break;
@ -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,18 +294,20 @@ 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)),
y * perlinFrequency * static_cast<float>(std::pow(perlinFrequencyBase, i)),
0, 0, 0, 0
) * 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));
}
elevation = (elevation + 1.f) / 2.f;
float distance = 2.0f * std::sqrt(x * x + y * y);
elevation = (elevation + heightBase) * (1.0f - edgeFactor * std::pow(distance, edgeDropoffExponent));
elevation = std::min(std::max(elevation, 0.0f), 1.0f);
elevation = (elevation + heightBase) * (1.0f - edgeFactor * std::pow(distance, edgeDropoffExponent));
elevation = std::min(std::max(elevation, 0.0f), 1.0f);
return elevation;
}
@ -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,16 +417,21 @@ 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;
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,
deltaX.z * deltaY.x - deltaX.x * deltaY.z,
deltaX.x * deltaY.y - deltaX.y * deltaY.x
);
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);
// Scale cross product to make z component 1.0f so we can drop it
crossProduct /= crossProduct.z;
@ -455,12 +467,12 @@ sf::Vector2f computeNormal(float left, float right, float bottom, float top)
void processWorkItem(std::vector<sf::Vertex>& vertices, const WorkItem& workItem)
{
unsigned int rowBlockSize = (resolutionY / blockCount) + 1;
unsigned int rowStart = rowBlockSize * workItem.index;
unsigned int rowStart = rowBlockSize * workItem.index;
if (rowStart >= resolutionY)
return;
unsigned int rowEnd = std::min(rowStart + rowBlockSize, resolutionY);
unsigned int rowEnd = std::min(rowStart + rowBlockSize, resolutionY);
unsigned int rowCount = rowEnd - rowStart;
const float scalingFactorX = static_cast<float>(windowWidth) / static_cast<float>(resolutionX);
@ -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].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].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));
}
// 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].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].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));
}
// 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].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].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));
}
}
}
// 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,72 +13,73 @@
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;
// 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)
{
sstr.str("");
sstr << value;
texts[label].value.setString(sstr.str());
}
// 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)
{
for (unsigned int j = 0; j < sf::Joystick::AxisCount; ++j)
{
sf::Text label;
sf::Text value;
};
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"};
// 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)
{
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)
{
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)
{
for (unsigned int j = 0; j < sf::Joystick::getButtonCount(index); ++j)
{
sstr.str("");
sstr << "Button " << j;
set(sstr.str().c_str(), sf::Joystick::isButtonPressed(index, j));
}
}
// Helper to update displayed joystick values
void updateValues(unsigned int 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);
}
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)
{
for (unsigned int j = 0; j < sf::Joystick::getButtonCount(index); ++j)
{
sstr.str("");
sstr << "Button " << j;
set(sstr.str().c_str(), sf::Joystick::isButtonPressed(index, j));
}
}
// Helper to update displayed joystick values
void updateValues(unsigned int 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
////////////////////////////////////////////////////////////
/// Entry point of application
@ -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");
}
@ -170,15 +174,13 @@ int main()
{
// Window closed or escape key pressed: exit
if ((event.type == sf::Event::Closed) ||
((event.type == sf::Event::KeyPressed) && (event.key.code == sf::Keyboard::Escape)))
((event.type == sf::Event::KeyPressed) && (event.key.code == sf::Keyboard::Escape)))
{
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>
@ -42,7 +43,7 @@ int main()
{
// Request a 24-bits depth buffer when creating the window
sf::ContextSettings contextSettings;
contextSettings.depthBits = 24;
contextSettings.depthBits = 24;
contextSettings.sRgbCapable = sRgb;
// Create the main window
@ -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,16 +68,14 @@ 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 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;
bool m_isLoaded;
static const sf::Font* s_font;
};

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,10 +54,9 @@ public:
}
private:
sf::Texture m_texture;
sf::Sprite m_sprite;
sf::Shader m_shader;
sf::Sprite m_sprite;
sf::Shader m_shader;
};
@ -68,33 +66,32 @@ 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"
"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"
"Maecenas adipiscing ornare scelerisque. Nullam at libero elit.\n"
"Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.\n"
"Nullam leo urna, tincidunt id semper eget, ultricies sed mi.\n"
"Morbi mauris massa, commodo id dignissim vel, lobortis et elit.\n"
"Fusce vel libero sed neque scelerisque venenatis.\n"
"Integer mattis tincidunt quam vitae iaculis.\n"
"Vivamus fringilla sem non velit venenatis fermentum.\n"
"Vivamus varius tincidunt nisi id vehicula.\n"
"Integer ullamcorper, enim vitae euismod rutrum, massa nisl semper ipsum,\n"
"vestibulum sodales sem ante in massa.\n"
"Vestibulum in augue non felis convallis viverra.\n"
"Mauris ultricies dolor sed massa convallis sed aliquet augue fringilla.\n"
"Duis erat eros, porta in accumsan in, blandit quis sem.\n"
"In hac habitasse platea dictumst. Etiam fringilla est id odio dapibus sit amet semper dui laoreet.\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"
"Maecenas adipiscing ornare scelerisque. Nullam at libero elit.\n"
"Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.\n"
"Nullam leo urna, tincidunt id semper eget, ultricies sed mi.\n"
"Morbi mauris massa, commodo id dignissim vel, lobortis et elit.\n"
"Fusce vel libero sed neque scelerisque venenatis.\n"
"Integer mattis tincidunt quam vitae iaculis.\n"
"Vivamus fringilla sem non velit venenatis fermentum.\n"
"Vivamus varius tincidunt nisi id vehicula.\n"
"Integer ullamcorper, enim vitae euismod rutrum, massa nisl semper ipsum,\n"
"vestibulum sodales sem ante in massa.\n"
"Vestibulum in augue non felis convallis viverra.\n"
"Mauris ultricies dolor sed massa convallis sed aliquet augue fringilla.\n"
"Duis erat eros, porta in accumsan in, blandit quis sem.\n"
"In hac habitasse platea dictumst. Etiam fringilla est id odio dapibus sit amet semper dui laoreet.\n");
m_text.setFont(getFont());
m_text.setCharacterSize(22);
m_text.setPosition({30.f, 20.f});
@ -121,8 +118,7 @@ public:
}
private:
sf::Text m_text;
sf::Text m_text;
sf::Shader m_shader;
};
@ -133,16 +129,14 @@ private:
class StormBlink : public Effect
{
public:
StormBlink() :
Effect("Storm + Blink")
StormBlink() : Effect("Storm + Blink")
{
}
bool onLoad() override
{
std::uniform_real_distribution<float> x_distribution(0, 800);
std::uniform_real_distribution<float> y_distribution(0, 600);
std::uniform_real_distribution<float> x_distribution(0, 800);
std::uniform_real_distribution<float> y_distribution(0, 600);
std::uniform_int_distribution<sf::Uint16> color_distribution(0, 255);
// Create the points
@ -181,9 +175,8 @@ public:
}
private:
sf::VertexArray m_points;
sf::Shader m_shader;
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,13 +255,12 @@ public:
}
private:
sf::RenderTexture m_surface;
sf::Texture m_backgroundTexture;
sf::Texture m_entityTexture;
sf::Sprite m_backgroundSprite;
sf::RenderTexture m_surface;
sf::Texture m_backgroundTexture;
sf::Texture m_entityTexture;
sf::Sprite m_backgroundSprite;
std::vector<sf::Sprite> m_entities;
sf::Shader m_shader;
sf::Shader m_shader;
};
@ -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)
{
}
@ -336,8 +325,8 @@ public:
sf::RenderStates statesCopy(states);
// Prepare the render state
statesCopy.shader = &m_shader;
statesCopy.texture = &m_logoTexture;
statesCopy.shader = &m_shader;
statesCopy.texture = &m_logoTexture;
statesCopy.transform = m_transform;
// Draw the point cloud
@ -345,10 +334,9 @@ public:
}
private:
sf::Texture m_logoTexture;
sf::Transform m_transform;
sf::Shader m_shader;
sf::Texture m_logoTexture;
sf::Transform m_transform;
sf::Shader m_shader;
sf::VertexArray m_pointCloud;
};
@ -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
@ -373,19 +360,13 @@ int main()
Effect::setFont(font);
// Create the effects
Pixelate pixelateEffect;
WaveBlur waveBlurEffect;
Pixelate pixelateEffect;
WaveBlur waveBlurEffect;
StormBlink stormBlinkEffect;
Edge edgeEffect;
Geometry geometryEffect;
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);
@ -26,12 +26,12 @@ int main()
// TCP, UDP or connected UDP ?
char protocol;
std::cout << "Do you want to use TCP (t) or UDP (u)? ";
std::cin >> protocol;
std::cin >> protocol;
// Client or server ?
char who;
std::cout << "Do you want to be a server (s) or a client (c)? ";
std::cin >> who;
std::cin >> who;
if (protocol == 't')
{

View File

@ -3,6 +3,7 @@
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Network.hpp>
#include <iomanip>
#include <iostream>
@ -35,7 +36,7 @@ void runTcpServer(unsigned short port)
std::cout << "Message sent to the client: " << std::quoted(out) << std::endl;
// Receive a message back from the client
char in[128];
char in[128];
std::size_t received;
if (socket.receive(in, sizeof(in), received) != sf::Socket::Done)
return;
@ -55,9 +56,8 @@ void runTcpClient(unsigned short port)
do
{
std::cout << "Type the address or name of the server to connect to: ";
std::cin >> server;
}
while (!server.has_value());
std::cin >> server;
} while (!server.has_value());
// Create a socket for communicating with the server
sf::TcpSocket socket;
@ -68,7 +68,7 @@ void runTcpClient(unsigned short port)
std::cout << "Connected to server " << server.value() << std::endl;
// Receive a message from the server
char in[128];
char in[128];
std::size_t received;
if (socket.receive(in, sizeof(in), received) != sf::Socket::Done)
return;

View File

@ -3,6 +3,7 @@
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Network.hpp>
#include <iomanip>
#include <iostream>
#include <optional>
@ -23,10 +24,10 @@ void runUdpServer(unsigned short port)
std::cout << "Server is listening to port " << port << ", waiting for a message... " << std::endl;
// Wait for a message
char in[128];
std::size_t received;
char in[128];
std::size_t received;
std::optional<sf::IpAddress> sender;
unsigned short senderPort;
unsigned short senderPort;
if (socket.receive(in, sizeof(in), received, sender, senderPort) != sf::Socket::Done)
return;
std::cout << "Message received from client " << sender.value() << ": " << std::quoted(in) << std::endl;
@ -50,9 +51,8 @@ void runUdpClient(unsigned short port)
do
{
std::cout << "Type the address or name of the server to connect to: ";
std::cin >> server;
}
while (!server.has_value());
std::cin >> server;
} while (!server.has_value());
// Create a socket for communicating with the server
sf::UdpSocket socket;
@ -64,10 +64,10 @@ void runUdpClient(unsigned short port)
std::cout << "Message sent to the server: " << std::quoted(out) << std::endl;
// Receive an answer from anyone (but most likely from the server)
char in[128];
std::size_t received;
char in[128];
std::size_t received;
std::optional<sf::IpAddress> sender;
unsigned short senderPort;
unsigned short senderPort;
if (socket.receive(in, sizeof(in), received, sender, senderPort) != sf::Socket::Done)
return;
std::cout << "Message received from " << sender.value() << ": " << std::quoted(in) << std::endl;

View File

@ -3,6 +3,7 @@
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Audio.hpp>
#include <iostream>
#include <string>
@ -20,9 +21,9 @@ void playSound()
// Display sound informations
std::cout << "killdeer.wav:" << '\n'
<< " " << buffer.getDuration().asSeconds() << " seconds" << '\n'
<< " " << buffer.getSampleRate() << " samples / sec" << '\n'
<< " " << buffer.getChannelCount() << " channels" << std::endl;
<< " " << buffer.getDuration().asSeconds() << " seconds" << '\n'
<< " " << buffer.getSampleRate() << " samples / sec" << '\n'
<< " " << buffer.getChannelCount() << " channels" << std::endl;
// Create a sound instance and play it
sf::Sound sound(buffer);
@ -55,9 +56,9 @@ void playMusic(const std::filesystem::path& filename)
// Display music informations
std::cout << filename << ":" << '\n'
<< " " << music.getDuration().asSeconds() << " seconds" << '\n'
<< " " << music.getSampleRate() << " samples / sec" << '\n'
<< " " << music.getChannelCount() << " channels" << std::endl;
<< " " << music.getDuration().asSeconds() << " seconds" << '\n'
<< " " << music.getSampleRate() << " samples / sec" << '\n'
<< " " << music.getChannelCount() << " channels" << std::endl;
// Play it
music.play();

View File

@ -3,8 +3,9 @@
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Audio.hpp>
#include <iostream>
#include <cstdlib>
#include <iostream>
////////////////////////////////////////////////////////////
@ -25,7 +26,7 @@ int main()
// Choose the sample rate
unsigned int sampleRate;
std::cout << "Please choose the sample rate for sound capture (44100 is CD quality): ";
std::cin >> sampleRate;
std::cin >> sampleRate;
std::cin.ignore(10000, '\n');
// Wait for user input...
@ -51,14 +52,14 @@ int main()
// Display captured sound informations
std::cout << "Sound information:" << '\n'
<< " " << buffer.getDuration().asSeconds() << " seconds" << '\n'
<< " " << buffer.getSampleRate() << " samples / seconds" << '\n'
<< " " << buffer.getChannelCount() << " channels" << std::endl;
<< " " << buffer.getDuration().asSeconds() << " seconds" << '\n'
<< " " << buffer.getSampleRate() << " samples / seconds" << '\n'
<< " " << buffer.getChannelCount() << " channels" << std::endl;
// Choose what to do with the recorded sound data
char choice;
std::cout << "What do you want to do with captured sound (p = play, s = save) ? ";
std::cin >> choice;
std::cin >> choice;
std::cin.ignore(10000, '\n');
if (choice == 's')

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
@ -28,16 +29,17 @@ std::filesystem::path resourcesDir()
int main()
{
std::random_device rd;
std::mt19937 rng(rd());
std::mt19937 rng(rd());
// Define some constants
const float gameWidth = 800;
const float gameHeight = 600;
const float gameWidth = 800;
const float gameHeight = 600;
sf::Vector2f paddleSize(25, 100);
float ballRadius = 10.f;
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,22 +93,22 @@ 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;
const sf::Time AITime = sf::seconds(0.1f);
const float paddleSpeed = 400.f;
float rightPaddleSpeed = 0.f;
const float ballSpeed = 400.f;
sf::Angle ballAngle = sf::degrees(0); // to be changed later
sf::Clock AITimer;
const sf::Time AITime = sf::seconds(0.1f);
const float paddleSpeed = 400.f;
float rightPaddleSpeed = 0.f;
const float ballSpeed = 400.f;
sf::Angle ballAngle = sf::degrees(0); // to be changed later
sf::Clock clock;
bool isPlaying = false;
bool isPlaying = false;
while (window.isOpen())
{
// Handle events
@ -114,7 +116,7 @@ int main()
{
// Window closed or escape key pressed: exit
if ((event.type == sf::Event::Closed) ||
((event.type == sf::Event::KeyPressed) && (event.key.code == sf::Keyboard::Escape)))
((event.type == sf::Event::KeyPressed) && (event.key.code == sf::Keyboard::Escape)))
{
window.close();
break;
@ -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,20 +161,19 @@ 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});
}
if (sf::Keyboard::isKeyPressed(sf::Keyboard::Down) &&
(leftPaddle.getPosition().y + paddleSize.y / 2 < gameHeight - 5.f))
(leftPaddle.getPosition().y + paddleSize.y / 2 < gameHeight - 5.f))
{
leftPaddle.move({0.f, paddleSpeed * deltaTime});
}
if (sf::Touch::isDown(0))
{
sf::Vector2i pos = sf::Touch::getPosition(0);
sf::Vector2i pos = sf::Touch::getPosition(0);
sf::Vector2f mappedPos = window.mapPixelToCoords(pos);
leftPaddle.setPosition({leftPaddle.getPosition().x, mappedPos.y});
}
@ -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
///
@ -125,9 +122,8 @@ void doClient(unsigned short port)
do
{
std::cout << "Type address or name of the server to connect to: ";
std::cin >> server;
}
while (!server.has_value());
std::cin >> server;
} 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
@ -133,9 +131,11 @@ private:
// (so we protect any operation on it with the mutex)
{
std::scoped_lock lock(m_mutex);
std::size_t oldSize = m_samples.size();
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>
////////////////////////////////////////////////////////////
@ -28,7 +28,7 @@ int main()
// Client or server ?
char who;
std::cout << "Do you want to be a server ('s') or a client ('c')? ";
std::cin >> who;
std::cin >> who;
if (who == 's')
{

File diff suppressed because it is too large Load Diff

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>
@ -44,7 +52,7 @@ void SoundFileFactory::registerReader()
// Create a new factory with the functions provided by the class
ReaderFactory factory;
factory.check = &T::check;
factory.check = &T::check;
factory.create = &priv::createReader<T>;
// Add it
@ -75,7 +83,7 @@ void SoundFileFactory::registerWriter()
// Create a new factory with the functions provided by the class
WriterFactory factory;
factory.check = &T::check;
factory.check = &T::check;
factory.create = &priv::createWriter<T>;
// Add it

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
///
@ -303,13 +302,13 @@ private:
////////////////////////////////////////////////////////////
// Member data
////////////////////////////////////////////////////////////
std::thread m_thread; //!< Thread running the background recording task
std::vector<Int16> m_samples; //!< Buffer to store captured samples
unsigned int m_sampleRate; //!< Sample rate
Time m_processingInterval; //!< Time period between calls to onProcessSamples
bool m_isCapturing; //!< Capturing state
std::string m_deviceName; //!< Name of the audio capture device
unsigned int m_channelCount; //!< Number of recording channels
std::thread m_thread; //!< Thread running the background recording task
std::vector<Int16> m_samples; //!< Buffer to store captured samples
unsigned int m_sampleRate; //!< Sample rate
Time m_processingInterval; //!< Time period between calls to onProcessSamples
bool m_isCapturing; //!< Capturing state
std::string m_deviceName; //!< Name of the audio capture device
unsigned int m_channelCount; //!< Number of recording channels
};
} // namespace sf

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
///
@ -331,25 +330,25 @@ private:
enum
{
BufferCount = 3, //!< Number of audio buffers used by the streaming loop
BufferRetries = 2 //!< Number of retries (excluding initial try) for onGetData()
BufferCount = 3, //!< Number of audio buffers used by the streaming loop
BufferRetries = 2 //!< Number of retries (excluding initial try) for onGetData()
};
////////////////////////////////////////////////////////////
// Member data
////////////////////////////////////////////////////////////
std::thread m_thread; //!< Thread running the background tasks
mutable std::recursive_mutex m_threadMutex; //!< Thread mutex
Status m_threadStartState; //!< State the thread starts in (Playing, Paused, Stopped)
bool m_isStreaming; //!< Streaming state (true = playing, false = stopped)
unsigned int m_buffers[BufferCount]; //!< Sound buffers used to store temporary audio data
unsigned int m_channelCount; //!< Number of channels (1 = mono, 2 = stereo, ...)
unsigned int m_sampleRate; //!< Frequency (samples / second)
Int32 m_format; //!< Format of the internal sound buffers
bool m_loop; //!< Loop flag (true to loop, false to play once)
Uint64 m_samplesProcessed; //!< Number of samples processed since beginning of the stream
std::thread m_thread; //!< Thread running the background tasks
mutable std::recursive_mutex m_threadMutex; //!< Thread mutex
Status m_threadStartState; //!< State the thread starts in (Playing, Paused, Stopped)
bool m_isStreaming; //!< Streaming state (true = playing, false = stopped)
unsigned int m_buffers[BufferCount]; //!< Sound buffers used to store temporary audio data
unsigned int m_channelCount; //!< Number of channels (1 = mono, 2 = stereo, ...)
unsigned int m_sampleRate; //!< Frequency (samples / second)
Int32 m_format; //!< Format of the internal sound buffers
bool m_loop; //!< Loop flag (true to loop, false to play once)
Uint64 m_samplesProcessed; //!< Number of samples processed since beginning of the stream
Int64 m_bufferSeeks[BufferCount]; //!< If buffer is an "end buffer", holds next seek position, else NoLoop. For play offset calculation.
Time m_processingInterval; //!< Interval for checking and filling the internal sound buffers.
Time m_processingInterval; //!< Interval for checking and filling the internal sound buffers.
};
} // namespace sf

View File

@ -35,9 +35,9 @@
////////////////////////////////////////////////////////////
// Define the SFML version
////////////////////////////////////////////////////////////
#define SFML_VERSION_MAJOR 3
#define SFML_VERSION_MINOR 0
#define SFML_VERSION_PATCH 0
#define SFML_VERSION_MAJOR 3
#define SFML_VERSION_MINOR 0
#define SFML_VERSION_PATCH 0
#define SFML_VERSION_IS_RELEASE false
@ -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 \
extern "C" __declspec(dllexport) unsigned long NvOptimusEnablement = 1; \
extern "C" __declspec(dllexport) unsigned long AmdPowerXpressRequestHighPerformance = 1;
#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
@ -422,14 +423,14 @@ private:
////////////////////////////////////////////////////////////
// Member data
////////////////////////////////////////////////////////////
std::shared_ptr<FontHandles> m_fontHandles; //!< Shared information about the internal font instance
bool m_isSmooth; //!< Status of the smooth filter
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
std::unique_ptr<priv::ResourceStream> m_stream; //!< Asset file streamer (if loaded from file)
#endif
std::shared_ptr<FontHandles> m_fontHandles; //!< Shared information about the internal font instance
bool m_isSmooth; //!< Status of the smooth filter
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
std::unique_ptr<priv::ResourceStream> m_stream; //!< Asset file streamer (if loaded from file)
#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

@ -43,7 +43,7 @@ enum PrimitiveType
LineStrip, //!< List of connected lines, a point uses the previous point to form a line
Triangles, //!< List of individual triangles
TriangleStrip, //!< List of connected triangles, a point uses the two previous points to form a triangle
TriangleFan //!< List of connected triangles, a point uses the common center and the previous point to form a triangle
TriangleFan //!< List of connected triangles, a point uses the common center and the previous point to form a triangle
};
} // namespace sf

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,12 +162,12 @@ 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>
// Create type aliases for the most common types
using IntRect = Rect<int>;
using IntRect = Rect<int>;
using FloatRect = Rect<float>;
} // namespace sf

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,15 +480,18 @@ private:
////////////////////////////////////////////////////////////
struct StatesCache
{
enum {VertexCacheSize = 4};
enum
{
VertexCacheSize = 4
};
bool enable; //!< Is the cache enabled?
bool glStatesSet; //!< Are our internal GL states set yet?
bool viewChanged; //!< Has the current view changed since last draw?
BlendMode lastBlendMode; //!< Cached blending mode
Uint64 lastTextureId; //!< Cached texture
bool texCoordsArrayEnabled; //!< Is GL_TEXTURE_COORD_ARRAY client state enabled?
bool useVertexCache; //!< Did we previously use the vertex cache?
bool enable; //!< Is the cache enabled?
bool glStatesSet; //!< Are our internal GL states set yet?
bool viewChanged; //!< Has the current view changed since last draw?
BlendMode lastBlendMode; //!< Cached blending mode
Uint64 lastTextureId; //!< Cached texture
bool texCoordsArrayEnabled; //!< Is GL_TEXTURE_COORD_ARRAY client state enabled?
bool useVertexCache; //!< Did we previously use the vertex cache?
Vertex vertexCache[VertexCacheSize]; //!< Pre-transformed vertices cache
};

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,18 +102,15 @@ 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}),
transformPoint({rectangle.left, rectangle.top + rectangle.height}),
transformPoint({rectangle.left + rectangle.width, rectangle.top}),
transformPoint({rectangle.left + rectangle.width, rectangle.top + rectangle.height})
};
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})};
// Compute the bounding rectangle of the transformed points
float left = points[0].x;
float top = points[0].y;
float right = points[0].x;
float left = points[0].x;
float top = points[0].y;
float right = points[0].x;
float bottom = points[0].y;
for (int i = 1; i < 4; ++i)
@ -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
///
@ -93,9 +92,9 @@ public:
////////////////////////////////////////////////////////////
// Member data
////////////////////////////////////////////////////////////
Vector2f position; //!< 2D position of the vertex
Color color; //!< Color of the vertex
Vector2f texCoords; //!< Coordinates of the texture's pixel to map to the vertex
Vector2f position; //!< 2D position of the vertex
Color color; //!< Color of the vertex
Vector2f texCoords; //!< Coordinates of the texture's pixel to map to the vertex
};
#include <SFML/Graphics/Vertex.inl>

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
///
@ -81,13 +81,13 @@ public:
OpeningDataConnection = 150, //!< File status ok, about to open data connection
// 2xx: the requested action has been successfully completed
Ok = 200, //!< Command ok
PointlessCommand = 202, //!< Command not implemented
SystemStatus = 211, //!< System status, or system help reply
DirectoryStatus = 212, //!< Directory status
FileStatus = 213, //!< File status
HelpMessage = 214, //!< Help message
SystemType = 215, //!< NAME system type, where NAME is an official system name from the list in the Assigned Numbers document
Ok = 200, //!< Command ok
PointlessCommand = 202, //!< Command not implemented
SystemStatus = 211, //!< System status, or system help reply
DirectoryStatus = 212, //!< Directory status
FileStatus = 213, //!< File status
HelpMessage = 214, //!< Help message
SystemType = 215, //!< NAME system type, where NAME is an official system name from the list in the Assigned Numbers document
ServiceReady = 220, //!< Service ready for new user
ClosingConnection = 221, //!< Service closing control connection
DataConnectionOpened = 225, //!< Data connection open, no transfer in progress
@ -110,7 +110,7 @@ public:
TransferAborted = 426, //!< Connection closed, transfer aborted
FileActionAborted = 450, //!< Requested file action not taken
LocalError = 451, //!< Requested action aborted, local error in processing
InsufficientStorageSpace = 452, //!< Requested action not taken; insufficient storage space in system, file unavailable
InsufficientStorageSpace = 452, //!< Requested action not taken; insufficient storage space in system, file unavailable
// 5xx: the command was not accepted and
// the requested action did not take place
@ -127,10 +127,10 @@ public:
FilenameNotAllowed = 553, //!< Requested action not taken, file name not allowed
// 10xx: SFML custom codes
InvalidResponse = 1000, //!< Not part of the FTP standard, generated by SFML when a received response cannot be parsed
InvalidResponse = 1000, //!< Not part of the FTP standard, generated by SFML when a received response cannot be parsed
ConnectionFailed = 1001, //!< Not part of the FTP standard, generated by SFML when the low-level socket connection with the server fails
ConnectionClosed = 1002, //!< Not part of the FTP standard, generated by SFML when the low-level socket connection is unexpectedly closed
InvalidFile = 1003 //!< Not part of the FTP standard, generated by SFML when a local file cannot be read or written
InvalidFile = 1003 //!< Not part of the FTP standard, generated by SFML when a local file cannot be read or written
};
////////////////////////////////////////////////////////////
@ -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
///
@ -201,18 +199,18 @@ public:
enum Status
{
// 2xx: success
Ok = 200, //!< Most common code returned when operation was successful
Created = 201, //!< The resource has successfully been created
Accepted = 202, //!< The request has been accepted, but will be processed later by the server
NoContent = 204, //!< The server didn't send any data in return
ResetContent = 205, //!< The server informs the client that it should clear the view (form) that caused the request to be sent
Ok = 200, //!< Most common code returned when operation was successful
Created = 201, //!< The resource has successfully been created
Accepted = 202, //!< The request has been accepted, but will be processed later by the server
NoContent = 204, //!< The server didn't send any data in return
ResetContent = 205, //!< The server informs the client that it should clear the view (form) that caused the request to be sent
PartialContent = 206, //!< The server has sent a part of the resource, as a response to a partial GET request
// 3xx: redirection
MultipleChoices = 300, //!< The requested page can be accessed from several locations
MovedPermanently = 301, //!< The requested page has permanently moved to a new location
MovedTemporarily = 302, //!< The requested page has temporarily moved to a new location
NotModified = 304, //!< For conditional requests, means the requested page hasn't changed and doesn't need to be refreshed
NotModified = 304, //!< For conditional requests, means the requested page hasn't changed and doesn't need to be refreshed
// 4xx: client error
BadRequest = 400, //!< The server couldn't understand the request (syntax error)
@ -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)
{
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;
}
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,12 +70,11 @@ 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,
std::chrono::high_resolution_clock,
std::chrono::steady_clock>;
using MostSuitableClock = std::conditional_t<std::chrono::high_resolution_clock::is_steady,
std::chrono::high_resolution_clock,
std::chrono::steady_clock>;
#endif
} // namespace priv
@ -88,7 +88,6 @@ class Time;
class SFML_SYSTEM_API Clock
{
public:
////////////////////////////////////////////////////////////
/// \brief Default constructor
///
@ -123,10 +122,9 @@ 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");
"Clock resolution is too low. Expecting at least a microsecond precision");
////////////////////////////////////////////////////////////
/// \brief Convert clock duration to Time

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

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