|
|
| Using ALLEGRO Audio Routines In GLFW OpenGL Project |
|
GaryT
Member #14,875
January 2013
|
I'm well on the way to creating my first OpenGL game (not using ALLEGRO though), and I'm using GLFW for creating the display window and processing user input i.e. keyboard and joystick. However, I'm at the stage where I want to add sound, and I've looked extensively at many audio libraries. I like the idea that if one day I want to release a game on a commercial basis that all the library dependencies I'm linking with are Free! subject to certain licencing conditions, but still free though. So I'm left struggling to find a suitable cross-platform audio library. Among others I've discovered (but not tried) FMOD, BASS, irrKlang (the most appealing to me so far) but they're not free for commercial purposes. I'm aware of OpenAL-Soft too, but it seems I'd have to get into multi-threading which I'm not very familiar with, which leads me to my question below: Question: Can I use (link with) ALLEGRO's audio routines by including them in my OpenGL project which uses GLFW (as mentioned above) without GLFW and ALLEGRO conflicting. I've read for example that OpenAL-Soft needs to run in its own thread so it doesn't block/stop the rest of the game loop from running. I'm confident I'll be able to create my own realistic 3D spacial sound effects by manipulating volume and pitch based on object positions and directions by using ALLEGRO's routines, if I can use them in my project without conflicts. I appreciate I could give it a try, but even if it appears to work okay, I'd still rather hear what you guys have to say, so thanks in advance. Cheers, Gary. |
|
Edgar Reynaldo
Major Reynaldo
May 2007
|
You may want to look into using the addon libraries separately, such as the audio and acodec addons. I don't believe you have to create a display, but I've never tested headless allegro before. I don't think there's a way for you to pass the GLFW OpenGL context to Allegro to use for a window, or to use the HWND of your GLFW window as a window for allegro if you wanted to use drawing it would take some hacking on allegro. It's a change I've wanted for a long time, the API would be : WGLContextID al_get_opengl_context(); bool al_set_new_display_opengl_context(WGLContextID id); That's my 2¢ EDIT My Website! | EAGLE GUI Library Demos | My Deviant Art Gallery | Spiraloid Preview | A4 FontMaker | Skyline! (Missile Defense) Eagle and Allegro 5 binaries | Older Allegro 4 and 5 binaries | Allegro 5 compile guide |
|
Neil Roy
Member #2,229
April 2002
|
Why not just use Allegro? Honestly, for OpenGL, GLFW etc... isn't giving you anything Allegro cannot. You just need to create an OpenGL context with Allegro and use it, and you will have access to all of Allegro's functions which handle audio, video, graphics very nicely. I have followed tutorials that use GLFW, but beyond the initial display and OpenGL context, they have little else to do with your 3D programming, except the usual input and non-graphic stuff. You can actually follow those tutorials just fine using whatever library you prefer to be honest. All you need to do is find out how to create an opengl context, which I believe there are examples which come with Allegro that show you how to do that. Ripping the guts out of a library to use in your own project might work, sounds a little dicey and unnecessary to me. If you're going to take the effort to do all of that, why not just use that effort to learn to open the context with Allegro to start with? --- |
|
Edgar Reynaldo
Major Reynaldo
May 2007
|
GaryT said: I'm using GLFW for creating the display window and processing user input i.e. keyboard and joystick. That's really not much of a dependency. Allegro can do all that easily. What about drawing? Are you using pure OpenGL? My Website! | EAGLE GUI Library Demos | My Deviant Art Gallery | Spiraloid Preview | A4 FontMaker | Skyline! (Missile Defense) Eagle and Allegro 5 binaries | Older Allegro 4 and 5 binaries | Allegro 5 compile guide |
|
GaryT
Member #14,875
January 2013
|
Thank you both. Edgar: Yes I'm using pure OpenGL for the drawing, with some help of course which includes; Blender; .obj files; ASSIMP; Shaders. Neil: I didn't know about ALLEGRO's OpenGL functionality until last night. They're both excellent responses which relate directly to my opening post very well, so again thank you very much. Edgar Reynaldo said: You may want to look into using the addon libraries separately, such as the audio and acodec addons. I don't believe you have to create a display, but I've never tested headless allegro before. That sounds like exactly what I'm looking for. I haven't used ALLEGRO for several years, but I'm wondering if even only! initializing! ALLEGRO might conflict with GLFW's handling of the display window, because perhaps even at that stage ALLEGRO might be executing code under-the-hood i.e. various display routines, even without later calling actual display functions later in the code. I'm definitely not looking to pass the GLFW OpenGL context to ALLEGRO, but I will be considering Neil's suggestion of just using ALLEGRO for everything. Neil Roy said: Ripping the guts out of a library to use in your own project might work, sounds a little dicey and unnecessary to me. Ripping the guts out isn't what I'm looking to do which sounds complicated anyway, so if using ALLEGRO's audio capabilities independently from the rest of ALLEGRO's functionality means that's what's required, then it isn't the solution for me. Two options then at least from what's been said so far: 1) Ditch GLFW and use only ALLEGRO. 2) Look into using the ALLEGRO audio and acodec addon libraries separately. I'm still very curious about option 2 at this stage, so any further knowledge and understanding about this possibility would be great. Once again thank you both. EDIT: So I've looked here: https://www.allegro.cc/forums/thread/617205/0 I wonder if "Arvidsson" ever fixed his glad issue. As long as I can still use OpenGL via ALLEGRO as freely! in every respect (i.e. select the version and be able to use all functionality) as with GLFW for example, then option 1 might be my best option. |
|
Edgar Reynaldo
Major Reynaldo
May 2007
|
It would not take a small test long to determine if you could play audio with allegro alongside glfw. And most assuredly yes, you can do anything you want with OpenGL alongside Allegro. A5's fully supports all OpenGL, and gives you many things to help you including shader support. The only thing to keep in mind is to know that allegro functions change opengl state, and changing opengl state means you have to reset things for allegro to render properly. My Website! | EAGLE GUI Library Demos | My Deviant Art Gallery | Spiraloid Preview | A4 FontMaker | Skyline! (Missile Defense) Eagle and Allegro 5 binaries | Older Allegro 4 and 5 binaries | Allegro 5 compile guide |
|
GaryT
Member #14,875
January 2013
|
I already have pretty much the complete 3D modelling and OpenGL side of things complete with all shader functionality working great, so I'm really only looking for the most practical solution for adding sound. |
|
|