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

Pages: [1]
Audio / Playing a sound wave
« on: December 22, 2015, 09:29:16 pm »
I have a function that allows a user input maths function (such as y = 2 *sin x) to be evaluated for whatever value of x. Is it possible to play this wave via SFML? The only way I've seen it done is via a callback that would pass the time value to the evaluation function, and then the result would be passed back to the library (done using PortAudio). As far as I know, you can't do that with SFML, so is there some other way to do it?

Graphics / Problem when resizing view to be same size as new window
« on: December 02, 2015, 08:20:44 pm »
Using this code
(click to show/hide)
and the attached "image.png", when I press the resize button, the sprite stays exactly the same size as expected, however some parts of it are changed, and this looks very weird in my full project, especially since everything is drawn to line up at the pixel level. I've attached the image used, as well as a screenshot from before, and one from after with red circles identifying some of the weird bits. I am on windows 10 using a version of SFML I build myself last July with CMake and MinGW 5.1.
EDIT: I forgot to say, the console output says that the new width is 1920 and the new height is 1001.

General / Linking on Linux
« on: November 13, 2015, 03:27:47 pm »
I've just switched from using Windows 10 to using Ubuntu and installed libsfml-dev using the Ubuntu Software Centre. However I'm confused, as the package that is installed contains only header files and when I attempt to link to the libraries in codeblocks, it says it cannot find -lsfml-graphics-s etc. Am I missing something? Do you have to compile the library yourself if you download it from the software centre (option 1 in the tutorial)? Sorry if it's a stupid question.

Feature requests / VertexArray begin() and end()
« on: August 23, 2015, 12:44:30 pm »
As VertexArray is a wrapper for std::vector<sf::Vertex>, I see no reason why it should not be able to be used in a range based for loop. However, because it has no begin() and end() functions, you either have to define your own ones using getVertexCount(), which seems unnecessary, or just stick with index based arrays, which I think should only be used if you need to know which element you are referring to. I think that having to define your own begin() and end() functions is not very user friendly and is just a hassle where it could just be done once in the library, and therefore as SFML aims to be as user friendly as possible, these functions should be added. It would also mean that you can pass VertexArray into functions that expect a vector easily be simply passing a starting and ending iterator.

Network / sf::IpAddress:toString() not working
« on: July 01, 2015, 02:45:13 pm »
I've made sfml from source (a two month old version of 2.3)  to work with MinGW 5.1.0 (with -std=c++14) with codeblocks on windows 8.1 and all network functions that I've tried work fine, except sf::IpAddress::toString(). This is my code:
#include <iostream>
#include <string>

#include <SFML/Graphics.hpp>
#include <SFML/Network.hpp>

int main()
    sf::RenderWindow window(sf::VideoMode(600,600), "Long distance pong");
    sf::IpAddress address(sf::IpAddress::getLocalAddress());
    sf::TcpSocket socket;
    //sf::Socket::Status = socket.connect("");
It keeps coming up with undefined reference to sf::IpAddress::toString[abi:cxx11]() const. I don't think it can be a problem with my linking as I've checked it loads of times, CMake didn't come up with any errors while I was building and no other errors or warnings are being produced (with -Wall on). Does anyone know why this one function isn't working?

I found that function in the repository and replaced my code (above) with this
#include <iostream>
#include <string>
#include <windows.h>

#include <SFML/Graphics.hpp>
#include <SFML/Network.hpp>

int main()
    sf::IpAddress address(sf::IpAddress::getLocalAddress());
    in_addr addr;
    addr.s_addr = address.toInteger();
and it works, but I would prefer to use the SFML function.

Graphics / Drawing sections of a vertex array
« on: June 29, 2015, 10:38:45 am »
I'm making a graph drawing program where I'm using an sf::VertexArray to represent the graph itself. My problem comes from graphs such as y=asin(1/x). These graphs have a gap in the middle where the value of y is undefined. My problem is, how do I stop the vertex array from drawing specific vertices? Even with a circle equation, I'll have to stop it drawing the vertices before and after the circle so is there any way to do this?

Feature requests / sf::Image::getPixel()/setPixel() validity
« on: May 16, 2015, 08:07:31 pm »
I've just been looking through the API documentation and it seemed fairly strange that for the want of a single if statement, the functions can produce undefined behaviour. Would it not be very simple to check whether the pixel is in range and either put the coordinates into range, or return black? I know it would be easy for the programmer to put these checks in place before using the function, but is not the point of these functions to make it easier/shorter to do certain tasks?

Graphics / Accurate zooming out
« on: May 14, 2015, 10:31:39 pm »
I've been using multiple sprites to make a single object with several independent moving parts and it all works fine. However I've realised that the images are twice as big as they should be. I tried using view.zoom(2), and while this zooms out fine, it means that every few frames, the sprites move and gaps appear. I also tried doubling the resolution of the spritesheet with gimp and getting rid of the zoom, thinking that if the pixels are half the size, then they should be half as big on the screen, but it had no effect. Is there any way I can solve this? What I'm saying is, is there any way to increase the resolution of an image/texture?

General / Program attempting to delete itself
« on: May 13, 2015, 12:14:35 pm »
I've made this program and it runs and compiles fine, but it I change anything and re-compile and run it, my antivirus either stops my exe for trying to delete itself, or it stops Id.exe. Does anyone have any idea why this is happening? As I have no idea what is causing this, I'll give my full code, it isn't that long. As I'm using RAII I thought it might be to do with that and there are some people who are amazing at it on here, but I don't know and it might be to do with my sfml code.
Code: [Select]
#include <SFML/Graphics.hpp>

