CAP4730: Computational Structures in Computer Graphics Introduction to OpenGL.

Slides:



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

Lecture 3 Graphics Pipeline and Graphics Software
Chapter 2: Graphics Programming
Computer Graphics CSCE 441
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:
Lab 1: OpenGL Tutorial CS 282. What’s the plan for today? Go over our framework code. Learn some basic OpenGL! Reveal Lab 1 Answer questions.
OpenGL (Graphics Library) Software Interface to graphics software Allows to create interactive programs that produce color images of moving 3D objects.
1 Angel: Interactive Computer Graphics 4E © Addison-Wesley 2005 Programming with OpenGL Part 1: Background Ed Angel Professor of Computer Science, Electrical.
OpenGL and Projections
Painterly Rendering CMPS Assignment 2. OpenGL OpenGL is a cross-language, cross- platform specification defining and API for 2D and 3D graphics.
Python and OpenGL Richard P. Muller Materials and Process Simulation Center California Institute of Technology June 29, 2000.
Programming with OpenGL Part 1: Background Mohan Sridharan Based on slides created by Edward Angel CS4395: Computer Graphics 1.
LAB #1: Computer Graphics Framework IGX is a set of programs which allow you to write graphics programs in C/C++ from plain text files. Benefits: 1. You.
OpenGL Tutorial Jason Lawrence COS426 Precept Notes 2/16/04.
3D Rendering with JOGL Introduction to Java OpenGL Graphic Library By Ricardo Veguilla
Introduction to OpenGL Keng Shih-Ling 2003 Spring.
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.
CSE328:Computer Graphics OpenGL Tutorial Dongli Zhang Department of Computer Science, SBU Department of Computer Science, Stony.
Computer Graphics Bing-Yu Chen National Taiwan University.
Programming in OpenGL Ryan Holmes CSE 570 February 12 th, 2003.
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.
INTRO TO COMPUTER GRAPHICS TEXT EDWARD ANGEL: EDITION 5 CS770/870
Introduction to OpenGL and GLUT GLUT. What is OpenGL? An application programming interface (API) A (low-level) Graphics rendering API Generate high-quality.
C O M P U T E R G R A P H I C S Jie chen Computer graphic -- OpenGL Howto.
CSC 461: Lecture 41 CSC461: Lecture 4 Introduction to OpenGL Objectives: Development of the OpenGL API OpenGL Architecture -- OpenGL as a state machine.
Computer Graphics Tz-Huan Huang National Taiwan University.
OpenGl Graphics Programming. Introduction OpenGL is a low-level graphics library specification. It makes available to the programmer a small set of geomteric.
Comp371 Computer Graphics Lecturer : Dr. Adam Krzyzak Mehdi Saeidian-manesh
2 COEN Computer Graphics I Introductions n Brad Grantham lecturer lab dude n Dave Shreiner lecturer slave driver.
Programming with OpenGL Part 1: Background
1 Angel: Interactive Computer Graphics 4E © Addison-Wesley 2005 Programming with OpenGL Part 1: Background Ed Angel Professor of Computer Science, Electrical.
Computer Graphics, KKU. Lecture 101 Introduction to OpenGL.
Introduction to OpenGL 1. 2 OpenGL A Graphics rendering API introduced in 1992 by Silicon Graphics Inc Provide the low-level functions to access graphics.
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,
CS 4363/6353 OPENGL BACKGROUND. WHY IS THIS CLASS SO HARD TO TEACH? (I’LL STOP WHINING SOON) Hardware (GPUs) double in processing power ever 6 months!
Introduction to OpenGL Programming Jian-Liang Lin 2002.
Modeling with OpenGL Practice with OpenGL transformations.
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 and GLUT. What’s OpenGL? An Application Programming Interface (API) A low-level graphics programming API – Contains over 250 functions.
Programming With OpenGL
Chun-Yuan Lin Introduction to OpenGL 2015/12/19 1 CG.
NoufNaief.net TA: Nouf Al-harbi.
CGGM Lab. Tan-Chi Ho Introduction to OpenGL.
OpenGL: The Open Graphics Language Introduction By Ricardo Veguilla.
Computer Graphics Lab 1 OpenGL.
Introduction to OpenGL & HW1 Announcement 劉軒銘, 網媒所 碩二 ICG 2012 Fall.
OpenGL Basic Drawing 2003 Spring Keng Shih-Ling
Lecture 2 Review OpenGL Libraries Graphics Overview Rendering Pipeline OpenGL command structure.
OpenGL Basic Drawing Jian-Liang Lin A Smidgen of OpenGL Code #include main() { InitializeAWindowPlease(); glClearColor (0.0, 0.0, 0.0, 0.0); glClear.
SPACE SHUTTLE LAUNCHING GUIDE Mis. V.R.PRATIMA Mr. ASWIN KUMAR PUNITH.K PAUL SUDEEP.G Submitted by.
Graphics OpenGL OpenGL Introduction 컴퓨터 그래픽스 김 창 헌.
1 Perception, Illusion and VR HNRS 299, Spring 2008 Lecture 17 Animations, Loops.
Introduction to Graphics Programming. Graphics API.
Introduction to OpenGL (INF 250) Veronika Solteszova et al., UiB Dept. of Informatics,
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.
OpenGL: The Open Graphics Language Technology and Historical Overview By Ricardo Veguilla.
Computer Graphics (Fall 2003) COMS 4160, Lecture 5: OpenGL 1 Ravi Ramamoorthi Many slides courtesy Greg Humphreys.
Dependency GRAPH ANALYZER
Administrivia Back on track: canceling OpenGL lecture 2 Assignment 1
Programming with OpenGL Part 1: Background
גרפיקה ממוחשבת: מבוא ל-OpenGL
Programming with OpenGL Part 1: Background
Introduction to OpenGL
Computer Graphics Practical Lesson 1-
Programming with OpenGL Part 1: Background
OpenGL Background CS 4722.
Presentation transcript:

