View Full Version : how to play video in opengl?

03-15-2006, 06:01 PM
I have a project.
It make me to player a media file such as ".rm" and ".mpeg" on a model, so how do that?

03-15-2006, 06:51 PM
There's a tutorial on using a video as a texture at NeHe's site. http://nehe.gamedev.net


03-15-2006, 07:01 PM
Also, this may be of some use: http://download.developer.nvidia.com/dev...ideoeffects.zip (http://download.developer.nvidia.com/developer/SDK/Individual_Samples/DEMOS/OpenGL/gpu_videoeffects.zip)


03-26-2006, 08:08 AM
opengl is very slow why are u using it???

03-26-2006, 11:03 AM
no, inaam is very slow, that's why I don't use him to play video.

Mikkel Gjoel
03-26-2006, 01:40 PM
Knackered - I use inaam for playing video. For the replays.

I've created a wrapper for using video-for-windows, that is basically the nehe-tutorial with rectangle-textures, without the assembler-stuff (and with a bug fixed... and a couple added probably). It simplifies matters quite a bit I think.



03-27-2006, 11:23 AM
Originally posted by inaam:
opengl is very slow why are u using it??? Little knowledge is dangerous. Lie down before you hurt yourself.

03-27-2006, 04:16 PM
Do search in this forum's. There is a several topics about playing video using OpenGL.

Easyest way is to modify Texture3D example from DXSDK that use Direct3D. Just remove D3D code and insert OpenGL calls.


03-29-2006, 04:18 PM
If you want it to be fast you might have to resort to using more than the bare minimum of OpenGL.

First - do not use glDrawPixels(). There is nothing wrong per se with glDrawPixels(), but it has a high probability of being slower.

Look at using YCbCr textures instead of RGB as this can save quite a bit of bandwidth. There are a few extensions which might do this or you could write a fragment shader - which is what I did. An YCbCr to RGB shader is very simple and is probably the best option for modern hardware.

Look at the ARB_pixel_buffer_object extension and see if you can transfer the textures more efficiently.

And on a non GL related note you should probably look into decoupling the display and decode functions by using double-buffering and decoding in a separate thread.

I have found that with a little work, OpenGL is quite good at displaying video.

03-30-2006, 01:40 AM
@tesla: could you provide your YCbCr to RGB shader to the forum?

03-30-2006, 04:19 AM
another YCbCr to RGB shader :

03-30-2006, 03:08 PM
Originally posted by ZbuffeR:
another YCbCr to RGB shader :
http://www.fourcc.org/source/YUV420P-OpenGL-GLSLang.c No, that is actually my shader. :)

03-30-2006, 03:12 PM
lol ok

04-03-2006, 11:18 AM
really how much diferrence is in DirectX and Opengl's speed?

04-03-2006, 04:03 PM
Originally posted by Ther:
really how much diferrence is in DirectX and Opengl's speed? I assume you want to talk about Direct3D, directX is for sound, joystick, networking...
They are basically the same. What does a difference is usally the graphic card or the competence of the programmer.
DirectX has issues about the overhead cost of going forth and back ring 0, so batching (and instancing) is VERY important, whereas this issue is not present with OpenGL.