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

Similar documents
Introduction to Computer Graphics with OpenGL/GLUT

Programming using OpenGL: A first Introduction

COMPUTER GRAPHICS LAB # 3

Graphics Programming

Computer Graphics. OpenGL

Assignment 1. Simple Graphics program using OpenGL

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

Computer Graphics. Making Pictures. Computer Graphics CSC470 1

Computer Graphics. Bing-Yu Chen National Taiwan University

Drawing Primitives. OpenGL basics

GL_COLOR_BUFFER_BIT, GL_PROJECTION, GL_MODELVIEW

Programming with OpenGL Part 1: Background

Introduction to OpenGL Week 1

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

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

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

RECITATION - 1. Ceng477 Fall

Basic Graphics Programming

Programming with OpenGL Part 1: Background

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

Draw the basic Geometry Objects. Hanyang University

Computer Graphics Course 2005

Lectures OpenGL Introduction

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

Announcements OpenGL. Computer Graphics. Autumn 2009 CS4815

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

Precept 2 Aleksey Boyko February 18, 2011

CS Computer Graphics: OpenGL, Continued

CS Computer Graphics: OpenGL, Continued

Announcements OpenGL. Computer Graphics. Spring CS4815

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

CS 4204 Computer Graphics

COMP 371/4 Computer Graphics Week 1

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

CSE4030 Introduction to Computer Graphics

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

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

Computer graphics MN1

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

Computer Graphics Primitive Attributes

Computer Graphics Introduction to OpenGL

CS Computer Graphics: Intro to OpenGL

CS Computer Graphics: Intro to OpenGL

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

Computer Graphics (Basic OpenGL)

Programming of Graphics

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

Lecture 3. Understanding of OPenGL programming

Lecture 4 of 41. Lab 1a: OpenGL Basics

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

OpenGL refresher. Advanced Computer Graphics 2012

Lecture 3 Advanced Computer Graphics (CS & SE )

Using OpenGL with CUDA

Programming with OpenGL Part 3: Three Dimensions

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

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

LECTURE 02 OPENGL API

CS 432 Interactive Computer Graphics

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

OpenGL/GLUT Intro. Week 1, Fri Jan 12

OpenGL Introduction Computer Graphics and Visualization


Introduction to OpenGL

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

Lecture 2 2D transformations Introduction to OpenGL

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

GLUT. What is OpenGL? Introduction to OpenGL and GLUT

Basic Graphics Programming

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 Transformation Li Zhang Spring 2008

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

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

OpenGL Basics I. Seoul National University Graphics & Media Lab

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

Computer Graphics 1 Computer Graphics 1

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

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

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

Computer Graphics: Line Drawing Algorithms

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

Introduction to OpenGL

Display Lists in OpenGL

Bob s Concise Introduction to Doxygen

Introduction to OpenGL: Part 2

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

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

API Background. Prof. George Wolberg Dept. of Computer Science City College of New York

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

Today s Agenda. Basic design of a graphics system. Introduction to OpenGL

Rendering. Part 1 An introduction to OpenGL

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

CSC 8470 Computer Graphics. What is Computer Graphics?

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

C OMPUTER G RAPHICS Thursday

Computer Graphics, Chapt 08

1.2 Basic Graphics Programming

OpenGL Tutorial. Ceng 477 Introduction to Computer Graphics

Information Coding / Computer Graphics, ISY, LiTH. OpenGL! ! where it fits!! what it contains!! how you work with it 11(40)

Computer Graphics Introduction to OpenGL

An Overview GLUT GLSL GLEW

Transcription:

Teacher Assistant : Tamir Grossinger email: tamirgr@gmail.com Reception hours: by email - Building 37 / office -102 Assignments: 4 programing using C++ 1 theoretical You can find everything you need in the red book:opengl programing guide 2

C++ is regarded as an intermediate-level programing language C++ has object oriented features C++ has directed access to the memory and has no garbage collector C++ has very good performance compare to other high level programing languages 3

is NOT: - A programming language (as we study it) - Windows API(access files, etc ) is: - A 3D graphics and modeling library - Cross Platform - highly portable and very fast - Application programming Interface (API) - Defining more than 250 commands 4

OpenGL Utility Library (GLU) - A set of utility functions that perform common (but sometimes complex) tasks. OpenGL Utility Toolkit (GLUT) - Provides functionality common to all window systems Open a window Get input from mouse and keyboard Menus Event-driven - Very basic GUI 5

