Buffers. Buffer. OpenGL Frame Buffer. OpenGL Buffers. Objectives

Similar documents
Simple Image File Formats

Lesson 10: Video-Out Interface

OpenGL & Delphi. Max Kleiner. 1/22

Image Processing and Computer Graphics. Rendering Pipeline. Matthias Teschner. Computer Science Department University of Freiburg

Introduction to graphics and LCD technologies. NXP Product Line Microcontrollers Business Line Standard ICs

Input and Interaction

Green = 0,255,0 (Target Color for E.L. Gray Construction) CIELAB RGB Simulation Result for E.L. Gray Match (43,215,35) Equal Luminance Gray for Green

Computer Graphics Hardware An Overview

Chapter 3 Graphics and Image Data Representations

QCD as a Video Game?

Input and Interaction. Project Sketchpad. Graphical Input. Physical Devices. Objectives

VESA BIOS Extension/Accelerator Functions (VBE/AF)

Methodology for Lecture. Review of Last Demo

UNIVERSITY OF CALICUT

FIRST Robotics Competition (FRC) Application Programming Interface (API) Specification For Machine Vision

Touchstone -A Fresh Approach to Multimedia for the PC

MassArt Studio Foundation: Visual Language Digital Media Cookbook, Fall 2013

Image Synthesis. Transparency. computer graphics & visualization

OpenGL Performance Tuning

System Calls and Standard I/O

Adobe Illustrator CS5 Part 1: Introduction to Illustrator

Computer Graphics. Anders Hast

JPEG File Interchange Format

Phys4051: C Lecture 2 & 3. Comment Statements. C Data Types. Functions (Review) Comment Statements Variables & Operators Branching Instructions

Lecture 3: Models of Spatial Information

MMGD0203 Multimedia Design MMGD0203 MULTIMEDIA DESIGN. Chapter 3 Graphics and Animations

Silverlight for Windows Embedded Graphics and Rendering Pipeline 1

Digital Imaging and Image Editing

Using the Siemens S65 Display

Data Storage 3.1. Foundations of Computer Science Cengage Learning

Computer Graphics Labs

DigitalMicrograph 3.4 User s Guide

Office of Creative Services. Tuck Visual Identity. A reference guide to Tuck s logos and visual identification standards

Raima Database Manager Version 14.0 In-memory Database Engine

Zeiss 780 Training Notes

Lecture Notes, CEng 477

HDI 4000 Ultrasound System

w w w. g e o s o f t. c o m

Solomon Systech Image Processor for Car Entertainment Application

Self-Positioning Handheld 3D Scanner

Lab #8: Introduction to ENVI (Environment for Visualizing Images) Image Processing

Chapter 07: Instruction Level Parallelism VLIW, Vector, Array and Multithreaded Processors. Lesson 05: Array Processors

The following is an overview of lessons included in the tutorial.

Using MATLAB to Measure the Diameter of an Object within an Image

Plotting: Customizing the Graph

Comp 410/510. Computer Graphics Spring Introduction to Graphics Systems

The C Programming Language course syllabus associate level

Graded ARM assembly language Examples

Monash University Clayton s School of Information Technology CSE3313 Computer Graphics Sample Exam Questions 2007

Preliminary Draft May 19th Video Subsystem

Package png. February 20, 2015

MASKS & CHANNELS WORKING WITH MASKS AND CHANNELS

Adding Animation With Cinema 4D XL

Data Storage. Chapter 3. Objectives. 3-1 Data Types. Data Inside the Computer. After studying this chapter, students should be able to:

Computer Graphics Labs

Digital Image Fundamentals. Selim Aksoy Department of Computer Engineering Bilkent University

1. General Description

Q&As: Microsoft Excel 2013: Chapter 2

Interaction. Triangles (Clarification) Choice of Programming Language. Display Lists. The CPU-GPU bus. CSCI 480 Computer Graphics Lecture 3

Structures for Data Compression Responsible persons: Claudia Dolci, Dante Salvini, Michael Schrattner, Robert Weibel

OPERATION MANUAL. MV-410RGB Layout Editor. Version 2.1- higher

GPU Architecture. Michael Doggett ATI

OpenEXR Image Viewing Software

Creating Web Pages with Microsoft FrontPage

