私はEX、任意の情報なしで送信されたデータに何が起こるか思ったんだけど:我々はデータを送信バッファを作成中空の/初期化されていないデータをOpenGLで送信するとどうなりますか?
struct Vertex
{
glm::vec3 Positions, UVs, Normals;
};
std::vector<Vertex> vertices;
// We fill vertices with a bunch of Vertex' that only have Positions and UVs filled in.
// Normals aren't iniatalized so im assuming they're a glm::vec3(0.0f,0.0f,0.0f) by default
後のコードで、私たちはsizeof(Vertex) * vertices[0]
の大きさを持つようにバッファを割り当てます。
glEnableVertexAttribArray(0);
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, sizeof(Vertex), reinterpret_cast<GLvoid*>(offsetof(Vertex, Positions)));
glEnableVertexAttribArray(1);
glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, sizeof(Vertex), reinterpret_cast<GLvoid*>(offsetof(Vertex, UVs)));
glEnableVertexAttribArray(2);
glVertexAttribPointer(2, 3, GL_FLOAT, GL_FALSE, sizeof(Vertex), reinterpret_cast<GLvoid*>(offsetof(Vertex, Normals)));
シェーダがシェーダで2つのインスタンスのそれぞれにおけるVertex::Normal
データで何をするん:
1)
#version 450 core
layout(location = 0) in vec3 Pos;
layout(location = 1) in vec3 UVs;
layout(location = 2) in vec3 Norms;
void main()
{
// We only use Pos and UVs, Norms is never referenced.
}
2)
#version 450 core
layout(location = 0) in vec3 Pos;
layout(location = 1) in vec3 UVs;
void main(){...}
1 。) シェイダーがノルムの初期化されていないvec3を保存することを期待しているのは、それにlocデータを取得するために使用します。しかし、私は、シェーダが使用されていないデータも破棄したと聞いています。
2) それは私はまだ助けをglVertexAttribArray(...)
おかげでを介してデータを送信するにもかかわらず、シェーダー内の場所を持っていないように私は、規範のvec3が破棄されることを期待!