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

Pages: [1] 2 3 4
1
Audio / Re: Cant get to play next song after first is finnished
« on: January 28, 2014, 12:24:13 am »
yeah. Moved conditional after

 while (app.isOpen())
    {

     if ( musicPlayer.getStatus() == sf::Music::Stopped )
          {
           musicPlayer.openFromFile("song2.wav");
           musicPlayer.play();
           std::cout << "Playing second intro" << std::endl;
          }

        sf::Event event;
        ....
 

And its working. Thank you G.

2
Audio / Cant get to play next song after first is finnished
« on: January 28, 2014, 12:00:23 am »
I tried something simple. It should work, but simply it doesnt and i have no idea why.

sf::Music musicPlayer;
    musicPlayer.openFromFile("song1.wav");
    musicPlayer.play();

    if ( musicPlayer.getStatus() == sf::Music::Stopped )
// OR if ( musicPlayer.getStatus() != sf::Music::Playing )
    {
    musicPlayer.openFromFile("song2.wav");
    musicPlayer.play();
    std::cout << "Playing second song" << std::endl;
    }
 

So after first song is finished it should play 2nd song, but it doesnt, no matter what conditional i use.
Anyone have idea how to implement this?

Thanks in advance
-----------------------------------------------------------------------------------
Also i have popping/cracking sound when i use .ogg files. .wav files works ok.
I have sfml 2.1.

3
General / sfml 2.1 build log shows some warnings
« on: August 15, 2013, 03:07:28 am »
http://pastebin.com/SYvGB6N5  << entire build log.

Actual warning is on 36%
[ 36%] Building CXX object src/SFML/Window/CMakeFiles/sfml-window.dir/Linux/JoystickImpl.cpp.o
/home/xwm/Downloads/SFML-2.1/src/SFML/Window/Linux/JoystickImpl.cpp: In static member function ‘static bool sf::priv::JoystickImpl::isConnected(unsigned int)’:
/home/xwm/Downloads/SFML-2.1/src/SFML/Window/Linux/JoystickImpl.cpp:123:51: warning: ignoring return value of ‘ssize_t read(int, void*, size_t)’, declared with attribute warn_unused_result [-Wunused-result]
 

Have i done something wrong? I installed sfml after it and sfml is working. Havent tested joystick so far.

info:
Linux 3.2.0-51 Kernel
Gcc 4.6.3
GNU Make 3.81

4
General / Re: Fullpath or execution dir on widows/linux/mac
« on: July 31, 2013, 12:09:14 am »
Solved it with:
#ifdef __linux
#include <unistd.h>

std::string getexepath()
  {
  char result[ PATH_MAX ];
  ssize_t count = readlink( "/proc/self/exe", result, PATH_MAX );
  return std::string( result, (count > 0) ? count : 0 );
  }
std::string DirName(std::string source)
{
    source.erase(std::find(source.rbegin(), source.rend(), '/').base(), source.end());
    return source;
}
#endif
 

call it from main();
std::string;
asd = getexepath();
asd = DirName(asd);
 
So string asd now have path to executable without executable name
so sf::Texture texture have become:
sf::Texture texture;
if (!texture.loadFromFile(asd + "Data/again/cb.bmp"))
{
    return 1;
}
 

And it works. Thank you for your help guys. Will work on windows and mac version of #define and will post code here, so if somebody needs it can use it :)

5
General / Re: Fullpath or execution dir on widows/linux/mac
« on: July 30, 2013, 10:24:28 pm »
So back to beginning:

#ifdef __linux
#include <unistd.h>

std::string getexepath()
  {
  char result[ PATH_MAX ];
  ssize_t count = readlink( "/proc/self/exe", result, PATH_MAX );
  return std::string( result, (count > 0) ? count : 0 );
  }
 
Anyone have an idea how to fixthis code to get output of folder where the application is started without application name?

6
General / Re: Fullpath or execution dir on widows/linux/mac
« on: July 30, 2013, 09:40:45 pm »
But the path to execution directory inside program will solve the problems i have with either linux or nautilus? [ i am using program pantheon-files]

7
General / Re: Fullpath or execution dir on widows/linux/mac
« on: July 30, 2013, 09:28:48 pm »
#include <SFML/Graphics.hpp>

int main()
{
    // Create the main window
    sf::RenderWindow window(sf::VideoMode(800, 600), "test");

    // Load a background
    sf::Texture background;
   if (!background.loadFromFile("Data/cb.bmp"))
   {
  return -1;
   }

    // load a sprite to display
    sf::Sprite sprite;
    sprite.setTexture(background);

        // Start the game loop
    while (window.isOpen())
    {
        // Process events
        sf::Event Event;
        while (window.pollEvent(Event))
        {
            // Close window : exit
            if (Event.type == sf::Event::Closed)
                window.close();
        }

        // Clear screen
        window.clear();

        // Draw the sprite
        window.draw(sprite);

        // Update the window
        window.display();
    }

    return EXIT_SUCCESS;
}
 
with cb.bmp being in "Data" folder. From terminal and from IDE it works, cant start application with double click on it. Nothing happends


EDIT: I could see only black screen on my app since i didnt have
// Draw the sprite
window.draw(sprite);
 

I have: gui.draw();  << since i use tgui :)

