Skip to content

Instantly share code, notes, and snippets.

View CMakeLists.txt
find_package(zlib)
if (NOT zlib_FOUND)
message("Fetch zlib content instead...")
include(FetchContent)
FetchContent_Declare(
zlib
GIT_REPOSITORY "https://github.com/madler/zlib.git"
GIT_TAG "v1.2.11"
)
@eXpl0it3r
eXpl0it3r / main.cpp
Last active Mar 19, 2021
How to center SFML sf::Text objects
View main.cpp
#include <iostream>
#include <SFML/Graphics.hpp>
int main()
{
auto window = sf::RenderWindow{{800, 600, 32}, "SFML Window"};
window.setFramerateLimit(60);
auto font = sf::Font{};
if (!font.loadFromFile("OpenSans.ttf"))
@eXpl0it3r
eXpl0it3r / CMakeLists.txt
Created May 28, 2020
sfeMovie SFML 2.5 CMake Migration
View CMakeLists.txt
cmake_minimum_required (VERSION 2.8.12)
# set a default build type if none was provided
# this has to be done before the project() instruction!
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build (Debug or Release)" FORCE)
endif()
@eXpl0it3r
eXpl0it3r / StreamLogger.hpp
Last active May 23, 2020
Redirect Stream to spdlog Logger
View StreamLogger.hpp
#include <streambuf>
#include <ostream>
#include "spdlog/spdlog.h"
template<class Element = char, class Trait = std::char_traits<Element>>
class StreamLogger : public std::basic_streambuf<Element, Trait>
{
public:
StreamLogger(std::ostream& stream, std::shared_ptr<spdlog::logger> logger)
@eXpl0it3r
eXpl0it3r / client.cpp
Last active May 27, 2020
SFML UDP Server & Client
View client.cpp
#include <SFML/Network.hpp>
#include <iostream>
#include <csignal>
#include <atomic>
#include <string>
using namespace std::string_literals;
namespace
{
@eXpl0it3r
eXpl0it3r / main.cpp
Last active Jan 14, 2019
SFML Cursor API
View main.cpp
#include <SFML/Graphics.hpp>
struct Cursor
{
Cursor() :
changed{ false },
current{ sf::Cursor::Arrow }
{
arrow.loadFromSystem(sf::Cursor::Arrow);
hand.loadFromSystem(sf::Cursor::Hand);
View main.cpp
#include <SFML/Graphics.hpp>
int main()
{
sf::RenderWindow window{ { 1280, 720 }, "Test"};
window.setFramerateLimit(60);
while(window.isOpen())
{
sf::Event event;
@eXpl0it3r
eXpl0it3r / IbEeaC.cpp
Last active Oct 10, 2018
I before E except after C
View IbEeaC.cpp
#include <iostream>
#include <fstream>
#include <string>
bool IbEeaC(const std::string& word)
{
for(auto position = word.find("ei"); position != std::string::npos; position = word.find("ei", position += 2))
{
if (position == 0 || word[position - 1] != 'c')
{
View opengl.cpp
// Link statically with GLEW
#define GLEW_STATIC
// Headers
#include <GL/glew.h>
#include <SOIL.h>
#include <SFML/Window.hpp>
// Shader sources
const GLchar* vertexSource = R"glsl(
@eXpl0it3r
eXpl0it3r / main.cpp
Created Jun 10, 2018
Visual Studio - std::ftell performance issue - better example
View main.cpp
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
int main()
{
// Search the first 32MiB for a Z character
constexpr auto maxToRead = 32 * 1024 * 1024;
auto f = std::fopen("test.dat", "rb");