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

Pages: [1] 2 3 ... 7
1
Audio / sf::Sound derivative not playing
« on: May 19, 2014, 07:21:16 pm »
I am trying to make an sound manager, from where I can play sounds through a system of IDs, for this I created a child class(Called ironically Sound_Struct). The problem I'm running into is that the sound I have loaded into it doesn't play. I have checked the file itself(through use of sf::Sound), aswell as the sf::SoundBuffer vector where I load/store the buffers. Here is the code, if someone could help that would be wonderful.

SoundManager.hpp
#pragma once
#include <SFML\Audio.hpp>
#include <list>
#include <string>
#include <iomanip>

class Sound_Struct : public sf::Sound
{
public:
        Sound_Struct(sf::SoundBuffer S_BUFF_SRC, std::string n_designation, int n_id);
        Sound_Struct(std::string n_designation, int n_id);
        void set_ID(int n_id){this->m_id = n_id;}
        int get_ID(){return this->m_id;}
        void set_Name(std::string n_designation){this->m_designation = n_designation;}
        std::string get_Name(){return this->m_designation;}
private:
        std::string m_designation;
        int m_id;
};

struct Music_Struct : public sf::Music
{
public:
        Music_Struct(std::string m_filename, std::string n_designation, int n_id);
        void set_ID(int n_id){this->m_id = n_id;}
        int get_ID(){return this->m_id;}
        void set_Name(std::string n_designation){this->m_designation = n_designation;}
        std::string get_Name(){return this->m_designation;}
private:
        std::string m_designation;
        int m_id;
};
class Sound_Manager
{
public:

        Sound_Manager();
        bool Add_Sound_Buffer(std::string m_filename); //Adds an sound_buffer into the Sound_Buffer list. Used for initial setup.

        bool Add_Sound(std::string m_filename, std::string m_designation, int m_id);
        void Add_Sound(sf::SoundBuffer m_S_BUFF, std::string m_designation, int m_id);
        void Add_Sound(sf::Sound* m_Sound, std::string m_designation, int m_id);
        void Add_Sound(int S_BUFF_ID, std::string m_designation, int m_id);
        void Add_Music(std::string m_filename, std::string m_designation, int m_id);
        void Delete_Sound(int m_id);
        void Delete_Sound(std::string m_designation);

        sf::SoundBuffer getBuffer(int ID);

        void Play_Sound(std::string m_designation);
        void Play_Sound(int m_id);
        void Play_Music(std::string m_designation);
        void Play_Music(int m_id);
        void Pause_All();
        void Resume_Previous();

        int no_Of_Sounds()
        {
                return this->Sounds.size();
        };
        int no_Of_Buffers()
        {
                return this->Sound_Buffers.size();
        };
public:
        std::list<Sound_Struct> Sounds; //Since sounds are given unique IDs, and likely change during runtime these are placed in a list
        std::vector<sf::SoundBuffer> Sound_Buffers; //Unchanging after startup, so placed in a vector
        std::vector<Music_Struct*> Songs; //Unchanging after startup, so placed in a vector
};

SoundManager.cpp (only including the functions that are relevant)
Sound_Struct::Sound_Struct(sf::SoundBuffer S_BUFF_SRC, std::string n_designation, int n_id) : sf::Sound(S_BUFF_SRC)
{
        this->m_designation = n_designation;
        this->m_id = n_id;
}
Sound_Manager::Sound_Manager()
{
        this->Songs.clear();
        this->Sounds.clear();
        this->Sound_Buffers.clear();
}
bool Sound_Manager::Add_Sound_Buffer(std::string m_filename)
{
        sf::SoundBuffer S_BUFF;
        if(S_BUFF.loadFromFile(m_filename))
        {
                this->Sound_Buffers.push_back(S_BUFF);
                return true;
        }
        else
                return false;
}
bool Sound_Manager::Add_Sound(std::string m_filename, std::string m_designation, int m_id)
{
        sf::SoundBuffer S_BUFF;
        if(S_BUFF.loadFromFile(m_filename))
        {
                this->Sound_Buffers.push_back(S_BUFF);
                Sound_Struct ne_Sound(S_BUFF,m_designation,m_id);
                this->Sounds.push_back(ne_Sound);
                return true;
        }
        else
                return false;
}
void Sound_Manager::Add_Sound(sf::SoundBuffer m_S_BUFF, std::string m_designation, int m_id)
{
        this->Sound_Buffers.push_back(m_S_BUFF);
        Sound_Struct ne_Sound(m_S_BUFF, m_designation, m_id);
        this->Sounds.push_back(ne_Sound);
}
void Sound_Manager::Play_Sound(std::string m_designation)
{
        std::list<Sound_Struct>::iterator iter;
        for(iter = this->Sounds.begin(); iter != this->Sounds.end(); iter++)
        {
                if(iter->get_Name() == m_designation)
                        iter->play();
        }
}
void Sound_Manager::Play_Sound(int m_id)
{
        std::list<Sound_Struct>::iterator iter;
        for(iter = this->Sounds.begin(); iter != this->Sounds.end(); iter++)
        {
                if(iter->get_ID() == m_id)
                        iter->play();
        }
}

