API for creating a display window and using keyboard/mouse interations. See RayWindow.cpp to see how these are used for Assignment3

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

Lecture 4 of 41. Lab 1a: OpenGL Basics

Precept 2 Aleksey Boyko February 18, 2011

Today s Agenda. Basic design of a graphics system. Introduction to OpenGL

Introduction to OpenGL

Computer graphics MN1

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

// double buffering and RGB glutinitdisplaymode(glut_double GLUT_RGBA); // your own initializations

Computer Graphics Lighting

Computer Graphics Lighting. Why Do We Care About Lighting?

An Interactive Introduction to OpenGL and OpenGL ES Programming. Ed Angel Dave Shreiner

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

An Interactive Introduction to OpenGL Programming

OpenGL. Toolkits.

Graphics Pipeline & APIs

Graphics Pipeline & APIs

Lecture 4 Advanced Computer Graphics (CS & SE )

Outline. Other Graphics Technology. OpenGL Background and History. Platform Specifics. The Drawing Process

Graphics and Computation Introduction to OpenGL

Programming using OpenGL: A first Introduction

Rendering. Part 1 An introduction to OpenGL

Lecture 2 2D transformations Introduction to OpenGL

Computer Graphics. OpenGL

Introduction to Computer Graphics with OpenGL/GLUT

Computer graphic -- Programming with OpenGL I

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

Computer graphics MN1

OpenGL: Open Graphics Library. Introduction to OpenGL Part II. How do I render a geometric primitive? What is OpenGL

RASTERISED RENDERING

1 (Practice 1) Introduction to OpenGL

RECITATION - 1. Ceng477 Fall

Introduction to OpenGL Transformations, Viewing and Lighting. Ali Bigdelou

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

OpenGL/GLUT Intro. Week 1, Fri Jan 12

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

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

GL_MODELVIEW transformation

Introduction to OpenGL

OpenGL refresher. Advanced Computer Graphics 2012

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

Luiz Fernando Martha André Pereira

CS Computer Graphics: Illumination and Shading I

CS Computer Graphics: Illumination and Shading I

Computer Graphics Introduction to OpenGL

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

Computer Graphics 1 Computer Graphics 1

CSE 167: Introduction to Computer Graphics Lecture #5: Visibility, OpenGL

CS4202: Test. 1. Write the letter corresponding to the library name next to the statement or statements that describe library.

Understand how real-world lighting conditions are approximated by OpenGL

CS Computer Graphics: OpenGL, Continued

CS Computer Graphics: OpenGL, Continued

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

Transformation Pipeline

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

Computer Graphics Primitive Attributes

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

Programming of Graphics

INF3320 Computer Graphics and Discrete Geometry

OpenGL Tutorial. Ceng 477 Introduction to Computer Graphics

OpenGL: A Practical Introduction. (thanks, Mark Livingston!)

Computer Graphics. Making Pictures. Computer Graphics CSC470 1

UNIT 7 LIGHTING AND SHADING. 1. Explain phong lighting model. Indicate the advantages and disadvantages. (Jun2012) 10M

CSC Graphics Programming. Budditha Hettige Department of Statistics and Computer Science

Basic Graphics Programming

Computer graphics Labs: OpenGL (1/3) Geometric transformations and projections

Assignment 1. Simple Graphics program using OpenGL

Today s class. Simple shadows Shading Lighting in OpenGL. Informationsteknologi. Wednesday, November 21, 2007 Computer Graphics - Class 10 1

Computer graphics MN1

Rendering Pipeline/ OpenGL

Computer Graphics. Chapter 10 Three-Dimensional Viewing

Lecture 3 Advanced Computer Graphics (CS & SE )

CS418 OpenGL & GLUT Programming Tutorial (I) Presented by : Wei-Wen Feng 1/30/2008

Pearce Outline. OpenGL Background and History. Other Graphics Technology. Platform Specifics. The Drawing Process

Getting Started. Overview (1): Getting Started (1): Getting Started (2): Getting Started (3): COSC 4431/5331 Computer Graphics.

OpenGL Transformations

Programming with OpenGL Part 1: Background

Introduction to OpenGL Week 1

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

Letterkenny Institute of Technology

Hierarchical Modeling: Tree of Transformations, Display Lists and Functions, Matrix and Attribute Stacks,

Computer graphic -- Programming with OpenGL 2

Computer Graphics Introduction to OpenGL

Introduction to OpenGL. Prof. Dr.-Ing. Lars Linsen

CSC 8470 Computer Graphics. What is Computer Graphics?

Lights, Colour and Materials In OpenGL

3D Graphics and OpenGl. First Steps

Spring 2013, CS 112 Programming Assignment 2 Submission Due: April 26, 2013

Using GLU/GLUT Objects

Basic Graphics Programming

CIS 636 Interactive Computer Graphics CIS 736 Computer Graphics Spring 2011

3D Graphics and API with OpenGL

COMP 371/4 Computer Graphics Week 1

Lighting. CSC 7443: Scientific Information Visualization

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

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

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

Exercise 1 Introduction to OpenGL

Modeling with Transformations

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

Drawing Primitives. OpenGL basics

Transcription:

