Introduction to OpenGL Programming

Slides:



Advertisements
Similar presentations
Introduction to OpenGL
Advertisements

OpenGL Basics.
OpenGL (Graphics Library) Software Interface to graphics software Allows to create interactive programs that produce color images of moving 3D objects.
Drawing Geometric Objects
1 Angel: Interactive Computer Graphics 4E © Addison-Wesley 2005 Programming with OpenGL Part 2: Complete Programs Ed Angel Professor of Computer Science,
1 Lecture 4 Graphical primitives Rasterization: algorithmic approach Rasterization: geometric approach 2D discrete lines, triangles Discrete planes 3D.
Programming with OpenGL Part 0: 3D API March 1, 2007.
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.
Development of Interactive 3D Virtual World Applications
Write a Simple Program with OpenGL & GLUT. Books and Web Books OpenGL Programming Guide (Red-book) OpenGL Reference Manual (Blue-book) OpenGL Super Bible.
Reference1. [OpenGL course slides by Rasmus Stenholt]
CS380 LAB I OpenGL Donghyuk Kim Reference1. [OpenGL course slides by Rasmus Stenholt] Reference2. [
Geometric Objects and Transformations Chapter 4. Points, Scalars and Vectors  Points - position in space  Scalars - real numbers, complex numbers obey.
COS 397 Computer Graphics Assoc. Prof. Svetla Boytcheva AUBG 2013 COS 397 Computer Graphics Practical Session №1 Introduction to OpenGL, GLFW and CG.
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.
Drawing Basic Graphics Primitives Lecture 4 Wed, Sep 3, 2003.
Chapter 4 10 February Agenda Program 2 – Due 2/17 Chapter 4 – transformations GLUT solids.
Using OpenGL in Visual C++ Opengl32.dll and glu32.dll should be in the system folder Opengl32.dll and glu32.dll should be in the system folder Opengl32.lib.
OpenGL A Brief Overview. What is OpenGL? It is NOT a programming language. It is a Graphics Rendering API consisting of a set of functions with a well.
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.
OpenGl Graphics Programming. Introduction OpenGL is a low-level graphics library specification. It makes available to the programmer a small set of geomteric.
1 Angel: Interactive Computer Graphics 4E © Addison-Wesley 2005 Programming with OpenGL Part 1: Background Ed Angel Professor of Computer Science, Electrical.
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,
P RACTICING O PEN GL- P RIMITIVES. O PEN GL O UTPUT P RIMITIVES  Each geometric object is described by a set of vertices and the type of primitive to.
Computer Graphics Bing-Yu Chen National Taiwan University.
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.
1 Chapter 2 Graphics Programming. 2 Using OpenGL in Visual C++ – 1/3 Opengl32.dll and glu32.dll should be in the system folder Opengl32.lib and glu32.lib.
NoufNaief.net TA: Nouf Al-harbi.
Computer Graphics Lab 1 OpenGL.
1 How to Install OpenGL u Software running under Microsoft Windows makes extensive use of "dynamic link libraries." A dynamic link library (DLL) is a set.
Lecture 2: Introduction to OpenGL
What are Computer Graphics Basically anything that is on you Monitor – This includes the text that you will see Text isn’t Advanced Graphics But…. Understanding.
Chap 2 Write a Simple OpenGL Program. Preparing 1/2 environment : Microsoft Visual C 、 Microsoft Visual C++.Net Also need : GLUT
1 Programming with OpenGL Part 2: Complete Programs.
OpenGL API 2D Graphic Primitives Angel Angel: Interactive Computer Graphics5E © Addison-Wesley
1 Perception, Illusion and VR HNRS 299, Spring 2008 Lecture 15 Creating 3D Models.
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,
2002 by Jim X. Chen: Drawing Geometric Models.1. Objectives –OpenGL drawing primitives and attributes –OpenGL polygon face.
Graphics Graphics Korea University kucg.korea.ac.kr Graphics Programming 고려대학교 컴퓨터 그래픽스 연구실.
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.
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.
OpenGL Programming Guide Chapter 2 Korea Univ. Graphics Labs. Ji Jun Yong Korea Univ. Graphics Labs. Ji Jun Yong.
Program Studi S-1 Teknik Informatika FMIPA Universitas Padjadjaran
Basic Program with OpenGL and GLUT
CSC Graphics Programming
Introduction to OpenGL (IDE: Eclipse)
CS380 Lab Spring Myungbae Son.
Programming with OpenGL Part 1: Background
LAB 5 Drawing Objects Lab 5 Drawing Objects.
Introduction to OpenGL
“Computer Science is no more about computers than astronomy is about telescopes.” Professor Edsger Dijkstra.
Programming with OpenGL Part 2: Complete Programs
OpenGL API 2D Graphic Primitives
Programming with OpenGL Part 2: Complete Programs
OpenGL (Open Graphics Library) Mr. B.A.Swamy Assistant Professor Dept of CSE.
OpenGL A Brief Overview.
Lab 3 Geometric Drawing Lab 3 Geometric Drawing.
CSE 411 Computer Graphics Lecture #3 Graphics Output Primitives
Drawing in the plane 455.
Introduction to OpenGL
LAB 5 Drawing Objects Lab 5 Drawing Objects.
Computer Graphics, Lee Byung-Gook, Dongseo Univ.
LAB 5 Drawing Objects Lab 5 Drawing Objects.
Programming with OpenGL Part 2: Complete Programs
Programming with OpenGL Part 2: Complete Programs
Programming with OpenGL Part 2: Complete Programs
Chapter 4 15 March 2006 EventPro Strategies is looking for a part-time programmer (any language) who knows SQL. For more info, contact Ryan Taylor,
OpenGL A Brief Overview.
Presentation transcript:

Introduction to OpenGL Programming Jung Lee

OpenGL Reference Sites OpenGL Official Site http://www.opengl.org/ Khronos Group http://www.khronos.org/ Nehe Productions http://nehe.gamedev.net/

OpenGL-Related Files Header File Static Library Dynamic Library gl.h, glaux.h, glu.h, glut.h To the ‘include’ directory Static Library opengl32.lib, glaux.lib, glu32.lib, glut32.lib To the ‘lib’ directory Dynamic Library opengl32.dll, glu32.dll, glut.dll, glut32.dll C:\WINDOWS\system32

Project Creation [Visual Studio 6.0] (1/3) [File]  [New] (Ctrl+N) [Win32 Console Application] Enter the project name  [OK] [An empty project]  [Finish]

Project Creation [Visual Studio 6.0] (2/3) [Project]  [Settings] (Alt+F7) [Link]  Object/library modules Type ‘opengl32.lib glu32.lib glut32.lib glaux.lib’

Project Creation [Visual Studio 6.0] (3/3) [File]  [New] (Ctrl+N) [C++ Source File] Enter the main file name

Project Creation [Visual Studio 8.0] (1/3) [File]  [New]  [Project] (Ctrl+Shift+N) [Visual C++]  [Win32]  [Win32 Console App] Enter the project name [빈 프로젝트]

Project Creation [Visual Studio 8.0] (2/3) [Project]  [속성] (Alt+F7) [구성 속성]  [링커]  [입력] [추가 종속성] Type ‘opengl32.lib glu32.lib glut32.lib glaux.lib’

Project Creation [Visual Studio 8.0] (3/3) [소스 파일] 우클릭  [새 항목 추가] [코드]  [C++파일(.cpp)] Enter the main file name  [추가(A)]

Project Creation [Visual Studio 2008] (1/2) [File]  [New] (Ctrl+Shift+N) [Project types]  [General] [Templates]  [Empty Project] Enter the project file name

Project Creation [Visual Studio 2008] (2/2) [Project]  [Settings…] (Alt+F7) [Link]  [Input]  [Additional Dependencies] Type ‘opengl32.lib glu32.lib glut32.lib glaux.lib’

Project Creation [Visual Studio 2010] (1/2) [File]  [New]  [Project] (Ctrl+Shift+N) [Visual C++]  [Win32]  [Win32 Console App] Enter the project name [Empty project]

Project Creation [Visual Studio 2010] (2/2) [Project]  [Properties] (Alt+F7) [Configuration Properties]  [Linker]  [Input] [Additional Dependencies] Type ‘opengl32.lib glu32.lib glut32.lib glaux.lib’

Example

OpenGL Primitives Miscellaneous Point Line Polygon Cube Tetrahedron GL_POINTS Line GL_LINES GL_LINE_STRIP GL_LINE_LOOP Polygon GL_POLYGON GL_TRIANGLES GL_TRIANGLE_STRIP GL_TRIANGLE_FAN GL_QUAD_STRIP Miscellaneous Cube Tetrahedron Icosahedron Sphere Torus Cone

Point GL_POINTS glBegin(GL_POINTS); glVertex3f(v1x, v1y, v1z); glEnd(); v1 v2 v4 v3

Line (1/3) GL_LINES glBegin(GL_LINES); glVertex3f(v1x, v1y, v1z); glEnd(); v1 v2 v4 v3

Line (2/3) GL_LINE_STRIP glBegin(GL_LINE_STRIP); glVertex3f(v1x, v1y, v1z); glVertex3f(v2x, v2y, v2z); glVertex3f(v3x, v3y, v3z); glVertex3f(v4x, v4y, v4z); glEnd(); v1 v2 v4 v3

Line (3/3) GL_LINE_LOOP glBegin(GL_LINE_LOOP); glVertex3f(v1x, v1y, v1z); glVertex3f(v2x, v2y, v2z); glVertex3f(v3x, v3y, v3z); glVertex3f(v4x, v4y, v4z); glEnd(); v1 v2 v4 v3

Triangle (1/3) GL_TRIANGLES glBegin(GL_TRIANGLES); glVertex3f(v1x, v1y, v1z); glVertex3f(v2x, v2y, v2z); glVertex3f(v3x, v3y, v3z); glEnd(); v1 v3 v2

Triangle (2/3) GL_TRIANGLE_STRIP glBegin(GL_TRIANGLE_STRIP); glVertex3f(v1x, v1y, v1z); glVertex3f(v2x, v2y, v2z); glVertex3f(v3x, v3y, v3z); glVertex3f(v4x, v4y, v4z); glVertex3f(v5x, v5y, v5z); glEnd(); v1 v3 v5 v2 v4

Triangle (3/3) GL_TRIANGLE_FAN glBegin(GL_TRIANGLE_FAN); glVertex3f(v1x, v1y, v1z); glVertex3f(v2x, v2y, v2z); glVertex3f(v3x, v3y, v3z); glVertex3f(v4x, v4y, v4z); glVertex3f(v5x, v5y, v5z); glEnd(); v5 v4 v3 v2 v1

Quadrilateral (1/2) GL_QUADS glBegin(GL_QUADS); glVertex3f(v1x, v1y, v1z); glVertex3f(v2x, v2y, v2z); glVertex3f(v3x, v3y, v3z); glVertex3f(v4x, v4y, v4z); glEnd(); v1 v4 v2 v3

Quadrilateral (2/2) GL_QUAD_STRIP glBegin(GL_QUAD_STRIP); glVertex3f(v1x, v1y, v1z); glVertex3f(v2x, v2y, v2z); glVertex3f(v3x, v3y, v3z); glVertex3f(v4x, v4y, v4z); glVertex3f(v5x, v5y, v5z); glVertex3f(v6x, v6y, v6z); glEnd(); v1 v3 v5 v2 v4 v6

Polygon GL_POLYGON glBegin(GL_POLYGON); glVertex3f(v1x, v1y, v1z); glEnd(); v1 v6 v2 v5 v3 v4

Miscellaneous (1/3) Cube Tetrahedron Icosahedron void glutSolidCube(GLdouble size) void glutWireCube(GLdouble size) Tetrahedron void glutSolidTetrahedron(void) void glutWireTetrahedron(void) Icosahedron void glutSolidIcosahedron(void) void glutWireIcosahedron(void)

Miscellaneous (2/3) Sphere Torus void glutSolidSphere(GLdouble radius, GLint slices, GLint stacks) void glutWireSphere(GLdouble radius, GLint slices, GLint stacks) Torus void glutSolidTorus(GLdouble innerRadius, GLdouble outerRadius, GLint nsides, GLint rings) void glutWireTorus(GLdouble innerRadius, GLdouble outerRadius, GLint nsides, GLint rings)

Miscellaneous (3/3) Cone Teapot void glutSolidCone(GLdouble base_radius, GLdouble height, GLint slices, GLint stacks) void glutWireCone(GLdouble base_radius, GLdouble height, GLint slices, GLint stacks) Teapot void glutSolidTeapot(GLdouble size) void glutWireTeapot(GLdouble size)

Teapot Example

Basic Functions (1/2) glPointSize(GLfloat size) glGetFloatv(GL_POINT_SIZE_RANGE) Returns the range of the point size that the hardware supports glLineWidth(GLfloat width) glGetFloatv(GL_LINE_WIDTH_RANGE) Returns the range of the line width that the hardware supports

Point Example

Basic Functions (2/2) glShadeModel(mode) Sets the polygon filling method mode GL_FLAT By only one color GL_SMOOTH By the weighted averaging the colors of member vertices (gradation) Default value

Line Example

Triangle Example

Rectangle Example : Revisited

‘Single vs. Double Buffering’ glFlush() vs. glutSwapBuffers() Single Buffering (GLUT_SINGLE, Default) Double Buffering (GLUT_DOUBLE) cf.) triple buffering Graphic Processor Frame Buffer Video Controller Display Device Slow Very Fast Front Buffer Graphic Processor Video Controller Display Device Back Buffer