# Computer graphics/2013-2014/Laboratory 1

Quick links: front; laboratories agenda, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, JOGL template.

## AGENDA SUMMARY

Please consult Computer graphics -- 2013-2014 -- info.uvt.ro/Laboratory agenda.

## EVALUATION SUMMARY

Please consult Computer graphics -- 2013-2014 -- info.uvt.ro.

## TOOLS, FRAMEWORKS, LIBRARIES

Please consult Computer graphics -- 2013-2014 -- info.uvt.ro/Laboratory tools.

## INTRODUCTION TO COMPUTER GRAPHICS
### Computer graphics

Computer graphics definitions :
* Is a sub-field of computer science which studies methods for digitally synthesizing and manipulating visual content. Although the term often refers to the study of three-dimensional computer graphics, it also encompasses two-dimensional graphics and image processing wikipedia:Computer graphics
* Is the pictorial representation and manipulation of data by a computer
* Is the set of technologies used to create art with computers. Art or designs created using such technologies
It studies :
* the manipulation of visual and geometric information using computational techniques.
* algorithms to reproduce physically photo-realistic images
The following can be seen as sub-parts of it:
* Geometry -- studies methods to represent and process surfaces
* Animation -- studies methods to represent and manipulate motion
* Rendering -- represents images staring from models by using computer programs
* Imaging -- studies image acquisition and editing.
Links:
* wikipedia:Constructive solid geometry
* wikipedia:Subdivision surface
* wikipedia:Polygon mesh
* wikipedia:Animation
* wikipedia:Rendering (computer graphics)
* wikipedia:Digital imaging
* wikipedia:Image processing

### 2D / 3D graphics
#### 2D graphics

    implies computer-based generation of digital images (or image sequences -- animation), from (mostly 2-dimensional) models (like geometric shapes, text, other digital images), and manipulation techniques (rotation, translation, scaling, transparency, blending etc.).

#### 3D graphics

    (just like 2D graphics) implies computer-based generation of digital images (or image sequences), from 3-dimensional geometric shapes.
Both 2D and 3D graphics are an umbrella for methods / algorithms from all subfields (like geometry, rendering and imaging).
It generally implies the following steps:
* Modeling;
* Defining/determining the scene layout;
* Rendering the scene (includes objects);
As a comparison of the two, the output is the same -- a 2-dimensional image (or sequence) --, but the inputs are different -- 2D shapes / 3D shapes.
Links:
* wikipedia:2D computer graphics
* wikipedia:3D computer graphics
* wikipedia:3D modeling
* wikipedia:3D rendering

### Digital images
#### A Digital image

    is the representation of an image as a 2 dimensional matrix of values -- pixels -- which encode the color of the corresponding image point.
Links:
* wikipedia:Raster graphics
* wikipedia:Pixel

#### Image Resolution

The image resolution represents the quantity of information stored in a digital image. This usually refers to the number of pixels that compose the image;
Links:
* wikipedia:Image resolution
* wikipedia:Pixels per inch -- PPI -- very seldom used, but usually for to display devices;
* wikipedia:Dots per inch -- DPI -- very frequently used, but mainly for plotting / printing devices;

#### Color depth
##### Bits per pixel

    the number of bits allocated / used to encode the color for each pixel.
Tipical cases:
* wikipedia:1-bit color = 2^1 = 2 colors: black and white image;
* 2-bit = 2^2 = 4 colors:
** wikipedia:Grayscale;
** wikipedia:Color Graphics Adapter -- CGA;
* 4-bit = 2^4 = 16 colors:
** wikipedia:Enhanced Graphics Adapter -- EGA;
** wikipedia:VGA;
* wikipedia:8-bit color = 2^8 = 256 colors:
** wikipedia:VGA;
** wikipedia:Super Video Graphics Array -- SVGA;
* 15-bit = 2^15 = 32768 colors:
** 5 bits for each RGB channel;
** wikipedia:Highcolor;
* 16-bits = 2^16 = 65536 colors:
** just like in the 15-bit case, but for the green channel we have 6 bits;
** wikipedia:Truecolor;
* 24-bits = 2^24 = 16777216 colors:
** 8 bits for each RGB channel;
Links:
* wikipedia:Color depth

#### Color spaces
##### Color space

    a mathematical method to represent (encode) a color, usually like a tuple of numbers (integers or reals).
Links:
* wikipedia:Color space
* wikipedia:RGB color model -- Red Green Blue
* wikipedia:SRGB color space
* wikipedia:CMYK color model -- Cyan Magenta Yellow Black
* wikipedia:HSV color space -- Hue Saturation Value
* wikipedia:HSL color space -- Hue Saturation Luminance
* wikipedia:CIE 1931 color space

#### File formats

Images are usually stored on disk using various formats such as BMP, PNG, TGA, JPEG, etc. Each of the formats has its own (compressed/uncompressed) way of representing the pixel data found in the image but in most of the cases it reduces itself to coding pixel data (number, color depth, color space) and other file/image related information.
Links:
* wikipedia:Image file formats
* wikipedia:Portable Network Graphics -- PNG
* wikipedia:BMP file format -- BMP
* wikipedia:Truevision TGA
* wikipedia:JPEG
* wikipedia:Image_file_formats#Vector_formats

## Graphics Processing Unit (GPU)

A dedicated rendering device either integrated within the motherboard or attached to a video card. Its purpose is to handle graphics specific operations. It incorporates several graphics primitive operations (2D/3D) which makes rendering much faster than when rendering directly on screen by using the CPU.
Links:
* wikipedia:Graphics processing unit

