Rendering. Part 1 An introduction to OpenGL

Similar documents
Lecture 4 of 41. Lab 1a: OpenGL Basics

ERKELEY DAVIS IRVINE LOS ANGELES RIVERSIDE SAN DIEGO SAN FRANCISCO EECS 104. Fundamentals of Computer Graphics. OpenGL

RECITATION - 1. Ceng477 Fall

Introduction to Computer Graphics with OpenGL/GLUT

Information Coding / Computer Graphics, ISY, LiTH. OpenGL! ! where it fits!! what it contains!! how you work with it 11(40)

Computer Graphics. OpenGL

CS Computer Graphics: OpenGL, Continued

CS Computer Graphics: OpenGL, Continued

CS 4204 Computer Graphics

API for creating a display window and using keyboard/mouse interations. See RayWindow.cpp to see how these are used for Assignment3

Image Processing. Geometry Processing. Reading: (Not really covered in our text. See Sects 18.1, 18.2.) Overview: Display

Today s Agenda. Basic design of a graphics system. Introduction to OpenGL

Computer Graphics 1 Computer Graphics 1

OpenGL. Jimmy Johansson Norrköping Visualization and Interaction Studio Linköping University

Lecture 2 2D transformations Introduction to OpenGL

Introduction to OpenGL. CSCI 4229/5229 Computer Graphics Fall 2012

CS 543 Lecture 1 (Part 3) Prof Emmanuel Agu. Computer Science Dept. Worcester Polytechnic Institute (WPI)

Computer Graphics. Bing-Yu Chen National Taiwan University

Computer Graphics. Making Pictures. Computer Graphics CSC470 1

Lecture 3 Advanced Computer Graphics (CS & SE )

Programming with OpenGL Part 2: Complete Programs Computer Graphics I, Fall

Exercise 1 Introduction to OpenGL

CSC Graphics Programming. Budditha Hettige Department of Statistics and Computer Science

GL_COLOR_BUFFER_BIT, GL_PROJECTION, GL_MODELVIEW

To Do. Computer Graphics (Fall 2008) Course Outline. Course Outline. Methodology for Lecture. Demo: Surreal (HW 3)

Programming using OpenGL: A first Introduction

OpenGL refresher. Advanced Computer Graphics 2012

COMP 371/4 Computer Graphics Week 1

Teacher Assistant : Tamir Grossinger Reception hours: by - Building 37 / office -102 Assignments: 4 programing using

CSC 8470 Computer Graphics. What is Computer Graphics?

CS 4731 Lecture 3: Introduction to OpenGL and GLUT: Part II. Emmanuel Agu

Basic Graphics Programming

OpenGL/GLUT Intro. Week 1, Fri Jan 12

Drawing Primitives. OpenGL basics

Computer Graphics Course 2005

Computer Graphics Introduction to OpenGL

Computer graphic -- Programming with OpenGL I

Computer Graphics Primitive Attributes

Introduction to OpenGL Week 1

Objectives. Image Formation Revisited. Physical Approaches. The Programmer s Interface. Practical Approach. Introduction to OpenGL Week 1

Basic Graphics Programming

Announcement. Homework 1 has been posted in dropbox and course website. Due: 1:15 pm, Monday, September 12

11/1/13. Basic Graphics Programming. Teaching Assistant. What is OpenGL. Course Producer. Where is OpenGL used. Graphics library (API)

Comp 410/510 Computer Graphics Spring Programming with OpenGL Part 2: First Program

CS559: Computer Graphics. Lecture 12: OpenGL Li Zhang Spring 2008

Programming with OpenGL Part 1: Background

2D Drawing Primitives

Geometry Primitives. Computer Science Department University of Malta. Sandro Spina Computer Graphics and Simulation Group. CGSG Geometry Primitives

Programming of Graphics

An Interactive Introduction to OpenGL Programming

VR-programming tools (procedural) More VRML later in this course! (declarative)

Computer Graphics (Basic OpenGL)

Graphics Programming. 1. The Sierpinski Gasket. Chapter 2. Introduction:

Graphics Programming. August 31, Programming of the Sierpinski gasket. Programming with OpenGL and C/C++

Draw the basic Geometry Objects. Hanyang University

CMSC 425: Lecture 4 More about OpenGL and GLUT Tuesday, Feb 5, 2013

OpenGL. Toolkits.

Precept 2 Aleksey Boyko February 18, 2011

Computer Graphics (CS 4731) OpenGL/GLUT(Part 1)

Lectures OpenGL Introduction

