|
Upgrading from Allegro 4.x to Allegro 5.x |
TeaRDoWN
Member #8,518
April 2007
|
I've decided that it's time to stop using Allegro 4(.2x) and upgrade to Allegro 5(.0.4). I've checked the examples and demos and everything seems pretty neat, however there are a few questions now when it comes to code upgrade: 1. Playing midi-files? 2. Playing ogg-files? 3. al_flip_display() 4. voice_set_priority() 5. Sprite fonts 6. Reading mouse buttons and coordinates in A5 bool TD_mouseB(int button) { ALLEGRO_MOUSE_STATE mouse_state; al_get_mouse_state(mouse_state); return al_mouse_button_down(mouse_state, button); } The mouse_state struct is local within the function and each time you want to check the mouse button you do a al_get_mouse_state() call. 7. key[KEY_ENTER] replaced by pressed_keys[ALLEGRO_KEY_ENTER]? That's all...for now. I'll add more questions as I go on updating my finished A4 project. Someone told me to not upgrade a project but when starting on a new one do the transition from A4 to A5. Starting to see why but I guess this is a good way in learning the new names and parameters of the used functions. |
Evert
Member #794
November 2000
|
TeaRDoWN said: 1. Playing midi-files? No midi support. It could conceivably be added (as an addon) very easily if someone is willing to put in the work. Quote: 2. Playing ogg-files? Yes, A5 comes with ogg support (but it needs to find the required support libraries at compile time; shouldn't be a problem if you use precompiled binaries). Quote: 3. al_flip_display() In a sense. You do all your drawing operations to the screen, which is double buffered by default. Quote: 5. Sprite fonts Yes. In fact, it internally uses pretty much the same code as A4 did. |
Elias
Member #358
May 2000
|
1. MIDI is not supported. When I ported things myself I just rendered the .mid files as .ogg. 2. It's built-in, yes. (In the official windows binaries - otherwise you need the right dependencies of course.) 3. Basically. You don't have a buffer or screen any longer - you just create a display (which has an OpenGL context or the DirectX equivalent) and al_flip_display simply translates to the OpenGL/DirectX command to render the frame. 4. The problem is the same as in A4 and it's just not supported in A5. However instead of using the "simple" API with al_play_sample and al_reserve_samples you can use the lower level al_play_sample_instance and manage priority yourself (works like A4 voices). I don't know why priorities were left out. 5. Yes, al_load_font will happily load any colored bitmap fonts. [EDIT: I'm too slow... but then I also had to research question 4 ] -- |
TeaRDoWN
Member #8,518
April 2007
|
1. If anyone has a midi-sollution for A5 (usable with VS 2010 v9.x) I would be super happy if I could get my hands on it too. Added two new questions (#6 and #7) in first post. Regarding #4 I guess I just have to code my own priority system. I so need it since player's samples should always be played and not interupted by 100s of enemies trying to play samples too. |
Evert
Member #794
November 2000
|
LordHolNapul
Member #3,619
June 2003
|
about midi support....
|
AMCerasoli
Member #11,955
May 2010
|
LordHolNapul said: "when the progress is not a progress... " If currently (2011) I run a game and start playing a MIDI song, I would immediately delete the game, blow out my computer, burn down my house, and move of country...
|
TeaRDoWN
Member #8,518
April 2007
|
Anyone got an answer/sollution on #7? Would be handy right now since I have about 200-300 build errors. Regarding Midi-support or not, true in a new game. But when making a remake of a 90s game it bring back the right feeling. But I'll convert my midis to another format if it is possible. |
raynebc
Member #11,908
May 2010
|
AMCerasoli said: If currently (2011) I run a game and start playing a MIDI song, I would immediately delete the game, blow out my computer, burn down my house, and move of country... There are instances where the MIDI is used to track data and not music itself, such as with rhythm gaming. I work on one such project where we'll either have to port the MIDI load function or write our own code to replace it. |
AMCerasoli
Member #11,955
May 2010
|
That's is because Allegro 5 doesn't use an array of flags anymore, but just a simple enum. I think you need to create it now, as the manual says: Quote: The constant ALLEGRO_KEY_MAX is always one higher than the highest key code. So if you want to use the key code as array index you can do something like this: bool pressed_keys[ALLEGRO_KEY_MAX]; ... pressed_keys[key_code] = true; But a better way would be to use the al_key_down() function. ALLEGRO_KEYBOARD_STATE key; while(1){ al_get_keyboard_state(&key); if (al_key_down(&key, ALLEGRO_KEY_LEFT)) // Do something } But events are better. raynebc said: There are instances where the MIDI is used to track data and not music itself, such as with rhythm gaming. I work on one such project where we'll either have to port the MIDI load function or write our own code to replace it. In such case it's acceptable, "tell me when to play the instruments, but please don't use yours" .
|
TeaRDoWN
Member #8,518
April 2007
|
Ah, thought the bool array existed but as usual I read too quickly. |
|