The actual loading/playing is done in the main file

        if(!Miss_Lisa.Add_Sound_Buffer("Sounds/Laser_Shot.wav"))
        {
                return;
        }
        Miss_Lisa.Add_Sound(0,"Laser_Shot",1);
//The sound can now be played by calling
Miss_Lisa.play_Sound(1)

2
Graphics / Re: Colouring coloured tiles using sf:color
« on: March 11, 2014, 10:23:06 pm »
Thanks for the response. I managed to fix it with a somewhat similar setup
Rendering_Tiles[x][y].setColor(sf::Color((1/Displayed_Tiles[x][y].Get_Water_Depth())* 100,(1/Displayed_Tiles[x][y].Get_Water_Depth())* 100,Displayed_Tiles[x][y].Get_Water_Depth()*3,255));
As well as rebinding the background of that specific tile to a white square, as opposed to the the background of the tile type, which was what I used before.
Although the macro is a bit off it hits somewhat close to the mark and provides the ability to distinguish between water depth, which is what was important anyway.

3
Graphics / [Solved]Colouring coloured tiles using sf:color
« on: March 09, 2014, 08:25:16 pm »
In my current project I have tiles which represent a certain type of terrain. Each of these types have their own coloured tile image. This all works very well but I also want to be able to represent a water/water depth value on top of a tile if there is water.
I would like to colour the tiles as they are outputted by setting the tiles color with a sf::color value where an higher water depth would mean an stronger blue.

I am currently using the following code:
        if(Displayed_Tiles[x][y].is_Water())
                        {
                                Rendering_Tiles[x][y].setColor(sf::Color(125,125,255/(Displayed_Tiles[x][y].Get_Water_Saturation()),255/2));
                        }

Where Displayed_Tiles
  • [y].Get_Water_Saturation() is an number over 1 which goes down lower as the water depth increases.  This code is called each time I draw the tiles to the screens. After the tiles have been draw I "flash" all Rendering_Tiles which means I reset their colour.

The problem is that it doesn't work, in two ways. The tiles aren't colored blue, no matter the water depth and the tiles color does not change if their water depth is decreased/increased.
Anyone have any clue of why the code isn't working or what steps I should take to remedy it?(Or recommend me a better system to colour the tiles according to a water depth variable?).

Sorry if an topic similar to this has been posted. Searched around on the graphics and general boards but couldn't find anything relevant to this topic.

4
SFML projects / Re: Exodus : SFML based windows Metroidvania game
« on: February 07, 2013, 06:12:27 pm »
Wow, this looks amazing!

5
SFML projects / Re: SFML Light System - Let There Be Light
« on: February 05, 2013, 04:45:04 pm »
// the old...
shader.bind();

// ...is equivalent to the new...
sf::Shader::bind(&shader);

// the old...
shader.unbind();

// ...is equivalent to the new...
sf::Shader::bind(NULL);

Okay, thank you for clearing that up.

EDIT: is this true for other classes ::bind, such as sf::texture::bind?

6
SFML projects / Re: SFML Light System - Let There Be Light
« on: February 05, 2013, 09:29:25 am »
Build the API documentation, and read it ;)

// bind a shader
sf::Shader::bind(&shader);

// bind nothing
sf::Shader::bind(NULL);

But what did the old call to ::bind with no arguments do? Did it do the same thing as calling ::bind(NULL)? Since I don't know what the old calls did, I don't know if ::bind(NULL) does the same thing.

7
SFML projects / Re: SFML Light System - Let There Be Light
« on: February 04, 2013, 10:52:20 pm »
Excuse me if this sounds dumb, but with the the version of SFML I have(downloaded a week or so ago) sf::shader::bind() can no longer be called with no arguments. Should I replace all calls to bind with no arguments with bind(NULL)?

8
General / Re: LNK 1112 compiling SFML 2.0 to VS2012
« on: February 03, 2013, 08:01:15 pm »
I had a container class which had SFML objects in it, when I moved the initalizer into main it worked. Sorry for taking up your time.

9
General / Re: LNK 1112 compiling SFML 2.0 to VS2012
« on: February 03, 2013, 04:01:58 pm »
    ntdll.dll!_RtlEnterCriticalSection@4()   Unknown
    Small Eye Coming Through.exe!sf::priv::MutexImpl::lock() Line 52   C++
