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

Pages: 1 [2] 3
16
Audio / can't play music files
« on: December 17, 2011, 05:23:37 pm »
hi,

I'm trying to load & play ogg and flac files. I wrote a class that uses sf::Music to load & play the files.

Although it seems to load them & even play them, I can't hear anything... Yes I have the volume turned up, and the device turned on :)

I have two different audio devices: my video card's hdmi output, and the internal sound card, which I use. I can play sounds with sf::Sound & sf::SoundBuffer, but not music. I'm on kUbuntu 11.10 64 bit, and using the latest SFML snapshot.

here's the code:
Code: [Select]

#ifndef sound_stream_h
#define sound_stream_h

#include "common.h"

class sound_stream
{
private:
    sf::Music samples;
    bool loaded;
protected:

public:

    void load(std::string filename);
    void play();
    void pause();
    void stop();
    int get_duration();
    void set_loop(bool loop);
    void set_pitch(float pitch);
    void set_volume(float volume);

    sound_stream() : loaded(false) {}
};

#endif


Code: [Select]

#include "sound_stream.h"
#include "objs.h"

void sound_stream::load(std::string filename)
{
    std::cout << "-Loading: " << filename << "\n";
    timer sound_timer;
    sound_timer.set_timerbegin();
    std::string full_path = objs::get()->conf.app_path + filename;
    if (objs::get()->file_exists(full_path))
    {
        if (samples.OpenFromFile(full_path))
        {
            loaded = true;
            std::cout << "  Loaded in: " << sound_timer.get_time_passed() / 1000.0f << " seconds\n";

        }
        else
        {
            loaded = false;
            std::cerr << "Error loading sound stream file: " << filename << "\n";
        }
    }
    else
    {
        loaded = false;
        std::cerr << "Error loading sound stream file: " << filename << "\n";
    }
}

void sound_stream::play()
{
    if (!loaded)
    {
        return;
    }

    samples.Play();
}

void sound_stream::pause()
{
    if (!loaded)
    {
        return;
    }

    samples.Pause();
}

void sound_stream::stop()
{
    if (!loaded)
    {
        return;
    }

    samples.Stop();
}

int sound_stream::get_duration()
{
    if (!loaded)
    {
        return -1;
    }

    return samples.GetDuration();
}

void sound_stream::set_loop(bool loop)
{
    if (!loaded)
    {
        return;
    }

    samples.SetLoop(loop);
}


void sound_stream::set_pitch(float pitch)
{
    if (!loaded)
    {
        return;
    }

    samples.SetPitch(pitch);
}

void sound_stream::set_volume(float volume)
{
    if (!loaded)
    {
        return;
    }

    if (volume >= 0.0f && volume <= 100.0f)
    {
        samples.SetVolume(volume);
    }
}


and I use it like this:
Code: [Select]

sound_stream test;

    test.load("resources/test.flac");

    test.play();


any idea what might be going wrong?

Best regards,
Yours3!f

17
sorry guys, but it was rather a cmake related issue... However you do need to link against sfml-system...

ps. I'm not too good at cmake :)

18
General discussions / FPS calculations with SFML2.0
« on: October 17, 2011, 10:21:08 am »
ok guys so here's how I do it:


Code: [Select]

float fps = 1.0f;
int frames = 0;
std::wstringstream ws;
timer render_timer;
font the_font;

while(true)
{
    frames++; //increment frame counter
    //check if a 1000ms (a second) has passed
    if ( render_timer.get_time_passed() > 1000.0f )
    {
        int timepassed = render_timer.get_time_passed();
        //if a second has passed, then fps equals, lets say:
        //60.099 = 1000 / ( 1015 / 61 )
        //so 61 frames have been drawn in 1015 ms --> 16.64 ms is the average time spent on one frame
        // so in 1000ms (a second) we have 1000 / 16.64 ms = 60.099 fps
        fps = 1000.0f / ( ( float ) timepassed / ( float ) frames );
        frames = 0;
        timepassed = 0;
        //reset timer
        render_timer.set_timerbegin();
    }

    ws << L"FPS:" << fps;
    the_font.render ( ws.str() );
    ws.str ( L"" );

    //check for error
    objs::get()->check_for_opengl_error();

    //show our work
    swap_buffer();
}


