Presentation is loading. Please wait.

Presentation is loading. Please wait.

OpenGL. Textures  Bind Textures similar to binding VBO’s  Create a texture for each object  Generate the texture similar how you generate a VBO buffer.

Similar presentations


Presentation on theme: "OpenGL. Textures  Bind Textures similar to binding VBO’s  Create a texture for each object  Generate the texture similar how you generate a VBO buffer."— Presentation transcript:

1 OpenGL

2 Textures  Bind Textures similar to binding VBO’s  Create a texture for each object  Generate the texture similar how you generate a VBO buffer GLuint text glGenTextures(1, &text)

3 Update Vertex Struct  struct Vertex  {  GLfloat position[3];  GLfloat uv[2];  };

4 Prepare Shader  Glint texAttrib = glGetAttribLocation(shaderProgram, “texcoord”);  glEnableVertexAttribArray(texAttrib);  glVertexAttribPointer(texAttrib, 2, GL_FLOAT, GL_FALSE, sizeof(Vertex),(void*)offsetOf(Vertex,uv))

5 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

6 Bind Texture To Image  Set Active Texture for Shader glActiveTexture(GL_TEXTURE0)  Binding glTexImage2D(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

7 Image Libraries  ImageMagick++  FreeImagePlus  Many more…  Specify which one you used in your readme!

8 References  https://www.open.gl/textures Provides information on shaders which you will need


Download ppt "OpenGL. Textures  Bind Textures similar to binding VBO’s  Create a texture for each object  Generate the texture similar how you generate a VBO buffer."

Similar presentations


Ads by Google