Comparison of different image compression formats. ECE 533 Project Report Paula Aguilera

NIS-Elements Viewer. User's Guide

Grasshopper3 U3. Point Grey Research Inc Riverside Way Richmond, BC Canada V6W 1K7 T (604)

FREQUENTLY ASKED QUESTIONS (FAQs) 123Scan 2 Scanner Configuration Utility 19 April 2011

Software Developer's Manual

High-speed image processing algorithms using MMX hardware

CMSC 427 Computer Graphics 1

Module 816. File Management in C. M. Campbell 1993 Deakin University

Fast Arithmetic Coding (FastAC) Implementations

SP8 Programmers 硕 飞 科 技. User's Guide. TEL: FAX: WEB:

ACE: Illustrator CC Exam Guide

QuickTime Import and Export Guide. (Legacy)

Video Camera Image Quality in Physical Electronic Security Systems

Contents 1. Introduction Login Order Status Search for pre-advice and orders View pre-advice or order...

Graphics Pipeline in a Nutshell

Lesson 15 - Fill Cells Plugin

Scanning in Windows XP: Basics Learning guide

HDS GEN2 (Keypad) Version 4.0 Software Update

MAIN_SNP_TOPO.dgm_2m

Chapter 4 Windows Applications Notepad, WordPad, and Paint

EARTH PEOPLE TECHNOLOGY SERIAL GRAPH TOOL FOR THE ARDUINO UNO USER MANUAL

System Calls Related to File Manipulation

VB.NET Programming Fundamentals

Periodontology. Digital Art Guidelines JOURNAL OF. Monochrome Combination Halftones (grayscale or color images with text and/or line art)

Computer Graphics (Basic OpenGL, Input and Interaction)

Graphics Input Primitives. 5. Input Devices Introduction to OpenGL. String Choice/Selection Valuator

Embedded Systems Design Course Applying the mbed microcontroller

Scan-Line Fill. Scan-Line Algorithm. Sort by scan line Fill each span vertex order generated by vertex list

Cabcharge Australia Limited, Cabcharge TMS Help Manual

1. Introduction to image processing

MBP_MSTR: Modbus Plus Master 12

Introducing the Microsoft IIS deployment guide

A Short Introduction to Computer Graphics

GPGPU Computing. Yong Cao

Transcription:

Buffers Objectives Introduce additional OpenGL buffers Learn to read and write buffers Learn to use blending Buffer Define a buffer by its spatial resolution (n x m) and its depth k, the number of bits/pixel pixel 1 2 OpenGL Frame Buffer OpenGL Buffers Color buffers can be displayed - Front -Back - Auxiliary -Overlay Depth Accumulation - High resolution buffer Stencil - Holds masks 3 4 1

Writing in Buffers Conceptually, we can consider all of memory as a large two-dimensional array of pixels We read and write rectangular block of pixels - Bit block transfer (bitblt) operations The frame buffer is part of this memory Writing Model Read destination pixel before writing source memory source writing into frame buffer frame buffer (destination) 5 6 Writing Modes XOR mode Source and destination bits are combined bitwise 16 possible functions (one per column in table) replace XOR OR Recall from Chapter 3 that we can use XOR by enabling logic operations and selecting the XOR write mode XOR is especially useful for swapping blocks of memory such as menus that are stored off screen If S represents screen and M represents a menu the sequence S S M M S M S S M swaps the S and M 7 8 2

The Pixel Pipeline OpenGL has a separate pipeline for pixels - Writing pixels involves Moving pixels from processor memory to the frame buffer Format conversions Mapping, Lookups, Tests - Reading pixels Format conversion Raster Position OpenGL maintains a raster position as part of the state Set by glrasterpos*() -glrasterpos3f(x, y, z); The raster position is a geometric entity - Passes through geometric pipeline - Eventually yields a 2D position in screen coordinates - This position in the frame buffer is where the next raster primitive is drawn 9 10 Buffer Selection Bitmaps OpenGL can draw into or read from any of the color buffers (front, back, auxiliary) Default to the back buffer Change with gldrawbuffer and glreadbuffer Note that format of the pixels in the frame buffer is different from that of processor memory and these two types of memory reside in different places - Need packing and unpacking - Drawing and reading can be slow OpenGL treats 1-bit pixels (bitmaps) differently than multi-bit pixels (pixelmaps) Bitmaps are masks which determine if the corresponding pixel in the frame buffer is drawn with the present raster color -0 color unchanged -1 color changed based on writing mode Bitmaps are useful for raster text -GLUT_BIT_MAP_8_BY_13 11 12 3

