Hi guys.
the following is code from the tutorial hge
quad.tex=hge->Texture_Load("particles.png");
// Set up quad which we will use for rendering sprite
quad.blend=BLEND_ALPHAADD | BLEND_COLORMUL | BLEND_ZWRITE;
for(int i=0;i<4;i++)
{
// Set up z-coordinate of vertices
quad.v[i].z=0.5f;
// Set up color. The format of DWORD col is 0xAARRGGBB
quad.v[i].col=0xFFFFA000;
}
// Set up quad's texture coordinates.
// 0,0 means top left corner and 1,1 -
// bottom right corner of the texture.
quad.v[0].tx=96.0/128.0; quad.v[0].ty=64.0/128.0;
quad.v[1].tx=128.0/128.0; quad.v[1].ty=64.0/128.0;
quad.v[2].tx=128.0/128.0; quad.v[2].ty=96.0/128.0;
quad.v[3].tx=96.0/128.0; quad.v[3].ty=96.0/128.0;
...
hge->RenderQuad(&quad);
result:
And i tryed repeat it on sfml
int main()
{
// Create the main window
sf::RenderWindow window(sf::VideoMode(800, 600), "SFML window");
sf::Texture tex;
if(!tex.loadFromFile("particles.png"))
{
return -1;
}
sf::Vertex v[4];
v[0].position.x = 300; v[0].position.y = 300;
v[1].position.x = 300+32; v[1].position.y = 300;
v[2].position.x = 300+32; v[2].position.y = 332;
v[3].position.x = 300; v[3].position.y = 332;
for(int i = 0; i<4; i++)
v[i].color = sf::Color(255,160,0);
v[0].texCoords.x = 96.0/128.0; v[0].texCoords.y = 64.0/128.0;
v[1].texCoords.x = 128.0/128.0; v[1].texCoords.y = 64.0/128.0;
v[2].texCoords.x = 128.0/128.0; v[2].texCoords.y = 96.0/128.0;
v[3].texCoords.x = 96.0/128.0; v[3].texCoords.y = 96.0/128.0;
sf::RenderStates state;
state.blendMode = sf::BlendMode::BlendAdd;
state.texture = &tex;
while (window.isOpen())
{
sf::Event event;
while (window.pollEvent(event))
{
if (event.type == sf::Event::Closed)
window.close();
}
// window.clear();
window.draw(v,4,sf::PrimitiveType::Quads,state);
window.display();
}
return EXIT_SUCCESS;
}
but I see the black screen. Why? How i can fix it? Thanks.
P.S. sorry for my english )