Hello, i'm exercising with drawing in SFML ...
I successfully drawn 2 rectangles that overlap.
What i want to do is a space here i can finally draw text (channel space for a lighting software)
i'm a first rectangle with borders, then another rectangle inside the first one, then another rectangle inside also.
The 2 first rectangles are OK, and the program runs, when i add the third rectangle in the code, the program crash immediatly. This drawing will result in a class later, but right now, i'm juste trying to draw things to see what i can do.
I'm not sure i'm doing the good thing to create what i want to do and if there is another best method for this, please tell me, i'm so new in using graphic libraries and kind of programming rookie who really want to learn to do the good things.
Wondering why is it crashing ?
Thx by advance.
Here is my code :
#include <SFML/Graphics.hpp>
#include <iostream>
#include "fonctionsdetexte.h"
using namespace std;
int main()
{
sf::RenderWindow window(sf::VideoMode(800,600), "voici une fenêtre");
window.setVerticalSyncEnabled(true);
sf::Event event;
sf::Font font;
sf::Text text;
sf::Vertex vertex;
if (!font.loadFromFile("OCRA_0.ttf"))
{
cout << "font not loaded" << endl;
}
while (window.isOpen())
{
if(event.type == sf::Event::Closed)
window.close();
while (window.pollEvent(event))
{
channel_job_core(event);
}
window.clear(sf::Color::Black);
sf::RectangleShape unders(sf::Vector2f(50.f, 70.f));
unders.setFillColor(sf::Color(0 , 0, 255));
unders.setOutlineThickness(2.f);
unders.setOutlineColor(sf::Color(255, 255, 255));
unders.setPosition(10, 10);
window.draw(unders);
sf::RectangleShape channel_strip(sf::Vector2f(50.f, 20.f));
channel_strip.setFillColor(sf::Color(255, 0, 0));
channel_strip.setPosition(10, 10);
window.draw(channel_strip);
// RectangleShape 'info_strip' make the program crashes,
// if commented, the program works and display the 2 first rectangle
sf::RectangleShape info_strip(sf::Vector2f(50.f, 20.f));
info_strip.setFillColor(sf::Color(255, 0, 0));
info_strip.setPosition(10, 35);
window.draw(info_strip);
/*text.setFont(font);
text.setString("wildcat");
text.setCharacterSize(54);
text.setFillColor(sf::Color::Red);
text.setStyle(sf::Text::Bold | sf::Text::Underlined);
window.draw(text);*/
window.display();
}
return 0;
}