to OpenGL Introduction Pipeline Graphics pipeline OpenGL pipeline OpenGL syntax Modeling Arrays Conclusion 1 Introduction Introduction to OpenGL

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

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

Graphics Programming

Computer Graphics (Basic OpenGL)

Exercise 1 Introduction to OpenGL

Announcements OpenGL. Computer Graphics. Autumn 2009 CS4815

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

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

OpenGL/GLUT Intro. Week 1, Fri Jan 12

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

Programming using OpenGL: A first Introduction

Lecture 2 2D transformations Introduction to OpenGL

CS Computer Graphics: OpenGL, Continued

CS Computer Graphics: OpenGL, Continued

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

Lecture 3. Understanding of OPenGL programming

Computer Graphics. Making Pictures. Computer Graphics CSC470 1

Announcements OpenGL. Computer Graphics. Spring CS4815

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

Introduction to OpenGL

Lectures OpenGL Introduction

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

GL_COLOR_BUFFER_BIT, GL_PROJECTION, GL_MODELVIEW

Basic Graphics Programming

Computer Graphics. Bing-Yu Chen National Taiwan University

Lecture 4 of 41. Lab 1a: OpenGL Basics

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

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

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

Drawing Primitives. OpenGL basics

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

1.2 Basic Graphics Programming

Computer Graphics, Chapt 08

Rendering Pipeline/ OpenGL

OpenGL JOGL. OpenGL & JOGL. Shaoting Zhang, or Tony. September 12, 2007

Computer Graphics 1 Computer Graphics 1

Introduction to OpenGL

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

Computer Graphics Course 2005

Introduction to OpenGL Week 1

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

CS 4204 Computer Graphics

Graphics Hardware and OpenGL

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

Introduction to Computer Graphics with OpenGL/GLUT

Duc Nguyen CSE 420 Computer Graphics 10/10/2018 Homework 1

Basic Graphics Programming

Computer Graphics (CS 543) Lecture 3b: Shader Setup & GLSL Introduction

3D computer graphics: geometric modeling of objects in the computer and rendering them

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

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

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

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

Programming with OpenGL Part 1: Background

CSE528 Computer Graphics: Theory, Algorithms, and Applications

Programming with OpenGL Part 1: Background

by modifying the glutinitwindowsize() function you can change the screen size to whatever you please.

CSE4030 Introduction to Computer Graphics

Classic Rendering Pipeline

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

Computer graphics MN1

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

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

Rendering Pipeline/ OpenGL

Computer Graphics. OpenGL

SOURCES AND URLS BIBLIOGRAPHY AND REFERENCES

Bob s Concise Introduction to Doxygen

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

Books, OpenGL, GLUT, GLUI, CUDA, OpenCL, OpenCV, PointClouds, and G3D

COMP 371/4 Computer Graphics Week 1

CS380: Computer Graphics Screen Space & World Space. Sung-Eui Yoon ( 윤성의 ) Course URL:

GLUT. What is OpenGL? Introduction to OpenGL and GLUT

Lecture 3 Advanced Computer Graphics (CS & SE )

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

2/3/16. Interaction. Triangles (Clarification) Choice of Programming Language. Buffer Objects. The CPU-GPU bus. CSCI 420 Computer Graphics Lecture 3


Interaction. CSCI 420 Computer Graphics Lecture 3

Interaction Computer Graphics I Lecture 3

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

Image Rendering. Rendering can be divided into three sub-problems. Image Formation The hidden surface problem visibility determination steps

Books, OpenGL, GLUT, CUDA, OpenCL, OpenCV, PointClouds, G3D, and Qt

RECITATION - 1. Ceng477 Fall

Precept 2 Aleksey Boyko February 18, 2011

An Overview GLUT GLSL GLEW

Programming with OpenGL Part 3: Three Dimensions

OpenGL and GLUT. COMP413 Computer Graphics. School of Computer Sci. & Eng. Kyungpook National University, Korea. Spring Semester, 2016

Computer Graphics. Chapter 3 Computer Graphics Software

1/12/11. Basic Graphics Programming. What is OpenGL. OpenGL is cross-platform. How does OpenGL work. How does OpenGL work (continued) The result

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

C++ is Fun Part 13 at Turbine/Warner Bros.! Russell Hanson

OpenGL. Toolkits.

COMPUTER GRAPHICS LAB # 3

Ulf Assarsson Department of Computer Engineering Chalmers University of Technology

Interaction. CSCI 480 Computer Graphics Lecture 3

Introduction to OpenGL: Part 2

Abel J. P. Gomes LAB. 1. INTRODUCTION TO OpenGL

Lecture 5: Viewing. CSE Computer Graphics (Fall 2010)

Introduction to OpenGL

Screen Space & World Space

CS 432 Interactive Computer Graphics

Transcription:

to to ning Lecture : introduction to Lab : first steps in and - 25/02/2009 Lecture/Lab : transformations and hierarchical - 04/03/2009 to Lecture : lights and materials in - 11/03/2009 Lab : lights and materials in - 18/03/2009 Estelle Duveau - estelle.duveau@inria.fr Lecture : textures in Lab : textures in - 25/03/2009 Lab : procedural animation - 01/04/2009 MoSIG1, to Computer Graphics, 25/02/2009 Lab : physical animation : particle systems - 08/04/2009 Lab : physical animation : collisions - 22/04/2009 1 2 to to References 1 2 D. Shreiner, M. Woo, J. Neider, T. Davis Programming Guide 3 aka the red book http://opengl-redbook.com 4 3 4 to What is it? 1 2 3 4 API (Application Programming Interface) for graphics hardware Non-dependant on the architecture or programming language Developped in 1989 (GL) by Silicon Graphics, extended to other architectures in 1993 () About 250 commands 5

