0

I try to use this: https://github.com/allefant/algif5 but this doesn't work.

#include "algif.h"

char const* pathBoss1 = "boss1.gif";
ALGIF_ANIMATION *boss1Gif = NULL;
boss1Gif = algif_load_animation(pathBoss1);
// in a function: 
al_draw_bitmap(algif_get_bitmap(bossGif, al_get_time()), boss.x, boss.y, 0);

It throws lots of bugs like this

Severity Code Description Project File Line Suppression State Error LNK2019 unresolved external symbol _algif_get_bitmap referenced in function "void __cdecl drawBoss(struct Boss &,struct ALGIF_ANIMATION *)" (?drawBoss@@YAXAAUBoss@@PAUALGIF_ANIMATION@@@Z) LearnAllegro C:\Users\User\source\repos\LearnAllegro\LearnAllegro\LearnAllegro.obj 1

As if the library was not found. (I put all the downloaded files into ProjectName>ProjectName as there are other .h files there)

What should I do?

John
  • 105
  • 10

2 Answers2

1

There is no official library - instead you need to add algif.c, bitmap.c, gif.c and lzw.c to your source files.

Alternatively if you know how to create a library you can create a library out of those 4 files and then link against that library.

allefant
  • 69
  • 1
  • 3
  • I put these files in projectName > projectName and added #include "algif.h". I get these errors: unresolved external symbol _algif_load_animation referenced in function _mainLearnAllegroC:\Users\User\source\repos\LearnAllegro\LearnAllegro\LearnAllegro.objunresolved external symbol _algif_destroy_animation referenced in function _main LearnAllegroC:\Users\User\source\repos\LearnAllegro\LearnAllegro\LearnAllegro.obunresolved external symbol_algif_get_bitmap referenced in function "void__cdecldrawBoss(structBoss &,struct ALGIF_ANIMATION *)"(?drawBoss@@YAXAAUBoss@@PAUALGIF_ANIMATION@@@Z) Learn... – John Jan 25 '18 at 16:40
  • Do I need to add some other "include" or only this is needed: #include "algif.h"? – John Jan 25 '18 at 16:40
  • If I add all "include" like this: #include "algif.h" #include "algif.c" #include "bitmap.c" #include "gif.c" #include "lzw.c" – John Jan 25 '18 at 16:45
  • ..then there are some other bugs: 'initializing': cannot convert from 'void *' to 'ALGIF_BITMAP *'LearnAllegro c:\users\user\source\repos\learnallegro\learnallegro\bitmap.c4 ErrorC2440'=': cannot convert from 'void *' to 'uint8_t *'LearnAllegroc:\users\user\source\repos\learnallegro\learnallegro\bitmap.c7 ErrorC2440'initializing': cannot convert from 'void *' to 'ALGIF_ANIMATION *' LearnAllegroc:\users\user\source\repos\learnallegro\learnallegro\gif.c 69 ErrorC2440'=': cannot convert from 'void *' to 'ALGIF_FRAME *'LearnAllegroc:\users\user\source\repos\learnallegro\learnallegro\gif.c158 – John Jan 25 '18 at 16:46
  • make sure to compile those files as C and not as C++ – allefant Jan 25 '18 at 17:10
  • So my program is in C++ and this extension is in C. What exacly should I do to use it? – John Jan 25 '18 at 17:21
0

The library did not work for me and I ended up inputting gif frames separately. This for loop I used might help you: A simplified version:

for (int i = 0; i < maxFrameBoss1; i++) {
    std::string filename;
    filename = "boss1//frame_" + std::to_string(i) + "_delay-0.03s.png";


    boss1Image[i] = al_load_bitmap(filename.c_str());
    if (!boss1Image[i]) {
        fprintf(stderr, "failed to create boss1Image bitmap!\n");
        return -1*i;
    }
}

Make sure to include this at the beginning of your program:

#include <iostream>
#include <string>
John
  • 105
  • 10