CAP4730: Computational Structures in Computer Graphics Introduction to OpenGL

What is OpenGL? “A software interface to graphics hardware” Written in C (NOT C++) Very fast (a standard to be accelerated) Portable Open standard Was SGI’s IRIS GL What it isn’t –A modeling tool –A new ‘language’ Other options: –Direct3D –MesaGL –VirtualGL –(Older) Glide –Why would you use one over another? What are companies’ motivations?

OpenGL/GLU/GLUT/GLUI OpenGL v2.1 (latest) is the “core” library that is platform independent GLUT v3.7 is an auxiliary library that handles window creation, OS system calls (mouse buttons, movement, keyboard, etc), callbacks. GLU is an auxiliary library that handles a variety of graphics accessory functions

ZIP file Look at ZIP file

Headers and Linking OpenGL - main stuff (the only thing that is required) –#include –Link opengl32.lib (PC) opengl.lib is an SGI implementation opengl32.lib is a Microsoft implementation (what you want) GLU - auxillary functions –#include –Link glu32.lib (PC)

Headers and Libraries GLUT - Window management (requires download of library) –#include –Link glut32.lib (PC), or -lglut (UNIX) Instead of GLUT, you can use GLX or WGL

GLUT GLUT is a Window Manager –Makes it easy to create windows –Platform independent –Gets you up and running, though it isn’t extremely customizable –Not meant for “commercial” products –Let’s compare what you get and you don’t get from GLUT.

Approach to programming in GL Use old code again! If you have any questions, check the “Red Book” (explains OpenGL) or the “Blue Book” (reference for commands) Use the function glGetError() to check for errors Note about function names: –gl means OpenGL (glVertex) –glu means GLU (gluPerspective) –glut means GLUT (glutCreateWindow)

Different Parts of a GL Program In your main(), setup GL and GLUT stuff Callbacks –Function that gets called when certain events (like a keyboard or mouse event) occur Display –Function where you would put all your graphics routines Global variables and states State Machine –Things have a global ‘state’ till you change it. For example, if you enable depth buffering, it will be on till you disable it.

Double Buffer Graphics card scans out the image on the frame buffer. What rate is this done at? So what is the problem with this? You might be in the middle of drawing a frame when it decides to scan out the image What is a solution? Have two separate frame buffers, one that the card scans out of, and the other you draw into. When you are done drawing a frame, you switch their roles What are the memory requirements?

Double Buffering... glVertex3f(0.1,0.1,0.1) glutSwapBuffers();...

Double Buffering... glVertex3f(0.1,0.1,0.1) glutSwapBuffers();...

Basic GL Commands glEnable/glDisable GL has many states of operation, and the way you change them is through Enabling and Disabling them. Ex. –glEnable(GL_DEPTH_TEST); –glDisable(GL_DEPTH_TEST); –glDepthFunc(GL_LESS);

Geometry Commands glBegin glVertex glColor glNormal glTexCoord glEnd

Lighting glEnable(GL_LIGHTING); glEnable(GL_LIGHT0); Glfloat fLightPosition[3]; –fLightPosition[0]=1; –fLightPosition[1]=1; –fLightPosition[2]=1; glLightfv(GL_LIGHT0,GL_POSITION,fLightPosition);

Example glBegin(GL_TRIANGLES); glVertex3f(0,1,0); glVertex3f(0,0,1); glVertex3f(0,0,0); glEnd(); glEnable(GL_LIGHTING); glBegin(GL_TRIANGLES); glVertex3f(0,0,1); glVertex3f(1,0,0); glVertex3f(0,0,0); glEnd(); glDisable(GL_LIGHTING);

State Machine OpenGL has several global variables: –GL_DEPTH_TEST –GL_LIGHTING –GL_SHADE_MODEL –GL_CULL_FACE –Color –Normal They are the current values till changed

State Examples glBegin(GL_TRIANGLES); glColor4f(1.0, 1.0, 1.0, 1.0); glVertex3f(0.0, 0.0, 0.0); glVertex3f(0.0, 1.0, 0.0); glColor4f(1.0, 0.0, 0.0, 1.0); glVertex3f(0.0, 0.0, 1.0); glEnd();

Stack Transformations are based on a stack architecture. glVertex3f(1,0,0); glTranslatef(2,0,0); glVertex3f(1,0,0); glRotatef(90,1,0,0); glTranslatef(2,0,0); glVertex3f(1,0,0);

Stack glTranslatef(1,0.8,2.4); glPushMatrix(); glRotatef(45,0,0,1); glScalef(1.5,1.5,1.5); glPushMatrix(); glTranslatef(-2,-1,1.2); glRotatef(27,.71,.71,0);

Stack glTranslatef(0.1, 0.5, 0.5); DrawTorso(); glPushMatrix(); glTranslatef(0.4, 0.4, 0.8); glRotatef(fArmRotation,0,0,1); glDrawUpperArm(); glTranslatef(0,0,-1); glRotatef(fLowerArmRotation,0.2,0.2,0.7); glPopMatrix();