1
Graphics / Incorrect displaying VertexArray
« on: November 30, 2018, 04:05:29 am »
I wanted to display points 16x16 on window with changed view, but my settings not work as I expected.
First line of points are not draw on window, until i changed {0, 0, 16, 16} to {0, -1, 16, 16} why is that work that way?
The whole code in attachment.
First line of points are not draw on window, until i changed {0, 0, 16, 16} to {0, -1, 16, 16} why is that work that way?
sf::RenderWindow window(sf::VideoMode(800, 600), "Window");
sf::VertexArray points(sf::Points, 256);
for(size_t i = 0u; i < 16; ++i)
{
for(size_t j = 0u; j < 16; ++j)
{
if(i == 0 || j == 0 || i == 15 || j == 15)
points[i * 16 + j] = {{static_cast<float>(j), static_cast<float>(i)}, sf::Color(0u, 255u, 0u)};
else
points[i * 16 + j] = {{static_cast<float>(j), static_cast<float>(i)}, sf::Color(255u, 0u, 0u)};
}
}
sf::View view;
view.reset({0, 0, 16, 16});
// view.reset({0, -1, 16, 16});
view.setViewport({0.25f, 0.25f, 0.5f, 0.5f});
window.setView(view);
sf::VertexArray points(sf::Points, 256);
for(size_t i = 0u; i < 16; ++i)
{
for(size_t j = 0u; j < 16; ++j)
{
if(i == 0 || j == 0 || i == 15 || j == 15)
points[i * 16 + j] = {{static_cast<float>(j), static_cast<float>(i)}, sf::Color(0u, 255u, 0u)};
else
points[i * 16 + j] = {{static_cast<float>(j), static_cast<float>(i)}, sf::Color(255u, 0u, 0u)};
}
}
sf::View view;
view.reset({0, 0, 16, 16});
// view.reset({0, -1, 16, 16});
view.setViewport({0.25f, 0.25f, 0.5f, 0.5f});
window.setView(view);
The whole code in attachment.