OpenGL Introduction Introduction OpenGL OpenGL is an API for computer graphics. Hardware-independent Windowing or getting input is not included in the API Low-level Only knows about triangles (kind of, but also: points, lines, polygons) Libraries are often built on top of OpenGL State machine The various API calls change the OpenGL state, query some part of that state, or cause OpenGL to use its current state to render something GLUT (OpenGL Utility Toolkit) or FreeGLUT API for creating a display window and using keyboard/mouse interations. See RayWindow.cpp to see how these are used for Assignment3 GLU (OpenGL Utility Library) Provides commonly used functions on top of OpenGL. Viewing/Camera functions glulookat (Sets the view matrix that transforms model coordinates to world coordinates) gluperspective (Sets up perspective projection given a field of view and aspect ratio) (RayWindow::DisplayFunction) Higher level shape drawing functions glucylinder glusphere Other GLEW - OpenGL Extension Wrangler Helps loading extensions GLFW 1

Similar to GLUT and FreeGLUT Many more Tutorial 1 - Hello World! (First Window) glutinit Primary initialization routine glutinitdisplaymode Creates windows with certain types of windows glutcreatewindow Creates the window with the provided name glutreshapewindow Changes the size of the window to the width and height provided glutdisplayfunc Sets a callback function for the window. GLUT determines when the display callback should be triggered based on the window s redisplay state (can set explicitly by calling glutpostredisplay). glutmainloop Starts the GLUT event processing loop, all registered callbacks will now get called. Tutorial 2 - First Rendering glclearcolor Establishes what color the window will be cleared to (background color) glclear Actually clears the window (by clearing the framebuffers) glgetfloatv Get values from the current OpenGL state GL_MODELVIEW_MATRIX, GL_PROJECTION_MATRIX Model coordinates (vertices defined relative to the model/object) Model Matrix World coordinates (vertices defined relative to the center of the world) View Matrix Camera coordinates (vertices defined relative to the camera) Projection Matrix Homogeneous coordinates (vertices defined relative to the camera s perspective) glbegin & glend 2

Define what type of objects to draw Possible types: GL_POINTS, GL_LINES, GL_LINE_STRIP, GL_LINE_LOOP, GL_TRIANGLES, GL_TRIANGLE_STRIP, GL_TRIANGLE_FAN, GL_QUADS, GL_QUAD_STRIP, and GL_POLYGON glcolor3f Set the color for a vertex (or any object) All objects after this call will use this color, need to call it again to change glvertex3f Vertices of a shape glutswapbuffers Tells the window to use the current buffers in the OpenGL state (calls glflush) Tutorial 3 - Model View and Projection Matrices glmatrixmode Specifies the matrix that will be operated on glloadidentity Replaces the specified current matrix with the identity matrix gluperspective For setting the perspective transformation (projection matrix) 4 arguments: fovy - field of view (degrees) in y direction aspect - aspect ratio (width/height) znear - near clipping plane zfar - far clipping plane glulookat For setting the viewing transformation (view matrix) 3 sets of arguments Eye x,y,z - location of the camera (3D point) - Center/Reference x,y,z - where camera is looking (3D point) - Up x,y,z - rotation of the camera (3D vector) You want to move forward - What is the direction vector (forward vector) of the camera??? You want to move right What is the vector pointing to the right of the camera??? glrotatef Rotates the current object angle degrees around the vector x,y,z gltranslatef Translates in the given x,y,z direction 3

Tutorial 4 - Transformation Stack glpushmatrix Pushes the current matrix stack down by one, duplicating the current matrix glpopmatrix Pops the current matrix stack, replacing the current matrix with the one below it Explanation: You are applying transformations to the modelview matrix (with gltranslate or glrotate) and then you are in some good reference position. You can push a duplicate matrix onto the stack, perform a transformation on that, and then pop it off and you are back at that reference position. This avoids having to either make backwards transformations to get back to your reference position or making the whole original sequence of transformations again. Tutorial 5, 6 - Call lists Not used in Assignment 3 anymore Tutorial 7 - Lighting glenable Enables a state variable glenable(gl_lighting) If not enabled (or gldisable is called) then everything is colored according to the glcolor calls made glenable(gl_light0) gllightfv Sets parameters for a light Parameters: light - which light it is pname - which parameter name to change for the light params - the value(s) of the parameters pname options: (GL_AMBIENT, GL_DIFFUSE, GL_SPECULAR, GL_POSITION, GL_SPOT_CUTOFF, GL_SPOT_DIRECTION, GL_SPOT_EXPONENT, GL_CONSTANT_ATTENUATION, GL_LINEAR_ATTENUATION, and GL_QUADRATIC_ATTENUATION) glmaterialfv 4

Sets parameters for a material (with respect to a light) Parameters: face - face being updated (GL_FRONT, GL_BACK, or GL_FRONT_AND_BACK) pname - which material parameter to change params - the value(s) of the parameters pname options: (GL_AMBIENT, GL_DIFFUSE, GL_SPECULAR, GL_EMISSION, GL_SHININESS, GL_AMBIENT_AND_DIFFUSE, or GL_COLOR_INDEXES) Tutorial 8 - Shading Tutorial 9 - Texture Tutorial 10 - Depth Test Tutorial 11 - Transparency 5