Announcements OpenGL. Computer Graphics. Autumn 2009 CS4815

Similar documents
Announcements OpenGL. Computer Graphics. Spring CS4815

Drawing Primitives. OpenGL basics

Duc Nguyen CSE 420 Computer Graphics 10/10/2018 Homework 1

COMPUTER GRAPHICS LAB # 3

Lecture 3. Understanding of OPenGL programming

by modifying the glutinitwindowsize() function you can change the screen size to whatever you please.

Assignment 1. Simple Graphics program using OpenGL

Programming using OpenGL: A first Introduction

Computer Graphics. Making Pictures. Computer Graphics CSC470 1

CS 432 Interactive Computer Graphics

CSE4030 Introduction to Computer Graphics

Lecture 2 CISC440/640 Spring Department of Computer and Information Science

GL_COLOR_BUFFER_BIT, GL_PROJECTION, GL_MODELVIEW

Teacher Assistant : Tamir Grossinger Reception hours: by - Building 37 / office -102 Assignments: 4 programing using

CS 543 Lecture 1 (Part II): Intro to OpenGL and GLUT (Part I) Emmanuel Agu

Graphics Programming

Lectures OpenGL Introduction

Using OpenGL with CUDA

Programming with OpenGL Part 2: Complete Programs Computer Graphics I, Fall

Graphics Programming. August 31, Programming of the Sierpinski gasket. Programming with OpenGL and C/C++

Introduction to OpenGL: Part 2

Introduction to MS Visual C/C++

Computer Graphics. OpenGL

Programming with OpenGL Part 3: Three Dimensions

Basic Graphics Programming

Bob s Concise Introduction to Doxygen

Abel J. P. Gomes LAB. 1. INTRODUCTION TO OpenGL

OpenGL JOGL. OpenGL & JOGL. Shaoting Zhang, or Tony. September 12, 2007

Computer Graphics, Chapt 08

Programming with OpenGL Part 1: Background

To Do. Computer Graphics (Fall 2008) Course Outline. Course Outline. Methodology for Lecture. Demo: Surreal (HW 3)

Overview of Graphics Systems Hearn & Baker Chapter 2. Some slides are taken from Robert Thomsons notes.

Early History of APIs. PHIGS and X. SGI and GL. Programming with OpenGL Part 1: Background. Objectives

CS559: Computer Graphics. Lecture 12: OpenGL Li Zhang Spring 2008

Programming with OpenGL Part 1: Background

CMSC 425: Lecture 4 More about OpenGL and GLUT Tuesday, Feb 5, 2013

Precept 2 Aleksey Boyko February 18, 2011

OpenGL Introduction Computer Graphics and Visualization

C++ is Fun Part 13 at Turbine/Warner Bros.! Russell Hanson

Computer Graphics (CS 543) Lecture 1 (Part 2): Introduction to OpenGL/GLUT (Part 1)

Introduction to Computer Graphics with OpenGL/GLUT

COS340A Assignment 1 I Pillemer Student# March 25 th 2007 p1/15

CS 4204 Computer Graphics

CS Computer Graphics: Intro to OpenGL

CS Computer Graphics: Intro to OpenGL

6. Make use of glviewport() to display two sine curves on the same screen, one on the

Introduction to OpenGL Week 1

Objectives. Image Formation Revisited. Physical Approaches. The Programmer s Interface. Practical Approach. Introduction to OpenGL Week 1

Computer Graphics (Basic OpenGL)

Computer Graphics (CS 4731) OpenGL/GLUT(Part 1)

3D computer graphics: geometric modeling of objects in the computer and rendering them

to OpenGL Introduction Pipeline Graphics pipeline OpenGL pipeline OpenGL syntax Modeling Arrays Conclusion 1 Introduction Introduction to OpenGL

Computer Graphics Course 2005

LECTURE 02 OPENGL API

PART-I: Lab for MCS-051 (Advanced Internet Technologies)

CS 4731 Lecture 3: Introduction to OpenGL and GLUT: Part II. Emmanuel Agu

CS380: Computer Graphics Basic OpenGL Structure. Sung-Eui Yoon ( 윤성의 ) Course URL:

Books, OpenGL, GLUT, GLUI, CUDA, OpenCL, OpenCV, PointClouds, and G3D

Computer Graphics. Bing-Yu Chen National Taiwan University

Cameras (and eye) Ideal Pinhole. Real Pinhole. Real + lens. Depth of field

OpenGL/GLUT Intro. Week 1, Fri Jan 12

Introduction to OpenGL


Graphics Programming. 1. The Sierpinski Gasket. Chapter 2. Introduction:

CS 543 Lecture 1 (Part 3) Prof Emmanuel Agu. Computer Science Dept. Worcester Polytechnic Institute (WPI)

Hierarchical Modeling: Tree of Transformations, Display Lists and Functions, Matrix and Attribute Stacks,

Books, OpenGL, GLUT, CUDA, OpenCL, OpenCV, PointClouds, G3D, and Qt

CS Computer Graphics: OpenGL, Continued

