1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.

Slides:



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

 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.
CSC 461: Lecture 51 CSC461 Lecture 5: Simple OpenGL Program Objectives: Discuss a simple program Discuss a simple program Introduce the OpenGL program.
1 Angel: Interactive Computer Graphics 4E © Addison-Wesley 2005 Programming with OpenGL Part 2: Complete Programs Ed Angel Professor of Computer Science,
1 Angel: Interactive Computer Graphics 4E © Addison-Wesley 2005 Programming with OpenGL Part 1: Background Ed Angel Professor of Computer Science, Electrical.
Programming with OpenGL Part 1: Background Mohan Sridharan Based on slides created by Edward Angel CS4395: Computer Graphics 1.
Introduction to OpenGL and GLUT GLUT. What is OpenGL? An application programming interface (API) A (low-level) Graphics rendering API Generate high-quality.
Graphics Architectures & OpenGL API Introduction Angel Angel: Interactive Computer Graphics5E © Addison-Wesley
CS 480/680 Computer Graphics Programming with Open GL Part 1: Background Dr. Frederick C Harris, Jr. Fall 2011.
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
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.
1 Angel and Shreiner: Interactive Computer Graphics 6E © Addison-Wesley 2012 Introduction to Computer Graphics Ed Angel Professor Emeritus of Computer.
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
1 E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley 2012 Programming with OpenGL Part 1: Background Ed Angel Professor Emeritus.
1 Angel: Interactive Computer Graphics 5E © Addison-Wesley 2009 Programming with OpenGL Review.
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
1 E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley 2012 Programming with OpenGL Part 2: Complete Programs Ed Angel Professor.
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
Programming with OpenGL Part 2: Complete Programs Ed Angel Professor of Emeritus of Computer Science University of New Mexico.
Programming with OpenGL Part 2: Complete Programs Ed Angel Professor of Emeritus of Computer Science University of New Mexico.
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
1 E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley 2012 Programming with OpenGL Part 6: Three Dimensions Ed Angel Professor.
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
Programming with OpenGL Part 3: Shaders Ed Angel Professor of Emeritus of Computer Science University of New Mexico 1 E. Angel and D. Shreiner: Interactive.
CS 480/680 Computer Graphics Programming with Open GL Part 2: Complete Programs Dr. Frederick C Harris, Jr. Fall 2011.
Hank Childs, University of Oregon Oct. 28th, 2016 CIS 441/541: Introduction to Computer Graphics Lecture 16: textures.
Introduction to Computer Graphics with WebGL
Programming with OpenGL Part 1: Background
Introduction to Computer Graphics with WebGL
Introduction to Computer Graphics with WebGL
Programming with OpenGL Part 2: Complete Programs
OpenGL API 2D Graphic Primitives
Programming with OpenGL Part 2: Complete Programs
Introduction to Computer Graphics with WebGL
Introduction to Computer Graphics with WebGL
GLSL I Ed Angel Professor of Computer Science, Electrical and Computer Engineering, and Media Arts Director, Arts Technology Center University of New Mexico.
Introduction to Computer Graphics with WebGL
Introduction to Computer Graphics with WebGL
Introduction to Computer Graphics with WebGL
Introduction to Computer Graphics with WebGL
Introduction to Computer Graphics with WebGL
Introduction to Computer Graphics with WebGL
Introduction to Computer Graphics with WebGL
Introduction to Computer Graphics with WebGL
Introduction to Computer Graphics with WebGL
Introduction to Computer Graphics with WebGL
Programming with OpenGL
Introduction to Computer Graphics with WebGL
Programming with OpenGL Part 1: Background
Introduction to Computer Graphics with WebGL
Introduction to Computer Graphics with WebGL
Introduction to Computer Graphics with WebGL
Introduction to Computer Graphics
Introduction to Computer Graphics with WebGL
Introduction to Computer Graphics with WebGL
Introduction to Computer Graphics with WebGL
Programming with OpenGL Part 2: Complete Programs
Programming with OpenGL Part 1: Background
Programming with OpenGL Part 2: Complete Programs
Programming with OpenGL Part 1: Background
Programming with OpenGL Part 6: Three Dimensions
Programming with OpenGL Part 3: Shaders
Programming with OpenGL Part 2: Complete Programs
Programming with OpenGL Part 2: Complete Programs
Introduction to Computer Graphics with WebGL
Presentation transcript:

