Run clang-format
This commit is contained in:
parent
88e9f82bee
commit
4f52793f7d
@ -4,14 +4,14 @@
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
#include <SFML/Window.hpp>
|
#include <SFML/Window.hpp>
|
||||||
|
|
||||||
|
#include <X11/Xlib.h>
|
||||||
#define GLAD_GL_IMPLEMENTATION
|
#define GLAD_GL_IMPLEMENTATION
|
||||||
#include <gl.h>
|
#include <gl.h>
|
||||||
|
|
||||||
#include <X11/Xlib.h>
|
|
||||||
#include <array>
|
#include <array>
|
||||||
#include <iostream>
|
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// Initialize OpenGL states into the specified view
|
/// Initialize OpenGL states into the specified view
|
||||||
@ -171,12 +171,18 @@ int main()
|
|||||||
XSetWindowAttributes attributes;
|
XSetWindowAttributes attributes;
|
||||||
attributes.background_pixel = BlackPixel(display, screen);
|
attributes.background_pixel = BlackPixel(display, screen);
|
||||||
attributes.event_mask = KeyPressMask;
|
attributes.event_mask = KeyPressMask;
|
||||||
Window window = XCreateWindow(display, RootWindow(display, screen),
|
Window window = XCreateWindow(display,
|
||||||
0, 0, 650, 330, 0,
|
RootWindow(display, screen),
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
650,
|
||||||
|
330,
|
||||||
|
0,
|
||||||
DefaultDepth(display, screen),
|
DefaultDepth(display, screen),
|
||||||
InputOutput,
|
InputOutput,
|
||||||
DefaultVisual(display, screen),
|
DefaultVisual(display, screen),
|
||||||
CWBackPixel | CWEventMask, &attributes);
|
CWBackPixel | CWEventMask,
|
||||||
|
&attributes);
|
||||||
if (!window)
|
if (!window)
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
|
|
||||||
@ -184,18 +190,30 @@ int main()
|
|||||||
XStoreName(display, window, "SFML Window");
|
XStoreName(display, window, "SFML Window");
|
||||||
|
|
||||||
// Let's create the windows which will serve as containers for our SFML views
|
// Let's create the windows which will serve as containers for our SFML views
|
||||||
Window view1 = XCreateWindow(display, window,
|
Window view1 = XCreateWindow(display,
|
||||||
10, 10, 310, 310, 0,
|
window,
|
||||||
|
10,
|
||||||
|
10,
|
||||||
|
310,
|
||||||
|
310,
|
||||||
|
0,
|
||||||
DefaultDepth(display, screen),
|
DefaultDepth(display, screen),
|
||||||
InputOutput,
|
InputOutput,
|
||||||
DefaultVisual(display, screen),
|
DefaultVisual(display, screen),
|
||||||
0, nullptr);
|
0,
|
||||||
Window view2 = XCreateWindow(display, window,
|
nullptr);
|
||||||
330, 10, 310, 310, 0,
|
Window view2 = XCreateWindow(display,
|
||||||
|
window,
|
||||||
|
330,
|
||||||
|
10,
|
||||||
|
310,
|
||||||
|
310,
|
||||||
|
0,
|
||||||
DefaultDepth(display, screen),
|
DefaultDepth(display, screen),
|
||||||
InputOutput,
|
InputOutput,
|
||||||
DefaultVisual(display, screen),
|
DefaultVisual(display, screen),
|
||||||
0, nullptr);
|
0,
|
||||||
|
nullptr);
|
||||||
|
|
||||||
// Show our windows
|
// Show our windows
|
||||||
XMapWindow(display, window);
|
XMapWindow(display, window);
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
|
#include <SFML/Audio.hpp>
|
||||||
|
#include <SFML/Graphics.hpp>
|
||||||
|
#include <SFML/Network.hpp>
|
||||||
#include <SFML/System.hpp>
|
#include <SFML/System.hpp>
|
||||||
#include <SFML/Window.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?
|
// Do we want to showcase direct JNI/NDK interaction?
|
||||||
// Undefine this to get real cross-platform code.
|
// Undefine this to get real cross-platform code.
|
||||||
@ -11,8 +11,8 @@
|
|||||||
|
|
||||||
#if defined(USE_JNI)
|
#if defined(USE_JNI)
|
||||||
// These headers are only needed for direct NDK/JDK interaction
|
// These headers are only needed for direct NDK/JDK interaction
|
||||||
#include <jni.h>
|
|
||||||
#include <android/native_activity.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
|
// Since we want to get the native activity from SFML, we'll have to use an
|
||||||
// extra header here:
|
// extra header here:
|
||||||
@ -159,7 +159,8 @@ int main(int argc, char *argv[])
|
|||||||
window.draw(text);
|
window.draw(text);
|
||||||
window.display();
|
window.display();
|
||||||
}
|
}
|
||||||
else {
|
else
|
||||||
|
{
|
||||||
sf::sleep(sf::milliseconds(100));
|
sf::sleep(sf::milliseconds(100));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -23,9 +23,10 @@
|
|||||||
//
|
//
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
#import <Cocoa/Cocoa.h>
|
|
||||||
#import <SFML/Graphics.hpp>
|
#import <SFML/Graphics.hpp>
|
||||||
|
|
||||||
|
#import <Cocoa/Cocoa.h>
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* NB: We need pointers for C++ objects fields in Obj-C interface !
|
* NB: We need pointers for C++ objects fields in Obj-C interface !
|
||||||
* The recommended way is to use PIMPL idiom.
|
* The recommended way is to use PIMPL idiom.
|
||||||
|
@ -24,6 +24,7 @@
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
#import "CocoaAppDelegate.h"
|
#import "CocoaAppDelegate.h"
|
||||||
|
|
||||||
#import "NSString+stdstring.h"
|
#import "NSString+stdstring.h"
|
||||||
|
|
||||||
// These define are used for converting the color of the NSPopUpButton
|
// These define are used for converting the color of the NSPopUpButton
|
||||||
@ -42,9 +43,7 @@
|
|||||||
// Our PIMPL
|
// Our PIMPL
|
||||||
struct SFMLmainWindow
|
struct SFMLmainWindow
|
||||||
{
|
{
|
||||||
SFMLmainWindow(sf::WindowHandle win) :
|
SFMLmainWindow(sf::WindowHandle win) : renderWindow(win), background(sf::Color::Blue)
|
||||||
renderWindow(win),
|
|
||||||
background(sf::Color::Blue)
|
|
||||||
{
|
{
|
||||||
std::string resPath = [[[NSBundle mainBundle] resourcePath] tostdstring];
|
std::string resPath = [[[NSBundle mainBundle] resourcePath] tostdstring];
|
||||||
if (!logo.loadFromFile(resPath + "/logo.png"))
|
if (!logo.loadFromFile(resPath + "/logo.png"))
|
||||||
@ -125,15 +124,14 @@ struct SFMLmainWindow
|
|||||||
self.visible = YES;
|
self.visible = YES;
|
||||||
|
|
||||||
// Launch the timer to periodically display our stuff into the Cocoa view.
|
// Launch the timer to periodically display our stuff into the Cocoa view.
|
||||||
self.renderTimer = [NSTimer timerWithTimeInterval:1.0/60.0
|
self.renderTimer = [NSTimer
|
||||||
|
timerWithTimeInterval:1.0 / 60.0
|
||||||
target:self
|
target:self
|
||||||
selector:@selector(renderMainWindow:)
|
selector:@selector(renderMainWindow:)
|
||||||
userInfo:nil
|
userInfo:nil
|
||||||
repeats:YES];
|
repeats:YES];
|
||||||
[[NSRunLoop mainRunLoop] addTimer:self.renderTimer
|
[[NSRunLoop mainRunLoop] addTimer:self.renderTimer forMode:NSDefaultRunLoopMode];
|
||||||
forMode:NSDefaultRunLoopMode];
|
[[NSRunLoop mainRunLoop] addTimer:self.renderTimer forMode:NSEventTrackingRunLoopMode];
|
||||||
[[NSRunLoop mainRunLoop] addTimer:self.renderTimer
|
|
||||||
forMode:NSEventTrackingRunLoopMode];
|
|
||||||
/*
|
/*
|
||||||
* This is really some ugly code but in order to have the timer fired
|
* 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.
|
* periodically we need to add it to the two above runloop mode.
|
||||||
|
@ -23,8 +23,8 @@
|
|||||||
//
|
//
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
#import <string>
|
|
||||||
#import <Foundation/Foundation.h>
|
#import <Foundation/Foundation.h>
|
||||||
|
#import <string>
|
||||||
|
|
||||||
@interface NSString (NSString_stdstring)
|
@interface NSString (NSString_stdstring)
|
||||||
|
|
||||||
|
@ -23,9 +23,10 @@
|
|||||||
//
|
//
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
#import "NSString+stdstring.h"
|
|
||||||
#include <SFML/System/Utf.hpp>
|
#include <SFML/System/Utf.hpp>
|
||||||
|
|
||||||
|
#import "NSString+stdstring.h"
|
||||||
|
|
||||||
@implementation NSString (NSString_stdstring)
|
@implementation NSString (NSString_stdstring)
|
||||||
|
|
||||||
+ (id)stringWithstdstring:(const std::string&)string
|
+ (id)stringWithstdstring:(const std::string&)string
|
||||||
@ -35,8 +36,7 @@
|
|||||||
|
|
||||||
sf::Utf8::fromAnsi(string.begin(), string.end(), std::back_inserter(utf8));
|
sf::Utf8::fromAnsi(string.begin(), string.end(), std::back_inserter(utf8));
|
||||||
|
|
||||||
NSString* str = [NSString stringWithCString:utf8.c_str()
|
NSString* str = [NSString stringWithCString:utf8.c_str() encoding:NSUTF8StringEncoding];
|
||||||
encoding:NSUTF8StringEncoding];
|
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
// Headers
|
// Headers
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
#include <SFML/Network.hpp>
|
#include <SFML/Network.hpp>
|
||||||
|
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <optional>
|
#include <optional>
|
||||||
@ -32,8 +33,7 @@ int main()
|
|||||||
{
|
{
|
||||||
std::cout << "Enter the FTP server address: ";
|
std::cout << "Enter the FTP server address: ";
|
||||||
std::cin >> address;
|
std::cin >> address;
|
||||||
}
|
} while (!address.has_value());
|
||||||
while (!address.has_value());
|
|
||||||
|
|
||||||
// Connect to the server
|
// Connect to the server
|
||||||
sf::Ftp server;
|
sf::Ftp server;
|
||||||
@ -93,8 +93,7 @@ int main()
|
|||||||
{
|
{
|
||||||
// Print the current server directory
|
// Print the current server directory
|
||||||
sf::Ftp::DirectoryResponse response = server.getWorkingDirectory();
|
sf::Ftp::DirectoryResponse response = server.getWorkingDirectory();
|
||||||
std::cout << response << '\n'
|
std::cout << response << '\n' << "Current directory is " << response.getDirectory() << std::endl;
|
||||||
<< "Current directory is " << response.getDirectory() << std::endl;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -195,8 +194,7 @@ int main()
|
|||||||
} while (choice != 0);
|
} while (choice != 0);
|
||||||
|
|
||||||
// Disconnect from the server
|
// Disconnect from the server
|
||||||
std::cout << "Disconnecting from server...\n"
|
std::cout << "Disconnecting from server...\n" << server.disconnect() << '\n';
|
||||||
<< server.disconnect() << '\n';
|
|
||||||
|
|
||||||
// Wait until the user presses 'enter' key
|
// Wait until the user presses 'enter' key
|
||||||
std::cout << "Press enter to exit..." << std::endl;
|
std::cout << "Press enter to exit..." << std::endl;
|
||||||
|
@ -2,13 +2,16 @@
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
// Headers
|
// Headers
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
|
#include <SFML/Graphics.hpp>
|
||||||
|
|
||||||
#define STB_PERLIN_IMPLEMENTATION
|
#define STB_PERLIN_IMPLEMENTATION
|
||||||
#include <stb_perlin.h>
|
#include <stb_perlin.h>
|
||||||
|
|
||||||
#include <SFML/Graphics.hpp>
|
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <array>
|
#include <array>
|
||||||
|
#include <cmath>
|
||||||
|
#include <cstdlib>
|
||||||
|
#include <cstring>
|
||||||
#include <deque>
|
#include <deque>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <mutex>
|
#include <mutex>
|
||||||
@ -16,10 +19,6 @@
|
|||||||
#include <thread>
|
#include <thread>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include <cmath>
|
|
||||||
#include <cstdlib>
|
|
||||||
#include <cstring>
|
|
||||||
|
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
@ -71,7 +70,7 @@ namespace
|
|||||||
float heightFactor = windowHeight / 2.0f;
|
float heightFactor = windowHeight / 2.0f;
|
||||||
float heightFlatten = 3.0f;
|
float heightFlatten = 3.0f;
|
||||||
float lightFactor = 0.7f;
|
float lightFactor = 0.7f;
|
||||||
}
|
} // namespace
|
||||||
|
|
||||||
|
|
||||||
// Forward declarations of the functions we define further down
|
// Forward declarations of the functions we define further down
|
||||||
@ -88,8 +87,7 @@ void generateTerrain(sf::Vertex* vertexBuffer);
|
|||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
// Create the window of the application
|
// Create the window of the application
|
||||||
sf::RenderWindow window(sf::VideoMode({windowWidth, windowHeight}), "SFML Island",
|
sf::RenderWindow window(sf::VideoMode({windowWidth, windowHeight}), "SFML Island", sf::Style::Titlebar | sf::Style::Close);
|
||||||
sf::Style::Titlebar | sf::Style::Close);
|
|
||||||
window.setVerticalSyncEnabled(true);
|
window.setVerticalSyncEnabled(true);
|
||||||
|
|
||||||
sf::Font font;
|
sf::Font font;
|
||||||
@ -159,12 +157,12 @@ int main()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Center the status text
|
// 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
|
// Set up an array of pointers to our settings for arrow navigation
|
||||||
constexpr std::array<Setting, 9> settings =
|
constexpr std::array<Setting, 9> settings = {
|
||||||
{{
|
{{"perlinFrequency", &perlinFrequency},
|
||||||
{"perlinFrequency", &perlinFrequency},
|
|
||||||
{"perlinFrequencyBase", &perlinFrequencyBase},
|
{"perlinFrequencyBase", &perlinFrequencyBase},
|
||||||
{"heightBase", &heightBase},
|
{"heightBase", &heightBase},
|
||||||
{"edgeFactor", &edgeFactor},
|
{"edgeFactor", &edgeFactor},
|
||||||
@ -172,8 +170,7 @@ int main()
|
|||||||
{"snowcapHeight", &snowcapHeight},
|
{"snowcapHeight", &snowcapHeight},
|
||||||
{"heightFactor", &heightFactor},
|
{"heightFactor", &heightFactor},
|
||||||
{"heightFlatten", &heightFlatten},
|
{"heightFlatten", &heightFlatten},
|
||||||
{"lightFactor", &lightFactor}
|
{"lightFactor", &lightFactor}}};
|
||||||
}};
|
|
||||||
|
|
||||||
std::size_t currentSetting = 0;
|
std::size_t currentSetting = 0;
|
||||||
|
|
||||||
@ -198,12 +195,23 @@ int main()
|
|||||||
{
|
{
|
||||||
switch (event.key.code)
|
switch (event.key.code)
|
||||||
{
|
{
|
||||||
case sf::Keyboard::Enter: generateTerrain(terrainStagingBuffer.data()); break;
|
case sf::Keyboard::Enter:
|
||||||
case sf::Keyboard::Down: currentSetting = (currentSetting + 1) % settings.size(); break;
|
generateTerrain(terrainStagingBuffer.data());
|
||||||
case sf::Keyboard::Up: currentSetting = (currentSetting + settings.size() - 1) % settings.size(); break;
|
break;
|
||||||
case sf::Keyboard::Left: *(settings[currentSetting].value) -= 0.1f; break;
|
case sf::Keyboard::Down:
|
||||||
case sf::Keyboard::Right: *(settings[currentSetting].value) += 0.1f; break;
|
currentSetting = (currentSetting + 1) % settings.size();
|
||||||
default: break;
|
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";
|
<< "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)
|
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());
|
hudText.setString(osstr.str());
|
||||||
|
|
||||||
@ -285,11 +294,13 @@ float getElevation(float x, float y)
|
|||||||
|
|
||||||
for (int i = 0; i < perlinOctaves; ++i)
|
for (int i = 0; i < perlinOctaves; ++i)
|
||||||
{
|
{
|
||||||
elevation += stb_perlin_noise3(
|
elevation += stb_perlin_noise3(x * perlinFrequency * static_cast<float>(std::pow(perlinFrequencyBase, i)),
|
||||||
x * perlinFrequency * static_cast<float>(std::pow(perlinFrequencyBase, i)),
|
|
||||||
y * perlinFrequency * static_cast<float>(std::pow(perlinFrequencyBase, i)),
|
y * perlinFrequency * static_cast<float>(std::pow(perlinFrequencyBase, i)),
|
||||||
0, 0, 0, 0
|
0,
|
||||||
) * static_cast<float>(std::pow(perlinFrequencyBase, -i));
|
0,
|
||||||
|
0,
|
||||||
|
0) *
|
||||||
|
static_cast<float>(std::pow(perlinFrequencyBase, -i));
|
||||||
}
|
}
|
||||||
|
|
||||||
elevation = (elevation + 1.f) / 2.f;
|
elevation = (elevation + 1.f) / 2.f;
|
||||||
@ -316,11 +327,7 @@ float getMoisture(float x, float y)
|
|||||||
x = x / resolutionX - 0.5f;
|
x = x / resolutionX - 0.5f;
|
||||||
y = y / resolutionY - 0.5f;
|
y = y / resolutionY - 0.5f;
|
||||||
|
|
||||||
float moisture = stb_perlin_noise3(
|
float moisture = stb_perlin_noise3(x * 4.f + 0.5f, y * 4.f + 0.5f, 0, 0, 0, 0);
|
||||||
x * 4.f + 0.5f,
|
|
||||||
y * 4.f + 0.5f,
|
|
||||||
0, 0, 0, 0
|
|
||||||
);
|
|
||||||
|
|
||||||
return (moisture + 1.f) / 2.f;
|
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)
|
sf::Color colorFromFloats(float r, float g, float b)
|
||||||
{
|
{
|
||||||
return sf::Color(static_cast<sf::Uint8>(r),
|
return sf::Color(static_cast<sf::Uint8>(r), static_cast<sf::Uint8>(g), static_cast<sf::Uint8>(b));
|
||||||
static_cast<sf::Uint8>(g),
|
|
||||||
static_cast<sf::Uint8>(b));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sf::Color getLowlandsTerrainColor(float moisture)
|
sf::Color getLowlandsTerrainColor(float moisture)
|
||||||
{
|
{
|
||||||
sf::Color color =
|
sf::Color color = moisture < 0.27f ? colorFromFloats(240, 240, 180)
|
||||||
moisture < 0.27f ? colorFromFloats(240, 240, 180) :
|
: moisture < 0.3f ? colorFromFloats(240 - (240 * (moisture - 0.27f) / 0.03f),
|
||||||
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)) :
|
240 - (40 * (moisture - 0.27f) / 0.03f),
|
||||||
moisture < 0.4f ? colorFromFloats(0, 200, 0) :
|
180 - (180 * (moisture - 0.27f) / 0.03f))
|
||||||
moisture < 0.48f ? colorFromFloats(0, 200 - (40 * (moisture - 0.4f) / 0.08f), 0) :
|
: moisture < 0.4f ? colorFromFloats(0, 200, 0)
|
||||||
moisture < 0.6f ? colorFromFloats(0, 160, 0) :
|
: moisture < 0.48f ? colorFromFloats(0, 200 - (40 * (moisture - 0.4f) / 0.08f), 0)
|
||||||
moisture < 0.7f ? colorFromFloats((34 * (moisture - 0.6f) / 0.1f), 160 - (60 * (moisture - 0.6f) / 0.1f), (34 * (moisture - 0.6f) / 0.1f)) :
|
: moisture < 0.6f ? colorFromFloats(0, 160, 0)
|
||||||
colorFromFloats(34, 100, 34);
|
: 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;
|
return color;
|
||||||
}
|
}
|
||||||
@ -366,9 +374,10 @@ sf::Color getHighlandsTerrainColor(float elevation, float moisture)
|
|||||||
{
|
{
|
||||||
sf::Color lowlandsColor = getLowlandsTerrainColor(moisture);
|
sf::Color lowlandsColor = getLowlandsTerrainColor(moisture);
|
||||||
|
|
||||||
sf::Color color =
|
sf::Color color = moisture < 0.6f ? sf::Color(112, 128, 144)
|
||||||
moisture < 0.6f ? sf::Color(112, 128, 144) :
|
: colorFromFloats(112 + (110 * (moisture - 0.6f) / 0.4f),
|
||||||
colorFromFloats(112 + (110 * (moisture - 0.6f) / 0.4f), 128 + (56 * (moisture - 0.6f) / 0.4f), 144 - (9 * (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);
|
float factor = std::min((elevation - 0.4f) / 0.1f, 1.f);
|
||||||
|
|
||||||
@ -408,14 +417,19 @@ sf::Color getSnowcapTerrainColor(float elevation, float moisture)
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
sf::Color getTerrainColor(float elevation, float moisture)
|
sf::Color getTerrainColor(float elevation, float moisture)
|
||||||
{
|
{
|
||||||
sf::Color color =
|
sf::Color color = elevation < 0.11f ? sf::Color(0, 0, static_cast<sf::Uint8>(elevation / 0.11f * 74.f + 181.0f))
|
||||||
elevation < 0.11f ? sf::Color(0, 0, static_cast<sf::Uint8>(elevation / 0.11f * 74.f + 181.0f)) :
|
: elevation < 0.14f
|
||||||
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) :
|
? sf::Color(static_cast<sf::Uint8>(std::pow((elevation - 0.11f) / 0.03f, 0.3f) * 48.f),
|
||||||
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)) :
|
static_cast<sf::Uint8>(std::pow((elevation - 0.11f) / 0.03f, 0.3f) * 48.f),
|
||||||
elevation < 0.17f ? sf::Color(240, 230, 140) :
|
255)
|
||||||
elevation < 0.4f ? getLowlandsTerrainColor(moisture) :
|
: elevation < 0.16f
|
||||||
elevation < snowcapHeight ? getHighlandsTerrainColor(elevation, moisture) :
|
? sf::Color(static_cast<sf::Uint8>((elevation - 0.14f) * 128.f / 0.02f + 48.f),
|
||||||
getSnowcapTerrainColor(elevation, moisture);
|
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 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 deltaY(0, 1, (std::pow(top, heightFlatten) - std::pow(bottom, heightFlatten)) * heightFactor);
|
||||||
|
|
||||||
sf::Vector3f crossProduct(
|
sf::Vector3f crossProduct(deltaX.y * deltaY.z - deltaX.z * deltaY.y,
|
||||||
deltaX.y * deltaY.z - deltaX.z * deltaY.y,
|
|
||||||
deltaX.z * deltaY.x - deltaX.x * deltaY.z,
|
deltaX.z * deltaY.x - deltaX.x * deltaY.z,
|
||||||
deltaX.x * deltaY.y - deltaX.y * deltaY.x
|
deltaX.x * deltaY.y - deltaX.y * deltaY.x);
|
||||||
);
|
|
||||||
|
|
||||||
// Scale cross product to make z component 1.0f so we can drop it
|
// Scale cross product to make z component 1.0f so we can drop it
|
||||||
crossProduct /= crossProduct.z;
|
crossProduct /= crossProduct.z;
|
||||||
@ -483,9 +495,13 @@ void processWorkItem(std::vector<sf::Vertex>& vertices, const WorkItem& workItem
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
vertices[arrayIndexBase + 0].position = sf::Vector2f(static_cast<float>(x) * scalingFactorX, static_cast<float>(y) * scalingFactorY);
|
vertices[arrayIndexBase + 0].position = sf::Vector2f(static_cast<float>(x) * scalingFactorX,
|
||||||
|
static_cast<float>(y) * scalingFactorY);
|
||||||
vertices[arrayIndexBase + 0].color = getTerrainColor(getElevation(x, y), getMoisture(x, y));
|
vertices[arrayIndexBase + 0].color = getTerrainColor(getElevation(x, y), getMoisture(x, y));
|
||||||
vertices[arrayIndexBase + 0].texCoords = computeNormal(getElevation(x - 1, y), getElevation(x + 1, y), getElevation(x, y + 1), getElevation(x, y - 1));
|
vertices[arrayIndexBase + 0].texCoords = computeNormal(getElevation(x - 1, y),
|
||||||
|
getElevation(x + 1, y),
|
||||||
|
getElevation(x, y + 1),
|
||||||
|
getElevation(x, y - 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Bottom left corner (first triangle)
|
// Bottom left corner (first triangle)
|
||||||
@ -495,15 +511,23 @@ void processWorkItem(std::vector<sf::Vertex>& vertices, const WorkItem& workItem
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
vertices[arrayIndexBase + 1].position = sf::Vector2f(static_cast<float>(x) * scalingFactorX, static_cast<float>(y + 1) * scalingFactorY);
|
vertices[arrayIndexBase + 1].position = sf::Vector2f(static_cast<float>(x) * scalingFactorX,
|
||||||
|
static_cast<float>(y + 1) * scalingFactorY);
|
||||||
vertices[arrayIndexBase + 1].color = getTerrainColor(getElevation(x, y + 1), getMoisture(x, y + 1));
|
vertices[arrayIndexBase + 1].color = getTerrainColor(getElevation(x, y + 1), getMoisture(x, y + 1));
|
||||||
vertices[arrayIndexBase + 1].texCoords = computeNormal(getElevation(x - 1, y + 1), getElevation(x + 1, y + 1), getElevation(x, y + 2), getElevation(x, y));
|
vertices[arrayIndexBase + 1].texCoords = computeNormal(getElevation(x - 1, y + 1),
|
||||||
|
getElevation(x + 1, y + 1),
|
||||||
|
getElevation(x, y + 2),
|
||||||
|
getElevation(x, y));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Bottom right corner (first triangle)
|
// 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].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)
|
// Top left corner (second triangle)
|
||||||
vertices[arrayIndexBase + 3] = vertices[arrayIndexBase + 0];
|
vertices[arrayIndexBase + 3] = vertices[arrayIndexBase + 0];
|
||||||
@ -518,15 +542,21 @@ void processWorkItem(std::vector<sf::Vertex>& vertices, const WorkItem& workItem
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
vertices[arrayIndexBase + 5].position = sf::Vector2f(static_cast<float>(x + 1) * scalingFactorX, static_cast<float>(y) * scalingFactorY);
|
vertices[arrayIndexBase + 5].position = sf::Vector2f(static_cast<float>(x + 1) * scalingFactorX,
|
||||||
|
static_cast<float>(y) * scalingFactorY);
|
||||||
vertices[arrayIndexBase + 5].color = getTerrainColor(getElevation(x + 1, y), getMoisture(x + 1, y));
|
vertices[arrayIndexBase + 5].color = getTerrainColor(getElevation(x + 1, y), getMoisture(x + 1, y));
|
||||||
vertices[arrayIndexBase + 5].texCoords = computeNormal(getElevation(x, y), getElevation(x + 2, y), getElevation(x + 1, y + 1), getElevation(x + 1, y - 1));
|
vertices[arrayIndexBase + 5].texCoords = computeNormal(getElevation(x, y),
|
||||||
|
getElevation(x + 2, y),
|
||||||
|
getElevation(x + 1, y + 1),
|
||||||
|
getElevation(x + 1, y - 1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Copy the resulting geometry from our thread-local buffer into the target buffer
|
// 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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
// Headers
|
// Headers
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
#include <SFML/Graphics.hpp>
|
#include <SFML/Graphics.hpp>
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <array>
|
#include <array>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
@ -69,14 +70,15 @@ namespace
|
|||||||
// Helper to update displayed joystick values
|
// Helper to update displayed joystick values
|
||||||
void updateValues(unsigned int index)
|
void updateValues(unsigned int index)
|
||||||
{
|
{
|
||||||
if (sf::Joystick::isConnected(index)) {
|
if (sf::Joystick::isConnected(index))
|
||||||
|
{
|
||||||
// Update the label-value sf::Text objects based on the current joystick state
|
// Update the label-value sf::Text objects based on the current joystick state
|
||||||
updateIdentification(index);
|
updateIdentification(index);
|
||||||
updateAxes(index);
|
updateAxes(index);
|
||||||
updateButtons(index);
|
updateButtons(index);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} // namespace
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
@ -135,10 +137,12 @@ int main()
|
|||||||
sstr << "Button " << i;
|
sstr << "Button " << i;
|
||||||
JoystickObject& object = texts[sstr.str()];
|
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.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");
|
object.value.setString("N/A");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -175,10 +179,8 @@ int main()
|
|||||||
window.close();
|
window.close();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
else if ((event.type == sf::Event::JoystickButtonPressed) ||
|
else if ((event.type == sf::Event::JoystickButtonPressed) || (event.type == sf::Event::JoystickButtonReleased) ||
|
||||||
(event.type == sf::Event::JoystickButtonReleased) ||
|
(event.type == sf::Event::JoystickMoved) || (event.type == sf::Event::JoystickConnected))
|
||||||
(event.type == sf::Event::JoystickMoved) ||
|
|
||||||
(event.type == sf::Event::JoystickConnected))
|
|
||||||
{
|
{
|
||||||
// Update displayed joystick values
|
// Update displayed joystick values
|
||||||
updateValues(event.joystickConnect.joystickId);
|
updateValues(event.joystickConnect.joystickId);
|
||||||
|
@ -3,9 +3,10 @@
|
|||||||
// Headers
|
// Headers
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
#include <SFML/Graphics.hpp>
|
#include <SFML/Graphics.hpp>
|
||||||
|
|
||||||
#include <array>
|
#include <array>
|
||||||
#include <iostream>
|
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
#define GLAD_GL_IMPLEMENTATION
|
#define GLAD_GL_IMPLEMENTATION
|
||||||
#include <gl.h>
|
#include <gl.h>
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
// Headers
|
// Headers
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
#include <SFML/Graphics.hpp>
|
#include <SFML/Graphics.hpp>
|
||||||
|
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
@ -15,7 +16,6 @@
|
|||||||
class Effect : public sf::Drawable
|
class Effect : public sf::Drawable
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
~Effect() override
|
~Effect() override
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@ -57,10 +57,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
Effect(const std::string& name) : m_name(name), m_isLoaded(false)
|
||||||
Effect(const std::string& name) :
|
|
||||||
m_name(name),
|
|
||||||
m_isLoaded(false)
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -71,14 +68,12 @@ protected:
|
|||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
// Virtual functions to be implemented in derived effects
|
// Virtual functions to be implemented in derived effects
|
||||||
virtual bool onLoad() = 0;
|
virtual bool onLoad() = 0;
|
||||||
virtual void onUpdate(float time, float x, float y) = 0;
|
virtual void onUpdate(float time, float x, float y) = 0;
|
||||||
virtual void onDraw(sf::RenderTarget& target, const sf::RenderStates& states) const = 0;
|
virtual void onDraw(sf::RenderTarget& target, const sf::RenderStates& states) const = 0;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
std::string m_name;
|
std::string m_name;
|
||||||
bool m_isLoaded;
|
bool m_isLoaded;
|
||||||
|
|
||||||
|
@ -2,16 +2,17 @@
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
// Headers
|
// Headers
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
#include "Effect.hpp"
|
|
||||||
#include <array>
|
#include <array>
|
||||||
#include <random>
|
#include <random>
|
||||||
|
|
||||||
|
#include "Effect.hpp"
|
||||||
|
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
std::random_device rd;
|
std::random_device rd;
|
||||||
std::mt19937 rng(rd());
|
std::mt19937 rng(rd());
|
||||||
}
|
} // namespace
|
||||||
|
|
||||||
const sf::Font* Effect::s_font = nullptr;
|
const sf::Font* Effect::s_font = nullptr;
|
||||||
|
|
||||||
@ -21,9 +22,7 @@ const sf::Font* Effect::s_font = nullptr;
|
|||||||
class Pixelate : public Effect
|
class Pixelate : public Effect
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
Pixelate() : Effect("Pixelate")
|
||||||
Pixelate() :
|
|
||||||
Effect("Pixelate")
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -55,7 +54,6 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
sf::Texture m_texture;
|
sf::Texture m_texture;
|
||||||
sf::Sprite m_sprite;
|
sf::Sprite m_sprite;
|
||||||
sf::Shader m_shader;
|
sf::Shader m_shader;
|
||||||
@ -68,16 +66,15 @@ private:
|
|||||||
class WaveBlur : public Effect
|
class WaveBlur : public Effect
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
WaveBlur() : Effect("Wave + Blur")
|
||||||
WaveBlur() :
|
|
||||||
Effect("Wave + Blur")
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
bool onLoad() override
|
bool onLoad() override
|
||||||
{
|
{
|
||||||
// Create the text
|
// Create the text
|
||||||
m_text.setString("Praesent suscipit augue in velit pulvinar hendrerit varius purus aliquam.\n"
|
m_text.setString(
|
||||||
|
"Praesent suscipit augue in velit pulvinar hendrerit varius purus aliquam.\n"
|
||||||
"Mauris mi odio, bibendum quis fringilla a, laoreet vel orci. Proin vitae vulputate tortor.\n"
|
"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"
|
"Praesent cursus ultrices justo, ut feugiat ante vehicula quis.\n"
|
||||||
"Donec fringilla scelerisque mauris et viverra.\n"
|
"Donec fringilla scelerisque mauris et viverra.\n"
|
||||||
@ -121,7 +118,6 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
sf::Text m_text;
|
sf::Text m_text;
|
||||||
sf::Shader m_shader;
|
sf::Shader m_shader;
|
||||||
};
|
};
|
||||||
@ -133,9 +129,7 @@ private:
|
|||||||
class StormBlink : public Effect
|
class StormBlink : public Effect
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
StormBlink() : Effect("Storm + Blink")
|
||||||
StormBlink() :
|
|
||||||
Effect("Storm + Blink")
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -181,7 +175,6 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
sf::VertexArray m_points;
|
sf::VertexArray m_points;
|
||||||
sf::Shader m_shader;
|
sf::Shader m_shader;
|
||||||
};
|
};
|
||||||
@ -193,9 +186,7 @@ private:
|
|||||||
class Edge : public Effect
|
class Edge : public Effect
|
||||||
{
|
{
|
||||||
public:
|
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)
|
for (std::size_t i = 0; i < m_entities.size(); ++i)
|
||||||
{
|
{
|
||||||
sf::Vector2f position;
|
sf::Vector2f position;
|
||||||
position.x = std::cos(0.25f * (time * static_cast<float>(i) + static_cast<float>(m_entities.size() - i))) * 300 + 350;
|
position.x = std::cos(0.25f * (time * static_cast<float>(i) + static_cast<float>(m_entities.size() - i))) * 300 +
|
||||||
position.y = std::sin(0.25f * (time * static_cast<float>(m_entities.size() - i) + static_cast<float>(i))) * 200 + 250;
|
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);
|
m_entities[i].setPosition(position);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -262,7 +255,6 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
sf::RenderTexture m_surface;
|
sf::RenderTexture m_surface;
|
||||||
sf::Texture m_backgroundTexture;
|
sf::Texture m_backgroundTexture;
|
||||||
sf::Texture m_entityTexture;
|
sf::Texture m_entityTexture;
|
||||||
@ -278,10 +270,7 @@ private:
|
|||||||
class Geometry : public Effect
|
class Geometry : public Effect
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
Geometry() : Effect("Geometry Shader Billboards"), m_pointCloud(sf::Points, 10000)
|
||||||
Geometry() :
|
|
||||||
Effect("Geometry Shader Billboards"),
|
|
||||||
m_pointCloud(sf::Points, 10000)
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -345,7 +334,6 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
sf::Texture m_logoTexture;
|
sf::Texture m_logoTexture;
|
||||||
sf::Transform m_transform;
|
sf::Transform m_transform;
|
||||||
sf::Shader m_shader;
|
sf::Shader m_shader;
|
||||||
@ -362,8 +350,7 @@ private:
|
|||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
// Create the main window
|
// Create the main window
|
||||||
sf::RenderWindow window(sf::VideoMode({800, 600}), "SFML Shader",
|
sf::RenderWindow window(sf::VideoMode({800, 600}), "SFML Shader", sf::Style::Titlebar | sf::Style::Close);
|
||||||
sf::Style::Titlebar | sf::Style::Close);
|
|
||||||
window.setVerticalSyncEnabled(true);
|
window.setVerticalSyncEnabled(true);
|
||||||
|
|
||||||
// Load the application font and pass it to the Effect class
|
// Load the application font and pass it to the Effect class
|
||||||
@ -379,13 +366,7 @@ int main()
|
|||||||
Edge edgeEffect;
|
Edge edgeEffect;
|
||||||
Geometry geometryEffect;
|
Geometry geometryEffect;
|
||||||
|
|
||||||
const std::array<Effect*, 5> effects{
|
const std::array<Effect*, 5> effects{&pixelateEffect, &waveBlurEffect, &stormBlinkEffect, &edgeEffect, &geometryEffect};
|
||||||
&pixelateEffect,
|
|
||||||
&waveBlurEffect,
|
|
||||||
&stormBlinkEffect,
|
|
||||||
&edgeEffect,
|
|
||||||
&geometryEffect
|
|
||||||
};
|
|
||||||
|
|
||||||
std::size_t current = 0;
|
std::size_t current = 0;
|
||||||
|
|
||||||
@ -461,9 +442,12 @@ int main()
|
|||||||
effects[current]->update(clock.getElapsedTime().asSeconds(), x, y);
|
effects[current]->update(clock.getElapsedTime().asSeconds(), x, y);
|
||||||
|
|
||||||
// Clear the window
|
// Clear the window
|
||||||
if(effects[current]->getName() == "Edge Post-effect"){
|
if (effects[current]->getName() == "Edge Post-effect")
|
||||||
|
{
|
||||||
window.clear(sf::Color::White);
|
window.clear(sf::Color::White);
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
window.clear(sf::Color(50, 50, 50));
|
window.clear(sf::Color(50, 50, 50));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,8 +2,8 @@
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
// Headers
|
// Headers
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
#include <iostream>
|
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
|
|
||||||
void runTcpServer(unsigned short port);
|
void runTcpServer(unsigned short port);
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
// Headers
|
// Headers
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
#include <SFML/Network.hpp>
|
#include <SFML/Network.hpp>
|
||||||
|
|
||||||
#include <iomanip>
|
#include <iomanip>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
@ -56,8 +57,7 @@ void runTcpClient(unsigned short port)
|
|||||||
{
|
{
|
||||||
std::cout << "Type the address or name of the server to connect to: ";
|
std::cout << "Type the address or name of the server to connect to: ";
|
||||||
std::cin >> server;
|
std::cin >> server;
|
||||||
}
|
} while (!server.has_value());
|
||||||
while (!server.has_value());
|
|
||||||
|
|
||||||
// Create a socket for communicating with the server
|
// Create a socket for communicating with the server
|
||||||
sf::TcpSocket socket;
|
sf::TcpSocket socket;
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
// Headers
|
// Headers
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
#include <SFML/Network.hpp>
|
#include <SFML/Network.hpp>
|
||||||
|
|
||||||
#include <iomanip>
|
#include <iomanip>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <optional>
|
#include <optional>
|
||||||
@ -51,8 +52,7 @@ void runUdpClient(unsigned short port)
|
|||||||
{
|
{
|
||||||
std::cout << "Type the address or name of the server to connect to: ";
|
std::cout << "Type the address or name of the server to connect to: ";
|
||||||
std::cin >> server;
|
std::cin >> server;
|
||||||
}
|
} while (!server.has_value());
|
||||||
while (!server.has_value());
|
|
||||||
|
|
||||||
// Create a socket for communicating with the server
|
// Create a socket for communicating with the server
|
||||||
sf::UdpSocket socket;
|
sf::UdpSocket socket;
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
// Headers
|
// Headers
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
#include <SFML/Audio.hpp>
|
#include <SFML/Audio.hpp>
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
@ -3,8 +3,9 @@
|
|||||||
// Headers
|
// Headers
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
#include <SFML/Audio.hpp>
|
#include <SFML/Audio.hpp>
|
||||||
#include <iostream>
|
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
|
@ -2,8 +2,9 @@
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
// Headers
|
// Headers
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
#include <SFML/Graphics.hpp>
|
|
||||||
#include <SFML/Audio.hpp>
|
#include <SFML/Audio.hpp>
|
||||||
|
#include <SFML/Graphics.hpp>
|
||||||
|
|
||||||
#include <random>
|
#include <random>
|
||||||
|
|
||||||
#ifdef SFML_SYSTEM_IOS
|
#ifdef SFML_SYSTEM_IOS
|
||||||
@ -37,7 +38,8 @@ int main()
|
|||||||
float ballRadius = 10.f;
|
float ballRadius = 10.f;
|
||||||
|
|
||||||
// Create the window of the application
|
// 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);
|
sf::Style::Titlebar | sf::Style::Close);
|
||||||
window.setVerticalSyncEnabled(true);
|
window.setVerticalSyncEnabled(true);
|
||||||
|
|
||||||
@ -140,8 +142,7 @@ int main()
|
|||||||
{
|
{
|
||||||
// Make sure the ball initial angle is not too much vertical
|
// Make sure the ball initial angle is not too much vertical
|
||||||
ballAngle = sf::degrees(std::uniform_real_distribution<float>(0, 360)(rng));
|
ballAngle = sf::degrees(std::uniform_real_distribution<float>(0, 360)(rng));
|
||||||
}
|
} while (std::abs(std::cos(ballAngle.asRadians())) < 0.7f);
|
||||||
while (std::abs(std::cos(ballAngle.asRadians())) < 0.7f);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -160,8 +161,7 @@ int main()
|
|||||||
float deltaTime = clock.restart().asSeconds();
|
float deltaTime = clock.restart().asSeconds();
|
||||||
|
|
||||||
// Move the player's paddle
|
// Move the player's paddle
|
||||||
if (sf::Keyboard::isKeyPressed(sf::Keyboard::Up) &&
|
if (sf::Keyboard::isKeyPressed(sf::Keyboard::Up) && (leftPaddle.getPosition().y - paddleSize.y / 2 > 5.f))
|
||||||
(leftPaddle.getPosition().y - paddleSize.y / 2 > 5.f))
|
|
||||||
{
|
{
|
||||||
leftPaddle.move({0.f, -paddleSpeed * deltaTime});
|
leftPaddle.move({0.f, -paddleSpeed * deltaTime});
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
#include <SFML/Audio.hpp>
|
#include <SFML/Audio.hpp>
|
||||||
#include <SFML/Network.hpp>
|
#include <SFML/Network.hpp>
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
|
|
||||||
@ -18,7 +19,6 @@ const sf::Uint8 clientEndOfStream = 2;
|
|||||||
class NetworkRecorder : public sf::SoundRecorder
|
class NetworkRecorder : public sf::SoundRecorder
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// Constructor
|
/// Constructor
|
||||||
///
|
///
|
||||||
@ -26,9 +26,7 @@ public:
|
|||||||
/// \param port Port of the remote host
|
/// \param port Port of the remote host
|
||||||
///
|
///
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
NetworkRecorder(const sf::IpAddress& host, unsigned short port) :
|
NetworkRecorder(const sf::IpAddress& host, unsigned short port) : m_host(host), m_port(port)
|
||||||
m_host(host),
|
|
||||||
m_port(port)
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -45,7 +43,6 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \see SoundRecorder::onStart
|
/// \see SoundRecorder::onStart
|
||||||
///
|
///
|
||||||
@ -126,8 +123,7 @@ void doClient(unsigned short port)
|
|||||||
{
|
{
|
||||||
std::cout << "Type address or name of the server to connect to: ";
|
std::cout << "Type address or name of the server to connect to: ";
|
||||||
std::cin >> server;
|
std::cin >> server;
|
||||||
}
|
} while (!server.has_value());
|
||||||
while (!server.has_value());
|
|
||||||
|
|
||||||
// Create an instance of our custom recorder
|
// Create an instance of our custom recorder
|
||||||
NetworkRecorder recorder(server.value(), port);
|
NetworkRecorder recorder(server.value(), port);
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
#include <SFML/Audio.hpp>
|
#include <SFML/Audio.hpp>
|
||||||
#include <SFML/Network.hpp>
|
#include <SFML/Network.hpp>
|
||||||
|
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <iterator>
|
#include <iterator>
|
||||||
@ -21,14 +22,11 @@ const sf::Uint8 serverEndOfStream = 2;
|
|||||||
class NetworkAudioStream : public sf::SoundStream
|
class NetworkAudioStream : public sf::SoundStream
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// Default constructor
|
/// Default constructor
|
||||||
///
|
///
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
NetworkAudioStream() :
|
NetworkAudioStream() : m_offset(0), m_hasFinished(false)
|
||||||
m_offset (0),
|
|
||||||
m_hasFinished(false)
|
|
||||||
{
|
{
|
||||||
// Set the sound parameters
|
// Set the sound parameters
|
||||||
initialize(1, 44100);
|
initialize(1, 44100);
|
||||||
@ -66,7 +64,6 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// /see SoundStream::OnGetData
|
/// /see SoundStream::OnGetData
|
||||||
///
|
///
|
||||||
@ -85,7 +82,8 @@ private:
|
|||||||
// (don't forget that we run in two separate threads)
|
// (don't forget that we run in two separate threads)
|
||||||
{
|
{
|
||||||
std::scoped_lock lock(m_mutex);
|
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
|
// Fill audio data to pass to the stream
|
||||||
@ -135,7 +133,9 @@ private:
|
|||||||
std::scoped_lock lock(m_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);
|
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)
|
else if (id == serverEndOfStream)
|
||||||
|
@ -2,8 +2,8 @@
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
// Headers
|
// Headers
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
#include <iostream>
|
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
|
@ -7,14 +7,14 @@
|
|||||||
|
|
||||||
// Include graphics because we use sf::Image for loading images
|
// Include graphics because we use sf::Image for loading images
|
||||||
#include <SFML/Graphics.hpp>
|
#include <SFML/Graphics.hpp>
|
||||||
|
|
||||||
#include <SFML/Window.hpp>
|
#include <SFML/Window.hpp>
|
||||||
|
|
||||||
#include <array>
|
#include <array>
|
||||||
|
#include <cmath>
|
||||||
|
#include <cstring>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <limits>
|
#include <limits>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <cmath>
|
|
||||||
#include <cstring>
|
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
@ -33,7 +33,8 @@ namespace
|
|||||||
for (int i = 0; i < 4; ++i)
|
for (int i = 0; i < 4; ++i)
|
||||||
{
|
{
|
||||||
for (int j = 0; j < 4; ++j)
|
for (int j = 0; j < 4; ++j)
|
||||||
temp[i][j] = left[0][j] * right[i][0] + left[1][j] * right[i][1] + left[2][j] * right[i][2] + left[3][j] * right[i][3];
|
temp[i][j] = left[0][j] * right[i][0] + left[1][j] * right[i][1] + left[2][j] * right[i][2] +
|
||||||
|
left[3][j] * right[i][3];
|
||||||
}
|
}
|
||||||
|
|
||||||
std::memcpy(result, temp, sizeof(Matrix));
|
std::memcpy(result, temp, sizeof(Matrix));
|
||||||
@ -184,13 +185,14 @@ namespace
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Debug we pass to Vulkan to call when it detects warnings or errors
|
// Debug we pass to Vulkan to call when it detects warnings or errors
|
||||||
VKAPI_ATTR VkBool32 VKAPI_CALL debugCallback(VkDebugReportFlagsEXT, VkDebugReportObjectTypeEXT, uint64_t, size_t, int32_t, const char*, const char* pMessage, void*)
|
VKAPI_ATTR VkBool32 VKAPI_CALL
|
||||||
|
debugCallback(VkDebugReportFlagsEXT, VkDebugReportObjectTypeEXT, uint64_t, size_t, int32_t, const char*, const char* pMessage, void*)
|
||||||
{
|
{
|
||||||
std::cerr << pMessage << std::endl;
|
std::cerr << pMessage << std::endl;
|
||||||
|
|
||||||
return VK_FALSE;
|
return VK_FALSE;
|
||||||
}
|
}
|
||||||
}
|
} // namespace
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
@ -238,34 +240,62 @@ public:
|
|||||||
descriptorPool(0)
|
descriptorPool(0)
|
||||||
{
|
{
|
||||||
// Vulkan setup procedure
|
// Vulkan setup procedure
|
||||||
if (vulkanAvailable) setupInstance();
|
if (vulkanAvailable)
|
||||||
if (vulkanAvailable) setupDebugReportCallback();
|
setupInstance();
|
||||||
if (vulkanAvailable) setupSurface();
|
if (vulkanAvailable)
|
||||||
if (vulkanAvailable) setupPhysicalDevice();
|
setupDebugReportCallback();
|
||||||
if (vulkanAvailable) setupLogicalDevice();
|
if (vulkanAvailable)
|
||||||
if (vulkanAvailable) setupSwapchain();
|
setupSurface();
|
||||||
if (vulkanAvailable) setupSwapchainImages();
|
if (vulkanAvailable)
|
||||||
if (vulkanAvailable) setupShaders();
|
setupPhysicalDevice();
|
||||||
if (vulkanAvailable) setupRenderpass();
|
if (vulkanAvailable)
|
||||||
if (vulkanAvailable) setupDescriptorSetLayout();
|
setupLogicalDevice();
|
||||||
if (vulkanAvailable) setupPipelineLayout();
|
if (vulkanAvailable)
|
||||||
if (vulkanAvailable) setupPipeline();
|
setupSwapchain();
|
||||||
if (vulkanAvailable) setupCommandPool();
|
if (vulkanAvailable)
|
||||||
if (vulkanAvailable) setupVertexBuffer();
|
setupSwapchainImages();
|
||||||
if (vulkanAvailable) setupIndexBuffer();
|
if (vulkanAvailable)
|
||||||
if (vulkanAvailable) setupUniformBuffers();
|
setupShaders();
|
||||||
if (vulkanAvailable) setupDepthImage();
|
if (vulkanAvailable)
|
||||||
if (vulkanAvailable) setupDepthImageView();
|
setupRenderpass();
|
||||||
if (vulkanAvailable) setupTextureImage();
|
if (vulkanAvailable)
|
||||||
if (vulkanAvailable) setupTextureImageView();
|
setupDescriptorSetLayout();
|
||||||
if (vulkanAvailable) setupTextureSampler();
|
if (vulkanAvailable)
|
||||||
if (vulkanAvailable) setupFramebuffers();
|
setupPipelineLayout();
|
||||||
if (vulkanAvailable) setupDescriptorPool();
|
if (vulkanAvailable)
|
||||||
if (vulkanAvailable) setupDescriptorSets();
|
setupPipeline();
|
||||||
if (vulkanAvailable) setupCommandBuffers();
|
if (vulkanAvailable)
|
||||||
if (vulkanAvailable) setupDraw();
|
setupCommandPool();
|
||||||
if (vulkanAvailable) setupSemaphores();
|
if (vulkanAvailable)
|
||||||
if (vulkanAvailable) setupFences();
|
setupVertexBuffer();
|
||||||
|
if (vulkanAvailable)
|
||||||
|
setupIndexBuffer();
|
||||||
|
if (vulkanAvailable)
|
||||||
|
setupUniformBuffers();
|
||||||
|
if (vulkanAvailable)
|
||||||
|
setupDepthImage();
|
||||||
|
if (vulkanAvailable)
|
||||||
|
setupDepthImageView();
|
||||||
|
if (vulkanAvailable)
|
||||||
|
setupTextureImage();
|
||||||
|
if (vulkanAvailable)
|
||||||
|
setupTextureImageView();
|
||||||
|
if (vulkanAvailable)
|
||||||
|
setupTextureSampler();
|
||||||
|
if (vulkanAvailable)
|
||||||
|
setupFramebuffers();
|
||||||
|
if (vulkanAvailable)
|
||||||
|
setupDescriptorPool();
|
||||||
|
if (vulkanAvailable)
|
||||||
|
setupDescriptorSets();
|
||||||
|
if (vulkanAvailable)
|
||||||
|
setupCommandBuffers();
|
||||||
|
if (vulkanAvailable)
|
||||||
|
setupDraw();
|
||||||
|
if (vulkanAvailable)
|
||||||
|
setupSemaphores();
|
||||||
|
if (vulkanAvailable)
|
||||||
|
setupFences();
|
||||||
|
|
||||||
// If something went wrong, notify the user by setting the window title
|
// If something went wrong, notify the user by setting the window title
|
||||||
if (!vulkanAvailable)
|
if (!vulkanAvailable)
|
||||||
@ -405,16 +435,26 @@ public:
|
|||||||
cleanupSwapchain();
|
cleanupSwapchain();
|
||||||
|
|
||||||
// Swapchain setup procedure
|
// Swapchain setup procedure
|
||||||
if (vulkanAvailable) setupSwapchain();
|
if (vulkanAvailable)
|
||||||
if (vulkanAvailable) setupSwapchainImages();
|
setupSwapchain();
|
||||||
if (vulkanAvailable) setupPipelineLayout();
|
if (vulkanAvailable)
|
||||||
if (vulkanAvailable) setupRenderpass();
|
setupSwapchainImages();
|
||||||
if (vulkanAvailable) setupPipeline();
|
if (vulkanAvailable)
|
||||||
if (vulkanAvailable) setupDepthImage();
|
setupPipelineLayout();
|
||||||
if (vulkanAvailable) setupDepthImageView();
|
if (vulkanAvailable)
|
||||||
if (vulkanAvailable) setupFramebuffers();
|
setupRenderpass();
|
||||||
if (vulkanAvailable) setupCommandBuffers();
|
if (vulkanAvailable)
|
||||||
if (vulkanAvailable) setupDraw();
|
setupPipeline();
|
||||||
|
if (vulkanAvailable)
|
||||||
|
setupDepthImage();
|
||||||
|
if (vulkanAvailable)
|
||||||
|
setupDepthImageView();
|
||||||
|
if (vulkanAvailable)
|
||||||
|
setupFramebuffers();
|
||||||
|
if (vulkanAvailable)
|
||||||
|
setupCommandBuffers();
|
||||||
|
if (vulkanAvailable)
|
||||||
|
setupDraw();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Setup Vulkan instance
|
// Setup Vulkan instance
|
||||||
@ -530,7 +570,8 @@ public:
|
|||||||
// Register for warnings and errors
|
// Register for warnings and errors
|
||||||
VkDebugReportCallbackCreateInfoEXT debugReportCallbackCreateInfo = VkDebugReportCallbackCreateInfoEXT();
|
VkDebugReportCallbackCreateInfoEXT debugReportCallbackCreateInfo = VkDebugReportCallbackCreateInfoEXT();
|
||||||
debugReportCallbackCreateInfo.sType = VK_STRUCTURE_TYPE_DEBUG_REPORT_CALLBACK_CREATE_INFO_EXT;
|
debugReportCallbackCreateInfo.sType = VK_STRUCTURE_TYPE_DEBUG_REPORT_CALLBACK_CREATE_INFO_EXT;
|
||||||
debugReportCallbackCreateInfo.flags = VK_DEBUG_REPORT_WARNING_BIT_EXT | VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT | VK_DEBUG_REPORT_ERROR_BIT_EXT;
|
debugReportCallbackCreateInfo.flags = VK_DEBUG_REPORT_WARNING_BIT_EXT |
|
||||||
|
VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT | VK_DEBUG_REPORT_ERROR_BIT_EXT;
|
||||||
debugReportCallbackCreateInfo.pfnCallback = debugCallback;
|
debugReportCallbackCreateInfo.pfnCallback = debugCallback;
|
||||||
|
|
||||||
// Create the debug callback
|
// Create the debug callback
|
||||||
@ -639,21 +680,24 @@ public:
|
|||||||
|
|
||||||
vkGetPhysicalDeviceFormatProperties(gpu, VK_FORMAT_D24_UNORM_S8_UINT, &formatProperties);
|
vkGetPhysicalDeviceFormatProperties(gpu, VK_FORMAT_D24_UNORM_S8_UINT, &formatProperties);
|
||||||
|
|
||||||
if (formatProperties.optimalTilingFeatures & VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT) {
|
if (formatProperties.optimalTilingFeatures & VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT)
|
||||||
|
{
|
||||||
depthFormat = VK_FORMAT_D24_UNORM_S8_UINT;
|
depthFormat = VK_FORMAT_D24_UNORM_S8_UINT;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
vkGetPhysicalDeviceFormatProperties(gpu, VK_FORMAT_D32_SFLOAT_S8_UINT, &formatProperties);
|
vkGetPhysicalDeviceFormatProperties(gpu, VK_FORMAT_D32_SFLOAT_S8_UINT, &formatProperties);
|
||||||
|
|
||||||
if (formatProperties.optimalTilingFeatures & VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT) {
|
if (formatProperties.optimalTilingFeatures & VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT)
|
||||||
|
{
|
||||||
depthFormat = VK_FORMAT_D32_SFLOAT_S8_UINT;
|
depthFormat = VK_FORMAT_D32_SFLOAT_S8_UINT;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
vkGetPhysicalDeviceFormatProperties(gpu, VK_FORMAT_D32_SFLOAT, &formatProperties);
|
vkGetPhysicalDeviceFormatProperties(gpu, VK_FORMAT_D32_SFLOAT, &formatProperties);
|
||||||
|
|
||||||
if (formatProperties.optimalTilingFeatures & VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT) {
|
if (formatProperties.optimalTilingFeatures & VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT)
|
||||||
|
{
|
||||||
depthFormat = VK_FORMAT_D32_SFLOAT;
|
depthFormat = VK_FORMAT_D32_SFLOAT;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -763,7 +807,8 @@ public:
|
|||||||
{
|
{
|
||||||
for (VkSurfaceFormatKHR& surfaceFormat : surfaceFormats)
|
for (VkSurfaceFormatKHR& surfaceFormat : surfaceFormats)
|
||||||
{
|
{
|
||||||
if ((surfaceFormat.format == VK_FORMAT_B8G8R8A8_UNORM) && (surfaceFormat.colorSpace == VK_COLOR_SPACE_SRGB_NONLINEAR_KHR))
|
if ((surfaceFormat.format == VK_FORMAT_B8G8R8A8_UNORM) &&
|
||||||
|
(surfaceFormat.colorSpace == VK_COLOR_SPACE_SRGB_NONLINEAR_KHR))
|
||||||
{
|
{
|
||||||
swapchainFormat.format = VK_FORMAT_B8G8R8A8_UNORM;
|
swapchainFormat.format = VK_FORMAT_B8G8R8A8_UNORM;
|
||||||
swapchainFormat.colorSpace = VK_COLOR_SPACE_SRGB_NONLINEAR_KHR;
|
swapchainFormat.colorSpace = VK_COLOR_SPACE_SRGB_NONLINEAR_KHR;
|
||||||
@ -819,8 +864,12 @@ public:
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
swapchainExtent.width = clamp<uint32_t>(window.getSize().x, surfaceCapabilities.minImageExtent.width, surfaceCapabilities.maxImageExtent.width);
|
swapchainExtent.width = clamp<uint32_t>(window.getSize().x,
|
||||||
swapchainExtent.height = clamp<uint32_t>(window.getSize().y, surfaceCapabilities.minImageExtent.height, surfaceCapabilities.maxImageExtent.height);
|
surfaceCapabilities.minImageExtent.width,
|
||||||
|
surfaceCapabilities.maxImageExtent.width);
|
||||||
|
swapchainExtent.height = clamp<uint32_t>(window.getSize().y,
|
||||||
|
surfaceCapabilities.minImageExtent.height,
|
||||||
|
surfaceCapabilities.maxImageExtent.height);
|
||||||
|
|
||||||
auto imageCount = clamp<uint32_t>(2, surfaceCapabilities.minImageCount, surfaceCapabilities.maxImageCount);
|
auto imageCount = clamp<uint32_t>(2, surfaceCapabilities.minImageCount, surfaceCapabilities.maxImageCount);
|
||||||
|
|
||||||
@ -1190,7 +1239,8 @@ public:
|
|||||||
pipelineColorBlendAttachmentState.srcAlphaBlendFactor = VK_BLEND_FACTOR_ONE;
|
pipelineColorBlendAttachmentState.srcAlphaBlendFactor = VK_BLEND_FACTOR_ONE;
|
||||||
pipelineColorBlendAttachmentState.dstAlphaBlendFactor = VK_BLEND_FACTOR_ONE_MINUS_SRC_ALPHA;
|
pipelineColorBlendAttachmentState.dstAlphaBlendFactor = VK_BLEND_FACTOR_ONE_MINUS_SRC_ALPHA;
|
||||||
pipelineColorBlendAttachmentState.alphaBlendOp = VK_BLEND_OP_ADD;
|
pipelineColorBlendAttachmentState.alphaBlendOp = VK_BLEND_OP_ADD;
|
||||||
pipelineColorBlendAttachmentState.colorWriteMask = VK_COLOR_COMPONENT_R_BIT | VK_COLOR_COMPONENT_G_BIT | VK_COLOR_COMPONENT_B_BIT | VK_COLOR_COMPONENT_A_BIT;
|
pipelineColorBlendAttachmentState.colorWriteMask = VK_COLOR_COMPONENT_R_BIT | VK_COLOR_COMPONENT_G_BIT |
|
||||||
|
VK_COLOR_COMPONENT_B_BIT | VK_COLOR_COMPONENT_A_BIT;
|
||||||
|
|
||||||
VkPipelineColorBlendStateCreateInfo pipelineColorBlendStateCreateInfo = VkPipelineColorBlendStateCreateInfo();
|
VkPipelineColorBlendStateCreateInfo pipelineColorBlendStateCreateInfo = VkPipelineColorBlendStateCreateInfo();
|
||||||
pipelineColorBlendStateCreateInfo.sType = VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO;
|
pipelineColorBlendStateCreateInfo.sType = VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO;
|
||||||
@ -1214,7 +1264,8 @@ public:
|
|||||||
graphicsPipelineCreateInfo.subpass = 0;
|
graphicsPipelineCreateInfo.subpass = 0;
|
||||||
|
|
||||||
// Create our graphics pipeline
|
// Create our graphics pipeline
|
||||||
if (vkCreateGraphicsPipelines(device, VK_NULL_HANDLE, 1, &graphicsPipelineCreateInfo, 0, &graphicsPipeline) != VK_SUCCESS)
|
if (vkCreateGraphicsPipelines(device, VK_NULL_HANDLE, 1, &graphicsPipelineCreateInfo, 0, &graphicsPipeline) !=
|
||||||
|
VK_SUCCESS)
|
||||||
{
|
{
|
||||||
vulkanAvailable = false;
|
vulkanAvailable = false;
|
||||||
return;
|
return;
|
||||||
@ -1268,7 +1319,11 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Helper to create a generic buffer with the specified size, usage and memory flags
|
// Helper to create a generic buffer with the specified size, usage and memory flags
|
||||||
bool createBuffer(VkDeviceSize size, VkBufferUsageFlags usage, VkMemoryPropertyFlags properties, VkBuffer& buffer, VkDeviceMemory& memory)
|
bool createBuffer(VkDeviceSize size,
|
||||||
|
VkBufferUsageFlags usage,
|
||||||
|
VkMemoryPropertyFlags properties,
|
||||||
|
VkBuffer& buffer,
|
||||||
|
VkDeviceMemory& memory)
|
||||||
{
|
{
|
||||||
// We only have a single queue so we can request exclusive access
|
// We only have a single queue so we can request exclusive access
|
||||||
VkBufferCreateInfo bufferCreateInfo = VkBufferCreateInfo();
|
VkBufferCreateInfo bufferCreateInfo = VkBufferCreateInfo();
|
||||||
@ -1423,13 +1478,11 @@ public:
|
|||||||
VkBuffer stagingBuffer = 0;
|
VkBuffer stagingBuffer = 0;
|
||||||
VkDeviceMemory stagingBufferMemory = 0;
|
VkDeviceMemory stagingBufferMemory = 0;
|
||||||
|
|
||||||
if (!createBuffer(
|
if (!createBuffer(sizeof(vertexData),
|
||||||
sizeof(vertexData),
|
|
||||||
VK_BUFFER_USAGE_TRANSFER_SRC_BIT,
|
VK_BUFFER_USAGE_TRANSFER_SRC_BIT,
|
||||||
VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT,
|
VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT,
|
||||||
stagingBuffer,
|
stagingBuffer,
|
||||||
stagingBufferMemory
|
stagingBufferMemory))
|
||||||
))
|
|
||||||
{
|
{
|
||||||
vulkanAvailable = false;
|
vulkanAvailable = false;
|
||||||
return;
|
return;
|
||||||
@ -1454,13 +1507,11 @@ public:
|
|||||||
vkUnmapMemory(device, stagingBufferMemory);
|
vkUnmapMemory(device, stagingBufferMemory);
|
||||||
|
|
||||||
// Create the GPU local vertex buffer
|
// Create the GPU local vertex buffer
|
||||||
if (!createBuffer(
|
if (!createBuffer(sizeof(vertexData),
|
||||||
sizeof(vertexData),
|
|
||||||
VK_BUFFER_USAGE_TRANSFER_DST_BIT | VK_BUFFER_USAGE_VERTEX_BUFFER_BIT,
|
VK_BUFFER_USAGE_TRANSFER_DST_BIT | VK_BUFFER_USAGE_VERTEX_BUFFER_BIT,
|
||||||
VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT,
|
VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT,
|
||||||
vertexBuffer,
|
vertexBuffer,
|
||||||
vertexBufferMemory
|
vertexBufferMemory))
|
||||||
))
|
|
||||||
{
|
{
|
||||||
vkFreeMemory(device, stagingBufferMemory, 0);
|
vkFreeMemory(device, stagingBufferMemory, 0);
|
||||||
vkDestroyBuffer(device, stagingBuffer, 0);
|
vkDestroyBuffer(device, stagingBuffer, 0);
|
||||||
@ -1506,13 +1557,11 @@ public:
|
|||||||
VkBuffer stagingBuffer = 0;
|
VkBuffer stagingBuffer = 0;
|
||||||
VkDeviceMemory stagingBufferMemory = 0;
|
VkDeviceMemory stagingBufferMemory = 0;
|
||||||
|
|
||||||
if (!createBuffer(
|
if (!createBuffer(sizeof(indexData),
|
||||||
sizeof(indexData),
|
|
||||||
VK_BUFFER_USAGE_TRANSFER_SRC_BIT,
|
VK_BUFFER_USAGE_TRANSFER_SRC_BIT,
|
||||||
VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT,
|
VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT,
|
||||||
stagingBuffer,
|
stagingBuffer,
|
||||||
stagingBufferMemory
|
stagingBufferMemory))
|
||||||
))
|
|
||||||
{
|
{
|
||||||
vulkanAvailable = false;
|
vulkanAvailable = false;
|
||||||
return;
|
return;
|
||||||
@ -1537,13 +1586,11 @@ public:
|
|||||||
vkUnmapMemory(device, stagingBufferMemory);
|
vkUnmapMemory(device, stagingBufferMemory);
|
||||||
|
|
||||||
// Create the GPU local index buffer
|
// Create the GPU local index buffer
|
||||||
if (!createBuffer(
|
if (!createBuffer(sizeof(indexData),
|
||||||
sizeof(indexData),
|
|
||||||
VK_BUFFER_USAGE_TRANSFER_DST_BIT | VK_BUFFER_USAGE_INDEX_BUFFER_BIT,
|
VK_BUFFER_USAGE_TRANSFER_DST_BIT | VK_BUFFER_USAGE_INDEX_BUFFER_BIT,
|
||||||
VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT,
|
VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT,
|
||||||
indexBuffer,
|
indexBuffer,
|
||||||
indexBufferMemory
|
indexBufferMemory))
|
||||||
))
|
|
||||||
{
|
{
|
||||||
vkFreeMemory(device, stagingBufferMemory, 0);
|
vkFreeMemory(device, stagingBufferMemory, 0);
|
||||||
vkDestroyBuffer(device, stagingBuffer, 0);
|
vkDestroyBuffer(device, stagingBuffer, 0);
|
||||||
@ -1570,13 +1617,11 @@ public:
|
|||||||
uniformBuffersMemory.push_back(0);
|
uniformBuffersMemory.push_back(0);
|
||||||
|
|
||||||
// The uniform buffer will be host visible and coherent since we use it for streaming data every frame
|
// The uniform buffer will be host visible and coherent since we use it for streaming data every frame
|
||||||
if (!createBuffer(
|
if (!createBuffer(sizeof(Matrix) * 3,
|
||||||
sizeof(Matrix) * 3,
|
|
||||||
VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT,
|
VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT,
|
||||||
VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT,
|
VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT,
|
||||||
uniformBuffers[i],
|
uniformBuffers[i],
|
||||||
uniformBuffersMemory[i]
|
uniformBuffersMemory[i]))
|
||||||
))
|
|
||||||
{
|
{
|
||||||
vulkanAvailable = false;
|
vulkanAvailable = false;
|
||||||
return;
|
return;
|
||||||
@ -1585,7 +1630,14 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Helper to create a generic image with the specified size, format, usage and memory flags
|
// Helper to create a generic image with the specified size, format, usage and memory flags
|
||||||
bool createImage(uint32_t width, uint32_t height, VkFormat format, VkImageTiling tiling, VkImageUsageFlags usage, VkMemoryPropertyFlags properties, VkImage& image, VkDeviceMemory& imageMemory)
|
bool createImage(uint32_t width,
|
||||||
|
uint32_t height,
|
||||||
|
VkFormat format,
|
||||||
|
VkImageTiling tiling,
|
||||||
|
VkImageUsageFlags usage,
|
||||||
|
VkMemoryPropertyFlags properties,
|
||||||
|
VkImage& image,
|
||||||
|
VkDeviceMemory& imageMemory)
|
||||||
{
|
{
|
||||||
// We only have a single queue so we can request exclusive access
|
// We only have a single queue so we can request exclusive access
|
||||||
VkImageCreateInfo imageCreateInfo = VkImageCreateInfo();
|
VkImageCreateInfo imageCreateInfo = VkImageCreateInfo();
|
||||||
@ -1647,16 +1699,14 @@ public:
|
|||||||
void setupDepthImage()
|
void setupDepthImage()
|
||||||
{
|
{
|
||||||
// Create our depth image
|
// Create our depth image
|
||||||
if (!createImage(
|
if (!createImage(swapchainExtent.width,
|
||||||
swapchainExtent.width,
|
|
||||||
swapchainExtent.height,
|
swapchainExtent.height,
|
||||||
depthFormat,
|
depthFormat,
|
||||||
VK_IMAGE_TILING_OPTIMAL,
|
VK_IMAGE_TILING_OPTIMAL,
|
||||||
VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT,
|
VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT,
|
||||||
VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT,
|
VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT,
|
||||||
depthImage,
|
depthImage,
|
||||||
depthImageMemory
|
depthImageMemory))
|
||||||
))
|
|
||||||
{
|
{
|
||||||
vulkanAvailable = false;
|
vulkanAvailable = false;
|
||||||
return;
|
return;
|
||||||
@ -1703,7 +1753,8 @@ public:
|
|||||||
barrier.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED;
|
barrier.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED;
|
||||||
barrier.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED;
|
barrier.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED;
|
||||||
barrier.image = depthImage;
|
barrier.image = depthImage;
|
||||||
barrier.subresourceRange.aspectMask = VK_IMAGE_ASPECT_DEPTH_BIT | ((depthFormat == VK_FORMAT_D32_SFLOAT) ? 0 : VK_IMAGE_ASPECT_STENCIL_BIT);
|
barrier.subresourceRange.aspectMask = VK_IMAGE_ASPECT_DEPTH_BIT |
|
||||||
|
((depthFormat == VK_FORMAT_D32_SFLOAT) ? 0 : VK_IMAGE_ASPECT_STENCIL_BIT);
|
||||||
barrier.subresourceRange.baseMipLevel = 0;
|
barrier.subresourceRange.baseMipLevel = 0;
|
||||||
barrier.subresourceRange.levelCount = 1;
|
barrier.subresourceRange.levelCount = 1;
|
||||||
barrier.subresourceRange.baseArrayLayer = 0;
|
barrier.subresourceRange.baseArrayLayer = 0;
|
||||||
@ -1711,7 +1762,16 @@ public:
|
|||||||
barrier.srcAccessMask = 0;
|
barrier.srcAccessMask = 0;
|
||||||
barrier.dstAccessMask = VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_READ_BIT | VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT;
|
barrier.dstAccessMask = VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_READ_BIT | VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT;
|
||||||
|
|
||||||
vkCmdPipelineBarrier(commandBuffer, VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT, 0, 0, 0, 0, 0, 1, &barrier);
|
vkCmdPipelineBarrier(commandBuffer,
|
||||||
|
VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT,
|
||||||
|
VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
1,
|
||||||
|
&barrier);
|
||||||
|
|
||||||
// End and submit the command buffer
|
// End and submit the command buffer
|
||||||
if (vkEndCommandBuffer(commandBuffer) != VK_SUCCESS)
|
if (vkEndCommandBuffer(commandBuffer) != VK_SUCCESS)
|
||||||
@ -1751,7 +1811,9 @@ public:
|
|||||||
imageViewCreateInfo.image = depthImage;
|
imageViewCreateInfo.image = depthImage;
|
||||||
imageViewCreateInfo.viewType = VK_IMAGE_VIEW_TYPE_2D;
|
imageViewCreateInfo.viewType = VK_IMAGE_VIEW_TYPE_2D;
|
||||||
imageViewCreateInfo.format = depthFormat;
|
imageViewCreateInfo.format = depthFormat;
|
||||||
imageViewCreateInfo.subresourceRange.aspectMask = VK_IMAGE_ASPECT_DEPTH_BIT | ((depthFormat == VK_FORMAT_D32_SFLOAT) ? 0 : VK_IMAGE_ASPECT_STENCIL_BIT);
|
imageViewCreateInfo.subresourceRange
|
||||||
|
.aspectMask = VK_IMAGE_ASPECT_DEPTH_BIT |
|
||||||
|
((depthFormat == VK_FORMAT_D32_SFLOAT) ? 0 : VK_IMAGE_ASPECT_STENCIL_BIT);
|
||||||
imageViewCreateInfo.subresourceRange.baseMipLevel = 0;
|
imageViewCreateInfo.subresourceRange.baseMipLevel = 0;
|
||||||
imageViewCreateInfo.subresourceRange.levelCount = 1;
|
imageViewCreateInfo.subresourceRange.levelCount = 1;
|
||||||
imageViewCreateInfo.subresourceRange.baseArrayLayer = 0;
|
imageViewCreateInfo.subresourceRange.baseArrayLayer = 0;
|
||||||
@ -1782,7 +1844,11 @@ public:
|
|||||||
|
|
||||||
VkBuffer stagingBuffer;
|
VkBuffer stagingBuffer;
|
||||||
VkDeviceMemory stagingBufferMemory;
|
VkDeviceMemory stagingBufferMemory;
|
||||||
createBuffer(imageSize, VK_BUFFER_USAGE_TRANSFER_SRC_BIT, VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT, stagingBuffer, stagingBufferMemory);
|
createBuffer(imageSize,
|
||||||
|
VK_BUFFER_USAGE_TRANSFER_SRC_BIT,
|
||||||
|
VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT,
|
||||||
|
stagingBuffer,
|
||||||
|
stagingBufferMemory);
|
||||||
|
|
||||||
void* ptr;
|
void* ptr;
|
||||||
|
|
||||||
@ -1803,16 +1869,14 @@ public:
|
|||||||
vkUnmapMemory(device, stagingBufferMemory);
|
vkUnmapMemory(device, stagingBufferMemory);
|
||||||
|
|
||||||
// Create a GPU local image
|
// Create a GPU local image
|
||||||
if (!createImage(
|
if (!createImage(imageData.getSize().x,
|
||||||
imageData.getSize().x,
|
|
||||||
imageData.getSize().y,
|
imageData.getSize().y,
|
||||||
VK_FORMAT_R8G8B8A8_UNORM,
|
VK_FORMAT_R8G8B8A8_UNORM,
|
||||||
VK_IMAGE_TILING_OPTIMAL,
|
VK_IMAGE_TILING_OPTIMAL,
|
||||||
VK_IMAGE_USAGE_TRANSFER_DST_BIT | VK_IMAGE_USAGE_SAMPLED_BIT,
|
VK_IMAGE_USAGE_TRANSFER_DST_BIT | VK_IMAGE_USAGE_SAMPLED_BIT,
|
||||||
VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT,
|
VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT,
|
||||||
textureImage,
|
textureImage,
|
||||||
textureImageMemory
|
textureImageMemory))
|
||||||
))
|
|
||||||
{
|
{
|
||||||
vkFreeMemory(device, stagingBufferMemory, 0);
|
vkFreeMemory(device, stagingBufferMemory, 0);
|
||||||
vkDestroyBuffer(device, stagingBuffer, 0);
|
vkDestroyBuffer(device, stagingBuffer, 0);
|
||||||
@ -1995,7 +2059,16 @@ public:
|
|||||||
barrier.srcAccessMask = VK_ACCESS_TRANSFER_WRITE_BIT;
|
barrier.srcAccessMask = VK_ACCESS_TRANSFER_WRITE_BIT;
|
||||||
barrier.dstAccessMask = VK_ACCESS_SHADER_READ_BIT;
|
barrier.dstAccessMask = VK_ACCESS_SHADER_READ_BIT;
|
||||||
|
|
||||||
vkCmdPipelineBarrier(commandBuffer, VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT, 0, 0, 0, 0, 0, 1, &barrier);
|
vkCmdPipelineBarrier(commandBuffer,
|
||||||
|
VK_PIPELINE_STAGE_TRANSFER_BIT,
|
||||||
|
VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
1,
|
||||||
|
&barrier);
|
||||||
|
|
||||||
// End and submit the command buffer
|
// End and submit the command buffer
|
||||||
if (vkEndCommandBuffer(commandBuffer) != VK_SUCCESS)
|
if (vkEndCommandBuffer(commandBuffer) != VK_SUCCESS)
|
||||||
@ -2262,7 +2335,14 @@ public:
|
|||||||
vkCmdBindIndexBuffer(commandBuffers[i], indexBuffer, 0, VK_INDEX_TYPE_UINT16);
|
vkCmdBindIndexBuffer(commandBuffers[i], indexBuffer, 0, VK_INDEX_TYPE_UINT16);
|
||||||
|
|
||||||
// Bind our descriptor sets
|
// Bind our descriptor sets
|
||||||
vkCmdBindDescriptorSets(commandBuffers[i], VK_PIPELINE_BIND_POINT_GRAPHICS, pipelineLayout, 0, 1, &descriptorSets[i], 0, 0);
|
vkCmdBindDescriptorSets(commandBuffers[i],
|
||||||
|
VK_PIPELINE_BIND_POINT_GRAPHICS,
|
||||||
|
pipelineLayout,
|
||||||
|
0,
|
||||||
|
1,
|
||||||
|
&descriptorSets[i],
|
||||||
|
0,
|
||||||
|
0);
|
||||||
|
|
||||||
// Draw our primitives
|
// Draw our primitives
|
||||||
vkCmdDrawIndexed(commandBuffers[i], 36, 1, 0, 0, 0);
|
vkCmdDrawIndexed(commandBuffers[i], 36, 1, 0, 0, 0);
|
||||||
@ -2338,12 +2418,7 @@ public:
|
|||||||
void updateUniformBuffer(float elapsed)
|
void updateUniformBuffer(float elapsed)
|
||||||
{
|
{
|
||||||
// Construct the model matrix
|
// Construct the model matrix
|
||||||
Matrix model = {
|
Matrix model = {{1.0f, 0.0f, 0.0f, 0.0f}, {0.0f, 1.0f, 0.0f, 0.0f}, {0.0f, 0.0f, 1.0f, 0.0f}, {0.0f, 0.0f, 0.0f, 1.0f}};
|
||||||
{ 1.0f, 0.0f, 0.0f, 0.0f },
|
|
||||||
{ 0.0f, 1.0f, 0.0f, 0.0f },
|
|
||||||
{ 0.0f, 0.0f, 1.0f, 0.0f },
|
|
||||||
{ 0.0f, 0.0f, 0.0f, 1.0f }
|
|
||||||
};
|
|
||||||
|
|
||||||
matrixRotateX(model, sf::degrees(elapsed * 59.0f));
|
matrixRotateX(model, sf::degrees(elapsed * 59.0f));
|
||||||
matrixRotateY(model, sf::degrees(elapsed * 83.0f));
|
matrixRotateY(model, sf::degrees(elapsed * 83.0f));
|
||||||
@ -2380,7 +2455,8 @@ public:
|
|||||||
char* ptr;
|
char* ptr;
|
||||||
|
|
||||||
// Map the current frame's uniform buffer into our address space
|
// Map the current frame's uniform buffer into our address space
|
||||||
if (vkMapMemory(device, uniformBuffersMemory[currentFrame], 0, sizeof(Matrix) * 3, 0, reinterpret_cast<void**>(&ptr)) != VK_SUCCESS)
|
if (vkMapMemory(device, uniformBuffersMemory[currentFrame], 0, sizeof(Matrix) * 3, 0, reinterpret_cast<void**>(&ptr)) !=
|
||||||
|
VK_SUCCESS)
|
||||||
{
|
{
|
||||||
vulkanAvailable = false;
|
vulkanAvailable = false;
|
||||||
return;
|
return;
|
||||||
@ -2404,7 +2480,12 @@ public:
|
|||||||
|
|
||||||
{
|
{
|
||||||
// Get the next image in the swapchain
|
// Get the next image in the swapchain
|
||||||
VkResult result = vkAcquireNextImageKHR(device, swapchain, std::numeric_limits<uint64_t>::max(), imageAvailableSemaphores[currentFrame], VK_NULL_HANDLE, &imageIndex);
|
VkResult result = vkAcquireNextImageKHR(device,
|
||||||
|
swapchain,
|
||||||
|
std::numeric_limits<uint64_t>::max(),
|
||||||
|
imageAvailableSemaphores[currentFrame],
|
||||||
|
VK_NULL_HANDLE,
|
||||||
|
&imageIndex);
|
||||||
|
|
||||||
// Check if we need to re-create the swapchain (e.g. if the window was resized)
|
// Check if we need to re-create the swapchain (e.g. if the window was resized)
|
||||||
if (result == VK_ERROR_OUT_OF_DATE_KHR)
|
if (result == VK_ERROR_OUT_OF_DATE_KHR)
|
||||||
@ -2414,7 +2495,8 @@ public:
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((result != VK_SUCCESS) && (result != VK_TIMEOUT) && (result != VK_NOT_READY) && (result != VK_SUBOPTIMAL_KHR))
|
if ((result != VK_SUCCESS) && (result != VK_TIMEOUT) && (result != VK_NOT_READY) &&
|
||||||
|
(result != VK_SUBOPTIMAL_KHR))
|
||||||
{
|
{
|
||||||
vulkanAvailable = false;
|
vulkanAvailable = false;
|
||||||
return;
|
return;
|
||||||
|
@ -6,8 +6,8 @@
|
|||||||
#ifndef WIN32_LEAN_AND_MEAN
|
#ifndef WIN32_LEAN_AND_MEAN
|
||||||
#define WIN32_LEAN_AND_MEAN
|
#define WIN32_LEAN_AND_MEAN
|
||||||
#endif
|
#endif
|
||||||
#include <windows.h>
|
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
|
#include <windows.h>
|
||||||
|
|
||||||
HWND button;
|
HWND button;
|
||||||
|
|
||||||
@ -69,14 +69,44 @@ int main()
|
|||||||
RegisterClass(&windowClass);
|
RegisterClass(&windowClass);
|
||||||
|
|
||||||
// Let's create the main window
|
// 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
|
// Add a button for exiting
|
||||||
button = CreateWindow(TEXT("BUTTON"), TEXT("Quit"), WS_CHILD | WS_VISIBLE, 560, 440, 80, 40, window, nullptr, instance, nullptr);
|
button = CreateWindow(TEXT("BUTTON"), TEXT("Quit"), WS_CHILD | WS_VISIBLE, 560, 440, 80, 40, window, nullptr, instance, nullptr);
|
||||||
|
|
||||||
// Let's create two SFML views
|
// 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 view1 = CreateWindow(TEXT("STATIC"),
|
||||||
HWND view2 = CreateWindow(TEXT("STATIC"), nullptr, WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS, 340, 20, 300, 400, window, nullptr, instance, nullptr);
|
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 SFMLView1(view1);
|
||||||
sf::RenderWindow SFMLView2(view2);
|
sf::RenderWindow SFMLView2(view2);
|
||||||
|
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
// Headers
|
// Headers
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
#include <SFML/Window.hpp>
|
#include <SFML/Window.hpp>
|
||||||
|
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
|
|
||||||
#define GLAD_GL_IMPLEMENTATION
|
#define GLAD_GL_IMPLEMENTATION
|
||||||
@ -12,8 +13,8 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <array>
|
#include <array>
|
||||||
#include <iostream>
|
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// Entry point of application
|
/// Entry point of application
|
||||||
|
@ -29,7 +29,6 @@
|
|||||||
// Headers
|
// Headers
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
#include <SFML/System.hpp>
|
|
||||||
#include <SFML/Audio/InputSoundFile.hpp>
|
#include <SFML/Audio/InputSoundFile.hpp>
|
||||||
#include <SFML/Audio/Listener.hpp>
|
#include <SFML/Audio/Listener.hpp>
|
||||||
#include <SFML/Audio/Music.hpp>
|
#include <SFML/Audio/Music.hpp>
|
||||||
@ -43,6 +42,7 @@
|
|||||||
#include <SFML/Audio/SoundRecorder.hpp>
|
#include <SFML/Audio/SoundRecorder.hpp>
|
||||||
#include <SFML/Audio/SoundSource.hpp>
|
#include <SFML/Audio/SoundSource.hpp>
|
||||||
#include <SFML/Audio/SoundStream.hpp>
|
#include <SFML/Audio/SoundStream.hpp>
|
||||||
|
#include <SFML/System.hpp>
|
||||||
|
|
||||||
|
|
||||||
#endif // SFML_AUDIO_HPP
|
#endif // SFML_AUDIO_HPP
|
||||||
|
@ -40,7 +40,6 @@ namespace sf
|
|||||||
class SFML_AUDIO_API AlResource
|
class SFML_AUDIO_API AlResource
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Default constructor
|
/// \brief Default constructor
|
||||||
///
|
///
|
||||||
|
@ -29,10 +29,11 @@
|
|||||||
// Headers
|
// Headers
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
#include <SFML/Audio/Export.hpp>
|
#include <SFML/Audio/Export.hpp>
|
||||||
|
|
||||||
|
#include <cstddef>
|
||||||
#include <filesystem>
|
#include <filesystem>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <cstddef>
|
|
||||||
|
|
||||||
|
|
||||||
namespace sf
|
namespace sf
|
||||||
@ -48,7 +49,6 @@ class SoundFileReader;
|
|||||||
class SFML_AUDIO_API InputSoundFile
|
class SFML_AUDIO_API InputSoundFile
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Default constructor
|
/// \brief Default constructor
|
||||||
///
|
///
|
||||||
|
@ -29,6 +29,7 @@
|
|||||||
// Headers
|
// Headers
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
#include <SFML/Audio/Export.hpp>
|
#include <SFML/Audio/Export.hpp>
|
||||||
|
|
||||||
#include <SFML/System/Vector3.hpp>
|
#include <SFML/System/Vector3.hpp>
|
||||||
|
|
||||||
|
|
||||||
@ -42,7 +43,6 @@ namespace sf
|
|||||||
class SFML_AUDIO_API Listener
|
class SFML_AUDIO_API Listener
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Change the global volume of all the sounds and musics
|
/// \brief Change the global volume of all the sounds and musics
|
||||||
///
|
///
|
||||||
|
@ -29,8 +29,10 @@
|
|||||||
// Headers
|
// Headers
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
#include <SFML/Audio/Export.hpp>
|
#include <SFML/Audio/Export.hpp>
|
||||||
#include <SFML/Audio/SoundStream.hpp>
|
|
||||||
#include <SFML/Audio/InputSoundFile.hpp>
|
#include <SFML/Audio/InputSoundFile.hpp>
|
||||||
|
#include <SFML/Audio/SoundStream.hpp>
|
||||||
|
|
||||||
#include <filesystem>
|
#include <filesystem>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
@ -48,7 +50,6 @@ class InputStream;
|
|||||||
class SFML_AUDIO_API Music : public SoundStream
|
class SFML_AUDIO_API Music : public SoundStream
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Structure defining a time range using the template type
|
/// \brief Structure defining a time range using the template type
|
||||||
///
|
///
|
||||||
@ -62,7 +63,6 @@ public:
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
Span()
|
Span()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
@ -72,11 +72,8 @@ public:
|
|||||||
/// \param len Initial Length
|
/// \param len Initial Length
|
||||||
///
|
///
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
Span(T off, T len):
|
Span(T off, T len) : offset(off), length(len)
|
||||||
offset(off),
|
|
||||||
length(len)
|
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
T offset; //!< The beginning offset of the time range
|
T offset; //!< The beginning offset of the time range
|
||||||
@ -211,7 +208,6 @@ public:
|
|||||||
void setLoopPoints(TimeSpan timePoints);
|
void setLoopPoints(TimeSpan timePoints);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Request a new chunk of audio samples from the stream source
|
/// \brief Request a new chunk of audio samples from the stream source
|
||||||
///
|
///
|
||||||
@ -246,7 +242,6 @@ protected:
|
|||||||
Int64 onLoop() override;
|
Int64 onLoop() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Initialize the internal state after loading a new music
|
/// \brief Initialize the internal state after loading a new music
|
||||||
///
|
///
|
||||||
|
@ -29,6 +29,7 @@
|
|||||||
// Headers
|
// Headers
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
#include <SFML/Audio/Export.hpp>
|
#include <SFML/Audio/Export.hpp>
|
||||||
|
|
||||||
#include <filesystem>
|
#include <filesystem>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <string>
|
#include <string>
|
||||||
@ -45,7 +46,6 @@ class SoundFileWriter;
|
|||||||
class SFML_AUDIO_API OutputSoundFile
|
class SFML_AUDIO_API OutputSoundFile
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Default constructor
|
/// \brief Default constructor
|
||||||
///
|
///
|
||||||
@ -102,7 +102,6 @@ public:
|
|||||||
void close();
|
void close();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
// Member data
|
// Member data
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
|
@ -29,7 +29,9 @@
|
|||||||
// Headers
|
// Headers
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
#include <SFML/Audio/Export.hpp>
|
#include <SFML/Audio/Export.hpp>
|
||||||
|
|
||||||
#include <SFML/Audio/SoundSource.hpp>
|
#include <SFML/Audio/SoundSource.hpp>
|
||||||
|
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
|
|
||||||
|
|
||||||
@ -45,7 +47,6 @@ class SoundBuffer;
|
|||||||
class SFML_AUDIO_API Sound : public SoundSource
|
class SFML_AUDIO_API Sound : public SoundSource
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Default constructor
|
/// \brief Default constructor
|
||||||
///
|
///
|
||||||
@ -213,7 +214,6 @@ public:
|
|||||||
void resetBuffer();
|
void resetBuffer();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
// Member data
|
// Member data
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
|
@ -29,12 +29,14 @@
|
|||||||
// Headers
|
// Headers
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
#include <SFML/Audio/Export.hpp>
|
#include <SFML/Audio/Export.hpp>
|
||||||
|
|
||||||
#include <SFML/Audio/AlResource.hpp>
|
#include <SFML/Audio/AlResource.hpp>
|
||||||
#include <SFML/System/Time.hpp>
|
#include <SFML/System/Time.hpp>
|
||||||
|
|
||||||
#include <filesystem>
|
#include <filesystem>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
|
||||||
#include <unordered_set>
|
#include <unordered_set>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
|
||||||
namespace sf
|
namespace sf
|
||||||
@ -50,7 +52,6 @@ class InputStream;
|
|||||||
class SFML_AUDIO_API SoundBuffer : AlResource
|
class SFML_AUDIO_API SoundBuffer : AlResource
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Default constructor
|
/// \brief Default constructor
|
||||||
///
|
///
|
||||||
@ -225,7 +226,6 @@ public:
|
|||||||
SoundBuffer& operator=(const SoundBuffer& right);
|
SoundBuffer& operator=(const SoundBuffer& right);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
friend class Sound;
|
friend class Sound;
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
|
@ -29,8 +29,10 @@
|
|||||||
// Headers
|
// Headers
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
#include <SFML/Audio/Export.hpp>
|
#include <SFML/Audio/Export.hpp>
|
||||||
|
|
||||||
#include <SFML/Audio/SoundBuffer.hpp>
|
#include <SFML/Audio/SoundBuffer.hpp>
|
||||||
#include <SFML/Audio/SoundRecorder.hpp>
|
#include <SFML/Audio/SoundRecorder.hpp>
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
|
||||||
@ -44,7 +46,6 @@ namespace sf
|
|||||||
class SFML_AUDIO_API SoundBufferRecorder : public SoundRecorder
|
class SFML_AUDIO_API SoundBufferRecorder : public SoundRecorder
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief destructor
|
/// \brief destructor
|
||||||
///
|
///
|
||||||
@ -65,7 +66,6 @@ public:
|
|||||||
const SoundBuffer& getBuffer() const;
|
const SoundBuffer& getBuffer() const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Start capturing audio data
|
/// \brief Start capturing audio data
|
||||||
///
|
///
|
||||||
@ -92,7 +92,6 @@ protected:
|
|||||||
void onStop() override;
|
void onStop() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
// Member data
|
// Member data
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
|
@ -29,6 +29,7 @@
|
|||||||
// Headers
|
// Headers
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
#include <SFML/Audio/Export.hpp>
|
#include <SFML/Audio/Export.hpp>
|
||||||
|
|
||||||
#include <filesystem>
|
#include <filesystem>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <string>
|
#include <string>
|
||||||
@ -48,7 +49,6 @@ class SoundFileWriter;
|
|||||||
class SFML_AUDIO_API SoundFileFactory
|
class SFML_AUDIO_API SoundFileFactory
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Register a new reader
|
/// \brief Register a new reader
|
||||||
///
|
///
|
||||||
@ -133,7 +133,6 @@ public:
|
|||||||
static std::unique_ptr<SoundFileWriter> createWriterFromFilename(const std::filesystem::path& filename);
|
static std::unique_ptr<SoundFileWriter> createWriterFromFilename(const std::filesystem::path& filename);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
// Types
|
// Types
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
|
@ -31,9 +31,17 @@ namespace sf
|
|||||||
{
|
{
|
||||||
namespace priv
|
namespace priv
|
||||||
{
|
{
|
||||||
template <typename T> std::unique_ptr<SoundFileReader> createReader() { return std::make_unique<T>(); }
|
template <typename T>
|
||||||
template <typename T> std::unique_ptr<SoundFileWriter> createWriter() { return std::make_unique<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>
|
template <typename T>
|
||||||
|
@ -57,7 +57,9 @@ public:
|
|||||||
/// \brief Virtual destructor
|
/// \brief Virtual destructor
|
||||||
///
|
///
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
virtual ~SoundFileReader() {}
|
virtual ~SoundFileReader()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Open a sound file for reading
|
/// \brief Open a sound file for reading
|
||||||
|
@ -29,6 +29,7 @@
|
|||||||
// Headers
|
// Headers
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
#include <SFML/Audio/Export.hpp>
|
#include <SFML/Audio/Export.hpp>
|
||||||
|
|
||||||
#include <filesystem>
|
#include <filesystem>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
@ -42,12 +43,13 @@ namespace sf
|
|||||||
class SFML_AUDIO_API SoundFileWriter
|
class SFML_AUDIO_API SoundFileWriter
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Virtual destructor
|
/// \brief Virtual destructor
|
||||||
///
|
///
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
virtual ~SoundFileWriter() {}
|
virtual ~SoundFileWriter()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Open a sound file for writing
|
/// \brief Open a sound file for writing
|
||||||
@ -59,7 +61,9 @@ public:
|
|||||||
/// \return True if the file was successfully opened
|
/// \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
|
/// \brief Write audio samples to the open file
|
||||||
|
@ -29,11 +29,13 @@
|
|||||||
// Headers
|
// Headers
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
#include <SFML/Audio/Export.hpp>
|
#include <SFML/Audio/Export.hpp>
|
||||||
|
|
||||||
#include <SFML/Audio/AlResource.hpp>
|
#include <SFML/Audio/AlResource.hpp>
|
||||||
#include <SFML/System/Time.hpp>
|
#include <SFML/System/Time.hpp>
|
||||||
#include <vector>
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <thread>
|
#include <thread>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
|
||||||
namespace sf
|
namespace sf
|
||||||
@ -45,7 +47,6 @@ namespace sf
|
|||||||
class SFML_AUDIO_API SoundRecorder : AlResource
|
class SFML_AUDIO_API SoundRecorder : AlResource
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief destructor
|
/// \brief destructor
|
||||||
///
|
///
|
||||||
@ -186,7 +187,6 @@ public:
|
|||||||
static bool isAvailable();
|
static bool isAvailable();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Default constructor
|
/// \brief Default constructor
|
||||||
///
|
///
|
||||||
@ -254,7 +254,6 @@ protected:
|
|||||||
virtual void onStop();
|
virtual void onStop();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Function called as the entry point of the thread
|
/// \brief Function called as the entry point of the thread
|
||||||
///
|
///
|
||||||
|
@ -29,6 +29,7 @@
|
|||||||
// Headers
|
// Headers
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
#include <SFML/Audio/Export.hpp>
|
#include <SFML/Audio/Export.hpp>
|
||||||
|
|
||||||
#include <SFML/Audio/AlResource.hpp>
|
#include <SFML/Audio/AlResource.hpp>
|
||||||
#include <SFML/System/Vector3.hpp>
|
#include <SFML/System/Vector3.hpp>
|
||||||
|
|
||||||
@ -42,7 +43,6 @@ namespace sf
|
|||||||
class SFML_AUDIO_API SoundSource : AlResource
|
class SFML_AUDIO_API SoundSource : AlResource
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Enumeration of the sound source states
|
/// \brief Enumeration of the sound source states
|
||||||
///
|
///
|
||||||
@ -278,7 +278,6 @@ public:
|
|||||||
virtual Status getStatus() const;
|
virtual Status getStatus() const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Default constructor
|
/// \brief Default constructor
|
||||||
///
|
///
|
||||||
|
@ -29,8 +29,10 @@
|
|||||||
// Headers
|
// Headers
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
#include <SFML/Audio/Export.hpp>
|
#include <SFML/Audio/Export.hpp>
|
||||||
|
|
||||||
#include <SFML/Audio/SoundSource.hpp>
|
#include <SFML/Audio/SoundSource.hpp>
|
||||||
#include <SFML/System/Time.hpp>
|
#include <SFML/System/Time.hpp>
|
||||||
|
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <mutex>
|
#include <mutex>
|
||||||
#include <thread>
|
#include <thread>
|
||||||
@ -45,7 +47,6 @@ namespace sf
|
|||||||
class SFML_AUDIO_API SoundStream : public SoundSource
|
class SFML_AUDIO_API SoundStream : public SoundSource
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Structure defining a chunk of audio data to stream
|
/// \brief Structure defining a chunk of audio data to stream
|
||||||
///
|
///
|
||||||
@ -179,7 +180,6 @@ public:
|
|||||||
bool getLoop() const;
|
bool getLoop() const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
NoLoop = -1 //!< "Invalid" endSeeks value, telling us to continue uninterrupted
|
NoLoop = -1 //!< "Invalid" endSeeks value, telling us to continue uninterrupted
|
||||||
@ -266,7 +266,6 @@ protected:
|
|||||||
void setProcessingInterval(Time interval);
|
void setProcessingInterval(Time interval);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Function called as the entry point of the thread
|
/// \brief Function called as the entry point of the thread
|
||||||
///
|
///
|
||||||
|
@ -29,7 +29,6 @@
|
|||||||
// Headers
|
// Headers
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
#include <SFML/Window.hpp>
|
|
||||||
#include <SFML/Graphics/BlendMode.hpp>
|
#include <SFML/Graphics/BlendMode.hpp>
|
||||||
#include <SFML/Graphics/CircleShape.hpp>
|
#include <SFML/Graphics/CircleShape.hpp>
|
||||||
#include <SFML/Graphics/Color.hpp>
|
#include <SFML/Graphics/Color.hpp>
|
||||||
@ -56,6 +55,7 @@
|
|||||||
#include <SFML/Graphics/VertexArray.hpp>
|
#include <SFML/Graphics/VertexArray.hpp>
|
||||||
#include <SFML/Graphics/VertexBuffer.hpp>
|
#include <SFML/Graphics/VertexBuffer.hpp>
|
||||||
#include <SFML/Graphics/View.hpp>
|
#include <SFML/Graphics/View.hpp>
|
||||||
|
#include <SFML/Window.hpp>
|
||||||
|
|
||||||
|
|
||||||
#endif // SFML_GRAPHICS_HPP
|
#endif // SFML_GRAPHICS_HPP
|
||||||
|
@ -107,9 +107,12 @@ struct SFML_GRAPHICS_API BlendMode
|
|||||||
/// \param alphaBlendEquation Specifies how to combine the source and destination alphas.
|
/// \param alphaBlendEquation Specifies how to combine the source and destination alphas.
|
||||||
///
|
///
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
BlendMode(Factor colorSourceFactor, Factor colorDestinationFactor,
|
BlendMode(Factor colorSourceFactor,
|
||||||
Equation colorBlendEquation, Factor alphaSourceFactor,
|
Factor colorDestinationFactor,
|
||||||
Factor alphaDestinationFactor, Equation alphaBlendEquation);
|
Equation colorBlendEquation,
|
||||||
|
Factor alphaSourceFactor,
|
||||||
|
Factor alphaDestinationFactor,
|
||||||
|
Equation alphaBlendEquation);
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
// Member Data
|
// Member Data
|
||||||
|
@ -29,6 +29,7 @@
|
|||||||
// Headers
|
// Headers
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
#include <SFML/Graphics/Export.hpp>
|
#include <SFML/Graphics/Export.hpp>
|
||||||
|
|
||||||
#include <SFML/Graphics/Shape.hpp>
|
#include <SFML/Graphics/Shape.hpp>
|
||||||
|
|
||||||
|
|
||||||
@ -41,7 +42,6 @@ namespace sf
|
|||||||
class SFML_GRAPHICS_API CircleShape : public Shape
|
class SFML_GRAPHICS_API CircleShape : public Shape
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Default constructor
|
/// \brief Default constructor
|
||||||
///
|
///
|
||||||
@ -107,7 +107,6 @@ public:
|
|||||||
Vector2f getPoint(std::size_t index) const override;
|
Vector2f getPoint(std::size_t index) const override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
// Member data
|
// Member data
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
|
@ -40,7 +40,6 @@ namespace sf
|
|||||||
class Color
|
class Color
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Default constructor
|
/// \brief Default constructor
|
||||||
///
|
///
|
||||||
|
@ -24,24 +24,14 @@
|
|||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
constexpr Color::Color() :
|
constexpr Color::Color() : r(0), g(0), b(0), a(255)
|
||||||
r(0),
|
|
||||||
g(0),
|
|
||||||
b(0),
|
|
||||||
a(255)
|
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
constexpr Color::Color(Uint8 red, Uint8 green, Uint8 blue, Uint8 alpha) :
|
constexpr Color::Color(Uint8 red, Uint8 green, Uint8 blue, Uint8 alpha) : r(red), g(green), b(blue), a(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)),
|
b(static_cast<Uint8>((color & 0x0000ff00) >> 8)),
|
||||||
a(static_cast<Uint8>(color & 0x000000ff))
|
a(static_cast<Uint8>(color & 0x000000ff))
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -66,10 +55,7 @@ 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) &&
|
return (left.r == right.r) && (left.g == right.g) && (left.b == right.b) && (left.a == right.a);
|
||||||
(left.g == right.g) &&
|
|
||||||
(left.b == right.b) &&
|
|
||||||
(left.a == right.a);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -29,7 +29,9 @@
|
|||||||
// Headers
|
// Headers
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
#include <SFML/Graphics/Export.hpp>
|
#include <SFML/Graphics/Export.hpp>
|
||||||
|
|
||||||
#include <SFML/Graphics/Shape.hpp>
|
#include <SFML/Graphics/Shape.hpp>
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
|
||||||
@ -42,7 +44,6 @@ namespace sf
|
|||||||
class SFML_GRAPHICS_API ConvexShape : public Shape
|
class SFML_GRAPHICS_API ConvexShape : public Shape
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Default constructor
|
/// \brief Default constructor
|
||||||
///
|
///
|
||||||
@ -112,7 +113,6 @@ public:
|
|||||||
Vector2f getPoint(std::size_t index) const override;
|
Vector2f getPoint(std::size_t index) const override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
// Member data
|
// Member data
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
|
@ -44,15 +44,15 @@ class RenderStates;
|
|||||||
class SFML_GRAPHICS_API Drawable
|
class SFML_GRAPHICS_API Drawable
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Virtual destructor
|
/// \brief Virtual destructor
|
||||||
///
|
///
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
virtual ~Drawable() {}
|
virtual ~Drawable()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
friend class RenderTarget;
|
friend class RenderTarget;
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
|
@ -29,9 +29,11 @@
|
|||||||
// Headers
|
// Headers
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
#include <SFML/Graphics/Export.hpp>
|
#include <SFML/Graphics/Export.hpp>
|
||||||
|
|
||||||
#include <SFML/Graphics/Glyph.hpp>
|
#include <SFML/Graphics/Glyph.hpp>
|
||||||
#include <SFML/Graphics/Texture.hpp>
|
|
||||||
#include <SFML/Graphics/Rect.hpp>
|
#include <SFML/Graphics/Rect.hpp>
|
||||||
|
#include <SFML/Graphics/Texture.hpp>
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
@ -56,7 +58,6 @@ class InputStream;
|
|||||||
class SFML_GRAPHICS_API Font
|
class SFML_GRAPHICS_API Font
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Holds various information about a font
|
/// \brief Holds various information about a font
|
||||||
///
|
///
|
||||||
@ -67,7 +68,6 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Default constructor
|
/// \brief Default constructor
|
||||||
///
|
///
|
||||||
@ -330,14 +330,15 @@ public:
|
|||||||
Font& operator=(const Font& right);
|
Font& operator=(const Font& right);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Structure defining a row of glyphs
|
/// \brief Structure defining a row of glyphs
|
||||||
///
|
///
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
struct Row
|
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 width; //!< Current width of the row
|
||||||
unsigned int top; //!< Y position of the row into the texture
|
unsigned int top; //!< Y position of the row into the texture
|
||||||
|
@ -28,10 +28,11 @@
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
// Headers
|
// Headers
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
#include <SFML/Graphics/Transform.hpp>
|
|
||||||
#include <SFML/Graphics/Color.hpp>
|
#include <SFML/Graphics/Color.hpp>
|
||||||
|
#include <SFML/Graphics/Transform.hpp>
|
||||||
#include <SFML/System/Vector2.hpp>
|
#include <SFML/System/Vector2.hpp>
|
||||||
#include <SFML/System/Vector3.hpp>
|
#include <SFML/System/Vector3.hpp>
|
||||||
|
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
|
|
||||||
|
|
||||||
@ -108,7 +109,7 @@ namespace Glsl
|
|||||||
/// sf::Glsl::Vec4 color = sf::Color::Cyan;
|
/// sf::Glsl::Vec4 color = sf::Color::Cyan;
|
||||||
/// \endcode
|
/// \endcode
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
using Vec4 = implementation-defined;
|
using Vec4 = ImplementationDefined;
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief 4D int vector (\p ivec4 in GLSL)
|
/// \brief 4D int vector (\p ivec4 in GLSL)
|
||||||
@ -122,13 +123,13 @@ namespace Glsl
|
|||||||
/// sf::Glsl::Ivec4 color = sf::Color::Cyan;
|
/// sf::Glsl::Ivec4 color = sf::Color::Cyan;
|
||||||
/// \endcode
|
/// \endcode
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
using Ivec4 = implementation-defined;
|
using Ivec4 = ImplementationDefined;
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief 4D bool vector (\p bvec4 in GLSL)
|
/// \brief 4D bool vector (\p bvec4 in GLSL)
|
||||||
///
|
///
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
using Bvec4 = implementation-defined;
|
using Bvec4 = ImplementationDefined;
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief 3x3 float matrix (\p mat3 in GLSL)
|
/// \brief 3x3 float matrix (\p mat3 in GLSL)
|
||||||
@ -153,7 +154,7 @@ namespace Glsl
|
|||||||
/// sf::Glsl::Mat3 matrix = transform;
|
/// sf::Glsl::Mat3 matrix = transform;
|
||||||
/// \endcode
|
/// \endcode
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
using Mat3 = implementation-defined;
|
using Mat3 = ImplementationDefined;
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief 4x4 float matrix (\p mat4 in GLSL)
|
/// \brief 4x4 float matrix (\p mat4 in GLSL)
|
||||||
@ -179,7 +180,7 @@ namespace Glsl
|
|||||||
/// sf::Glsl::Mat4 matrix = transform;
|
/// sf::Glsl::Mat4 matrix = transform;
|
||||||
/// \endcode
|
/// \endcode
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
using Mat4 = implementation-defined;
|
using Mat4 = ImplementationDefined;
|
||||||
|
|
||||||
#else // SFML_DOXYGEN
|
#else // SFML_DOXYGEN
|
||||||
|
|
||||||
|
@ -95,11 +95,7 @@ struct Vector4
|
|||||||
/// \brief Default constructor, creates a zero vector
|
/// \brief Default constructor, creates a zero vector
|
||||||
///
|
///
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
Vector4() :
|
Vector4() : x(0), y(0), z(0), w(0)
|
||||||
x(0),
|
|
||||||
y(0),
|
|
||||||
z(0),
|
|
||||||
w(0)
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -112,11 +108,7 @@ struct Vector4
|
|||||||
/// \param W Component of the 4D vector
|
/// \param W Component of the 4D vector
|
||||||
///
|
///
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
Vector4(T X, T Y, T Z, T W) :
|
Vector4(T X, T Y, T Z, T W) : x(X), y(Y), z(Z), w(W)
|
||||||
x(X),
|
|
||||||
y(Y),
|
|
||||||
z(Z),
|
|
||||||
w(W)
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -29,6 +29,7 @@
|
|||||||
// Headers
|
// Headers
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
#include <SFML/Graphics/Export.hpp>
|
#include <SFML/Graphics/Export.hpp>
|
||||||
|
|
||||||
#include <SFML/Graphics/Rect.hpp>
|
#include <SFML/Graphics/Rect.hpp>
|
||||||
|
|
||||||
|
|
||||||
@ -41,12 +42,13 @@ namespace sf
|
|||||||
class SFML_GRAPHICS_API Glyph
|
class SFML_GRAPHICS_API Glyph
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Default constructor
|
/// \brief Default constructor
|
||||||
///
|
///
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
Glyph() : advance(0), lsbDelta(0), rsbDelta(0) {}
|
Glyph() : advance(0), lsbDelta(0), rsbDelta(0)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
// Member data
|
// Member data
|
||||||
|
@ -29,8 +29,10 @@
|
|||||||
// Headers
|
// Headers
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
#include <SFML/Graphics/Export.hpp>
|
#include <SFML/Graphics/Export.hpp>
|
||||||
|
|
||||||
#include <SFML/Graphics/Color.hpp>
|
#include <SFML/Graphics/Color.hpp>
|
||||||
#include <SFML/Graphics/Rect.hpp>
|
#include <SFML/Graphics/Rect.hpp>
|
||||||
|
|
||||||
#include <filesystem>
|
#include <filesystem>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
@ -47,7 +49,6 @@ class InputStream;
|
|||||||
class SFML_GRAPHICS_API Image
|
class SFML_GRAPHICS_API Image
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Create the image and fill it with a unique color
|
/// \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
|
/// \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
|
/// \brief Change the color of a pixel
|
||||||
@ -272,7 +276,6 @@ public:
|
|||||||
void flipVertically();
|
void flipVertically();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
// Member data
|
// Member data
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
|
@ -29,6 +29,7 @@
|
|||||||
// Headers
|
// Headers
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
#include <SFML/System/Vector2.hpp>
|
#include <SFML/System/Vector2.hpp>
|
||||||
|
|
||||||
#include <optional>
|
#include <optional>
|
||||||
|
|
||||||
|
|
||||||
@ -42,7 +43,6 @@ template <typename T>
|
|||||||
class Rect
|
class Rect
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Default constructor
|
/// \brief Default constructor
|
||||||
///
|
///
|
||||||
|
@ -25,13 +25,8 @@
|
|||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
template <typename T>
|
template <typename T>
|
||||||
constexpr Rect<T>::Rect() :
|
constexpr Rect<T>::Rect() : left(0), top(0), width(0), height(0)
|
||||||
left (0),
|
|
||||||
top (0),
|
|
||||||
width (0),
|
|
||||||
height(0)
|
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -43,7 +38,6 @@ top (position.y),
|
|||||||
width(size.x),
|
width(size.x),
|
||||||
height(size.y)
|
height(size.y)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -139,8 +133,8 @@ constexpr Vector2<T> Rect<T>::getSize() const
|
|||||||
template <typename T>
|
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) &&
|
return (left.left == right.left) && (left.width == right.width) && (left.top == right.top) &&
|
||||||
(left.top == right.top) && (left.height == right.height);
|
(left.height == right.height);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -29,6 +29,7 @@
|
|||||||
// Headers
|
// Headers
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
#include <SFML/Graphics/Export.hpp>
|
#include <SFML/Graphics/Export.hpp>
|
||||||
|
|
||||||
#include <SFML/Graphics/Shape.hpp>
|
#include <SFML/Graphics/Shape.hpp>
|
||||||
|
|
||||||
|
|
||||||
@ -41,7 +42,6 @@ namespace sf
|
|||||||
class SFML_GRAPHICS_API RectangleShape : public Shape
|
class SFML_GRAPHICS_API RectangleShape : public Shape
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Default constructor
|
/// \brief Default constructor
|
||||||
///
|
///
|
||||||
@ -95,7 +95,6 @@ public:
|
|||||||
Vector2f getPoint(std::size_t index) const override;
|
Vector2f getPoint(std::size_t index) const override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
// Member data
|
// Member data
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
|
@ -29,6 +29,7 @@
|
|||||||
// Headers
|
// Headers
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
#include <SFML/Graphics/Export.hpp>
|
#include <SFML/Graphics/Export.hpp>
|
||||||
|
|
||||||
#include <SFML/Graphics/BlendMode.hpp>
|
#include <SFML/Graphics/BlendMode.hpp>
|
||||||
#include <SFML/Graphics/Transform.hpp>
|
#include <SFML/Graphics/Transform.hpp>
|
||||||
|
|
||||||
@ -45,7 +46,6 @@ class Texture;
|
|||||||
class SFML_GRAPHICS_API RenderStates
|
class SFML_GRAPHICS_API RenderStates
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Default constructor
|
/// \brief Default constructor
|
||||||
///
|
///
|
||||||
@ -101,8 +101,7 @@ public:
|
|||||||
/// \param theShader Shader to use
|
/// \param theShader Shader to use
|
||||||
///
|
///
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
RenderStates(const BlendMode& theBlendMode, const Transform& theTransform,
|
RenderStates(const BlendMode& theBlendMode, const Transform& theTransform, const Texture* theTexture, const Shader* theShader);
|
||||||
const Texture* theTexture, const Shader* theShader);
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
// Static member data
|
// Static member data
|
||||||
|
@ -29,13 +29,15 @@
|
|||||||
// Headers
|
// Headers
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
#include <SFML/Graphics/Export.hpp>
|
#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/BlendMode.hpp>
|
||||||
#include <SFML/Graphics/RenderStates.hpp>
|
#include <SFML/Graphics/Color.hpp>
|
||||||
#include <SFML/Graphics/PrimitiveType.hpp>
|
#include <SFML/Graphics/PrimitiveType.hpp>
|
||||||
|
#include <SFML/Graphics/Rect.hpp>
|
||||||
|
#include <SFML/Graphics/RenderStates.hpp>
|
||||||
#include <SFML/Graphics/Vertex.hpp>
|
#include <SFML/Graphics/Vertex.hpp>
|
||||||
|
#include <SFML/Graphics/View.hpp>
|
||||||
|
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
|
|
||||||
|
|
||||||
@ -52,7 +54,6 @@ class Transform;
|
|||||||
class SFML_GRAPHICS_API RenderTarget
|
class SFML_GRAPHICS_API RenderTarget
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Destructor
|
/// \brief Destructor
|
||||||
///
|
///
|
||||||
@ -257,8 +258,10 @@ public:
|
|||||||
/// \param states Render states to use for drawing
|
/// \param states Render states to use for drawing
|
||||||
///
|
///
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
void draw(const Vertex* vertices, std::size_t vertexCount,
|
void draw(const Vertex* vertices,
|
||||||
PrimitiveType type, const RenderStates& states = RenderStates::Default);
|
std::size_t vertexCount,
|
||||||
|
PrimitiveType type,
|
||||||
|
const RenderStates& states = RenderStates::Default);
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Draw primitives defined by a vertex buffer
|
/// \brief Draw primitives defined by a vertex buffer
|
||||||
@ -278,7 +281,10 @@ public:
|
|||||||
/// \param states Render states to use for drawing
|
/// \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
|
/// \brief Return the size of the rendering region of the target
|
||||||
@ -387,7 +393,6 @@ public:
|
|||||||
void resetGLStates();
|
void resetGLStates();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Default constructor
|
/// \brief Default constructor
|
||||||
///
|
///
|
||||||
@ -404,7 +409,6 @@ protected:
|
|||||||
void initialize();
|
void initialize();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Apply the current view
|
/// \brief Apply the current view
|
||||||
///
|
///
|
||||||
@ -476,7 +480,10 @@ private:
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
struct StatesCache
|
struct StatesCache
|
||||||
{
|
{
|
||||||
enum {VertexCacheSize = 4};
|
enum
|
||||||
|
{
|
||||||
|
VertexCacheSize = 4
|
||||||
|
};
|
||||||
|
|
||||||
bool enable; //!< Is the cache enabled?
|
bool enable; //!< Is the cache enabled?
|
||||||
bool glStatesSet; //!< Are our internal GL states set yet?
|
bool glStatesSet; //!< Are our internal GL states set yet?
|
||||||
|
@ -29,9 +29,11 @@
|
|||||||
// Headers
|
// Headers
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
#include <SFML/Graphics/Export.hpp>
|
#include <SFML/Graphics/Export.hpp>
|
||||||
#include <SFML/Graphics/Texture.hpp>
|
|
||||||
#include <SFML/Graphics/RenderTarget.hpp>
|
#include <SFML/Graphics/RenderTarget.hpp>
|
||||||
|
#include <SFML/Graphics/Texture.hpp>
|
||||||
#include <SFML/Window/ContextSettings.hpp>
|
#include <SFML/Window/ContextSettings.hpp>
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
|
|
||||||
@ -49,7 +51,6 @@ namespace priv
|
|||||||
class SFML_GRAPHICS_API RenderTexture : public RenderTarget
|
class SFML_GRAPHICS_API RenderTexture : public RenderTarget
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Default constructor
|
/// \brief Default constructor
|
||||||
///
|
///
|
||||||
@ -224,7 +225,6 @@ public:
|
|||||||
const Texture& getTexture() const;
|
const Texture& getTexture() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
// Member data
|
// Member data
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
|
@ -29,6 +29,7 @@
|
|||||||
// Headers
|
// Headers
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
#include <SFML/Graphics/Export.hpp>
|
#include <SFML/Graphics/Export.hpp>
|
||||||
|
|
||||||
#include <SFML/Graphics/RenderTarget.hpp>
|
#include <SFML/Graphics/RenderTarget.hpp>
|
||||||
#include <SFML/Window/Window.hpp>
|
#include <SFML/Window/Window.hpp>
|
||||||
|
|
||||||
@ -42,7 +43,6 @@ namespace sf
|
|||||||
class SFML_GRAPHICS_API RenderWindow : public Window, public RenderTarget
|
class SFML_GRAPHICS_API RenderWindow : public Window, public RenderTarget
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Default constructor
|
/// \brief Default constructor
|
||||||
///
|
///
|
||||||
@ -71,7 +71,10 @@ public:
|
|||||||
/// \param settings Additional settings for the underlying OpenGL context
|
/// \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
|
/// \brief Construct the window from an existing control
|
||||||
@ -140,7 +143,6 @@ public:
|
|||||||
[[nodiscard]] bool setActive(bool active = true) override;
|
[[nodiscard]] bool setActive(bool active = true) override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Function called after the window has been created
|
/// \brief Function called after the window has been created
|
||||||
///
|
///
|
||||||
@ -161,7 +163,6 @@ protected:
|
|||||||
void onResize() override;
|
void onResize() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
// Member data
|
// Member data
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
|
@ -29,10 +29,12 @@
|
|||||||
// Headers
|
// Headers
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
#include <SFML/Graphics/Export.hpp>
|
#include <SFML/Graphics/Export.hpp>
|
||||||
|
|
||||||
#include <SFML/Graphics/Glsl.hpp>
|
#include <SFML/Graphics/Glsl.hpp>
|
||||||
#include <SFML/Window/GlResource.hpp>
|
|
||||||
#include <SFML/System/Vector2.hpp>
|
#include <SFML/System/Vector2.hpp>
|
||||||
#include <SFML/System/Vector3.hpp>
|
#include <SFML/System/Vector3.hpp>
|
||||||
|
#include <SFML/Window/GlResource.hpp>
|
||||||
|
|
||||||
#include <filesystem>
|
#include <filesystem>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
@ -52,7 +54,6 @@ class Transform;
|
|||||||
class SFML_GRAPHICS_API Shader : GlResource
|
class SFML_GRAPHICS_API Shader : GlResource
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Types of shaders
|
/// \brief Types of shaders
|
||||||
///
|
///
|
||||||
@ -71,7 +72,9 @@ public:
|
|||||||
/// \see setUniform(const std::string&, CurrentTextureType)
|
/// \see setUniform(const std::string&, CurrentTextureType)
|
||||||
///
|
///
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
struct CurrentTextureType {};
|
struct CurrentTextureType
|
||||||
|
{
|
||||||
|
};
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Represents the texture of the object being drawn
|
/// \brief Represents the texture of the object being drawn
|
||||||
@ -82,7 +85,6 @@ public:
|
|||||||
static CurrentTextureType CurrentTexture;
|
static CurrentTextureType CurrentTexture;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Default constructor
|
/// \brief Default constructor
|
||||||
///
|
///
|
||||||
@ -149,7 +151,8 @@ public:
|
|||||||
/// \see loadFromMemory, loadFromStream
|
/// \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
|
/// \brief Load the vertex, geometry and fragment shaders from files
|
||||||
@ -171,7 +174,9 @@ public:
|
|||||||
/// \see loadFromMemory, loadFromStream
|
/// \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
|
/// \brief Load the vertex, geometry or fragment shader from a source code in memory
|
||||||
@ -234,7 +239,9 @@ public:
|
|||||||
/// \see loadFromFile, loadFromStream
|
/// \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
|
/// \brief Load the vertex, geometry or fragment shader from a custom stream
|
||||||
@ -297,7 +304,9 @@ public:
|
|||||||
/// \see loadFromFile, loadFromMemory
|
/// \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
|
/// \brief Specify value for \p float uniform
|
||||||
@ -624,7 +633,6 @@ public:
|
|||||||
static bool isGeometryAvailable();
|
static bool isGeometryAvailable();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Compile the shader(s) and create the program
|
/// \brief Compile the shader(s) and create the program
|
||||||
///
|
///
|
||||||
|
@ -29,6 +29,7 @@
|
|||||||
// Headers
|
// Headers
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
#include <SFML/Graphics/Export.hpp>
|
#include <SFML/Graphics/Export.hpp>
|
||||||
|
|
||||||
#include <SFML/Graphics/Drawable.hpp>
|
#include <SFML/Graphics/Drawable.hpp>
|
||||||
#include <SFML/Graphics/Transformable.hpp>
|
#include <SFML/Graphics/Transformable.hpp>
|
||||||
#include <SFML/Graphics/VertexArray.hpp>
|
#include <SFML/Graphics/VertexArray.hpp>
|
||||||
@ -46,7 +47,6 @@ class Texture;
|
|||||||
class SFML_GRAPHICS_API Shape : public Drawable, public Transformable
|
class SFML_GRAPHICS_API Shape : public Drawable, public Transformable
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Virtual destructor
|
/// \brief Virtual destructor
|
||||||
///
|
///
|
||||||
@ -250,7 +250,6 @@ public:
|
|||||||
FloatRect getGlobalBounds() const;
|
FloatRect getGlobalBounds() const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Default constructor
|
/// \brief Default constructor
|
||||||
///
|
///
|
||||||
@ -268,7 +267,6 @@ protected:
|
|||||||
void update();
|
void update();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Draw the shape to a render target
|
/// \brief Draw the shape to a render target
|
||||||
///
|
///
|
||||||
@ -303,7 +301,6 @@ private:
|
|||||||
void updateOutlineColors();
|
void updateOutlineColors();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
// Member data
|
// Member data
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
|
@ -29,10 +29,11 @@
|
|||||||
// Headers
|
// Headers
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
#include <SFML/Graphics/Export.hpp>
|
#include <SFML/Graphics/Export.hpp>
|
||||||
|
|
||||||
#include <SFML/Graphics/Drawable.hpp>
|
#include <SFML/Graphics/Drawable.hpp>
|
||||||
|
#include <SFML/Graphics/Rect.hpp>
|
||||||
#include <SFML/Graphics/Transformable.hpp>
|
#include <SFML/Graphics/Transformable.hpp>
|
||||||
#include <SFML/Graphics/Vertex.hpp>
|
#include <SFML/Graphics/Vertex.hpp>
|
||||||
#include <SFML/Graphics/Rect.hpp>
|
|
||||||
|
|
||||||
|
|
||||||
namespace sf
|
namespace sf
|
||||||
@ -47,7 +48,6 @@ class Texture;
|
|||||||
class SFML_GRAPHICS_API Sprite : public Drawable, public Transformable
|
class SFML_GRAPHICS_API Sprite : public Drawable, public Transformable
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Default constructor
|
/// \brief Default constructor
|
||||||
///
|
///
|
||||||
@ -190,7 +190,6 @@ public:
|
|||||||
FloatRect getGlobalBounds() const;
|
FloatRect getGlobalBounds() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Draw the sprite to a render target
|
/// \brief Draw the sprite to a render target
|
||||||
///
|
///
|
||||||
|
@ -29,11 +29,13 @@
|
|||||||
// Headers
|
// Headers
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
#include <SFML/Graphics/Export.hpp>
|
#include <SFML/Graphics/Export.hpp>
|
||||||
|
|
||||||
#include <SFML/Graphics/Drawable.hpp>
|
#include <SFML/Graphics/Drawable.hpp>
|
||||||
#include <SFML/Graphics/Transformable.hpp>
|
|
||||||
#include <SFML/Graphics/Rect.hpp>
|
#include <SFML/Graphics/Rect.hpp>
|
||||||
|
#include <SFML/Graphics/Transformable.hpp>
|
||||||
#include <SFML/Graphics/VertexArray.hpp>
|
#include <SFML/Graphics/VertexArray.hpp>
|
||||||
#include <SFML/System/String.hpp>
|
#include <SFML/System/String.hpp>
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
@ -49,7 +51,6 @@ class Font;
|
|||||||
class SFML_GRAPHICS_API Text : public Drawable, public Transformable
|
class SFML_GRAPHICS_API Text : public Drawable, public Transformable
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Enumeration of the string drawing styles
|
/// \brief Enumeration of the string drawing styles
|
||||||
///
|
///
|
||||||
@ -406,7 +407,6 @@ public:
|
|||||||
FloatRect getGlobalBounds() const;
|
FloatRect getGlobalBounds() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Draw the text to a render target
|
/// \brief Draw the text to a render target
|
||||||
///
|
///
|
||||||
|
@ -29,8 +29,10 @@
|
|||||||
// Headers
|
// Headers
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
#include <SFML/Graphics/Export.hpp>
|
#include <SFML/Graphics/Export.hpp>
|
||||||
#include <SFML/Window/GlResource.hpp>
|
|
||||||
#include <SFML/Graphics/Rect.hpp>
|
#include <SFML/Graphics/Rect.hpp>
|
||||||
|
#include <SFML/Window/GlResource.hpp>
|
||||||
|
|
||||||
#include <filesystem>
|
#include <filesystem>
|
||||||
|
|
||||||
|
|
||||||
@ -50,7 +52,6 @@ class Image;
|
|||||||
class SFML_GRAPHICS_API Texture : GlResource
|
class SFML_GRAPHICS_API Texture : GlResource
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Types of texture coordinates that can be used for rendering
|
/// \brief Types of texture coordinates that can be used for rendering
|
||||||
///
|
///
|
||||||
@ -62,7 +63,6 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Default constructor
|
/// \brief Default constructor
|
||||||
///
|
///
|
||||||
@ -580,7 +580,6 @@ public:
|
|||||||
static unsigned int getMaximumSize();
|
static unsigned int getMaximumSize();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
friend class Text;
|
friend class Text;
|
||||||
friend class RenderTexture;
|
friend class RenderTexture;
|
||||||
friend class RenderTarget;
|
friend class RenderTarget;
|
||||||
|
@ -29,6 +29,7 @@
|
|||||||
// Headers
|
// Headers
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
#include <SFML/Graphics/Export.hpp>
|
#include <SFML/Graphics/Export.hpp>
|
||||||
|
|
||||||
#include <SFML/Graphics/Rect.hpp>
|
#include <SFML/Graphics/Rect.hpp>
|
||||||
#include <SFML/System/Vector2.hpp>
|
#include <SFML/System/Vector2.hpp>
|
||||||
|
|
||||||
@ -44,7 +45,6 @@ class Angle;
|
|||||||
class Transform
|
class Transform
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Default constructor
|
/// \brief Default constructor
|
||||||
///
|
///
|
||||||
@ -67,9 +67,7 @@ public:
|
|||||||
/// \param a22 Element (2, 2) of the matrix
|
/// \param a22 Element (2, 2) of the matrix
|
||||||
///
|
///
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
constexpr Transform(float a00, float a01, float a02,
|
constexpr Transform(float a00, float a01, float a02, float a10, float a11, float a12, float a20, float a21, float a22);
|
||||||
float a10, float a11, float a12,
|
|
||||||
float a20, float a21, float a22);
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Return the transform as a 4x4 matrix
|
/// \brief Return the transform as a 4x4 matrix
|
||||||
@ -264,7 +262,6 @@ public:
|
|||||||
static const Transform Identity; //!< The identity transform (does nothing)
|
static const Transform Identity; //!< The identity transform (does nothing)
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
// Member data
|
// Member data
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
|
@ -102,13 +102,10 @@ constexpr Vector2f Transform::transformPoint(const Vector2f& point) const
|
|||||||
constexpr FloatRect Transform::transformRect(const FloatRect& rectangle) const
|
constexpr FloatRect Transform::transformRect(const FloatRect& rectangle) const
|
||||||
{
|
{
|
||||||
// Transform the 4 corners of the rectangle
|
// Transform the 4 corners of the rectangle
|
||||||
const Vector2f points[] =
|
const Vector2f points[] = {transformPoint({rectangle.left, rectangle.top}),
|
||||||
{
|
|
||||||
transformPoint({rectangle.left, rectangle.top}),
|
|
||||||
transformPoint({rectangle.left, rectangle.top + rectangle.height}),
|
transformPoint({rectangle.left, rectangle.top + rectangle.height}),
|
||||||
transformPoint({rectangle.left + rectangle.width, rectangle.top}),
|
transformPoint({rectangle.left + rectangle.width, rectangle.top}),
|
||||||
transformPoint({rectangle.left + rectangle.width, rectangle.top + rectangle.height})
|
transformPoint({rectangle.left + rectangle.width, rectangle.top + rectangle.height})};
|
||||||
};
|
|
||||||
|
|
||||||
// Compute the bounding rectangle of the transformed points
|
// Compute the bounding rectangle of the transformed points
|
||||||
float left = points[0].x;
|
float left = points[0].x;
|
||||||
|
@ -29,6 +29,7 @@
|
|||||||
// Headers
|
// Headers
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
#include <SFML/Graphics/Export.hpp>
|
#include <SFML/Graphics/Export.hpp>
|
||||||
|
|
||||||
#include <SFML/Graphics/Transform.hpp>
|
#include <SFML/Graphics/Transform.hpp>
|
||||||
#include <SFML/System/Angle.hpp>
|
#include <SFML/System/Angle.hpp>
|
||||||
|
|
||||||
@ -42,7 +43,6 @@ namespace sf
|
|||||||
class SFML_GRAPHICS_API Transformable
|
class SFML_GRAPHICS_API Transformable
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Default constructor
|
/// \brief Default constructor
|
||||||
///
|
///
|
||||||
@ -227,7 +227,6 @@ public:
|
|||||||
const Transform& getInverseTransform() const;
|
const Transform& getInverseTransform() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
// Member data
|
// Member data
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
|
@ -41,7 +41,6 @@ namespace sf
|
|||||||
class Vertex
|
class Vertex
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Default constructor
|
/// \brief Default constructor
|
||||||
///
|
///
|
||||||
|
@ -24,19 +24,13 @@
|
|||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
constexpr Vertex::Vertex() :
|
constexpr Vertex::Vertex() : position(0, 0), color(255, 255, 255), texCoords(0, 0)
|
||||||
position (0, 0),
|
|
||||||
color (255, 255, 255),
|
|
||||||
texCoords(0, 0)
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
constexpr Vertex::Vertex(const Vector2f& thePosition) :
|
constexpr Vertex::Vertex(const Vector2f& thePosition) : position(thePosition), color(255, 255, 255), texCoords(0, 0)
|
||||||
position (thePosition),
|
|
||||||
color (255, 255, 255),
|
|
||||||
texCoords(0, 0)
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -29,10 +29,12 @@
|
|||||||
// Headers
|
// Headers
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
#include <SFML/Graphics/Export.hpp>
|
#include <SFML/Graphics/Export.hpp>
|
||||||
#include <SFML/Graphics/Vertex.hpp>
|
|
||||||
|
#include <SFML/Graphics/Drawable.hpp>
|
||||||
#include <SFML/Graphics/PrimitiveType.hpp>
|
#include <SFML/Graphics/PrimitiveType.hpp>
|
||||||
#include <SFML/Graphics/Rect.hpp>
|
#include <SFML/Graphics/Rect.hpp>
|
||||||
#include <SFML/Graphics/Drawable.hpp>
|
#include <SFML/Graphics/Vertex.hpp>
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
|
||||||
@ -45,7 +47,6 @@ namespace sf
|
|||||||
class SFML_GRAPHICS_API VertexArray : public Drawable
|
class SFML_GRAPHICS_API VertexArray : public Drawable
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Default constructor
|
/// \brief Default constructor
|
||||||
///
|
///
|
||||||
@ -171,7 +172,6 @@ public:
|
|||||||
FloatRect getBounds() const;
|
FloatRect getBounds() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Draw the vertex array to a render target
|
/// \brief Draw the vertex array to a render target
|
||||||
///
|
///
|
||||||
@ -182,7 +182,6 @@ private:
|
|||||||
void draw(RenderTarget& target, const RenderStates& states) const override;
|
void draw(RenderTarget& target, const RenderStates& states) const override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
// Member data
|
// Member data
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
|
@ -29,9 +29,11 @@
|
|||||||
// Headers
|
// Headers
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
#include <SFML/Graphics/Export.hpp>
|
#include <SFML/Graphics/Export.hpp>
|
||||||
#include <SFML/Graphics/PrimitiveType.hpp>
|
|
||||||
#include <SFML/Graphics/Drawable.hpp>
|
#include <SFML/Graphics/Drawable.hpp>
|
||||||
|
#include <SFML/Graphics/PrimitiveType.hpp>
|
||||||
#include <SFML/Window/GlResource.hpp>
|
#include <SFML/Window/GlResource.hpp>
|
||||||
|
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
|
|
||||||
|
|
||||||
@ -47,7 +49,6 @@ class Vertex;
|
|||||||
class SFML_GRAPHICS_API VertexBuffer : public Drawable, private GlResource
|
class SFML_GRAPHICS_API VertexBuffer : public Drawable, private GlResource
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Usage specifiers
|
/// \brief Usage specifiers
|
||||||
///
|
///
|
||||||
@ -320,7 +321,6 @@ public:
|
|||||||
static bool isAvailable();
|
static bool isAvailable();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Draw the vertex buffer to a render target
|
/// \brief Draw the vertex buffer to a render target
|
||||||
///
|
///
|
||||||
@ -331,7 +331,6 @@ private:
|
|||||||
void draw(RenderTarget& target, const RenderStates& states) const override;
|
void draw(RenderTarget& target, const RenderStates& states) const override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
// Member data
|
// Member data
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
|
@ -29,6 +29,7 @@
|
|||||||
// Headers
|
// Headers
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
#include <SFML/Graphics/Export.hpp>
|
#include <SFML/Graphics/Export.hpp>
|
||||||
|
|
||||||
#include <SFML/Graphics/Rect.hpp>
|
#include <SFML/Graphics/Rect.hpp>
|
||||||
#include <SFML/Graphics/Transform.hpp>
|
#include <SFML/Graphics/Transform.hpp>
|
||||||
#include <SFML/System/Angle.hpp>
|
#include <SFML/System/Angle.hpp>
|
||||||
@ -44,7 +45,6 @@ namespace sf
|
|||||||
class SFML_GRAPHICS_API View
|
class SFML_GRAPHICS_API View
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Default constructor
|
/// \brief Default constructor
|
||||||
///
|
///
|
||||||
@ -233,7 +233,6 @@ public:
|
|||||||
const Transform& getInverseTransform() const;
|
const Transform& getInverseTransform() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
// Member data
|
// Member data
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
|
@ -29,7 +29,6 @@
|
|||||||
// Headers
|
// Headers
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
#include <SFML/System.hpp>
|
|
||||||
#include <SFML/Network/Ftp.hpp>
|
#include <SFML/Network/Ftp.hpp>
|
||||||
#include <SFML/Network/Http.hpp>
|
#include <SFML/Network/Http.hpp>
|
||||||
#include <SFML/Network/IpAddress.hpp>
|
#include <SFML/Network/IpAddress.hpp>
|
||||||
@ -40,6 +39,7 @@
|
|||||||
#include <SFML/Network/TcpListener.hpp>
|
#include <SFML/Network/TcpListener.hpp>
|
||||||
#include <SFML/Network/TcpSocket.hpp>
|
#include <SFML/Network/TcpSocket.hpp>
|
||||||
#include <SFML/Network/UdpSocket.hpp>
|
#include <SFML/Network/UdpSocket.hpp>
|
||||||
|
#include <SFML/System.hpp>
|
||||||
|
|
||||||
|
|
||||||
#endif // SFML_NETWORK_HPP
|
#endif // SFML_NETWORK_HPP
|
||||||
|
@ -29,8 +29,10 @@
|
|||||||
// Headers
|
// Headers
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
#include <SFML/Network/Export.hpp>
|
#include <SFML/Network/Export.hpp>
|
||||||
|
|
||||||
#include <SFML/Network/TcpSocket.hpp>
|
#include <SFML/Network/TcpSocket.hpp>
|
||||||
#include <SFML/System/Time.hpp>
|
#include <SFML/System/Time.hpp>
|
||||||
|
|
||||||
#include <filesystem>
|
#include <filesystem>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
@ -47,7 +49,6 @@ class IpAddress;
|
|||||||
class SFML_NETWORK_API Ftp
|
class SFML_NETWORK_API Ftp
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Enumeration of transfer modes
|
/// \brief Enumeration of transfer modes
|
||||||
///
|
///
|
||||||
@ -66,7 +67,6 @@ public:
|
|||||||
class SFML_NETWORK_API Response
|
class SFML_NETWORK_API Response
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Status codes possibly returned by a FTP response
|
/// \brief Status codes possibly returned by a FTP response
|
||||||
///
|
///
|
||||||
@ -173,7 +173,6 @@ public:
|
|||||||
const std::string& getMessage() const;
|
const std::string& getMessage() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
// Member data
|
// Member data
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
@ -188,7 +187,6 @@ public:
|
|||||||
class SFML_NETWORK_API DirectoryResponse : public Response
|
class SFML_NETWORK_API DirectoryResponse : public Response
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Default constructor
|
/// \brief Default constructor
|
||||||
///
|
///
|
||||||
@ -206,7 +204,6 @@ public:
|
|||||||
const std::filesystem::path& getDirectory() const;
|
const std::filesystem::path& getDirectory() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
// Member data
|
// Member data
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
@ -221,7 +218,6 @@ public:
|
|||||||
class SFML_NETWORK_API ListingResponse : public Response
|
class SFML_NETWORK_API ListingResponse : public Response
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Default constructor
|
/// \brief Default constructor
|
||||||
///
|
///
|
||||||
@ -240,7 +236,6 @@ public:
|
|||||||
const std::vector<std::string>& getListing() const;
|
const std::vector<std::string>& getListing() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
// Member data
|
// Member data
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
@ -482,7 +477,9 @@ public:
|
|||||||
/// \see upload
|
/// \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
|
/// \brief Upload a file to the server
|
||||||
@ -505,7 +502,10 @@ public:
|
|||||||
/// \see download
|
/// \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
|
/// \brief Send a command to the FTP server
|
||||||
@ -526,7 +526,6 @@ public:
|
|||||||
[[nodiscard]] Response sendCommand(const std::string& command, const std::string& parameter = "");
|
[[nodiscard]] Response sendCommand(const std::string& command, const std::string& parameter = "");
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Receive a response from the server
|
/// \brief Receive a response from the server
|
||||||
///
|
///
|
||||||
|
@ -29,9 +29,11 @@
|
|||||||
// Headers
|
// Headers
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
#include <SFML/Network/Export.hpp>
|
#include <SFML/Network/Export.hpp>
|
||||||
|
|
||||||
#include <SFML/Network/IpAddress.hpp>
|
#include <SFML/Network/IpAddress.hpp>
|
||||||
#include <SFML/Network/TcpSocket.hpp>
|
#include <SFML/Network/TcpSocket.hpp>
|
||||||
#include <SFML/System/Time.hpp>
|
#include <SFML/System/Time.hpp>
|
||||||
|
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <optional>
|
#include <optional>
|
||||||
#include <string>
|
#include <string>
|
||||||
@ -46,7 +48,6 @@ namespace sf
|
|||||||
class SFML_NETWORK_API Http
|
class SFML_NETWORK_API Http
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Define a HTTP request
|
/// \brief Define a HTTP request
|
||||||
///
|
///
|
||||||
@ -54,7 +55,6 @@ public:
|
|||||||
class SFML_NETWORK_API Request
|
class SFML_NETWORK_API Request
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Enumerate the available HTTP methods for a request
|
/// \brief Enumerate the available HTTP methods for a request
|
||||||
///
|
///
|
||||||
@ -144,7 +144,6 @@ public:
|
|||||||
void setBody(const std::string& body);
|
void setBody(const std::string& body);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
friend class Http;
|
friend class Http;
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
@ -193,7 +192,6 @@ public:
|
|||||||
class SFML_NETWORK_API Response
|
class SFML_NETWORK_API Response
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Enumerate all the valid status codes for a response
|
/// \brief Enumerate all the valid status codes for a response
|
||||||
///
|
///
|
||||||
@ -304,7 +302,6 @@ public:
|
|||||||
const std::string& getBody() const;
|
const std::string& getBody() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
friend class Http;
|
friend class Http;
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
@ -417,7 +414,6 @@ public:
|
|||||||
[[nodiscard]] Response sendRequest(const Request& request, Time timeout = Time::Zero);
|
[[nodiscard]] Response sendRequest(const Request& request, Time timeout = Time::Zero);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
// Member data
|
// Member data
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
|
@ -29,11 +29,13 @@
|
|||||||
// Headers
|
// Headers
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
#include <SFML/Network/Export.hpp>
|
#include <SFML/Network/Export.hpp>
|
||||||
|
|
||||||
#include <SFML/System/Time.hpp>
|
#include <SFML/System/Time.hpp>
|
||||||
|
|
||||||
#include <iosfwd>
|
#include <iosfwd>
|
||||||
#include <optional>
|
#include <optional>
|
||||||
#include <string_view>
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <string_view>
|
||||||
|
|
||||||
|
|
||||||
namespace sf
|
namespace sf
|
||||||
@ -164,7 +166,6 @@ public:
|
|||||||
static const IpAddress Broadcast; //!< The "broadcast" address (for sending UDP messages to everyone on a local network)
|
static const IpAddress Broadcast; //!< The "broadcast" address (for sending UDP messages to everyone on a local network)
|
||||||
|
|
||||||
private:
|
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);
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
|
@ -29,9 +29,10 @@
|
|||||||
// Headers
|
// Headers
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
#include <SFML/Network/Export.hpp>
|
#include <SFML/Network/Export.hpp>
|
||||||
|
|
||||||
|
#include <cstddef>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <cstddef>
|
|
||||||
|
|
||||||
|
|
||||||
namespace sf
|
namespace sf
|
||||||
@ -48,7 +49,6 @@ class UdpSocket;
|
|||||||
class SFML_NETWORK_API Packet
|
class SFML_NETWORK_API Packet
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Default constructor
|
/// \brief Default constructor
|
||||||
///
|
///
|
||||||
@ -164,7 +164,6 @@ public:
|
|||||||
bool endOfPacket() const;
|
bool endOfPacket() const;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Test the validity of the packet, for reading
|
/// \brief Test the validity of the packet, for reading
|
||||||
///
|
///
|
||||||
@ -368,7 +367,6 @@ public:
|
|||||||
Packet& operator<<(const String& data);
|
Packet& operator<<(const String& data);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
friend class TcpSocket;
|
friend class TcpSocket;
|
||||||
friend class UdpSocket;
|
friend class UdpSocket;
|
||||||
|
|
||||||
@ -412,7 +410,6 @@ protected:
|
|||||||
virtual void onReceive(const void* data, std::size_t size);
|
virtual void onReceive(const void* data, std::size_t size);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// Disallow comparisons between packets
|
/// Disallow comparisons between packets
|
||||||
///
|
///
|
||||||
|
@ -29,7 +29,9 @@
|
|||||||
// Headers
|
// Headers
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
#include <SFML/Network/Export.hpp>
|
#include <SFML/Network/Export.hpp>
|
||||||
|
|
||||||
#include <SFML/Network/SocketHandle.hpp>
|
#include <SFML/Network/SocketHandle.hpp>
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
|
||||||
@ -44,7 +46,6 @@ class SocketSelector;
|
|||||||
class SFML_NETWORK_API Socket
|
class SFML_NETWORK_API Socket
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Status codes that may be returned by socket functions
|
/// \brief Status codes that may be returned by socket functions
|
||||||
///
|
///
|
||||||
@ -68,7 +69,6 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Destructor
|
/// \brief Destructor
|
||||||
///
|
///
|
||||||
@ -117,7 +117,6 @@ public:
|
|||||||
bool isBlocking() const;
|
bool isBlocking() const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Types of protocols that the socket can use
|
/// \brief Types of protocols that the socket can use
|
||||||
///
|
///
|
||||||
@ -178,7 +177,6 @@ protected:
|
|||||||
void close();
|
void close();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
friend class SocketSelector;
|
friend class SocketSelector;
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
|
@ -29,7 +29,9 @@
|
|||||||
// Headers
|
// Headers
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
#include <SFML/Network/Export.hpp>
|
#include <SFML/Network/Export.hpp>
|
||||||
|
|
||||||
#include <SFML/System/Time.hpp>
|
#include <SFML/System/Time.hpp>
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
|
|
||||||
@ -44,7 +46,6 @@ class Socket;
|
|||||||
class SFML_NETWORK_API SocketSelector
|
class SFML_NETWORK_API SocketSelector
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Default constructor
|
/// \brief Default constructor
|
||||||
///
|
///
|
||||||
@ -153,7 +154,6 @@ public:
|
|||||||
SocketSelector& operator=(const SocketSelector& right);
|
SocketSelector& operator=(const SocketSelector& right);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
struct SocketSelectorImpl;
|
struct SocketSelectorImpl;
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
|
@ -29,8 +29,9 @@
|
|||||||
// Headers
|
// Headers
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
#include <SFML/Network/Export.hpp>
|
#include <SFML/Network/Export.hpp>
|
||||||
#include <SFML/Network/Socket.hpp>
|
|
||||||
#include <SFML/Network/IpAddress.hpp>
|
#include <SFML/Network/IpAddress.hpp>
|
||||||
|
#include <SFML/Network/Socket.hpp>
|
||||||
|
|
||||||
|
|
||||||
namespace sf
|
namespace sf
|
||||||
@ -44,7 +45,6 @@ class TcpSocket;
|
|||||||
class SFML_NETWORK_API TcpListener : public Socket
|
class SFML_NETWORK_API TcpListener : public Socket
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Default constructor
|
/// \brief Default constructor
|
||||||
///
|
///
|
||||||
|
@ -29,8 +29,10 @@
|
|||||||
// Headers
|
// Headers
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
#include <SFML/Network/Export.hpp>
|
#include <SFML/Network/Export.hpp>
|
||||||
|
|
||||||
#include <SFML/Network/Socket.hpp>
|
#include <SFML/Network/Socket.hpp>
|
||||||
#include <SFML/System/Time.hpp>
|
#include <SFML/System/Time.hpp>
|
||||||
|
|
||||||
#include <optional>
|
#include <optional>
|
||||||
|
|
||||||
|
|
||||||
@ -47,7 +49,6 @@ class Packet;
|
|||||||
class SFML_NETWORK_API TcpSocket : public Socket
|
class SFML_NETWORK_API TcpSocket : public Socket
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Default constructor
|
/// \brief Default constructor
|
||||||
///
|
///
|
||||||
@ -210,7 +211,6 @@ public:
|
|||||||
[[nodiscard]] Status receive(Packet& packet);
|
[[nodiscard]] Status receive(Packet& packet);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
friend class TcpListener;
|
friend class TcpListener;
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
|
@ -29,8 +29,10 @@
|
|||||||
// Headers
|
// Headers
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
#include <SFML/Network/Export.hpp>
|
#include <SFML/Network/Export.hpp>
|
||||||
#include <SFML/Network/Socket.hpp>
|
|
||||||
#include <SFML/Network/IpAddress.hpp>
|
#include <SFML/Network/IpAddress.hpp>
|
||||||
|
#include <SFML/Network/Socket.hpp>
|
||||||
|
|
||||||
#include <optional>
|
#include <optional>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
@ -46,7 +48,6 @@ class Packet;
|
|||||||
class SFML_NETWORK_API UdpSocket : public Socket
|
class SFML_NETWORK_API UdpSocket : public Socket
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
// Constants
|
// Constants
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
@ -153,7 +154,11 @@ public:
|
|||||||
/// \see send
|
/// \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
|
/// \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);
|
[[nodiscard]] Status receive(Packet& packet, std::optional<IpAddress>& remoteAddress, unsigned short& remotePort);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
// Member data
|
// Member data
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
|
@ -48,7 +48,8 @@
|
|||||||
|
|
||||||
#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)
|
#if defined(SFML_OPENGL_ES)
|
||||||
#include <GLES/gl.h>
|
#include <GLES/gl.h>
|
||||||
@ -72,8 +73,8 @@
|
|||||||
#include <GLES/glext.h>
|
#include <GLES/glext.h>
|
||||||
|
|
||||||
// We're not using OpenGL ES 2+ yet, but we can use the sRGB extension
|
// We're not using OpenGL ES 2+ yet, but we can use the sRGB extension
|
||||||
#include <GLES2/gl2platform.h>
|
|
||||||
#include <GLES2/gl2ext.h>
|
#include <GLES2/gl2ext.h>
|
||||||
|
#include <GLES2/gl2platform.h>
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -30,6 +30,7 @@
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
#include <SFML/Config.hpp>
|
#include <SFML/Config.hpp>
|
||||||
|
|
||||||
#include <SFML/System/Angle.hpp>
|
#include <SFML/System/Angle.hpp>
|
||||||
#include <SFML/System/Clock.hpp>
|
#include <SFML/System/Clock.hpp>
|
||||||
#include <SFML/System/Err.hpp>
|
#include <SFML/System/Err.hpp>
|
||||||
|
@ -29,6 +29,7 @@
|
|||||||
// Headers
|
// Headers
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
#include <SFML/System/Export.hpp>
|
#include <SFML/System/Export.hpp>
|
||||||
|
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
|
|
||||||
|
|
||||||
@ -41,7 +42,6 @@ namespace sf
|
|||||||
class Angle
|
class Angle
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Default constructor
|
/// \brief Default constructor
|
||||||
///
|
///
|
||||||
@ -142,7 +142,6 @@ public:
|
|||||||
static const Angle Zero; //!< Predefined 0 degree angle value
|
static const Angle Zero; //!< Predefined 0 degree angle value
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
friend constexpr Angle degrees(float angle);
|
friend constexpr Angle degrees(float angle);
|
||||||
friend constexpr Angle radians(float angle);
|
friend constexpr Angle radians(float angle);
|
||||||
|
|
||||||
@ -158,7 +157,6 @@ private:
|
|||||||
constexpr explicit Angle(float degrees);
|
constexpr explicit Angle(float degrees);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
// Member data
|
// Member data
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
|
@ -35,12 +35,11 @@ namespace priv
|
|||||||
else
|
else
|
||||||
return val + b;
|
return val + b;
|
||||||
}
|
}
|
||||||
}
|
} // namespace priv
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
constexpr Angle::Angle() :
|
constexpr Angle::Angle() : m_degrees(0.0f)
|
||||||
m_degrees(0.0f)
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -74,8 +73,7 @@ constexpr Angle Angle::wrapUnsigned() const
|
|||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
constexpr Angle::Angle(float degrees) :
|
constexpr Angle::Angle(float degrees) : m_degrees(degrees)
|
||||||
m_degrees(degrees)
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -29,6 +29,7 @@
|
|||||||
// Headers
|
// Headers
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
#include <SFML/System/Export.hpp>
|
#include <SFML/System/Export.hpp>
|
||||||
|
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
#include <ratio>
|
#include <ratio>
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
@ -71,8 +72,7 @@ namespace priv
|
|||||||
#if defined(SFML_SYSTEM_ANDROID) && defined(SFML_ANDROID_USE_SUSPEND_AWARE_CLOCK)
|
#if defined(SFML_SYSTEM_ANDROID) && defined(SFML_ANDROID_USE_SUSPEND_AWARE_CLOCK)
|
||||||
using MostSuitableClock = SuspendAwareClock;
|
using MostSuitableClock = SuspendAwareClock;
|
||||||
#else
|
#else
|
||||||
using MostSuitableClock = std::conditional_t<
|
using MostSuitableClock = std::conditional_t<std::chrono::high_resolution_clock::is_steady,
|
||||||
std::chrono::high_resolution_clock::is_steady,
|
|
||||||
std::chrono::high_resolution_clock,
|
std::chrono::high_resolution_clock,
|
||||||
std::chrono::steady_clock>;
|
std::chrono::steady_clock>;
|
||||||
#endif
|
#endif
|
||||||
@ -88,7 +88,6 @@ class Time;
|
|||||||
class SFML_SYSTEM_API Clock
|
class SFML_SYSTEM_API Clock
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Default constructor
|
/// \brief Default constructor
|
||||||
///
|
///
|
||||||
@ -123,8 +122,7 @@ public:
|
|||||||
private:
|
private:
|
||||||
using ClockImpl = priv::MostSuitableClock;
|
using ClockImpl = priv::MostSuitableClock;
|
||||||
|
|
||||||
static_assert(ClockImpl::is_steady,
|
static_assert(ClockImpl::is_steady, "Provided implementation is not a monotonic clock");
|
||||||
"Provided implementation is not a monotonic clock");
|
|
||||||
static_assert(std::ratio_less_equal<ClockImpl::period, std::micro>::value,
|
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");
|
||||||
|
|
||||||
|
@ -29,6 +29,7 @@
|
|||||||
// Headers
|
// Headers
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
#include <SFML/System/Export.hpp>
|
#include <SFML/System/Export.hpp>
|
||||||
|
|
||||||
#include <iosfwd>
|
#include <iosfwd>
|
||||||
|
|
||||||
|
|
||||||
|
@ -29,12 +29,15 @@
|
|||||||
// Headers
|
// Headers
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
#include <SFML/Config.hpp>
|
#include <SFML/Config.hpp>
|
||||||
|
|
||||||
#include <SFML/System/Export.hpp>
|
#include <SFML/System/Export.hpp>
|
||||||
|
|
||||||
#include <SFML/System/InputStream.hpp>
|
#include <SFML/System/InputStream.hpp>
|
||||||
#include <memory>
|
|
||||||
#include <string>
|
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
#include <filesystem>
|
#include <filesystem>
|
||||||
|
#include <memory>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
#ifdef SFML_SYSTEM_ANDROID
|
#ifdef SFML_SYSTEM_ANDROID
|
||||||
namespace sf::priv
|
namespace sf::priv
|
||||||
@ -140,7 +143,6 @@ public:
|
|||||||
Int64 getSize() override;
|
Int64 getSize() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
// Member data
|
// Member data
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
|
@ -29,6 +29,7 @@
|
|||||||
// Headers
|
// Headers
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
#include <SFML/Config.hpp>
|
#include <SFML/Config.hpp>
|
||||||
|
|
||||||
#include <SFML/System/Export.hpp>
|
#include <SFML/System/Export.hpp>
|
||||||
|
|
||||||
|
|
||||||
@ -41,12 +42,13 @@ namespace sf
|
|||||||
class SFML_SYSTEM_API InputStream
|
class SFML_SYSTEM_API InputStream
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Virtual destructor
|
/// \brief Virtual destructor
|
||||||
///
|
///
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
virtual ~InputStream() {}
|
virtual ~InputStream()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Read data from the stream
|
/// \brief Read data from the stream
|
||||||
|
@ -29,8 +29,11 @@
|
|||||||
// Headers
|
// Headers
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
#include <SFML/Config.hpp>
|
#include <SFML/Config.hpp>
|
||||||
#include <SFML/System/InputStream.hpp>
|
|
||||||
#include <SFML/System/Export.hpp>
|
#include <SFML/System/Export.hpp>
|
||||||
|
|
||||||
|
#include <SFML/System/InputStream.hpp>
|
||||||
|
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
|
|
||||||
|
|
||||||
@ -43,7 +46,6 @@ namespace sf
|
|||||||
class SFML_SYSTEM_API MemoryInputStream : public InputStream
|
class SFML_SYSTEM_API MemoryInputStream : public InputStream
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Default constructor
|
/// \brief Default constructor
|
||||||
///
|
///
|
||||||
@ -100,7 +102,6 @@ public:
|
|||||||
Int64 getSize() override;
|
Int64 getSize() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
// Member data
|
// Member data
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
|
@ -29,7 +29,9 @@
|
|||||||
// Headers
|
// Headers
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
#include <SFML/System/Export.hpp>
|
#include <SFML/System/Export.hpp>
|
||||||
|
|
||||||
#include <SFML/System/Utf.hpp>
|
#include <SFML/System/Utf.hpp>
|
||||||
|
|
||||||
#include <iterator>
|
#include <iterator>
|
||||||
#include <locale>
|
#include <locale>
|
||||||
#include <string>
|
#include <string>
|
||||||
@ -45,7 +47,6 @@ namespace sf
|
|||||||
class SFML_SYSTEM_API String
|
class SFML_SYSTEM_API String
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
// Types
|
// Types
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
@ -529,7 +530,6 @@ public:
|
|||||||
ConstIterator end() const;
|
ConstIterator end() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
friend SFML_SYSTEM_API bool operator==(const String& left, const String& right);
|
friend SFML_SYSTEM_API bool operator==(const String& left, const String& right);
|
||||||
friend SFML_SYSTEM_API bool operator<(const String& left, const String& right);
|
friend SFML_SYSTEM_API bool operator<(const String& left, const String& right);
|
||||||
|
|
||||||
|
@ -30,6 +30,7 @@
|
|||||||
// Headers
|
// Headers
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
#include <SFML/System/Export.hpp>
|
#include <SFML/System/Export.hpp>
|
||||||
|
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
|
|
||||||
|
|
||||||
|
@ -40,7 +40,6 @@ namespace sf
|
|||||||
class Time
|
class Time
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Default constructor
|
/// \brief Default constructor
|
||||||
///
|
///
|
||||||
@ -85,7 +84,6 @@ public:
|
|||||||
static const Time Zero; //!< Predefined "zero" time value
|
static const Time Zero; //!< Predefined "zero" time value
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
friend constexpr Time seconds(float);
|
friend constexpr Time seconds(float);
|
||||||
friend constexpr Time milliseconds(Int32);
|
friend constexpr Time milliseconds(Int32);
|
||||||
friend constexpr Time microseconds(Int64);
|
friend constexpr Time microseconds(Int64);
|
||||||
@ -102,7 +100,6 @@ private:
|
|||||||
constexpr explicit Time(Int64 microseconds);
|
constexpr explicit Time(Int64 microseconds);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
// Member data
|
// Member data
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
|
@ -24,8 +24,7 @@
|
|||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
constexpr Time::Time() :
|
constexpr Time::Time() : m_microseconds(0)
|
||||||
m_microseconds(0)
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -52,8 +51,7 @@ constexpr Int64 Time::asMicroseconds() const
|
|||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
constexpr Time::Time(Int64 microseconds) :
|
constexpr Time::Time(Int64 microseconds) : m_microseconds(microseconds)
|
||||||
m_microseconds(microseconds)
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -29,10 +29,11 @@
|
|||||||
// Headers
|
// Headers
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
#include <SFML/Config.hpp>
|
#include <SFML/Config.hpp>
|
||||||
|
|
||||||
|
#include <cstdlib>
|
||||||
#include <iterator>
|
#include <iterator>
|
||||||
#include <locale>
|
#include <locale>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <cstdlib>
|
|
||||||
|
|
||||||
|
|
||||||
namespace sf
|
namespace sf
|
||||||
@ -54,7 +55,6 @@ template <>
|
|||||||
class Utf<8>
|
class Utf<8>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Decode a single UTF-8 character
|
/// \brief Decode a single UTF-8 character
|
||||||
///
|
///
|
||||||
@ -261,7 +261,6 @@ template <>
|
|||||||
class Utf<16>
|
class Utf<16>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Decode a single UTF-16 character
|
/// \brief Decode a single UTF-16 character
|
||||||
///
|
///
|
||||||
@ -468,7 +467,6 @@ template <>
|
|||||||
class Utf<32>
|
class Utf<32>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Decode a single UTF-32 character
|
/// \brief Decode a single UTF-32 character
|
||||||
///
|
///
|
||||||
|
@ -103,10 +103,7 @@ template <typename Out>
|
|||||||
Out Utf<8>::encode(Uint32 input, Out output, Uint8 replacement)
|
Out Utf<8>::encode(Uint32 input, Out output, Uint8 replacement)
|
||||||
{
|
{
|
||||||
// Some useful precomputed data
|
// Some useful precomputed data
|
||||||
static constexpr Uint8 firstBytes[7] =
|
static constexpr Uint8 firstBytes[7] = {0x00, 0x00, 0xC0, 0xE0, 0xF0, 0xF8, 0xFC};
|
||||||
{
|
|
||||||
0x00, 0x00, 0xC0, 0xE0, 0xF0, 0xF8, 0xFC
|
|
||||||
};
|
|
||||||
|
|
||||||
// encode the character
|
// encode the character
|
||||||
if ((input > 0x0010FFFF) || ((input >= 0xD800) && (input <= 0xDBFF)))
|
if ((input > 0x0010FFFF) || ((input >= 0xD800) && (input <= 0xDBFF)))
|
||||||
|
@ -25,8 +25,10 @@
|
|||||||
#ifndef SFML_VECTOR2_HPP
|
#ifndef SFML_VECTOR2_HPP
|
||||||
#define SFML_VECTOR2_HPP
|
#define SFML_VECTOR2_HPP
|
||||||
|
|
||||||
#include <SFML/System/Angle.hpp>
|
|
||||||
#include <SFML/System/Export.hpp>
|
#include <SFML/System/Export.hpp>
|
||||||
|
|
||||||
|
#include <SFML/System/Angle.hpp>
|
||||||
|
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
|
|
||||||
|
|
||||||
@ -41,7 +43,6 @@ template <typename T>
|
|||||||
class Vector2
|
class Vector2
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Default constructor
|
/// \brief Default constructor
|
||||||
///
|
///
|
||||||
|
@ -25,30 +25,22 @@
|
|||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
template <typename T>
|
template <typename T>
|
||||||
constexpr Vector2<T>::Vector2() :
|
constexpr Vector2<T>::Vector2() : x(0), y(0)
|
||||||
x(0),
|
|
||||||
y(0)
|
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
template <typename T>
|
template <typename T>
|
||||||
constexpr Vector2<T>::Vector2(T X, T Y) :
|
constexpr Vector2<T>::Vector2(T X, T Y) : x(X), y(Y)
|
||||||
x(X),
|
|
||||||
y(Y)
|
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
template <typename T>
|
template <typename T>
|
||||||
template <typename U>
|
template <typename U>
|
||||||
constexpr Vector2<T>::Vector2(const Vector2<U>& vector) :
|
constexpr Vector2<T>::Vector2(const Vector2<U>& vector) : x(static_cast<T>(vector.x)), y(static_cast<T>(vector.y))
|
||||||
x(static_cast<T>(vector.x)),
|
|
||||||
y(static_cast<T>(vector.y))
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -26,6 +26,7 @@
|
|||||||
#define SFML_VECTOR3_HPP
|
#define SFML_VECTOR3_HPP
|
||||||
|
|
||||||
#include <SFML/System/Export.hpp>
|
#include <SFML/System/Export.hpp>
|
||||||
|
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
|
|
||||||
namespace sf
|
namespace sf
|
||||||
@ -39,7 +40,6 @@ template <typename T>
|
|||||||
class Vector3
|
class Vector3
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Default constructor
|
/// \brief Default constructor
|
||||||
///
|
///
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user