GLUT. What is OpenGL? Introduction to OpenGL and GLUT

Similar documents
An Overview GLUT GLSL GLEW

Introduction to Computer Graphics with OpenGL/GLUT

Exercise 1 Introduction to OpenGL

GL_COLOR_BUFFER_BIT, GL_PROJECTION, GL_MODELVIEW

RECITATION - 1. Ceng477 Fall

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

CS Computer Graphics: OpenGL, Continued

CS Computer Graphics: OpenGL, Continued

CS Computer Graphics: Intro to OpenGL

CS Computer Graphics: Intro to OpenGL

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

Computer Graphics. Bing-Yu Chen National Taiwan University

Computer Graphics 1 Computer Graphics 1

Lecture 4 of 41. Lab 1a: OpenGL Basics

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

CS 4204 Computer Graphics

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

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

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

Programming using OpenGL: A first Introduction

Drawing Primitives. OpenGL basics

Introduction to OpenGL. CSCI 4229/5229 Computer Graphics Fall 2012

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

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

COMP 371/4 Computer Graphics Week 1

Lecture 2 2D transformations Introduction to OpenGL

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

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

Programming with OpenGL Part 1: Background

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

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

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

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

Rendering. Part 1 An introduction to OpenGL

Lecture 3 Advanced Computer Graphics (CS & SE )

Introduction to OpenGL Week 1

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

Computer Graphics Course 2005

Computer Graphics. Making Pictures. Computer Graphics CSC470 1

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

OpenGL. Toolkits.

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

OpenGL Introduction Computer Graphics and Visualization

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

Computer graphics MN1

Computer Graphics. OpenGL

Computer Graphics, Chapt 08

Computer Graphics (Basic OpenGL)

Computer Graphics (CS 543) Lecture 1 (Part 1): Introduction to Computer Graphics

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

Precept 2 Aleksey Boyko February 18, 2011

Announcements OpenGL. Computer Graphics. Spring CS4815

Lectures OpenGL Introduction

CS450/550. Pipeline Architecture. Adapted From: Angel and Shreiner: Interactive Computer Graphics6E Addison-Wesley 2012

Draw the basic Geometry Objects. Hanyang University

Basic Graphics Programming

Announcements OpenGL. Computer Graphics. Autumn 2009 CS4815

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

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

Lecture 10: Input, Interaction & callbacks. CITS 3003 Graphics & Animation

An Interactive Introduction to OpenGL Programming

Image Processing. Geometry Processing. Reading: (Not really covered in our text. See Sects 18.1, 18.2.) Overview: Display

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

Graphics Programming

Programming of Graphics

OpenGL/GLUT Intro. Week 1, Fri Jan 12

CSC 8470 Computer Graphics. What is Computer Graphics?

Computer graphic -- Programming with OpenGL I

Assignment 1. Simple Graphics program using OpenGL

CS 432 Interactive Computer Graphics

Basic Graphics Programming

Bob s Concise Introduction to Doxygen

CIS 441/541: Introduction to Computer Graphics Lecture 14: OpenGL Basics

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

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

Display Lists in OpenGL

COMPUTER GRAPHICS LAB # 3

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

3D Graphics and OpenGl. First Steps

Programming with OpenGL Part 1: Background

Computer Graphics - Chapter 1 Graphics Systems and Models

Introduction to OpenGL

OpenGL refresher. Advanced Computer Graphics 2012

Input and Interaction

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

CS130 : Computer Graphics. Tamar Shinar Computer Science & Engineering UC Riverside

2D Drawing Primitives

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

Lecture 3. Understanding of OPenGL programming

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

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

Computer Graphics. Chapter 3 Computer Graphics Software

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

CSE528 Computer Graphics: Theory, Algorithms, and Applications

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

Graphics Pipeline & APIs

Computer Graphics CS 460. Software. Computer Graphics. 2. Medium Level (General Programming Packages)

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

Computer Graphics Primitive Attributes

Transcription:

