Commit 22b7e6c2 authored by Geequette's avatar Geequette

Add example 9, font example

parent 693b18bc
......@@ -29,13 +29,9 @@ LIBS += -lsfml-system
# Sources files
SOURCES += main.cpp
# Fragment files
DISTFILES += example_001.frag \
birds.wav \
music.ogg
DISTFILES += example_002.frag
DISTFILES += example_003.frag
DISTFILES += example_004.frag
# Audio files
DISTFILES += birds.wav
DISTFILES += music.ogg
......
# This file is used to ignore files which are generated
# ----------------------------------------------------------------------------
*~
*.autosave
*.a
*.core
*.moc
*.o
*.obj
*.orig
*.rej
*.so
*.so.*
*_pch.h.cpp
*_resource.rc
*.qm
.#*
*.*#
core
!core/
tags
.DS_Store
*.debug
Makefile*
*.prl
*.app
moc_*.cpp
ui_*.h
qrc_*.cpp
Thumbs.db
*.res
*.rc
/.qmake.cache
/.qmake.stash
# qtcreator generated files
*.pro.user*
# xemacs temporary files
*.flc
# Vim temporary files
.*.swp
# Visual Studio generated files
*.ib_pdb_index
*.idb
*.ilk
*.pdb
*.sln
*.suo
*.vcproj
*vcproj.*.*.user
*.ncb
*.sdf
*.opensdf
*.vcxproj
*vcxproj.*
# MinGW generated files
*.Debug
*.Release
# Python byte code
*.pyc
# Binaries
# --------
*.dll
*.exe
/*!
* \file main.cpp
* \brief start SFML in full screen and display a sprite (http://www.lucidarme.me/?p=6127)
* \author Philippe Lucidarme
* \version 1.0
* \date 12/18/2016
*/
// SFML libraries
#include <SFML/Graphics.hpp>
#include <iostream>
int main()
{
// _____________________
// ::: Create window :::
// Create a window with the same pixel depth as the desktop
sf::VideoMode desktopMode = sf::VideoMode::getDesktopMode();
sf::RenderWindow window(sf::VideoMode( desktopMode.width,
desktopMode.height,
desktopMode.bitsPerPixel),
"SFML part 3",
sf::Style::Fullscreen);
// Enable vertical sync. (vsync)
window.setVerticalSyncEnabled (true);
// _________________
// ::: Load font :::
sf::Font font;
if (!font.loadFromFile("../example_font.ttf"))
{
std::cerr << ".Error while loading font" << std::endl;
return -1;
}
sf::Text text;
text.setFont(font); // font est un sf::Font
text.setString(L"www.lucidarme.me");
text.setCharacterSize(60); // exprimée en pixels, pas en points !
text.setColor(sf::Color::Black);
text.setOrigin(text.getLocalBounds().width/2. , text.getLocalBounds().height/2.);
std::cout << text.getLocalBounds().width << "\t" << text.getLocalBounds().height;
// _________________
// ::: Main loop :::
sf::Clock timer;
while (window.isOpen())
{
// Process events
sf::Event event;
while (window.pollEvent(event))
{
// Close the window if a key is pressed or if requested
if (event.type == sf::Event::Closed) window.close();
if (event.type == sf::Event::KeyPressed) window.close();
}
// Clear the window and apply grey background
window.clear( sf::Color(127,127,127));
text.setPosition(window.getSize().x/2. , window.getSize().y/2.);
window.draw(text);
// Update display and wait for vsync
window.display();
}
return 0;
}
# Dont' need Qt libs
QT -= core
QT -= gui
# Binary name
TARGET = part_00*
# Console app
CONFIG += console
# Puts the executable into a bundle
CONFIG -= app_bundle
# This is an applications
TEMPLATE = app
# Create directories for temporrary files
OBJECTS_DIR = tmp
MOC_DIR = tmp
# Binaries will be placed in the bin directory
DESTDIR = bin
LIBS += -lsfml-audio
LIBS += -lsfml-graphics
LIBS += -lsfml-network
LIBS += -lsfml-window
LIBS += -lsfml-system
# Sources files
SOURCES += main.cpp
DISTFILES += \
example_font.ttf
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment