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

Pages: [1]
1
Feature requests / System cursors
« on: January 19, 2015, 09:43:19 pm »
I would like to be able to set the mouse cursor to the OS's built in cursors (arrow, edit wait, regular etc).

There's example here: https://github.com/SFML/SFML/wiki/Tutorial:-Change-Cursor. Is there some reason this feature isn't included in sfml?

2
Graphics / Reset view zoom?
« on: December 25, 2014, 02:22:08 pm »
How do I reset a view that I've called zoom() on to a zoom factor of 100%  without altering it's position?

3
Graphics / VertexArray repeat texture [Solved]
« on: December 25, 2014, 09:17:33 am »
How do I repeat a texture without stretching it across the size of the vertex array?

I've tried this: but it seems  to stretch the checkers.

Relevant Code: (rect is area I would like to repeat texture in. the texture is 64x64 px)
sf::Texture checkers;
checkers.loadFromImage(*createChecker());
checkers.setRepeated(true);

void Checkers::setTextureRect(sf::IntRect rect)
{
        // size //
        m_vertices[0].position = sf::Vector2f(0,0);
        m_vertices[1].position = sf::Vector2f(rect.width,0);
        m_vertices[2].position = sf::Vector2f(rect.width, rect.height);
        m_vertices[3].position = sf::Vector2f(0,rect.height);
       
        m_vertices[0].texCoords = sf::Vector2f(0,0);
        m_vertices[1].texCoords = sf::Vector2f(64,0);
        m_vertices[2].texCoords = sf::Vector2f(64, 64);
        m_vertices[3].texCoords = sf::Vector2f(0,64);
}

void Checkers::draw(sf::RenderTarget& target, sf::RenderStates states) const
{
    states.transform *= getTransform();
    states.texture = checkers;

    target.draw(m_vertices, states);
}

4
Graphics / BlendMode
« on: December 24, 2014, 01:41:02 am »
I want to draw lines as the opposite color as the background with alpha. How I do this?
This blend mode draws opposite color of background
states.blendMode = sf::BlendMode(sf::BlendMode::OneMinusDstColor, sf::BlendMode::Zero,sf::BlendMode::Add, sf::BlendMode::One, sf::BlendMode::Zero, sf::BlendMode::Add);
 
but it doesn't draw alpha I set on the lines. How do I make alpha work? I tried this but no good.
states.blendMode = sf::BlendMode(sf::BlendMode::OneMinusDstColor, sf::BlendMode::OneMinusSrcAlpha,sf::BlendMode::Add, sf::BlendMode::One, sf::BlendMode::OneMinusDstAlpha, sf::BlendMode::Add);
 

5
Graphics / Undoing Color to Alpha.
« on: December 16, 2014, 01:38:10 am »
I want to change color in image to alpha. I can do this with sf::image's createMaskFromColor however what's the best way to reverse this? Do I need to store two copies? or do I loop through all the pixels? or is there a better way?

6
Feature requests / Better way to get errors.
« on: December 02, 2014, 11:51:25 pm »
I would like to display sfml's errors in my gui but since they're an ostream theres really no neat way to do this....

7
Feature requests / sf::VerArray.erase
« on: November 04, 2014, 03:06:07 am »
I need to erase a vertex from a vertexarray. There is no erase function. Please add one.

8
General / Why can't wxwidgets and sfml play nice?
« on: September 02, 2014, 10:36:07 pm »
I want to use sfml with wxwidgets. I tried to follow a rather dated tutorial because there isn't a more recent one.

Tutorials here: http://sfml-dev.org/tutorials/1.6/graphics-wxwidgets.php

The tutorial is for sfml1.6 and wxwidgets 2.x however I want to use sfml2.1 with wxwidgets 3 but the code wont compile. Apparently win_gtk.h is now a private header and unaccessible in gtk3? This header contains gtk_pizza. As for the display() error I have no idea what's wrong there... Anyway to make everything play nice?

Here's my code:

#include <SFML/Graphics.hpp>

#include <wx/wx.h>

#ifdef __WXGTK__
    #include <gdk/gdkx.h>
    #include <gtk/gtk.h>
    // #include <wx/gtk/win_gtk.h> this doesn't exist in wxwidgets3?
#endif


class wxSFMLCanvas : public wxControl, public sf::RenderWindow
{
public :

    wxSFMLCanvas(wxWindow* Parent = NULL, wxWindowID Id = -1, const wxPoint& Position = wxDefaultPosition,
                 const wxSize& Size = wxDefaultSize, long Style = 0);

    virtual ~wxSFMLCanvas();

private :

    DECLARE_EVENT_TABLE()

    virtual void OnUpdate();

    void OnIdle(wxIdleEvent&);

    void OnPaint(wxPaintEvent&);

    void OnEraseBackground(wxEraseEvent&);
};

void wxSFMLCanvas::OnIdle(wxIdleEvent&)
{
    // Send a paint message when the control is idle, to ensure maximum framerate
    Refresh();
}

void wxSFMLCanvas::OnPaint(wxPaintEvent&)
{
    // Prepare the control to be repainted
    wxPaintDC Dc(this);

    // Let the derived class do its specific stuff
    OnUpdate();

    // Display on screen
    Display();
}


