私は赤い本(第7版)を読んで、glMultiDrawElementsをテストしている間、私は画面上に何も得ておらず、デバッグコンソールでは "アクセス違反"エラーが発生しました。私はMVS2010を使用し、ここで私がコンパイルメインコード部品である:glMultiDrawElements
// C4UB_V2F interwined format, vertex are CCW ordered
static const GLfloat vertex[] = {
// First triangle
0xff0000ff, 0.25f, 1.0f, // nevermind on that incorrect integer colors
0x00ff00ff, 0.0f, 0.0f,
0x0000ffff, 0.5f, 0.0f,
// Second one
0xff0000ff, 0.75f, 0.0f,
0x00ff00ff, 0.5f, 1.0f,
0x0000ffff, 1.0f, 1.0f
};
void init() {
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
glShadeModel(GL_SMOOTH);
glInterleavedArrays(GL_C4UB_V2F, 0, vertex);
}
static const GLubyte order[] = { 0, 1, 2, 3, 4, 5 };
static GLubyte oneIndices[] = {0, 1, 2};
static GLubyte twoIndices[] = {3, 4, 5};
static GLsizei count[] = {3, 3};
static GLvoid * indices[2] = {oneIndices, twoIndices};
void render() {
glClear(GL_COLOR_BUFFER_BIT);
// This one works perfectly:
//glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_BYTE, order);
// And this one generates access violation error
// in the book there's no indices casting, but MVS2010 is too lazy to cast it itself
glMultiDrawElements(GL_TRIANGLES, count, GL_UNSIGNED_BYTE, (const GLvoid **)indices, 2);
// This command never executes 'cause of acces violation error occuring
glFlush();
}
は私には思えるインデックスをキャストしながら、私は何かを逃しましたが、私は正確に何を得ることができません。何か案は?
色は浮動小数点数に変換され、浮動小数点数は色として使用されます(代わりに構造体を使用します)が、これでエラーは発生しません。 –
ここで新しくなったので、同意と投票の機能についてあなたに知らせてください。 –
私が頻繁に見る非公式な情報によると、この手順はちょうど壊れています。単純な_for_ループが代わりに使用されています。私のビデオカード(RadeonとIntel i3プロセッサーに内蔵されているもの)の両方がこれを実行できないため、ハードウェアの問題ではないかどうかはわかりません。 – AlexXsWx