Ok, I am new to openGL.
I am having a hard time figuring out what the best method is for rendering a video in 3D space.
I am using C# as my development because I only really want to focus on Windows for now and it is great for quick prototyping...anyway.
I am using OpenTK which is essentially the same as openGL (if you didn't already know), so information on either would be great.
I am using VLC so any file type can be supported.
Currently I have this code:
[source lang="csharp"]IMediaPlayerFactory factory = new MediaPlayerFactory();
IVideoPlayer player = player = factory.CreatePlayer<IVideoPlayer>();
IMedia media = factory.CreateMedia<IMedia>(@"C:\test.flv");
IMemoryRenderer memRender = player.CustomRenderer;
memRender.SetCallback(delegate(Bitmap frame)
{
//This is my callback, so every frame for VLC code call this.
//This code should lock and update the texture (unsure if it is needed to lock)
});
memRender.SetFormat(new BitmapFormat(300, 300, ChromaType.RV24));
player.Open(media);
player.Play();[/source]
would it be better to render in the Callback?
or during the render loop?
I have tried everything and searched the net for ideas to get the bitmap from the video to the texture, but I haven't been successful, I know the bitmap is correct, because I wrote code to output it, so it is rendering, I just can't get OpenTK to generate the texure and load it onto the screen.
I want the focus to be on speed.
any help is appreciated, thanks!
C# Rendering Video from external thread using LibVlc
I am only double posting because I solved this, and I figured if anyone was curious, they would like to know.
Instead of a call back, which can be called at any time (which I assume will mostly be AFTER a frame is rendered and before it is cleared, thus not rendering, I used this in my render loop.
it is playing the video just fine, although I am not sure how to handle multiple textures yet.
also is there a more efficient way of doing this?
Instead of a call back, which can be called at any time (which I assume will mostly be AFTER a frame is rendered and before it is cleared, thus not rendering, I used this in my render loop.
if(player.IsPlaying)
{
Bitmap bitmap = memRender.CurrentFrame;
BitmapData data = bitmap.LockBits(new Rectangle(0, 0, bitmap.Width, bitmap.Height),
ImageLockMode.ReadOnly, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
GL.TexImage2D(TextureTarget.Texture2D, 0, PixelInternalFormat.Rgba, data.Width, data.Height, 0,
OpenTK.Graphics.OpenGL.PixelFormat.Bgra, PixelType.UnsignedByte, data.Scan0);
bitmap.UnlockBits(data);
bitmap.Dispose();
}
base.OnRenderFrame(e);
it is playing the video just fine, although I am not sure how to handle multiple textures yet.
also is there a more efficient way of doing this?
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement