我一直在关注如何使用C++输出二维向量的教程,并得出以下代码:
#include <iostream>
#include <vector>
using namespace std;
int main()
{
vector < vector < int > > test { { 1, 2, 3,
4, 5, 6,
7, 8, 9 } };
for( unsigned int i = 0; i < test.size(); i++ )
{
for( unsigned int j = 0; j < test[i].size(); j++ )
{
cout << test[i][j] << " ";
}
cout << endl;
}
}
Run Code Online (Sandbox Code Playgroud)
产生以下输出:
1 2 3 4 5 6 7 8 9
Run Code Online (Sandbox Code Playgroud)
正如您所看到的,我的结果看起来并不完全符合预期; 我希望能够将矢量输出到二维网格状空间.据我所知,我的代码遵循示例,但是 …
为什么我必须使用 SDL_LockTexture 和 SDL_UnlockTexture 来使用 SDL2 操作硬件纹理?我知道“STATIC”纹理访问和“STREAMING”纹理访问之间的区别,但我想我很困惑,因为我似乎记得使用“SDL_SetTextureColorMod”来调整“STATIC”纹理的颜色。那么,为什么有时我们必须锁定像素而有时我们不需要呢?