How to embed SDL video in an existing OpenGL project
I'm working on an OpenGL game, and would like to play video on 3D surfaces within the game. SDL seems to be an excellent choice for video playback, but is it possible to create the surface inside of an existing OpenGL context? How would I go about doing this?开发者_如何转开发
SDL has, to my knowledge, no functions for video playback; don't be fooled by API names like SDL_Video
. Those are actually used for window management.
What you need to do is using some video decoder library to decode video into image buffers, then pass these image buffers into an OpenGL texture. The open source video player mplayer (which internally uses the ffmpeg libavformat and libavcodec libraries for video/audio decoding) also has an OpenGL video output module. I suggest you fetch the mplayer source code and take a look into the OpenGL video output module, to get an idea how to do this.
EDIT:
Since you're using SdlDotNet, I suggest using a SdlDotNet.Graphics.SurfaceGl
as target surface for the SdlDotNet.Graphics.Movie
.
精彩评论