wxSFMLCanvas::wxSFMLCanvas(wxWindow* Parent, wxWindowID Id, const wxPoint& Position, const wxSize& Size, long Style) :
wxControl(Parent, Id, Position, Size, Style)
{
    #ifdef __WXGTK__

        // GTK implementation requires to go deeper to find the
        // low-level X11 identifier of the widget
        gtk_widget_realize(m_wxwindow);
        gtk_widget_set_double_buffered(m_wxwindow, false);
        GdkWindow* Win = GTK_PIZZA(m_wxwindow)->bin_window;
        XFlush(GDK_WINDOW_XDISPLAY(Win));
        //sf::RenderWindow::Create(GDK_WINDOW_XWINDOW(Win));

    #else

        // Tested under Windows XP only (should work with X11
        // and other Windows versions - no idea about MacOS)
        //sf::RenderWindow::Create(GetHandle());

    #endif
}

Here are the errors:
[greg@greg-desktop polyedit]$ make
g++ -g -I. -I/usr/lib/wx/include/gtk2-unicode-3.0 -I/usr/include/wx-3.0 -D_FILE_OFFSET_BITS=64 -DWXUSINGDLL -D__WXGTK__ -pthread -I/usr/include/gtk-2.0 -I/usr/lib/gtk-2.0/include -I/usr/include/pango-1.0 -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/pixman-1 -I/usr/include/libdrm -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/libpng16 -I/usr/include/pango-1.0 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/include/freetype2 -I/usr/include/libpng16 -I/usr/include/harfbuzz -I/usr/include/freetype2 -I/usr/include/libpng16 -I/usr/include/harfbuzz   -MMD -MP -c -o .eobjs/./main.o main.cpp
main.cpp: In member function 'void wxSFMLCanvas::OnPaint(wxPaintEvent&)':
main.cpp:49:13: error: invalid use of incomplete type 'Display {aka struct _XDisplay}'
     Display();
             ^
In file included from /usr/include/wx-3.0/wx/cursor.h:69:0,
                 from /usr/include/wx-3.0/wx/event.h:21,
                 from /usr/include/wx-3.0/wx/wx.h:24,
                 from main.cpp:3:
/usr/include/wx-3.0/wx/utils.h:778:15: error: forward declaration of 'Display {aka struct _XDisplay}'
 inline struct _XDisplay *wxGetX11Display()
               ^
main.cpp: In constructor 'wxSFMLCanvas::wxSFMLCanvas(wxWindow*, wxWindowID, const wxPoint&, const wxSize&, long int)':
main.cpp:62:46: error: 'GTK_PIZZA' was not declared in this scope
         GdkWindow* Win = GTK_PIZZA(m_wxwindow)->bin_window