happy coding :)

19
Hi,

I've just upgraded my sfml build to the latest snapshot, and I experienced a strange thing: when I tried to compile my project it throw me the following error:
Quote

/usr/bin/ld: CMakeFiles/proba2.dir/src/main.cpp.o: undefined reference to symbol 'sf::Clock::Clock()'
/usr/bin/ld: note: 'sf::Clock::Clock()' is defined in DSO /usr/local/lib/libsfml-system.so.2 so try adding it to the linker command line
/usr/local/lib/libsfml-system.so.2: could not read symbols: Invalid operation


Which is strange because linking to sfml-window used to work until now, so I tried to link sfml-system (as suggested), but the compiler went crazy and all my linkings, GLEW, freetype, freeimage etc. throw undefined reference...
Quote

set(${project_name}_external_libs Xrandr pthread sfml-window sfml-system GLEW freetype freeimage)


Is there something I forgot (or should've done)?

I installed the snapshot with:
Quote

cmake CM*
make
sudo make install


EDIT:
here's are the building errors with sfml-system:
Quote
libload_obj.so: undefined reference to `__glewBindBuffer'
libframe_buffer.so: undefined reference to `__glewCheckFramebufferStatus'
libshader_manager.so: undefined reference to `__glewGetShaderiv'
libloop.so: undefined reference to `__GLEW_VERSION_3_3'
libimage_loader.so: undefined reference to `FreeImage_GetWidth'
libfont.so: undefined reference to `FT_Set_Char_Size'
libimage_loader.so: undefined reference to `FreeImage_GetHeight'
librender_buffer.so: undefined reference to `__glewIsRenderbuffer'
librender_buffer.so: undefined reference to `__glewFramebufferRenderbuffer'
/home/yours3lf/Documents/proba2/mymath/lib/libcamera.so: undefined reference to `mymath::mymath_main::export_m3x3_from_m4x4(mymath::m4x4)'
libimage_loader.so: undefined reference to `FreeImage_Load'
librender_buffer.so: undefined reference to `__glewBindRenderbuffer'
libload_obj.so: undefined reference to `__glewVertexAttribPointer'
libshader.so: undefined reference to `__glewUniformMatrix3fv'
/home/yours3lf/Documents/proba2/mymath/lib/libcamera.so: undefined reference to `mymath::mymath_main::get_plane_eq(mymath::vec3f, mymath::vec3f, mymath::vec3f)'
libframe_buffer.so: undefined reference to `__glewIsFramebuffer'
libshader.so: undefined reference to `__glewUniformMatrix4fv'
libshader.so: undefined reference to `__glewUniform4fv'
libload_obj.so: undefined reference to `__glewEnableVertexAttribArray'
libshader_manager.so: undefined reference to `__glewGetUniformLocation'
libimage_loader.so: undefined reference to `FreeImage_GetBits'
libshader_manager.so: undefined reference to `__glewLinkProgram'
/home/yours3lf/Documents/proba2/mymath/lib/libcamera.so: undefined reference to `mymath::mymath_main::create_rotation_m4x4(float, mymath::vec3f)'
libimage_loader.so: undefined reference to `FreeImage_ConvertTo32Bits'
librender_buffer.so: undefined reference to `__glewRenderbufferStorage'
libtexture.so: undefined reference to `__glewFramebufferTexture2D'
libload_obj.so: undefined reference to `__glewGenVertexArrays'
libloop.so: undefined reference to `glewInit'
libshader_manager.so: undefined reference to `__glewGetProgramInfoLog'
libloop.so: undefined reference to `event::get_resize()'
libshader_manager.so: undefined reference to `__glewCompileShader'
/home/yours3lf/Documents/proba2/mymath/lib/libcamera.so: undefined reference to `mymath::mymath_main::cross_prod(mymath::vec3f, mymath::vec3f)'
libmesh.so: undefined reference to `__glewDrawRangeElements'
libloop.so: undefined reference to `glewGetErrorString'
libfont.so: undefined reference to `FT_Init_FreeType'
libloop.so: undefined reference to `FreeImage_GetVersion'
libshader_manager.so: undefined reference to `__glewCreateShader'
libshader_manager.so: undefined reference to `__glewCreateProgram'
librender_buffer.so: undefined reference to `__glewGenRenderbuffers'
libloop.so: undefined reference to `glewGetString'
libshader.so: undefined reference to `__glewUniform1i'
libshader_manager.so: undefined reference to `__glewShaderSource'
libmip_map_creator.so: undefined reference to `__glewTexImage3D'
/home/yours3lf/Documents/proba2/mymath/lib/libcamera.so: undefined reference to `mymath::mymath_main::create_translation_m4x4(mymath::vec3f)'
/home/yours3lf/Documents/proba2/mymath/lib/libcamera.so: undefined reference to `mymath::mymath_main::create_rotation_m3x3(float, mymath::vec3f)'
libload_obj.so: undefined reference to `__glewGetAttribLocation'
libloop.so: undefined reference to `FreeImage_Initialise'
libshader_manager.so: undefined reference to `__glewGetShaderInfoLog'
libload_obj.so: undefined reference to `__glewBindVertexArray'
libfont.so: undefined reference to `FT_New_Face'
/home/yours3lf/Documents/proba2/mymath/lib/libcamera.so: undefined reference to `mymath::mymath_main::create_ortographic_m4x4(float, float, float, float, float, float)'
libload_obj.so: undefined reference to `__glewGenBuffers'
libshader_manager.so: undefined reference to `__glewGetProgramiv'
libfont.so: undefined reference to `FT_Load_Char'
/home/yours3lf/Documents/proba2/mymath/lib/libmatrix_stack.so: undefined reference to `mymath::mymath_main::create_scale_m4x4(mymath::vec3f)'
/home/yours3lf/Documents/proba2/mymath/lib/libcamera.so: undefined reference to `mymath::mymath_main::rotate_vec3f(mymath::vec3f, mymath::m3x3)'
libimage_loader.so: undefined reference to `FreeImage_GetFileType'
/home/yours3lf/Documents/proba2/mymath/lib/libcamera.so: undefined reference to `mymath::mymath_main::normalize_vec3f(mymath::vec3f)'
libshader_manager.so: undefined reference to `__glewBindAttribLocation'
/home/yours3lf/Documents/proba2/mymath/lib/libcamera.so: undefined reference to `mymath::mymath_main::transform_vec4f(mymath::vec4f, mymath::m4x4)'
libload_obj.so: undefined reference to `__glewBufferData'
libshader.so: undefined reference to `__glewUseProgram'
libframe_buffer.so: undefined reference to `__glewDrawBuffers'
libshader_manager.so: undefined reference to `__glewAttachShader'
libloop.so: undefined reference to `event::handle_event()'
libframe_buffer.so: undefined reference to `__glewGenFramebuffers'
/home/yours3lf/Documents/proba2/mymath/lib/libcamera.so: undefined reference to `mymath::mymath_main::deg_to_rad(float)'
libshader_manager.so: undefined reference to `__glewValidateProgram'
libframe_buffer.so: undefined reference to `__glewBindFramebuffer'
/home/yours3lf/Documents/proba2/mymath/lib/libcamera.so: undefined reference to `mymath::operator*(mymath::m3x3 const&, mymath::vec3f const&)'


EDIT2:
I've uploaded a small program to demonstrate this. However in this the compiler doesn't go crazy when I add sfml-system, but it can only find GLEW if I install it from the software center, if I install GLEW manually it can't find it... (and it only complains about it in runtime...)
here's the link: http://www.2shared.com/file/BzOPYhu8/sfml-testtar.html

EDIT3:
Here's another program, but now the compiler does go crazy... This used to work before...
link: http://www.2shared.com/file/zR0pVQTR/proba3tar.html

Best regards,
Yours3lf

20
General / get current context & current display
« on: October 11, 2011, 06:03:26 pm »
ok, thanks :) after a quick googling I found that I just need to include GL/glx.h and the glx funcs are working now :)

