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.


Topics - Foaly

Pages: 1 2 [3] 4
31
Graphics / Using white parts of a binary image
« on: November 28, 2012, 04:59:46 pm »
Hello everybody!
I am facing a problem, on which I would like to get some input on from some of the experts in this forum :)
I have a binary image (basically a mask) so a pixel is either black or white (Example). Now i want to get the coordinates of all the white pixel, to use them as positions for some sprites. The only thing I can think of is something like this (pseudocode):
for(x = 0; x <= width; x++)
   for(y = 0; y <= height; y++)
      if(image[x][y] == white)
          whitepixels.push_back(pair(x,y));
But this seems very chuncky and inefficient to me, because the binary image is fairly big and it's updated every frame. So my question is, is there a more efficient or optimized way to do this? I basically want to use the white parts of the binary image to draw stuff there.
Thanks in advance, Foaly :)

32
Graphics / Line Spacing
« on: November 06, 2012, 11:37:34 am »
Hello,
I was wondering if there is a way in SFML to control the spacing between lines in sf::Text. I have a text object that spans over multiple lines. It's created like this:

std::stringstream stream;

for(int i = 0; i < 10; i++)
{
    stream << "Some Text " << i << std::endl;
}

m_Text.setString(stream.str());

I saw that there is a getLineSpacing() function in sf::Font, but I'm not quiet sure if that's the thing I'm looking for, since it's not in sf::Text. So I was wondering is there any way I can control the spacing between lines in sf::Text? And if not is it possible to add such an option?

33
SFML wiki / Default wiki license
« on: October 18, 2012, 09:13:50 am »
Hi everybody.
There has been a discussion about what license the source codes in the wiki should have if the author didn't specify one himself (kind of a default license). This is important, because many people forget to include a license notice them self or are maybe just unsure of what to use. To keep people from not using code from the wiki, just because of a stupid issue like this, I wanted to set a default license. Laurent said he is too busy to take care of this, so I thought I'll do it myself. But I thought I should ask the community first what license to use. I myself think public domain is the best bet, because people who upload stuff to the wiki want to share their code and want people to use it. But of course choose for yourself :D . If anyone wants another option that I didn't include, I'll add it.
This is important so please cast your vote.
Thanks, Foaly

