黒い空/ちらつきのある画面を取り除くためにあらゆる方法を試した結果、(2週間の攪拌の後)問題は最終的に解決され、私にとって新しい教訓になりました.
OpenGL ES 2.0 では、バッファ オブジェクト (vbo または ibo) を nio バッファと混在させることはできないようです。コードは主にバッファ オブジェクトを使用するか、nio のみを使用する必要があります。
これは間違ったコードです:
////////////////////////////////
// program for missiles start //
////////////////////////////////
GLES20.glUseProgram(GLES20Renderer._programMissiles);
GLES20.glVertexAttribPointer(GLES20Renderer._aPositionLocationMissiles, 3, GLES20.GL_FLOAT, false, 12, GLES20Renderer._pointVFBMissile);
GLES20.glEnableVertexAttribArray(GLES20Renderer._aPositionLocationMissiles);
GLES20.glDrawArrays(GLES20.GL_POINTS, 0, 3);
///////////////////////////////
// program for missiles end //
///////////////////////////////
//////////////////////////////
// program for player start //
//////////////////////////////
GLES20.glUseProgram(GLES20Renderer._programBody);
GLES20.glBindBuffer(GLES20.GL_ARRAY_BUFFER, GLES20Renderer._bodyBuffers[0]);
GLES20.glVertexAttribPointer(GLES20Renderer._aPositionLocationBody, 3, GLES20.GL_FLOAT, false, 12, 0);
GLES20.glEnableVertexAttribArray(GLES20Renderer._aPositionLocationBody);
GLES20.glBindBuffer(GLES20.GL_ARRAY_BUFFER, GLES20Renderer._bodyBuffers[1]);
GLES20.glVertexAttribPointer(GLES20Renderer._aColorLocationBody, 4, GLES20.GL_FLOAT, false, 16, 0);
GLES20.glEnableVertexAttribArray(GLES20Renderer._aColorLocationBody);
GLES20.glBindBuffer(GLES20.GL_ARRAY_BUFFER, GLES20Renderer._bodyBuffers[2]);
GLES20.glVertexAttribPointer(GLES20Renderer._aNormalPositionBody, 3, GLES20.GL_FLOAT, false, 0, 0);
GLES20.glEnableVertexAttribArray(GLES20Renderer._aNormalPositionBody);
GLES20.glUniform3f(GLES20Renderer._uLightPositionLocationBody, GLES20Renderer._LightPosInEyeSpace[0], GLES20Renderer._LightPosInEyeSpace[1], GLES20Renderer._LightPosInEyeSpace[2]);
GLES20.glUniformMatrix4fv(GLES20Renderer._uMVPLocationBody, 1, false, GLES20Renderer._MVPMatrixBody, 0);
GLES20.glBindBuffer(GLES20.GL_ELEMENT_ARRAY_BUFFER, GLES20Renderer._bodyBuffers[3]);
GLES20.glDrawElements(GLES20.GL_TRIANGLES, 372, GLES20.GL_UNSIGNED_SHORT, 0);
GLES20.glUseProgram(GLES20Renderer._programNozzle);
GLES20.glBindBuffer(GLES20.GL_ARRAY_BUFFER, GLES20Renderer._nozzleBuffers[0]);
GLES20.glVertexAttribPointer(GLES20Renderer._aPositionLocationNozzle, 3, GLES20.GL_FLOAT, false, 12, 0);
GLES20.glEnableVertexAttribArray(GLES20Renderer._aPositionLocationNozzle);
GLES20.glBindBuffer(GLES20.GL_ARRAY_BUFFER, GLES20Renderer._nozzleBuffers[1]);
GLES20.glVertexAttribPointer(GLES20Renderer._aColorLocationNozzle, 4, GLES20.GL_FLOAT, false, 16, 0);
GLES20.glEnableVertexAttribArray(GLES20Renderer._aColorLocationNozzle);
GLES20.glBindBuffer(GLES20.GL_ARRAY_BUFFER, GLES20Renderer._nozzleBuffers[2]);
GLES20.glVertexAttribPointer(GLES20Renderer._aNormalPositionNozzle, 3, GLES20.GL_FLOAT, false, 0, 0);
GLES20.glEnableVertexAttribArray(GLES20Renderer._aNormalPositionNozzle);
GLES20.glUniform3f(GLES20Renderer._uLightPositionLocationNozzle, GLES20Renderer._LightPosInEyeSpace[0], GLES20Renderer._LightPosInEyeSpace[1], GLES20Renderer._LightPosInEyeSpace[2]);
GLES20.glUniformMatrix4fv(GLES20Renderer._uMVPLocationNozzle, 1, false, GLES20Renderer._MVPMatrixNozzle, 0);
GLES20.glBindBuffer(GLES20.GL_ELEMENT_ARRAY_BUFFER, GLES20Renderer._nozzleBuffers[3]);
GLES20.glDrawElements(GLES20.GL_TRIANGLES, 144, GLES20.GL_UNSIGNED_SHORT, 0);
/////////////////////////////
// program for player end //
/////////////////////////////
これは正しいコードです:
////////////////////////////////
// program for missiles start //
////////////////////////////////
GLES20.glUseProgram(GLES20Renderer._programMissile);
GLES20.glBindBuffer(GLES20.GL_ARRAY_BUFFER, GLES20Renderer._missileBuffers[0]);
GLES20.glVertexAttribPointer(GLES20Renderer._aPositionLocationMissile, 3, GLES20.GL_FLOAT, false, 12, 0);
GLES20.glEnableVertexAttribArray(GLES20Renderer._aPositionLocationMissile);
GLES20.glBindBuffer(GLES20.GL_ELEMENT_ARRAY_BUFFER, GLES20Renderer._missileBuffers[1]);
GLES20.glDrawElements(GLES20.GL_POINTS, 3, GLES20.GL_UNSIGNED_SHORT, 0);
///////////////////////////////
// program for missiles end //
///////////////////////////////
//////////////////////////////
// program for player start //
//////////////////////////////
GLES20.glUseProgram(GLES20Renderer._programBody);
GLES20.glBindBuffer(GLES20.GL_ARRAY_BUFFER, GLES20Renderer._bodyBuffers[0]);
GLES20.glVertexAttribPointer(GLES20Renderer._aPositionLocationBody, 3, GLES20.GL_FLOAT, false, 12, 0);
GLES20.glEnableVertexAttribArray(GLES20Renderer._aPositionLocationBody);
GLES20.glBindBuffer(GLES20.GL_ARRAY_BUFFER, GLES20Renderer._bodyBuffers[1]);
GLES20.glVertexAttribPointer(GLES20Renderer._aColorLocationBody, 4, GLES20.GL_FLOAT, false, 16, 0);
GLES20.glEnableVertexAttribArray(GLES20Renderer._aColorLocationBody);
GLES20.glBindBuffer(GLES20.GL_ARRAY_BUFFER, GLES20Renderer._bodyBuffers[2]);
GLES20.glVertexAttribPointer(GLES20Renderer._aNormalPositionBody, 3, GLES20.GL_FLOAT, false, 0, 0);
GLES20.glEnableVertexAttribArray(GLES20Renderer._aNormalPositionBody);
GLES20.glUniform3f(GLES20Renderer._uLightPositionLocationBody, GLES20Renderer._LightPosInEyeSpace[0], GLES20Renderer._LightPosInEyeSpace[1], GLES20Renderer._LightPosInEyeSpace[2]);
GLES20.glUniformMatrix4fv(GLES20Renderer._uMVPLocationBody, 1, false, GLES20Renderer._MVPMatrixBody, 0);
GLES20.glBindBuffer(GLES20.GL_ELEMENT_ARRAY_BUFFER, GLES20Renderer._bodyBuffers[3]);
GLES20.glDrawElements(GLES20.GL_TRIANGLES, 372, GLES20.GL_UNSIGNED_SHORT, 0);
GLES20.glUseProgram(GLES20Renderer._programNozzle);
GLES20.glBindBuffer(GLES20.GL_ARRAY_BUFFER, GLES20Renderer._nozzleBuffers[0]);
GLES20.glVertexAttribPointer(GLES20Renderer._aPositionLocationNozzle, 3, GLES20.GL_FLOAT, false, 12, 0);
GLES20.glEnableVertexAttribArray(GLES20Renderer._aPositionLocationNozzle);
GLES20.glBindBuffer(GLES20.GL_ARRAY_BUFFER, GLES20Renderer._nozzleBuffers[1]);
GLES20.glVertexAttribPointer(GLES20Renderer._aColorLocationNozzle, 4, GLES20.GL_FLOAT, false, 16, 0);
GLES20.glEnableVertexAttribArray(GLES20Renderer._aColorLocationNozzle);
GLES20.glBindBuffer(GLES20.GL_ARRAY_BUFFER, GLES20Renderer._nozzleBuffers[2]);
GLES20.glVertexAttribPointer(GLES20Renderer._aNormalPositionNozzle, 3, GLES20.GL_FLOAT, false, 0, 0);
GLES20.glEnableVertexAttribArray(GLES20Renderer._aNormalPositionNozzle);
GLES20.glUniform3f(GLES20Renderer._uLightPositionLocationNozzle, GLES20Renderer._LightPosInEyeSpace[0], GLES20Renderer._LightPosInEyeSpace[1], GLES20Renderer._LightPosInEyeSpace[2]);
GLES20.glUniformMatrix4fv(GLES20Renderer._uMVPLocationNozzle, 1, false, GLES20Renderer._MVPMatrixNozzle, 0);
GLES20.glBindBuffer(GLES20.GL_ELEMENT_ARRAY_BUFFER, GLES20Renderer._nozzleBuffers[3]);
GLES20.glDrawElements(GLES20.GL_TRIANGLES, 144, GLES20.GL_UNSIGNED_SHORT, 0);
/////////////////////////////
// program for player end //
/////////////////////////////