CS 4204 Computer Graphics

Similar documents
Working with Callbacks

Input and Interaction

Lecture 4. Interaction / Graphical Devices. CS 354 Computer Graphics Sunday, January 20, 13

Lecture 11: Callbacks. CITS 3003 Graphics & Animation

Comp 410/510 Computer Graphics Spring Input & Interaction

Input, Interaction and Animation Week 2

Project Sketchpad. Ivan Sutherland (MIT 1963) established the basic interactive paradigm that characterizes interactive computer graphics:

Input and Interaction. Ed Angel Professor of Computer Science, Electrical and Computer Engineering, and Media Arts University of New Mexico

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

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

Input and Interaction. CS 537 Interactive Computer Graphics Prof. David E. Breen Department of Computer Science

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

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

CSCI 4620/8626. The 2D Viewing Pipeline

Today s class. Viewing transformation Menus Mandelbrot set and pixel drawing. Informationsteknologi

1 (Practice 1) Introduction to OpenGL

Lectures OpenGL Introduction

Lecture 4 of 41. Lab 1a: OpenGL Basics

Drawing and Coordinate Systems

Getting Started. Overview (1): Getting Started (1): Getting Started (2): Getting Started (3): COSC 4431/5331 Computer Graphics.

Advanced Computer Graphics (CS & SE )

GRAFIKA KOMPUTER. ~ M. Ali Fauzi

BOUNCING BALL IMRAN IHSAN ASSISTANT PROFESSOR

Computer Graphics (Basic OpenGL)

COMPUTER GRAPHICS LAB # 3

CS 4204 Computer Graphics

OpenGL Introduction Computer Graphics and Visualization

Drawing and Coordinate Systems

More on Coordinate Systems. Coordinate Systems (3) Coordinate Systems (2) Coordinate Systems (5) Coordinate Systems (4) 9/15/2011

Computer Graphics (CS 543) Lecture 2b: 2D Graphics Systems (Drawing Polylines, tiling, & Aspect Ratio)

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

Fundamental Types of Viewing

CS 432 Interactive Computer Graphics

Introduction to Computer Graphics with OpenGL/GLUT

Lecture 3 Advanced Computer Graphics (CS & SE )

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

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

Precept 2 Aleksey Boyko February 18, 2011

Basic Graphics Programming

OpenGL Tutorial. Ceng 477 Introduction to Computer Graphics

Interaction. CSCI 480 Computer Graphics Lecture 3

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

Working Style of Program

Using OpenGL with CUDA

Overview of Projections: From a 3D world to a 2D screen.

Viewing Transformation

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

Programming using OpenGL: A first Introduction

Computer Graphics 1 Computer Graphics 1

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

Computer Graphics. OpenGL

GL_COLOR_BUFFER_BIT, GL_PROJECTION, GL_MODELVIEW

Computer Graphics. Chapter 10 Three-Dimensional Viewing

Lecture 4 Advanced Computer Graphics (CS & SE )

OpenGL Transformations

RECITATION - 1. Ceng477 Fall

CS380: Computer Graphics Viewing Transformation. Sung-Eui Yoon ( 윤성의 ) Course URL:

Chapter 3: Modeling Transformation

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

Drawing Primitives. OpenGL basics

Introduction to OpenGL

Computer Graphics Course 2005

SOURCES AND URLS BIBLIOGRAPHY AND REFERENCES

Notes on Assignment. Notes on Assignment. Notes on Assignment. Notes on Assignment

Transformations (Rotations with Quaternions) October 24, 2005

Interaction Computer Graphics I Lecture 3

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

Computer Graphics. Downloaded from: LectureNotes 1 CSC-254

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

Lecture 4. Viewing, Projection and Viewport Transformations

Introduction to OpenGL

2/3/16. Interaction. Triangles (Clarification) Choice of Programming Language. Buffer Objects. The CPU-GPU bus. CSCI 420 Computer Graphics Lecture 3

Interaction. CSCI 420 Computer Graphics Lecture 3

C OMPUTER G RAPHICS Thursday

Basic Graphics Programming

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

蔡侑庭 (Yu-Ting Tsai) National Chiao Tung University, Taiwan. Prof. Wen-Chieh Lin s CG Slides OpenGL 2.1 Specification

1.2 Basic Graphics Programming