9
Audio / Linking sfml on Mac OSX
« on: August 17, 2013, 09:02:11 pm »
clang++  -o "/Users/greg/enigma-dev/./MacOS/build/Release/EnigmaXcode.app/Contents/MacOS/EnigmaXcode" .eobjs/MacOSX/MacOSX/Run/SHELLmain.o .eobjs/MacOSX/MacOSX/Run/libEGMstd.o .eobjs/MacOSX/MacOSX/Run/Platforms/Cocoa/CocoaDialog.o .eobjs/MacOSX/MacOSX/Run/Platforms/Cocoa/CocoaFunctions.o .eobjs/MacOSX/MacOSX/Run/Platforms/Cocoa/CocoaMain.o .eobjs/MacOSX/MacOSX/Run/Platforms/Cocoa/CocoaWindow.o .eobjs/MacOSX/MacOSX/Run/Platforms/Cocoa/XLIBthreads.o .eobjs/MacOSX/MacOSX/Run/Platforms/Cocoa/file_manip.o .eobjs/MacOSX/MacOSX/Run/Platforms/Cocoa/EnigmaView.o .eobjs/MacOSX/MacOSX/Run/Platforms/Cocoa/EnigmaXcodeAppDelegate.o .eobjs/MacOSX/MacOSX/Run/Platforms/Cocoa/WindowFunctions.o .eobjs/MacOSX/MacOSX/Run/Platforms/Cocoa/main.o .eobjs/MacOSX/MacOSX/Run/Graphics_Systems/OpenGL1/GLbackground.o .eobjs/MacOSX/MacOSX/Run/Graphics_Systems/OpenGL1/GLblend.o .eobjs/MacOSX/MacOSX/Run/Graphics_Systems/OpenGL1/GLcolors.o .eobjs/MacOSX/MacOSX/Run/Graphics_Systems/OpenGL1/GLcurves.o .eobjs/MacOSX/MacOSX/Run/Graphics_Systems/OpenGL1/GLd3d.o .eobjs/MacOSX/MacOSX/Run/Graphics_Systems/OpenGL1/GLenable.o .eobjs/MacOSX/MacOSX/Run/Graphics_Systems/OpenGL1/GLfont.o .eobjs/MacOSX/MacOSX/Run/Graphics_Systems/OpenGL1/GLmodel.o .eobjs/MacOSX/MacOSX/Run/Graphics_Systems/OpenGL1/GLprimitives.o .eobjs/MacOSX/MacOSX/Run/Graphics_Systems/OpenGL1/GLprofiler.o .eobjs/MacOSX/MacOSX/Run/Graphics_Systems/OpenGL1/GLscreen.o .eobjs/MacOSX/MacOSX/Run/Graphics_Systems/OpenGL1/GLshapes.o .eobjs/MacOSX/MacOSX/Run/Graphics_Systems/OpenGL1/GLsprite.o .eobjs/MacOSX/MacOSX/Run/Graphics_Systems/OpenGL1/GLstdraw.o .eobjs/MacOSX/MacOSX/Run/Graphics_Systems/OpenGL1/GLsurface.o .eobjs/MacOSX/MacOSX/Run/Graphics_Systems/OpenGL1/GLtextures.o .eobjs/MacOSX/MacOSX/Run/Graphics_Systems/OpenGL1/GLtiles.o .eobjs/MacOSX/MacOSX/Run/Graphics_Systems/OpenGL1/OPENGLStd.o .eobjs/MacOSX/MacOSX/Run/Graphics_Systems/OpenGL1/glew.o .eobjs/MacOSX/MacOSX/Run/Audio_Systems/SFML/SFMLadvanced.o .eobjs/MacOSX/MacOSX/Run/Audio_Systems/SFML/SFMLbasic.o .eobjs/MacOSX/MacOSX/Run/Collision_Systems/Precise/coll_funcs.o .eobjs/MacOSX/MacOSX/Run/Collision_Systems/Precise/coll_impl.o .eobjs/MacOSX/MacOSX/Run/Collision_Systems/Precise/placeholderlinks.o .eobjs/MacOSX/MacOSX/Run/Widget_Systems/None/nowidget_impl.o .eobjs/MacOSX/MacOSX/Run/Universal_System/CallbackArrays.o .eobjs/MacOSX/MacOSX/Run/Universal_System/ENIGMA_GLOBALS.o .eobjs/MacOSX/MacOSX/Run/Universal_System/IMGloading.o .eobjs/MacOSX/MacOSX/Run/Universal_System/backgroundinit.o .eobjs/MacOSX/MacOSX/Run/Universal_System/backgroundstruct.o .eobjs/MacOSX/MacOSX/Run/Universal_System/callbacks_events.o .eobjs/MacOSX/MacOSX/Run/Universal_System/collisions_object.o .eobjs/MacOSX/MacOSX/Run/Universal_System/darray.o .eobjs/MacOSX/MacOSX/Run/Universal_System/depth_draw.o .eobjs/MacOSX/MacOSX/Run/Universal_System/dynamic_args.o .eobjs/MacOSX/MacOSX/Run/Universal_System/estring.o .eobjs/MacOSX/MacOSX/Run/Universal_System/fileio.o .eobjs/MacOSX/MacOSX/Run/Universal_System/fontinit.o .eobjs/MacOSX/MacOSX/Run/Universal_System/fontstruct.o .eobjs/MacOSX/MacOSX/Run/Universal_System/globalupdate.o .eobjs/MacOSX/MacOSX/Run/Universal_System/graphics_object.o .eobjs/MacOSX/MacOSX/Run/Universal_System/highscore_functions.o .eobjs/MacOSX/MacOSX/Run/Universal_System/instance.o .eobjs/MacOSX/MacOSX/Run/Universal_System/instance_planar.o .eobjs/MacOSX/MacOSX/Run/Universal_System/instance_system.o .eobjs/MacOSX/MacOSX/Run/Universal_System/lives.o .eobjs/MacOSX/MacOSX/Run/Universal_System/loading.o .eobjs/MacOSX/MacOSX/Run/Universal_System/lodepng.o .eobjs/MacOSX/MacOSX/Run/Universal_System/mathnc.o .eobjs/MacOSX/MacOSX/Run/Universal_System/move_functions.o .eobjs/MacOSX/MacOSX/Run/Universal_System/multifunction_variant.o .eobjs/MacOSX/MacOSX/Run/Universal_System/object.o .eobjs/MacOSX/MacOSX/Run/Universal_System/planar_object.o .eobjs/MacOSX/MacOSX/Run/Universal_System/rectpack.o .eobjs/MacOSX/MacOSX/Run/Universal_System/reflexive_types.o .eobjs/MacOSX/MacOSX/Run/Universal_System/resource_data.o .eobjs/MacOSX/MacOSX/Run/Universal_System/roomsystem.o .eobjs/MacOSX/MacOSX/Run/Universal_System/soundinit.o .eobjs/MacOSX/MacOSX/Run/Universal_System/spriteinit.o .eobjs/MacOSX/MacOSX/Run/Universal_System/spritestruct.o .eobjs/MacOSX/MacOSX/Run/Universal_System/terminal_io.o .eobjs/MacOSX/MacOSX/Run/Universal_System/transform_object.o .eobjs/MacOSX/MacOSX/Run/Universal_System/var4.o .eobjs/MacOSX/MacOSX/Run/Universal_System/var4_lua.o .eobjs/MacOSX/MacOSX/Run/Universal_System/zlib.o .eobjs/MacOSX/MacOSX/Run/Universal_System/Extensions/Alarms/alarmcode.o .eobjs/MacOSX/MacOSX/Run/Universal_System/Extensions/Timelines/timelines.o .eobjs/MacOSX/MacOSX/Run/Universal_System/Extensions/Paths/path_functions.o .eobjs/MacOSX/MacOSX/Run/Universal_System/Extensions/Paths/pathinit.o .eobjs/MacOSX/MacOSX/Run/Universal_System/Extensions/Paths/pathstruct.o .eobjs/MacOSX/MacOSX/Run/Universal_System/Extensions/MotionPlanning/motion_planning.o .eobjs/MacOSX/MacOSX/Run/Universal_System/Extensions/MotionPlanning/motion_planning_struct.o .eobjs/MacOSX/MacOSX/Run/Universal_System/Extensions/MotionPlanning/mp_movement.o .eobjs/MacOSX/MacOSX/Run/Universal_System/Extensions/DateTime/date_time.o .eobjs/MacOSX/MacOSX/Run/Universal_System/Extensions/ParticleSystems/PS_actions.o .eobjs/MacOSX/MacOSX/Run/Universal_System/Extensions/ParticleSystems/PS_effects.o .eobjs/MacOSX/MacOSX/Run/Universal_System/Extensions/ParticleSystems/PS_particle_attractor.o .eobjs/MacOSX/MacOSX/Run/Universal_System/Extensions/ParticleSystems/PS_particle_changer.o .eobjs/MacOSX/MacOSX/Run/Universal_System/Extensions/ParticleSystems/PS_particle_deflector.o .eobjs/MacOSX/MacOSX/Run/Universal_System/Extensions/ParticleSystems/PS_particle_depths.o .eobjs/MacOSX/MacOSX/Run/Universal_System/Extensions/ParticleSystems/PS_particle_destroyer.o .eobjs/MacOSX/MacOSX/Run/Universal_System/Extensions/ParticleSystems/PS_particle_emitter.o .eobjs/MacOSX/MacOSX/Run/Universal_System/Extensions/ParticleSystems/PS_particle_particles_apiimpl.o .eobjs/MacOSX/MacOSX/Run/Universal_System/Extensions/ParticleSystems/PS_particle_sprites.o .eobjs/MacOSX/MacOSX/Run/Universal_System/Extensions/ParticleSystems/PS_particle_system.o .eobjs/MacOSX/MacOSX/Run/Universal_System/Extensions/ParticleSystems/PS_particle_system_apiimpl.o .eobjs/MacOSX/MacOSX/Run/Universal_System/Extensions/ParticleSystems/PS_particle_system_manager.o .eobjs/MacOSX/MacOSX/Run/Universal_System/Extensions/ParticleSystems/PS_particle_type.o .eobjs/MacOSX/MacOSX/Run/Universal_System/Extensions/ParticleSystems/PS_particle_updatedraw.o .eobjs/MacOSX/MacOSX/Run/Universal_System/Extensions/DataStructures/data_structures.o  -lz -framework Cocoa -framework OpenGL -framework SFML -framework sfml-audio -framework sfml-system -framework OpenAL -framework sndfile -lz
Undefined symbols for architecture x86_64:
  "sf::SoundBuffer::loadFromFile(std::string const&)", referenced from:
      enigma_user::sound_add(std::string, int, bool) in SFMLbasic.o
      enigma_user::sound_replace(int, std::string, int, bool) in SFMLbasic.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[1]: *** [compile_game] Error 1