6

Mathematically intensive stage The image is displayed on your screen Where texture and vertex data is stored Creates the color image from the geometric, color and texture data 7

OpenGL commands use gl prefix GLU commands use glu prefix GLUT commands use glut prefix 8

Coordinates glvertex( ) - Usually float - No restriction on the values range - Vectors glnormal(..) Color glcolor( ) - Usually float - Values of Red, Green and Blue - Range 0.0 to 1.0 0.0f 3.0f 0.0f 0.0f 0.0f 0.0f 3.0f 0.0f 0.0f R G B 9

10

glbegin() represents the beginning of vertices definition glend() represents the end of the definition glvertex() - is used within the definition block - has no influence out of this block Basic types of shapes: - GL_POINTS draw isolated points - GL_LINES draw lines - GL_TRIANGLES triangles - GL_QUADS squares. - And many more. 11

glbegin(glenum mode) sets the type of primitive OpenGL will interpret the next vertices list: 12

glbegin(gl_points) V0 V1 V2 V3 V4 V5 V6 V7 glend() Point size? 13

glbegin(gl_lines) V0 V1 V2 V3 V4 V5 V6 V7 glend() Line size? 14

glbegin(gl_line_loop) V0 V1 V2 V3 V4 V5 V6 V7 glend() Polygon? 15

glbegin(gl_triangles) V0 V1 V2 V3 V4 V5 V6 V7 glend() 16

glbegin(gl_polygon) V0 V1 V2 V3 V4 V5 V6 V7 glend() 17

glbegin(gl_quads) V0 V1 V2 V3 V4 V5 V6 V7 glend() 18

Rarely would the clipping area dimensions match the window s dimensions The coordinate system must be mapped glviewport maps between logical Cartesian coordinates and physical screen pixel coordinates When we change window s dimensions OpenGL calculate again image size and fit it to the window glviewport (GLint x, GLint y, GLsizei width, GLsizei height ); 19

Most OpenGL programs have a similar structure that consists of the following functions - Main(): defines the callback functions opens one or more windows with the required properties enters event loop (last executable statement) - Init ( ): sets the state variables Viewing Attributes - Callbacks Display function mydisplay( ) Input and window functions 20

glutinit allows application to get command line arguments and initializes system glutinitdisplaymode requests properties for the window - RGB color - Single buffering glutinitwindowsize in pixels glutcreatewindow create window with title simple glutdisplayfunc display callback glutmainloop enter infinite event loop 21

#include glut.h int main(int argc, char** argv) { glutinit (& argc, argv) ; glutinitdisplaymode (GLUT_SINGLE) ; glutinitwindowsize ( 500,500) ; glutcreatewindow( Simple ) ; glutdisplayfunc(mydisplay) ; } init () ; glutmainloop () ; 22

Void init ( ) { glclearcolor(0.0, 0.0, 0.0, 1.0) ; } glmatrixmode(gl_projection) ; glloadidentity( ) ; glortho(-1.0, 1.0, -1.0, 1.0, -1.0, 1.0) ; 23

void mydisplay(void){ glclear(gl_color_buffer_bit); glcolor3f(1.0f, 0.0f, 0.0f); glbegin(gl_triangles); glvertex2f(0.0 f, 0.0f); glvertex2f(1.0 f, 0.0f); glvertex2f(0.0 f, 1.0f); glend(); glcolor3f(0.0f, 1.0f, 0.0f); gllinewidth(8.4); glbegin(gl_lines); glvertex2f(0.0 f, 0.5f); glvertex2f(1.0 f, 0.5f); glend(); glflush(); } 24

You should download from the course site a zip file includes: glut32.dll glut32.lib, glut.h Copy it to the project folder (where the source code and extract it there) In Visual studio go to project menu -> properties -> C/C++ -> general In the right menu choose additional include directory and add glut.h path 25

26

Choose linker in the left menu -> input -> additional dependencies in the right menu -> choose edit and add glut32.lib Now after you apply changes you can run your program (press ctrl F5). 27

For lifeg.c you have to include opengl libraries: gcc hello.c lgl lglu lglut o hello 28

Expand code example to draw a sixth shape Draw a new INTERESTING shape in a new color This is a warm up mission; should not take you more than an hour 29