CSC Graphics Programming

Slides:



Advertisements
Similar presentations
Introduction to OpenGL
Advertisements

2IV60 Computer graphics Graphics primitives and attributes Jack van Wijk TU/e.
Informationsteknologi Monday, October 29, 2007Computer Graphics - Class 21 Today’s class Graphics programming Color.
OpenGL (Graphics Library) Software Interface to graphics software Allows to create interactive programs that produce color images of moving 3D objects.
What is OpenGL The OpenGL graphics system is a software interface to graphics hardware. (The GL stands for Graphics Library.) It allows you to create interactive.
Drawing Geometric Objects
1 Angel: Interactive Computer Graphics 4E © Addison-Wesley 2005 Programming with OpenGL Part 2: Complete Programs Ed Angel Professor of Computer Science,
1 Lecture 4 Graphical primitives Rasterization: algorithmic approach Rasterization: geometric approach 2D discrete lines, triangles Discrete planes 3D.
OpenGL and WebGL Drawing Functions CSCI 440 Day Five.
CSC 461: Lecture 6 1 CSC461 Lecture 6: 2D Programming in OpenGL Objectives:  Fundamental OpenGL primitives  Attributes  Viewport.
Computer Graphics CS 385 February 7, Fundamentals of OpenGl and Glut Today we will go through the basics of a minimal OpenGl Glut project, explaining.
Curso: Graficación Prof. Gueorgi Khatchatourov
OpenGL Programming Guide (Red Book) State Management and Drawing Geometric Objects 고려대학교 그래픽스 연구실 강 신 진.
Reference1. [OpenGL course slides by Rasmus Stenholt]
CS380 LAB I OpenGL Donghyuk Kim Reference1. [OpenGL course slides by Rasmus Stenholt] Reference2. [
JOGL in MS Windows GDI – Graphics Device Interface (Windows-specific) OpenGL Lib JOGL Commands GDI Processor Graphics Hardware JOGL Lib.
COS 397 Computer Graphics Assoc. Prof. Svetla Boytcheva AUBG 2013 COS 397 Computer Graphics Practical Session №1 Introduction to OpenGL, GLFW and CG.
1 GLUT Callback functions Event-driven: Programs that use windows  Input/Output  Wait until an event happens and then execute some pre-defined functions.
Using OpenGL. 2 What is OpenGL? A software interface to graphics hardware It is a Graphics Rendering API (Application Programmer’s Interface) that is.
Drawing Basic Graphics Primitives Lecture 4 Wed, Sep 3, 2003.
Open GL Programming Speaker: 彭任右 Date: 2005/10/3.
2 COEN Computer Graphics I Introductions n Brad Grantham lecturer lab dude n Dave Shreiner lecturer slave driver.
Interactive Computer Graphics Lecture 2: The programming approach to building graphical applications using OpenGL API.
Computer Graphics CS 385 January 31, Fractals Some definitions Object which is self-similar at all scales. Regardless of scale the same level of.
State Management and Drawing Geometry Objects
1. OpenGL/GLU/GLUT  OpenGL v4.0 (latest) is the “core” library that is platform independent  GLUT v3.7 is an auxiliary library that handles window creation,
P RACTICING O PEN GL- P RIMITIVES. O PEN GL O UTPUT P RIMITIVES  Each geometric object is described by a set of vertices and the type of primitive to.
Introduction to OpenGL  OpenGL is a graphics API  Software library  Layer between programmer and graphics hardware (and software)  OpenGL can fit in.
Computer Graphics Bing-Yu Chen National Taiwan University.
Intro to OpenGL: Vertices and Drawing
UniS CS297 Graphics with Java and OpenGL State Management and Drawing Primative Geometric Objects.
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
NoufNaief.net 1 TA: Nouf Al-Harbi.
Graphics: Conceptual Model
What are Computer Graphics Basically anything that is on you Monitor – This includes the text that you will see Text isn’t Advanced Graphics But…. Understanding.
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.
1 E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley 2012 Programming with OpenGL Part 4: Color and Attributes Isaac Gang University.
1 Perception, Illusion and VR HNRS 299, Spring 2008 Lecture 15 Creating 3D Models.
31/1/2006Based on: Angel (4th Edition) & Akeine-Möller & Haines (2nd Edition)1 CSC345: Advanced Graphics & Virtual Environments Lecture 2: Introduction.
OpenGL: Introduction #include main() { OpenWindow() ; glClearColor(0.0, 0.0, 0.0, 0.0); glClear(GL_COLOR_BUFFER_BIT); glOrtho(-1.0, 1.0, -1.0, 1.0, -1.0,
2002 by Jim X. Chen: Drawing Geometric Models.1. Objectives –OpenGL drawing primitives and attributes –OpenGL polygon face.
CIS 681 Review: OpenGL. CIS 681 Command Syntax OpenGL commands start with a gl. This is followed by the base command such as Color. Followed by the number.
Computer Graphics I, Fall Programming with OpenGL Part 2: Complete Programs.
Computer Graphics (Fall 2003) COMS 4160, Lecture 5: OpenGL 1 Ravi Ramamoorthi Many slides courtesy Greg Humphreys.
Computer Graphics Lecture 34. OpenGL Programming II Taqdees A. Siddiqi
OpenGL Programming Guide Chapter 2 Korea Univ. Graphics Labs. Ji Jun Yong Korea Univ. Graphics Labs. Ji Jun Yong.
Program Studi S-1 Teknik Informatika FMIPA Universitas Padjadjaran
The Human Visual System vs The Pinhole camera
CS380 Lab Spring Myungbae Son.
State Management and Drawing Geometric Objects
State Management and Drawing Geometric Objects
Programming with OpenGL Part 2: Complete Programs
Materi Anatomi OpenGL Fungsi GLUT Posisi Kamera Proyeksi
OpenGL API 2D Graphic Primitives
Programming with OpenGL Part 2: Complete Programs
OpenGL (Open Graphics Library) Mr. B.A.Swamy Assistant Professor Dept of CSE.
Lab 3 Geometric Drawing Lab 3 Geometric Drawing.
Objectives OpenGL drawing primitives and attributes
Starting to draw dealing with Windows which libraries? clipping
Introduction to Computer Graphics with WebGL
Programming with OpenGL Part 4: Color and Attributes
Drawing in the plane 455.
Programming with OpenGL Part 2: Complete Programs
Programming with OpenGL Part 2: Complete Programs
Starting to draw dealing with Windows which libraries? clipping
Programming with OpenGL Part 4: Color and Attributes
Programming with OpenGL Part 2: Complete Programs
Introduction to OpenGL Programming
Presentation transcript:

CSC 307 1.0 Graphics Programming Budditha Hettige Department of Statistics and Computer Science

Graphics Programming 2D Drawing 03 Graphics Programming 2D Drawing

Primitive Types GL_POINTS GL_LINES GL_TRIANGLES GL_TRIANGLE_STRIP GL_QUAD_STRIP GL_LINE_STRIP GL_LINE_LOOP GL_QUADS GL_POLYGON GL_TRIANGLE_FAN

Points point is represented by a set of floating-point numbers called a vertex glBegin(GL_POINTS); glVertex2f(0.0, 0.0); glVertex2f(0.0, 3.0); glVertex2f(4.0, 3.0); glVertex2f(6.0, 1.5); glVertex2f(4.0, 0.0); glEnd();

Lines (GL_LINES) Pairs of vertices interpreted as individual line segments

Lines (GL_LINE_STRIP) Series of connected line segments

Lines (GL_LINE_LOOP) Same as GL_LINE_STRIP, with a segment added between last and first vertices

Line Details Specify lines with different widths and lines void glLineWidth(GLfloat width); Stippled Lines void glLineStipple(GLint factor, GLushort pattern); glEnable(GL_LINE_STIPPLE);

Example glEnable(GL_LINE_STIPPLE); glLineStipple(1, 0x0101); /* dotted */ glLineStipple(1, 0x00FF); /* dashed */ glLineStipple(1, 0x1C47); /* dash/dot/dash */ glLineStipple(1, 0x0101); glBegin(GL_LINE_LOOP); glVertex2f(-0.5, -0.5); glVertex2f(-0.5, 0.5); glVertex2f(0.5, 0.5); glVertex2f(0.5, -0.5); glEnd();

Triangles (GL_TRIANGLES) Triples of vertices interpreted as triangles

OpenGL 2D-Drawing glBegin(GL_TRIANGLES); glEnd(); glVertex2f(-0.20f, 0.0f); glVertex2f(0.20f, 0.0f); glVertex2f(0.0f, 0.40f); glVertex2f(-0.60f,-0.20f); glVertex2f(-0.20f,-0.40f); glVertex2f(0.0f, -0.80f); glVertex2f(0.20f, -0.40f); glVertex2f(0.60f, -0.20f); glEnd();

Triangles (GL_TRIANGLE_STRIP) Linked strip of triangles

Triangles (GL_TRIANGLE_FAN) Linked fan of triangles

Quad-(GL_QUADS) Quadruples of vertices interpreted as four-sided polygons

Quads (GL_QUAD_STRIP) Linked strip of quadrilaterals

Polygon (GL_POLYGON) Boundary of a simple, convex polygon

Polygon Details Points, Outlines, or Solids void glPolygonMode(GLenum face, GLenum mode); Face GL_FRONT_AND_BACK, GL_FRONT, or GL_BACK Mode GL_POINT, GL_LINE, or GL_FILL

Stippling Polygons Example filled polygons are drawn with a solid pattern void glPolygonStipple(const GLubyte *mask); Example Polygons.cpp glEnable(GL_POLYGON_STIPPLE); glPolygonStipple(fly); glRectf(125.0, 25.0, 225.0, 125.0); GLubyte fly[] = { 0x00, 0x00, 0x00, 0x00, 0x00,... };

OpenGL 2D-Drawing void display(void) { glClear (GL_COLOR_BUFFER_BIT); glColor3f (1.0, 0.0, 0.0); // red glBegin(GL_POLYGON); glVertex2f(-0.20f, 0.50f); glVertex2f(0.20f, 0.50f); glVertex2f(0.50f, 0.20f); glVertex2f(0.50f, -0.20f); glColor3f (0.0, 0.0, 1.0); // blue glVertex2f(0.20f, -0.50f); glVertex2f(-0.20f, -0.50f); glVertex2f(-0.50f, -0.20f); glVertex2f(-0.50f, 0.20f); glEnd(); glFlush (); }

RGB Color Space G R B Green (1,0,0) Yellow (1,1,0) White (1,1,1) Cyan Image: Pixel maps to color Green (1,0,0) Yellow (1,1,0) White (1,1,1) Cyan (0,1,1) Red (1,0,0) R Blk Blue (0,0,1) Magenta (1,0,1) B

Common Composite Colors

Colors glColor3f(1.0, 0.0, 0.0); The current RGB color is red: full red, no green, no blue. RGB Display Modes

Specifying a Color and a Shading Model RGBA mode, use the glColor*() command to select a current color. void glColor3{b s i f d ub us ui}(TYPE r, TYPE g, TYPE b); void glColor4{b s i f d ub us ui}(TYPE r, TYPE g, TYPE b, TYPE a); void glColor3{b s i f d ub us ui}v(const TYPE *v); void glColor4{b s i f d ub us ui}v(const TYPE *v);

Specifying a Shading Model single color (flat shading) many different colors (smooth shading, also called Gouraud shading) void glShadeModel(GLenum mode); GL_SMOOTH (the default) or GL_FLAT. glShadeModel(GL_SMOOTH); Example: Shading.cpp