• Tidak ada hasil yang ditemukan

02 |Introduction to OpenGL

N/A
N/A
Protected

Academic year: 2022

Membagikan "02 |Introduction to OpenGL"

Copied!
14
0
0

Teks penuh

(1)

02 |Introduction to OpenGL

Imam Cholissodin| [email protected]

(2)

Introduction to OpenGL

1. Computer Graphics 2. What’s OpenGL ? 3. OpenGL History

4. OpenGL Architecture

5. Fixed-Function vs Programmability 6. Related Libraries

7. OpenGL Syntax

8. Simple CG Program Architecture 9. Setup OpenGL

10.Demo OpenGL Program

(3)

Computer Graphics

• Grafika komputer (Inggris: Computer graphics) adalah bagian dari ilmu komputer yang berkaitan dengan pembuatan dan manipulasi gambar (visual) secara digital (sumber : Wiki).

• Bagaimana menurut pemahaman anda?

(4)

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.

(5)

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.

(6)

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).

(7)

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).

(8)

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 .

(9)

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.

(10)

Simple CG Program Architecture

• Berisi kode inisialisasi : penciptaan window, loading resource, dsb .

• berisi finite loop untuk logika, dan rendering.

Inisialisasi

Update logika

Rendering

De- Inisialisasi

Keluar ?

(11)

Setup OpenGL (using GLUT)

• Windows :

http://www.cs.csustan.edu/%7ersc/SDSU/GLUT install.html

• GLUT download :

http://www.opengl.org/resources/libraries/gl ut/glut_downloads.php

(12)

Setup OpenGL

• 3 file penting dalam OpenGL yang akan digunakan, yaitu : glut.h, glut32.lib dan glu32.dll

• Letakkan glut.h ke dalam direktori :

“Programs Files\VC\include”

• Letakkan glut32.lib ke dalam direktori :

“Programs Files\VC\lib”

• Letakkan glut32.dll ke dalam direktori :

“Windows\System32”

(13)

Demo Configuration OpenGL

• Live Demo Setup OpenGL di Kelas

• Live Demo OpenGL Code Base

– Create Line

– Contoh code online dapat di akses pada link berikut :

• http://www.glprogramming.com/red/chapter01.html (hello.c & double.c)

(14)

Selesai

Imam Cholissodin| [email protected]

Referensi

Dokumen terkait