Assignment 1. Simple Graphics program using OpenGL

Computer Graphics. Chapter 3 Computer Graphics Software

// double buffering and RGB glutinitdisplaymode(glut_double GLUT_RGBA); // your own initializations

Lecture 2 CISC440/640 Spring Department of Computer and Information Science

CS 432 Interactive Computer Graphics

Rendering Pipeline/ OpenGL

Computer graphics MN1

Computer Graphics, Chapt 08

GLUT. What is OpenGL? Introduction to OpenGL and GLUT

Early History of APIs. PHIGS and X. SGI and GL. Programming with OpenGL Part 1: Background. Objectives

CSE 167: Introduction to Computer Graphics Lecture #5: Visibility, OpenGL

Graphics Programming

Programming with OpenGL Part 1: Background

CS559: Computer Graphics. Lecture 12: OpenGL Transformation Li Zhang Spring 2008

Introduction to OpenGL

RASTERISED RENDERING

Computer graphic -- Programming with OpenGL 2

Graphics Pipeline & APIs

COMPUTER GRAPHICS LAB # 3

CS 428: Fall Introduction to. OpenGL primer. Andrew Nealen, Rutgers, /13/2010 1

Cameras (and eye) Ideal Pinhole. Real Pinhole. Real + lens. Depth of field

This library uses only GL functions but contains code for creating common objects and simplifying viewing.

CS450/550. Pipeline Architecture. Adapted From: Angel and Shreiner: Interactive Computer Graphics6E Addison-Wesley 2012

CSE528 Computer Graphics: Theory, Algorithms, and Applications

Graphics Pipeline & APIs

Simple Geometric Modeling

三維繪圖程式設計 3D Graphics Programming Design 第三章三維繪圖狀態設定和幾何元件繪製嘉大資工系盧天麒

Lecture 2. Determinants. Ax = 0. a 11 x 1 + a 12 x a 1n x n = 0 a 21 x 1 + a 22 x a 2n x n = 0

Graphics and Visualization

Computer Graphics Introduction to OpenGL

Computer Graphics. Downloaded from: LectureNotes 1 CSC-254

An Overview GLUT GLSL GLEW

Class of Algorithms. Visible Surface Determination. Back Face Culling Test. Back Face Culling: Object Space v. Back Face Culling: Object Space.

SOURCES AND URLS BIBLIOGRAPHY AND REFERENCES

World Coordinate System

Normalized Device Coordinate System (NDC) World Coordinate System. Example Coordinate Systems. Device Coordinate System

cs123 Lab 3 OpenGL Part One 1 Introduction 2 OpenGL Basics 2.2 The Rendering Pipeline 2.1 The CPU and the GPU 2.3 Basic Syntax of OpenGL commands

An Interactive Introduction to OpenGL and OpenGL ES Programming. Ed Angel Dave Shreiner

API Background. Prof. George Wolberg Dept. of Computer Science City College of New York

2. OpenGL -I. 2.1 What is OpenGL? Things OpenGL can do: -23-

Transcription:

Rendering Part 1 An introduction to OpenGL Olivier Gourmel VORTEX Team IRIT University of Toulouse gourmel@irit.fr

Image synthesis The Graphics Processing Unit (GPU): A highly parallel architecture specialized in the rasterization of objects composed of polygons (meshes), usually triangles.

The GPU Architecture of a GPU (nvidia GeForce 6800)

The graphic pipeline Input: Geometry Lighting model Camera Model Output area Output: Color value at each pixel Stored in the framebuffer

The graphic pipeline 3D Objects: Defined in their own frame (object space) The object frame is located in the world space (with regards to world frame)

The graphic pipeline Transforms vertex coordinates from the world space to the camera space (eye coordinates)

The graphic pipeline Clipping : Transforms eye coordinates to Normalized Device Coordinates (NDC) (maps each coordinates to range [-1, 1]) Suppresses geometry outside the viewing volume

The graphic pipeline Projection to screen space (2D) :

The graphic pipeline Rasterization : for each triangle Computes the pixels overlapped by this triangle (fragments) Interpolates the vertex attributes (color, normals, depth...) at each fragment

The graphic pipeline Eliminates hidden fragments using a depth buffer A depth buffer stores the depth of the last fragment written at each pixel.

The graphic pipeline Object space World space Eye space Normalized device coordinates Screen space

Introduction to OpenGL OpenGL : Open Graphics Library Standard specification (Architecture Review Board (ARB)) API : software interface with graphic hardware State machine 200 commands to write interactive 3D programs State variables : viewing frustum, drawing color, material properties, light properties, etc. OpenGL is not A window manager A 3D modeling tool

