Skip to content

[Note] Program 2.1

Juhwi Eden Kim edited this page Oct 7, 2019 · 4 revisions
  • 초기화: GLFW - glfwInit() / GLEW - glewInit()

  • glfwCreateWindow() : GLFW 윈도우, 이와 연결된 OpenGL 컨텍스트 생성 (옵션은 window hints로)
  • window hint : 컴퓨터가 호환되어야 하는 OpenGL 버전 2.0 ("major"=2. "minor"=0) 책에는 4.3으로 되어 있음

  • VSync(vertical synchronization) : glfwSwapInterval(), glfwSwapBuffers() - GLFW windows are by default double-buffered.
  • double buffering : there are two color buffers - one that is displayed, and one that is being rendered to. After an entire frame is rendered, the buffers are swapped. Double buffering is used to reduce undesirable visual artifacts.

  • glfwMakeContextCurrent() : GLFW 윈도우가 OpenGL 컨텍스트를 current로 자동생성하지 않아서 필요

  • rendering loop의 구성 : display(), glfwSwapBuffers(), glfwPollEvents()
  • glfwSwapBuffers() : paints the screen
  • glfwPollEvents() : handles window-related events (키가 눌리는 것 같은)
  • glfwWindowShouldClose() : 창이 닫혀야 하는 이벤트 (X키가 눌리는 것 같은)

  • init(window), display(window) : window object를 참조로 가지고 있음, 이 함수들은 특정 상황에서 window object에 접근해야 할 수 있음
  • display(glfwGetTime()) : 현재 시간(초기화 후 경과된 시간)을 받아 옴, 사용 중인 컴퓨터에 관계 없이 애니메이션이 동일 속도로 실행되도록 시간을 맞추는 데 유용

  • glClear() : OpenGl이 가진 (여기서는 color)버퍼를 모두 clear, 미리 정의된 색 'clear color'로 채움 (투명한의 clear가 아니라, cleared의 clear)
  • GL_COLOR_BUFFER_BIT : GLbitfield, color buffer를 참조함
  • color buffer : one of predefined OpenGL constants(몇개는 enums으로 부름), 픽셀들이 렌더링될 때 픽셀들을 포함하는 버퍼
  • glClearColor() : glClear()가 채울 색 'clear color'를 미리 정의

  • glfwDestroyWindow(), glfwTerminate() : 사용자가 GLFW 윈도우를 닫으려 할 때 render loop를 exit, main 함수가 GLFW에게 윈도우를 destroy, terminate할 것을 각각 요청 - 차이는?

Clone this wiki locally