What is OpenGL? Introduction to OpenGL and An application programming interface (API) A (low-level) Graphics rendering API Generate high-quality h color images composed of geometric and image primitives What is OpenGL? Maximal Portability Display device independent Window system independent Operating system independent d Without a standard API (such as OpenGL) - impossible to port (100, 50) Line(100,50,150,80) - device/lib 1 (150, 100) Moveto(100,50) - device/lib 2 Lineto(150,100) 1

OpenGL Basics Code Example OpenGL s primary function Rendering Rendering? converting geometric/mathematical th ti object descriptions into frame buffer values OpenGL can render: Geometric primitives Bitmaps and Images (Raster primitives) void Display() glclear(gl _ COLOR_ BUFFER_ BIT); glcolor4f(1,1,0,1); glbegin(gl_polygon); glvertex2f(-0.5, -0.5); glvertex2f(-0.5, 0.5); glvertex2f(0.5, 0.5); glvertex2f(0.5, -0.5); glend(); glflush(); Specifying Geometric primitives Primitive Types Primitives are specified using glbegin(primtype); // define your primitives here glend(); primtype: GL_POINTS, GL_LINES, GL_TRIANGLES, GL_QUADS, 2

Sample Example OpenGL Command Formats Void DrawQuad(GLfloat color[]) glcolor3f(0,0,1); l 0 glbegin(gl_quads); glvertex2f(0,0); glvertex2f(1.0, 0,0); glvertex2f(1.0, 1.0); glvertex2f(0.0, 1.0); glend(); number of Components/ Dimensions 2 (x,y) 3 (x,y,z) 4 (x,y,z,w) or (r,g,b,a) glvertex2f(x, y) B byte ub unsigned byte s short us unsigned short i int ui unsigned int f float d double Add v for vector form glvertex2fv(v) Shape Example Window-based programming Most of the modern graphics systems are window-based Non-window based environment Window based environment 3

Window system independent OpenGL is window system independent No window management functions create windows, resize windows, event handling, etc This is to ensure the application s portability Create some headache though just a pure OpenGL program won t work anywhere. More APIs are needed X window system: GLX Apple Macintosh: AGL Microsoft Windows: WGL These libraries provide complete functionality to create Graphics User Interface (GUI) such as sliders, buttons,, menus etc. Problem you need to learn and implement them all to write a true portable software Use (OpenGL Utility Toolkit) Basics For fast prototyping, we can use to interface with different window systems is a window independent API programs written using OpenGL and can be ported to X windows, MS windows, and Macintosh with no effort does not contain all the bells and whistles though (no sliders, no dialog boxes, no menu bar, etc) Program Structure 1. Configure and open window () 2. Initialize OpenGL (Optional) 3. Register input callback functions () Render Resize Input: keyboard, mouse, etc 4. Enter event processing loop () 4

Sample Program Sample Program int mode = _RGB _SINGLE; glutcreatewindow(argv[0]); int mode = _RGB _SINGLE; Specify the display Mode RGB or color Index, single or double Buffer Sample Program Sample Program int mode = _RGB _SINGLE; Create a window Named simple with resolution 500 x 500 int mode = _RGB _SINGLE; Your OpenGL initialization code (Optional) 5

Sample Program Callback functions? int mode = _RGB _SINGLE; Register your call back functions Most of window-based programs are event-driven which means do nothing until an event happens, and then execute some pre-defined functions Events key press, mouse button press and release, window resize, etc. glutdisplayfunc(void (*func)(void) ) void display() the function you provide. It contains all the OpenGL drawing function calls and will be called when pixels in the window need to be refreshed. Event Queue MainLoop() Mouse_callback() Event queue Keypress_callback() Keyboard Mouse window_callback() Window 6

And many more glutmainloop() glutkeyboardfunc() register the callback that will be called when a key is pressed glutmousefunc() register the callback that will be called when a mouse button is pressed glutmotionfunc() register the callback that will be called when the mouse is in motion while a buton is pressed glutidlefunc() register the callback that will be called when nothing is going on (no event) int mode = _RGB _SINGLE; glutreshapefunc(resize); The program goes into a infinite loop waiting for events 7