make: *** [Game] Error 2

/** Copyright (C) 2013 cheeseboy the great, Robert B. Colton
*** Copyright (C) 2013 Josh Ventura <JoshV@zoominternet.net>
***
*** This file is a part of the ENIGMA Development Environment.
***
*** ENIGMA is free software: you can redistribute it and/or modify it under the
*** terms of the GNU General Public License as published by the Free Software
*** Foundation, version 3 of the license or any later version.
***
*** This application and its source code is distributed AS-IS, WITHOUT ANY
*** WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
*** FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
*** details.
***
*** You should have received a copy of the GNU General Public License along
*** with this code. If not, see <http://www.gnu.org/licenses/>
**/


#ifdef _WIN32
#define AL_LIBTYPE_STATIC
#define SFML_STATIC
#endif

#include <SFML/Audio.hpp>
#include <vector>
#include "../General/ASbasic.h"

#include <cstdlib>
#include <cstdio>

struct normalizer {
  unsigned char lowbyte, highbyte;
  void normalize() {
    if (highbyte > 255) highbyte = 1, lowbyte = 1;
  }
};

class CustomSoundStream: public sf::SoundStream {
  void *userdata;
  void *buffer;
  const size_t buffer_size;
 
  size_t (*ongetdata)(void *userdata, void *buffer, size_t size);
  void (*onseek)(void *userdata, float position);
  void (*oncleanup)(void *userdata);
 
  public:
 
  CustomSoundStream(size_t (*callback)(void *userdata, void *buffer, size_t size),
    void (*seek)(void *userdata, float position), void (*cleanup)(void *userdata), void* userdata):
      userdata(userdata), buffer(new char[BUFSIZ]), buffer_size(BUFSIZ),
      ongetdata(callback), onseek(seek), oncleanup(cleanup) { initialize(2, 44100); }

  ~CustomSoundStream() {
    oncleanup(userdata);
  }
 
  private:

