Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » So what's Allegro doing special ...

This thread is locked; no one can reply to it. rss feed Print
 1   2 
So what's Allegro doing special ...
23yrold3yrold
Member #1,134
March 2001
avatar

Okay, I've mentioned this before. I'm making a little program for my class that draws up a window on the second monitor of the computer, which is set up to be displayed at the front of the room via projector. Works fine and dandy, and there's been three versions. One that's just an Allegro GFX_AUTODETECT_WINDOWED, one that's Win32 and OpenGL, and one that's Win32 and uses Allegro to draw the double buffer to the device context via draw_to_hdc(). Those last two are made with the class style WS_POPUP and just drawn to cover the second monitor, making it appear fullscreen (the pure Allegro program I just drag over there :P) since I couldn't figure out how to make it go actually fullscreen on monitor two.

Now, I'm hammering out the final version of this thing after all my experimenting. And the third program setup works the best for me; I can use all the fancy Win32 GUI stuff with the simple Allegro graphics routines. Works great. One catch: it's slow. Like, really slow. Like runs at a quarter the speed of the other two programs slow, at best.

Now I assume this is an issue with hardware acceleration of some kind. The other two programs are fine so I know the machine is (barely) capable. The pure Allegro setup won't work because I need a dialog box or two and it's got the ugly border. The Win32/OpenGL version is okay, but OpenGL is a pain to set up compared to Allegro, plus the Allegro code is already done anyway (the Win32/OpenGL test was actually a completely seperate program).

So, I'd really like to know what Allegro is doing that it works fine in the plain version, but runs so slow in the Win32 version. I'm guessing there's some DirectX of some kind running in the background? How hard would it be to add that as a wrapper between Allegro and Win32? I've never used DirectX. Should I just bite the bullet and do the best I can with OpenGL 2D and Win32, and forget Allegro? I'm hoping someone with insight into Allegro's guts can tell me how hard it is to reproduce what it's doing. Otherwise I'll just go with OpenGL, clumsy as I am with it.

I can try to provide some skeleton code of any of these programs if it would help.

--
Software Development == Church Development
Step 1. Build it.
Step 2. Pray.

GullRaDriel
Member #3,861
September 2003
avatar

Quote:

I can try to provide some skeleton code of any of these programs if it would help.

I will try to make some test if you do so.

"Code is like shit - it only smells if it is not yours"
Allegro Wiki, full of examples and articles !!

Marco Radaelli
Member #3,028
December 2002
avatar

If I'm right, blit_to_hdc() should rely on GDI, not on DirectX.

Do I understand correctly that you have one Allegro application that needs to go fullscreen on the second monitor? So it's not a matter of multiple windows?

I won't have any real solution, though.

[edit]

A quick look at the sources under /win shows that function is in gdi.c, so I guess I'm right.

Milan Mimica
Member #3,877
September 2003
avatar

isn't blit_to_hdc() slow as hell?

Evert
Member #794
November 2000
avatar

Yes.

Thomas Fjellstrom
Member #476
June 2000
avatar

Quote:

isn't GDI slow as hell?

Fixed.

--
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

GullRaDriel
Member #3,861
September 2003
avatar

GDI is always slow as hell.

"Code is like shit - it only smells if it is not yours"
Allegro Wiki, full of examples and articles !!

ImLeftFooted
Member #3,935
October 2003
avatar

