Welcome, Guest. Please login or register. Did you miss your activation email?

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - m3tr

Pages: [1]
1
Graphics / Re: Mismatch in coordinate system of window and getPixel
« on: November 13, 2018, 05:28:52 pm »
It worked.
But why pixel/point coordinates are not integers?

PS: Is this the best way to solve this problem?

2
Graphics / Mismatch in coordinate system of window and getPixel
« on: November 13, 2018, 04:19:51 pm »
#include <SFML/Graphics.hpp>
#include <iostream>
int main()
{
    sf::RenderWindow window(sf::VideoMode(200, 200), "SFML works!",sf::Style::Default);
    window.setVerticalSyncEnabled(true);
    sf::Vertex point;
    point.color = sf::Color::Red;
    point.position = sf::Vector2f(2,2);
    window.draw(&point,1,sf::Points),
    window.clear();
    window.display();
    sf::Image img = window.capture();
    window.display();
    window.clear();
    window.draw(&point,1,sf::Points);
    img = window.capture();
    std::cout << img.getPixel(2,1).toInteger() <<  '\n'; // gives red
    std::cout << img.getPixel(2,2).toInteger() <<  '\n'; //gives black, this should have given red
    window.close();
    return 0;
}
 
Pixel (2,2) is red using draw but is black using getPixel. Why?

Pages: [1]
anything