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.
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
· 没有源码,如何修改代码逻辑?
· 全程不用写代码,我用AI程序员写了一个飞机大战
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 记一次.NET内存居高不下排查解决与启示
· DeepSeek 开源周回顾「GitHub 热点速览」
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了