|
This thread is locked; no one can reply to it. |
1
2
|
Game icon |
AleX-G Squadron
Member #13,593
October 2011
|
I wanted to configure my game app to have an icon http://wiki.allegro.cc/index.php?title=Set_a_windows_icon#Compiling_with_MSVC Can anyone give an example? www.anothergames.com |
Neil Roy
Member #2,229
April 2002
|
Create resource.rc put this in it: ALLEGRO_ICON ICON "my_icon.ico" Create resource.h put this in it: #define IDI_MYICON 1 Add both files to your project, include the header and compile and you should have a nice icon. Incidentally, I like to use the free software IcoFX to create my icons with. Great little program will create all the sizes you need and save as a proper icon. Edit: Hmph, IcoFX USED to be free, looks like they made v2 pay. Glad I downloaded it when I did. Edit2: You can download the old FREEWARE version (1.6.4). I updated the above link to point to it instead. They made a new version 2 and are charging $50 for it... from FREEWARE to $50+?!?! isane. This is a good reason why I like to back up things I download onto DVD rather than relying on them always being there online. I think I'll buy a solid state drive and start backing up more often. --- |
AleX-G Squadron
Member #13,593
October 2011
|
Shall i add the lines of code with notepad? www.anothergames.com |
torhu
Member #2,727
September 2002
|
You can open .rc files in msvc by right-clicking and selecting "View Code" (I'm using msvc 9 express). You don't need a header file, you just need the RC. This is enough: Put the .ico in the same folder as the .rc. The header file is for turning the name constants into numbers, but you can load resources using the name string directly too (see below). Add the file to the solution in msvc, which will automatically compile it into a .res file and link with it when building your project. As far as I can tell, Allegro 5 doesn't have the automatic icon loading that Allegro 4 had. So unless you do some extra work, the icon will only be used by Explorer. Explorer just loads the first icon resource it finds in the file. But it won't become the window icon automatically. I use this code for setting the window icon using the same icon resource: #ifdef ALLEGRO_WINDOWS HWND winhandle; HICON icon; #endif And later: #ifdef ALLEGRO_WINDOWS icon = LoadIcon(GetModuleHandle(NULL), "IDI_ICON1"); if (icon) { winhandle = al_get_win_window_handle(display); SetClassLongPtr(winhandle, GCLP_HICON, (LONG_PTR)icon); SetClassLongPtr(winhandle, GCLP_HICONSM, (LONG_PTR)icon); } #endif You have to create the display first, obviously |
AleX-G Squadron
Member #13,593
October 2011
|
I dont know i get this: And where do you put your code, inside your .rc file or .cpp? www.anothergames.com |
Arthur Kalliokoski
Second in Command
February 2005
|
What are the permissions on this resource.rc file? And do you have extensions hidden, so it's actually "resource.rc.txt"? They all watch too much MSNBC... they get ideas. |
AleX-G Squadron
Member #13,593
October 2011
|
There is no .txt at the end and i usually get something like Opened in another text editor when there is no text editor opened {"name":"606513","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/e\/9\/e9049b308f6a1623d4be1c4c6f08322f.png","w":353,"h":80,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/e\/9\/e9049b308f6a1623d4be1c4c6f08322f"} I also get this when i try to click on it {"name":"606514","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/a\/d\/ad8f7052be5418a216e18c703ce14285.png","w":492,"h":246,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/a\/d\/ad8f7052be5418a216e18c703ce14285"} www.anothergames.com |
Neil Roy
Member #2,229
April 2002
|
You need to rename it to "resource.rc" and get rid of that (1). That means you have two versions of it in the same folder, choose one of them and add that line to it and delete the other. Also, if it states it is already open, you probably still have an editor open that you used to add the line with. Save it and then close the editor so you only have MSVC running. Or switch to using something like CodeBlocks and a GNU compiler. --- |
Trent Gamblin
Member #261
April 2000
|
I use IcoFX too. $50 just for that? That's unreasonably high. I'll just continue using the free version I have while I can, then find something else (either free or not insanely priced just to convert icons.)
|
Neil Roy
Member #2,229
April 2002
|
I was curious about the file format for .ICO files, I wonder how hard it would be to make a simple conversion program using Allegro to create icons for people. Wouldn't have to be feature rich. --- |
Arthur Kalliokoski
Second in Command
February 2005
|
I thought there was an icon utility in A4? They all watch too much MSNBC... they get ideas. |
Trent Gamblin
Member #261
April 2000
|
The only unique feature of IcoFX (though there are probably other programs that do this) is it can store any number of different sized icons in the same .ico file. I usually store a 48x48 (XP) and 256x256 (Vista & 7).
|
Specter Phoenix
Member #1,425
July 2001
|
Do you not use icons (ico) for Linux? I've not really messed with them before.
|
Trent Gamblin
Member #261
April 2000
|
No, they're mainly a Windows thing. Only other place I've ever seen them is website icons (the little ones in the url bar.)
|
LennyLen
Member #5,313
December 2004
|
NiteHackr said: I was curious about the file format for .ICO files, I wonder how hard it would be to make a simple conversion program using Allegro to create icons for people. Wouldn't have to be feature rich. An .ico file is pretty much just a .bmp file with a flag set in the header. I have functions written for A4 for loading/saving .cur files which could be easily adapted since .cur is also the same format.
|
Thomas Fjellstrom
Member #476
June 2000
|
LennyLen said: An .ico file is pretty much just a .bmp file with a flag set in the header. I have functions written for A4 for loading/saving .cur files which could be easily adapted since .cur is also the same format. Gotta love the RIFF format. AVI's are also RIFF[1]. But they don't share near as much of the structure as bmp, ico, and cur's do. References
-- |
LennyLen
Member #5,313
December 2004
|
The DIB structure (bmp, cur, ico) isn't RIFF format. The ANI animated cursor is though.
|
AleX-G Squadron
Member #13,593
October 2011
|
There is no resource.rc and i found out why it said still open. Still same problem, did exactly as you said. www.anothergames.com |
Thomas Fjellstrom
Member #476
June 2000
|
LennyLen said: The DIB structure (bmp, cur, ico) isn't RIFF format. The ANI animated cursor is though Damn I don't know what in was thinking ::( -- |
AMCerasoli
Member #11,955
May 2010
|
I knew there should be a tools like this on the internet. What bout this? http://www.icoconverter.com/ Not tested...
|
torhu
Member #2,727
September 2002
|
I use IcoFX 1.6.4, which is free. AleX-G Squadron, what exactly is your current problem? Maybe there's something new about the way msvc 11 handles .rc files, but I can't see why you shouldn't be able to just add the .rc file to the solution and build. |
AleX-G Squadron
Member #13,593
October 2011
|
I dont really get it. www.anothergames.com |
Specter Phoenix
Member #1,425
July 2001
|
From what I remember of MSVC++ it has always been fairly easy to include them assuming you are meaning something like this from 2006 ( http://www.gamedev.net/topic/379876-setting-the-compiled-programs-icon-in-visual-studio/ ). Though, if this is something for you book, then you shouldn't be worrying about this as Icons again have nothing to do with C++ nor Allegro.
|
AleX-G Squadron
Member #13,593
October 2011
|
Ok, at least less work Anyone can find any video who shows how to do it? Meanwhile enjoy this video... www.anothergames.com |
torhu
Member #2,727
September 2002
|
If you upload your source code and everything needed to build your game, I can make an msvc 9 project that you can probably open with msvc 11. You don't need to upload Allegro, just tell me exactly what files I need to link with. |
|
1
2
|