|
Allegro 4 - allegro_icon |
Andrew Gillett
Member #15,868
January 2015
|
I realise this is pretty oldschool, but - the Windows page of the Allegro 4 manual says: "When creating the main window, Allegro searches the executable for an ICON resource named "allegro_icon". If it is present, Allegro automatically loads it and uses it as its application icon; otherwise, Allegro uses the default IDI_APPLICATION icon." I have an icon of that name in the resources, and it displays on the EXE, but it doesn't get displayed as the application icon. The relevant code in wwnd.c is: It appears that this is returning null. Please let me know if there is a better place to post this. |
torhu
Member #2,727
September 2002
|
What does your .rc file look like? |
Andrew Gillett
Member #15,868
January 2015
|
The relevant line from the .rc file looks like this: allegro_icon ICON "build\\icon256.ico" My current workaround is: HICON i = LoadImage(nullptr, "icon256.ico", IMAGE_ICON, 256, 256, LR_LOADFROMFILE|LR_SHARED); (I have yet to discover how to create an icon file containing icons of different sizes - or rather, MSVC's icon editor lets me do that, but can't see how to actually import bitmaps into icons using that. Currently using FormatFactory for conversion, but that doesn't seem to allow multiple icons per .ICO) |
torhu
Member #2,727
September 2002
|
I'm not sure why that wouldn't work, looks OK to me. For creating icon files I used to use a program called IcoFX, I think 1.6.4 was the last free version of it. |
ZoriaRPG
Member #16,714
July 2017
|
|
Andrew Gillett
Member #15,868
January 2015
|
Unfortunately that didn't work. |
ZoriaRPG
Member #16,714
July 2017
|
In MSVC, hold Control+Shift+E This will shift you into 'Resource View'. Open the tree for your project, and then the icon.cr tree, and the icon tre under that. Then, check if he icon resource is present. If it is, right click it, and select 'Insert Icon'. That will allow you to view all of the icon modes, and edit them right there in MSVC. You should be able to copy an image in a gfx programme, and paste it into an icon type, there. You can probably skip all of that extraneous code to load the icon in your game, and use this instead. I hope that this helps. (Screenshot, attached) <img src="http://zoriarpg.com/msvc/msvc-resource-view.png"> Someone remind me, please.... WTH is the correct tag format to embed an image? I tried a base <img> tag pair, and several forms of hypertext markup code. None of it worked?! ...or is it just the attachment, as I had thought but my file size is too large?
|
Andrew Gillett
Member #15,868
January 2015
|
This is what mine looks like (except I have now combined all 3 icons into one .ICO file): |
ZoriaRPG
Member #16,714
July 2017
|
Andrew Gillett said: except I have now combined all 3 icons into one .ICO file Does this mean that you have solved this issue? You should just be able to paste the icon data directly into MSVC, without the need of any external icon editor. If your build isn't generating the icons where they belong, then check your .vcproj file, too. You want to see an entry similar to this: <File RelativePath="C:\path_to\icon.rc" > </File> That is, ensure that the resource script is properly embedded into the project. For the sake of completion, you can also embed an icon in using allegro_icon, like this: https://github.com/ArmageddonGames/ZeldaClassic/blob/2.55/zc_icon.c That's for X-Windows (Unix/Linux).
|
Peter Hull
Member #1,136
March 2001
|
I tried and it seemed to work for me. allegro_icon ICON icon.ico and the C code (it's been ages since I did any allegro 4) 1#include <allegro.h>
2
3int main(int argc, char *argv[])
4{
5 (void) argc;
6 (void) argv;
7 allegro_init();
8 install_timer();
9 install_keyboard();
10 set_gfx_mode(GFX_AUTODETECT_WINDOWED, 320, 240, 0, 0);
11 rest(5000);
12 set_gfx_mode(GFX_TEXT, 0, 0, 0, 0);
13 return 0;
14}
15END_OF_MAIN();
I attached the icon I used. I find ImageMagick is a good way to create multi-resolution icons, if you have the images you can just do: magick image16x16.png image32x32.png image48x48.png icon.ico and if you are lazy you can even get IM to create the individual images by resizing a larger master image. EDIT: Just thinking, can you attach your icon? I'm wondering if LoadIcon is a bit picky on the size/colour depths it accepts because it's an 'old' API function.
|
Andrew Gillett
Member #15,868
January 2015
|
The entry in the vcxproj file looks like this: <ItemGroup> The icons display correctly on the EXE file but I still need my workaround for them to be used as the application icons while it's running. You can find my icon file here: |
Peter Hull
Member #1,136
March 2001
|
Your icon worked fine for me. Maybe it's related to the high dpi stuff? I am at a loss.
|
|