Allegro 5.0.0rc1 released!
Peter Wang

http://sourceforge.net/projects/alleg/files/allegro-prerelease/5.0.0-rc1/

Quote:

Changes from 4.9.22 to 5.0.0 RC1 (November 2010)
================================================

The developers this time were: Trent Gamblin, Evert Glebbeek, Elias Pschernig,
Paul Suntsov, Peter Wang.

Graphics:

- Make al_resize_display keep the original resolution (or change back) if it
can't set the users request, on Windows.

- Do not emit ALLEGRO_DISPLAY_RESIZE events from the Windows and X11 display
drivers when using al_resize_display.

- [X11] Make al_get_num_display_modes and al_get_display_mode work if the
adapter is set to default. Right now there was no way to query the modes of
the default monitor.

- [X11] Use _NET_WM_STATE_FULLSCREEN hint for "true" fullscreen displays.
Enable mouse grabbing in fullscreen modes.

- Added ALLEGRO_EVENT_DISPLAY_ORIENTATION and implement it on iOS.

- Dennis Busch fixed a problem with displays not showing up on the
primary display by default in some dual head setups, on Windows.

- Increase the precision of texture coordinate deltas in the software triangle
renderer, from floats to doubles.

- Remove al_get_frontbuffer(). It wasn't implemented anywhere.

- Implement min/mag filter and mipmap flags for Direct3D.

Input:

- Report correct initial mouse position if a display is created with the mouse
pointer inside, or if the mouse routines are installed after a display is
created (X11, Windows).

- John Murphy fixed improperly mapped axes on the Windows joystick driver.

Events:

- Do not register user event sources with the destructor system as it cannot
work reliably. User event sources must be destroyed manually.

Filesystem:

- Make al_get_fs_entry_name and al_get_current_directory return strings
instead of ALLEGRO_PATH.

- Make al_make_directory create parent directories as needed.

- Fix al_create_fs_entry to not trim the root path "/" down to the empty
string with the stdio backend.

Path routines:

- Remove al_make_path_absolute and replace it by al_rebase_path.

- Remove undocumented behavior of setting a default organization name of
"allegro" for all apps.

- Correctly return standard paths as directories on OS X.

Threads:

- Rename al_wait_cond_timed to al_wait_cond_until to match al_wait_cond_until.

Config routines:

- Add a blank line between sections when writing out a config file.

Other core:

- Move the Windows event loops back into the same thread as the D3D event
loop. It's a requirement of D3D, else you can get crashes as I was when
resetting the device (like tabbing away from a fullscreen app).

- Add some missing standard entries to the OS X menu bar (the "hide", "hide
others" and the window list, mainly).

Audio addon:

- Automatically stop sample instances which point to a buffer of a sample
which is about to be destroyed with al_destroy_sample.

- alsa: Resume properly after suspending.

Image I/O addon:

- Make GDI+ support compile cleanly with the headers that come with MinGW
package w32api-3.15.

- Speed up PNG and BMP saving, and NSImageFromAllegroBitmap loading.

TTF addon:

- Add a flag for loading TTFs without anti-aliasing (ALLEGRO_TTF_MONOCHROME).

PhysicsFS addon:

- Make PhysFS implementation of al_get_current_directory return "/", not NULL.

Primitives addon:

- Fix several failed sub-bitmap related unit tests on Windows.

- Made thick outlined triangles look nicer when the triangles are very thin.

- Add a debug-only check for primitives addon initialization to aid in code
portability.

Examples:

- Added example demonstrating the effect of premultiplied alpha.

- Make 'F' toggle fullscreen window in SPEED (in-game).

- Minor improvements to the a5teroids demo.

Documentation:

- Many documentation updates.

- Add list of contributors and a readme for packagers.

- Make make_doc tool build cleanly on MSVC, and work around a problem with
recent version of Pandoc on Windows.

- Improve styling of PDF output.

- Add generated man pages to archives.

Bindings:

- Implemented array types in the Python wrapper.

Japa Illo

thank you!

will give it a go.

furinkan
Quote:

Furinkan increased to level 5.0.0rc1!

Furinkan is trying to learn A5,
but Furinkan can only learn 4 gfx apis!

Forget an older gfx api to learn A5?
>yes no

Which one?
Alleg4 GL
>DX3D GX

Furinkan forgot DX3D and...

Furinkan learned A5!

;D

Karadoc ~~

milestone.

Thomas Fjellstrom

Achievement Gained: Allegro 5.0rc1!

video

Mark Oates

We should all drink a beer in celebration.

Quote:

Report correct initial mouse position if a display is created with the mouse
pointer inside, or if the mouse routines are installed after a display is
created

nice. 8-)

furinkan

I should get on Mr. Harbour's forums and pester him to update his book!

Allegro needs more public exposure.

@Thomas:
Nice choice on the foamy!

Elias

We should all drink a beer in celebration.

I'll save that for when the final 5.0.0 is out, RC1, RC2, RC3, ... is just a different way of naming versions :P

Trezker

Well, RC should at least mean no more API changes right?
I don't mind if you add functions, but if you change existing functions from now on it's just not right...

Adding functions after disallowing changes would be rather risky though.
So I recommend sticking to bug fixes.

Thomas Fjellstrom
Trezker said:

Well, RC should at least mean no more API changes right?
I don't mind if you add functions, but if you change existing functions from now on it's just not right...

This means 5.0 won't have any removals, or renames or arg changes.

5.0 is frozen now, fixes only till 5.0.0 is released.

5.1 however is open, and additions can be made there. I'm not sure if we guarantee strict source compatibility between 5.x releases, but I think we might? In that case, only additions can be made between 5.x releases.

tobing

Alas, I hoped that ALLEGRO_VERSION would be 5 now. When will that be changed?

Thomas Fjellstrom
tobing said:

Alas, I hoped that ALLEGRO_VERSION would be 5 now. When will that be changed?

It is as far as I know. Versions in 5.0 and 5.1 branches have been properly changed. Even 4.9 should show 5.0.

Append: It is in the zip on sourceforge as well.

tobing

Ha, seems that I was too quick. NOW 4.9 is 5.0, and I didn't realize that I have to get the 5.0 branch from SVN.

Thomas Fjellstrom
tobing said:

Ha, seems that I was too quick. NOW 4.9 is 5.0, and I didn't realize that I have to get the 5.0 branch from SVN.

It should be 5.0 in the old 4.9 branch as well. Thats where peter changed it first, then tagged RC1, and branched 5.0 off of.

tobing

Now got it all right.

There's one thing I would like to make in a different way, but I'm not sure how to do it cleanly...

I'd like to build the core allegro library as DLL, but all addons as static libs, in fact I'd like to include the required sources into one bigger static library.

Dario ff

Seems Allegro 5 might be released before DNF after all. 8-)

(Febreaury/March 2011)

Elias
tobing said:

I'd like to build the core allegro library as DLL, but all addons as static libs, in fact I'd like to include the required sources into one bigger static library.

Why would you want that? If you link the addons static, you may as well link that main dll static, as the addons depend on it. Or do you mean you want something like the allegro-monolith.dll, i.e. just one big DLL which has allegro and all addons and their dependencies?

tobing

Well, doing everything static would be one solution, yes. With allegro4 I had allegro DLL, lpng and zlib DLLs, and almost everything else packed into one static lib. There are two game projects sitting on this, so they both took from the static lib only what they need and import the DLL stuff they use. This gives only few DLLs, but has allegro (and lpng and zlib) as shared library...

So, this is perhaps mostly a matter of taste here. One of the nice aspects of using DLLs is that global variables are lock in there... which is not the case for static libraries.

Definitely not a mega DLL including everything.

Hmmm... maybe I should take this as opportunity to switch to all static libraries after all.

kenmasters1976

Nice. Downloading.

tobing

I'm wondering... where have pack files gone? Am I supposed to use zip files instead?

What about the nice config file routines, it seems that I have to re-implement things using the new functionality?

Why are useful functions like get_extension not there any longer?

I'm really missing a lot of convenient functions, which looks like I have to re-implement things that have been present in allegro 4.4.

SiegeLord
tobing said:

I'm wondering... where have pack files gone? Am I supposed to use zip files instead?

