Icon in Allegro

0

I'm doing a little game with Allegro 4.2.2 in Code::Bloks 16.01 and I would like to add a custom icon. Searching the Internet I found that adding a resource file to the project could be done, but I only managed to get the executable .exe and the terminal to have the Icon, but the Allegro No! Window.

I found that using windows.h could add the icon to the window. But you can not load windows.h and Allegro at the same time, because they collide. Then I found here that I should load winalleg.h as a replacement for the windows.h , although I do not handle the Windows API very well, I kept searching and I found in the following links how to do it but this does not work for me in allegro
link
link

If I use this, it tells me

error: 'hInstance' was not declared in this scope
Código

HICON hMyIcon = LoadIcon(hInstance, MAKEINTRESOURCE(MAINICON));

If someone can help me, I'd appreciate it

Game.cpp

#include\<allegro.h\>
#include<winalleg.h>

#define V_Ancho 800
#define V_Alto 600

BITMAP *buffer;

int main() {
    allegro_init();
    install_keyboard();
    install_mouse();
    set_color_depth(32);
    set_gfx_mode(GFX_AUTODETECT_WINDOWED,V_Ancho,V_Alto,0,0);
    show_mouse(screen);

    buffer = create_bitmap(V_Ancho,V_Alto);
    buffer = load_bitmap("background.bmp",0);

    blit(buffer,screen,0,0,0,0,V_Ancho,V_Alto);

    while(!key[KEY_ESC]){
    readkey;
    }

    destroy_bitmap(buffer);

    return 0;
}
END_OF_MAIN();

resource.rc

#ifndef _resource_rc
#define _resource_rc

MAINICON    ICON    "ICON 32x32.ico"

#endif // _resource_rc

I leave the project in the following link: link

    
asked by José F 31.08.2017 в 19:15
source

1 answer

0
  • Configure in the codeblocks toolchain so that the program finds the windres.exe file. It is the file responsible for creating the exe with the imaje.

  • Assuming we have an icon called saitama.ico, the paste of the project should look like this:

  • The rc file has the following line:

  • We compiled the project and the debug or release paste will appear. In my case debug. It depends on how the project is configured.

  • Inside the pasta is the exe already with the imaje as you can see. That's all should work.
  • answered by 01.09.2017 в 04:30