Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » Allegro5 with GTK, QT or Wxwidgets

This thread is locked; no one can reply to it. rss feed Print
Allegro5 with GTK, QT or Wxwidgets
aniquilator
Member #9,841
May 2008
avatar

Hello everyone!
Sometime ago I made a program to help me make animations to my games. For that I used guichan. But guichan is for using more with ingame stuff. I was thinking about remaking my program with a better gui, like wxWidgets, QT or GTK.
I know thats a way to use allegro 4.2 with wxwidgets.. Is that a way to do so with allegro5?

I know that allegro now uses(can use, i think) openGL to render its graphics, is there a way to get the opengl window handler, or somethink like this? case with QT, I can embed an opengl window with my gui.

Please help me, I read a lot about allegro5 possible guis but. I dont really need an ingame gui, WHAT I NEED is a gui, with an allegro5 window embed...
let me try to explain better. I got a program, with my gui, I will let the user change a lot of values, and in the "allegro window", I will render some graphics with the data gathered. ::)

So thats it, i would really appreciate your help. Thanks in advance.

If you wanna know exactly what i will remake see this, maybe you can understand better:

video

Thomas Fjellstrom
Member #476
June 2000
avatar

I'd probably just use Qt's or OpenGL functions to do the drawing if I was going to the trouble of making a tool for a game in Qt.

But I think you might be able to mix Qt and Allegro 5 if you make sure to handle allegro 5 messages in with the Qt messages. I assume that'd be done using the QEventLoop stuff. And after that you'd grab the window id from allegro, and tell Qt to embed that window in one of its own widgets. That part is going to need platform specific code though.

--
Thomas Fjellstrom - [website] - [email] - [Allegro Wiki] - [Allegro TODO]
"If you can't think of a better solution, don't try to make a better solution." -- weapon_S
"The less evidence we have for what we believe is certain, the more violently we defend beliefs against those who don't agree" -- https://twitter.com/neiltyson/status/592870205409353730

aniquilator
Member #9,841
May 2008
avatar

Hey, thanks, i will to try to look at QEventLoop.
unfortunately I cant just use openGl or Qts function to do the drawing, cause, i made a lot of classes that use allegro5 drawing, and I need those classes to render the graphics, they render animations, and spritepacks at most. I could try to convert the images they return to qt's image format, but I think it must be a better way.

Now I could initiate a application in Qt, and display an allegro window, but when I quit the application, it seems that the allegro don't let qt finish it all. Do you know why? I just put this code in the constructor of my widget:

#SelectExpand
1printf("allegro_init()-call\n"); 2al_install_system(ALLEGRO_VERSION_INT, NULL) == true); 3printf("allegro_init()-end\n"); 4mydisplay = al_create_display(320, 240);

And I put this code in the destructor of my class:

#SelectExpand
1al_destroy_display(mydisplay); 2printf("al_uninstall_system()-call\n"); 3al_uninstall_system(); 4printf("al_uninstall_system()-end\n");

I works fine, It inits, create the display, and show the quit message properly, but the application, stills running..
If I remove the al_install_system ... it quits properly. Any idea?
Thanks in advance

Edit:
I was doing some tests here, and something very interesting happened..
Like I explained before, I'm creating a display for allegro, and was drawing some rectangles in the display with al_draw_filled_rectangle. The weird thing is that the rectangles are being drawn into the QT widget, instead of their being drawn into the allegro's display! look at the code below:

#SelectExpand
1int x=10,y=10; 2int W=50,H=50; 3 4al_set_target_backbuffer(mydisplay); 5al_draw_filled_rectangle(x, y, x + W, y + H, al_map_rgba_f(1, 0, 0, 1)); 6al_draw_bitmap(bmp, 100, 100, 0); 7al_draw_filled_rectangle(0, 0, W, H, al_map_rgba_f(1, 1, 0, 0.1)); 8al_flip_display();

About the things being drawn into the Qt widget, its ok, even better to me, I just need to know how to hide the allegro display now.

In addiction the rectangles are being drawn correctly, but the BITMAP just show a white rectangle... It doesn't show the image itself. I made a program to test the image, and it shows ok.

Edit:
I've discovered something, it seems that the problem that is leading to corrupt images being drawn is because the images are being loaded corrupted..
I've checked the same image loaded in a common program, and the image loaded in QT. It seems that the image addon is messing with the image pixels, i dont know why..
it inits ok, I've checked everythings ok, maybe I'm missing something...>:(

Edit:
I've discovered more... It was a long day full of tests guys... so The problem with QT isn't about the image addon that loads the image, its about the bitmap structure..
Even if I create a bitmap, and put pixels to it, it will corrupt, and I don't know why.. :(
To test my theory I used another lib to load the sprite and store it in a matrix of pixels, and I made a function to draw the pixels, just 2 FORs, and thats it.
It worked.. So the problem was really with the bitmap struct.

So, after that I start to mess around with GTK. And I got better results. =) Allegro can draw everything in an openGL widget! =) thats right everything works, and the best: The application quits properly. Now what I have to do is to stop creating the allegro display...

Is There some way to tell allegro to use a openGL context, and not create its own display? If there's a way every gonna be almost perfect! LOL8-)

Go to: