Learning OpenGL for N-body Sims #3 - A Textured Box using GLSL

Continuing by following the tutorials at opengl-tutorials, we'll make a textured box and follow it with a slowly moving camera.

Box

We bind another buffer to hold our textures.


glGenBuffers(1, &uv_buffer);
glBindBuffer(GL_ARRAY_BUFFER, uv_buffer);
glBufferData(GL_ARRAY_BUFFER, sizeof(g_uv_buffer_data), g_uv_buffer_data, GL_STATIC_DRAW);

Also, we can set our viewpoint using the handy shortcut glm::lookAt.

viewMatrix = glm::lookAt(cameraPos, cameraTarget, glm::vec3(0.0f,1.0f,0.0f));

Source code on Github

Popular posts from this blog

Building a PID hover controller for Kerbal Space Program with kOS and IPython Notebook

Learning TensorFlow #1 - Using Computer Vision to turn a Chessboard image into chess tiles

Visualizing TLE Orbital Elements with Python and matplotlib