to It s a state machine! to Things it can NOT do State machine = each parameter retains its value and is used with that value until being explicitely changed Parameters can be : modes : shading mode, matrix manipulated... glshademode(gl FLAT); glshademode(gl SMOOTH); Can NOT create nor manage a viewer Can NOT manage complex objects : only 3 types of geometric (points, lines, polygons) booleans : lights on/off, blend colors,... glenable(gl LIGHT0); gldisable(gl LIGHT1); scalar values : colors, viewpoint,... glcolor3f(0.0,0.0,0.0); glnormal3f(1.0,0.0,0.0); Additional libraries needed : GLU : opengl Utility library : more complex 3D models GLUT : opengl Utility Toolkit : viewer 6 7 to Example : with GLUT int main(int argc, char** argv){ glutinit(&argc,argv); glutinitdisplaymode(glut SINGLE GLUT RGB); glutinitwindowsize(250,250); glutinitwindowposition(100,100); glutcreatewindow("hello"); // not yet displayed init(); // to define with glutdisplayfunc(display); glutmousefunc(mouse); glutkeyboardfunc(keyboard); // call back functions to define with glutmainloop; // Let s go! Scene displayed return 0; } 1 2 3 4 8 to Graphics 1 2 3 1 Create 3D models () 2 Build the scene from instances of models placed in a world frame ( transformation) 3 Convert to camera frame (culling, frustrum) 4 Convert to screen frame (projection) 4 5 Compute image (rasterization) 9

to 1 2 3 4 Create context Loop : 1 Manage mouse/keyboard events 2 Display 1 Clear screen 2 Viewpoint 3 For each object : 1 Place object 2 Modify state machine 3 Draw 10 to Display : void display () { 1 Clear screen glclear(gl COLOR BUFFER BIT); 2 Viewpoint glmatrixmode(gl PROJECTION); glortho(0.0,1.0,0.0,1.0,-1.0,1.0); Basic example - 1/2 3 For each object : 1 Place object glmatrixmode(gl MODELVIEW); 2 Modify state machine glcolor3f(1.0,1.0,1.0); 3 Draw glvertex3f(0.25,0.25,0.0); glvertex3f(0.75,0.25,0.0); glvertex3f(0.75,0.75,0.0); glvertex3f(0.25,0.75,0.0); glflush(); // Execute commands in hold to Basic example - 1/2 void display () { glclear(gl COLOR BUFFER BIT); glmatrixmode(gl PROJECTION); glortho(0.0,1.0,0.0,1.0,-1.0,1.0); glmatrixmode(gl MODELVIEW); glcolor3f(1.0,1.0,1.0); glvertex3f(0.25,0.25,0.0); glvertex3f(0.75,0.25,0.0); glvertex3f(0.75,0.75,0.0); glvertex3f(0.25,0.75,0.0); glflush(); } } 11 12 to Basic example - 2/2 1 2 3 4 13

to Syntax - 1/2 to Syntax - 2/2 Reminder : modes : gl[mode]mode(gl VALUE) booleans : glenable(gl VALUE) constants start with GL scalar values : glcolor3f(1.0,1.0,1.0); gl : command... 3 :... that has 3 arguments... f :... of type float. glcolor3fv(color array); suffixes and types b integer (8 bits) signed char GLbyte s integer (16 bits) short GLshort i integer (32 bits) int ou long GLint f real (32 bits) float GLfloat d real (64 bits) double GLdouble ub unsigned integer (8 bits) unsigned char GLubyte us unsigned integer (16 bits) unsigned long GLushort ul unsigned integer (32 bits) unsigned int ou long GLuint The argument is a vector (or array) of 3 floats (GLfloat color array[] = { 1.0,0.0,0.0 } ; ) 14 15 1 2 3 4 1 2 3 4 to to Example - planar pentagon Complex object = combination of elementary elements : 1 Points (vertices) : coordinates in a given reference frame 2 Lines : segments 3 Polygons : simple convex polygons glvertex2f(0.0, 0.0); glvertex2f(0.0, 3.0); glvertex2f(4.0, 3.0); glvertex2f(6.0, 1.5); glvertex2f(4.0, 0.0); glflush(); 16 17

to Geometric 1 2 3 4 18 to Parameters to Example : normals Point size (in pixels) : glpointsize(2.0); Line width (in pixels) : gllinewidth(3.0); Line drawing : many stippling styles Different renderings for front and back faces : glpolygonmode(gl FRONT,GL FILL); glpolygonmode(gl BACK,GL LINE); Culling : glcullface(gl BACK); : back-faces non-visible The color, normal,..., at each vertex can be specified glnormal3fv(n0); glvertex3fv(v0); glnormal3fv(n1); glvertex3fv(v1); glnormal3fv(n2); glvertex3fv(v2);... Get current values : glgetfloatv(gl LINE WIDTH); Beware of the order : parameter (i.e. normal) before coordinates 19 20 to 1 2 3 4 An array for each type of data : coordinates, normal, color, texture,... Create an array : glenableclientstate(gl NORMAL ARRAY); Use that array : glcolorpointer(3,gl FLOAT,5*sizeof(GLfloat),color); stride = offset (in bytes) between 2 consecutive data elements Access an element glarrayelement(0); : done in all active arrays Access several elements : gldrawelements(gl POLYGON,5,GL UNSIGNED INT,vertices); Also glmultidrawelements(...), gldrawrangeelements(...),... 21

to : 1 2 3 4 Done : General process : geometric Highlights : State machine Primitives the redbook To do : lab complex objects with...next week! 22