CS Computer Graphics: OpenGL, Continued

SOURCES AND URLS BIBLIOGRAPHY AND REFERENCES

// double buffering and RGB glutinitdisplaymode(glut_double GLUT_RGBA); // your own initializations

Display Lists in OpenGL

An Overview GLUT GLSL GLEW

Basic Graphics Programming

Comp 410/510 Computer Graphics Spring Programming with OpenGL Part 2: First Program

1.2 Basic Graphics Programming

CS418 OpenGL & GLUT Programming Tutorial (I) Presented by : Wei-Wen Feng 1/30/2008

OpenGL refresher. Advanced Computer Graphics 2012

... Print PROGRAMS\Final Project final\planes\planeshoot.c 1

CS559: Computer Graphics. Lecture 12: OpenGL Transformation Li Zhang Spring 2008

UNIT 7 LIGHTING AND SHADING. 1. Explain phong lighting model. Indicate the advantages and disadvantages. (Jun2012) 10M

Fourier Series. Given a periodic function, x(t), (-T <t <T): + b n sin n t T. a n cos n t T. 2 a 0 + Z T. a n = 1 T. x(t) cos n t T. b n = 1 T.

GLUT Tutorial. John Tsiombikas (Nuclear / The Lab Demos) May 6, Introduction to GLUT (OpenGL Utility Toolkit)

11/1/13. Basic Graphics Programming. Teaching Assistant. What is OpenGL. Course Producer. Where is OpenGL used. Graphics library (API)

Exercise 1 Introduction to OpenGL

Source code: #include <iostream>

Modeling Transform. Chapter 4 Geometric Transformations. Overview. Instancing. Specify transformation for objects 李同益

2. OpenGL -I. 2.1 What is OpenGL? Things OpenGL can do: -23-

Graphics Hardware and OpenGL

VR-programming tools (procedural) More VRML later in this course! (declarative)

Drawing and Coordinate Systems

Input and Interaction. 1. Interaction. Chapter 3. Introduction: - We now turn to the development of interactive graphics programs.

Computer graphics MN1

Ulf Assarsson Department of Computer Engineering Chalmers University of Technology

(21) OpenGL GUI. OpenGL GUI 1 UNIX MAGAZINE UNIX. SGI (Silicon Graphics Inc.) Windows PC GUI. UNIX Windows GUI. Java. 1 prefposition() X X

RECITATION - 1. Ceng477 Fall

Drawing and Coordinate Systems

C++ - OpenGL - Setting up Visual Studio

Computer Graphics 1 Computer Graphics 1

Computer Graphics: Line Drawing Algorithms

Transcription:

Computer Graphics Autumn 2009

Outline 1 Labs 2

Labs Outline 1 Labs 2

Labs Labs Week02 lab Marking 8 10 labs in total each lab worth 2 3% of overall grade marked on attendance and completion of lab completed lab generally required by end of week (but not this week s)

Outline 1 Labs 2

What is it? is a completely open graphics library that takes the headache out of graphics programming Hardware- and operating system-independent Initially developed by SGI (Silicon Graphics) Several implementations of exist Several tutorials, HOWTOs exist examples site

Outline 1 Labs 2

hierarchy program.cc Source code (C++, C, Python, etc.) OS specific interface GL Utility Toolkit (glutfuncx()) GL Utility (glufuncx()) Complex manipulations Device independent only GL core (glfuncx()) Basic drawing primitives

hierarchy Documentation gl and glu function documentation is here glut documentation is here

Outline 1 Labs 2

A First Program For the program that follows (called try.cc) the following command compiles: g++ try.cc -l glut -o try

