DREAM IDEA PLAN IMPLEMENTATION 1 2 Introduction to






























- Slides: 30

DREAM IDEA PLAN IMPLEMENTATION 1

2

Introduction to Computer Graphics Present to: Amirkabir University of Technology (Tehran Polytechnic) & Semnan University Dr. Kourosh Kiani Email: kkiani 2004@yahoo. com Email: Kourosh. kiani@aut. ac. com Web: aut. ac. com 3

Amirkabir & Semnan University Computer & Electrical Faculty Lecture 08 Introduction to Open. GL 4 4

Early History of APIs • IFIPS (1973) formed two committees to come up with a standard graphics API – Graphical Kernel System (GKS) • 2 D but contained good workstation model – Core • Both 2 D and 3 D – GKS adopted as IS 0 and later ANSI standard (1980 s) • GKS not easily extended to 3 D (GKS-3 D) – Far behind hardware development 5

PHIGS and X • Programmers Hierarchical Graphics System (PHIGS) – Arose from CAD community – Database model with retained graphics (structures) • X Window System – DEC/MIT effort – Client-server architecture with graphics • PEX combined the two – Not easy to use (all the defects of each) 6

SGI and GL • Silicon Graphics (SGI) revolutionized the graphics workstation by implementing the pipeline in hardware (1982) • To access the system, application programmers used a library called GL • With GL, it was relatively simple to program three dimensional interactive applications 7

Open. GL The success of GL lead to Open. GL (1992), a platform-independent API that was – Easy to use – Close enough to the hardware to get excellent performance – Focus on rendering – Omitted windowing and input to avoid window system dependencies 8

Open. GL Evolution • Originally controlled by an Architectural Review Board (ARB) – Members included SGI, Microsoft, Nvidia, HP, 3 DLabs, IBM, ……. – Relatively stable (present version 2. 1) • Evolution reflects new hardware capabilities – 3 D texture mapping and texture objects – Vertex programs – Allows for platform specific features through extensions – ARB replaced by Khronos 9

Graphics API v. s. Application API • Graphics API – A software interface for graphics hardware. – Provide the low-level functions to access graphics hardware directly. – Example • Open. GL / Direct 3 D • Application API – High level interface for application development. – Example • Game Engine, VR tools… 10

What is Open. GL • Industry standard. • Hardware independent. • OS independent. 11

Open. GL 12

What is Open. GL 3/4 • What Open. GL does not provide – Window system events. – User input and output. – High level functions for 3 D model description. – Each window system has its own library to initialize Open. GL environment. • WGL, GLX, AGL, … • GLUT

What is Open. GL • Graphics API to access graphics hardware directly. • Features – Industry standard. • Game, CAD, Film Industry… – Hardware independent. • All platforms, All graphics hardwares. – Window system independent. • Win 32, X-win, Mac… 14

What Open. GL provides • • 15 Draw with points, lines, and polygons. Matrix(View) Transformation Hidden Surface Removal (Z-Buffer) Light effects Gouraud Shading Texture mapping Pixels operation

The Buffers • A buffer is a memory area in the graphics hardware for some special purposes. • An Open. GL system can manipulate the four buffers: – – 16 Color buffers Depth buffer (Z-Buffer) Stencil buffer Accumulation buffer

Open. GL Libraries • Open. GL Library – The basic library to access the graphics hardware. • GLU – Provide some useful utilities based on the Open. GL library. • GLX / WGL / AGL – OS dependent libraries to bind the Open. GL library with specific window system. – GLX for X-window, WGL for win 32, AGL for Apple. 17

Open. GL Utility Toolkit (GLUT) • A window system-independent toolkit to hide the complexities of differing window system APIs. • Use the prefix of glut. (ex: glut. Display. Func()) • Provide following operations: – Initializing and creating window – Handling window and input events – Drawing basic three-dimensional objects – Running the program 18

Software Organization Application Program Open. GL Motif widget or similar GLUT GLX, AGL or WGL GLU X, Win 32, Mac O/S Software and/or Hardware 19 GL

Open. GL Utility Toolkit (GLUT) • Where can I get GLUT? – Win 32: • http: //www. xmission. com/~nate/glut. html – Linux: • http: //www. mesa 3 d. org/ 20

Open. GL Utility Toolkit (GLUT) • On Microsoft Visual C++ 6: – Put glut. h into <MSVC>/include/GL/ – Put glut. lib into <MSVC>/lib/ – Put glut 32. dll into <window>/System 32/ • On Microsoft Visual C++. NET: – Put glut. h into <MSVC>/platform. SDK/include/GL/ – Put glut. lib into <MSVC>/platform. SDK/lib/ – Put glut 32. dll into <window>/System 32/ 21

How to Compile • On Microsoft Visual C++ 6: – Create a new Project with Win 32 Console Application – Open Project Settings dialog and add opengl 32. lib glut 32. lib into Link/Objects/library modules. – Writing your Open. GL code. – Compile it. 22

The Simplest Program #include <GL/glut. h> void GL_display() { gl. Clear. Color(0. 0 f, 0. 0 f); gl. Clear(GL_COLOR_BUFFER_BIT); gl. Color 3 f(1. 0 f, 1. 0 f); glut. Solid. Cube(1. 0); gl. Flush(); } void GL_reshape(GLsizei w, GLsizei h) { gl. Viewport(0, 0, w, h); gl. Matrix. Mode(GL_PROJECTION); gl. Load. Identity(); gl. Ortho(-2. 0 f, -2. 0 f, 2. 0 f); gl. Matrix. Mode(GL_MODELVIEW); gl. Load. Identity(); } 23 1/3

The Simplest Program void main(void) { glut. Init. Display. Mode(GLUT_SINGLE | GLUT_RGB); glut. Create. Window("Sample"); glut. Display. Func(GL_display); glut. Reshape. Func(GL_reshape); glut. Main. Loop(); } 24

25

#include <GL/glut. h> void mydisplay() { gl. Clear(GL_COLOR_BUFFER_BIT); gl. Begin(GL_POLYGON); gl. Vertex 2 f(-0. 5, -0. 5); gl. Vertex 2 f(-0. 5, 0. 5); gl. Vertex 2 f(0. 5, -0. 5); gl. End(); gl. Flush(); } int main(int argc, char** argv) { glut. Create. Window(“Dr. kiani 2"); glut. Display. Func(mydisplay); glut. Main. Loop(); return 0; } 26

27

28

Questions? Discussion? Suggestions ?

30