I know less than you do about the guts :(.

In case you didn't see my thread and do decide to go the OpenGL route yet don't want to learn OpenGL, you could look at my library:
Thing 1.0 Library
Sprite Thing Example

If you do decide to learn OpenGL, maybe my code will make the learning process easier? I'd try to analyze bitmap.h and bitmap_hardware.cpp

As for getting OpenGL up and running (albeit this isn't that difficult), you can look for that in conf.cpp

Also note this: In Conf.cpp you have included aldumb.h... this file is not needed. I don't think I got around to fixing that line of code before the thread closed :-X

Richard Phipps
Member #1,632
November 2001
avatar

If he switches to OpenGL, we will never see TMS! :-/

23yrold3yrold
Member #1,134
March 2001
avatar

The Masters of the Obvious said:

isn't blit_to_hdc() slow as hell?

isn't GDI slow as hell?

GDI is always slow as hell.

Yes, thank you all. Now, on to how we might rectify it, and more specifically, if anyone knows how Allegro in particular does it ...

--
Software Development == Church Development
Step 1. Build it.
Step 2. Pray.

Marco Radaelli
Member #3,028
December 2002
avatar

Quote:

I can use all the fancy Win32 GUI stuff with the simple Allegro graphics routines. Works great. One catch: it's slow. Like, really slow. Like runs at a quarter the speed of the other two programs slow, at best.

02:20 am idea (so discard it if sounds strange, tomorrow I'll reread it ^_^): Can't you have all the fancy Win32 GUI stuff in a window and have Allegro manage its other? Or even use a pipe to connect a Win32 program to the Allegro one, and you pass anything you get from the Win32 GUI program to the Allegro program through the pipe or some other IPC system?

Milan Mimica
Member #3,877
September 2003
avatar

The are many Allegro GFX drivers, some of theme are GFX_GDI and GFX_DIRECTX, go figure how allegro does it in each of the two cases.

23yrold3yrold
Member #1,134
March 2001
avatar

MR: no, because the whole point is the Allegro window is ugly. :) It's got a border I can't get rid of.

MM: I'd love to "go figure how", but the Allegro source code does not make for light reading the last time I examined it. :p

DD: Can I use that with Win32? I already know OpenGL fairly well, the point is to avoid re-writing old code that already works fine in Allegro. I may just bite the bullet and go that path if I can get it running at a decent speed though ....

--
Software Development == Church Development
Step 1. Build it.
Step 2. Pray.

Thomas Fjellstrom
Member #476
June 2000
avatar

Quote:

Yes, thank you all. Now, on to how we might rectify it, and more specifically, if anyone knows how Allegro in particular does it ...

The GDI driver is slow. Always has been. The faster drivers are all DirectX/DirectDraw.

--
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

Milan Mimica
Member #3,877
September 2003
avatar

In the other words, there is nothing special Allegro doing in GFX_GDI mode.

23yrold3yrold
Member #1,134
March 2001
avatar

That's not very helpful. I didn't ask what Allegro was doing special "in GFX_GDI mode" ...

Screw you guys; I'll just use OpenGL. :P No cookies.

--
Software Development == Church Development
Step 1. Build it.
Step 2. Pray.

Thomas Fjellstrom
Member #476
June 2000
avatar

That's why we mentioned DirectX. IT USES DIRECTX!. I hope you read that this time.

--
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

23yrold3yrold
Member #1,134
March 2001
avatar

Did you read it when I said it in the original post as well? ::) That it uses DirectX I knew already (duh). How I might easily go about doing the same thing to use Allegro in a custom Win32 window without a miserable framerate is kinda the topic. If there's no easy way, then straight up OpenGL it is since I know it better than DirectX. If there is a way, however, I was hoping an Allegro guru could tell me ...

--
Software Development == Church Development
Step 1. Build it.
Step 2. Pray.

Thomas Fjellstrom
Member #476
June 2000
avatar

Oh, threre is, win_set_window will let you give allegro your own window. or win_get_window, and you can MODIFY allegro's.

--
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

23yrold3yrold
Member #1,134
March 2001
avatar

There, now that's information I might actually be able to use. :) I didn't know the actual API made allowances for that sort of thing; guess I'll RTFM and see if it fits ....

--
Software Development == Church Development
Step 1. Build it.
Step 2. Pray.

Thomas Fjellstrom
Member #476
June 2000
avatar

win_set_window HAS to be done before a call to set_gfx_mode iirc.

--
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

Nicol Bolas
Member #9,238
November 2007

Quote:

Oh, threre is, win_set_window will let you give allegro your own window.

If I may offer a counterpoint, I haven't had much luck getting win_set_window to work. Allegro 4.2.2's input system doesn't seem to behave itself very well when you use this. I've also noticed a number of other posts about win_set_window that have shown problems with various bits of Allegro when trying to use it.

It may be that the feature needs work, or has suffered bit rot.

ImLeftFooted
Member #3,935
October 2003
avatar

23yrold23yrold said:

DD: Can I use that with Win32? I already know OpenGL fairly well, the point is to avoid re-writing old code that already works fine in Allegro. I may just bite the bullet and go that path if I can get it running at a decent speed though ....

It runs on windows as well as linux. On linux you must compile with NO_D3D=1.

If by win32 you mean to ask if it can be placed inside a win32 control, then no.

aj5555
Member #9,033
September 2007

GDI is slow for a number of reasons;

  • different colour depths for the screens.. very slow.

  • allegro in 32bit, desktop in 16 bit... very slow.

  • sometimes its a drivers issue (often integrated gfx cards on laptops, the 2nd desktop is always slow.

however.. if you match up the allegro version (32bit/16bit) with the desktop depth, and your DONT have windows spanning 2 desktops, then its wicked fast!

if your data for that screen is already in a suitably packed RGB structure, look at the GDI function StretchDiBits() to get the desktops DC, call GetDC(NULL);

regarding your windows without borders etc, that is easy to do also.. by changing the win32 windows style info in the CreateWindow()

another hack i do, used shared memory, and copy it into another running process like a SDL window.

i have heaps of these multi-screen methods, at least one of them ought to work for you.

Thomas Fjellstrom
Member #476
June 2000
avatar

Quote:

however.. if you match up the allegro version (32bit/16bit) with the desktop depth, and your DONT have windows spanning 2 desktops, then its wicked fast!

Two requests:
1. Please define "Whicked Fast" (especially compared to DDraw and D3D emulated DDraw)
2. Prove it.

--
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

 1   2 


Go to: