+ All Categories
Home > Documents > CS293 Graphics with Java and OpenGL

CS293 Graphics with Java and OpenGL

Date post: 09-Jan-2016
Category:
Upload: corine
View: 56 times
Download: 5 times
Share this document with a friend
Description:
CS293 Graphics with Java and OpenGL. Introduction. The OpenGL graphics system is a software interface to graphics hardware. (The GL stands for Graphics Library.) For interactive programs that produce color images of moving three-dimensional objects. First introduced 1992. OpenGL. - PowerPoint PPT Presentation
25
UniS CS293 Graphics with Java and OpenGL Introduction
Transcript
Page 1: CS293 Graphics with Java and OpenGL

UniS

CS293 Graphics with Java and OpenGL

Introduction

Page 2: CS293 Graphics with Java and OpenGL

2

UniS

• The OpenGL graphics system is a software interface to graphics hardware. (The GL stands for Graphics Library.)

• For interactive programs that produce color images of moving three-dimensional objects.

• First introduced 1992.

Page 3: CS293 Graphics with Java and OpenGL

3

UniS

OpenGL

With OpenGL, you can control computer-graphics technology to produce realistic pictures or ones that depart from reality in imaginative ways.

OpenGL has become the industry standard for graphics applications

and games.

Page 4: CS293 Graphics with Java and OpenGL

4

UniS

JOGL

OpenGL is originally written in C.

JOGL is the Java OpenGLprogramming bindings to OpenGL APIs.

JOGL, since 2003, is maintained and supported by Sun Microsystems as one of their official Java projects: https://jogl.dev.java.net/

Page 5: CS293 Graphics with Java and OpenGL

5

UniS

JOGL

• JOGL is very much still being developed.• Our goal is to understand OpenGL. Java is simply a

means to an end.• We study OpenGL basics and how to build

interesting animated 3D models. • Hence, we do not devote any significant effort to

worrying about the current foibles of the JOGL implementation.

• We stick with an early version of JOGL which is tried and tested, which is available from the course web site.

• We do not use any additional tools to build 3D models beyond Netbeans 5.5. Most of these are in flux and are not stable. At the time of writing, NetBeans 6.0 still has unpredictable behaviour when compiling some JOGL code.

Page 6: CS293 Graphics with Java and OpenGL

6

UniS

Texts

• Free online copy of the original OpenGL V1.1 Redbook:http://www.glprogramming.com/red/index.html

• Note: written in C, not Java. However this is a very informative book, which has been used extensively for this course as the main source of examples and core material.

• Goes in-depth into many aspects of computer graphics that are invaluable as aid to understanding subject.

• Many examples from Redbook have been translated into Java and are available online:

http://ak.kiet.le.googlepages.com/theredbookinjava.html

Page 7: CS293 Graphics with Java and OpenGL

7

UniS

Texts

• BEWARE EARLY VERSIONS of JOGL texts.• Learning Java Bindings for OpenGL (JOGL). Not compatible

with current version of JOGL, beware!

Page 8: CS293 Graphics with Java and OpenGL

8

UniS

Course Details

• Much of the material for this course is a direct translation of the material available in the Open GL Redbook, except we use JOGL not C.

• Core material split into following sections

• "Introduction to OpenGL," provides a glimpse into the kinds of things OpenGL can do.

Includes simple OpenGL program and essential programming details you need to know for subsequent sections.

Page 9: CS293 Graphics with Java and OpenGL

9

UniS

Course Details

• "State Management and Drawing Geometric Objects," how to create a three-dimensional geometric description of an object that is eventually drawn on the screen.

• "Viewing," how three-dimensional models are transformed before being drawn onto a two-dimensional screen. You can control these transformations to show a particular view of a model.

• "Color," how to specify the colour and shading method used to draw an object.

• "Lighting," how to control the lighting conditions surrounding an object and how that object responds to light (that is, how it reflects or absorbs light). Lighting is an important topic, since objects usually don't look three-dimensional until they're lit.

Page 10: CS293 Graphics with Java and OpenGL

10

UniS

Introduction to OpenGL

• "What Is OpenGL?", what it does and doesn't do, and how it works.

• "A Smidgen of OpenGL Code" presents a small OpenGL program and briefly discusses it.

• "OpenGL Command Syntax" explains some of the conventions and notations used by OpenGL commands.

• "OpenGL as a State Machine" describes the use of state variables in OpenGL and the commands for querying, enabling, and disabling states.

