CS297 Graphics with Java and OpenGL

Slides:



Advertisements
Similar presentations
OpenGL Course Notes Chapter 2: State Management and Drawing Geometric Objects Jim Mims, Spring 2009.
Advertisements

Chapter 2: Graphics Programming
Computer Graphics Tz-Huan Huang National Taiwan University (Slides are based on Prof. Chen’s)
Computer Graphics CSCE 441
Graphics Pipeline.
Computer Graphic Creator: Mohsen Asghari Session 2 Fall 2014.
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 Models and Architectures Ed Angel Professor of Computer Science, Electrical and Computer.
3D Rendering with JOGL Introduction to Java OpenGL Graphic Library By Ricardo Veguilla
Computer Graphics: Programming, Problem Solving, and Visual Communication Steve Cunningham California State University Stanislaus and Grinnell College.
Course Overview, Introduction to CG Glenn G. Chappell U. of Alaska Fairbanks CS 381 Lecture Notes Friday, September 5, 2003.
COS 397 Computer Graphics Assoc. Prof. Svetla Boytcheva AUBG 2013 COS 397 Computer Graphics Practical Session №1 Introduction to OpenGL, GLFW and CG.
UniS CS297 Graphics with Java and OpenGL Viewing, the model view matrix.
UniS CS297 Graphics with Java and OpenGL Introduction.
Linear Interpolation, Brief Introduction to OpenGL Glenn G. Chappell U. of Alaska Fairbanks CS 381 Lecture Notes Monday, September.
Image Synthesis Rabie A. Ramadan, PhD 2. 2 Java OpenGL Using JOGL: Using JOGL: Wiki: You can download JOGL from.
UniS CS293 Graphics with Java and OpenGL Introduction.
Korea University Korea University Computer Graphics Laboratory Computer Graphics Laboratory Jung Lee, Chapter 13.
CSE 470: Computer Graphics. 10/15/ Defining a Vertex A 2D vertex: glVertex2f(GLfloat x, GLfloat y); 2D vertexfloating pointopenGL parameter type.
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.
Homogeneous Form, Introduction to 3-D Graphics Glenn G. Chappell U. of Alaska Fairbanks CS 381 Lecture Notes Monday, October 20,
Image Synthesis Rabie A. Ramadan, PhD 1. 2 About my self Rabie A. Ramadan My website and publications
CSE Real Time Rendering Week 2. Graphics Processing 2.
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
1 Computer Graphics Week2 –Creating a Picture. Steps for creating a picture Creating a model Perform necessary transformation Lighting and rendering the.
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.
UniS CS297 Graphics with Java and OpenGL Basic Definitions.
Computer Graphics Chapter 6 Andreas Savva. 2 Interactive Graphics Graphics provides one of the most natural means of communicating with a computer. Interactive.
Introduction to OpenGL  OpenGL is a graphics API  Software library  Layer between programmer and graphics hardware (and software)  OpenGL can fit in.
Introduction to OpenGL. OpenGL is a low-level graphics library specification. It makes available to the programmer  a small set of geometric primitives.
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.
RENDERING Introduction to Shading models – Flat and Smooth shading – Adding texture to faces – Adding shadows of objects – Building a camera in a program.
NoufNaief.net TA: Nouf Al-harbi.
CS COMPUTER GRAPHICS LABORATORY. LIST OF EXPERIMENTS 1.Implementation of Bresenhams Algorithm – Line, Circle, Ellipse. 2.Implementation of Line,
UniS CS297 Graphics with Java and OpenGL Blending.
1 Angel: Interactive Computer Graphics5E © Addison- Wesley 2009 Image Formation Fundamental imaging notions Fundamental imaging notions Physical basis.
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.
Chapter 1 Graphics Systems and Models Models and Architectures.
Introduce Jogl. Outline What is Jogl Jogl coding template Create a GLPanel Draw a 2D object on GLPanel Draw texts on GLPanel Draw a 3D object on GLPanel.
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.
CPCS 391 Computer Graphics Lab One. Computer Graphics Using Java What is Computer Graphics: Computer graphics are graphics created using computers and,
Computer Graphics (Fall 2003) COMS 4160, Lecture 5: OpenGL 1 Ravi Ramamoorthi Many slides courtesy Greg Humphreys.
Administrivia Back on track: canceling OpenGL lecture 2 Assignment 1
Computer Graphics Lecture 3 Computer Graphics Hardware
Computer Graphics Lecture 32
Modeling 101 For the moment assume that all geometry consists of points, lines and faces Line: A segment between two endpoints Face: A planar area bounded.
Programming with OpenGL Part 2: Complete Programs
CS451Real-time Rendering Pipeline
OpenGL API 2D Graphic Primitives
Models and Architectures
Programming with OpenGL Part 2: Complete Programs
Models and Architectures
Models and Architectures
Introduction to Computer Graphics with WebGL
Class 1: First Program.
Display Lists & Text Glenn G. Chappell
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
Programming with OpenGL Part 2: Complete Programs
Presentation transcript:

