Painterly Rendering CMPS 160 - Assignment 2. OpenGL OpenGL is a cross-language, cross- platform specification defining and API for 2D and 3D graphics.

Slides:



Advertisements
Similar presentations
Create a Simple Game in Scratch
Advertisements

OpenGL Open a Win32 Console Application in Microsoft Visual C++.
OpenGL CMSC340 3D Character Design & Animation. What is OpenGL? A low-level graphics library specification designed for use with the C and C++ provides…
Create a Simple Game in Scratch
Chapter 2: Graphics Programming
Computer Graphics CSCE 441
Tutorial on Basic Usage
Word Processing First Steps
CS 4731 Lecture 2: Intro to 2D, 3D, OpenGL and GLUT (Part I) Emmanuel Agu.
Mrs. Chapman. Tabs (Block Categories) Commands Available to use Script Area where you type your code Sprite Stage All sprites in this project.
What is OpenGL? Low level 2D and 3D Graphics Library Competitor to Direct3D (the rendering part of DirectX) Used in: CAD, virtual reality, scientific.
IAT 800 Lab 1: Loops, Animation, and Simple User Interaction.
OpenGL (I). What is OpenGL (OGL)? OGL is a 3D graphics & modeling library Can also use it to draw 2D objects.
CSC 461: Lecture 51 CSC461 Lecture 5: Simple OpenGL Program Objectives: Discuss a simple program Discuss a simple program Introduce the OpenGL program.
OpenGL 3D and Animation for Simulating a Solar System
Based on slides created by Edward Angel
SE320: Introduction to Computer Games Week 8: Game Programming Gazihan Alankus.
Mr. Wortzman. Tabs (Block Categories) Available Blocks Script Area Sprite Stage All sprites in this project.
Introduction to VBA. This is not Introduction to Excel We’re going to assume you have a basic level of familiarity with Excel If you don’t, or you need.
Using Graphics Libraries Lecture 3 Mon, Sep 1, 2003.
Chi-Cheng Lin, Winona State University CS430 Computer Graphics Graphics Programming and OpenGL.
Programming in OpenGL Ryan Holmes CSE 570 February 12 th, 2003.
CAP4730: Computational Structures in Computer Graphics Introduction to OpenGL.
Introduction to Graphical User Interfaces. Objectives * Students should understand what a procedural program is. * Students should understand what an.
Introduction to OpenGL and GLUT GLUT. What is OpenGL? An application programming interface (API) A (low-level) Graphics rendering API Generate high-quality.
WORKING WITH CALLBACKS Ed Angel Professor of Computer Science, Electrical and Computer Engineering, and Media Arts University of New Mexico Angel: Interactive.
Prepared by Fareeha Lecturer DCS IIUI 1 Windows API.
Lecture 5: Interaction 1  Principles of Interactive Graphics  CMSCD2012  Dr David England, Room 711,  ex 2271 
Lecture 3 OpenGL.
CS 450: COMPUTER GRAPHICS PORTRAIT OF AN OPENGL PROGRAM SPRING 2015 DR. MICHAEL J. REALE.
Addison Wesley is an imprint of © 2010 Pearson Addison-Wesley. All rights reserved. Chapter 7 The Game Loop and Animation Starting Out with Games & Graphics.
 “OpenGL (Open Graphics Library) is a standard specification defining a cross- language cross-platform API for writing applications that produce 2D and.