  void clipBuffer() {
    for (size_t i = 0; i < BUFSIZ / sizeof(normalizer); ++i)
      ((normalizer*)buffer)[i].normalize();
  }

  bool onGetData(Chunk& data) {
    data.samples = (short*) buffer;
    data.sampleCount = ongetdata(userdata, buffer, buffer_size)/sizeof(short);
    //clipBuffer();
    return true;
  }
 
  void onSeek(sf::Time timeOffset) {
    onseek(userdata, timeOffset.asSeconds());
  }
};

struct PlayableSound {
    virtual ~PlayableSound() {

    }
        virtual bool play() = 0;
        virtual bool pause() = 0;
    virtual void stop() = 0;
        virtual sf::SoundSource::Status getStatus() = 0;
        virtual sf::Time getPlayingOffset() = 0;
        virtual sf::Time getDuration() = 0;
        virtual unsigned int getSampleRate() = 0;
        virtual unsigned int getChannelCount() = 0;
        virtual float getVolume() = 0;
        virtual float getPitch() = 0;
        virtual float getMinDistance() = 0;
        virtual float getAttenuation() = 0;
        virtual sf::Vector3f getPosition() = 0;
        virtual float getX() = 0;
        virtual float getY() = 0;
        virtual float getZ() = 0;
        virtual bool setLoop(bool loop) = 0;
    virtual void setVolume(float volume) = 0;
        virtual void setPlayingOffset(sf::Time offset) = 0;
        virtual void setPosition(float x, float y, float z) = 0;
        virtual void setPitch(float pitch) = 0;
        virtual void setMinDistance(float distance) = 0;
        virtual void setAttenuation(float attenuation) = 0;
};

struct PlayableSoundInstance : public PlayableSound {
        sf::Sound *sound;
        sf::SoundBuffer *buffer;

        PlayableSoundInstance(sf::Sound *s, sf::SoundBuffer *b): sound(s), buffer(b) {};
       
        ~PlayableSoundInstance() {
          delete sound;
          delete buffer;
        }

        bool play() {
          sound->play();
        }

        bool pause() {
          sound->pause();
        }

        void stop() {
          sound->stop();
        }

        sf::SoundSource::Status getStatus() {
          return sound->getStatus();
        }

        sf::Time getPlayingOffset() {
          return sound->getPlayingOffset();
        }

        sf::Time getDuration() {
          return buffer->getDuration();
        }

        unsigned int getSampleRate() {
          return buffer->getSampleRate();
        }

        unsigned int getChannelCount() {
          return buffer->getChannelCount();
        }

        float getVolume() {
          return sound->getVolume();
        }

        float getPitch() {
          return sound->getPitch();
        }

        float getMinDistance() {
          return sound->getMinDistance();
        }

        float getAttenuation() {
          return sound->getAttenuation();
        }

        sf::Vector3f getPosition() {
          return sound->getPosition();
        }

        float getX() {
          return sound->getPosition().x;
        }

        float getY() {
          return sound->getPosition().y;
        }

        float getZ() {
          return sound->getPosition().z;
        }

        bool setLoop(bool loop) {
          sound->setLoop(loop);
        }

        void setVolume(float volume) {
          sound->setVolume(volume);
        }

        void setPlayingOffset(sf::Time offset) {
          sound->setPlayingOffset(offset);
        }

        void setPosition(float x, float y, float z) {
          sound->setPosition(x, y, z);
        }

        void setPitch(float pitch) {
          sound->setPitch(pitch);
        }

        void setMinDistance(float distance) {
          sound->setMinDistance(distance);
        }

        void setAttenuation(float attenuation) {
          sound->setAttenuation(attenuation);
        }
};

struct PlayableSoundStream : public PlayableSound {
        sf::SoundStream *stream;

        PlayableSoundStream(sf::SoundStream *s): stream(s) {};

        ~PlayableSoundStream() {
          delete stream;
        }

        bool play() {
          stream->play();
        }

        bool pause() {
          stream->pause();
        }

        void stop() {
          stream->stop();
        }

        sf::SoundSource::Status getStatus() {
          return stream->getStatus();
        }

        sf::Time getPlayingOffset() {
          return stream->getPlayingOffset();
        }

        sf::Time getDuration() {
          // sfml soundstreams do not have a way of getting their duration
          //return stream->getDuration();
        }

        unsigned int getSampleRate() {
          return stream->getSampleRate();
        }

        unsigned int getChannelCount() {
          return stream->getChannelCount();
        }

        float getVolume() {
          return stream->getVolume();
        }

        float getPitch() {
          return stream->getPitch();
        }

        float getMinDistance() {
          return stream->getMinDistance();
        }

        float getAttenuation() {
          return stream->getAttenuation();
        }

        sf::Vector3f getPosition() {
          return stream->getPosition();
        }

        float getX() {
          return stream->getPosition().x;
        }

        float getY() {
          return stream->getPosition().y;
        }

        float getZ() {
          return stream->getPosition().z;
        }

        bool setLoop(bool loop) {
          stream->setLoop(loop);
        }

        void setVolume(float volume) {
          stream->setVolume(volume);
        }

        void setPlayingOffset(sf::Time offset) {
          stream->setPlayingOffset(offset);
        }

