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

Pages: [1]
1
Network / Re: Optimizing Networking
« on: May 28, 2015, 04:50:43 pm »
To be honest this forum is crowded with condescendant people! What a shame for an open-source community!

2
SFML projects / Re: Moonman (my sfml game is on kickstarter!)
« on: January 19, 2015, 10:21:33 am »
Thank you for your answer :) I will check that out :) And by the way I was reading you Kickstarter page and noticed that it's not clearly mentioned that you're running a Steam Greenlight campaign at the same time. Maybe what you need is that big "Help get us on STEAM" banner. In my opinion that will help you drive the traffic to your Steam Greenlight page. :)

3
SFML projects / Re: Moonman (my sfml game is on kickstarter!)
« on: January 15, 2015, 11:44:41 pm »
Those pixels are beautiful. Well done! I have a question concerning the lighting system. How is it implemented in your engine?

4
Window / Re: Joystick vibration
« on: December 24, 2014, 10:48:44 am »
Has this been implemented?

5
Graphics / Re: Font is failing to load
« on: December 23, 2014, 10:42:15 pm »
You're welcome :)

6
Graphics / Re: Font is failing to load
« on: December 23, 2014, 04:28:33 am »
You need to remove the semicolon after your "if" statement otherwise you will always get that error message! 
if(!font_.loadFromFile("arial.ttf"));// The problem is here! Remove the semicolon!
        std::cout << "Failed to load font." << std::endl;
 

7
Graphics / Re: Why is sf::Drawable::draw() private?
« on: December 19, 2014, 06:28:09 am »
It would be cleaner to have a class that's Drawable and has a Sprite (composition):
#include <SFML/Graphics/Sprite.hpp>
#include <SFML/Graphics/Drawable.hpp>
#include <SFML/Graphics/RenderTarget.hpp>
#include <SFML/Graphics/RenderStates.hpp>

class MyClass : public sf::Drawable {
    private:
                virtual void draw(sf::RenderTarget& target, sf::RenderStates states) const {
                        // My functionality
                        target.draw(sprite, states);
                }
   
    private:
                sf::Sprite sprite;
};
 

8
Feature requests / Re: small & stupid api changes: radians, vectors, colors
« on: September 23, 2014, 12:51:39 pm »
Thank you @dabbertorres and @Nexus, well that looks a bit cleaner :) It will always need to copy the object's color thought but hey it does the job and it's clean. :)

9
Feature requests / Re: small & stupid api changes: radians, vectors, colors
« on: September 23, 2014, 02:09:05 am »
Indeed #3 would be a nice feature especially for people that are used to web development.

On another subject, it would also be great to add a setAlpha function to SFML graphic entities so one would avoid writing code like this :
sf::Uint8 alpha = 100;
const sf::Color& c = text.getColor();// text is an sf::Text
text.setColor(sf::Color(c.r, c.g, c.b, alpha));

Or maybe there is another straightforward way of writing this code that I'm not aware of?

10
Thank you for the reply!

Well I guess I thought I could save up some vertices by drawing the background and the texture together (I'll be drawing a lot of rectangle entities). Too bad!

Premature optimization is the root of all evil :D

11
Graphics / Render a rectangle with vertices using a texture and a color
« on: August 18, 2014, 03:22:54 am »
Hello,

This is maybe easy to achieve but (as I just started learning Graphics Programming) I couldn't manage to get it working as intended.
So I have a red rectangle rendered via a vertex array :

Now I want to draw on top of it a texture (white question mark with transparent background) using "textCoord" :

so the final result would be like this :

But this is what I get instead:

I assume this because SFML infernally multiplies the texture's pixels by the vertices' colors. If that's true, how can I change the blend mode used to draw the rectangle? And what's the appropriate mode to use in this case?

Thank you in advance.

PS: Here is a minimal code ("questionMark.png" is attached to this post):
int main()
{
    sf::RenderWindow window(sf::VideoMode(400, 240), "My window");

    sf::Texture texture;
    if (!texture.loadFromFile("questionMark.png"))
    {
        // error...
    }

    // create an array of 4 vertices that define a quad primitive
    sf::VertexArray quad(sf::Quads, 4);

    // define the position of the quad's points
    quad[0].position = sf::Vector2f(10, 10);
    quad[1].position = sf::Vector2f(100, 10);
    quad[2].position = sf::Vector2f(100, 100);
    quad[3].position = sf::Vector2f(10, 100);

    // define the color of the quad's points
    quad[0].color = sf::Color::Red;
    quad[1].color = sf::Color::Red;
    quad[2].color = sf::Color::Red;
    quad[3].color = sf::Color::Red;

    // define its texture area
    quad[0].texCoords = sf::Vector2f(0, 0);
    quad[1].texCoords = sf::Vector2f(8, 0);
    quad[2].texCoords = sf::Vector2f(8, 8);
    quad[3].texCoords = sf::Vector2f(0, 8);

    // define the render states
    sf::RenderStates states;
    //states.blendMode = ???;
    states.texture = &texture;


    // run the program as long as the window is open
    while (window.isOpen())
    {
        // check all the window's events that were triggered since the last iteration of the loop
        sf::Event event;
        while (window.pollEvent(event))
        {
            // "close requested" event: we close the window
            if (event.type == sf::Event::Closed)
                window.close();
        }

        // clear the window with black color
        window.clear(sf::Color::Black);

        // draw everything here...
        window.draw(quad, states);

        // end the current frame
        window.display();
    }

    return 0;
}
 

Pages: [1]