Commit 7756573e authored by Geequette's avatar Geequette

Bug with sfml display

parent 0d18a68c
/*!
* \file main.cpp
* \brief First example of SFML (http://www.lucidarme.me/?p=6127)
* \brief Display the list of available video mode (http://www.lucidarme.me/?p=6127)
* \author Philippe Lucidarme (from official SFML tutorial)
* \version 1.0
* \date 12/18/2016
......
# 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 (from official SFML tutorial)
* \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);
//sf::RenderWindow window(sf::VideoMode( 800,600),"SFML part 3");
// Enable vertical sync. (vsync)
window.setVerticalSyncEnabled (true);
// ____________________
// ::: Load texture :::
// Create texture from PNG file
sf::Texture texture;
if (!texture.loadFromFile("../../img/sfml-icon-small.jpg"))
{
std::cerr << "Error while loading texture" << std::endl;
return -1;
}
// Enable the smooth filter. The texture appears smoother so that pixels are less noticeable.
texture.setSmooth(true);
// _______________________________________
// ::: Create sprite and apply texture :::
// Create the sprite and apply the texture
sf::Sprite sprite;
sprite.setTexture(texture);
sf::FloatRect spriteSize=sprite.getGlobalBounds();
// sprite.setOrigin(spriteSize.width/2.,spriteSize.height/2.);
std::cout << desktopMode.width << " " << spriteSize.width;
sf::Sprite sprite2=sprite;
sf::Sprite sprite3=sprite;
sf::Sprite sprite4=sprite;
sf::Vertex line[] =
{
sf::Vertex(sf::Vector2f(1366/2, 0)),
sf::Vertex(sf::Vector2f(1366/2, 768))
};
// définit un cercle de rayon 200
sf::CircleShape circle(10);
circle.setOrigin(10,10);
// _________________
// ::: Main loop :::
int x=0;
sf::Clock timer;
while (window.isOpen())
{
// Display fps
// std::cout << 1/timer.restart().asSeconds() << " fps" << std::endl;
// 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));
// Draw the sprite
// sprite.setPosition(window.getSize().x/2.-spriteSize.width/2., window.getSize().y/2.-spriteSize.height/2.);
// sprite.setPosition(window.getSize().x/2.-spriteSize.width/2., 0);
// sprite.setPosition(0, 128);
// window.draw(sprite);
/*sprite2.setPosition(256, 128);
window.draw(sprite2);
sprite3.setPosition(512, 128);
window.draw(sprite3);
sprite4.setPosition(555, 128);
window.draw(sprite4);
*/
window.draw(line, 2, sf::Lines);
// circle.setPosition((x++%14)*100,0);
// window.draw(circle);
// Update display and wait for vsync
window.display();
// if (x==1366) window.close();
}
return 0;
}
# Dont' need Qt libs
QT -= core
QT -= gui
# Binary name
TARGET = part_003
# 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
TEMPLATE = subdirs
SUBDIRS += part_001
SUBDIRS += part_002
SUBDIRS += part_003
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