Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

std::vector to Corrade::Containers conversion broken on WIndows #366

Closed
Consti10 opened this issue Aug 21, 2019 · 4 comments
Closed

std::vector to Corrade::Containers conversion broken on WIndows #366

Consti10 opened this issue Aug 21, 2019 · 4 comments

Comments

@Consti10
Copy link

Consti10 commented Aug 21, 2019

Hello,
I have included Corrade/Containers/ArrayViewStl.h, but the automatic conversion of std::vector throws a run time error when passing it to the GL::Buffer setData() function.
Here is what compiles & runs without problems (as a workaround):
bufferV.setData(Corrade::Containers::arrayView(vertexData.data(), vertexData.size()));
But replacing the line with the 'better' code:
bufferV.setData(vertexData);
Throws the following run time error:

`Program: ...cuments\magnum_vector_field\build\src\Debug\MyApplication.exe
File: C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.22.27905\include\vector
Line: 1475

Expression: vector subscript out of range

For information on how your program can cause an assertion
failure, see the Visual C++ documentation on asserts.`

The function where the error arises:
`void MyApplication::updateBuffers() {
const float lifeTimeDelta = 0.000001f;

//Vector2 vertexData[MaxParticles];
//Containers::ArrayView<Vector3> vertexData;
std::vector<Vector2> vertexData{};

for (int i = 0; i < MaxParticles; i++) {
	Particle& p = ParticlesContainer[i]; // shortcut
	if (p.life > 0.0f) {
		// Decrease life
		p.life -= lifeTimeDelta;
		if (p.life > 0.0f) {
			//do nothing, just upload data
			vertexData.push_back(p.pos);
		}
	}
}
//bufferV.setData(Corrade::Containers::arrayView(vertexData.data(), vertexData.size()));
bufferV.setData(vertexData);
_mesh.setCount(vertexData.size());

}`

@Squareys
Copy link
Contributor

I think this is a duplicate of mosra/corrade#75
It was fixed 11 hours ago, can you try updating corrade?

@mosra
Copy link
Owner

mosra commented Aug 21, 2019

Nice, two race conditions at the same time -- just when I wanted to post exactly the same comment about this being pushed to master today early morning 😆

@Consti10
Copy link
Author

Haha, good to hear it's already fixed.
I'l let you know once I updated corrade.

@mosra mosra added this to the 2019.0b milestone Aug 21, 2019
@mosra mosra added this to TODO in Project management via automation Aug 21, 2019
@Consti10
Copy link
Author

Consti10 commented Aug 21, 2019

Latest version of --head via vcpkg (re-install)
Confirmed fix, works again.

Project management automation moved this from TODO to Done Aug 21, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Development

No branches or pull requests

3 participants