Yep. With the PhysFS addon.

Quote:

What about the nice config file routines, it seems that I have to re-implement things using the new functionality?

Is this not good enough for you?

Quote:

Why are useful functions like get_extension not there any longer?

al_get_path_extension

tobing

Zip files are OK, but I liked pack files a lot, too.

Quote:

Is this [alleg.sourceforge.net] not good enough for you?

Well, that is pretty suggestive. It's not good enough, in some way, yes. I can implement what I'm using with those functions, but I have to implement all parsing, handling of default values and more than one config file at a time all by myself, whereas allegro 4's functions did a lot of that work for me. That's why I'm asking.

Quote:

al_get_path_extension [alleg.sourceforge.net]

Sorry, I missed that one. Ürobably because I didn't think of doing it that way - I have a file name and want to get the extension, or cut the extension off to show only the file name in a list. Now, I have to create an ALLEGRO_PATH object, find the basename and destroy the object after that. To me that seems overly complicated.

Please don't understand me wrong here. I don't mean to criticize everything, mainly I want to know why certain things have been dropped or are done in less convenient ways than before. On the other hand I appreciate the nifty new things, like threads and all the hardware acceleration stuff.

Evert
tobing said:

I can implement what I'm using with those functions, but I have to implement all parsing, handling of default values and more than one config file at a time all by myself, whereas allegro 4's functions did a lot of that work for me. That's why I'm asking.

I find it's actually easier to use multiple config files with A5 than it is with A4, but that's probably just a matter of taste.
It's true that you don't get default values, but it's very easy to emulate Allegro 4's config routines on top of Allegro 5 functions if you really want that feature - and in fact, I've done that for a project I'm porting from Allegro 4 to Allegro 5 (have a look at the demos/speed/a4_aux.c file for the basic idea).

Quote:

I have a file name and want to get the extension, or cut the extension off to show only the file name in a list. Now, I have to create an ALLEGRO_PATH object, find the basename and destroy the object after that. To me that seems overly complicated.

