-1

currently trying to make a skybox using the soil lib. However, I get these two errors and have no idea why or what to do to fix them... If anyone could offer any help or suggestions would be greatly appreciated!

GLuint textureCon;

int widthX, heightY;
unsigned char* imageInfo;

std::list<int> faces;
faces.push_back(6);

glBindTexture(GL_TEXTURE_CUBE_MAP, textureCon);

for (GLuint i = 0; i < faces.size(); i++)
{
    imageInfo = SOIL_load_image(faces[i], &widthX, &heightY, 0, SOIL_LOAD_RGB);
    glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X + i, 0, GL_RGB, widthX, heightY, 0, GL_RGB, GL_UNSIGNED_BYTE, imageInfo);
}

Error message

Where I'm saying faces[i] that is where the E0349 error occurs saying that the square brackets don't match the operator? But I thought that's how to use lists? Thanks again for any help!

Werner Henze
  • 16,404
  • 12
  • 44
  • 69
  • Please post the full error messages not just the compiler's code numbers. – Richard Critten Dec 27 '17 at 14:02
  • 3
    Anyway, you just didn't read the documentation for `std::list`. It's not a random-access container, so `operator[]` is not meaningful and hence does not exist. See e.g. http://en.cppreference.com/w/cpp/container/list where there is no `operator[]` to be found. You probably actually want `std::vector`, as do 99.9999% of people who want a container, and it *is* a random-access container with an `operator[]`. (You can get the item at a particular notional 'index' in an `std::list` using iterators and `advance` or arithmetic or something, but you probably don't really want to.) – underscore_d Dec 27 '17 at 14:04
  • 1
    Please provide the error message as text (searchable) and not as png (not searchable). Thanks – Werner Henze Dec 27 '17 at 14:07

1 Answers1

1

I think you misunderstood some things here.

1) push_back only push one element into a container, for example: push_back(6) will push 6 into the container and not 6 elements as you need.

2) std::list doens't have the [] operator defined, it's not meant for that. If you need to access each element, I recommend you to use std::vector instead which has a [] operator.

  • Ah right! Thanks a lot, mate, ill have a bash at doing that then! –  Dec 27 '17 at 14:10
  • Re `1)`, as I'm sure you'll see in the documentation, `std::vector` has a constructor that lets you create it with a specific initial number of elements. – underscore_d Dec 27 '17 at 14:10