Skip to content

Commit 02ef4fe

Browse files
committed
adding a comment
1 parent 5fdd454 commit 02ef4fe

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

iOSSwiftOpenGL.xcodeproj/project.pbxproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,8 @@
100100
isa = PBXGroup;
101101
children = (
102102
AD88146E1960EEBF005F2E41 /* Main.storyboard */,
103-
AD88148D1960EFCE005F2E41 /* SimpleFragment.glsl */,
104103
AD88148B1960EFBA005F2E41 /* SimpleVertex.glsl */,
104+
AD88148D1960EFCE005F2E41 /* SimpleFragment.glsl */,
105105
AD8814711960EEBF005F2E41 /* Images.xcassets */,
106106
AD8814691960EEBF005F2E41 /* iOSSwiftOpenGL.xcdatamodeld */,
107107
AD8814661960EEBF005F2E41 /* Info.plist */,

iOSSwiftOpenGL/OpenGLView.swift

+2-1
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,6 @@ class OpenGLView: UIView {
193193

194194
glGenBuffers(1, &self.indexBuffer)
195195
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER.asUnsigned(), self.indexBuffer)
196-
197196
glBufferData(GL_ELEMENT_ARRAY_BUFFER.asUnsigned(), Int(sizeofValue(Indices)), &Indices, GL_STATIC_DRAW.asUnsigned())
198197
}
199198

@@ -219,6 +218,8 @@ class OpenGLView: UIView {
219218
glVertexAttribPointer(self.colorSlot, 4 as GLint, GL_FLOAT.asUnsigned(), GLboolean.convertFromIntegerLiteral(UInt8(GL_FALSE)), Int32(sizeof(Vertex)), colorSlotFirstComponent)
220219

221220
// Calls glDrawElements to make the magic happen! This actually ends up calling your vertex shader for every vertex you pass in, and then the fragment shader on each pixel to display on the screen.
221+
// Note that the second parameter to glDrawElements is the number of vertices to render. We use a C trick
222+
// here in order to determine this by dividing the size of Indices in bytes by the size of its first element in bytes.
222223
let vertextBufferOffset: CConstVoidPointer = COpaquePointer(UnsafePointer<Int>(0))
223224
glDrawElements(GL_TRIANGLES.asUnsigned(), Int32(GLfloat(sizeofValue(Indices)) / GLfloat(sizeofValue(Indices.0))), GL_UNSIGNED_BYTE.asUnsigned(), vertextBufferOffset)
224225

0 commit comments

Comments
 (0)