Raster Color Same as drawing color set by glcolor*() Fixed by last call to glrasterpos*() glcolor3f(1.0, 0.0, 0.0); glrasterpos3f(x, y, z); glcolor3f(0.0, 0.0, 1.0); glbitmap(. glbegin(gl_lines); glvertex3f(..) Geometry drawn in blue Ones in bitmap use a drawing color of red Drawing Bitmaps glbitmap(width, height, x0, y0, xi, yi, bitmap) offset from raster position increments in raster position after bitmap drawn first raster position second raster position 13 14 Drawing Bitmaps Example: Checker Board glbitmap(width, height, x0, y0, xi, yi, bitmap) offset from raster position increments in raster position after bitmap drawn First raster position GLubyte wb[2] = {0 x 00, 0 x ff; GLubyte check[512]; int i, j; for(i=0; i<64; i++) for (j=0; j<64, j++) check[i*8+] = wb[(i/8+j)%2]; glbitmap( 64, 64, 0.0, 0.0, 0.0, 0.0, check); second raster position 15 16 4

Pixel Maps OpenGL Pixel Functions OpenGL works with rectangular arrays of pixels called pixel maps or images Pixels are in one byte ( 8 bit) chunks - Luminance (gray scale) images 1 byte/pixel - RGB 3 bytes/pixel Three functions - Draw pixels: processor memory to frame buffer - Read pixels: frame buffer to processor memory - Copy pixels: frame buffer to frame buffer glreadpixels(x,y,width,height,format,type,myimage) start pixel in frame buffer size type of pixels type of image pointer to processor memory GLubyte myimage[512][512][3]; glreadpixels(0,0, 512, 512, GL_RGB, GL_UNSIGNED_BYTE, myimage); gldrawpixels(width,height,format,type,myimage) starts at raster position 17 18 Image Formats Displaying a PPM Image We often work with images in a standard format (JPEG, TIFF, GIF) How do we read/write such images with OpenGL? PPM is a very simple format Each image file consists of a header followed by all the pixel data Header No support in OpenGL - OpenGL knows nothing of image formats - Some code available on Web - Can write readers/writers for some simple formats in OpenGL P6 # comment 1 # comment 2. #comment n rows columns maxvalue pixels 19 20 5

Reading the Header Reading the Header (cont) FILE *fd; int k, nm; char c; int i; char b[100]; check for P3 float s; in first line int red, green, blue; printf("enter file name\n"); scanf("%s", b); fd = fopen(b, "r"); fscanf(fd,"%[^\n] ",b); if(b[0]!='p' b[1]!= 6'){ printf("%s is not a PPM file!\n", b); exit(0); printf("%s is a PPM file\n",b); 21 fscanf(fd, "%c",&c); while(c == '#') { fscanf(fd, "%[^\n] ", b); printf("%s\n",b); fscanf(fd, "%c",&c); ungetc(c,fd); skip over comments by looking for # in first column 22 Reading the Data Scaling the Image Data fscanf(fd, "%d %d %d", &n, &m, &k); printf("%d rows %d columns max value= %d\n",n,m,k); nm = n*m; image=malloc(3*sizeof(gluint)*nm); s=255./k; scale factor for(i=0;i<nm;i++) { fscanf(fd,"%d %d %d",&red, &green, &blue ); image[3*nm-3*i-3]=red; image[3*nm-3*i-2]=green; image[3*nm-3*i-1]=blue; We can scale the image in the pipeline glpixeltransferf(gl_red_scale, s); glpixeltransferf(gl_green_scale, s); glpixeltransferf(gl_blue_scale, s); We may have to swap bytes when we go from processor memory to the frame buffer depending on the processor. If so we can use glpixelstorei(gl_unpack_swap_bytes,gl_true); 23 24 6

The display callback void display() { glclear(gl_color_buffer_bit); glrasterpos2i(0,0); gldrawpixels(n,m,gl_rgb, GL_UNSIGNED_INT, image); glflush(); 25 7