Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Can you integrate allegro into an sfml window?  (Read 753 times)

0 Members and 1 Guest are viewing this topic.

Me-Myself-And-I

  • Jr. Member
  • **
  • Posts: 65
    • View Profile
Can you integrate allegro into an sfml window?
« on: May 13, 2024, 02:46:11 pm »
Hey, everybody.

I've been thinking sfml isn't up to the task for video playing so I thought i'd use allegro just for the videos. I want  to have the video display in the sfml window but I'm not sure if this works. I don't know allegro. I don't even have it set up yet. But I would like to find out if its even possible to do this before I waste time on allegro. I know allegro and sfml are built on opengl so there is some possibility.
Thanks

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10883
    • View Profile
    • development blog
    • Email
Re: Can you integrate allegro into an sfml window?
« Reply #1 on: May 13, 2024, 03:00:16 pm »
Maybe it's possible somehow, but I feel if you have the knowledge to hack those two libraries together, you might as well use a video playback library instead or if you must, port Allegro's addon to SFML.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

kojack

  • Sr. Member
  • ****
  • Posts: 329
  • C++/C# game dev teacher.
    • View Profile
Re: Can you integrate allegro into an sfml window?
« Reply #2 on: May 13, 2024, 05:07:34 pm »
I guess it depends on what you require as to whether Allegro is a good idea.
Taking a look at the official Allegro video addon, it only supports Ogg Theora video files and the top of the main source file says:
Quote
/* This is just a quick hack. But good enough for our use of displaying
 * a short intro video when our game starts up - so might as well share
 * it.
 *
 * Known bugs:
 *
 * - Only very crude synching. Audio is slightly delayed and some
 *   videos seem to constantly drift off and then the audio gets all
 *   distorted...
 *
 * - Seeking/Pausing doesn't really work.
 *
 * - Memory leaks. Easy to fix but don't have time right now.
https://github.com/liballeg/allegro5/blob/master/addons/video/video.c

Me-Myself-And-I

  • Jr. Member
  • **
  • Posts: 65
    • View Profile
Re: Can you integrate allegro into an sfml window?
« Reply #3 on: May 15, 2024, 01:18:35 am »
I see... I thought perhaps allegro would be reasonably easy to put into an sfml window. Looks like that brings me back to sfemovie, which is something I have so far unsuccessfully setup.  ::)  Thanks anyways. :)

fallahn

  • Sr. Member
  • ****
  • Posts: 499
  • Buns.
    • View Profile
    • Trederia
Re: Can you integrate allegro into an sfml window?
« Reply #4 on: May 15, 2024, 10:46:39 am »
What sort of video do you need to support? If it's just for some intro videos/cutscenes pl_mpeg is pretty easy to integrate with a RenderTexture/AudioStream
https://github.com/phoboslab/pl_mpeg

or there's more comprehensive support with libvlc:
https://github.com/kjetand/vlc4sfml

kojack

  • Sr. Member
  • ****
  • Posts: 329
  • C++/C# game dev teacher.
    • View Profile
Re: Can you integrate allegro into an sfml window?
« Reply #5 on: May 15, 2024, 11:32:16 am »
If you don't need audio, OpenCV is very easy to get working in SFML (1 line of code to load a video, about 5 lines to read a frame into a texture, do that with a timer). I haven't done much with it, I was just testing security camera footage analysis and playback, so the video was already low framerate.

Me-Myself-And-I

  • Jr. Member
  • **
  • Posts: 65
    • View Profile
Re: Can you integrate allegro into an sfml window?
« Reply #6 on: May 17, 2024, 03:23:41 pm »
Quote
What sort of video do you need to support? If it's just for some intro videos/cutscenes pl_mpeg is pretty easy to integrate with a RenderTexture/AudioStream
This sounds like what I need. Could you please show me an example script of the video player being used for sfml?

fallahn

  • Sr. Member
  • ****
  • Posts: 499
  • Buns.
    • View Profile
    • Trederia
Re: Can you integrate allegro into an sfml window?
« Reply #7 on: May 18, 2024, 12:05:47 pm »
This should get you off on the right foot:

https://github.com/fallahn/VideoTexture

Just add the files in the 'src' directory to your project, and check the example for usage :)

Me-Myself-And-I

  • Jr. Member
  • **
  • Posts: 65
    • View Profile
Re: Can you integrate allegro into an sfml window?
« Reply #8 on: May 19, 2024, 12:23:08 am »
Thankyou.
There's a problem though. 
216   3   ...\pl_mpeg.h   [Error] conflicting declaration 'typedef struct plm_plane_t plm_plane_t'

fallahn

  • Sr. Member
  • ****
  • Posts: 499
  • Buns.
    • View Profile
    • Trederia
Re: Can you integrate allegro into an sfml window?
« Reply #9 on: May 19, 2024, 11:57:24 am »
When you add the files to your project, make sure you're only compiling VideoTexture.cpp (not the header files)

Me-Myself-And-I

  • Jr. Member
  • **
  • Posts: 65
    • View Profile
Re: Can you integrate allegro into an sfml window?
« Reply #10 on: May 22, 2024, 04:18:20 pm »
This might sound dumb but... how exactly do you do that? :P I don't think I've ever heard of excluding header files from compilation when the cpp file is using them. Neither have I found any documentation on how to do that.

fallahn

  • Sr. Member
  • ****
  • Posts: 499
  • Buns.
    • View Profile
    • Trederia
Re: Can you integrate allegro into an sfml window?
« Reply #11 on: May 22, 2024, 05:22:14 pm »
It depends on you compiler/toolchain setup.

For example Visual Studio lists 2 folders in its source tree "Header Files" and "Source Files". Only the files which are included in the "Source Files" folder are sent for compilation. It's at this point any header files which are #include 'd in the *.cpp files are pulled in by the compiler for compilation. (Well, kinda, they're put in place by the preprocessor just before compilation).

On the other hand *.hpp files listed in the "Header Files" section are ignored, except for when they're explicitly #include 'd in a *.cpp file. If you try adding an *.hpp file to the "Source Files" folder, Visual Studio will try to compile it directly which may or may not be what you want (probably not in most cases, and definitely not in this specific case).

Other toolchain/compiler setups are similar: you list the source files (*.c and *.cpp) you want to compile, followed by the directories containing the header files. That way the compiler will only pull in any header files for compilation as is needed.

So what I mean is - make sure the *.hpp files are not being added to the list of files to be compiled, either by accidentally adding them to the "Source Files" folder in Vidual Studio, or by any other means with a different compiler.

Me-Myself-And-I

  • Jr. Member
  • **
  • Posts: 65
    • View Profile
Re: Can you integrate allegro into an sfml window?
« Reply #12 on: May 22, 2024, 09:23:06 pm »
I don't think that's the problem.
The header files are not listed in the cmake file.
# Project: Project1
# Makefile created by Dev-C++ 5.11

CPP      = g++.exe
CC       = gcc.exe
WINDRES  = windres.exe
OBJ      = main.o VideoTexture.o
LINKOBJ  = main.o VideoTexture.o
LIBS     = -L"C:/Program Files (x86)/Dev-Cpp/MinGW64/x86_64-w64-mingw32/lib32" -L"C:/SFML-2.4.0/lib" -static-libgcc -lsfml-graphics -lsfml-network -lsfml-audio  -lsfml-system -lsfml-window -m32
INCS     = -I"C:/Program Files (x86)/Dev-Cpp/MinGW64/include" -I"C:/Program Files (x86)/Dev-Cpp/MinGW64/x86_64-w64-mingw32/include" -I"C:/Program Files (x86)/Dev-Cpp/MinGW64/lib/gcc/x86_64-w64-mingw32/4.9.2/include"
CXXINCS  = -I"C:/Program Files (x86)/Dev-Cpp/MinGW64/include" -I"C:/Program Files (x86)/Dev-Cpp/MinGW64/x86_64-w64-mingw32/include" -I"C:/Program Files (x86)/Dev-Cpp/MinGW64/lib/gcc/x86_64-w64-mingw32/4.9.2/include" -I"C:/Program Files (x86)/Dev-Cpp/MinGW64/lib/gcc/x86_64-w64-mingw32/4.9.2/include/c++" -I"C:/SFML-2.4.0/include"
BIN      = Project1.exe
CXXFLAGS = $(CXXINCS) -m32 -std=c++11
CFLAGS   = $(INCS) -m32 -std=c++11
RM       = rm.exe -f

.PHONY: all all-before all-after clean clean-custom

all: all-before $(BIN) all-after

clean: clean-custom
        ${RM} $(OBJ) $(BIN)

$(BIN): $(OBJ)
        $(CPP) $(LINKOBJ) -o $(BIN) $(LIBS)

main.o: main.cpp
        $(CPP) -c main.cpp -o main.o $(CXXFLAGS)

VideoTexture.o: VideoTexture.cpp
        $(CPP) -c VideoTexture.cpp -o VideoTexture.o $(CXXFLAGS)

fallahn

  • Sr. Member
  • ****
  • Posts: 499
  • Buns.
    • View Profile
    • Trederia
Re: Can you integrate allegro into an sfml window?
« Reply #13 on: May 23, 2024, 10:56:07 am »
Just tried it with gcc and there were a few typos which needed fixing 😅

I've updated the repo with a version that I've tested on my linux box and added a CMake project for the demo if you'd like to try it.

Me-Myself-And-I

  • Jr. Member
  • **
  • Posts: 65
    • View Profile
Re: Can you integrate allegro into an sfml window?
« Reply #14 on: May 24, 2024, 02:45:11 am »
Thankyou very much. That definitely solved the conflicting declaration issue.
I'm still having two errors.
undefined reference to `_imp__glBindTexture@8'
undefined reference to `_imp__glTexImage2D@36'
 

I guess since it works for you it must be because my SFML version must be incompatible with this. I use sfml 2.4.0.