        void setPosition(float x, float y, float z) {
          stream->setPosition(x, y, z);
        }

        void setPitch(float pitch) {
          stream->setPitch(pitch);
        }

        void setMinDistance(float distance) {
          stream->setMinDistance(distance);
        }

        void setAttenuation(float attenuation) {
          stream->setAttenuation(attenuation);
        }
};

std::vector<PlayableSound*> sounds;

namespace enigma
{
  int audiosystem_initialize() {
    //TODO: Initialize audio system
    return 0;
  }

  void audiosystem_update() {
    //TODO: Perform audio fall off and emitter updating
  }

  int sound_add_from_buffer(int id, void* buffer, size_t size) {
    int i = (int)sounds.size();
    sf::SoundBuffer *buf = new sf::SoundBuffer();
    sf::Sound *snd;

    buf->loadFromMemory(buffer, size);
               
    snd = new sf::Sound();
    snd->setBuffer(*buf);
    sounds.push_back(new PlayableSoundInstance(snd, buf));
    return i;
  }

  void audiosystem_cleanup() {
    //TODO: Cleanup and delete/free sounds/existing buffers from memory
  }

  int sound_allocate() {
    int i = sounds.size();
    sounds.push_back(NULL);
    return i;
  }

  int sound_add_from_stream(int id, size_t (*callback)(void *userdata, void *buffer, size_t size), void (*seek)(void *userdata, float position), void (*cleanup)(void *userdata), void *userdata)
  {
      CustomSoundStream *snd;

      snd = new CustomSoundStream(callback, seek, cleanup, userdata);
      sounds[id] = new PlayableSoundStream(snd);       
      return 0;
  }

}

namespace enigma_user {

int sound_add(std::string fname, int kind, bool preload)
{
  int i = (int)sounds.size();
  sf::SoundBuffer *buffer = new sf::SoundBuffer();
  sf::Sound *snd;
               
  if (!buffer->loadFromFile(fname))
  {
    delete buffer;
    return -1;
  }
  else
  {
    snd = new sf::Sound();
    snd->setBuffer(*buffer);
    sounds.push_back(new PlayableSoundInstance(snd, buffer));
    return i;
  }
}

bool sound_exists(int sound)
{
        return unsigned(sound) < sounds.size();
}

void sound_delete(int sound)
{
        delete sounds[sound];
}

bool sound_replace(int sound, std::string fname, int kind, bool preload)
{
  sf::SoundBuffer *buffer = new sf::SoundBuffer();
  sf::Sound *snd;

  if (!buffer->loadFromFile(fname))
  {
    delete buffer;
    return -1;
  }
  else
  {
    delete sounds[sound];
    snd = new sf::Sound();
    snd->setBuffer(*buffer);
    sounds.push_back(new PlayableSoundInstance(snd, buffer));
    return true;
  }
}

bool sound_play(int sound)
{
        sounds[sound]->play();
        return sounds[sound]->getStatus() == sf::Sound::Playing;
}

void action_sound(int snd, bool loop)
{
        (loop ? sound_loop:sound_play)(snd);
}

bool sound_loop(int sound)
{
        sounds[sound]->setLoop(true);
        sounds[sound]->play();
        return sounds[sound]->getStatus() == sf::Sound::Playing;
}

void sound_stop(int sound)
{
        sounds[sound]->setLoop(false);
        sounds[sound]->stop();
}

void sound_stop_all()
{
        for(unsigned i=0; i < sounds.size(); i++)
        {
          sounds[i]->stop();
        }
}

bool sound_pause(int sound)
{
        sounds[sound]->pause();
        return sounds[sound]->getStatus() == sf::Sound::Paused;
}

void sound_pause_all()
{
        for(unsigned i=0; i < sounds.size(); i++)
        {
          sounds[i]->pause();
        }
}
void sound_resume_all()
{
        for(unsigned i=0; i < sounds.size(); i++)
        {
          if (sounds[i]->getStatus() == sf::Sound::Paused)
                sounds[i]->play();
        }
}

void sound_global_volume(float volume)
{
        sf::Listener::setGlobalVolume(volume);
}

void sound_set_volume(int sound, float volume)
{
        sounds[sound]->setVolume(volume);
}

void sound_seek(int sound, float position)
{
        sounds[sound]->setPlayingOffset(sf::seconds(position));
}

void sound_seek_all(float position)
{
        for(unsigned i=0; i < sounds.size(); i++)
        {
          sounds[i]->setPlayingOffset(sf::seconds(position));
        }
}

void sound_set_pitch(int sound, float pitch)
{
        sounds[sound]->setPitch(pitch);
}

void sound_3d_set_sound_position(int sound, float x, float y, float z)
{
        sounds[sound]->setPosition(x, y, z);
}

void sound_3d_set_sound_distance(int sound, float mindist, float maxdist)
{
        sounds[sound]->setMinDistance(mindist);
        sounds[sound]->setAttenuation(1/(maxdist-mindist));
}

bool sound_isplaying(int sound)
{
        return sounds[sound]->getStatus() == sf::Sound::Playing;
}

bool sound_ispaused(int sound)
{
        return sounds[sound]->getStatus() == sf::Sound::Paused;
}

float sound_get_position(int sound)
{
        return sounds[sound]->getPlayingOffset().asSeconds();
}

float sound_get_length(int sound)
{
        return sounds[sound]->getDuration().asSeconds();
}

unsigned int sound_get_samplerate(int sound)
{
        return sounds[sound]->getSampleRate();
}

unsigned int sound_get_channels(int sound)
{
        return sounds[sound]->getChannelCount();
}

int sound_get_x(int sound)
{
        return sounds[sound]->getX();
}
int sound_get_y(int sound)
{
        return sounds[sound]->getY();
}
int sound_get_z(int sound)
{
        return sounds[sound]->getZ();
}

float sound_get_volume(int sound)
{
        return sounds[sound]->getVolume();
}

float sound_get_pitch(int sound)
{
        return sounds[sound]->getPitch();
}

}
 