A First Program (contd.) int main (int argc, char ** argv) { glutinit(&argc, argv); glutinitdisplaymode(glut_single GLUT_RGB); glutinitwindowposition(50, 100); glutinitwindowsize(400, 300); glutcreatewindow("an example"); init(); // we will write this } glutdisplayfunc(linesegmentgreen); glutmainloop(); // and this

A First Program (contd.) int main (int argc, char ** argv) { glutinit(&argc, argv); glutinitdisplaymode(glut_single GLUT_RGB); glutinitwindowposition(50, 100); glutinitwindowsize(400, 300); glutcreatewindow("an example"); init(); // we will write this } glutdisplayfunc(linesegmentgreen); glutmainloop(); // and this

A First Program (contd.) int main (int argc, char ** argv) { glutinit(&argc, argv); glutinitdisplaymode(glut_single GLUT_RGB); glutinitwindowposition(50, 100); glutinitwindowsize(400, 300); glutcreatewindow("an example"); init(); // we will write this } glutdisplayfunc(linesegmentgreen); glutmainloop(); // and this

Top part of program: init() #include <GL/glut.h> // ==> gl.h and glu.h void init (void) { glclearcolor(1.0, 1.0, 1.0, 0.0); } glmatrixmode(gl_projection); gluortho2d(0.0, 200.0, 0.0, 150.0);

Explanation glclearcolor(1.0, 1.0, 1.0, 0.0); sets background colour to white (R=G=B=1.0), with colour blending set to 0.0 (transparent) glmatrixmode(gl_projection); use the matrix stack concerned with projecting images onto screen gluortho2d(0.0, 200.0, 0.0, 150.0); only worry about coordinates in the range of (0,0) (200,150)

Final part of program: linesegmentgreen() void linesegmentgreen (void) { glclear(gl_color_buffer_bit); glcolor3f(0.0, 1.0, 0.0); glbegin(gl_lines); glvertex2i(15, 180); glvertex2i(145, 10); glend(); } glflush();

Explanation glutdisplayfunc(linesegmentgreen); fn. to call whenever screen needs to be redisplayed glutmainloop(); loops forever listening for interesting events GLUT_SINGLE is a defined constant (see glut.h) glclear(gl_color_buffer_bit); clears color buffer by coloring all pixels with color of glclearcolor glcolor3f(0.0, 1.0, 0.0); sets pen colour glbegin(gl_lines); glvertex2i(15, 180); glvertex2i(145, 10); glend(); glflush(); draw the picture now

Outline 1 Labs 2

Program to draw lines of HI Default view coordinates go from -1.0 to 1.0 in both X and Y That is, lower left corner is (-1.0, -1.0) and upper right corner is (1.0, 1.0) The X axis is horizontal and the Y axis is vertical. gcc hi.c -l glut -o AllSayHi Program will respond to q from keyboard

main() int main (int argc, char** argv) { glutinit(&argc, argv); // initialize glut glutinitdisplaymode(glut_rgb GLUT_SINGLE); glutinitwindowsize(400,400); // window width, heig glutinitwindowposition(0,0); // x, y of top left c glutcreatewindow(argv[0]); // create window, with glutdisplayfunc(display); // display callback glutkeyboardfunc(quit); // keyboard callback glutmainloop(); // hand over control t } return 0;

quit() // input keyboard function to quit with q or Q. void quit(unsigned char key, int x, int y) { if (key == q key == Q ) exit(0); }

Callback function display() #include <GL/glut.h> void display() // display callback function { glclear(gl_color_buffer_bit); // clear the window gllinewidth(4.0); // set line width, in pixels // default view coordinates go from -1.0 // to 1.0 in both X and Y.

display() (contd.) // Draw H, comprising three lines glbegin(gl_lines); // begin a geometric primitive glcolor3f(1.0, 1.0, 1.0); // set color to white glvertex2f(-0.8, -0.6); // left glvertex2f(-0.8, 0.6); // upright glvertex2f(-0.2, 0.6); // right glvertex2f(-0.2, -0.6);// upright glvertex2f(-0.8, 0.0); // line 3: start... glvertex2f(-0.2, 0.0); //... and end glend();

display() (contd.) // Draw H, comprising three lines glbegin(gl_lines); // begin a geometric primitive glcolor3f(1.0, 1.0, 1.0); // set color to white glvertex2f(-0.8, -0.6); // left glvertex2f(-0.8, 0.6); // upright glvertex2f(-0.2, 0.6); // right glvertex2f(-0.2, -0.6);// upright glvertex2f(-0.8, 0.0); // line 3: start... glvertex2f(-0.2, 0.0); //... and end glend();

display() (contd.) // Draw H, comprising three lines glbegin(gl_lines); // begin a geometric primitive glcolor3f(1.0, 1.0, 1.0); // set color to white glvertex2f(-0.8, -0.6); // left glvertex2f(-0.8, 0.6); // upright glvertex2f(-0.2, 0.6); // right glvertex2f(-0.2, -0.6);// upright glvertex2f(-0.8, 0.0); // line 3: start... glvertex2f(-0.2, 0.0); //... and end glend();

display() (contd.) // Draw H, comprising three lines glbegin(gl_lines); // begin a geometric primitive glcolor3f(1.0, 1.0, 1.0); // set color to white glvertex2f(-0.8, -0.6); // left glvertex2f(-0.8, 0.6); // upright glvertex2f(-0.2, 0.6); // right glvertex2f(-0.2, -0.6);// upright glvertex2f(-0.8, 0.0); // line 3: start... glvertex2f(-0.2, 0.0); //... and end glend();

display() (contd.) // Draw H, comprising three lines glbegin(gl_lines); // begin a geometric primitive glcolor3f(1.0, 1.0, 1.0); // set color to white glvertex2f(-0.8, -0.6); // left glvertex2f(-0.8, 0.6); // upright glvertex2f(-0.2, 0.6); // right glvertex2f(-0.2, -0.6);// upright glvertex2f(-0.8, 0.0); // line 3: start... glvertex2f(-0.2, 0.0); //... and end glend();

display() (contd.) // Draw I, comprising three different lines glbegin(gl_lines); glcolor3f(1.0, 0.0, 0.0); // set color to red glvertex2f(0.5, -0.6); glvertex2f(0.5, 0.6); glvertex2f(0.3, 0.6); glvertex2f(0.7, 0.6); glvertex2f(0.3, -0.6); glvertex2f(0.7, -0.6); glend(); } glflush();