Allegro.cc - Online Community

Allegro.cc Forums » Allegro Development » Allegro 4.9.8

This thread is locked; no one can reply to it. rss feed Print
Allegro 4.9.8
Elias
Member #358
May 2000

For X11, if we want to support the classic middle-click selection, we'll have to tap into Allegro's X11 events handler:

http://tronche.com/gui/x/xlib/events/client-communication/selection.html

It works in a kinda stupid way, whenever you paste something, X11 sends an event to the window with the current selection asking it for the data.

Apparently in KDE and Gnome there also is a normal, non-stupid clipboard with persistent data (so the selection won't be gone when you close the window like with the X11 one) - haven't found out yet how to access it though. Maybe we only should support the normal clipboard and not the middle-click one.. but from example code I've seen so far both are entangled somehow :/

--
"Either help out or stop whining" - Evert

Don Freeman
Member #5,110
October 2004
avatar

I have an early version for getting text, in Windows anyway.

a5_clipboard.h:

1///////////////////////////////////////////////////////////////////////////////
2#ifndef A5_CLIPBOARD_H
3#define A5_CLIPBOARD_H
4///////////////////////////////////////////////////////////////////////////////
5#include <allegro5/allegro5.h>
6#include <windows.h>
7///////////////////////////////////////////////////////////////////////////////
8AL_BEGIN_EXTERN_C
9///////////////////////////////////////////////////////////////////////////////
10// These are exposed to the user. Internally, they are implemented in a system
11// specific way, through a file that is compiled only for that system. On a
12// Windows system, that happens to be a5_clipboard_win.c
13// Only the text functions are implemented right now.
14AL_FUNC(bool,al_set_clipboard_text,(const char *));
15AL_FUNC(char *,al_get_clipboard_text,(void));
16AL_FUNC(bool,al_set_clipboard_bitmap,(ALLEGRO_BITMAP*));
17AL_FUNC(ALLEGRO_BITMAP*,al_get_clipboard_bitmap,(void));
18AL_FUNC(bool,al_set_clipboard_sample,(ALLEGRO_SAMPLE*));
19AL_FUNC(ALLEGRO_SAMPLE*,al_get_clipboard_sample,(void));
20///////////////////////////////////////////////////////////////////////////////
21AL_END_EXTERN_C
22///////////////////////////////////////////////////////////////////////////////
23#endif // A5_CLIPBOARD_H
24///////////////////////////////////////////////////////////////////////////////

a5_clipboard_win.c:

1///////////////////////////////////////////////////////////////////////////////
2#include <allegro5/allegro5.h>
3#include "a5_clipboard.h"
4///////////////////////////////////////////////////////////////////////////////
5// Windows specific clipboard routines.
6///////////////////////////////////////////////////////////////////////////////
7bool al_set_clipboard_text( const char *source )
8{
9 char * buffer;
10 HGLOBAL clipbuffer;
11 BOOL ok = OpenClipboard(NULL);
12 if (!ok)
13 return false;
14 EmptyClipboard();
15 if ( !source )
16 source = "\0";
17 clipbuffer = GlobalAlloc(GMEM_DDESHARE, strlen(source)+1);
18 if ( clipbuffer == NULL )
19 return false;
20 buffer = (char*)GlobalLock(clipbuffer);
21 strcpy(buffer, source);
22 GlobalUnlock(clipbuffer);
23 SetClipboardData(CF_TEXT,clipbuffer);
24 CloseClipboard();
25 return true;
26}
27///////////////////////////////////////////////////////////////////////////////
28char * al_get_clipboard_text( void )
29{
30 BOOL ok = OpenClipboard(NULL);
31 char * buffer = NULL;
32 HANDLE hData;
33 if (!ok)
34 return NULL;
35 hData = GetClipboardData( CF_TEXT );
36 buffer = (char*)GlobalLock( hData );
37 GlobalUnlock( hData );
38 CloseClipboard();
39 return buffer;
40}
41///////////////////////////////////////////////////////////////////////////////

Do you think I should add an option to limit the amount of text that is returned?
I still haven't figured how to get unicode text (like from character map) to show up correctly...even using ALLEGRO_USTR. Any suggestions?

--
"Everyone tells me I should forget about you, you don’t deserve me. They’re right, you don’t deserve me, but I deserve you."
"It’s so simple to be wise. Just think of something stupid to say and then don’t say it."

Thomas Fjellstrom
Member #476
June 2000
avatar

Windows unicode is likely UCS-2, or UTF-16 (whatever), allegro deals in UTF-8, you may have to use uconvert (if peter kept it around) to convert to utf8.

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

Evert
Member #794
November 2000
avatar

Quote:

Do you think I should add an option to limit the amount of text that is returned?

Arbitrary limits are evil, so no, you shouldn't. But who is responsible for freeing the pointer returned by al_get_clipboard_text? If it's a static buffer that changes the next time GetClipboardData/GlobalLock are called, you should strdup it.

Quote:

I still haven't figured how to get unicode text (like from character map) to show up correctly...even using ALLEGRO_USTR. Any suggestions?

It should work AFAIK if you use a char * pointing to a UTF8 encoded string. Doesn't that work for you? Have you checked the encoding?

Don Freeman
Member #5,110
October 2004
avatar

Ok...I'll look at it later. Thanks for the comments.:D

--
"Everyone tells me I should forget about you, you don’t deserve me. They’re right, you don’t deserve me, but I deserve you."
"It’s so simple to be wise. Just think of something stupid to say and then don’t say it."

axilmar
Member #1,204
April 2001

Demo not working for me (VS 2009). It stops when trying to load the sound file "big_explosion.ogg", although the file is in the proper place.

Trent Gamblin
Member #261
April 2000
avatar

Do you have OGG vorbis support compiled in? You need libogg and libvorbis for that.

axilmar
Member #1,204
April 2001

Quote:

Do you have OGG vorbis support compiled in? You need libogg and libvorbis for that.

I don't think so. Is it a prerequisite for Allegro 5? or is it only for the demo?

Thomas Fjellstrom
Member #476
June 2000
avatar

Its a prerequisite for the demo, and any sound playing example you want to be able to load ogg.

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

axilmar
Member #1,204
April 2001

Ok, libogg and libvorbis downloaded, compiled and installed.

What now? how do I add support for it for the demo? or is it automatic?

EDIT:

The code that fails is this one:

/* Function: al_load_sample
 */
ALLEGRO_SAMPLE *al_load_sample(const char *filename)
{
   const char *ext;

   ASSERT(filename);

   ext = strrchr(filename, '.');
   if (ext == NULL)
      return NULL;

The filename is "c:\dev\allegro-4.9.8\demo\data\sfx\big_explosion.ogg".

The function strrchr returns null, and therefore the sample can not be loaded.

Thomas Fjellstrom
Member #476
June 2000
avatar

You re ran cmake for allegro, and re compiled it right?

Quote:

The function strrchr returns null, and therefore the sample can not be loaded.

It can't return NULL in that case, it'll find the last . and return that. You must be mistaken on what is actually going on there.

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

axilmar
Member #1,204
April 2001

Nope. I am about to do that again.

EDIT:

Bleh, I built libvorbis but cmake can't find it, although I added the correct paths...it's late, and I am tired of the the command line already. The command line sucks. No demo for me...

kenmasters1976
Member #8,794
July 2007

Which Addons doesn't require any external libraries?. Right now I have only built the core Allegro lib and the Primitives addon, but I'm thinking into building the rest.

Don Freeman
Member #5,110
October 2004
avatar

I was wondering if I could get some people to test this for me. I've noticed different behavior on two different machines, both with the same OS (Windows Server 2008). I am guessing this is a driver issue, maybe ATI Vs. nVidia . The main problem is that my ATI driver (at least in my mind so far) is causing this to fail when loading the Terrain.png file. I can not seem to get debug info from it either. The debugger says that there are no symbols for it...allegro was compiled with debug options as well as the program, so I assume that it is a failure in one of the other modules, perhaps something from DirectX. I can switch the Terrain.png to be a grid of 10x10 tiles and it works. It is almost as if it is running out of memory, but that can't be...I have over a gig in each machine and plenty of free memory. I am thinking it has something to do with texture memory and the way the two (nVidia and ATI) handle that. I am just trying to figure what the main deal is here. I've also noticed that on my ATI system, the drawing functions look different as well. The drawing functions look fine in other programs I've made between both systems, so that is weird. It is the exact same program, but the al_draw_rounded_rect looks different on both systems. It looks correct on my nVidia card, but the rounded rects look slightly scewed. If you decide to test this for me, please let me know what system (OS and version) and what kind of video card type and video memory your system has. Note: this was tested with Allegro-4.9.8, so that is why I am posting it here. I want to see if this is a bug with Allegro, or something with ATI or nVidia drivers.

Here is the Visual Studio 2008 project files, source code, and data needed.
Here is the 10x10 tile grid file that worked on the ATI system. If you would, please rename the original Terrain.png and put this to data/gfx/terrain.png in the programs search path. Please test with both versions and let me know if one worked and not the other, or if both worked/failed for you as well.

For those who do test it, spacebar pops up the terrain to 'select' (enter tile brush selection mode) and esc exits the program. When in 'select' mode, arrow keys move the selection cursor around, enter selects a tile brush, and esc exits that mode.

Thanks guys.:-*

Edit:
Here is a compiled version for Windows (using Visual Studio 2008).

The standard no screen shot, no download...so here ya go:
Main screen:
http://www.allegro.cc/files/attachment/598032
Tile brush select mode:
http://www.allegro.cc/files/attachment/598033

--
"Everyone tells me I should forget about you, you don’t deserve me. They’re right, you don’t deserve me, but I deserve you."
"It’s so simple to be wise. Just think of something stupid to say and then don’t say it."

MiquelFire
Member #3,110
January 2003
avatar

Um, yea, I'll test when I feel like downloading the dlls

---
Febreze (and other air fresheners actually) is just below perfumes/colognes, and that's just below dead skunks in terms of smells that offend my nose.
MiquelFire.red
If anyone is of the opinion that there is no systemic racism in America, they're either blind, stupid, or racist too. ~Edgar Reynaldo

Don Freeman
Member #5,110
October 2004
avatar

Anyone?! I want to see if this is something with the way the new API deals with hardware calls, or if it is a driver issue...and if it can be fixed. Maybe this could be addressed in the FAQ or other area.::)

--
"Everyone tells me I should forget about you, you don’t deserve me. They’re right, you don’t deserve me, but I deserve you."
"It’s so simple to be wise. Just think of something stupid to say and then don’t say it."

Neil Walker
Member #210
April 2000
avatar

Can you statically link everything or point me in the direction of the allegro dlls? I've got the depencies from here http://www.allegro.cc/forums/thread/599504/798701#target

But they only include non-allegro stuff.

Neil.
MAME Cabinet Blog / AXL LIBRARY (a games framework) / AXL Documentation and Tutorial

wii:0356-1384-6687-2022, kart:3308-4806-6002. XBOX:chucklepie

Trent Gamblin
Member #261
April 2000
avatar

allegro5.org has binaries.

Trezker
Member #1,739
December 2001
avatar

What's the... purpose of http://allegro5.org ?
The FAQ doesn't seem to be working, and there's no about page.
What do you get for creating an account?

Thomas Fjellstrom
Member #476
June 2000
avatar

Right now its purpose is news on Allegro 5 and Binaries. We (trent and I) don't really have much news to post...

Later on it will probably just be turned into an alias for liballeg.org once allegro 5 is released.

The FAQ seems to be working fine though. Its just that there are no questions ;)

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

