Introduction : What is OpenGL

Slides:



Advertisements
Similar presentations
Presented by: Stacy C. Lovell. How do we perceive color? Our eyes contain only 3 types of photosentitive cells tuned to three frequencies Red, Green,
Advertisements

Graphics Pipeline.
Status – Week 257 Victor Moya. Summary GPU interface. GPU interface. GPU state. GPU state. API/Driver State. API/Driver State. Driver/CPU Proxy. Driver/CPU.
RealityEngine Graphics Kurt Akeley Silicon Graphics Computer Systems.
OPENGL Return of the Survival Guide. Buffers (0,0) OpenGL holds the buffers in a coordinate system such that the origin is the lower left corner.
Computer Graphic Creator: Mohsen Asghari Session 2 Fall 2014.
1 Understanding of OpenGL TA: Dong Hyun Jeong Instructor : Dr. Kalpathi Subramanian Texture Mapping.
Compositing and Blending - Chapter 8 modified by Ray Wisman Ed Angel Professor of Computer Science, Electrical and Computer Engineering,
Real-Time Rendering SPEACIAL EFFECTS Lecture 03 Marina Gavrilova.
1 Angel: Interactive Computer Graphics 4E © Addison-Wesley 2005 Models and Architectures Ed Angel Professor of Computer Science, Electrical and Computer.
Ch 1 Intro to Graphics page 1CS 367 First Day Agenda Best course you have ever had (survey) Info Cards Name, , Nickname C / C++ experience, EOS experience.
CS 4731: Computer Graphics Lecture 17: Texturing Emmanuel Agu.
3D Rendering with JOGL Introduction to Java OpenGL Graphic Library By Ricardo Veguilla
Texture Mapping A way of adding surface details Two ways can achieve the goal:  Surface detail polygons: create extra polygons to model object details.
1 Perception, Illusion and VR HNRS 299, Spring 2008 Lecture 19 Other Graphics Considerations Review.
JOGL in MS Windows GDI – Graphics Device Interface (Windows-specific) OpenGL Lib JOGL Commands GDI Processor Graphics Hardware JOGL Lib.
Graphics System CSC 2141 Introduction to Computer Graphics.
Basic OpenGL Glenn G. Chappell U. of Alaska Fairbanks CS 381 Lecture Notes Wednesday, September 10, 2003.
Computer Graphics Texture Mapping Eriq Muhammad Adams
Texture Mapping. Scope Buffers Buffers Various of graphics image Various of graphics image Texture mapping Texture mapping.
Computer Graphics Ben-Gurion University of the Negev Fall 2012.
Mapping method Texture Mapping Environmental mapping (sphere mapping) (cube mapping)
CS 450: COMPUTER GRAPHICS REVIEW: INTRODUCTION TO COMPUTER GRAPHICS – PART 2 SPRING 2015 DR. MICHAEL J. REALE.
Graphics Systems and OpenGL. Business of Generating Images Images are made up of pixels.
CSC 461: Lecture 3 1 CSC461 Lecture 3: Models and Architectures  Objectives –Learn the basic design of a graphics system –Introduce pipeline architecture.
CS 480/680 Computer Graphics Image Formation Dr. Frederick C Harris, Jr.
CS 638, Fall 2001 Multi-Pass Rendering The pipeline takes one triangle at a time, so only local information, and pre-computed maps, are available Multi-Pass.
OpenGL Conclusions OpenGL Programming and Reference Guides, other sources CSCI 6360/4360.
Ch 2 Graphics Programming page 1 CSC 367 Coordinate Systems (2.1.2) Device coordinates, or screen coordinates (pixels) put limitations on programmers and.
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
Introduction to OpenGL Programming Jian-Liang Lin 2002.
1Computer Graphics Lecture 4 - Models and Architectures John Shearer Culture Lab – space 2
COMPUTER GRAPHICS CSCI 375. What do I need to know?  Familiarity with  Trigonometry  Analytic geometry  Linear algebra  Data structures  OOP.
Computer Graphics Chapter 6 Andreas Savva. 2 Interactive Graphics Graphics provides one of the most natural means of communicating with a computer. Interactive.
Review of OpenGL Basics
Introduction to OpenGL  OpenGL is a graphics API  Software library  Layer between programmer and graphics hardware (and software)  OpenGL can fit in.
09/16/03CS679 - Fall Copyright Univ. of Wisconsin Last Time Environment mapping Light mapping Project Goals for Stage 1.
Draw a Simple Object. Pixel pipeline Vertex pipeline Course Map Transformation & Lighting Primitive assembly Viewport culling & clipping Texture blending.
Advanced Computer Graphics Spring 2014 K. H. Ko School of Mechatronics Gwangju Institute of Science and Technology.
Review on Graphics Basics. Outline Polygon rendering pipeline Affine transformations Projective transformations Lighting and shading From vertices to.
Programming With OpenGL
OpenGL: The Open Graphics Language Introduction By Ricardo Veguilla.
What are shaders? In the field of computer graphics, a shader is a computer program that runs on the graphics processing unit(GPU) and is used to do shading.
1 Programming with OpenGL Part 2: Complete Programs.
OpenGL API 2D Graphic Primitives Angel Angel: Interactive Computer Graphics5E © Addison-Wesley
Chapter 4 -- Color1 Color Open GL Chapter 4. Chapter 4 -- Color2 n The goal of almost all OpenGL applications is to draw color pictures in a window on.
The Framebuffer Hyun-Chul Cho. HyunChul Cho - KUCG -2 Buffer Goal of a graphics program Draw pictures on the screen Screen Rectangular array.
1 E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley 2012 Models and Architectures 靜宜大學 資訊工程系 蔡奇偉 副教授 2012.
Computer Graphics I, Fall Programming with OpenGL Part 2: Complete Programs.
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.
Discrete Techniques.
Draw a Simple Object.
Computer Graphics Lecture 32
Programming with OpenGL Part 2: Complete Programs
Models and Architectures
Programming with OpenGL Part 2: Complete Programs
OpenGL (Open Graphics Library) Mr. B.A.Swamy Assistant Professor Dept of CSE.
Models and Architectures
Models and Architectures
Introduction to Computer Graphics with WebGL
The Graphics Pipeline Lecture 5 Mon, Sep 3, 2007.
Introduction to OpenGL
Models and Architectures
Models and Architectures
Programming with OpenGL Part 2: Complete Programs
Programming with OpenGL Part 2: Complete Programs
CS297 Graphics with Java and OpenGL
Programming Textures Lecture 15 Fri, Sep 28, 2007.
Programming with OpenGL Part 2: Complete Programs
Presentation transcript:

Introduction : What is OpenGL Software interface to graphics hardware Hardware-independent interface OpenGL's main purpose is to render two- and three-dimensional objects into a frame buffer.

Fundamentals Primitives and Commands defined by a group of one or more vertices Commands are always processed in the order in which they are received Procedural versus Descriptive Execution Model client-servermodel for interpretation of OpenGL commands

Basic OpenGL Operation High-level block diagram of how OpenGL processes data

Getting started with OpenGL Initialisation Setting up the window for rendering Set up the correct window style and class attribute : WS_CLIPSIBLINGS and WS_CLIPCHILDREN Should have CS_OWNDC instead of CS_PARENTDC Set up a pixel format Create a device context Creating a rendering context.

Pixel Format Description of the actual format given to a particular window Some of the properties that you want some control over Single or double buffering Drawing to a window and/or bitmap Supporting GDI and/or OpenGL calls RGBA or color-indexed Color depth (bits/pixel) z-axis depth

Getting started with OpenGL Contd. Tell OpenGL about the window you're rendering to and how you want your scene to be viewed Responding to the WM_SIZE message. Responding to the WM_PAINT message. Responding to the WM_ERASEBACKGROUND message. Responding to the WM_PALETTECHANGED, WM_QUERYNEWPALETTE, and WM_ACTIVATE messages (if you use a color-index pixel format). Deleting the RC and DC when your program finishes.

Initialisation

Simple example using OpenGL Add OpenGL32.lib GLu32.lib and GLaux.lib Include the header files #include <windows.h> // Header File For Windows #include <gl\gl.h> // Header File For The OpenGL32 Library #include <gl\glu.h> // Header File For The GLu32 Library #include <gl\glaux.h> // Header File For The GLaux Library InitGL glShadeModel(GL_SMOOTH); glClearColor(0.0f, 0.0f, 0.0f, 0.0f); glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST); ReSizeGLScene(GLsizei width, GLsizei height) glViewport(0, 0, width, height); glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluPerspective(45.0f,(GLfloat)width/(GLfloat)height,0.1f,100.0f); glMatrixMode(GL_MODELVIEW);

Simple example using OpenGL : Contd. DrawGLScene(GLvoid) glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glLoadIdentity(); glTranslatef(-1.5f,0.0f,-6.0f); glBegin(GL_TRIANGLES); glVertex3f( 0.0f, 1.0f, 0.0f); glVertex3f(-1.0f,-1.0f, 0.0f); glVertex3f( 1.0f,-1.0f, 0.0f); glEnd(); CreateGLWindow() CreateWindow() Initialise Pixel Format PIXELFORMATDESCRIPTOR pfd ChoosePixelFormat(hDC,&pfd) SetPixelFormat(hDC,PixelFormat,&pfd) wglCreateContext(hDC) wglMakeCurrent(hDC,hRC) call ReSizeGLScene(width, height); call InitGL()