8
General / Re: Fullpath or execution dir on widows/linux/mac
« on: July 30, 2013, 08:54:50 pm »
So what you want me to do with Lo-X code ?

9
General / Re: Fullpath or execution dir on widows/linux/mac
« on: July 30, 2013, 08:40:30 pm »
Yes, i will test what you said in minute or two :)

10
General / Re: Fullpath or execution dir on widows/linux/mac
« on: July 30, 2013, 08:34:42 pm »
#include <stdio.h>
#include <unistd.h>
#include <string.h>

int main(int argc, char **argv)
{
    char the_path[256];

    getcwd(the_path, 255);

    printf("%s\n", the_path);

    return 0;
}
 

My mistake again.
its Lo-x code i used in my application, and the one i posted results

11
General / Re: Fullpath or execution dir on widows/linux/mac
« on: July 30, 2013, 08:29:45 pm »
#include <unistd.h>
#include <iostream>

int main(int, char**) {
    char* pwd = getwd(NULL);
    std::cout << "Working directory: " << pwd;
    free(pwd);
    return 0;
}
 

Cant compile:

=== hiura test, Debug ===
warning: ‘char* getwd(char*)’ is deprecated (declared at /usr/include/i386-linux-gnu/bits/unistd.h:222) [-Wdeprecated-declarations]|
warning: null argument where non-null required (argument 1) [-Wnonnull]|
warning: ‘char* getwd(char*)’ is deprecated (declared at /usr/include/i386-linux-gnu/bits/unistd.h:222) [-Wdeprecated-declarations]|
error: ‘free’ was not declared in this scope|
=== Build finished: 1 errors, 3 warnings (0 minutes, 1 seconds) ===

Give me a minut or two to test another code

12
General / Re: Fullpath or execution dir on widows/linux/mac
« on: July 30, 2013, 08:10:13 pm »
Yup, but the way you said it i tought you want me to actualy double click on console application and see what happends :)

Anyway put Hiura code into my app
This is output from terminal when i start compiled and builded application with ./Swing Studio 0:
/home/xwm/Developing/Swing Studio 0.4.0/bin/Debug/Swing Studio 0  << my #define __linux
/home/xwm/Developing/Swing Studio 0.4.0/bin/Debug                            << Hiura code

This is output from IDE terminal when i start application from IDE:
/home/xwm/Developing/Swing Studio 0.4.0/bin/Debug/Swing Studio 0 << my #define __linux
/home/xwm/Developing/Swing Studio 0.4.0                                            << Hiura code

EDIT: Typed Hiura Name/Nick wrong. My appology
EDIT NO 2. It was Lo-X code

13
General / Re: Fullpath or execution dir on widows/linux/mac
« on: July 30, 2013, 07:36:30 pm »
@wmbuRn :

What happen if you use Hiura code or the code below in your program when 1) you launch it by command line and 2) by double clicking

#include <stdio.h>
#include <unistd.h>
#include <string.h>

int main(int argc, char **argv) {
    char the_path[256];

    getcwd(the_path, 255);

    printf("%s\n", the_path);

    return 0;
}
1. I moved application everywhere and start it from terminal, it does output the folder where the application is.
2. Nothing is shown, screen wont even blink. Like i havent double clicked on it.

14
General / Re: Fullpath or execution dir on widows/linux/mac
« on: July 30, 2013, 07:25:52 pm »
Will this work on linux/ windows/ mac:

imagine these functions return path to application without programName[.exe or .out or .app]
#ifdef _WIN32
#include <windows.h>

std::string getexepath()
  {
  char result[ MAX_PATH ];
  return std::string( result, GetModuleFileName( NULL, result, MAX_PATH ) );
  }
#endif

#ifdef __linux
#include <unistd.h>

std::string getexepath()
  {
  char result[ PATH_MAX ];
  ssize_t count = readlink( "/proc/self/exe", result, PATH_MAX );
  return std::string( result, (count > 0) ? count : 0 );
  }
#endif
#ifdef __APPLE__
// imagine there is getexepath() function that return exe path on mac
#endif
 

so calling this code:
...
std::string asd;
asd = getexepath();
...
picture->load(asd + "Data/Backgrounds/loginBackground.png");
same code should work on windows/linux/mac?

15
General / Re: Fullpath or execution dir on widows/linux/mac
« on: July 30, 2013, 07:06:56 pm »
I never used mac, barely used windows. Whole my life i spent using linux. So only thing i used from Windows family is windows 98 :)

I am curently using linux > elementary os luna beta 2, which looks like mac :)

And i have no idea why "Data/ images i need.png" wont work when started via double click.

Pages: [1] 2 3 4