1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science Laboratory University of New Mexico Angel and Shreiner: Interactive Computer Graphics 7E © Addison-Wesley 2015

2 Programming with WebGL Part 1: Background Ed Angel Professor Emeritus of Computer Science University of New Mexico Angel and Shreiner: Interactive Computer Graphics 7E © Addison-Wesley 2015

3 OpenGL Architecture Angel and Shreiner: Interactive Computer Graphics 7E © Addison-Wesley 2015

4 Software Organization Angel and Shreiner: Interactive Computer Graphics 7E © Addison-Wesley 2015

5 A OpenGL Simple Program Generate a square on a solid background Angel and Shreiner: Interactive Computer Graphics 7E © Addison-Wesley 2015

It used to be easy 6 #include void mydisplay(){ glClear(GL_COLOR_BUFFER_BIT); glBegin(GL_QUAD; glVertex2f(-0.5, -0.5); glVertex2f(-0,5, 0,5); glVertex2f(0.5, 0.5); glVertex2f(0.5, -0.5); glEnd() } int main(int argc, char** argv){ glutCreateWindow("simple"); glutDisplayFunc(mydisplay); glutMainLoop(); } Angel and Shreiner: Interactive Computer Graphics 7E © Addison-Wesley 2015

7 What happened? Most OpenGL functions deprecated ­immediate vs retained mode ­make use of GPU Makes heavy use of state variable default values that no longer exist ­Viewing ­Colors ­Window parameters However, processing loop is the same Angel and Shreiner: Interactive Computer Graphics 7E © Addison-Wesley 2015

Execution in Browser 8 Angel and Shreiner: Interactive Computer Graphics 7E © Addison-Wesley 2015

9 Event Loop Remember that the sample program specifies a render function which is a event listener or callback function ­Every program should have a render callback ­For a static application, we need only execute the render function once ­In a dynamic application, the render function can call itself recursively but each redrawing of the display must be triggered by an event Angel and Shreiner: Interactive Computer Graphics 7E © Addison-Wesley 2015

10 Lack of Object Orientation All versions of OpenGL are not object oriented so that there are multiple functions for a given logical function Example: sending values to shaders ­gl.uniform3f ­gl.uniform2i ­gl.uniform3dv Underlying storage mode is the same Angel and Shreiner: Interactive Computer Graphics 7E © Addison-Wesley 2015

11 WebGL function format gl.uniform3f(x,y,z) belongs to WebGL canvas function name x,y,z are variables gl.uniform3fv(p) p is an array dimension Angel and Shreiner: Interactive Computer Graphics 7E © Addison-Wesley 2015

12 WebGL constants Most constants are defined in the canvas object ­In desktop OpenGL, they were in #include files such as gl.h Examples ­desktop OpenGL glEnable(GL_DEPTH_TEST); ­WebGL gl.enable(gl.DEPTH_TEST) gl.clear(gl.COLOR_BUFFER_BIT) Angel and Shreiner: Interactive Computer Graphics 7E © Addison-Wesley 2015

WebGL and GLSL WebGL requires shaders and is based less on a state machine model than a data flow model Most state variables, attributes and related pre 3.1 OpenGL functions have been deprecated Action happens in shaders Job of application is to get data to GPU 13 Angel and Shreiner: Interactive Computer Graphics 7E © Addison-Wesley 2015

GLSL OpenGL Shading Language C-like with ­Matrix and vector types (2, 3, 4 dimensional) ­Overloaded operators ­C++ like constructors Similar to Nvidia’s Cg and Microsoft HLSL Code sent to shaders as source code WebGL functions compile, link and get information to shaders 14 Angel and Shreiner: Interactive Computer Graphics 7E © Addison-Wesley 2015