Announcements. Submitting Programs Upload source and executable(s) (Windows or Mac) to digital dropbox on Blackboard

OpenGL refresher. Advanced Computer Graphics 2012

Graphics Programming

Lecture 5: Viewing. CSE Computer Graphics (Fall 2010)

The Viewing Pipeline adaptation of Paul Bunn & Kerryn Hugo s notes

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

Transformation Pipeline

Computer Graphics (CS 4731) Lecture 11: Implementing Transformations. Prof Emmanuel Agu. Computer Science Dept. Worcester Polytechnic Institute (WPI)

Introduction to OpenGL

Imaging and 2D Transforms

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

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

3D Viewing. With acknowledge to: Ed Angel. Professor of Computer Science, Electrical and Computer Engineering, and Media Arts University of New Mexico

1 Transformations. Chapter 1. Transformations. Department of Computer Science and Engineering 1-1

2D and 3D Viewing Basics

Lecture 3. Understanding of OPenGL programming

OpenGL and X, Column 1: An OpenGL Toolkit

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

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

521493S Computer Graphics Exercise 1 (Chapters 1-3)

OPENGL TM AND X, COLUMN 1: AN OPENGL TOOLKIT

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

Transcription:

CS 4204 Computer Graphics GLUT (Continue) More Interactions Yong Cao Virginia Tech References: Interactive Computer Graphics, Fourth Edition, Ed Angle

Orthographical Projection Synthetic camera model View angle and view volume Clipping Aspect ratio Viewport mapping

Synthetic Camera Model projector p image plane projection of p center of projection

View angle

View volume

Orthographical projection Creating an orthographic view by moving the camera away from the projection plane.

Orthographical projection Orthographic projectors with projection plane z = 0. The default camera and an orthographic view volume.

Orthographical projection

Clipping (a) Objects before clipping. (b) Image after clipping.

Aspect-ratio (a) Viewing rectangle. (b) Display window.

A mapping to the viewport.

Reshaping the window We can reshape and resize the OpenGL display window by pulling the corner of the window What happens to the display? Must redraw from application Two possibilities Display part of world Display whole world but force to fit in new window Can alter aspect ratio

Reshape possibilities original reshaped

The Reshape callback glutreshapefunc(myreshape) void myreshape( int w, int h) Returns width and height of new window (in pixels) A redisplay is posted automatically at end of execution of the callback GLUT has a default reshape callback but you probably want to define your own The reshape callback is good place to put viewing functions because it is invoked when the window is first opened

Example Reshape (Demo) This reshape preserves shapes by making the viewport and world window have the same aspect ratio void myreshape(int w, int h) { glviewport(0, 0, w, h); glmatrixmode(gl_projection); /* switch matrix mode */ glloadidentity(); if (w <= h) gluortho2d(-2.0, 2.0, -2.0 * (GLfloat) h / (GLfloat) w, 2.0 * (GLfloat) h / (GLfloat) w); else gluortho2d(-2.0 * (GLfloat) w / (GLfloat) h, 2.0 * (GLfloat) w / (GLfloat) h, -2.0, 2.0); glmatrixmode(gl_modelview); /* return to modelview mode */ }

Toolkits and Widgets Most window systems provide a toolkit or library of functions for building user interfaces that use special types of windows called widgets Widget sets include tools such as Menus Slidebars Dials Input boxes But toolkits tend to be platform dependent GLUT provides a few widgets including menus

Menus GLUT supports pop-up menus A menu can have submenus Three steps Define entries for the menu Define action for each menu item Action carried out if entry selected Attach menu to a mouse button

Defining a simple menu In main.c menu_id = glutcreatemenu(mymenu); glutaddmenuentry( clear Screen, 1); gluaddmenuentry( exit, 2); glutattachmenu(glut_right_button); clear screen exit entries that appear when right button depressed identifiers

Menu actions Menu callback void mymenu(int id) { if(id == 1) glclear(); if(id == 2) exit(0); } Note each menu has an id that is returned when it is created entry in parent menu Add submenus by glutaddsubmenu(char *submenu_name, submenu id)

Other functions in GLUT Dynamic Windows Create and destroy during execution Multiple Windows (Demo) Changing callbacks during execution Timers void gluttimerfunc( unsigned int msecs,, void (*func)(int value), value); Portable fonts glutbitmapcharacter (See demo) glutstrokecharacter (See demo)