>   Small Eye Coming Through.exe!sf::Mutex::lock() Line 57   C++
    Small Eye Coming Through.exe!sf::Lock::Lock(sf::Mutex & mutex={...}) Line 39   C++
    Small Eye Coming Through.exe!sf::GlResource::GlResource() Line 49   C++
    Small Eye Coming Through.exe!sf::Texture::Texture() Line 66   C++
    Small Eye Coming Through.exe!Level::Level() Line 24   C++
    Small Eye Coming Through.exe!LevelManager::LevelManager() Line 314   C++
    Small Eye Coming Through.exe!`dynamic initializer for 'LvlManager''() Line 59   C++
    Small Eye Coming Through.exe!_initterm(void (void) * * pfbegin=0x0163b488, void (void) * * pfend=0x0163b850) Line 894   C
    Small Eye Coming Through.exe!_cinit(int initFloatingPrecision=1) Line 290   C
    Small Eye Coming Through.exe!__tmainCRTStartup() Line 227   C
    Small Eye Coming Through.exe!mainCRTStartup() Line 164   C
    kernel32.dll!@BaseThreadInitThunk@12()   Unknown
    ntdll.dll!___RtlUserThreadStart@8()   Unknown
    ntdll.dll!__RtlUserThreadStart@8()   Unknown

There is the entire call stack.

The first function which comes from my code is the Level one. It is a constructor.

10
General / Re: LNK 1112 compiling SFML 2.0 to VS2012
« on: February 02, 2013, 05:59:10 pm »
Oh ok, sorry.

Here are the 3 lines below:

 Small Eye Coming Through.exe!sf::Mutex::lock() Line 57
 Small Eye Coming Through.exe!sf::Lock::Lock(sf::Mutex & mutex={...}) Line 39
 Small Eye Coming Through.exe!sf::GlResource::GlResource() Line 49

11
General / Re: LNK 1112 compiling SFML 2.0 to VS2012
« on: February 02, 2013, 12:29:35 pm »
Look at the window with the callstack in it, so you see exactly from where the error originated, i.e. somewhere from your code.

Sorry if I seem stupid, but I am not sure from where it is called, since I never call Mutex explicitly.

From the call stack, the frames/lines above the call to muteximpl::lock is
ntdll.dll!_RtlEnterCriticalSection@4()
Small Eye Coming Through.exe!sf::priv::MutexImpl::lock() Line 52

Does that help? :/


12
General / Re: LNK 1112 compiling SFML 2.0 to VS2012
« on: February 02, 2013, 12:18:56 am »
Is it coming from the constructor of a global variable? (look at the call stack)

>   Small Eye Coming Through.exe!sf::priv::MutexImpl::lock() Line 52
Is the line which the arrow is pointing to in the call stack.

Was that what you meant?(Sorry, I'm not used to using the call stack)

13
General / Re: LNK 1112 compiling SFML 2.0 to VS2012
« on: February 01, 2013, 09:43:08 pm »
Welp, I made a new project and got it running.. partways.

Now, upon compiling the project I get this error(after linking and when the application has launched)

Unhandled exception at 0x771022B2 (ntdll.dll) in Small Eye Coming Through.exe: 0xC0000005: Access violation writing location 0x00000004.

It points me toward the function MutexImpl::Lock

Any clues of why that error is there?

14
General / Re: LNK 1112 compiling SFML 2.0 to VS2012
« on: January 31, 2013, 10:58:44 pm »
Are you 100% sure the built libs are built as 32bit?
The error means that the linker found x64 builds.

Btw if you port your project I'd suggest to start with a new and empty project. ;)

I am not 100% sure, but I think they should be. I selected visual studio 11 as my generator so that should make them 32 bit right? Is there any good way to check?

15
General / LNK 1112 compiling SFML 2.0 to VS2012
« on: January 31, 2013, 10:03:18 pm »
So I'm trying to convert a project of mine from vc++2008 to vs2012, and discovered that since there are no ready built version of SFML for it I would have to compile it myself from CMake.

Firstly I would just like to say that I have never used CMake and I apologize in advance since the solution will most likely be obvious to veterans of CMake.
I followed the tutorial at
http://sfml-dev.org/tutorials/2.0/compile-with-cmake.php
I built the static libraries, with Visual Studio 11(not x64!) chosen as my generator in CMake.

After linking everything correctly(I think) I attempted to compile. I got a few errors which I corrected.
However during linking I get LNK1112 error, with the output saying:
error LNK1112: module machine type 'x64' conflicts with target machine type 'X86'       C:\Users\Admin\Google Drive\C++ project\VS2012\New Game\sfml-system-s-d.lib(Time.obj)  
 

So I was wondering how I should fix this. Did I set something wrong in the CMake options, or is something else the cause?

Some general info:
  • I am using CMake 2.8.10
  • I am using Visual Studio 2012 Express
  • The project itself was win32 in my vc++2008 configuration

Pages: [1] 2 3 ... 7