NeHe OpenGL Lesson42 - Multiple Viewports
This samples shows us how to create multiple views in one window. With OpenGL command glViewport, we could place our scene into any rectangle area on the window. Usually, we will set the view port to the size of the window or window client area. This will make one full window view display. With glviewport function, you could choose any rectangle area on a window to display your view. This command will take the left-bottom point as the original point, width goes along horizontally, and height goes along vertically.
Update OpenGL texture object dynamically
// tex_data contain RGB texture data glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, width, height, GL_RGB, GL_UNSIGNED_BYTE, tex_data);
Create the maze texture data
Once you play a bit with the program, you will be curious about such maze texture created. Here is the main workflow:
- a) At first, we will choose a random position (2i, 2j) as the start point;
- b) Check all position at (2i, 2j) are filled with color, if all of them are filled with color, then the process finished, otherwise continue;
c) Check current position (2i, 2j) is a validate position (this position will not beyond the rectangle area and could turn around: could turn up or down, left or right ). If this is validate position, continue; otherwise, use a while loop to randomly pick up an empty position (2i, 2j); continue;
d) randomly find a turn direction; filled with the new direction { 4 possibility, (2i+1, 2j), (2i-1, 2j), (2i, 2j+1), (2i, 2j-1) }if we could turn along this direction, and move the position to a new position (2n, 2m) { 4 possibility, (2i+2, 2j), (2i-2, 2j), (2i, 2j+2), (2i, 2j-2)};
e) fill color to (2n, 2m);
f) go to step b).
The full source code could be found 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:你的「微服务管家」又秀新绝活了