I think the reason it's done this way is to accomodate different encodings in the filesystem and in the Allegro strings (which are always UTF-8), but I didn't follow that discussion in a great amount of detail (basically because I didn't personally care about the issues that were raised).

SiegeLord
tobing said:

Well, that is pretty suggestive. It's not good enough, in some way, yes. I can implement what I'm using with those functions, but I have to implement all parsing, handling of default values and more than one config file at a time all by myself, whereas allegro 4's functions did a lot of that work for me. That's why I'm asking.

Yes. The new way is more powerful (marginally) but less convenient, no argument there.

Quote:

Sorry, I missed that one. Ürobably because I didn't think of doing it that way - I have a file name and want to get the extension, or cut the extension off to show only the file name in a list. Now, I have to create an ALLEGRO_PATH object, find the basename and destroy the object after that. To me that seems overly complicated.

How would you get that filename in the first place? The native file dialog addon returns ALLEGRO_PATH for example. The filesystem functions don't... but I think that's a problem of those functions, not of the ALLEGRO_PATH concept.

Thomas Fjellstrom

Not to mention that when you're messing with path's in A5 you really want to be using an ALLEGRO_PATH rather than a char* or a std::string. ALLEGRO_PATH is much handier, and you don't have to worry about unicode.

tobing
Evert said:

have a look at the demos/speed/a4_aux.c file for the basic idea

Yes, I have seen that.

Quote:

I think the reason it's done this way is to accomodate different encodings in the filesystem and in the Allegro strings (which are always UTF-8)

Ah, right, files are UTF8 on modern systems, so things tend to be more complicated. Sigh.

SiegeLord said:

How would you get that filename in the first place? The native file dialog addon returns ALLEGRO_PATH for example. The filesystem functions don't... but I think that's a problem of those functions, not of the ALLEGRO_PATH concept.

Well, good point. I think I get the file name from a function which traverses a directory and calls a callback function for each file name that matches a simple pattern, like "*.lua". Inside I have a ALLEGRO_FS_ENTRY from which I get the path name...

After all, it might be necessary to change more code than I anticipated. There's a lot of small things that pile up.

Thomas Fjellstrom
tobing said:

Inside I have a ALLEGRO_FS_ENTRY from which I get the path name...

I really would have liked there to be functions to get an ALLEGRO_PATH from an ALLEGRO_FS_ENTRY as well as from al_read_directory. Would have made everything nice, but It never got done.

Evert
tobing said:

Ah, right, files are UTF8 on modern systems, so things tend to be more complicated.

If only. In that case things would be easier.
As I recall, it's UTF8 on OS X (or at least the interface lets you pretend its all UTF8), but it's UTF16 (?) on Windows, and whatever you want on Linux.

Quote:

After all, it might be necessary to change more code than I anticipated. There's a lot of small things that pile up.

Yes.
I've kept notes of my porting effort for my game, which I'll clean up and post here at some point (sooner rather than later, I hope).

I really would have liked there to be functions to get an ALLEGRO_PATH from an ALLEGRO_FS_ENTRY as well as from al_read_directory. Would have made everything nice, but It never got done.

No reason we couldn't add those in 5.1, right?

Thomas Fjellstrom
Evert said:

As I recall, it's UTF8 on OS X (or at least the interface lets you pretend its all UTF8), but it's UTF16 (?) on Windows, and whatever you want on Linux.

Most times on linux its some ASCII code page, or UTF-8. More modern systems will choose UTF-8.

And since Allegro 5 has gone for "All UTF-8 all the time", it accepts ONLY valid UTF-8 for its own strings, and will convert to UCS-2 or UTF-16 on windows.

Quote:

No reason we couldn't add those in 5.1, right?

I would've LOVEed it if the versions that handle char* were never added to begin with. But that may have made more people un-happy. But yeah, they can probably be added in 5.1.

wonsungi

Great job you guys! Even the readme_msvc.txt build procedure is manageable. I would just add:

  • When converting an MSVC 9 project to MSVC 10 (to work around the CMake naming bug) several compiler errors will result related to int64_t. To fix this, uncomment the line: #define ALLEGRO_HAVE_STDINT_H in alplatf.h.

  • Another option is to alter the CMake file so the Allegro DLL's don't have dots in their names. In the common.cmake file change: `SUFFIX -${ALLEGRO_SOVERSION}.dll` -> `SUFFIX -${ALLEGRO_DLL_SHORTVER}.dll`. Now CMAKE will generate valid MSVC 10 project files. Note this is not a good option if you want your Allegro programs to dynamically link to the Allegro library files built and shared by everyone else.

  • Running the examples. There are two other options:

    1. Build the INSTALL project. This copies the library files into MSVC's search path (%VCINSTALLDIR%\bin). Then you can select a startup project and run it with F5 (from within MSVC).

    2. Copy the Allegro DLL files to a new directory (like C:\ALLEGRO_BIN). Then append that directory to your system %PATH%. Now you can run Allegro 5 programs from any path on your system (including from within MSVC)

I made a cursory survey of all the example programs, and I found some things that might need fixing:

  • ex_utf8, ex_ttf, ex_font and ex_config fail to compile with warning C4819 if the default locale is not set to English (mine was set to CP949, Korean). The work-around is to set the system locale to English.

  • The Windows taskbar is rendered over ex_dualies. This problem is common to most of the dual monitor/fullscreen window examples. In addition, ex_dualies has some intermittent problems:

    • Occasionally causes explorer to crash on startup.

    • Sometimes the Mysha display only shows a solid green color.

    • Sometimes the Windows taskbar is not restored to its original size+location.

  • ex_fs_resize does not work very well with a dual monitor setup. It fails to change the resolution; it just sits in a semi-opened state (the log window is open, but the other window is just a sliver in the taskbar.) ex_fs_resize works if the monitors are duplicated, showing the exact same thing at the same resolution.

  • ex_threads sometimes results in one of two types of errors:

    1. When starting: fatal error (Callstack attached.)

    2. When closing: First-chance exception at 0x7741f49f in ex_threads.exe. (Callstack attached.)

  • ex_winfull taskbar also has some issues with the Windows taskbar being rendered over the Allegro display. On a dual monitor setup, I actually see two windows: the regular one on one monitor, and fullscreen window on the other. Clicking on the regular window causes the taskbar to occlude the fullscreen one. Works fine if the monitors are set to duplicate eachother instead of extend the desktop.

  • speed also has a problem with the Windows taskbar covering the Allegro window when switching to fullscreen mode with "F". The work-around is to click the taskbar, then click the Allegro window. I do not see the "regular sized" window with this one (like ex_winfull)

  • Building the run_tests projects results in several failures. These tests all passed in a previous SVN version of Allegro. List of failed tests attached.

Environment:

  • Ran all examples from within MSVC; RelWithDebugInfo

  • Allegro 5.0.0rc1

  • MSVC Express 2010

  • Windows 7 32-bit

  • Lenovo X301 laptop

  • FS-HS240LEDT external monitor

Matthew Leverton

Regarding CMake and MSVC 10, you can:

  • use nmake instead of project files, or

  • use my patched copy of cmake

That's assuming they haven't fixed the big in CMake yet.

Peter Wang

Thanks for testing!

  • Does this mean MSVC 10 has stdint.h?


  • ex_utf8, ex_ttf, ex_font and ex_config: unfortunately I can't find a decent solution to this. I don't really want to externalise the strings or use hex codes as some of these are meant to be readable examples. Apparently MSVC will treat these files are UTF-8 encoded if they have the stupid byte order mark (BOM) at the start; can you test if that works? I can't believe there is no command line option to force the input encoding.


  • I believe the failing test cases are related to r13800. I did not have time to investigate whether the library or the test suite is at fault.

Michał Cichoń

Yes, MSVC2010 has stdint.h.

Matthew Leverton

Does this mean MSVC 10 has stdint.h

Yes, and Allegro supports it correctly. The problem is CMake does not build proper MSVC 10 files, and the MSVC 9 ones are not compatible.

Thomas Fjellstrom

Would an option be to just rename the DLLs for windows to use the dll short version rather than SO version?

wonsungi

Apparently MSVC will treat these files are UTF-8 encoded if they have the stupid byte order mark (BOM) at the start; can you test if that works? I can't believe there is no command line option to force the input encoding.

Yes, it compiles... but it doesn't quite fix it. The BOM introduces compilation warnings in the English locale, then! There are still (different) warnings for the Korean local, too. The Unicode literal outputs of both programs are not properly printed; the UTF tests fail and/or hang.

Sample warning when compiling BOM file in Korean locale (CP949):
warning C4566: character represented by universal-character-name '\u25A2' cannot be represented in the current code page (949)

Sample warning when compiling BOM file in English locale (CP1252):
warning C4566: character represented by universal-character-name '\u25A0' cannot be represented in the current code page (1252)

I tried several other encodings, too: Unicode, Unicode Big-Endian, UFT-7. The only combination that worked was UFT-8 without signature compiled in English Locale.

Peter Wang

Ok, thanks. What happens to wide character strings, L"€"? If we can convince MSVC to use UTF-16 encoding for those, we can do a runtime conversion to UTF-8. With a C++ class it should be relatively painless.

Michał Cichoń
tobing
Evert said:

I've kept notes of my porting effort for my game, which I'll clean up and post here at some point (sooner rather than later, I hope).

This I'm looking forward to, I guess that it will be of great help for newbies to A5. One of the big things I'm going to port next is the game loop, which I think will have to look very different from the previous implementation.

wonsungi

Ok, thanks. What happens to wide character strings, L"€"? If we can convince MSVC to use UTF-16 encoding for those, we can do a runtime conversion to UTF-8. With a C++ class it should be relatively painless.

I forgot to mention I tried L"", too. MSVC complains about incompatible types. I also tried the "_T()" macro without any luck.

I suppose it might work if we modify Allegro a little. Is that what you mean by runtime conversion? I was reading the L"" macro messes up non-MSVC compilers, though...

Peter Wang

Allegro would remain the same. In the one or two examples, we would write U("føø"), where U(s) is a macro that expands to convert(L"føø") on MSVC, and "føø" everywhere else. convert() would return a pointer a UTF-8 string. This just requires that MSVC consistently output a UTF-16 string whenever we use the L"" syntax, which surely it does?

EDIT: attached a patch you can try (specifically ex_ttf).

Michał Cichoń

L"" convert to UCS-2, not UTF-16.

Elias
tobing said:

I'm really missing a lot of convenient functions, which looks like I have to re-implement things that have been present in allegro 4.4.

I ported the 4.4 skater demo to the 5.0 API and it's true to some extent. Basically I had to spend most time in unexpected places, like string/path handling and config files. In my case for the config files I used the versions from a4_aux.h with builtin types and default values. For path handling i changed to using ALLEGRO_PATH, which was some work but made the code more readable than the original. All the old u* functions need to be replaced with ALLEGRO_USTR, which actually has more convenience functions than the old ones.

Replacing all the messy code which randomly queries key[] and uses a timer and rest() for timing and implements 3 different double buffering methods was rather easy on the other hand. And the new events code is more reliable (e.g. no key presses can't be missed like with key[]), and it's also shorter and easier to read.

tobing

Yes, I have seen the stuff in a4_aux* already. I think I'll do similar things for config files, I just have to add support for override_config_file to what you have already done there.

Path and file system handling is an issue. For example, I have a function in place that takes care of auto saves. So all auto saves are collected from the file system, then the oldest are deleted, such that only a given maximum number of such auto saves exists. This requires matching file names, using a pattern like "auto*.vacs", then sorting the entries by modification date. Sure, this is possible with the new interfaces, except for the pattern matching... how would I do that? Which library to use here, that doesn't come a with massive overkill?

For the game loop and display stuff, I think I'll just re-write those parts. Will hopefully result in less and cleaner code. And yes, there's an occasional access to key[] and mouse_b...

Evert
tobing said:

One of the big things I'm going to port next is the game loop, which I think will have to look very different from the previous implementation.

I was dreading this part, but in the end, it was all very painless. The way I'd set up the code probably helped here though.

Elias
Evert said:

I was dreading this part, but in the end, it was all very painless. The way I'd set up the code probably helped here though.

Yes, that was just like my experience with the skater demo. I have to praise whoever wrote that demo for doing input handling the way it was done. Also for not using the A4 GUI, in which case I'd not have attempted the port.

Evert
Elias said:

Also for not using the A4 GUI, in which case I'd not have attempted the port.

Guess what my project was using for the menu screens... ;)
Actually that bit also wasn't so bad; A4's GUI is reasonably self-contained, so I ripped it out of whatever Allegro 4 version I had installed at the time. Then it's just a matter of replacing/emulating all the input code in there (fairly straightforward) and getting the widgets to compile (again easy with a tweaked version of a4_aux). Not that I haven't actually tested most of them, since I'm using custom widgets for most things.
There are a few glitches here and there (and some things I changed that didn't work the way I wanted to to begin with) but overall that was also more tedious than painful.

wonsungi

Allegro would remain the same. In the one or two examples, we would write U("føø"), where U(s) is a macro that expands to convert(L"føø") on MSVC, and "føø" everywhere else. convert() would return a pointer a UTF-8 string. This just requires that MSVC consistently output a UTF-16 string whenever we use the L"" syntax, which surely it does?

EDIT: attached a patch you can try (specifically ex_ttf).

The patch seems to do the trick. No MSVC compiler warnings in US or Korean locales, and the UTF output looks good in both the resulting executables.

Pho75_

Congrats to Allegro team on their impending 5.0 release.
I love Allegro, old and new.

Will support for stencils make it in to the next release, or are
there already commits? What new features are planned for 5.1 branch?

Wishlist:
I do wish support for at least 8-bit memory bitmaps had remained.
along with some blit/mask wrappers to transfer to ALLEGRO_BITMAP.
I found them particularly useful not just for sprites, but for world maps, etc.
For my project, I ended up ripping out the api from a much earlier
version or allegro and just slapping in C code to reimplement bitmap
creation and drawing primitives.
Obviously the performance is much worse than assembly.
Am I the only one living in the past. :P

Cheers.

Thomas Fjellstrom
Pho75_ said:

Will support for stencils make it in to the next release, or are
there already commits?

Thats something I really want, so I might help with it. Well see if I have the knowledge and skills ;D

Quote:

I do wish support for at least 8-bit memory bitmaps had remained.

The only way that's happening is if someone who wants it, writes the code. I don't have anything against that feature, I just don't want or need it ;) I do believe that the loaders will load 8 bit bitmaps, but up convert on load (not entirely sure).

Evert

I do believe that the loaders will load 8 bit bitmaps, but up convert on load (not entirely sure).

Yes, they do.

If I were to add 8 bit bitmaps to Allegro 5, I would probably make the palette a property of each bitmap (you'd be drawing them to a higher-colour depth display anyway) and do on-the-fly conversions when needed (so you don't get penalised more than once if the palette doesn't change).

Elias

8-bit doesn't necessaily mean palette. I think it would make sense to support something like GL_LUMINANCE in OpenGL ES 2.0:

Quote:

Each element is a single luminance value.
The GL converts it to floating point,
then assembles it into an RGBA element by replicating the luminance value
three times for red, green, and blue and attaching 1 for alpha.
Each component is then clamped to the range [0,1].

It could save a lot of texture space for e.g. fonts. Saving texture space reminds me, we should add an example how to use texture compression (OpenGL only - unless someone wants to make an addon which wraps around D3D as well).

Trezker

Just installed this version. I have a problem with the native filechooser. It freezes the program.

I'm on Ubuntu 10.04.

Peter Wang

There were no changes to the native dialogs addon from 4.9.22 :P

Can you get a backtrace by running under gdb?

Trezker

Hmm, I've never tried getting a backtrace for a program that freezes, only for crashes. How would I go about doing that?

Testing ex_native_filechooser.
It starts 5 threads, and when I click open it starts another thread then the log window goes grey and it's all frozen. It starts a thread and freezes no matter where I click actually.
Even if I don't click at all it freezes in less than 30 seconds.

Peter Wang

When it hangs, press ^C in the gdb window and you will get the usual gdb prompt. You can get a backtrace of all threads with: thread apply all bt

Thomas Fjellstrom
Trezker said:

Hmm, I've never tried getting a backtrace for a program that freezes, only for crashes. How would I go about doing that?

Most debuggers can attach to running programs. With gdb on unix you hand it the program's pid.

With threaded applications you want to run this in gdb: "thread apply all bt full" confusing, but it tells gdb to output a full backtrace for ALL threads.

Trezker
#0  0x0012d422 in __kernel_vsyscall ()
#1  0x00ae2015 in pthread_cond_wait@@GLIBC_2.3.2 ()
   from /lib/tls/i686/cmov/libpthread.so.0
#2  0x00197478 in _al_cond_wait (cond=0x834511c, mutex=0x8345100)
    at /home/anders/allegro/allegro-5.0.0rc1/include/allegro5/platform/aintuthr.h:81
#3  0x00193594 in al_wait_for_event (queue=0x83450d8, ret_event=0xbffff070)
    at /home/anders/allegro/allegro-5.0.0rc1/src/events.c:354
#4  0x0804a0f1 in main ()
    at /home/anders/allegro/allegro-5.0.0rc1/examples/ex_native_filechooser.c:228

Seems to be stuck in al_wait_for_event.

Oh, perhaps all threads is a good idea.

#SelectExpand
1Thread 7 (Thread 0xb53feb70 (LWP 18260)): 2#0 0x0012d422 in __kernel_vsyscall () 3No symbol table info available. 4#1 0x00ae4af9 in __lll_lock_wait () from /lib/tls/i686/cmov/libpthread.so.0 5No symbol table info available. 6#2 0x00ae013b in _L_lock_748 () from /lib/tls/i686/cmov/libpthread.so.0 7No symbol table info available. 8#3 0x00adff61 in pthread_mutex_lock () from /lib/tls/i686/cmov/libpthread.so.0 9No symbol table info available. 10#4 0x00650096 in ?? () from /usr/lib/libgdk-x11-2.0.so.0 11No symbol table info available. 12#5 0x00650020 in gdk_threads_enter () from /usr/lib/libgdk-x11-2.0.so.0 13No symbol table info available. 14#6 0x00130ff3 in gtk_start_and_lock (fd=0x8383f60) 15 at /home/anders/allegro/allegro-5.0.0rc1/addons/native_dialog/gtk_dialog.c:80 16 argc = 0 17 argv = 0x0 18 __func__ = "gtk_start_and_lock" 19#7 0x00131504 in _al_show_native_file_dialog (display=0x8160810, fd=0x8383f60) 20 at /home/anders/allegro/allegro-5.0.0rc1/addons/native_dialog/gtk_dialog.c:194 21---Type <return> to continue, or q <return> to quit--- 22 window = 0x1314e6 23#8 0x001306f1 in al_show_native_file_dialog (display=0x8160810, 24 dialog=0x8383f60) 25 at /home/anders/allegro/allegro-5.0.0rc1/addons/native_dialog/dialog.c:40 26 fd = 0x8383f60 27#9 0x08049b05 in async_file_dialog_thread_func (thread=0x8384048, 28 arg=0x8383ed0) 29 at /home/anders/allegro/allegro-5.0.0rc1/examples/ex_native_filechooser.c:54 30 data = 0x8383ed0 31 event = {type = 11403047, any = {type = 11403047, source = 0x0, 32 timestamp = 5.6363764798007543e-317}, display = {type = 11403047, 33 source = 0x0, timestamp = 5.6363764798007543e-317, x = 0, y = 0, 34 width = 18260, height = 2469876, orientation = -1254102160}, 35 joystick = {type = 11403047, source = 0x0, 36 timestamp = 5.6363764798007543e-317, id = 0x0, stick = 0, 37 axis = 18260, pos = 3.46103345e-39, button = -1254102160}, 38 keyboard = {type = 11403047, source = 0x0, 39 timestamp = 5.6363764798007543e-317, display = 0x0, keycode = 0, 40 unichar = 18260, modifiers = 2469876}, mouse = {type = 11403047, 41 source = 0x0, timestamp = 5.6363764798007543e-317, display = 0x0, 42 x = 0, y = 18260, z = 2469876, w = -1254102160, dx = 4001536, 43 dy = -1254104680, dz = 1668093, dw = 137904244, button = 0, 44---Type <return> to continue, or q <return> to quit--- 45 pressure = 0}, timer = {type = 11403047, source = 0x0, 46 timestamp = 5.6363764798007543e-317, count = 0, 47 error = 6.0319852354159264e-308}, user = {type = 11403047, 48 source = 0x0, timestamp = 5.6363764798007543e-317, 49 __internal__descr = 0x0, data1 = 0, data2 = 18260, 50 data3 = 2469876, data4 = -1254102160}} 51#10 0x0019f352 in thread_func_trampoline (inner=0x8384048, _outer=0x8384048) 52 at /home/anders/allegro/allegro-5.0.0rc1/src/threads.c:80 53 outer = 0x8384048 54 system = 0x807d4b8 55#11 0x001e6120 in thread_proc_trampoline (data=0x8384048) 56 at /home/anders/allegro/allegro-5.0.0rc1/src/unix/uxthread.c:36 57 thread = 0x8384048 58#12 0x00add96e in start_thread () from /lib/tls/i686/cmov/libpthread.so.0 59No symbol table info available. 60#13 0x00e70a4e in clone () from /lib/tls/i686/cmov/libc.so.6 61No symbol table info available. 62 63Thread 6 (Thread 0xb5bffb70 (LWP 18258)): 64#0 0x0012d422 in __kernel_vsyscall () 65No symbol table info available. 66#1 0x00ae5736 in nanosleep () from /lib/tls/i686/cmov/libpthread.so.0 67No symbol table info available. 68---Type <return> to continue, or q <return> to quit--- 69#2 0x001e5f93 in al_rest (seconds=0.032767999999999999) 70 at /home/anders/allegro/allegro-5.0.0rc1/src/unix/utime.c:68 71 timeout = {tv_sec = 0, tv_nsec = 32767999} 72 fsecs = 0 73#3 0x0019ff0c in timer_thread_proc (self=0x25e8c0, unused=0x0) 74 at /home/anders/allegro/allegro-5.0.0rc1/src/timernu.c:99 75 old_time = 10.353538 76 new_time = 10.353538 77 interval = 0.032767999999999999 78#4 0x001e6120 in thread_proc_trampoline (data=0x25e8c0) 79 at /home/anders/allegro/allegro-5.0.0rc1/src/unix/uxthread.c:36 80 thread = 0x25e8c0 81#5 0x00add96e in start_thread () from /lib/tls/i686/cmov/libpthread.so.0 82No symbol table info available. 83#6 0x00e70a4e in clone () from /lib/tls/i686/cmov/libc.so.6 84No symbol table info available. 85 86Thread 5 (Thread 0xb64dcb70 (LWP 18257)): 87#0 0x0012d422 in __kernel_vsyscall () 88No symbol table info available. 89#1 0x00e62b86 in poll () from /lib/tls/i686/cmov/libc.so.6 90No symbol table info available. 91#2 0x009d94eb in g_poll () from /lib/libglib-2.0.so.0 92---Type <return> to continue, or q <return> to quit--- 93No symbol table info available. 94#3 0x009cc0ac in ?? () from /lib/libglib-2.0.so.0 95No symbol table info available. 96#4 0x009cc817 in g_main_loop_run () from /lib/libglib-2.0.so.0 97No symbol table info available. 98#5 0x029ed400 in ?? () from /usr/lib/libORBit-2.so.0 99No symbol table info available. 100#6 0x009f2def in ?? () from /lib/libglib-2.0.so.0 101No symbol table info available. 102#7 0x00add96e in start_thread () from /lib/tls/i686/cmov/libpthread.so.0 103No symbol table info available. 104#8 0x00e70a4e in clone () from /lib/tls/i686/cmov/libc.so.6 105No symbol table info available. 106 107Thread 4 (Thread 0xb6e72b70 (LWP 18256)): 108#0 0x0012d422 in __kernel_vsyscall () 109No symbol table info available. 110#1 0x00ae2015 in pthread_cond_wait@@GLIBC_2.3.2 () 111 from /lib/tls/i686/cmov/libpthread.so.0 112No symbol table info available. 113#2 0x029cf88d in giop_recv_buffer_get () from /usr/lib/libORBit-2.so.0 114No symbol table info available. 115#3 0x029d467b in ORBit_small_invoke_stub () from /usr/lib/libORBit-2.so.0 116---Type <return> to continue, or q <return> to quit--- 117No symbol table info available. 118#4 0x029d48a6 in ORBit_small_invoke_stub_n () from /usr/lib/libORBit-2.so.0 119No symbol table info available. 120#5 0x029e1227 in ORBit_c_stub_invoke () from /usr/lib/libORBit-2.so.0 121No symbol table info available. 122#6 0x02911ae4 in Accessibility_EventListener_notifyEvent () 123 from /usr/lib/libspi.so.0 124No symbol table info available. 125#7 0x028ec3cc in ?? () from /usr/lib/gtk-2.0/modules/libatk-bridge.so 126No symbol table info available. 127#8 0x028ecb57 in ?? () from /usr/lib/gtk-2.0/modules/libatk-bridge.so 128No symbol table info available. 129#9 0x009593b0 in ?? () from /usr/lib/libgobject-2.0.so.0 130No symbol table info available. 131#10 0x0095adb4 in g_signal_emit_valist () from /usr/lib/libgobject-2.0.so.0 132No symbol table info available. 133#11 0x0095b256 in g_signal_emit () from /usr/lib/libgobject-2.0.so.0 134No symbol table info available. 135#12 0x028d5e97 in ?? () from /usr/lib/gtk-2.0/modules/libgail.so 136No symbol table info available. 137#13 0x003a2424 in ?? () from /usr/lib/libgtk-x11-2.0.so.0 138No symbol table info available. 139#14 0x00945252 in g_closure_invoke () from /usr/lib/libgobject-2.0.so.0 140---Type <return> to continue, or q <return> to quit--- 141No symbol table info available. 142#15 0x0095999d in ?? () from /usr/lib/libgobject-2.0.so.0 143No symbol table info available. 144#16 0x0095ac33 in g_signal_emit_valist () from /usr/lib/libgobject-2.0.so.0 145No symbol table info available. 146#17 0x0095b256 in g_signal_emit () from /usr/lib/libgobject-2.0.so.0 147No symbol table info available. 148#18 0x004cf636 in ?? () from /usr/lib/libgtk-x11-2.0.so.0 149No symbol table info available. 150#19 0x0039bf3c in gtk_main_do_event () from /usr/lib/libgtk-x11-2.0.so.0 151No symbol table info available. 152#20 0x0069039a in ?? () from /usr/lib/libgdk-x11-2.0.so.0 153No symbol table info available. 154#21 0x009c85e5 in g_main_context_dispatch () from /lib/libglib-2.0.so.0 155No symbol table info available. 156#22 0x009cc2d8 in ?? () from /lib/libglib-2.0.so.0 157No symbol table info available. 158#23 0x009cc817 in g_main_loop_run () from /lib/libglib-2.0.so.0 159No symbol table info available. 160#24 0x0039c3c9 in gtk_main () from /usr/lib/libgtk-x11-2.0.so.0 161No symbol table info available. 162#25 0x00130d84 in gtk_thread_func (data=0x0) 163 at /home/anders/allegro/allegro-5.0.0rc1/addons/native_dialog/gtk_dialog.c:4---Type <return> to continue, or q <return> to quit--- 1648 165 __func__ = "gtk_thread_func" 166#26 0x009f2def in ?? () from /lib/libglib-2.0.so.0 167No symbol table info available. 168#27 0x00add96e in start_thread () from /lib/tls/i686/cmov/libpthread.so.0 169No symbol table info available. 170#28 0x00e70a4e in clone () from /lib/tls/i686/cmov/libc.so.6 171No symbol table info available. 172 173Thread 3 (Thread 0xb77d0b70 (LWP 18255)): 174#0 0x0012d422 in __kernel_vsyscall () 175No symbol table info available. 176#1 0x00ae2015 in pthread_cond_wait@@GLIBC_2.3.2 () 177 from /lib/tls/i686/cmov/libpthread.so.0 178No symbol table info available. 179#2 0x00131083 in gtk_unlock_and_wait (nd=0x807db48) 180 at /home/anders/allegro/allegro-5.0.0rc1/addons/native_dialog/gtk_dialog.c:90 181No locals. 182#3 0x00131f1c in _al_open_native_text_log (textlog=0x807db48) 183 at /home/anders/allegro/allegro-5.0.0rc1/addons/native_dialog/gtk_dialog.c:375 184 top = 0x80f2040 185---Type <return> to continue, or q <return> to quit--- 186 scroll = 0x80ecc78 187 view = 0x80c4818 188#4 0x00130977 in textlog_thread_proc (thread=0x807dc18, arg=0x807db48) 189 at /home/anders/allegro/allegro-5.0.0rc1/addons/native_dialog/textlog.c:22 190 textlog = 0x807db48 191#5 0x0019f352 in thread_func_trampoline (inner=0x807dc18, _outer=0x807dc18) 192 at /home/anders/allegro/allegro-5.0.0rc1/src/threads.c:80 193 outer = 0x807dc18 194 system = 0x807d4b8 195#6 0x001e6120 in thread_proc_trampoline (data=0x807dc18) 196 at /home/anders/allegro/allegro-5.0.0rc1/src/unix/uxthread.c:36 197 thread = 0x807dc18 198#7 0x00add96e in start_thread () from /lib/tls/i686/cmov/libpthread.so.0 199No symbol table info available. 200#8 0x00e70a4e in clone () from /lib/tls/i686/cmov/libc.so.6 201No symbol table info available. 202 203Thread 2 (Thread 0xb7fd1b70 (LWP 18254)): 204#0 0x0012d422 in __kernel_vsyscall () 205No symbol table info available. 206#1 0x00e69971 in select () from /lib/tls/i686/cmov/libc.so.6 207No symbol table info available. 208#2 0x001f129d in xglx_background_thread (self=0x807d4e8, arg=0x807d4b8) 209---Type <return> to continue, or q <return> to quit--- 210 at /home/anders/allegro/allegro-5.0.0rc1/src/x/xsystem.c:164 211 x11_fd = 5 212 fdset = {__fds_bits = {32, 0 <repeats 31 times>}} 213 small_time = {tv_sec = 0, tv_usec = 30436} 214 s = 0x807d4b8 215 event = {type = 10, xany = {type = 10, serial = 35, send_event = 0, 216 display = 0x8065eb0, window = 171966466}, xkey = {type = 10, 217 serial = 35, send_event = 0, display = 0x8065eb0, 218 window = 171966466, root = 0, subwindow = 3, time = 1634831459, 219 x = 117, y = -2, x_root = 753, y_root = 513, state = 0, 220 keycode = 3, same_screen = 1}, xbutton = {type = 10, serial = 35, 221 send_event = 0, display = 0x8065eb0, window = 171966466, root = 0, 222 subwindow = 3, time = 1634831459, x = 117, y = -2, x_root = 753, 223 y_root = 513, state = 0, button = 3, same_screen = 1}, xmotion = { 224 type = 10, serial = 35, send_event = 0, display = 0x8065eb0, 225 window = 171966466, root = 0, subwindow = 3, time = 1634831459, 226 x = 117, y = -2, x_root = 753, y_root = 513, state = 0, 227 is_hint = 3 '\003', same_screen = 1}, xcrossing = {type = 10, 228 serial = 35, send_event = 0, display = 0x8065eb0, 229 window = 171966466, root = 0, subwindow = 3, time = 1634831459, 230 x = 117, y = -2, x_root = 753, y_root = 513, mode = 0, detail = 3, 231 same_screen = 1, focus = 1, state = 16}, xfocus = {type = 10, 232 serial = 35, send_event = 0, display = 0x8065eb0, 233---Type <return> to continue, or q <return> to quit--- 234 window = 171966466, mode = 0, detail = 3}, xexpose = {type = 10, 235 serial = 35, send_event = 0, display = 0x8065eb0, 236 window = 171966466, x = 0, y = 3, width = 1634831459, 237 height = 117, count = -2}, xgraphicsexpose = {type = 10, 238 serial = 35, send_event = 0, display = 0x8065eb0, 239 drawable = 171966466, x = 0, y = 3, width = 1634831459, 240 height = 117, count = -2, major_code = 753, minor_code = 513}, 241 xnoexpose = {type = 10, serial = 35, send_event = 0, 242 display = 0x8065eb0, drawable = 171966466, major_code = 0, 243 minor_code = 3}, xvisibility = {type = 10, serial = 35, 244 send_event = 0, display = 0x8065eb0, window = 171966466, 245 state = 0}, xcreatewindow = {type = 10, serial = 35, 246 send_event = 0, display = 0x8065eb0, parent = 171966466, 247 window = 0, x = 3, y = 1634831459, width = 117, height = -2, 248 border_width = 753, override_redirect = 513}, xdestroywindow = { 249 type = 10, serial = 35, send_event = 0, display = 0x8065eb0, 250 event = 171966466, window = 0}, xunmap = {type = 10, serial = 35, 251 send_event = 0, display = 0x8065eb0, event = 171966466, 252 window = 0, from_configure = 3}, xmap = {type = 10, serial = 35, 253 send_event = 0, display = 0x8065eb0, event = 171966466, 254 window = 0, override_redirect = 3}, xmaprequest = {type = 10, 255 serial = 35, send_event = 0, display = 0x8065eb0, 256 parent = 171966466, window = 0}, xreparent = {type = 10, 257---Type <return> to continue, or q <return> to quit--- 258 serial = 35, send_event = 0, display = 0x8065eb0, 259 event = 171966466, window = 0, parent = 3, x = 1634831459, 260 y = 117, override_redirect = -2}, xconfigure = {type = 10, 261 serial = 35, send_event = 0, display = 0x8065eb0, 262 event = 171966466, window = 0, x = 3, y = 1634831459, width = 117, 263 height = -2, border_width = 753, above = 513, 264 override_redirect = 0}, xgravity = {type = 10, serial = 35, 265 send_event = 0, display = 0x8065eb0, event = 171966466, 266 window = 0, x = 3, y = 1634831459}, xresizerequest = {type = 10, 267 serial = 35, send_event = 0, display = 0x8065eb0, 268 window = 171966466, width = 0, height = 3}, xconfigurerequest = { 269 type = 10, serial = 35, send_event = 0, display = 0x8065eb0, 270 parent = 171966466, window = 0, x = 3, y = 1634831459, 271 width = 117, height = -2, border_width = 753, above = 513, 272 detail = 0, value_mask = 3}, xcirculate = {type = 10, serial = 35, 273 send_event = 0, display = 0x8065eb0, event = 171966466, 274 window = 0, place = 3}, xcirculaterequest = {type = 10, 275 serial = 35, send_event = 0, display = 0x8065eb0, 276 parent = 171966466, window = 0, place = 3}, xproperty = { 277 type = 10, serial = 35, send_event = 0, display = 0x8065eb0, 278 window = 171966466, atom = 0, time = 3, state = 1634831459}, 279 xselectionclear = {type = 10, serial = 35, send_event = 0, 280 display = 0x8065eb0, window = 171966466, selection = 0, time = 3}, 281---Type <return> to continue, or q <return> to quit--- 282 xselectionrequest = {type = 10, serial = 35, send_event = 0, 283 display = 0x8065eb0, owner = 171966466, requestor = 0, 284 selection = 3, target = 1634831459, property = 117, 285 time = 4294967294}, xselection = {type = 10, serial = 35, 286 send_event = 0, display = 0x8065eb0, requestor = 171966466, 287 selection = 0, target = 3, property = 1634831459, time = 117}, 288 xcolormap = {type = 10, serial = 35, send_event = 0, 289 display = 0x8065eb0, window = 171966466, colormap = 0, new = 3, 290 state = 1634831459}, xclient = {type = 10, serial = 35, 291 send_event = 0, display = 0x8065eb0, window = 171966466, 292 message_type = 0, format = 3, data = { 293 b = "c\214qau\000\000\000\376\377\377\377\361\002\000\000\001\002\000", s = {-29597, 24945, 117, 0, -2, -1, 753, 0, 513, 0}, l = {1634831459, 294 117, -2, 753, 513}}}, xmapping = {type = 10, serial = 35, 295 send_event = 0, display = 0x8065eb0, window = 171966466, 296 request = 0, first_keycode = 3, count = 1634831459}, xerror = { 297 type = 10, display = 0x23, resourceid = 0, serial = 134635184, 298 error_code = 2 '\002', request_code = 0 '\000', 299 minor_code = 64 '@'}, xkeymap = {type = 10, serial = 35, 300 send_event = 0, display = 0x8065eb0, window = 171966466, 301 key_vector = "\000\000\000\000\003\000\000\000c\214qau\000\000\000\376\377\377\377\361\002\000\000\001\002\000\000\000\000\000"}, xgeneric = { 302 type = 10, serial = 35, send_event = 0, display = 0x8065eb0, 303---Type <return> to continue, or q <return> to quit--- 304 extension = 171966466, evtype = 0}, xcookie = {type = 10, 305 serial = 35, send_event = 0, display = 0x8065eb0, 306 extension = 171966466, evtype = 0, cookie = 3, data = 0x61718c63}, 307 pad = {10, 35, 0, 134635184, 171966466, 0, 3, 1634831459, 117, -2, 308 753, 513, 0, 3, 1, 1, 16, 0, 0, 0, 0, 0, 0, 0}} 309 last_reset_screensaver_time = 0 310#3 0x001e6120 in thread_proc_trampoline (data=0x807d4e8) 311 at /home/anders/allegro/allegro-5.0.0rc1/src/unix/uxthread.c:36 312 thread = 0x807d4e8 313#4 0x00add96e in start_thread () from /lib/tls/i686/cmov/libpthread.so.0 314No symbol table info available. 315#5 0x00e70a4e in clone () from /lib/tls/i686/cmov/libc.so.6 316No symbol table info available. 317 318Thread 1 (Thread 0xb7fd2a90 (LWP 18253)): 319#0 0x0012d422 in __kernel_vsyscall () 320No symbol table info available. 321#1 0x00ae2015 in pthread_cond_wait@@GLIBC_2.3.2 () 322 from /lib/tls/i686/cmov/libpthread.so.0 323No symbol table info available. 324#2 0x00197478 in _al_cond_wait (cond=0x8319f44, mutex=0x8319f28) 325 at /home/anders/allegro/allegro-5.0.0rc1/include/allegro5/platform/aintuthr.h:81 326---Type <return> to continue, or q <return> to quit--- 327No locals. 328#3 0x00193594 in al_wait_for_event (queue=0x8319f00, ret_event=0xbffff070) 329 at /home/anders/allegro/allegro-5.0.0rc1/src/events.c:354 330 next_event = 0x0 331 __PRETTY_FUNCTION__ = "al_wait_for_event" 332#4 0x0804a0f1 in main () 333 at /home/anders/allegro/allegro-5.0.0rc1/examples/ex_native_filechooser.c:228 334 h = 480 335 event = {type = 30, any = {type = 30, source = 0x831a248, 336 timestamp = 10.353541999999999}, display = {type = 30, 337 source = 0x831a248, timestamp = 10.353541999999999, x = 282, 338 y = 0, width = 1372777472, height = 1058235918, 339 orientation = 1434544}, joystick = {type = 30, source = 0x831a248, 340 timestamp = 10.353541999999999, id = 0x11a, stick = 0, 341 axis = 1372777472, pos = 0.575775981, button = 1434544}, 342 keyboard = {type = 30, source = 0x831a248, 343 timestamp = 10.353541999999999, display = 0x11a, keycode = 0, 344 unichar = 1372777472, modifiers = 1058235918}, mouse = {type = 30, 345 source = 0x831a248, timestamp = 10.353541999999999, 346 display = 0x11a, x = 0, y = 1372777472, z = 1058235918, 347 w = 1434544, dx = 1119288, dy = 1984974, dz = 11376804, 348 dw = 2469876, button = 3049257840, pressure = 5.60734625e-39}, 349---Type <return> to continue, or q <return> to quit--- 350 timer = {type = 30, source = 0x831a248, 351 timestamp = 10.353541999999999, count = 282, 352 error = 7.4000000000504218e-05}, user = {type = 30, 353 source = 0x831a248, timestamp = 10.353541999999999, 354 __internal__descr = 0x11a, data1 = 0, data2 = 1372777472, 355 data3 = 1058235918, data4 = 1434544}} 356 display = 0x8160810 357 timer = 0x831a248 358 queue = 0x8319f00 359 font = 0x8319fb0 360 background = {r = 1, g = 1, b = 1, a = 1} 361 active = {r = 0, g = 0, b = 0, a = 1} 362 inactive = {r = 0.501960814, g = 0.501960814, b = 0.501960814, a = 1} 363 info = {r = 1, g = 0, b = 0, a = 1} 364 old_dialog = 0x0 365 cur_dialog = 0x8383ed0 366 message_box = 0x0 367 redraw = false 368 close_log = false 369 button = 134517828 370 message_log = true

Peter Wang

Can you also post the contents of allegro.log?

Trezker

Attached

EDIT: So A.cc doesn't finish uploading after pressing submit post.

Peter Wang

I think it will be a bit easier to debug with more logging. Please post the allegro.log again after applying this patch.

Trezker

Here you go.

Peter Wang

Thanks. Does this help?

Trezker

No it did not.
Attached new log and backtrace.
New behaviour though, when running in gdb I only get the log window and it freezes there.

Peter Wang

I'm not sure what the problem is, but it could be a GTK bug. The implementation was bugging me anyway so I changed it a simpler, message-passing type structure, instead of trying to find the bug.

Trezker

And it works!
I like the humor when I click anywhere.

Peter Wang

Great. I've committed a more complete version of the patch.

Trezker

The native filechooser in A5 returns absolute paths, but I want relative paths.

What's the simplest method for removing current directory from the path?

I noticed that al_get_current_directory returns a string that must be freed. Why? I would prefer to have freeing that off my hands when I need the cwd.

Trent Gamblin

On a slightly related note, I don't know if this is a big problem (probably not), but al_get_current_directory returns a path without a trailing / (or \). My colleague wrote some code that turned out to be messing up because he assumed there was going to be a / at the end. So I had to create a temporary string and add the / then add the rest of the path.

Evert
Trezker said:

The native filechooser in A5 returns absolute paths, but I want relative paths.

Just out of curiosity: why?
I can't think of a use case where absolute paths would be bad. Arguably you want to base things off the current directory with the idea that you can still find the file if you move the whole directory tree, but that only works for files under the tree...

Quote:

What's the simplest method for removing current directory from the path?

Probably using al_remove_path_component (by the way, it'd be neat if Acc's markup started recognising A5 functions).

EDIT: could someone clarify the distinction between al_join_path() and al_rebase_path()? From the description it seems that they do more or less the same thing, except one modifies the first argument and one modifies the second argument...? The example at al_rebase_path() does what I'd expect al_join_path() to do (which doesn't have an example an dprobably needs it) while I would expect al_rebase_path() to more-or-less allow you to do what the OP wants here.
I'm confused now...

Trezker

I want to save the paths in a level file so they can be loaded no matter where the game is installed.

If a file is not under the tree, I'm considering importing it by copying the selected file to a folder where the game would want those files to be.

Perhaps I should just get the filename part from the path, prepend expected folder and check file existence. If it's not where it's supposed to be then I copy the file selected in filechooser.

Thomas Fjellstrom

Yeah, I think we should add an `al_path_make_relative(ALLEGRO_PATH *working, ALLEGRO_PATH *path)` or something along those lines. This would take path, and remove "working"'s path components from "path".

Its not that hard to do yourself though.

Elias
Trezker said:

I noticed that al_get_current_directory returns a string that must be freed. Why? I would prefer to have freeing that off my hands when I need the cwd.

That's not how things work in C. Look at this:

al_change_directory("blah1");
str1 = al_get_current_directory();
al_change_directory("blah2");
str2 = al_get_current_directory();
printf("%s %s", str1, str2);

If you do this in a loop a few 1000 times it would mean a lot of strings which have to be kept... only way around that is to free them. What we could do is have you pass in a buffer and length where the string gets written to though, but that would be awkward as you now have to deal with arbitrary buffer lengths. More annoying than adding a free call I think.

Yeah, I think we should add an `al_path_make_relative(ALLEGRO_PATH *working, ALLEGRO_PATH *path)` or something along those lines.

The name would be confusing. For example if I'm in "/home/blah1" then want the relative path to "/home/blah2", I would expect to get "../blah2".

Trezker

Other A5 functions that return strings don't require the user to free.

http://alleg.sourceforge.net/a5docs/refman/path.html#al_path_cstr
"The returned pointer is valid only until the path is modified in any way, or until the path is destroyed."

http://alleg.sourceforge.net/a5docs/refman/utf8.html#al_cstr
"This pointer will only be valid while the underlying string is not modified and not destroyed."

Thomas Fjellstrom
Trezker said:

"The returned pointer is valid only until the path is modified in any way, or until the path is destroyed."

Thats a bit of a special case, the ALLEGRO_PATH structure stores a cache of the c-string so it doesn't have to keep re-making the full string each time al_path_cstr is called, and thats what it returns.

I assume al_cstr is the same. Most times with a current dir string, you wan't to keep it around, not have it disappear just because you changed dirs and called al_current_dir again.

Peter Wang

Those are "object-oriented" and have some place to stash the string buffer. The only such place for al_get_current_directory() is in a global variable, which introduces problems with threads. Then we would need to make it thread-local, which introduces its own issues.

Just make a function that copies the string to your preferred location, and free Allegro's string immediately. You can make assumptions in your application that Allegro can't.

Erin Maus

I was just fiddling around with this version of Allegro and I found a problem. Probably on my end, but the behavior is still strange regardless.

I have this simple program:

#SelectExpand
1int main(void) 2{ 3 ALLEGRO_DISPLAY * display; 4 5 if (!al_init()) 6 return 1; 7 8 al_set_new_display_flags(ALLEGRO_FULLSCREEN_WINDOW & ALLEGRO_OPENGL); 9 al_set_new_display_option(ALLEGRO_STENCIL_SIZE, 1, ALLEGRO_REQUIRE); 10 11 display = al_create_display(640, 480); 12 13 if (!display) 14 return 1; 15 16 al_destroy_display(display); 17 18 return 0; 19}

Running it endlessly tries to create windows until the program crashes. I attached the log and am using the RC1 release from Allegro5.org. I figured al_create_display would fail gracefully instead of getting stuck in an endless loop.

Thomas Fjellstrom

That problem seems to happen on some computers.. It should be known that there is no loop in the display creation code AFAIK. So whatever is happening is a driver or d3d bug.

So far we have no idea what causes it.

Peter Wang

Adding some logging in the loop around d3d_disp.cpp:1809 should help to debug it.

Elias

Well, the attached log does suggest some kind of loop. I added a bug report for it so we won't forget before the final 5.0, but hopefully we'll be able to fix it right away.

David Capello

Is it related to D3D or to OpenGL? (see the ALLEGRO_OPENGL in al_set_new_display_flags)

If it is related to OpenGL, I think that "display_thread_proc" in "wgl_disp.c" needs a review, because there are an ugly hack/loop for DInput (which is not used anymore).

Trent Gamblin

It's a D3D bug. It has to do with matching the best display format.

Thomas Fjellstrom

It's a D3D bug. It has to do with matching the best display format.

Except it seems he's setting ALLEGRO_OPENGL?

Trent Gamblin

Hmm in that case I don't know ???

Erin Maus

Thanks for the info. I won't use that code myself (as I said I was just fiddling with it).

I found another crash that only happens occasionally. Basically, when my program exits, it crashes some place in d3d_shutdown. The exact place tends to be rather random. The example is as follows:

#SelectExpand
1int main(void) 2{ 3 ALLEGRO_DISPLAY * display; 4 5 if (!al_init()) 6 return 1; 7 8 al_set_new_display_flags(ALLEGRO_WINDOWED & ALLEGRO_OPENGL); 9 al_set_new_display_option(ALLEGRO_SAMPLE_BUFFERS, 1, ALLEGRO_SUGGEST); 10 al_set_new_display_option(ALLEGRO_SAMPLES, 16, ALLEGRO_SUGGEST); 11 al_set_new_display_option(ALLEGRO_STENCIL_SIZE, 8, ALLEGRO_SUGGEST); 12 13 display = al_create_display(640, 480); 14 15 if (!display) 16 return 1; 17 18 al_set_window_title(display, "Bright Side"); 19 al_set_window_position(display, 0, 0); 20 al_toggle_display_flag(display, ALLEGRO_NOFRAME, true); 21 22 al_flip_display(); 23 24 al_destroy_display(display); 25 26 al_uninstall_system(); 27 28 return 0; 29}

Sorry for any inconvenience!

edit: Seems to only happen due to al_toggle_display_flag. Without it I haven't encountered a crash yet.

Thomas Fjellstrom

Ohh.. I noticed something quite wrong in your code.

Do not use & to combine flags. use |.

Please re try both of your examples!

Trent Gamblin

al_set_new_display_flags(ALLEGRO_WINDOWED & ALLEGRO_OPENGL);

I think you want an | there not an &. However, this may be a legitimate bug. Thanks.

Erin Maus

Oh duh! Sorry and I'll try it again.

edit: Yea that seems to be the problem (same with the previous one, probably). Sorry for wasting everyone's time! (my excuse is I haven't used bit operations in a long time, but that's a rather lame excuse... "Oh, I haven't ridden a bike in four years! How will I remember?")

edit: Actually that really should have no effect. ALLEGRO_OPENGL & ALLEGRO_WINDOWED is 0. Would that not be a valid input? After all, it'd just default to the regular settings (or am I wrong?). In any case, I encountered a crash again after doing some other stuff, tried the code previously with the fix, and lo and behold it happens. So I guess I wasn't wasting anyone's time.

Trent Gamblin

So let me get this straight. It's crashing when using the OpenGL driver and when using the D3D driver, or is it one or the other?

Erin Maus

I haven't had it crash yet with OpenGL, just Direct3D in d3d_shutdown.

Trent Gamblin

If you're using ALLEGRO_OPENGL then you're using OpenGL not D3D. Memory corruption could cause it to appear to crash in the d3d driver. I just want to make it clear, so could you please post the code that crashes?

Erin Maus

By Direct3D I mean when I do not set any flags (through al_set_new_display_flags).

When I use Direct3D it crashes (by using the code below) at the end of the program:

al_set_new_display_flags(0); /* Or just not calling it at all. */

And this does not crash at the end:

al_set_new_display_flags(ALLEGRO_OPENGL)

The example I am using is just this:

#SelectExpand
1int main(void) 2{ 3 ALLEGRO_DISPLAY * display; 4 5 if (!al_init()) 6 return 1; 7 8 al_set_new_display_option(ALLEGRO_SAMPLE_BUFFERS, 1, ALLEGRO_SUGGEST); 9 al_set_new_display_option(ALLEGRO_SAMPLES, 16, ALLEGRO_SUGGEST); 10 al_set_new_display_option(ALLEGRO_STENCIL_SIZE, 8, ALLEGRO_SUGGEST); 11 12 display = al_create_display(640, 480); 13 14 if (!display) 15 return 1; 16 17 al_set_window_title(display, "Bright Side"); 18 al_set_window_position(display, 0, 0); 19 al_toggle_display_flag(display, ALLEGRO_NOFRAME, true); 20 21 al_flip_display(); 22 23 al_destroy_display(display); 24 25 al_uninstall_system(); 26 27 return 0; 28}

By default, this would use the Direct3D driver on Windows, or am I wrong?

Trent Gamblin

Yes, that's right. But since you were using ALLEGRO_OPENGL in all of your previous examples I had to verify.

Erin Maus

I really don't mean to be a pain but I found a problem with getting display modes in OpenGL. The "height" member in ALLEGRO_DISPLAY_MODE is never set. I looked at the source and understand why the pixel format is not filled, so I ignore that for OpenGL contexts, but the height is important. Code is like so:

ALLEGRO_DISPLAY_MODE mode;
al_set_new_display_option(ALLEGRO_SAMPLE_BUFFERS, 1, ALLEGRO_SUGGEST);
al_set_new_display_option(ALLEGRO_SAMPLES, 16, ALLEGRO_SUGGEST);
al_set_new_display_option(ALLEGRO_STENCIL_SIZE, 8, ALLEGRO_SUGGEST);
al_get_display_mode(0, &mode)

printf("%d %d", mode.width, mode.height) /* Prints 640 0 (for example). */

David Capello

But since you were using ALLEGRO_OPENGL in all of your previous examples I had to verify.

Aaron was not using OpenGL really, see the Thomas Fjellstrom comment, he was using:

(ALLEGRO_WINDOWED & ALLEGRO_OPENGL) = (1 & 4) = 0 (& instead of |)

  al_set_new_display_flags(0);

I missed it too.

Trent Gamblin

Aaron was not using OpenGL really, see the Thomas Fjellstrom comment, he was using:

I noticed that but assumed he was still using OpenGL after correcting that.

Aaron, if you're able to repeat this bug, could you please try adding a delay (Try Sleep(1000) on windows) after al_uninstall_sytem and before returning from main? I think it's a race condition. I was only able to reproduce it once though so I'm not sure.

Trezker

I started using the filechooser in Cumulate and I'm annoyed by this error that shows up every time I use it.

** (<unknown>:16706): CRITICAL **: giop_thread_request_push: assertion `tdata != NULL' failed

I've tried to replicate it in a small example program but can't make it happen there. But in Cumulate it happens even in the simplest possible use of filechooser, create, show and destroy.

Usage can be found in this file.
https://github.com/trezker/Cumulate/blob/master/editor/file.cpp

Trent Gamblin

Aaron, for the second bug about OpenGL display modes, try the patch attached to this post.

Erin Maus

The patch worked; thanks a bunch!

Trent Gamblin

YW. What about the delay I suggested a couple posts above?

Erin Maus

Oh, I just tried that now after seeing your post and first run crashed still. Seems to crash during the call to al_uninstall_system, not after (when returning from main). Sleep never gets called.

Thread #605549. Printed from Allegro.cc