Frame Buffers Contain different amounts of data per pixel Bitplane : A buffer that stores a single bit of information about pixels Color buffer holds the color information You can use GL_STEREO or GL_DOUBLEBUFFER Depth buffer stores a depth value for each pixel Stencil buffer to restrict drawing to certain portions of the screen Accumulation buffer holds RGBA color data accumulating a series of images into a final, composite image

Colors each pixel emits different amounts of red, green, and blue light can be stored either in RGBA mode or color index mode API used glColor3f (1.0, 0.0, 0.0);

Rotation Three major axes and therefore three rotations API used glRotatef(Angle,Xvector,Yvector,Zvector)

Drawing Solid Objects glVertex3f( 0.0f, 1.0f, 0.0f); // Top Of Triangle (Front) glVertex3f(-1.0f,-1.0f, 1.0f); // Left Of Triangle (Front) glVertex3f( 1.0f,-1.0f, 1.0f); // Right Of Triangle (Front) Display lists group of OpenGL commands that have been stored for later execution improve performance API's used gluint glGenLists() glNewList(listname, GL_COMPILE) glEndList()

Texture Mapping Textures are simply rectangular arrays of data Allows you to glue an image to a polygon Texture mapping ensures that all the right things happen as the polygon is transformed and rendered Filtering Process of averaging or interpolating texels provide different trade-offs between speed and image quality API's used glTexParameteri() for GL_TEXTURE_MIN_FILTER and GL_TEXTURE_MAG_FILTER Parameter : GL_NEAREST or GL_LINEAR or MIPMAP

Blending Tells how to specify a blending function that combines color values from a source and a destination Occurs after your scene has been rasterized and converted to fragments, but just before the final pixels are drawn in the framebuffer Basic Alpha Blending result = ALPHA * srcPixel + ( 1 - ALPHA ) * destPixel API's glColor4f(1.0f,1.0f,1.0f,0.5f); glBlendFunc(GL_SRC_ALPHA,GL_ONE);

2D Texture Font use just one texture to display any of 256 different characters on the screen. average character is 16 pixels wide and roughly 16 pixels tall. Take your standard 256x256 texture it's easy to see that you can fit 16 letters across, and you can have a total of 16 rows up and down. glPushMatrix() glPopMatrix();

Quadratics used to create complex objects such as spheres, discs, cylinders and cones. GluNewQuadric() gluQuadricNormals(quadratic, GLU_SMOOTH); glTranslatef(0.0f,0.0f,-1.5f); // Center The Cylinder gluCylinder(quadratic,1.0f,1.0f,3.0f,32,32); // Draw Our Cylinder Tessellation to display of concave polygons, polygons containing hole, or polygons with intersecting edges

Masking two step process: place a black and white image of the texture on top of the scene switch blending modes, and map the texture on top of the black cut out.

Clipping & Reflections Requires stencil buffer Steps : gluSphere() glBindTexture(GL_TEXTURE_2D, texture[2]); glColor4f(1.0f, 1.0f, 1.0f, 0.4f); glEnable(GL_BLEND); // Enable Blending glBlendFunc(GL_SRC_ALPHA, GL_ONE); glEnable(GL_TEXTURE_GEN_S); //enable Sphere Mapping glEnable(GL_TEXTURE_GEN_T); // Enable Sphere Mapping gluSphere(q, 0.35f, 32, 16); clearing the buffers define clipping plane eqaution : used for clipping the reflected image.

Clipping & Reflections : Contd set the color mask to white glColorMask(0,0,0,0); enable stencil testing glEnable(GL_STENCIL_TEST); glStencilFunc(GL_ALWAYS, 1, 1); glStencilOp(GL_KEEP, GL_KEEP, GL_REPLACE); Draw the floor Change the color mask to opaque enable the clipping plane draw the reflected image

Shadows Extensively uses the stensil buffer A shaded region is a region in a scene that cannot be "seen" by a light source. INFINITY : how far to extend the shadow volume polygons Data reuired for casting a shadow : array of vertices vertex normals : to calculate orientation of the face plane equation indices into the array of faces in the object : to define edges

Limitations Printing OpenGL and GDI graphics cannot be mixed in a double-buffered window There are no per-window hardware color palettes. There is no direct support for the Clipboard, dynamic data exchange (DDE), or OLE There is no support for the following pixel format features: stereoscopic images, alpha bitplanes, and auxiliary buffers