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

Strawberry DNA extraction and viewing with a cheap USB Microscope

Visualizing TLE Orbital Elements with Python and matplotlib

Relearning web development by writing a clicking game using React, Npm and Browserify