Basic commands General form of an OpenGL function: void gl {2,3,4}{s,i,f,d}[v] (TYPE coords); 2: (x, y) 3: (x, y, z) 4: (x, y, z, h) s: short i: int f: float d: double v: vector (array) GLshort -- s GLfloat -- f GLdouble -- d GLint -- i GLxx * -- v

Basic commands Vertex: basic component of a primitive glvertex {2,3}{s,i,f,d}[v]() Defined between a glbegin() and a glend() Specification of a mode (type of the primitive) glbegin(mode); glvertex*(coordinates); glvertex*(coordinates);.. glvertex*(coordinates); glend(); MODES GL_POINTS GL_LINES GL_LINE_STRIP GL_LINE_LOOP GL_POLYGON GL_TRIANGLES GL_TRIANGLE_STRIP GL_TRIANGLE_FAN GL_QUADS GL_QUAD_STRIP

Basic commands glvertex* (coordinates) Samples: glvertex2s(2, 3); glvertex3d(0.0, 0.0, 3.1415926535898); glvertex3f( 2.3f, 12.0f, -4.8f); GLdouble dvect[3]={5.0, 9.0, 1435.0}; glvertex3dv(dvect); typedef struct { GLfloat x, y, z; } Point3D; Point3D pt = {0.0, 4.0, 6.0}; glvertex3fv((glfloat *) &pt);

Basic commands Primitive types: Points Line segments Independent line segments Polylines Empty polygons

Basic operations Primitive types Filled polygons polygons, independent triangles or quads triangle fan, triangle strip, quad strip

Basic operations Polygons orientation Default : front face if oriented counterclockwise on the screen Can be changed : glfrontface(mode) Mode : GL_CCW (counterclockwise), GL_CW (clockwise) Drawing mode of the faces glpolygonmode(face, mode) Face : GL_FRONT, GL_BACK, GL_FRONT_AND_BACK Mode : GL_POINT, GL_LINE, GL_FILL

Introduction to OpenGL Programming interfaces Application software OpenGL Glx Driver Hardware X-Window

Introduction to OpenGL Programming interfaces Application software GLU OpenGL Glx Driver Hardware X-Window

Introduction to OpenGL Programming interfaces Application software GLU OpenGL glut Glx Driver Hardware X-Window

Introduction to GLUT GL Utility Toolkit ( OpenGL) A library to create and handle windows easily Can be used to handle events as well (key strokes, etc..) Available on various platforms Linux, Windows, MacOS...

Introduction to GLUT Initializing and creating windows Just call the functions : void glutinit(int * argc, char **argv); void glutinitdisplaymode( unsigned int mode); void glutinitwindowsize(int width, int height); void glutinitwindowposition(int x, int y); int glutcreatewindow(char *title); Then :

Introduction to GLUT Can be used to handle double buffering Can be used to redraw the window at any time void glutswapbuffers( void ); void glutpostredisplay( void ); (At last) launch the main loop (waits for an event) void glutmainloop( void );

Introduction to GLUT Handles user interactions with the use of Callback procedures: void glutdisplayfunc( void (*f)(void)); void glutreshapefunc( void (*f)(int width, int height)); void glutkeyboardfunc( void (*f)(unsigned int key, int x, int y)); void glutmousefunc(void (*f)(int button, int state, int x, int y)); void glutmotionfunc( void (*f)(int x, int y )); void glutspecialfunc( void (*f)(int key, int x, int y)); void glutidlefunc( void (*f) ( void ));

Introduction to GLUT GLUT has some predefined 3D objects: void glut{wire Solid}Cube( GLdouble size); void glut{wire Solid}Sphere( GLdouble radius, GLint slices, GLint stacks); void glut{wire Solid}Cone( GLdouble base, GLdouble height, GLint slices, GLint stacks); void glut {Wire Solid}Torus( GLdouble innerradius, GLdouble outerradius, GLint nsides, GLint rings); void glut {Wire Solid}Teapot( GLdouble size); void glut {Wire Solid}Tetrahedron(void); void glut {Wire Solid}Decahedron(void);

Tutorial: Draw a simple polygon Write an OpenGL program that draws a filled polygon in white on a black background Function that draws the polygon Function that quits the application whenever <q> is stroked void display(void) void key (unsigned char c, int mousex, int mousey) Function handling the possible change in size of the window void reshape(int width, int height) Main Include and constants