Assignment 1. Simple Graphics program using OpenGL

Similar documents
Computer Graphics. Making Pictures. Computer Graphics CSC470 1

COMPUTER GRAPHICS LAB # 3

Drawing Primitives. OpenGL basics

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

Programming using OpenGL: A first Introduction

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

Computer Graphics. OpenGL

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

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

Announcements OpenGL. Computer Graphics. Autumn 2009 CS4815

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

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

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

Announcements OpenGL. Computer Graphics. Spring CS4815

Lecture 3. Understanding of OPenGL programming

Computer Graphics, Chapt 08

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

CS Computer Graphics: OpenGL, Continued

CS Computer Graphics: OpenGL, Continued

CSC 8470 Computer Graphics. What is Computer Graphics?

Introduction to Computer Graphics with OpenGL/GLUT

Computer Graphics: Line Drawing Algorithms

Programming with OpenGL Part 1: Background

CS 4204 Computer Graphics

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

Graphics Programming

Introduction to OpenGL Week 1

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

CSE4030 Introduction to Computer Graphics

COMP 371/4 Computer Graphics Week 1

Luiz Fernando Martha André Pereira

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

Computer Graphics (Basic OpenGL)

GL_COLOR_BUFFER_BIT, GL_PROJECTION, GL_MODELVIEW

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

Precept 2 Aleksey Boyko February 18, 2011

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

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

ERKELEY DAVIS IRVINE LOS ANGELES RIVERSIDE SAN DIEGO SAN FRANCISCO EECS 104. Fundamentals of Computer Graphics. OpenGL

RECITATION - 1. Ceng477 Fall

Basic Graphics Programming

Andrew Yenalavitch Homework 1 CSE Fall 2014

Draw the basic Geometry Objects. Hanyang University

CSC Graphics Programming. Budditha Hettige Department of Statistics and Computer Science

Lecture 4 of 41. Lab 1a: OpenGL Basics

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

OpenGL refresher. Advanced Computer Graphics 2012

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

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

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

Computer Graphics. Bing-Yu Chen National Taiwan University

Lectures OpenGL Introduction

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

OpenGL Introduction Computer Graphics and Visualization

Computer Graphics Introduction to OpenGL

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

Programming with OpenGL Part 3: Three Dimensions

Computer Graphics 1 Computer Graphics 1

Lecture 3 Advanced Computer Graphics (CS & SE )

CS621 Lab 1 Name: Ihab Zbib

Introduction to OpenGL: Part 2

Programming of Graphics

Using OpenGL with CUDA

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

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

Computer Graphics Primitive Attributes

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

Bob s Concise Introduction to Doxygen

Basic Graphics Programming

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

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

Computer Graphics Anatomy of GUI. Computer Graphics CSC470 1

Introduction to MS Visual C/C++

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

Windows and Viewports. Windows and Viewports. Windows and Viewports. Windows and Viewports. CSC 706 Computer Graphics

Computer Graphics (4731) Lecture 4: 2D Graphics Systems (Drawing Polylines, tiling, & Aspect Ratio)

Announcement. Homework 1 has been posted in dropbox and course website. Due: 1:15 pm, Monday, September 12