21
General / get current context & current display
« on: October 11, 2011, 04:28:04 pm »
Thanks Laurent, but I'm on linux :) so I guess that doesn't apply to me...
Or does it? I tried it but either I have to include something else or that's windows only.

22
General / get current context & current display
« on: October 10, 2011, 07:44:50 pm »
Hi,

I'm currently experimenting with OpenCL OpenGL interoperation, so to set up my context I'd need the current context and the current display id.

with glx it looks like this:
Code: [Select]
cl_context_properties properties[] =
{
  CL_GL_CONTEXT_KHR, (cl_context_properties)glXGetCurrentContext(), //the GL context id
  CL_GLX_DISPLAY_KHR, (cl_context_properties)glXGetCurrentDisplay(), //the display id
  CL_CONTEXT_PLATFORM, (cl_context_properties)the_cl_platform, //this is set up by me
  0
};

cl_int error;
//the_cl_device is set up by me
the_cl_context = clCreateContext(properties, 1, &the_cl_device, 0, 0, &error);
assert(error == CL_SUCCESS);


so how can I get the same GL context id and window id in SFML?
NOTE: I'm on Linux.

here's the pdf that explains CL-GL interop:
http://sa10.idav.ucdavis.edu/docs/sa10-dg-opencl-gl-interop.pdf

