OpenGL AVI Player (glut window)
This program shows how to play video with OpenGL & OpenAL. The .avi file that could be supported should be an old AVI file format, that no video & audio data compress happened here. This kind of AVI file format is not popular on the current PC any more, because the currently CPU & Sound device is so powerful that such compress data could be playing time de-compressed. This will save us a lot of disk for files size.
Main Idea
The main idea here is that: extract the video data & audio data based on the video itself frame rate. For the video data, just fill it to the color buffer; For the audio data, just give it to the OpenAL API, let the sound device handle the left work, that is playing the sound.
Code Refactoring & Design Patten. The reason why we need to do code refactoring and using design pattern is that when the scale of soft become very huge, we need a way to handle them. Usually, we will divide the big problem into several smaller problems, category them into different areas or specified problem. We will analysis them, find the characteristic of them, or abstract the common properties among them, or figure out the key features appeared among them. What we do just to make us clearly understand what the real problems we are facing, which position we are located currently during the problem solving process. Human brain are not the same as computers, we could only remember several things (for most guys, the maxim value is 7) at the same time because of ourselves physics limitation. But we could find other unities or tools or methods to overcome such problem. That is it.
Code Refactoring
For code refactoring, I think the most possibility time for code refactoring is when you want to add some features into the code, you find some other easier logic method to make your new features could be integrated very easily and more make scene. And the refactoring scope should be local and more centeric locating in one sub-system. There is no need to refactor a lots of source code because you feel uncomfortable with the coding style. And you need a testable-unit, so that you could test your modification is OK or not after every steps. This is very very important, otherwise you will lose some important logic or code patch logic, and break other well work features.
Design Pattern
For Design Pattern, the first time I touched those words, I thought they were super high technology. If you used some patterns in your code, it seems your coding level was super high. So I tried to use those patterns as more as possible, even a very a short of code. But I was wrong. The final goal is that we need to make our source code more readable, easily understand, self-explain, simple, and stupid. If you archive that, that is your pattern. Do not relay those existing pattern too much, they proved to solve some problem in some specific context. But I doubt whether it could solve your problem perfectly or not. Maybe you notice that there are many variations in one pattern, that is result of the different brain solve may similar problem in different context. It is normal.
For this program the code refactoring version is here, and the original version is here.