how to play video in opengl?

I have a project.
It make me to player a media file such as “.rm” and “.mpeg” on a model, so how do that?

There’s a tutorial on using a video as a texture at NeHe’s site.


Also, this may be of some use:…


opengl is very slow why are u using it???

no, inaam is very slow, that’s why I don’t use him to play video.

1 Like

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.


Originally posted by inaam:
opengl is very slow why are u using it???
Little knowledge is dangerous. Lie down before you hurt yourself.

1 Like

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.


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.

@tesla: could you provide your YCbCr to RGB shader to the forum?

another YCbCr to RGB shader :

Originally posted by ZbuffeR:
another YCbCr to RGB shader :

No, that is actually my shader. :slight_smile:

lol ok

really how much diferrence is in DirectX and Opengl’s speed?

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.