Best regards,
Yours3!f

23
General / mouse warping in sfml
« on: July 23, 2011, 09:25:22 am »
I think I solved the problem, I just needed to use
sf::Mouse::SetPosition(pos, window)
instead of
sf::Mouse::SetPosition(pos)

where window was the main window I created.
It seems to set the cursor position to the right location now.

24
General / mouse warping in sfml
« on: July 22, 2011, 09:58:09 pm »
ok, I'm having a little bit of problem with this function.
It seems to warp my mouse to:
x coord: middle of the screen
y coord: middle of the screen - mouse height

that is for a 1280x720 window I get the mouse position 640, 340. I don't know if it is an SFML bug or I've done something wrong or it is just the windowing system (Kubuntu 11.04/ KDE), but it is clear that it warps my mouse to that location, because if I move the mouse in a way that in 33 ms (one frame) it moves more than 20-30 pixels then eventually my camera goes down as opposed to always going upwards because of that.

Did anyone have issues like that?

or how can I get the height of the cursor so that I can warp it to the correct position?

Best regards,
Yours3!f

25
General / mouse warping in sfml
« on: July 17, 2011, 06:29:58 pm »
Thanks, I'm going to build the docs definitely. I'm using version 2.

26
General / mouse warping in sfml
« on: July 17, 2011, 12:15:55 am »
wow, ok, I only checked the docs here on sfml-dev.org...
is the one on github better?

anyways thank you!

27
Window / set fullscreen mode for an already created window
« on: July 17, 2011, 12:03:53 am »
ok thank you.

28
General / mouse warping in sfml
« on: July 16, 2011, 11:46:20 pm »
Hi,

I want to warp the mouse, so that the user can move the camera in FPS style.
in SDL there is a function SDL_WarpMoues() which does this. Is there such thing in SFML? Or how is it done in SFML?

Best regards,
Yours3!f

29
Window / set fullscreen mode for an already created window
« on: July 16, 2011, 10:25:59 pm »
Hi,

I'd like to set the fullscreen mode for an already created window without recreating it.

like so:

sf::Window the_window;

the_window.Create(sf::VideoMode(800, 600, 32), "", sf::Style::Default, sf::ContextSettings(0, 0, 0, 4, 1));

the_window.SetFullscreen(true);
or something like that.
and
the_window.SetFullscreen(false);
for making it windowed again.
How can I do that?

(I looked in the docs but I found nothing about it only recreating the window, on the forum I couldn't find any answer)

EDIT:
To add, how can I change the video mode in runtime without recreating the window?

Best regards,
Yours3!f

30
General discussions / SDL vs. SFML
« on: June 11, 2011, 09:50:22 am »
i tried and it was nice, really easy to set up i still use it for some projects

Pages: 1 [2] 3