#include "block.hpp"

int main()
    sf::RenderWindow window(sf::VideoMode(200, 200), "SFML works!");
    sf::Image tileImage;
    std::shared_ptr<sf::Texture> bodyTexture;
    std::array<std::shared_ptr<sf::Texture>,24> pistonTextures;
    std::array<std::shared_ptr<sf::Texture>,24> leftConnectorTextures;
    std::array<std::shared_ptr<sf::Texture>,24> rightConnectorTextures;
    bodyTexture.reset(new sf::Texture);
    for(int i (0); i < 24; i = i + 1)
        pistonTextures[i].reset(new sf::Texture);
        leftConnectorTextures[i].reset(new sf::Texture);
        rightConnectorTextures[i].reset(new sf::Texture);
    for(int i (0); i < 24; i = i + 1)
    block Block(bodyTexture,pistonTextures,leftConnectorTextures,rightConnectorTextures,0,0);
    while (window.isOpen())
        sf::Event event;
        while (window.pollEvent(event))
            if (event.type == sf::Event::Closed)

    return 0;

Code: [Select]

#include <array>
#include <memory>

class block{
    std::shared_ptr<sf::Texture> bodyTexture;
    std::array<std::shared_ptr<sf::Texture>,24> pistonTextures;
    std::array<std::shared_ptr<sf::Texture>,24> leftConnectorTextures;
    std::array<std::shared_ptr<sf::Texture>,24> rightConnectorTextures;
    std::array<sf::Sprite,16> sprites;
    int xpos, ypos, pistonFrame, leftConnectorFrame, rightConnectorFrame;
    static const int pistonLimit = 24;
    static const int leftConnectorLimit = 24;
    static const int rightConnectorLimit = 24;
    bool changePiston, changeLeftCon, changeRightCon, upLinked, downLinked, leftLinked, rightLinked;
    block(std::shared_ptr<sf::Texture> BodyTexture,std::array<std::shared_ptr<sf::Texture>,24> PistonTextures,std::array<std::shared_ptr<sf::Texture>,24> LeftConnectorTextures,std::array<std::shared_ptr<sf::Texture>,24> RightConnectorTextures,int xPos, int yPos);
    void draw(sf::RenderWindow & window);


Code: [Select]
#include <SFML/Graphics.hpp>

#include "block.hpp"

block::block(std::shared_ptr<sf::Texture> BodyTexture,std::array<std::shared_ptr<sf::Texture>,24> PistonTextures,std::array<std::shared_ptr<sf::Texture>,24> LeftConnectorTextures,std::array<std::shared_ptr<sf::Texture>,24> RightConnectorTextures,int xPos, int yPos)
    xpos = xPos;
    ypos = yPos;

    pistonFrame =
    leftConnectorFrame =
    rightConnectorFrame =
    changePiston =
    changeLeftCon =
    changeRightCon =
    upLinked =
    downLinked =
    rightLinked =
    leftLinked =

    bodyTexture = BodyTexture;

    for(int i (0); i < 24; i = i + 1)
        pistonTextures[i] = PistonTextures[i];
        rightConnectorTextures[i] = RightConnectorTextures[i];
        leftConnectorTextures[i] = LeftConnectorTextures[i];

    for(int i (0); i < 16; i = i + 4)

    for(int i (0); i < 16; i = i + 4)
        sprites[i+3].setRotation(270 + (90*(i/4)));



void block::draw(sf::RenderWindow & window)

General / Generating sfml with CMake
« on: May 12, 2015, 05:02:44 pm »
I'm probably being stupid with this, but it's the first time I've ever got CMake to work so I'm a bit confused. I'm also not sure what relevant information to give so if someone would tell me what information would be helpful, I'll happily give it. I followed the tutorial exactly and I generated MinGW makefiles in C:\Documents\sfmltest. However I'm not sure how to actually link them to my project now, seeing as the generated files and folders didn't contain that which is distributed in the pre-built versions. As I said I know I'm probably missing something fundamental, but I got stuck after generating (which seems to have worked fine) and I just don't know what to do now.

Graphics / Rendertexture versus many sprites
« on: May 07, 2015, 05:29:45 pm »
I'm trying to make a game at the moment where I have objects which have many independent small animations, such as the extension/contraction of small pistons. Is it more efficient to have many sprites held in a container (one sprite per animated part) which are all drawn to the screen individually, or should I draw them all onto a rendertexture first, so that the entire object is on one texture, and then draw it to the screen in one go?

Graphics / Glitchy display when dragging window offscreen
« on: April 23, 2015, 06:31:47 pm »
I'm not sure if this is a problem with anything I'm doing or with SFML as it has happened in every program I've ever written. If you grab the window and drag it offscreen then back onscreen, the window fills with fairly random repeated graphics and it only updates when you release the mouse. Is there anything that can be done about this or is it just a problem with SFML?

Audio / SFML Audio without dlls
« on: February 02, 2015, 06:13:58 pm »
Is it possible to include the sfml audio module in my project without also having to have openal32.dll and libnsfile.dll in the folder? Could I, for example, compile them into the exe? I've been trying to make a completely portable exe where only one file is necessary for it to run successfully and I'd rather not have to use a different audio library because the sfml one is by far the best and easiest to use that I've found. I'm using SFML 2.1 at the moment because when I tried to upgrade it crashed, but if SFML 2.2 can do it and 2.1 can't then I'll see if I can link to that instead.

Pages: [1]