Elias
Member #358
May 2000

Trent registered liballeg.org and allegro5.org.

I think it would be best if we made those the official addresses. "alleg.sf.net" ties us to SF (probably Allegro's web hosting will never change to anything else - but still no reason to have it as official address). Right now the "official" address is still talula.something.really.long.nobody.can.remember - which is kinda stupid.

--
"Either help out or stop whining" - Evert

Trezker
Member #1,739
December 2001
avatar

Yeah I like allegro5.org, has a good solid feel to it.
The design of it right now really looks like a place where you should be able to find all the resources you need with just one or two clicks. But I don't think you do quite yet, basically because some things people need haven't been written yet.

kenmasters1976
Member #8,794
July 2007

The program crashes on my machine and I don't have some of the needed addons installed to try and build it myself on MinGW. Sorry.

Trent Gamblin
Member #261
April 2000
avatar

If anyone wants to work on the FAQ or any other areas of allegro5.org let me know. I can handle the binary releases.

Neil Walker
Member #210
April 2000
avatar

Don said:

Anyone?!

Right I've got 28 dlls in my folder now! I remember the days when you could ship an exe and a dat ;)

Anyway, as soon as I start the program I get an exception. Here is my directory folder in case I've missed something:

a5_acodec-4.9.8.dll
a5_color-4.9.8.dll
a5_font-4.9.8.dll
a5_iio-4.9.8.dll
a5_memfile-4.9.8.dll
a5_primitives-4.9.8.dll
a5_ttf-4.9.8.dll
allegro-4.9.8.dll
freetype6.dll
jpeg62.dll
kcm_audio-4.9.8.dll
libFLAC++.dll
libFLAC.dll
libpng12.dll
librle3.dll
libsndfile-1.dll
MapEditorEnhanced.exe
ogg.dll
ogg_d.dll
tmp.txt
vorbis.dll
vorbisenc.dll
vorbisenc_d.dll
vorbisfile.dll
vorbisfile_d.dll
vorbis_d.dll
zlib1.dll

Neil.
MAME Cabinet Blog / AXL LIBRARY (a games framework) / AXL Documentation and Tutorial

wii:0356-1384-6687-2022, kart:3308-4806-6002. XBOX:chucklepie



Go to: