|
Help for al_draw_ustr() |
Korhal
Member #15,603
May 2014
|
Hello there, I am a beginner to allegro 5 and I want to use Allegro 5 in c++ at university to develope a programm that simulates the movement of a machine. In this programm, the user chooses several sets of parameters for the simulation. Then every set of Parameters is simulated. The Process is shown to the user in a Window on the screen. For every set of parameters a new window is opened and closed after the simulation is finished. Problem: allegro-5.0.10-monolith-mt.dll! al_draw_ustr() + 0x80 bytes I don't understand what this means. The error seems to happen in the moment when a new window for a new simulation opens. I see the window but no thing is drawn yet on it. I checked if i destroy all the *font and *display but that seems to be correct. Thanks a lot for your help!! |
AMCerasoli
Member #11,955
May 2010
|
I think that crash may be related to a uninitialized pointer. After you destroy the fonts are you loading them again after you start running your next simulation?
|
Edgar Reynaldo
Major Reynaldo
May 2007
|
Allegro 5 from Git said:
71/* Function: al_draw_ustr
72 */
73void al_draw_ustr(const ALLEGRO_FONT *font,
74 ALLEGRO_COLOR color, float x, float y, int flags,
75 const ALLEGRO_USTR *ustr)
76{
77 ASSERT(font);
78 ASSERT(ustr);
79
80 if (flags & ALLEGRO_ALIGN_CENTRE) {
81 /* Use integer division to avoid introducing a fractional
82 * component to an integer x value.
83 */
84 x -= font->vtable->text_length(font, ustr) / 2;
85 }
86 else if (flags & ALLEGRO_ALIGN_RIGHT) {
87 x -= font->vtable->text_length(font, ustr);
88 }
89
90 if (flags & ALLEGRO_ALIGN_INTEGER)
91 align_to_integer_pixel(&x, &y);
92
93 font->vtable->render(font, color, ustr, x, y);
94}
In the debug build, a null font or ustr would be caught by the assert. In the release build the only way it could crash is if font is corrupt (ie. already freed). I suppose a corrupt ustr could crash it too though. Use the debug build and run it through a debugger. It Hope this helps. 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 |
Korhal
Member #15,603
May 2014
|
Thanks a lot for your help! Is this affecting the location where the information is storred? Up to now I placed the following lines to another position of my program so they don't get executed in every loop: But still getting the following error: |
Edgar Reynaldo
Major Reynaldo
May 2007
|
Yeah, you probably have a giant memory leak. You should not be initializing your display, queue, timer, etc on every loop. You want to initialize them once for your window and then destroy them when you are done to prevent a memory leak. Same goes for fonts. If you load them on every iteration without also destroying them then you will be leaking memory, which will eventually cause it to crash when it runs out of memory. So, make sure you're not doing that, and if you still have problems, try to post code in <code>code goes here...</code> tags. 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 |
Korhal
Member #15,603
May 2014
|
Thank you for your help! Thanks a lot for your support! |
|