Programming With OpenGL

Slides:



Advertisements
Similar presentations
Programming with OpenGL - Getting started - Hanyang University Han Jae-Hyek.
Advertisements

©Zachary Wartell, UNCC9/28/ :30 AM 1 Overview of OpenGL Revision: 1.2 Copyright Professor Zachary Wartell, University of North Carolina All Rights.
Chapter 2: Graphics Programming
Computer Graphics CSCE 441
CS 352: Computer Graphics Chapter 7: The Rendering Pipeline.
Computer Graphics(Fall 2003) COMS 4160, Lecture 7: OpenGL 3 Ravi Ramamoorthi Many slides courtesy Greg Humphreys.
Pemrograman OpenGL Dasar
David Luebke5/16/2015 Administrivia l Back on track: canceling OpenGL lecture 2 l Assignment 1 –Greg Yukl found an alternate XForms site:
CS 4731 Lecture 2: Intro to 2D, 3D, OpenGL and GLUT (Part I) Emmanuel Agu.
 The success of GL lead to OpenGL (1992), a platform-independent API that was  Easy to use  Close enough to the hardware to get excellent performance.
What is OpenGL? Low level 2D and 3D Graphics Library Competitor to Direct3D (the rendering part of DirectX) Used in: CAD, virtual reality, scientific.
1 Angel: Interactive Computer Graphics 4E © Addison-Wesley 2005 Programming with OpenGL Part 1: Background Ed Angel Professor of Computer Science, Electrical.
Further Programming for 3D applications CE Introduction to Further Programming for 3D application Bob Hobbs Faculty of Computing, Engineering and.
Computer Graphics (Fall 2005) COMS 4160, Lecture 10: OpenGL 1
Graphics Systems I-Chen Lin’s CG slides, Doug James’s CG slides Angel, Interactive Computer Graphics, Chap 1 Introduction to Graphics Pipeline.
Introduction to OpenGL. What is OpenGL OpenGL is a low-level software interface to graphics hardware No commands for performing windowing tasks or obtaining.
Programming with OpenGL Part 1: Background Mohan Sridharan Based on slides created by Edward Angel CS4395: Computer Graphics 1.
3D Rendering with JOGL Introduction to Java OpenGL Graphic Library By Ricardo Veguilla
Introduction to OpenGL Jian Huang This set of slides are extracted from the Interactive OpenGL Programming course given by Dave Shreine, Ed Angel and Vicki.
Computer Graphics Bing-Yu Chen National Taiwan University.
Programming in OpenGL Ryan Holmes CSE 570 February 12 th, 2003.
CAP4730: Computational Structures in Computer Graphics Introduction to OpenGL.
JOGL in MS Windows GDI – Graphics Device Interface (Windows-specific) OpenGL Lib JOGL Commands GDI Processor Graphics Hardware JOGL Lib.
Programmable Pipelines. Objectives Introduce programmable pipelines ­Vertex shaders ­Fragment shaders Introduce shading languages ­Needed to describe.
Basic OpenGL Glenn G. Chappell U. of Alaska Fairbanks CS 381 Lecture Notes Wednesday, September 10, 2003.
Using OpenGL. 2 What is OpenGL? A software interface to graphics hardware It is a Graphics Rendering API (Application Programmer’s Interface) that is.
OpenGL Shading Language (Advanced Computer Graphics) Ernest Tatum.
Introduction to OpenGL and GLUT GLUT. What is OpenGL? An application programming interface (API) A (low-level) Graphics rendering API Generate high-quality.
CSC 461: Lecture 41 CSC461: Lecture 4 Introduction to OpenGL Objectives: Development of the OpenGL API OpenGL Architecture -- OpenGL as a state machine.
Graphics Architectures & OpenGL API Introduction Angel Angel: Interactive Computer Graphics5E © Addison-Wesley
Graphics Programming using OpenGL. OpenGL is a software interface that allows the programmer to create 2D and 3D graphics images. This interface consists.
OpenGl Graphics Programming. Introduction OpenGL is a low-level graphics library specification. It makes available to the programmer a small set of geomteric.
The Graphics Rendering Pipeline 3D SCENE Collection of 3D primitives IMAGE Array of pixels Primitives: Basic geometric structures (points, lines, triangles,
2 COEN Computer Graphics I Introductions n Brad Grantham lecturer lab dude n Dave Shreiner lecturer slave driver.
Programming with OpenGL Part 1: Background
CSC 461: Lecture 3 1 CSC461 Lecture 3: Models and Architectures  Objectives –Learn the basic design of a graphics system –Introduce pipeline architecture.
Ch 2 Graphics Programming page 1 CSC 367 Coordinate Systems (2.1.2) Device coordinates, or screen coordinates (pixels) put limitations on programmers and.
1. OpenGL/GLU/GLUT  OpenGL v4.0 (latest) is the “core” library that is platform independent  GLUT v3.7 is an auxiliary library that handles window creation,
1 Figures are extracted from Angel's book (ISBN x) The Human Visual System vs The Pinhole camera Human Visual System Visible Spectrum Pinhole.
Introduction to OpenGL Programming Jian-Liang Lin 2002.
Computer Graphics Chapter 6 Andreas Savva. 2 Interactive Graphics Graphics provides one of the most natural means of communicating with a computer. Interactive.
Introduction to OpenGL  OpenGL is a graphics API  Software library  Layer between programmer and graphics hardware (and software)  OpenGL can fit in.
Computer Graphics Bing-Yu Chen National Taiwan University.
Introduction to OpenGL. OpenGL is a low-level graphics library specification. It makes available to the programmer  a small set of geometric primitives.
Chun-Yuan Lin Introduction to OpenGL 2015/12/19 1 CG.
NoufNaief.net TA: Nouf Al-harbi.
Graphics: Conceptual Model
CSCE 441: Computer Graphics
Introduction to OpenGL Programming
OpenGL Basic Drawing 2003 Spring Keng Shih-Ling
OpenGL API 2D Graphic Primitives Angel Angel: Interactive Computer Graphics5E © Addison-Wesley
OpenGL Basic Drawing Jian-Liang Lin A Smidgen of OpenGL Code #include main() { InitializeAWindowPlease(); glClearColor (0.0, 0.0, 0.0, 0.0); glClear.
Graphics OpenGL OpenGL Introduction 컴퓨터 그래픽스 김 창 헌.
Introduction to Graphics Programming. Graphics API.
Graphics Graphics Korea University kucg.korea.ac.kr Graphics Programming 고려대학교 컴퓨터 그래픽스 연구실.
Introduction to OpenGL (INF 250) Veronika Solteszova et al., UiB Dept. of Informatics,
Computer Graphics I, Fall Programming with OpenGL Part 2: Complete Programs.
OpenGL CS418 Computer Graphics John C. Hart. OpenGL Based on GL (graphics library) by Silicon Graphics Inc. (SGI) Advantages: Runs on everything, including.
OpenGL CS418 Computer Graphics John C. Hart. OpenGL: Event-driven How in OpenGL? Programmer registers callback functions Callback function called when.
INTRODUCTION TO OPENGL
Computer Graphics (Fall 2003) COMS 4160, Lecture 5: OpenGL 1 Ravi Ramamoorthi Many slides courtesy Greg Humphreys.
Administrivia Back on track: canceling OpenGL lecture 2 Assignment 1
The Human Visual System vs The Pinhole camera
Computer Graphics Lecture 32
“Computer Science is no more about computers than astronomy is about telescopes.” Professor Edsger Dijkstra.
Models and Architectures
Introduction to OpenGL
Models and Architectures
CIS 441/541: Introduction to Computer Graphics Lecture 15: shaders
OpenGL Background CS 4722.
Presentation transcript:

Programming With OpenGL A Technical Overview of The OpenGL Graphics API Programming With OpenGL Computer Graphics

Graphics API OpenGL(All Platform) DirectX(Windows) -DirectDraw -DirectSound -DirectPlay -DirectInput -DirectSetup OpenGL(All Platform) DirectX(Windows)

Programming With OpenGL An Introduction OpenGL, the standard software interface for graphics hardware, allows programmers to create interactive 2D and 3D graphics applications on a variety of systems. With OpenGL you can create high-quality color images. OpenGL makes it easy to build geometric models, change the viewing position, control the color and lighting of geometric primitives, and manipulate pixel and texture map images. This course will cover an immediately applicable subset of OpenGL, so that you can write a simple graphics program. Computer Graphics

OpenGL Advantages OpenGL is the most logical extension of Programming With OpenGL OpenGL Advantages Standard & Portability - Open OpenGL is the most logical extension of brilliant API called GL Supported through a larger number of vendors 1992, SGI SGI, IBM, DEC, Intel, Microsoft, Vendor and hardware independent Better integration into the windowing system Win95, Win98, WinNT, Win2000,WinXP Computer Graphics

Objectives Understand the order of operations, and the major libraries Programming With OpenGL Objectives Become familiar with the capabilities of OpenGL Understand the order of operations, and the major libraries Know how to use viewing, lighting, shading, and hidden surface removal functionality Know how to draw images with OpenGL and process event-driven input See how code is written and compiled Computer Graphics

Programming With OpenGL What is OpenGL? A low-level graphics modeling and rendering library (includes more than 100 functions) State machine A layer of abstraction between graphics hardware and an application program Hardware, Window System and Operating System independent Computer Graphics

Where is in the Graphics System Programming With OpenGL Where is in the Graphics System Developing & Application OpenInventor, SoftImage 3D OpenGL Window System X-Windows, MS Windows … Operating System UNIX, MS Windows, OS/2... Graphics Hardware SGI-XZ, SGI-Extreme, AGC-3D.. Computer Graphics

What OpenGL Can Do For You Programming With OpenGL What OpenGL Can Do For You Wireframe Models, Viewing, Transformation Antialiasing Flat And Smooth Shading Shadows Texture Mapping Motion Blur Haze and Fog, Depth -Of -Field Effect Evaluator Function: 1D & 2D Bezier Curves, NURBS ... Computer Graphics

Graphics Functions Primitive functions Attribute functions Programming With OpenGL Graphics Functions Primitive functions Attribute functions Viewing functions Transformation functions Input functions / control functions Computer Graphics

Overview of OpenGL Components Programming With OpenGL Overview of OpenGL Components OpenGL Library - gl OpenGL Utilities - glu OpenGL Extension to X Windows - glx OpenGL Programming Guide Auxiliary Library - aux Windows Graphics Library - wgl Computer Graphics

OpenGL Library GL Powerful But Primitive Set Of Rendering Commands Programming With OpenGL OpenGL Library GL Powerful But Primitive Set Of Rendering Commands All high level drawing is done in terms of these commands You can write your own toolkit based on these functions The GL Library Includes Functions supporting drawing primitives Lines, Points, Circles, Polygons, Characters, ... Clipping, Viewing, Projections, Transformation Shading, Lighting Direct colors 3D rendering functions such as Antialiasing, Multi buffering, Texture, ... Pixels manipulation (read, write, copy) Computer Graphics

OpenGL Utility Library GLU Programming With OpenGL OpenGL Utility Library GLU Utility library is a set of commonly used graphics routines built on top of OpenGL Uses lower level OpenGL commands for Setting up matrixes for viewing and projection Performing polygon tessellation - concave polygons, polygons with holes, self- intersecting polygons, .. Rendering surfaces (spheres, cylinders, disks, ..) Mipmapping NURBS (Non-Uniform Rational B-Spline) curves Error handling This library is part of the OpenGL implementation Computer Graphics

OpenGL Auxiliary Library Programming With OpenGL OpenGL Auxiliary Library This is a simple, platform-dependent library Makes programming examples simpler & more complete Managing windows Handling input events Drawing classic 3-D objects Managing a background process Running a program Do not use them in a production application Computer Graphics

OpenGL Command Syntax OpenGL commands use : OpenGL define constants Programming With OpenGL OpenGL Command Syntax OpenGL commands use : the prefix gl initial capital letters for each word making up the command name OpenGL define constants begin with GL use all capital letters use underscore to separate words OpenGL uses command extensions for clarification whenever the same command exists to use different arguments Examples : glClearColor() GL_COLOR_BUFFER_BIT glColor3fv() Computer Graphics

OpenGL Command Syntax  glVertex3fv Programming With OpenGL OpenGL Command Syntax  glVertex3fv v indicates vector format, if present data type: f float d double float s signed short integer i signed integer number of components (2, 3, or 4) Other data types in OpenGL commands - b character - ub unsigned character - us unsigned short integer - ui unsinged integer Computer Graphics

Programming With OpenGL Drawing Geometry Vertices can define a variety of geometric objects, and different numbers of vertices are required depending on the object. We can group as many vertices as desired, using the functions glBegin() and glEnd() Types of primitives glBegin (GLenum primitiveType) Example: glBegin (GL_POLYGON); glVertex3f(-. 5f, -. 5f, -. 5f); glVertex3f(. 5f, -. 5f, -. 5f); glVertex3f(-. 5f, .5f, -. 5f); glVertex3f(. 5f, .5f, -. 5f); glEnd(); Computer Graphics

Programming With OpenGL Primitive Types Computer Graphics

Attributes primitive is to be rendered graphics system Programming With OpenGL Attributes An attribute is any property that determines how a geometric primitive is to be rendered The present values of attribute are part of the state of the graphics system Each geometric type has a set of attributes Computer Graphics

Attributes Vertex attributes: glPointSize() point size Programming With OpenGL Attributes Vertex attributes: glPointSize() point size glColor*()/ glIndex*() current vertex color glNormal*() current vertex normal (lighting) glMaterial*() current material property (lighting) glTexCoord*() current texture coordinate glEdgeFlag*() edge status (surface primitives) RGB colors: glColor3f(1.0,0.0,0.0) glClearColor(1.0,1.0,1.0,1.0) Indexed color: glIndexi(element) Alpha channel - opacity or transparency Computer Graphics

Drawing Geometry Example: Drawing a green, flat triangle strip: Programming With OpenGL Drawing Geometry Example: Drawing a green, flat triangle strip: glBegin (GL_ TRIANGLE_ STRIP); glColor3f( 0. f, 1. f, 0. f); glNormal3f( 0. f, 0. f, 1. f); glVertex3f(-. 5f, -. 5f, -. 5f); glVertex3f(. 5f, -. 5f, -. 5f); glVertex3f(-. 5f, .5f, -. 5f); glVertex3f(. 5f, .5f, -. 5f); glEnd(); glBegin - glEnd paradigm allows great flexibility in describing primitives. Any combination of color, normal, texture, material etc. information can be bound with any given vertex. Computer Graphics

OpenGL The Statemachine Programming With OpenGL OpenGL The Statemachine OpenGL knows about various different states or modes These states remain in effect until you change them Examples of states variables are: the current color current viewing and transformation matrix line and polygon stippling patterns polygon drawing modes shading modes pixel packing conventions position and characteristics of light sources material properties Each state variable has a default value You can query the current variable value Computer Graphics

States glEnable (GLenum capability) glDisable (GLenum capability) Programming With OpenGL States glEnable (GLenum capability) glDisable (GLenum capability) GLboolean glIsEnabled (GLenum cap) - turn on and off OpenGL states - capability can be one of (partial list): GL_ BLEND (alpha blending) GL_ DEPTH_ TEST (depth buffer) GL_ FOG GL_ LIGHTING GL_ LINE_ SMOOTH (line antialiasing) Computer Graphics

Structure of a Typical Program Programming With OpenGL Structure of a Typical Program main: create window initialize GL states (e. g., viewing, color, lighting) initialize display lists check for events (and process them) if window event (window moved, exposed, etc.) - modify viewport, if needed - redraw else if mouse or keyboard - do something, e. g., change states & redraw Computer Graphics

Initialization void auxInitWindow(Glbyte *titleString) Programming With OpenGL Initialization void auxInitWindow(Glbyte *titleString) - Win32 API: CreateWindow(…) void auxInitDisplayMode(Glbitfield mask) Mask: AUX_RGBA or AUX_INDEX AUX_SINGLE or AUX_DOUBLE AUX_DEPTH AUX_STENCIL AUX_ACCUM void auxInitPosition(Glint x,Glint y, Glsizei width,Glsizei height) - Win32 API: MoveWindow(…) Computer Graphics

Control Functions (GLsizei,Glsizei)) void(*function)(AUX_EVENTREC*)) Programming With OpenGL Control Functions void auxMainLoop(void(*displayFunc)void)) -Windows message: WM_PAINT void auxReshapeFunc(void(*function) (GLsizei,Glsizei)) -Windows message: WM_SIZE void auxMouseFunc(Glint button,Glint mode, void(*function)(AUX_EVENTREC*)) - Windows Message: WM_MOUSEDOWN Computer Graphics

Redraw redraw: clear screen (to background color) Programming With OpenGL Redraw redraw: clear screen (to background color) change state( s), if needed render some graphics change more states render some more graphics .... Computer Graphics

Homework: The Sierpinski Gasket Programming With OpenGL Homework: The Sierpinski Gasket 1. Pick an initial point at random inside the triangle. 2. Select one of the three vertices at random. 3. Find the point halfway between the initial point and the randomly selected vertex. 4. Display this new point by putting some sort of marker, such as a small circle, at its location. 5. Replace the initial point with this new point. 6. Return to step 2. V2 P0 P1 P2 V1 V3 Computer Graphics