CS297 Graphics with Java and OpenGL Basic Definitions

Introduction to OpenGL, Rendering Pipeline Construct shapes from geometric primitives, thereby creating mathematical descriptions of objects. (OpenGL considers points, lines, polygons, images, and bitmaps to be primitives.) Arrange the objects in three-dimensional space and select the desired vantage point for viewing the composed scene. Calculate the color of all the objects. The color might be explicitly assigned by the application, determined from specified lighting conditions, obtained by pasting a texture onto the objects, or some combination of these three actions. Convert the mathematical description of objects and their associated color information to pixels on the screen. This process is called rasterization.

Basic Definitions Models, or objects, are constructed from geometric primitives - points, lines, and polygons - that are specified by their vertices. Pixel, is the smallest visible element the display hardware can put on the screen. Rendering, process by which a computer creates images from models and consists of pixels drawn on the screen. Bitplane, area of memory that holds one bit of information for every pixel on the screen. E.g. bit might indicate how red a particular pixel is supposed to be. Framebuffer, stores all bitplanes, and holds all the information that the graphics display needs to control the color and intensity of all the pixels on the screen.

OpenGL simple example Very simple example shows many of JOGL elements that are common to all graphic programs. Only displays white square on black background, shown in Java Swing JFrame object. Full Code on course web site.

// various package imports declared here public class Simple2 implements GLEventListener { /* ***** Missing Code for GLEventListener interface methods on next slide ********* */ public static void main(String[ ] args) { JFrame.setDefaultLookAndFeelDecorated(false); JFrame jframe = new JFrame("Simple2"); jframe.setSize(500, 500); jframe.setLocationRelativeTo(null); // center of screen GLJPanel canvas = new GLJPanel(); Simple2 newGLEvtListnr = new Simple2(); canvas.addGLEventListener(newGLEvtListnr); jframe.getContentPane().add(canvas);//add canvas to JFrame window jframe.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); jframe.setVisible(true); // show window } }

Missing Code for Simple2 class public void display(GLAutoDrawable drawable) { GL gl = drawable.getGL(); gl.glClearColor(0.0f, 0.0f, 0.0f, 0.0f); gl.glClear(GL.GL_COLOR_BUFFER_BIT); gl.glColor3f(1.0f, 1.0f, 1.0f); gl.glOrtho(-1.0f, 1.0f, -1.0f, 1.0f, -1.0f, 1.0f); gl.glBegin(GL.GL_POLYGON); gl.glVertex2f(-0.5f, -0.5f); gl.glVertex2f(-0.5f, 0.5f); gl.glVertex2f(0.5f, 0.5f); gl.glVertex2f(0.5f, -0.5f); gl.glEnd(); gl.glFlush(); }

Simple2 drawable method glClearColor() establishes what color the window will be cleared to glClear() actually clears the window Once the clearing color is set, the window is cleared to that color whenever glClear() is called. glColor3f() command establishes what color to use for drawing objects – white for this example. glOrtho(), specifies coordinate system OpenGL assumes as it draws the final image and how the image gets mapped to the screen for orthographic parallel viewing volume.

gl.glOrtho(left, right, bottom, top, near, far); (right, top, -far) (right, top, -near) y x z point of view (left, bottom, -far) (left, bottom, -near)

Perspective (used later for 3D) Note glOrtho does not define perspective in 3D, it only defines the space that will be observable. For perspective different OpenGL operators are necessary: gl.glViewport(0, 0, w, h); gl.glMatrixMode(GL.GL_PROJECTION); glu.gluPerspective(40.0, (float) w / (float) h, 1.0, 20.0); These will be discussed in detail in later sections.

Simple2 drawable method code between glBegin() and glEnd(), define the object to be drawn a polygon with four vertices polygon's "corners" are defined by the glVertex3f() commands, or in 2D diagram glVertex2f(). Note the ‘f’ denotes that parameters are given as floating point values. (x, y, z) coordinates, the polygon is a rectangle on the z=0 plane glFlush() ensures that the drawing commands are actually executed rather than stored in a buffer awaiting additional OpenGL commands

Introduction to elementrary animation in OpenGL Movie motion is achieved by taking a sequence of pictures and projecting them at 24 per second on the screen Each frame is moved into position behind the lens, The shutter is opened, and the frame is displayed. The shutter is momentarily closed while the film is advanced to the next frame, then that frame is displayed, and so on. Old Charlie Chaplin movies were shot at 16 frames per second and are noticeably jerky. Computer-graphics screens typically refresh (redraw the picture) approximately 60 to 76 times per second Refresh rates faster than 120, however, are beyond the point of diminishing returns, since the human eye is only so good. The key reason that motion picture projection works is that each frame is complete when it is displayed.