Solution

Files changed (1) hide show
  1. lab2-textures/lab2_main.cpp +13 -0
lab2-textures/lab2_main.cpp CHANGED
@@ -45,6 +45,7 @@ GLuint shaderProgram;
45
45
  // the vertex data (in positionBuffer) and color data per vertex (in colorBuffer)
46
46
  GLuint positionBuffer, colorBuffer, indexBuffer, texcoordBuffer, vertexArrayObject;
47
47
 
48
+ GLuint texture;
48
49
 
49
50
 
50
51
 
@@ -130,6 +131,18 @@ void initialize()
130
131
  // Load Texture
131
132
  //************************************
132
133
  // Task 2
134
+ int w, h, comp;
135
+ unsigned char* image = stbi_load("../scenes/textures/asphalt.jpg", &w, &h, &comp, STBI_rgb_alpha);
136
+ glGenTextures(1, &texture);
137
+ glBindTexture(GL_TEXTURE_2D, texture);
138
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, w, h, 0, GL_RGBA, GL_UNSIGNED_BYTE, image);
139
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
140
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
141
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
142
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
143
+ glBindTexture(GL_TEXTURE_2D, 0);
144
+
145
+ stbi_image_free(image);
133
146
  }
134
147
 
135
148