|
al_draw_line failure |
ponyman
Member #14,713
November 2012
|
Hi everyone, it's my first post here. 1for(int i = 0; i<(n-1); i++)
2{
3 for(int j = (i+1); j<n; j++)
4 {
5 al_draw_line(pX[i], pY[i], pX[j], pY[j], red, 2);
6 file<<"Line between "<<pX[i]<<" "<<pY[i]<<" and "<<pX[j]<<" "<<pY[j]<< endl;
7 }
8}
The code above is supposed to draw lines between points "i" and "j" described by coordinates stored in "float" type vectors, f.e. pX[1] and pY[1] are coordinates of "Point 2". Problem is, lines are not drawn, and I don't know, why. As a part of crude debugging, notifications of supposed drawings are saved in .txt file in pattern shown below. In result, I get properly filled file: 2Line between 417.815 260.791 and 411.355 280.674
3Line between 417.815 260.791 and 400.902 298.778
4Line between 417.815 260.791 and 386.913 314.314
5Line between 417.815 260.791 and 370 326.602
6Line between 417.815 260.791 and 350.902 335.106
7Line between 417.815 260.791 and 330.453 339.452
8and so on...
which means numerical input is all right. I get no errors nor warnings. It's not the first time this function is acting weird - not drawing when code seems to be all-OK. There's an possibility that I'm missing something little yet essential about the usage of this function, but right now, I'm clueless. Full listing of fuction using this code : http://pastebin.com/JvsGVrTM |
Arthur Kalliokoski
Second in Command
February 2005
|
Did you initialize primitives? Also try substituting al_map_rgb_f(1.0,0.0,0.0) for red. They all watch too much MSNBC... they get ideas. |
ponyman
Member #14,713
November 2012
|
@Arthur - I've changed the drawing colour with your suggestion and it works! |
Arthur Kalliokoski
Second in Command
February 2005
|
You can't call functions such as al_map_rgb() outside of main() or another function, I'd guess it loaded "red" with the address of al_map_rgb(). Try to find out how to increase the error reporting of your compiler. They all watch too much MSNBC... they get ideas. |
ponyman
Member #14,713
November 2012
|
Good old DevC++ does not report this as an error. Well, I'll be wiser now. |
Arthur Kalliokoski
Second in Command
February 2005
|
ponyman said: Good old DevC++ IIRC, DevC++ uses MinGW and the gcc compiler, right? You can turn up the errors and warnings with -O2 -Wall -Wextra in the compiler options (whereever those are). They all watch too much MSNBC... they get ideas. |
ponyman
Member #14,713
November 2012
|
You're right, I'll try it. |
Thomas Fjellstrom
Member #476
June 2000
|
Arthur Kalliokoski said: You can't call functions such as al_map_rgb() outside of main() or another function, I'd guess it loaded "red" with the address of al_map_rgb(). Try to find out how to increase the error reporting of your compiler. Calling functions outside of main like that is valid in C++. However, it is not normally valid to call allegro functions before you've called al_init or after al_uninstall_system has been called. Many also don't like it if there isn't a current display or target bitmap. It's something that is easy to trip up on when using C++ "as normal". -- |
|