Why the errors?

10
General / Custom Makefile...
« on: May 13, 2013, 07:21:47 am »
Because I want to statically link openal and everything else and also i'm not a fan of cmake...
I have written a custom makefile:
CXX := i686-w64-mingw32-g++
CFLAGS := -DAL_LIBTYPE_STATIC -DSFML_STATIC -I./include -I./
LDFLAGS := -lOpenAL32 -lsndfile -ldsound -lwinmm -lole32

WIN32_SOURCES := $(wildcard SFML/System/Win32/*.cpp)
WIN32_OBJECTS := $(patsubst %.cpp,%.o,$(WIN32_SOURCES))

SYSTEM_SOURCES := $(wildcard SFML/System/*.cpp)
SYSTEM_OBJECTS := $(patsubst %.cpp,%.o,$(SYSTEM_SOURCES))

AUDIO_SOURCES := $(wildcard SFML/Audio/*.cpp)
AUDIO_OBJECTS := $(patsubst %.cpp,%.o,$(AUDIO_SOURCES))

all: main win32 system audio
        ${CXX} -shared ${WIN32_OBJECTS} ${SYSTEM_OBJECTS} -o libsfml-system-s.a
        ${CXX} -shared -L./ ${AUDIO_OBJECTS} -o libsfml-audio-s.a -lsfml-system-s ${LDFLAGS}

main: SFML/Main/SFML_Main.cpp SFML/Main/SFML_Main.o

win32: ${WIN32_OBJECTS}

system: ${SYSTEM_OBJECTS}

audio: ${AUDIO_OBJECTS}

%.o: %.cpp
        ${CXX} ${CFLAGS} -c $< -o $@
       
clean:
        find . -name "*.o" -exec rm {} \;
        find . -name "*.a" -exec rm {} \;
 

No errors on output:
greg@greg-laptop ~/enigma-dev/ENIGMAsystem/Additional/Windows/sfml $ make
i686-w64-mingw32-g++ -DAL_LIBTYPE_STATIC -DSFML_STATIC -I./include -I./ -c SFML/Main/SFML_Main.cpp -o SFML/Main/SFML_Main.o
i686-w64-mingw32-g++ -DAL_LIBTYPE_STATIC -DSFML_STATIC -I./include -I./ -c SFML/System/Win32/ClockImpl.cpp -o SFML/System/Win32/ClockImpl.o
i686-w64-mingw32-g++ -DAL_LIBTYPE_STATIC -DSFML_STATIC -I./include -I./ -c SFML/System/Win32/ThreadImpl.cpp -o SFML/System/Win32/ThreadImpl.o
i686-w64-mingw32-g++ -DAL_LIBTYPE_STATIC -DSFML_STATIC -I./include -I./ -c SFML/System/Win32/SleepImpl.cpp -o SFML/System/Win32/SleepImpl.o
i686-w64-mingw32-g++ -DAL_LIBTYPE_STATIC -DSFML_STATIC -I./include -I./ -c SFML/System/Win32/ThreadLocalImpl.cpp -o SFML/System/Win32/ThreadLocalImpl.o
i686-w64-mingw32-g++ -DAL_LIBTYPE_STATIC -DSFML_STATIC -I./include -I./ -c SFML/System/Win32/MutexImpl.cpp -o SFML/System/Win32/MutexImpl.o
i686-w64-mingw32-g++ -DAL_LIBTYPE_STATIC -DSFML_STATIC -I./include -I./ -c SFML/System/Thread.cpp -o SFML/System/Thread.o
i686-w64-mingw32-g++ -DAL_LIBTYPE_STATIC -DSFML_STATIC -I./include -I./ -c SFML/System/Clock.cpp -o SFML/System/Clock.o
i686-w64-mingw32-g++ -DAL_LIBTYPE_STATIC -DSFML_STATIC -I./include -I./ -c SFML/System/Time.cpp -o SFML/System/Time.o
i686-w64-mingw32-g++ -DAL_LIBTYPE_STATIC -DSFML_STATIC -I./include -I./ -c SFML/System/Sleep.cpp -o SFML/System/Sleep.o
i686-w64-mingw32-g++ -DAL_LIBTYPE_STATIC -DSFML_STATIC -I./include -I./ -c SFML/System/String.cpp -o SFML/System/String.o
i686-w64-mingw32-g++ -DAL_LIBTYPE_STATIC -DSFML_STATIC -I./include -I./ -c SFML/System/Lock.cpp -o SFML/System/Lock.o
i686-w64-mingw32-g++ -DAL_LIBTYPE_STATIC -DSFML_STATIC -I./include -I./ -c SFML/System/ThreadLocal.cpp -o SFML/System/ThreadLocal.o
i686-w64-mingw32-g++ -DAL_LIBTYPE_STATIC -DSFML_STATIC -I./include -I./ -c SFML/System/Mutex.cpp -o SFML/System/Mutex.o
i686-w64-mingw32-g++ -DAL_LIBTYPE_STATIC -DSFML_STATIC -I./include -I./ -c SFML/System/Err.cpp -o SFML/System/Err.o
i686-w64-mingw32-g++ -DAL_LIBTYPE_STATIC -DSFML_STATIC -I./include -I./ -c SFML/Audio/Listener.cpp -o SFML/Audio/Listener.o
i686-w64-mingw32-g++ -DAL_LIBTYPE_STATIC -DSFML_STATIC -I./include -I./ -c SFML/Audio/AudioDevice.cpp -o SFML/Audio/AudioDevice.o
i686-w64-mingw32-g++ -DAL_LIBTYPE_STATIC -DSFML_STATIC -I./include -I./ -c SFML/Audio/SoundBufferRecorder.cpp -o SFML/Audio/SoundBufferRecorder.o
i686-w64-mingw32-g++ -DAL_LIBTYPE_STATIC -DSFML_STATIC -I./include -I./ -c SFML/Audio/SoundFile.cpp -o SFML/Audio/SoundFile.o
i686-w64-mingw32-g++ -DAL_LIBTYPE_STATIC -DSFML_STATIC -I./include -I./ -c SFML/Audio/SoundRecorder.cpp -o SFML/Audio/SoundRecorder.o
i686-w64-mingw32-g++ -DAL_LIBTYPE_STATIC -DSFML_STATIC -I./include -I./ -c SFML/Audio/SoundBuffer.cpp -o SFML/Audio/SoundBuffer.o
i686-w64-mingw32-g++ -DAL_LIBTYPE_STATIC -DSFML_STATIC -I./include -I./ -c SFML/Audio/Music.cpp -o SFML/Audio/Music.o
i686-w64-mingw32-g++ -DAL_LIBTYPE_STATIC -DSFML_STATIC -I./include -I./ -c SFML/Audio/ALCheck.cpp -o SFML/Audio/ALCheck.o
i686-w64-mingw32-g++ -DAL_LIBTYPE_STATIC -DSFML_STATIC -I./include -I./ -c SFML/Audio/SoundSource.cpp -o SFML/Audio/SoundSource.o
i686-w64-mingw32-g++ -DAL_LIBTYPE_STATIC -DSFML_STATIC -I./include -I./ -c SFML/Audio/Sound.cpp -o SFML/Audio/Sound.o
i686-w64-mingw32-g++ -DAL_LIBTYPE_STATIC -DSFML_STATIC -I./include -I./ -c SFML/Audio/SoundStream.cpp -o SFML/Audio/SoundStream.o
i686-w64-mingw32-g++ -shared SFML/System/Win32/ClockImpl.o SFML/System/Win32/ThreadImpl.o SFML/System/Win32/SleepImpl.o SFML/System/Win32/ThreadLocalImpl.o SFML/System/Win32/MutexImpl.o SFML/System/Thread.o SFML/System/Clock.o SFML/System/Time.o SFML/System/Sleep.o SFML/System/String.o SFML/System/Lock.o SFML/System/ThreadLocal.o SFML/System/Mutex.o SFML/System/Err.o -o libsfml-system-s.a
i686-w64-mingw32-g++ -shared -L./ SFML/Audio/Listener.o SFML/Audio/AudioDevice.o SFML/Audio/SoundBufferRecorder.o SFML/Audio/SoundFile.o SFML/Audio/SoundRecorder.o SFML/Audio/SoundBuffer.o SFML/Audio/Music.o SFML/Audio/ALCheck.o SFML/Audio/SoundSource.o SFML/Audio/Sound.o SFML/Audio/SoundStream.o -o libsfml-audio-s.a -lsfml-system-s -lOpenAL32 -lsndfile -ldsound -lwinmm -lole32

but when trying to link against it:
eobjs/Linux/Windows/Run/Universal_System/Extensions/MotionPlanning/mp_movement.o .eobjs/Linux/Windows/Run/Universal_System/Extensions/DateTime/date_time.o .eobjs/Linux/Windows/Run/Universal_System/Extensions/DataStructures/data_structures.o  -lffi -lcomdlg32 -lgdi32 -lwinmm -lopengl32 -lglu32 -lsfml-audio-s -lsfml-system-s -lz
.eobjs/Linux/Windows/Run/Audio_Systems/SFML/SFML_basic.o:SFML_basic.cpp:(.text+0x457): undefined reference to `sf::SoundBuffer::SoundBuffer()'

and etc.

Any idea where I messed up?

11
General / Cross Compiling linux->win32
« on: May 12, 2013, 04:51:01 am »
I'm trying to cross compile from linux to windows. Using dynamic libs work but static ones get linker errors:
http://paste2.org/2dpU0xs8
I've added -DSFML_STATIC as you can see so why the errors?

Pages: [1]
anything