@@ -105,9 +105,8 @@ void Game::InitializeGame(const char* vertShader, const char* fragShader) {
105105 myMatrix = resizeMatrix * matrTransl;
106106
107107 glClearColor (0 .0f , 0 .0f , 0 .0f , 0 .0f );
108- LoadTexture (texture, " blueAsteroid.png " );
108+ Game::loadTextures ( );
109109}
110-
111110void Game::FireAnimation () {
112111 if (fireTail >= resetTailEvery) {
113112 fireTail = resetTailEvery;
@@ -199,9 +198,9 @@ void Game::RenderFunction(void) {
199198 myMatrixLocation = glGetUniformLocation (TextureProgramId, " myMatrix" );
200199
201200 glActiveTexture (GL_TEXTURE0);
202- glBindTexture (GL_TEXTURE_2D, texture);
201+
203202 for (auto & asteroid : asteroids) {
204-
203+ glBindTexture (GL_TEXTURE_2D, textures[asteroid-> getTextureIndex ()]);
205204 glm::mat4 asteroidMatrix = glm::scale (glm::mat4 (1 .0f ), glm::vec3 (asteroid->getRadius (), asteroid->getRadius (), 1.0 ));
206205 glm::mat4 animateMatrix = glm::translate (glm::mat4 (1 .0f ), glm::vec3 (0.0 , - asteroid->getTranslatedDistance (), 0.0 )); // controleaza translatia de-a lungul lui Oy
207206 backgroundMatrix = backgroundScaleMatrix * backgroundTranslateMatrix;
@@ -346,7 +345,7 @@ void Game::CreateAsteroidBuffers() {
346345 Vertices[9 * k + 5 ] = 0 .0f ;
347346 Vertices[9 * k + 6 ] = 0 .0f ;
348347
349- cout << (float )k / 18 << " " ;
348+ // cout << (float)k / 18 << " ";
350349 Vertices[9 * k + 7 ] = (sin (theta) + 1 ) / 2 ;
351350 Vertices[9 * k + 8 ] = (cos (theta) + 1 )/ 2 ;
352351 }
@@ -436,4 +435,11 @@ void Game::LoadTexture(GLuint &texture, const char* imageName)
436435
437436 SOIL_free_image_data (image);
438437 glBindTexture (GL_TEXTURE_2D, 0 );
438+ }
439+ void Game::loadTextures () {
440+ for (auto & imageName : Constants::textureImages) {
441+ GLuint texture;
442+ LoadTexture (texture, imageName);
443+ textures.push_back (texture);
444+ }
439445}
0 commit comments