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 - Sholar

Pages: [1]
1
Graphics / Re: Rendering with sf::Vertex and blending
« on: May 06, 2013, 07:26:41 pm »
Laurent, thank you very much for your answers! If uncommented window.clear () and a set of SF :: BlendAdd, everything works fine. I'm so ashamed)

3
Graphics / Re: Rendering with sf::Vertex and blending
« on: May 06, 2013, 03:38:29 pm »
if set sf::BlendMultiply, black screen appears again.

4
Graphics / Re: Rendering with sf::Vertex and blending
« on: May 06, 2013, 02:18:33 pm »
Thank you, Laurent. I fixed it so:
v[0].texCoords.x = 96.0;                v[0].texCoords.y = 64.0;
v[1].texCoords.x = 128.0;               v[1].texCoords.y = 64.0;
v[2].texCoords.x = 128.0;               v[2].texCoords.y = 96.0;
v[3].texCoords.x = 96.0;                v[3].texCoords.y = 96.0;
 

Now it looks as


but it doesn't look like the first screenshot.  What ideas?

5
Graphics / Rendering with sf::Vertex and blending
« on: May 06, 2013, 05:04:35 am »
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 )

Pages: [1]
anything