opengl. textures bind textures similar to binding vbo’s create a texture for each object ...
TRANSCRIPT
TEXTURESOpenGL
Textures
Bind Textures similar to binding VBO’s Create a texture for each object Generate the texture similar how you
generate a VBO bufferGLuint textglGenTextures(1, &text)
Update Vertex Struct
struct Vertex { GLfloat position[3]; GLfloat uv[2]; };
Prepare Shader
Glint texAttrib = glGetAttribLocation(shaderProgram, “texcoord”);
glEnableVertexAttribArray(texAttrib); glVertexAttribPointer(texAttrib, 2,
GL_FLOAT, GL_FALSE, sizeof(Vertex),(void*)offsetOf(Vertex,uv))
Assimp Textures
When looping through each face for it’s vertices you will need to check the mesh for texture coordinates.mesh->HasTextureCoords(0)aiVector3D textureCoord = mesh-
>mTextureCoords[0][face.mIndices[k]]vert.uv[0] = textureCoord.x;vert.uv[1] = textureCoord.y
Bind Texture To Image
Set Active Texture for ShaderglActiveTexture(GL_TEXTURE0)
BindingglTexImage2D(GL_TEXTURE_2D, 0,
GL_RGB, imgWidth, imgHeight, 0, GL_RGB, GL_UNSIGNED_BYTE, image )
“image” is an array of pixels you obtain from your image loader
Image Libraries
ImageMagick++ FreeImagePlus Many more… Specify which one you used in your
readme!
References
https://www.open.gl/texturesProvides information on shaders which you
will need