OpenGL (Graphics Library) Software Interface to graphics software Allows to create interactive programs that produce color images of moving 3D objects.

Slides:



Advertisements
Similar presentations
OpenGL CMSC340 3D Character Design & Animation. What is OpenGL? A low-level graphics library specification designed for use with the C and C++ provides…
Advertisements

OPEN GL. Install GLUT Download package di sini Dari devcpp, buka Tools->PackageManager-
Line and Curve Drawing Algorithms. Line Drawing x0x0 y0y0 x end y end.
Chapter 2: Graphics Programming
Computer Graphics CSCE 441
Pemrograman OpenGL Dasar
#include int line_width = 1; void Display( void ) { glEnable( GL_LINE_STIPPLE ); glClearColor (0.0, 0.0, 0.0, 0.0); glClear(GL_COLOR_BUFFER_BIT);
OpenGL (I). What is OpenGL (OGL)? OGL is a 3D graphics & modeling library Can also use it to draw 2D objects.
1 Angel: Interactive Computer Graphics 4E © Addison-Wesley 2005 Programming with OpenGL Part 2: Complete Programs Ed Angel Professor of Computer Science,
CENG477 Introduction to Computer Graphics Introduction to OpenGL, GLUT and GLUI.
CSE 494/598 Intro to Applied Computer Graphics Anshuman Razdan DCST AR's Web Page AR's Web Page
ITEPC 06 - Workshop on Fractal Creation Chiew-Lan Tai and Oscar Au.
Computer Graphics CS 385 February 7, Fundamentals of OpenGl and Glut Today we will go through the basics of a minimal OpenGl Glut project, explaining.
Introduction to OpenGL M. Ramanathan STTP CAD 2011Introduction to OpenGL.
Reference1. [OpenGL course slides by Rasmus Stenholt]
CS380 LAB I OpenGL Donghyuk Kim Reference1. [OpenGL course slides by Rasmus Stenholt] Reference2. [
CAP 4703 Computer Graphic Methods Prof. Roy Levow Lecture 2.
Basic OpenGL Glenn G. Chappell U. of Alaska Fairbanks CS 381 Lecture Notes Wednesday, September 10, 2003.
Introduction to OpenGL and GLUT GLUT. What is OpenGL? An application programming interface (API) A (low-level) Graphics rendering API Generate high-quality.
Computer Graphics using OpenGL, 3 rd Edition F. S. Hill, Jr. and S. Kelley Chapter 2 Initial Steps in Drawing Figures Ureerat Suksawatchon Faculty of Informatics.
2 COEN Computer Graphics I Introductions n Brad Grantham lecturer lab dude n Dave Shreiner lecturer slave driver.
1 Angel: Interactive Computer Graphics 4E © Addison-Wesley 2005 Programming with OpenGL Part 1: Background Ed Angel Professor of Computer Science, Electrical.
Computer Graphics CS 385 January 31, Fractals Some definitions Object which is self-similar at all scales. Regardless of scale the same level of.
1 Figures are extracted from Angel's book (ISBN x) The Human Visual System vs The Pinhole camera Human Visual System Visible Spectrum Pinhole.
CD2012 Principles of Interactive Graphics Lecture 01 Introduction Abir Hussain (Rome: 6.33,Tel , Web:
Introduction to GL Geb Thomas. Example Code int main(int argc, char **argv) { glutInit(&argc, argv); glutInitDisplayMode ( GLUT_SINGLE | GLUT_RGB | GLUT_DEPTH);
Computing & Information Sciences Kansas State University CIS 536/636 Introduction to Computer Graphics Lecture 4 of 41 William H. Hsu Department of Computing.
Computer Graphics Bing-Yu Chen National Taiwan University.
1 Angel: Interactive Computer Graphics 5E © Addison-Wesley 2009 Programming with OpenGL Review.
Introduction to OpenGL and GLUT. What’s OpenGL? An Application Programming Interface (API) A low-level graphics programming API – Contains over 250 functions.
C O M P U T E R G R A P H I C S Guoying Zhao 1 / 43 C O M P U T E R G R A P H I C S Guoying Zhao 1 / 43 Computer Graphics Programming with OpenGL I.
CA 302 Computer Graphics and Visual Programming Lecture 2: Introduction to OpenGL Aydın Öztürk
Chun-Yuan Lin Introduction to OpenGL 2015/12/19 1 CG.
NoufNaief.net TA: Nouf Al-harbi.
NoufNaief.net 1 TA: Nouf Al-Harbi.
CSCE 441: Computer Graphics
Introduction to OpenGL Programming
OpenGL Basic Drawing 2003 Spring Keng Shih-Ling
CS552: Computer Graphics Lecture 6: Viewing in 2D.
1 Programming with OpenGL Part 2: Complete Programs.
OpenGL API 2D Graphic Primitives Angel Angel: Interactive Computer Graphics5E © Addison-Wesley
31/1/2006Based on: Angel (4th Edition) & Akeine-Möller & Haines (2nd Edition)1 CSC345: Advanced Graphics & Virtual Environments Lecture 2: Introduction.
OpenGL: Introduction #include main() { OpenWindow() ; glClearColor(0.0, 0.0, 0.0, 0.0); glClear(GL_COLOR_BUFFER_BIT); glOrtho(-1.0, 1.0, -1.0, 1.0, -1.0,
OpenGL Basic Drawing Jian-Liang Lin A Smidgen of OpenGL Code #include main() { InitializeAWindowPlease(); glClearColor (0.0, 0.0, 0.0, 0.0); glClear.
CIS 681 Review: OpenGL. CIS 681 Command Syntax OpenGL commands start with a gl. This is followed by the base command such as Color. Followed by the number.
Introduction to Graphics Programming. Graphics API.
Introduction to Graphics Programming. Graphics: Conceptual Model Real Object Human Eye Display Device Graphics System Synthetic Model Synthetic Camera.
Computer Graphics I, Fall Programming with OpenGL Part 2: Complete Programs.
INTRODUCTION TO OPENGL
Computer Graphics (Fall 2003) COMS 4160, Lecture 5: OpenGL 1 Ravi Ramamoorthi Many slides courtesy Greg Humphreys.
Computer Graphics -practical- Lecture 6. (visual c++) open gl library To use open GL with VC++ we add these files:- 1)Glut.h C:\program files\ Microsoft.
Program Studi S-1 Teknik Informatika FMIPA Universitas Padjadjaran
Introduction to OpenGL (IDE: Eclipse)
The Human Visual System vs The Pinhole camera
Introduction to OpenGL
Programming with OpenGL Part 2: Complete Programs
Materi Anatomi OpenGL Fungsi GLUT Posisi Kamera Proyeksi
OpenGL API 2D Graphic Primitives
Programming with OpenGL Part 2: Complete Programs
Graphics Programming (I)
OpenGL (Open Graphics Library) Mr. B.A.Swamy Assistant Professor Dept of CSE.
Lab 3 Geometric Drawing Lab 3 Geometric Drawing.
גרפיקה ממוחשבת: מבוא ל-OpenGL
Drawing in the plane 455.
Introduction to OpenGL
Line and Curve Drawing Algorithms
Computer Graphics, Lee Byung-Gook, Dongseo Univ.
Programming with OpenGL Part 2: Complete Programs
Programming with OpenGL Part 2: Complete Programs
Programming with OpenGL Part 2: Complete Programs
Presentation transcript:

OpenGL (Graphics Library) Software Interface to graphics software Allows to create interactive programs that produce color images of moving 3D objects.

OpenGL ● OpenGL – Hardware independent, only specifies graphics output low level, no GUI operations (events, windows, menu’s) ●OpenGL Utility (GLU) – Higher level graphics primitives (spheres, curves, curved surfaces) ●OpenGL Utility Toolkit (GLUT) – Primitive window setup & event handling. enables truly window system independent applications

OpenGL Basic Syntax (C Language Binding) ●Functions: glXXXX – glBegin, glEnd, glPolygonMode ●Constants: GL_XXXX – GL_2D, GL_RGB, GL_CCW ●Types: GLxxx – GLbyte, GLshort, GLint, GLfloat, GLdouble, GLboolean

OpenGL Header Files #include However, If using GLUT to handle window- managing operations #include

Display-Window Management Using GLUT Step1 : GLUT Initialization glut Init (&argc, argv); Step2 : Display window is created on the screen with the function glutCreateWindow ( “ An Example OpenGL Program”); Other functions such as : glutDisplayFunc ( lineSegment); //displaying any object glutInitWindowPosition (50, 100); // set the position of window

Display-Window Management Using GLUT.. glutInitWindowSize (400, 300); //set the size of the window glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB); //options for buffering and color modes Final Step : All display windows are activated and displayed glutMainLoop ( ); This function completes the window- processing operations.

OpenGL Program Example #include void init (void) { glClearColor (1.0, 1.0, 1.0, 0.0); //Set Display-window color to white glMatrixMode (GL_PROJECTION); // Set projection parameters gluOrtho2D (0.0, 200.0, 0.0, 150.0); }

Continued.. void lineSegment (void) { glClear (GL_COLOR_BUFFER_BIT); // Clear display window glColor3f (1.0, 0.0, 0.0); //Set line segment color to red glBegin (GL_LINES); glVertex2i (180, 15); //Specify line- segment geometry glVertex2i (10, 145); glEnd (); glFlush (); // Process all OpenGL routines as quickly as possible }

Continued.. void main (int argc, char** argv) { glutInit (&argc, argv);// Initialize GLUT glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB); // Set display mode glutInitWindowPosition (50, 100); //Set top-left display-window position glutInitWindowSize (400,300); //Set display-window width and height

Continued.. glutCreateWindow ("An Example OpenGL Program");// Create display window init (); // Execute initialization procedure glutDisplayFunc (lineSegment); // Send graphics to display window glutMainLoop (); }

OpenGL Geometric Output Primitives ●Types: GL_POINTS, GL_LINES, GL_LINE_LOOP, GL_LINE_STRIP, GL_POLYGON, GL_QUADS, GL_QUAD_STRIP, GL_TRIANGLE, GL_TRIANGLE_STRIP, GL_TRIANGLE_FAN ●Basic Syntax: glBegin (PrimitiveConstant); glVertex3f (x1,y1,z1) glVertex3f (x2,y2,z2) …. glEnd(); glVertex(2|3|4)(s|i|d|f)[v]

Points & Lines v0 v1 v2 v3 glBegin (PrimitiveConstant); glVertex3f (x1,y1,z1) glVertex3f (x2,y2,z2) …. glEnd(); v0 v1 v2 v3 v4 v5 GL_POINTS GL_LINES GL_LINE_STRIP v0 v1 v2 v3 v4 GL_LINE_LOOP

Polygons glBegin (PrimitiveConstant); glVertex3f (x1,y1,z1) glVertex3f (x2,y2,z2) …. glEnd(); GL_POLYGON v0 v1 v2 v3 v4 v0 v1 v2 v3 v4 v5 v6 v7 GL_QUADS v0 v1 v2 v3 v4 v5 v6 v7 GL_QUAD_STRIP

Polygons (2) glBegin (PrimitiveConstant); glVertex3f (x1,y1,z1) glVertex3f (x2,y2,z2) …. glEnd(); v0 v1 v2 v3 v4 v5 GL_TRIANGLES GL_TRIANGLE_STRIP v0 v1 v2 v3 v4 v5 GL_TRIANGLE_FAN v0 v1 v2 v3 v4 v5 N vertices N/3 Triangles N+2 vertices N Triangles N+2 vertices N Triangles

References Computer Graphics with OpenGL :H & B RedBook : Tutorials : ITCS 4120 class notes