Ch 2 Graphics Programming page 1 CSC 367 Coordinate Systems (2.1.2) Device coordinates, or screen coordinates (pixels) put limitations on programmers and.
CD2012 Principles of Interactive Graphics Lecture 01 Introduction Abir Hussain (Rome: 6.33,Tel , Web:
Interactive Computer Graphics CS 418 MP1: Dancing I TA: Zhicheng Yan Sushma S Kini Mary Pietrowicz Slides Taken from: “An Interactive Introduction to OpenGL.
Introduction to OpenGL and GLUT. What’s OpenGL? An Application Programming Interface (API) A low-level graphics programming API – Contains over 250 functions.
1 Input and Interaction. 2 Objectives Introduce the basic input devices ­Physical Devices ­Logical Devices ­Input Modes Event-driven input Introduce double.
Creating a Simple Game in Scratch Barb Ericson Georgia Tech June 2008.
Computer Graphics I, Fall 2010 Working with Callbacks.
Advanced Stuff Learning by example: Responding to the mouse.
Pop-Up Menus Glenn G. Chappell U. of Alaska Fairbanks CS 381 Lecture Notes Friday, September 26, 2003.
Create a Halloween Computer Game in Scratch Stephanie Smullen and Dawn Ellis Barb Ericson October 2008.
GLUT functions glutInit allows application to get command line arguments and initializes system gluInitDisplayMode requests properties for the window.
Lecture 2 Review OpenGL Libraries Graphics Overview Rendering Pipeline OpenGL command structure.
Scratch for Interactivity Dr. Ben Schafer Department of Computer Science University of Northern Iowa.
What’s on Your Desktop?. Programs on your computer Some programs are standard on most computers for example: Microsoft Word Internet Explorer Microsoft.
Programming with Visual Studio MFC and OpenGL. Outline Creating a project Adding OpenGL initialization code and libraries Creating a mouse event Drawing.
Introduction to Scratch We will be using the Scratch Environment today, so please log in to the Scratch website (scratch.mit.edu)
Computer Graphics I, Fall Programming with OpenGL Part 2: Complete Programs.
Creating a Simple Game in Scratch Barb Ericson Georgia Tech May 2009.
1 Angel: Interactive Computer Graphics 5E © Addison-Wesley 2009 Working with Callbacks.
Introducing Scratch Learning resources for the implementation of the scenario
INTRODUCTION TO OPENGL
Computer Graphics (Fall 2003) COMS 4160, Lecture 5: OpenGL 1 Ravi Ramamoorthi Many slides courtesy Greg Humphreys.
Visual Basic .NET BASICS
Create a Halloween Computer Game in Scratch
Scratch for Interactivity
Introduction to the Mouse
Computer Graphics Lecture 33
Computation as an Expressive Medium
Chapter 3 arrays of vertices vertex arrays display lists drawing text
Display Lists & Text Glenn G. Chappell
Drawing in the plane 455.
Introduction to OpenGL
More on Widgets, Misc. Topics
Chapter 3 arrays of vertices vertex arrays display lists drawing text
Model, View, Controller design pattern
Creating a Simple Game in Scratch
“Captured screen” appears.
Presentation transcript:

Painterly Rendering CMPS Assignment 2

OpenGL OpenGL is a cross-language, cross- platform specification defining and API for 2D and 3D graphics (taking advantage of hardware acceleration when possible).

GLUT “GL Utility Toolkit” GLUT is a layer on top of OpenGL that hides details of communicating with the system to control windows, and monitor the keyboard and mouse.

Assignment Overview Write code from scratch (ok, minimal base code) Due in 1 week Makefile takes care of building and converting image formats Build process assumes you use C++ but you don’t have to use an OO concepts (base code doesn’t). Designed for Mac lab (if you want to build elsewhere you should only have to change the Makefile) -- Makefile.cygwin available on class page

Demo My main.cc is 217 lines long Includes generous whitespace and comments Allows various color and brush modes. I spent way too much time painting cool pictures instead of debugging to give a good estimate on programming time… My guess 2-8 hours?

Concepts Think of GLUT as a machine, you configure it, turn it on, and leave it run by itself. Register “callbacks” to have to contact you back when certain events happen. Within callbacks, think of OpenGL as something you are sending message to. Use your normal loops and conditionals to get the right commands triggered at the right time and use glFlush() to get to to actually perform all the actions it has stored up. Its lazy on these Macs.

main.cc (in extreeeeeeeeeeeeeeeeeeeemly high level psuedocode) include ppm canvas header include gl/glut headers declare some shared state variables declare some callback functions declare main

main() Initialize glut -- glutInit load source image -- ppmLoadCanvas Create a window -- glutCreateWindow register callbacks -- glutSomethingFunc Let GLUT take over -- glutMainLoop() **never returns**

cb_display() Normally all screen drawing code goes here We are lazy We only draw when the user tries to paint something Leave the body of this function blank

cb_mouse(button,state,x,y) Called whenever a mouse button is pushed down or let up Put your code to draw a paint blob here or in…

cb_motion(x,y) Called for each location along a mouse dragging path When user drags, moves, drags again there is a jump in the coordinates fed to this function, use cb_mouse to figure out when this happens Paint here if you like Save this x,y for later so you can use it to draw lines from this position to the next If you want to track mouse motion when no buttons are down there is way

cb_keyboard(key,x,y) Called whenever a key is pressed You should exit(0) when the user presses ‘q’ You can use other keys to trigger changing of painting modes or clear the screen. No modifiers (alt,ctrl,whatever) are passed, there is a way to get these

cb_reshape(w,h) Called at startup and when the window is resized You should save w,h to help interpret mouse coordinates glViewport tells GL what part of the window you want to use (all of it!) Look up glMatrixMode and gluOrtho2D to setup projection matrix properly Optionally, clear the screen as well

Global state variables Canvas - the function where you actually paint needs access to the source image loaded in main() Window size - compare mouse coordinates to these to figure out relative location within window Last cursor position - draw lines from this location to current location to make directional strokes if you like

ppm_canvas usage canvas_t canvas; ppmLoadCanvas(“some.ppm”,&canvas); int x = 50; // column, left to right int y = 100; // row, top to bottom (I think) pixel_t pixel = PIXEL(canvas,x,y); int r = RED(pixel); float g = GREEN(pixel)/255.0; // OpenGL expects colors in the range 0.0f-1.0f

Actually painting something Look these up in the linked documentaiton: glBegin(GL_???) glEnd() glColor*() glVertex*()

the provided Makefile “make” builds your program, tells you what to write in your README if you don’t have one “make demo” builds binary+documentation tarball to brag to your friends/classmates without revealing top secret painting effect implementation “make some.ppm” converts some.jpg to ppm format (also works for gif, png, whatever…) If you use multiple source files to complete the assignment you must edit the a line in the Makefile