a window ◼ Check success at L30. If failed, print an error message. ◼ After glfwCreateWindow call, you must call glfwTerminate regardless of its success. Computer Graphics Course @Waseda University
OpenGL window (GLFWwindow*) ◼ Outputs: no output ◼ What is OpenGL context? ◼ Set of parameters and data for OpenGL ◼ Parameters for target buffer (= set of pixels) ◼ Data for vertices, textures to specify a scene ◼ In this course, you will make only one context ◼ You don’t care about it seriously ◼ For multithread or multi-window systems, you need to manage multiple contexts. Computer Graphics Course @Waseda University
display ◼ Initialization here is for software side settings ◼ c.f.) glfwInit initializes hardware side settings ◼ Typical settings ◼ Color for filling backgrounds (now only this one) ◼ Enable features (depth testing, face culling, textures) ◼ Create shader program and vertex buffers Computer Graphics Course @Waseda University
color, but is for filling color buffers. ◼ Arguments: ◼ 1st, 2nd, 3rd: red, green and blue components ◼ 4th: alpha channel (transparency, specify 1.0) ◼ For each of them, 0 is minimum, 1 is maximum (float types) ◼ Outputs: no outputs ◼ Quick intro to color space ◼ RGB color ◼ Specified by three channels, i.e., R (red), G (green), B (blue) ◼ Other color spaces? (not supported by OpenGL) ◼ CMYK (for printing), HSV (color editing), Lab (perceptual) Computer Graphics Course @Waseda University
Check if window closing operation is queued ◼ Arguments: ◼ Window pointer to check its close (GLFWwindow*) ◼ Outputs: boolean (can be closed or not) Loop continues while close operation is not queued
University ◼ glClear ◼ Clear (= fill with values) buffers specified ◼ Arguments: ◼ Buffers to be cleared (int) ◼ Outputs: no outputs ◼ Notice ◼ For color buffer, value specified by glClearColor is used ◼ glClearColor does not clear color buffer (name is bit confusing)
different render buffers ◼ Draw something to hidden buffer, and swap after finished ◼ Important for heavy drawing processes Computer Graphics Course @Waseda University Single Double Start Start Finish Finish Drawing Drawing
by default ◼ Front buffer & back buffer ◼ Modern APIs (DirectX, Vulkan) can use buffers more than three (which is called “swap chain”) ◼ Target buffer is specified by glDrawBuffer (GL_BACK is default) Computer Graphics Course @Waseda University
arguments are changed. Especially, what happens if you specify non-one value for 4th argument of glClearColor (will it change window transparency?) ◼ Practice 2-2 ◼ Check what happens if glClear is not called Computer Graphics Course @Waseda University
geometry data will be specified ◼ Arguments: ◼ Type of primitives you draw ◼ GL_TRIANGLES: triangles ◼ GL_LINES: polylines defined by series of edges ◼ GL_LINE_STRIP: polylines defined by series of vertices ◼ GL_QUADS: quadrangles ◼ glEnd ◼ Notify OpenGL that data specification is finished ◼ Arguments: no arguments Computer Graphics Course @Waseda University
Y coordinates of a vertex ◼ glColor3f ◼ Arguments: ◼ Red, green and blue components of vertex color (min: 0, max: 1) Computer Graphics Course @Waseda University Call above methods three times to specify a triangle!
specify vertex color only once at the beginning ◼ Practice 2-4 ◼ Check what happens if you change vertex colors (test more than 3 combinations) ◼ Practice 2-5 ◼ Check what happens if you change vertex positions (test at least one case where absolute value of X/Y coordinate is more than 1) Computer Graphics Course @Waseda University
color is kept until next glColor3f call. → same color is used when you call it only once ◼ Color interpolation ◼ OpenGL need to know which pixel is inside triangle. ◼ Pixel locations inside triangle is calculated by interpolating 3 corners of triangle. ◼ Other data for vertices (color, normal, etc.) are also interpolated → interpolated colors are shown without doing anything Computer Graphics Course @Waseda University