34
SFML website / Date on the license Page
« on: October 16, 2012, 09:51:24 am »
This is a super minor thing, but since updating the web pages is the last issue before releasing sfml 2.0 I thought I mention it. On the web page license (http://www.sfml-dev.org/license.php) it still says 2007 - 2008 :D

35
SFML wiki / Settings parser
« on: October 16, 2012, 07:46:15 am »
Hello!
I really like the simplicity of the settings parser on the wiki. (https://github.com/SFML/SFML/wiki/Source%3A-Settings-Parser) I would like to use it in a project and I couldn't find a license notice so I was wondering under what license the code is.

36
Graphics / Wave Shader
« on: October 14, 2012, 02:08:17 pm »
Hi I would like to apply a wave shader (just like the one in the examples) to a texture. But since a texture only has 4 vertices I don't think I can use the one from the examples. I'm not very good at shader programming, so I don't really know how to implement the effect as a fragment shader... can anybody help me out?

Another small question: What's the name of the blur effect that is used in the example?

37
SFML projects / Crazy Painter
« on: September 22, 2012, 12:08:53 pm »
Hey everybody!
I want to show you a little program I have been working on lately, which in the lack of a better name I called Crazy Painter. It's neither a game nor a real multimedia application. It's just an artsy, fun little program for when you bored. Give it a try and tell me what you think :)

The controls are really simple: Grab the red dot with the mouse an drag it around.
Pressing "c" clears the screen
Pressing "a" toggles the automatic mode
Pressing "h" toggles between linear and hermite interpolation in the automatic mode
Pressing "f" toggles a slow fade

Here is a screenshot:


Caution: Don't use this program drunk or on drugs! :D

Downloadlink: www.max.jewieft.de/games/Crazy%20Painter.zip

38
Graphics / Fading without artifacts
« on: September 13, 2012, 06:29:31 pm »
Hello there,
for a little program I'm making, I am drawing a couple drawable objects on top of a Rendertexture, without clearing it. Now I want that the stuff that is already on the texture to slowly fade. To achieve this I made a RectangleShape as big as the Texture and has a semi-transparent black color, which is drawn on top of the Texture at the beginning of each render cycle.
The problem is that it only works partly. The texture fades a little bit, but after some time it stops and the old objects stay as dark artifacts.
Does anybody know whats wrong or another way how I could fade the texture?
Thanks in advance,
Foaly

39
Graphics / Color transmission is not smooth
« on: September 10, 2012, 07:50:09 pm »
Hi there,
a while back I was looking for a way to make a transition between multiple colors. Thread: http://en.sfml-dev.org/forums/index.php?topic=7996.msg54612 The other day I picked the project up again and I came up with the following solution: Changing the hue over time and then calculating the RGB from that. I implemented the following code:
        hue += 0.5 * fTime;
        if(hue > 1.0)
            hue = 0.0;

        float r = abs(3.0 - 6.0 * hue) - 1.0;
        float g = 2.0 - abs(2.0 - 6.0 * hue);
        float b = 2.0 - abs(4.0 - 6.0 * hue);

        color = sf::Color(CLAMP(r, 0.f, 1.f) * 255.f, CLAMP(g, 0.f, 1.f) * 255.f, CLAMP(b, 0.f, 1.f) * 255.f);
 
I doesn't give the results i expected though... The transitions are choppy and not all colors are shown. It looks like this:



I don't really know why. The calculation seem to be right. Does anybody know what's wrong?

40
Graphics / Round Ended Lines
« on: September 10, 2012, 12:03:05 pm »
Hi there,
I'm trying to implement a class that draws round ended lines. For that I made a class that inherits from sf::Shape. First I thought I implement a class that draws lines. I did that and i works. But now I'm not sure how to put the rounded ends on it. I'm thinking that I have to compute half a circle and just put it on the two end points, but I'm not quiet sure how to compute the "rotation" of the circle. Can somebody point me in the right direction?

Here is my code so far.

Header File:
#ifndef ROUNDENDEDLINE_H
#define ROUNDENDEDLINE_H

#include <SFML/Graphics/Shape.hpp>
#include <cmath>
#include <iostream>


class CRoundendedLine : public sf::Shape
{
public:

    CRoundendedLine(const sf::Vector2f& endPoint = sf::Vector2f(0, 0), const float width = 1.0);

    void setEndPoint(const sf::Vector2f& endPoint);

    void setWidth(const float width);

    virtual unsigned int getPointCount() const;

    virtual sf::Vector2f getPoint(unsigned int index) const;

private :

    sf::Vector2f m_endPoint;
    float m_Width;
};

#endif //ROUNDENDEDLINE_H
 

Implementation:
#include "RoundendedLine.h"

CRoundendedLine::CRoundendedLine(const sf::Vector2f& endPoint, const float width) : m_endPoint (endPoint), m_Width (width)
{
    update();
}

void CRoundendedLine::setEndPoint(const sf::Vector2f& endPoint)
{
    m_endPoint = endPoint;
    update();
}

void CRoundendedLine::setWidth(const float width)
{
    m_Width = width;
    update();
}

unsigned int CRoundendedLine::getPointCount() const
{
    return 4;
}


// Compute the normal of a segment
sf::Vector2f computeNormal(const sf::Vector2f& p1, const sf::Vector2f& p2)
{
    sf::Vector2f normal(p1.y - p2.y, p2.x - p1.x);
    float length = std::sqrt(normal.x * normal.x + normal.y * normal.y);
    if (length != 0.f)
        normal /= length;
    return normal;
}

sf::Vector2f CRoundendedLine::getPoint(unsigned int index) const
{
    sf::Vector2f P1(1.0, 0.0);
    sf::Vector2f P2(m_endPoint + sf::Vector2f(1.0, 0.0) - getPosition());

    // Compute the extrusion direction
    sf::Vector2f Normal = computeNormal(P1, P2);
    Normal *= m_Width / 2;

    switch (index)
    {
        default:
        case 0: return sf::Vector2f(P1 - Normal);
        case 1: return sf::Vector2f(P2 - Normal);
        case 2: return sf::Vector2f(P2 + Normal);
        case 3: return sf::Vector2f(P1 + Normal);
    }
}
 

Usage:
#include <SFML/Graphics.hpp>
#include "RoundendedLine.h"
#include <iostream>

int main()
{
    sf::RenderWindow window(sf::VideoMode(800, 600), "SFML works!");

    CRoundendedLine RoundendedLine;
    RoundendedLine.setPosition(200,200);
    RoundendedLine.setEndPoint(sf::Vector2f(270, 300));
    RoundendedLine.setWidth(11);

    sf::Vertex* startVertex =  new sf::Vertex(sf::Vector2f(200, 200), sf::Color::Red);
    sf::Vertex* endVertex =  new sf::Vertex(sf::Vector2f(270, 300), sf::Color::Blue);

    while (window.isOpen())
    {
        sf::Event event;
        while (window.pollEvent(event))
        {
            // Close Event
            if (event.type == sf::Event::Closed)
                window.close();

            // Escape key pressed
            if ((event.type == sf::Event::KeyPressed) && (event.key.code == sf::Keyboard::Escape))
                window.close();
        }

        window.clear();
        window.draw(RoundendedLine);
        window.draw(startVertex, 1, sf::Points);
        window.draw(endVertex, 1, sf::Points);
        window.display();
    }

    return 0;
}
 

41
Feature requests / Custom blend modes
« on: August 12, 2012, 11:33:45 pm »
Hello there,
I'd like to bring up the discussion about the custom blend modes. They have been mentioned in a couple threads, but there has never been a decision or a detailed discussion about them. I think blend modes are an important part of graphics programming and that a custom blend mode functionality would be really useful.

42
Audio / Portaudio and Mingw
« on: August 09, 2012, 01:20:32 am »
Hello everybody,
I'm looking into realtime audio processing. The library port audio looks really promising, but I can't get it to compile with mingw on windows 7. The little bit of documentation I found wasn't helpful eigher. I know it's a little out of scope of this forum, but I thought somebody here might have some experience and can help me.
Thanks in advance.
Foaly

43
General / Cross Platform float
« on: June 12, 2012, 01:17:46 pm »
In config.hpp SFML defines a bunch of fixed-point data types in a cross-platform way (sf::Int16 etc.). I was wondering why are there no floating point data types (i.e. float or double)? I read somewhere that they are not consistent across all platforms either.

44
General / SFML and Qt
« on: May 30, 2012, 05:52:19 pm »
Hello everybody,
I would like to use SFML and Qt together, but not in the way that is described in the tutorials (I don't want to integrate a SFML view in a Qt interface). I would like to have two separate windows, one Qt window with a couple controls and one SFML window, that renders stuff.
I am not sure what the best way of doing this is. Could someone point me in the right direction? Should I use two different threads?
Thanks in advance,
Foaly

45
Window / Minor improvement
« on: May 29, 2012, 11:25:02 am »
For whatever reason I was looking at the window source code the other day and I noticed a little thing that made me wonder. In line 336 (the display function) the time of the clock is requested and in the next line the clock is restarted.
I read somewhere (either the doc or a forum post) that it's better to just use the restart function, because it also returns the elapsed time and you skip the delay between the two function calls.
Is there a specific reason you don't use only restart? I was just wondering. I know this really is a minor thing :)

Pages: 1 2 [3] 4
anything