public void Draw() { Gles.glEnable(Gles.GL_DEPTH_TEST); Gles.glClearColor(0, 0, 0.4f, 1); Gles.glClear(Gles.GL_COLOR_BUFFER_BIT | Gles.GL_DEPTH_BUFFER_BIT); if (mProgram == 0) { return; } Gles.glUseProgram(mProgram); Gles.glThrowError(); if (UseBufferMethod) { Gles.glBindBuffer(Gles.GL_ARRAY_BUFFER, mVertexPositionBuffer); Gles.glThrowError(); Gles.glVertexAttribPointer((GLuint)mPositionAttribLocation, 3, Gles.GL_FLOAT, Gles.GL_FALSE, 0, IntPtr.Zero); Gles.glThrowError(); } else { Gles.glVertexAttribPointer((GLuint)mPositionAttribLocation, 3, Gles.GL_FLOAT, Gles.GL_FALSE, 0, mVertexPositions); Gles.glThrowError(); } Gles.glEnableVertexAttribArray((GLuint)mPositionAttribLocation); Gles.glThrowError(); Gles.glDrawArrays(Gles.GL_TRIANGLES, 0, 3); Gles.glThrowError(); }
public void Draw() { Gles.glEnable(Gles.GL_DEPTH_TEST); Gles.glClear(Gles.GL_COLOR_BUFFER_BIT | Gles.GL_DEPTH_BUFFER_BIT); if (mProgram == 0) { return; } Gles.glUseProgram(mProgram); Gles.glBindBuffer(Gles.GL_ARRAY_BUFFER, mVertexPositionBuffer); Gles.glEnableVertexAttribArray((GLuint)mPositionAttribLocation); Gles.glVertexAttribPointer((GLuint)mPositionAttribLocation, 3, Gles.GL_FLOAT, Gles.GL_FALSE, 0, IntPtr.Zero); Gles.glBindBuffer(Gles.GL_ARRAY_BUFFER, mVertexColorBuffer); Gles.glEnableVertexAttribArray((GLuint)mColorAttribLocation); Gles.glVertexAttribPointer((GLuint)mColorAttribLocation, 3, Gles.GL_FLOAT, Gles.GL_FALSE, 0, IntPtr.Zero); float[,] modelMatrix = MathHelpers.SimpleModelMatrix((float)mDrawCount / 50.0f); Gles.glUniformMatrix4fv(mModelUniformLocation, 1, Gles.GL_FALSE, modelMatrix); float[,] viewMatrix = MathHelpers.SimpleViewMatrix(); Gles.glUniformMatrix4fv(mViewUniformLocation, 1, Gles.GL_FALSE, viewMatrix); float[,] projectionMatrix = MathHelpers.SimpleProjectionMatrix((float)mWindowWidth / (float)mWindowHeight); Gles.glUniformMatrix4fv(mProjUniformLocation, 1, Gles.GL_FALSE, projectionMatrix); // Draw 36 indices: six faces, two triangles per face, 3 indices per triangle Gles.glBindBuffer(Gles.GL_ELEMENT_ARRAY_BUFFER, mIndexBuffer); Gles.glDrawElements(Gles.GL_TRIANGLES, (6 * 2) * 3, Gles.GL_UNSIGNED_SHORT, IntPtr.Zero); mDrawCount += 1; }