## Technologies
### OpenGL

OpenGL stands for Open Graphics Library;
* it was developed by Silicon Graphics in 1992;
* its present version is 3.0 and was released in August 11th 2008
* is a specification for cross-platform API (Application Programmable Interface);
* it describes a set of functions, their inputs and outputs, and the resulting behaviors;
* it is used for 2D or 3D graphics;
Among its purposes we can note:
* hide hardware interfacing details;
* provide an unified programmable interface;
* it provides a procedural paradigm scene description, meaning that the programmer has to describe all the steps that are required to render a scene -- thus being a low-level library;
** hardware manufactures design hardware to meet the feature requirements, meanwhile software implementors develop libraries that meet the standard functionality;
** it focuses only on rendering, and not on windowing, keyboard / mouse input, or network related issues;
*** as a result a number of utility libraries have been built on top of it:
**** GLU (OpenGL Utility Library ) : provides higher-level drawing routines than OpenGL
**** GLUT (OpenGL Utility Toolkit) : utilities which primarily perform system-level I/O with the host computer (window definition, window control, monitoring of keyboard and mouse input, limited support for creating pop-up menus, etc.)
**** GLUI (OpenGL User Interface Library) : based on GLUT it provides controls such as buttons, check-boxes, radio buttons, and spinners to OpenGL applications. It is platform independent
**** SDL (Simple DirectMedia Layer) : presents a simple interface to various platforms' graphics, sound, and input devices. It is platform independent
**** etc.
Links:
* wikipedia:OpenGL
* wikipedia:OpenGL Utility Library
* wikipedia:OpenGL Utility Toolkit
* wikipedia:Simple DirectMedia Layer
* wikipedia:Application programming interface

### DirectX

DirectX:
* was created by Microsoft and first released in 1995
* its present version is 11 and was released on February 4th 2009 (added multi-threading support, GPGPU support and tessellation support)
* it runs only on Microsoft platforms (Windows and Xbox)
* is a collection of different APIs, each focusing on a specific task
* is used mainly in game development, but also for CAD (Computer Aided Design)
* is not a standard specification, but a closed-source software
* is composed of:
** RT -- runtime -- needed to run an application using DirectX (usually it is bundled with application installation kits, but also ships with the operating system)
** SDK -- software development kit -- needed to develop an application using DirectX
* like OpenGL the developer describes the scene for each step -- immediate mode
* initially it included an implementation of the scene graph paradigm -- retained mode;
* its sub-APIs are:
** DirectDraw -- used for 2D graphics;
** Direct3D -- used for 3D graphics;
** XInput (former DirectInput in versions < 10)-- used for keyboard and mouse input;
** DirectPlay -- used for network / multi-play related tasks (in version 10 the dplay.dll was removed and replace by dplayx.dll);
** XACT (former DirectSound in versions < 10) and DirectMusic -- used to play or record sounds;
** DirectShow -- removed as of 2005 but backwards compatibility still present
Links:
* wikipedia:DirectX
* wikipedia:DirectDraw
* wikipedia:Direct3D
* wikipedia:DirectInput
* wikipedia:DirectPlay
* wikipedia:DirectSound
* wikipedia:DirectMusic
* wikipedia:DirectShow
* wikipedia:Software framework
* wikipedia:Software development kit
* wikipedia:Runtime

### Java 2D / Java 3D

Java 2D / Java 3D:
* Java 2D is an API for drawing 2D shapes
* Java 3D is an API for drawing 3D objects
* Java 3D runs on top of either OpenGL or DirectX
* is more than a wrapper by using a real OOP concepts
* Java 3D uses scene graph paradigm, but has also immediate mode
Links:
* wikipedia:Java 2D
* wikipedia:Java 3D
* wikipedia:Scene graph

### JOGL -- Java OpenGL

* its latest version is 1.1.1 and was released in May 22nd 2008
* is a wrapper for OpenGL, mirroring all the GL functions, thus retaining the same API feeling
* as OpenGL it does not include window related calls and there is no utility library for these tasks. Thus it relies an Java specific libraries (AWT, SWING) to create GUI based applications
* delegates calls to OpenGL using JNI (Java Native Call)
* since version 1.1.0 it provides full access to GL 2.0 features
* conversion between OpenGL code written in C, and OpenGL code written in Java is extremely easy, due to the direct mapping (naming) of GL functions
* since Java SE 6, Java 2D and Java OpenGL have become inter-operable -- allowing developers to mix code
Links:
* JOGL
* wikipedia:Java OpenGL
* wikipedia:Java Native Interface

### XNA

* was created by Microsoft and first released in 2004
* its latest version is 3.0 released in October 30th 2008
* it is based on .Net Framework;
* is comprised of a set of tools with a managed runtime environment which facilitate computer game
* it tries to remove the boilerplate code;
* it tries to allow developers to focus on game content and experience;
* it is usable from any .NET language (like C#);
Links:
* wikipedia:Microsoft XNA
* wikipedia:Boilerplate (text)

### X3D (former VRML)

* first appeared in 1994 as VRML (Virtual Reality Modeling Language). VRML97 dating back from 1997 is the last version of it. It is a standard file format for representing 3-dimensional interactive vector graphics designed for use on the Internet (WWW)
* it was re-engineered as X3D whose abstract specifications were approved in 2004. XML and ClassicVRML encodings were approved in 2005
* the current version of X3D is 3.2
* it has an XML based syntax
Links:
* wikipedia:VRML
* wikipedia:X3D
* Gabriel Iuhasz, iuhasz.gabriel@info.uvt.ro