110 likes | 236 Vues
This overview introduces OpenGL, a low-level graphics API developed for rendering graphics independent of platform. It covers OpenGL's history, its architectural evolution from a state machine to a programmable pipeline, and the distinction between fixed-function and programmable shaders. Further, it highlights libraries associated with OpenGL, such as GLUT, SDL, and GLFW, which facilitate window management and input handling. With code examples and an emphasis on practical implementation, this guide serves as a stepping stone for beginners in computer graphics.
E N D
02 |Introduction to OpenGL Eriq Muhammad Adams J | eriq.adams@ub.ac.id
What is OpenGL ? • Low-level Graphics API (Application Programming Interface) / antarmuka perangkat lunak ke kartu grafis. • Independen terhadap platform (hanya menyediakan fungsi grafis, tidak menyediakan fungsi yang dependen terhadap platform : input handling, windowing, dsb). • Banyak digunakan di aplikasi grafis : CAD programs, games, data visualization, dsb.
OpenGL History • Dikembangkan pertama kali oleh SGI (Silicon Graphics, Inc). • 1992 diambil alih oleh OpenGL ARB (Architecture Review Board) : 3DLabs, ATI, Dell, Evans & Sutherland, Hewlett-Packard, IBM, Intel, Matrox, NVIDIA, SGI, Sun Microsystems sebagai pembuat dan pengelola spesifikasi OpenGL. • 2006 dikontrol oleh The Khronos group.
OpenGL Architecture • Sebuah state machine, contoh untuk menggambar objek dengan warna merah programmer harus merubah color state ke merah lalu menggambar objek tersebut. • Tetapi sejak OpenGL 3.0 (programmable pipeline/shader based) menjadi less state- oriented API : state functions untuk color, normals, lighting deprecated (kadaluarsa).
Fixed-Function vs Programmability • Fixed-function pipeline dirancang utk berjalan di CPU (single-path rendering). • Programmable pipeline (shader based) dirancang utk berjalan di GPU sehingga lebih flexible dan mudah dikontrol oleh programmer. • Ada 3 jenis shaders : Vertex shaders (memodifikasi vertex), Fragment shaders (memodifikasi pixel), Geometry shaders (menggenerate vertices, dan bukan fitur inti).
Related Libraries • GLUT (OpenGL Utility Toolkit) menyediakan fungsi untuk windowing, menus, input-handling. • SDL (Simple Direct Media Layer) : librari multimedia cross-platform . • GLFW : windowing, creating an OpenGL context and managing input .
OpenGL Syntax • Diawali dengan awalan gl : glVertex3f() • Nomor menunjukkan jumlah parameter : glVertex3f(1.0f, 1.0f, 1.0f) punya 3 parameter • Huruf setelah nomor menunjukkan tipe data parameter : glVertex3f() bertipe data float.
Simple CG Program Architecture Inisialisasi • Berisi kode inisialisasi : penciptaan window, loading resource, dsb . • berisi finite loop untuk update logika, dan rendering. Update logika Rendering Keluar ? De-Inisialisasi
Setup OpenGL (using GLFW) • Silakan lihat petunjuk dan unduh contoh demo program di https://github.com/e4dams/grafika-komputer
Hello OpenGL ! https://github.com/e4dams/grafika-komputer/tree/master/your_projects/Pertemuan_02