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