I wanted to configure my game app to have an icon
I mean only the icon of the executable on windows
I saw this link on the wiki about MSVC but i dont understand it
http://wiki.allegro.cc/index.php?title=Set_a_windows_icon#Compiling_with_MSVC
Can anyone give an example?
Thanks
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.
]]>Shall i add the lines of code with notepad?
Because in visual studio, it wont let you write on .rc files.
I tried with notepad adding your lines of code, added a my_icon.ico
in the project folder and in the debug folder, added the #include
<resource.rc> and <resource.h> but the project didnt succeed the build.
Am I missing something?
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:
IDI_ICON1 ICON "my_icon.ico"
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
]]>I dont know i get this:
{"name":"606512","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/d\/1\/d1b08a7b10a0c706107ca375817581be.png","w":1280,"h":180,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/d\/1\/d1b08a7b10a0c706107ca375817581be"}
And where do you put your code, inside your .rc file or .cpp?
I copy paste it and i get what you see in the image
What are the permissions on this resource.rc file? And do you have extensions hidden, so it's actually "resource.rc.txt"?
]]>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
The permissions are all granted
{"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"}
]]>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.
]]>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.)
]]>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.
]]>I thought there was an icon utility in A4?
]]>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).
]]>Do you not use icons (ico) for Linux? I've not really messed with them before.
]]>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.)
]]>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.
]]>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.
The DIB structure (bmp, cur, ico) isn't RIFF format. The ANI animated cursor is though.
]]>There is no resource.rc and i found out why it said still open.
I had notepad++ and closed all tabs then closed.
Still same problem, did exactly as you said.
{"name":"606515","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/3\/e\/3efb5f8699f4222930bc016c7b044d79.png","w":625,"h":499,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/3\/e\/3efb5f8699f4222930bc016c7b044d79"}
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 ::(
]]>I knew there should be a tools like this on the internet. What bout this? http://www.icoconverter.com/ Not tested...
]]>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.
]]>I dont really get it.
I get so many errors for the icon.
But i think it has to do with MSVC 2012 as you guys say it is easy!
{"name":"606517","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/a\/a\/aa74f9a82966209ea3c2814dde578767.png","w":1280,"h":961,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/a\/a\/aa74f9a82966209ea3c2814dde578767"}
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.
]]>Ok, at least less work
But the more i know the better it is!
Though i remember making C# programs icons very easy.
Here i have to add allegro coding lines,
but how comes there are allegro commands when that has nothing to do with allegro?
Anyone can find any video who shows how to do it?
I dont have time to waste on an icon!
Meanwhile enjoy this video...
http://www.youtube.com/watch?NR=1&feature=endscreen&v=WAnERyiaYXU
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.
]]>Copy paste the code there, dont forget the objects.h to include and that is all.
]]>Yeah, icons are a great thing to play with, but you have to remember (as pointed out here) that icons are Windows only. If you are making a book for C++ and Allegro then you want to keep OS Specific things to a minimal or leave them out all together. Depending on how you are aiming the book (a person that never programmed a day in their life or a person that has programmed before) you would have to decide "Am I teaching just Allegro or C++ too (or other language)?" If you are teaching a person who has never programmed you will have to teach them to install a compiler for their OS (Windows/Mac/Linux), have a primer that covers the basics of C++ (int/char/float, varables) and the main concepts used in the book (classes/vectors/maps/etc) and then get into Allegro. If you are doing it for someone that is experienced then just put a paragraph or two explaining they need to know how to install a compiler for their OS of choice and know C++ before starting the book then you can just focus on Allegro and the games.
]]>Actually, i have never used any other OS except windows, so i made it for visual studio 2012 and added some links how to download express version. I dont know about other OS and the readers have to find their way through, since i don't know any other OS.
I have added a chapter about C++ so they can start with it. It will be quite long and i have not included it in the Allegro 5 chapters, normally, but as a bonus material at the beginning of the book. Experts on C++ normally can find or refresh things or can go directly to the allegro 5 chapters.
I was even thinking to make 2 books.
One for game programming and one for game design where i add the full game.
I dont know, but i want to keep it nice and simple.
A book would be awesome in 100 pages at max.
Here's an msvc 9 project, complete with icon. Remember to replace the .lib file with the correct one if you want to build with another version of msvc.
]]>It doesn't work. Here is what i get after compiling
{"name":"606541","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/1\/f\/1f175b0fa50e34fc927e30d9e60224da.png","w":1280,"h":688,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/1\/f\/1f175b0fa50e34fc927e30d9e60224da"}
That's not compiler messages, it's about the conversion of the project configuration. It's all warnings and no errors, so you could try building and see if it works.
]]>This is what i get when i try to build it
{"name":"606542","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/0\/b\/0bbe4592180f0fab8759d05668a5417d.png","w":1280,"h":985,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/0\/b\/0bbe4592180f0fab8759d05668a5417d"}
Are you using the Allegro headers from the zip file I uploaded? Looks like there is a problem with the int64_t type. It's defined in almsvc.h. Just change it to be defined unconditionally and see if that helps.
]]>What does defined unconditionally mean?
]]>That there is no "if something" in front of it. It's always defined.
]]>Actually, i have never used any other OS except windows, so i made it for visual studio 2012 and added some links how to download express version. I dont know about other OS and the readers have to find their way through, since i don't know any other OS.I have added a chapter about C++ so they can start with it. It will be quite long and i have not included it in the Allegro 5 chapters, normally, but as a bonus material at the beginning of the book. Experts on C++ normally can find or refresh things or can go directly to the allegro 5 chapters.I was even thinking to make 2 books.
One for game programming and one for game design where i add the full game.
I dont know, but i want to keep it nice and simple.
A book would be awesome in 100 pages at max.
Game Design is covered on numerous sites (GDNet, Flipcode's Archive site, and Gamasutra for example). As for the OS, drop out any OS specific code (Win32API/DirectX) and keep focus on C++ and Allegro only otherwise you may lose a large chunk of Allegro users as most I believe are Linux or Mac now (I only use Windows to play games (Guild Wars, Steam games, etc) and do all my coding in Ubuntu.
]]>