Skip to content

Tag

C / C++

8 posts

Building Draco and Compressing 3D Files

3D data files can get very large. Basically, the more polygons (vertices) there are, the larger they get. But especially on the web, large files take a long time to download, which isn't practical. So this time, we'll reduce the file size with Draco, a 3D data compression program developed by Google. Draco can make files very small. We'll actually compress an OBJ file with Draco.

Vertex Arrays and VBOs

OpenGL and GLSL provide a mechanism called VBO for sending data to the GPU more efficiently. So far, we've been sending data to GLSL with functions such as glBegin() and glVertex3f(). As I mentioned before, glBegin() and the like have already been removed or deprecated, and drawing with them is very slow. Here we send only the vertices to GLSL as an attribute variable, but you can send normals, colors, UVs, and other data the same way. With what we've covered so far, you should be able to write fairly efficient programs. By the way, there's also the term VAO (Vertex Array Object), which is very confusing, but it isn't another kind of VBO or an alternative to VBOs: it's a way to encapsulate VBOs.

Opening a Window with GLFW

For drawing with OpenGL, GLUT (or FreeGLUT) would be fine, but GLUT is a bit unintuitive, makes contexts harder to understand, and is no longer maintained (presumably for good reason), so I'll use GLFW. GLFW is still maintained and has more features.

Useful Basics to Know When Using OpenGL

Long explanations of history and internals would put you to sleep, so I'd rather skip them, but these are the parts I stumbled over badly while teaching myself, so I think I have to explain them. I'll still do my best to keep it short. You don't need to understand everything, but it's good to know the big picture, so I've collected it here in part 1. Skimming it the first time is fine. Your understanding of OpenGL should deepen as you move on to the later articles, so come back and read it again then.

Setting Up Visual Studio for OpenGL

In these lessons, I'll explain OpenGL so that even people touching it for the first time can follow along. The target level is someone who has written a little C. The series is about OpenGL 2.1, but I'll avoid the old features as much as possible so that what you learn is easy to apply to newer versions such as OpenGL 3.x and 4.x. Why OpenGL 2.1? Because many PCs don't support the newer versions of OpenGL. If you release software you've made, you want as many people as possible to use it, and in those cases you often have to use an older OpenGL. For example, Clip Studio Paint, the most famous illustration software, appears to use OpenGL 2.1, and Live2D appears to use OpenGL 3.3. Even commercial software deliberately uses OpenGL versions that aren't the latest.