[Examples] Updated to use 1.1 API

This commit is contained in:
Stefanos A. 2014-01-30 11:40:01 +01:00
Родитель eeaa3276f1
Коммит bc95477488
1 изменённых файлов: 5 добавлений и 7 удалений

Просмотреть файл

@ -132,9 +132,7 @@ void main(void)
GL.AttachShader(shaderProgramHandle, fragmentShaderHandle); GL.AttachShader(shaderProgramHandle, fragmentShaderHandle);
GL.LinkProgram(shaderProgramHandle); GL.LinkProgram(shaderProgramHandle);
Debug.WriteLine(GL.GetProgramInfoLog(shaderProgramHandle)); Debug.WriteLine(GL.GetProgramInfoLog(shaderProgramHandle));
GL.UseProgram(shaderProgramHandle); GL.UseProgram(shaderProgramHandle);
// Set uniforms // Set uniforms
@ -151,19 +149,19 @@ void main(void)
void CreateVBOs() void CreateVBOs()
{ {
GL.GenBuffers(1, out positionVboHandle); positionVboHandle = GL.GenBuffer();
GL.BindBuffer(BufferTarget.ArrayBuffer, positionVboHandle); GL.BindBuffer(BufferTarget.ArrayBuffer, positionVboHandle);
GL.BufferData<Vector3>(BufferTarget.ArrayBuffer, GL.BufferData<Vector3>(BufferTarget.ArrayBuffer,
new IntPtr(positionVboData.Length * Vector3.SizeInBytes), new IntPtr(positionVboData.Length * Vector3.SizeInBytes),
positionVboData, BufferUsageHint.StaticDraw); positionVboData, BufferUsageHint.StaticDraw);
GL.GenBuffers(1, out normalVboHandle); normalVboHandle = GL.GenBuffer();
GL.BindBuffer(BufferTarget.ArrayBuffer, normalVboHandle); GL.BindBuffer(BufferTarget.ArrayBuffer, normalVboHandle);
GL.BufferData<Vector3>(BufferTarget.ArrayBuffer, GL.BufferData<Vector3>(BufferTarget.ArrayBuffer,
new IntPtr(positionVboData.Length * Vector3.SizeInBytes), new IntPtr(positionVboData.Length * Vector3.SizeInBytes),
positionVboData, BufferUsageHint.StaticDraw); positionVboData, BufferUsageHint.StaticDraw);
GL.GenBuffers(1, out eboHandle); eboHandle = GL.GenBuffer();
GL.BindBuffer(BufferTarget.ElementArrayBuffer, eboHandle); GL.BindBuffer(BufferTarget.ElementArrayBuffer, eboHandle);
GL.BufferData(BufferTarget.ElementArrayBuffer, GL.BufferData(BufferTarget.ElementArrayBuffer,
new IntPtr(sizeof(uint) * indicesVboData.Length), new IntPtr(sizeof(uint) * indicesVboData.Length),
@ -179,7 +177,7 @@ void main(void)
// This means we do not have to re-issue VertexAttribPointer calls // This means we do not have to re-issue VertexAttribPointer calls
// every time we try to use a different vertex layout - these calls are // every time we try to use a different vertex layout - these calls are
// stored in the VAO so we simply need to bind the correct VAO. // stored in the VAO so we simply need to bind the correct VAO.
GL.GenVertexArrays(1, out vaoHandle); vaoHandle = GL.GenVertexArray();
GL.BindVertexArray(vaoHandle); GL.BindVertexArray(vaoHandle);
GL.EnableVertexAttribArray(0); GL.EnableVertexAttribArray(0);
@ -214,7 +212,7 @@ void main(void)
GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit); GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);
GL.BindVertexArray(vaoHandle); GL.BindVertexArray(vaoHandle);
GL.DrawElements(BeginMode.Triangles, indicesVboData.Length, GL.DrawElements(PrimitiveType.Triangles, indicesVboData.Length,
DrawElementsType.UnsignedInt, IntPtr.Zero); DrawElementsType.UnsignedInt, IntPtr.Zero);
SwapBuffers(); SwapBuffers();