• "OpenGL Rendering Pipeline" shows a typical sequence of operations for processing geometric and image data.

• "Animation" explains in high level terms how to create pictures on the screen that move.

Page 11: CS293 Graphics with Java and OpenGL

11

UniS

Introduction to OpenGL

• OpenGL is a software interface to graphics hardware.

• This interface consists of about 200 distinct commands that you use to specify the objects and operations needed to produce interactive three-dimensional applications.

Page 12: CS293 Graphics with Java and OpenGL

12

UniS

Introduction to OpenGL

• OpenGL is designed as a streamlined, hardware-independent interface to be implemented on many different hardware platforms.

• No commands for performing windowing tasks or obtaining user input are included in OpenGL;

• Similarly, OpenGL doesn't provide high-level commands for describing models of three-dimensional objects.

• With OpenGL, you must build up your desired model from a small set of geometric primitives - points, lines, and polygons.

Page 13: CS293 Graphics with Java and OpenGL

13

UniS

Introduction to OpenGL, Basic Image Construction

• Lets look at how the cover plate for the Redbook is constructed with OpenGl

Page 14: CS293 Graphics with Java and OpenGL

14

UniS

Introduction to OpenGL, Basic Image Construction

• Cover scene constructed as a wireframe model

Page 15: CS293 Graphics with Java and OpenGL

15

UniS

Introduction to OpenGL, Basic Image Construction

• Each line of wire corresponds to an edge of a primitive (typically a polygon).

• For example, the surface of the table is constructed from triangular polygons that fit together in a sort of 3d jigsaw

Page 16: CS293 Graphics with Java and OpenGL

16

UniS

Introduction to OpenGL, Basic Image Construction

• Note that you can see portions of objects that would be obscured if the objects were solid rather than wireframe.

• For example, you can see the entire model of the hills outside the window even though most of this model is normally hidden by the wall of the room.

• The globe appears to be nearly solid because it's composed of hundreds of colored blocks, and you see the wireframe lines for all the edges of all the blocks, even those forming the back side of the globe.

Page 17: CS293 Graphics with Java and OpenGL

17

UniS

Introduction to OpenGL, Basic Image Construction

• Depth-cued version of wireframe scene. Note that the lines farther from the eye are dimmer, giving a visual cue of depth.

Page 18: CS293 Graphics with Java and OpenGL

18

UniS

Introduction to OpenGL, Basic Image Construction

• OpenGL uses atmospheric effects (collectively referred to as fog) to achieve depth cueing.

Page 19: CS293 Graphics with Java and OpenGL

19

UniS

Introduction to OpenGL, Basic Image Construction

Antialiased version of the wireframe scene.

Page 20: CS293 Graphics with Java and OpenGL

20

UniS

Introduction to OpenGL, Basic Image Construction

• Antialiasing is a technique for reducing the jagged edges (also known as jaggies) created when approximating smooth edges using pixels - short for picture elements - which are confined to a rectangular grid.

• Such jaggies are usually the most visible with near-horizontal or near-vertical lines.

Page 21: CS293 Graphics with Java and OpenGL

21

UniS

Introduction to OpenGL, Basic Image Construction

• Flat-shaded, unlit version of the scene.

Page 22: CS293 Graphics with Java and OpenGL

22

UniS

Introduction to OpenGL, Basic Image Construction

• The objects in the scene are now shown as solid. • They appear "flat" in the sense that only one color is

used to render each polygon, so they don't appear smoothly rounded.

• There are no effects from any light sources.

Page 23: CS293 Graphics with Java and OpenGL

23

UniS

Introduction to OpenGL, Basic Image Construction

• Lit, smooth-shaded version of the scene.

Page 24: CS293 Graphics with Java and OpenGL

24

UniS

Introduction to OpenGL, Basic Image Construction

• scene looks much more realistic and three-dimensional

• objects are shaded to respond to the light sources in the room as if the objects were smoothly rounded.

Page 25: CS293 Graphics with Java and OpenGL

25

UniS

Introduction to OpenGL, Basic Image Construction• Final Image again, built from previous images, also

has texture mapping and shadows.• Texture mapping allows you to apply a two-

dimensional image onto a three-dimensional object. • Table surface is the most vibrant example of texture

mapping. • The wood grain on the floor and table surface are all

texture mapped, as well as the wallpaper and the toy spinning top.


Recommended