Recent

Author Topic: Allegro.pas and Canvas  (Read 5012 times)

eoneuk

  • New member
  • *
  • Posts: 7
Allegro.pas and Canvas
« on: December 14, 2014, 02:07:03 pm »
Is it possible to use Allegro.pas to draw either pixels or shapes directly on a canvas?
I can use Allegro, but it is in its own separate window.  I want to use it within a form.

Was not successful in finding any information either on the internet or in this forum.
 Any help or guidance will be appreciated.


Ed

User137

  • Hero Member
  • *****
  • Posts: 1791
    • Nxpascal home
Re: Allegro.pas and Canvas
« Reply #1 on: December 14, 2014, 05:11:02 pm »
I can't imagine that it would. Allegro was originally made for games, and Canvas based techniques are nearly always too slow for that. I don't know details of the pascal's allegro, if it is just a wrapper to old DOS-based library?

Never

  • Sr. Member
  • ****
  • Posts: 409
  • OS:Win7 64bit / Lazarus 1.4
Re: Allegro.pas and Canvas
« Reply #2 on: December 14, 2014, 05:56:14 pm »
i'm pretty sure you can do what you want since Allegro supports several different types of bitmaps
[ http://allegro-pas.sourceforge.net/docs/4/intro.html ]
@Ñuño Martínez can assist you more
have a look here
[ http://www.pascalgamedevelopment.com/showthread.php?5100-Show-a-bitmap-on-a-TPaintBox&highlight=allegro+canvas ]
Νέπε Λάζαρε λάγγεψων οξωκά ο φίλοσ'ς αραεύσε

Ñuño_Martínez

  • Hero Member
  • *****
  • Posts: 1186
    • Burdjia
Re: Allegro.pas and Canvas
« Reply #3 on: December 18, 2014, 11:15:03 am »
Somebody called me?  ::)

About Allegro.pas 4
In short: Yes, it is possible.

The long answer:
There's an example in subdirectory "examples/lazarus" but it is not fast because it just copies each pixel.  Actually that example is very uneficent and I'm sure it can be improved a lot (IIRC there are a way to write directly in to the TImage data, which should be lot faster as you can avoid screen update until you finished the work).

Theoretically, there are some Allegro's functions that allows to "transport" an Allegro bitmap to a structure that can be used directly by desktop API.  Unfortunately I wasn't able to make it run on Free Pascal, and I have no idea why.  Also, it would force to use OS dependent code (it's not the same Windows than Linux than MacOS...) and I really hate to use and write OS dependent code, so I didn't tried again.

About Allegro.pas 5 beta (and SVN)
Actually I have no idea if it's possible.  Allegro 5 defines a whole new API, that includes multiple window management, and I'm not familiar and comfortable with it (that explains why Allegro.pas 5 is still unfinished and unstable),  Anyway, I think it should be possible.  Allegro 5 allows to use OpenGL, so if you create an OpenGL context in your TForm may be you're able to use Allegro.pas to upload textures to the OpenGL server.

A sort of disclaimer
I really want to work more on Allegro.pas (both versions 4 and 5), but sadly I'm very busy right now.  Anyway I do some upgrades time to time uploading them to the SVN repository (TRUNK for version 4, BRANCHES/5 for version 5), and I'm glad that people uses it and asks about problems, because it helps me to improve the library.  So keep up the work, and may be we found an improvement and a new version of Allegro.pas would be released soon.
« Last Edit: December 18, 2014, 11:17:47 am by Ñuño_Martínez »
Are you interested in game programming? Join the Pascal Game Development community!
Also visit the Game Development Portal

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 11455
  • FPC developer.
Re: Allegro.pas and Canvas
« Reply #4 on: December 18, 2014, 12:21:44 pm »
What is the attraction of Allegro? I never really understood that.

Ñuño_Martínez

  • Hero Member
  • *****
  • Posts: 1186
    • Burdjia
Re: Allegro.pas and Canvas
« Reply #5 on: December 18, 2014, 05:16:38 pm »
I'm not sure that I've understood your question.

Allegro 4 had an "old school API" (bitmaps, sprites, MIDI ...), and it's simpler than SDL. Also deployment is simpler as only one dynamic library file is needed.

Allegro 5 has a modern style API (hardware accelerated graphics, state-based implementation, event-based responses...), but also simpler than SDL (in my humble opinion, but I still prefer the old API).  Deployment, though, is much more complex on Windows as there are different compilation options than results on different dynamic library file distribution (different quantity and naming).
Are you interested in game programming? Join the Pascal Game Development community!
Also visit the Game Development Portal

 

TinyPortal © 2005-2018