나는 당신을 위해 잘 작동하는 버퍼 크기를 찾고, 가능한 경우 VBO에 귀하의 vert 데이터를 결합합니다. 타겟 하드웨어가 실제로 이것을 지시 할 것이므로 다른 번호로 놀아 보는 것이 가장 좋습니다.
모델에서 렌더링에 실제로 사용해야하는 VBO의 오프셋을 참조하려면 일부 클래스를 사용하십시오. 예를 들어 상자와 자동차가 있습니다.
class MeshManager
{
public:
int loadMesh(const Mesh * mesh)
{
//load the mesh
//Add it to some current VBO or manage the creation of VBOs better.
ManagedMesh managedMesh(theVao, theVbo, theOffset, theLength, theType, theIdentifier);
theIdentifier++;
}
private:
std::map<std::string, ManagedMesh> meshMap;
int theIdentifier;
}
class Renderer
{
public:
void render(int meshId, Vector3f translation, Vector3f rotation);
}
int main(int argc, char** argv)
{
MeshManager meshManager;
Model model("mymodel.obj");
const Mesh * meshes = model.getMeshes();
int meshCount = model.getMeshCount();
for(int i=0; i<meshCount; i++)
{
meshManager.loadMesh(mesh);
}
model.freeMeshes();
}
뭔가 종류. 분명히 나는로드 된 메쉬 ID를 저장하지 않을 것이지만 당신이 그림을 얻은 것 같아요. 나는 전문가는 아니지만, 이것이 내가 어떻게 할 것인지에 대한 대략적인 예입니다. 또한 가능한 한 배치 렌더링을 시도하는 것을 잊지 마십시오. 렌더링을 1)로드해야하는 VBOs 2)로드해야하는 자료로 정렬하십시오. GPU를 계속 켜고 끄는 작업은 비용이 많이 듭니다. 시행 착오는 게임의 이름입니다 (게임이 프로그래밍 됨).