void drawdot(glint x, GLint y) { glbegin(gl_points); glvertex2i(x,y); glend();

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

API for creating a display window and using keyboard/mouse interations. See RayWindow.cpp to see how these are used for Assignment3

Graphics and Visualization

Chapter 13 Selection and Feedback

Programming with OpenGL Part 1: Background

2D Drawing Primitives

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

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

Computer graphic -- Programming with OpenGL I

Computer Graphics Course 2005

OpenGL. Jimmy Johansson Norrköping Visualization and Interaction Studio Linköping University

Computer Graphics. Chapter 3 Computer Graphics Software

Rendering. Part 1 An introduction to OpenGL

This library uses only GL functions but contains code for creating common objects and simplifying viewing.

Graphics Hardware and OpenGL

Drawing and Coordinate Systems

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

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

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

1.2 Basic Graphics Programming

Display Lists in OpenGL

C OMPUTER G RAPHICS Thursday

Transcription:

Assignment 1 Simple Graphics program using OpenGL In this assignment we will use basic OpenGL functions to draw some basic graphical figures. Example: Consider following program to draw a point on screen. #include <math.h> #include <stdio.h> #include <GL/gl.h> #include <GL/glu.h> #include <GL/glut.h> void myinit(void) { glclearcolor(1.0,1.0,1.0,0.0); glcolor3f(0.0, 0.0f, 0.0f); glpointsize(4.0); glmatrixmode(gl_projection); glloadidentity(); gluortho2d(0.0, 640.0, 0.0, 480.0); } void mydisplay(void) {int i; glclear(gl_color_buffer_bit); glbegin(gl_points); glvertex2i(40,40); glend(); glflush(); } void main(int argc, char **argv) { glutinit(&argc, argv); glutinitdisplaymode(glut_single GLU T_RGB); glutinitwindowsize(640,480); glutinitwindowposition(350,350); glutcreatewindow("my First Attempt")e glutdisplayfunc(mydisplay); myinit(); glutmainloop(); } The compilation and execution procedure is as follows $cc first.c -lglu -lglut -lgl -o first $./first Functions used: 1. glclearcolor(1.0,1.0,1.0,0.0); set the background color to bright white, 0.0 indicates no transparency 2. glcolor3f(0.0, 0.0,0.0); // set the color to black 3. glpointsize(4.0);//set the point size to 4 by 4 pixels 4. glmatrixmode(gl_projection); //set up the co-ordinate system 5. glclear(gl_color_buffer_bit); //clear the entire window to background color 6. glbegin and glend are used to delimit the vertices of a primitive operation. single argument to glbegin specifies the mode in which the vertices are to be interpreted. a. GL_POINTS treats each vertex as a single point b. GL_LINES treats each pair of vertices as an independent line segment

c. GL_LINE_STRIP draws a connected group of line segments d. GL_LINE_LOOP draws a connected group from first to last e. The other possibilities are - GL_TRIANGLES, GL_TRIANGLE_SRIP, GL_TRIANGLE_FAN, GL_QUADS, GL_QUAD_STRIP, GL_POLYGON 7. glvertex2i(40,40); // plot the point with two integer arguments 8. glend() has no arguments. 9. glflush(); //the entire data is to be processed and sent for display. 1. Write OpenGL program to draw X & Y axes system. 2. Write OpenGL program to draw basic house shape. 3. Display random 50 points (4x4 pixel size) with random colours (use rand() function. Create the following graphics using simple graphics primitives, a) Divide the screen area with four quadrants and divide each axis into intervals of size 10. b) Write OpenGL program to draw star shapes at random positions and fill them with random colours. c) Display a grid along with axis that divides the entire area into 50 by 50 size boxes. The grid should be in light green colour. d) Display a picture containing a two storied house e) Display sine/cosine function

Assignment 2 Using graphics primitives to display graphics Implement any one of the following primitive algorithms a) Implement Bresenham line drawing algorithm b) Implement Bresenham circle drawing algorithm Write a program to draw a scene. Program should use graphics primitives to draw objects. Program should have routines to create complex objects using graphics primitives. These routines should be invoked to create the final scene.

Assignment 3 Window to viewport transformations and other transformations Implement basic transformations as functions and apply these transformations on basic objects (triangle, square) and display the transformed objects a) Translation b) Rotation about the origin/pivot point c) Scaling about the origin/ fixed point d) Reflection about x-axis/ y-axis/ line y=x e) Sheer along x-axis/y-axis Implement following clipping algorithms as functions and apply these functions on some polygons, a) Sutherland Hodgman algorithm b) Weiler-Atherton Algorithm

Assignment 4 Using simple Keyboard and Mouse interaction 1. Write OpenGL program to draw points at positions clicked by mouse. 2. Accept names of ten different colours from user and draw star shapes with those colours using OpenGL. 1. Create dancing human figure using OpenGL.

Graphics mini-project Guidelines The project is to be carried out with a team size of Two or Three. The graphics mini project should solve a small problem completely or a larger problem partially. There should be use of display graphics using Open GL primitives. Some of the Project ideas are given below. 1. Write a program to read data from a file and displays the picture. Generate few such interesting files. You can design your own file format. For example if your picture contains only polylines then the only entry on first line of the file will specify number of polylines. This will be followed by line entries for each polyline. The first line entry will indicate number of points in the polyline followed by coordinates of each point on the polyline in successive line entries. You can generalize the file format to include the other primitive types, colour values etc. 2. Write a program that generates a Maze of R rows and C columns and find and display the path from start to end. 3. Write a program that creates tiles that is a square window with some interesting geometrical pattern /motif onto it. Produce tiling of the display screen by placing tiles all over the screen. 4. Write functions to draw scatter plot, bar chart, line chart and pie chart for a given set of data points as input or in a file. Write a program that can demonstrate these functions. 5. Write functions to draw some basic objects. Write scaling transformations so that picture can be enlarged to large size or compressed to smaller size. Accept an integer argument, the object type, the size(low, medium, large) and colour codes (RGB) as input and display n objects of the given size and colour in a line.