Skip to content

Commit 838a22b

Browse files
committed
Enable backface culling
1 parent 6e914ad commit 838a22b

1 file changed

Lines changed: 10 additions & 6 deletions

File tree

src/opengl_visualization/main.clj

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ void main()
206206
(GL20/glUniform2f (GL20/glGetUniformLocation program "iResolution") window-width window-height))
207207

208208
;; Since the correct VAO is already bound, we are now ready to draw the quad.
209-
(GL11/glDrawElements GL11/GL_QUADS 4 GL11/GL_UNSIGNED_INT 0)
209+
(GL11/glDrawElements GL11/GL_QUADS (count indices) GL11/GL_UNSIGNED_INT 0)
210210
(screenshot)
211211

212212
;; ### Finishing up
@@ -316,11 +316,11 @@ void main()
316316
;; The index array defines the order of the vertices.
317317
(def indices-cube
318318
(int-array [0 1 2 3
319-
4 5 6 7
319+
7 6 5 4
320320
0 3 7 4
321-
1 2 6 5
321+
5 6 2 1
322322
3 2 6 7
323-
0 1 5 4]))
323+
4 5 1 0]))
324324

325325
;; ### Initialize vertex buffer array
326326
;;
@@ -407,11 +407,12 @@ void main()
407407

408408
;; Enable depth testing and render.
409409
(do
410-
(GL11/glEnable GL11/GL_DEPTH_TEST)
410+
(GL11/glEnable GL11/GL_CULL_FACE)
411+
(GL11/glCullFace GL11/GL_BACK)
411412
(GL11/glClearColor 0.0 0.0 0.0 1.0)
412413
(GL11/glClearDepth 1.0)
413414
(GL11/glClear (bit-or GL11/GL_COLOR_BUFFER_BIT GL11/GL_DEPTH_BUFFER_BIT))
414-
(GL11/glDrawElements GL11/GL_QUADS 24 GL11/GL_UNSIGNED_INT 0)
415+
(GL11/glDrawElements GL11/GL_QUADS (count indices-cube) GL11/GL_UNSIGNED_INT 0)
415416
(screenshot))
416417

417418
;; ### Finishing up
@@ -423,6 +424,9 @@ void main()
423424
(GL30/glBindVertexArray 0)
424425
(GL15/glDeleteBuffers vao))
425426

427+
;; ## Approximating a sphere
428+
429+
426430
(GL20/glDeleteProgram program)
427431
(GL11/glDeleteTextures texture)
428432

0 commit comments

Comments
 (0)