Department of Computer Science Engineering, Mits - Jadan, Pali, Rajasthan, India

Similar documents
About the Tutorial. Audience. Prerequisites. Copyright & Disclaimer. Computer Graphics

From Ver(ces to Fragments: Rasteriza(on

Digital Differential Analyzer Bresenhams Line Drawing Algorithm

In today s lecture we ll have a look at: A simple technique The mid-point circle algorithm

OpenGL Graphics System. 2D Graphics Primitives. Drawing 2D Graphics Primitives. 2D Graphics Primitives. Mathematical 2D Primitives.

Output Primitives. Dr. S.M. Malaek. Assistant: M. Younesi

Output Primitives Lecture: 4. Lecture 4

Chapter - 2: Geometry and Line Generations

Computer Graphics : Bresenham Line Drawing Algorithm, Circle Drawing & Polygon Filling

CS 450: COMPUTER GRAPHICS REVIEW: DRAWING LINES AND CIRCLES SPRING 2015 DR. MICHAEL J. REALE

Computer Graphics: Graphics Output Primitives Line Drawing Algorithms

Efficient Plotting Algorithm

From Vertices to Fragments: Rasterization. Reading Assignment: Chapter 7. Special memory where pixel colors are stored.

Rasterization: Geometric Primitives

CS6504 & Computer Graphics Unit I Page 1

Overview of Computer Graphics

Tópicos de Computação Gráfica Topics in Computer Graphics 10509: Doutoramento em Engenharia Informática. Chap. 2 Rasterization.

Computer Graphics Prof. Sukhendu Das Dept. of Computer Science and Engineering Indian Institute of Technology, Madras Lecture - 14

Scan Conversion. CMP 477 Computer Graphics S. A. Arekete

R asterisation. Part I: Simple Lines. Affine transformation. Transform Render. Rasterisation Line Rasterisation 2/16

Computer Graphics D Graphics Algorithms

GRAPHICS OUTPUT PRIMITIVES

Output Primitives Lecture: 3. Lecture 3. Output Primitives. Assuming we have a raster display, a picture is completely specified by:

Rasterization, or What is glbegin(gl_lines) really doing?

Line Drawing. Foundations of Computer Graphics Torsten Möller

Chapter 3. Sukhwinder Singh

Points and lines. x x 1 + y 1. y = mx + b

CS Rasterization. Junqiao Zhao 赵君峤

Computer Graphics. - Rasterization - Philipp Slusallek

(Refer Slide Time: 00:03:51)

Scan Conversion. Drawing Lines Drawing Circles

EF432. Introduction to spagetti and meatballs

Computer Graphics. Lecture 2. Doç. Dr. Mehmet Gokturk

Line Drawing. Introduction to Computer Graphics Torsten Möller / Mike Phillips. Machiraju/Zhang/Möller

UNIT 2 GRAPHIC PRIMITIVES

Computer Graphics Lecture Notes

I Internal Examination (Model Paper) B.Tech III Year VI semester, Computer Science & Engineering

Realtime 3D Computer Graphics Virtual Reality

Scan Converting Lines

Topic 0. Introduction: What Is Computer Graphics? CSC 418/2504: Computer Graphics EF432. Today s Topics. What is Computer Graphics?

CS 4731: Computer Graphics Lecture 21: Raster Graphics: Drawing Lines. Emmanuel Agu

An Improved Algorithm for Scan-converting a Line

Unit 2 Output Primitives and their Attributes

Raster Displays and Scan Conversion. Computer Graphics, CSCD18 Fall 2008 Instructor: Leonid Sigal

Announcements. Midterms graded back at the end of class Help session on Assignment 3 for last ~20 minutes of class. Computer Graphics

CS 130. Scan Conversion. Raster Graphics

RASTERIZING POLYGONS IN IMAGE SPACE

Introduction to Computer Graphics (CS602) Lecture 05 Line Drawing Techniques

FROM VERTICES TO FRAGMENTS. Lecture 5 Comp3080 Computer Graphics HKBU

EF432. Introduction to spagetti and meatballs

0. Introduction: What is Computer Graphics? 1. Basics of scan conversion (line drawing) 2. Representing 2D curves

Painter s HSR Algorithm

Computer Graphics D Graphics Algorithms

COMP371 COMPUTER GRAPHICS

(Refer Slide Time: 9:36)

CPSC / Scan Conversion

CS 450: COMPUTER GRAPHICS RASTERIZING LINES SPRING 2016 DR. MICHAEL J. REALE

Einführung in Visual Computing

Lecture 6 of 41. Scan Conversion 1 of 2: Midpoint Algorithm for Lines and Ellipses

Lecture 6 of 41. Scan Conversion 1 of 2: Midpoint Algorithm for Lines and Ellipses

CSCI 420 Computer Graphics Lecture 14. Rasterization. Scan Conversion Antialiasing [Angel Ch. 6] Jernej Barbic University of Southern California

Line Drawing Week 6, Lecture 9

Fall CSCI 420: Computer Graphics. 7.1 Rasterization. Hao Li.

Rasterization. Rasterization (scan conversion) Digital Differential Analyzer (DDA) Rasterizing a line. Digital Differential Analyzer (DDA)

Rendering. A simple X program to illustrate rendering

A New Line Drawing Algorithm Based on Sample Rate Conversion

(Refer Slide Time: 00:02:00)

Replica Technique for Geometric Modelling

Welcome to CS 4/57101 Computer Graphics

Department of Computer Sciences Graphics Fall 2003 (Lecture 2) Pixels

CS452/552; EE465/505. Clipping & Scan Conversion

Scan Conversion. Lines and Circles

Pipeline implementation II

Scan Converting Circles

Rendering. A simple X program to illustrate rendering

Display Technologies: CRTs Raster Displays

UNIT 2 Scan Conversion Techniques and Image Representation Unit-02/Lecture-01

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

COMP30019 Graphics and Interaction Scan Converting Polygons and Lines

Computer Graphics: 6-Rasterization

Computer Graphics: Line Drawing Algorithms

Manipal Institute of Technology Manipal University Manipal

MET71 COMPUTER AIDED DESIGN

UNIT -8 IMPLEMENTATION

OUTPUT PRIMITIVES. CEng 477 Introduction to Computer Graphics METU, 2007

Renderer Implementation: Basics and Clipping. Overview. Preliminaries. David Carr Virtual Environments, Fundamentals Spring 2005

Chapter 8: Implementation- Clipping and Rasterization

CS 543: Computer Graphics. Rasterization

Topics. From vertices to fragments

Graphics System. Processor. Output Display. Input Devices. Frame Buffer. Memory. Array of pixels. Resolution: # of pixels Depth: # of bits/pixel

MODULE - 4. e-pg Pathshala

Computer Graphics (CS 543) Lecture 10: Rasterization and Antialiasing

CSC Computer Graphics

CSCI 4620/8626. Coordinate Reference Frames

Clipping and Scan Conversion

From 3D World to 2D Screen. Hendrik Speleers

Topic #1: Rasterization (Scan Conversion)

Chapter 3: Graphics Output Primitives. OpenGL Line Functions. OpenGL Point Functions. Line Drawing Algorithms

Mcq In Computer Graphics

CS 4300 Computer Graphics. Prof. Harriet Fell Fall 2012 Lecture 5 September 13, 2012

Transcription:

International Journal of Scientific Research in Computer Science, Engineering and Information Technology 2018 IJSRCSEIT Volume 3 Issue 1 ISSN : 2456-3307 Performance Analysis of OpenGL Java Bindings with Graphics Scan Conversion Algorithms Naresh Purohit *1, Rajendra Purohit 2 ABSTRACT *1 Department of Computer Science Engineering, Mits - Jadan, Pali, Rajasthan, India 2 Research Scholar, Rajasthan Technical University, Kota, Rajasthan, India This paper presents a Performance Analysis of OPNGL with Java bindings i.e. Light Weight Java Game Library ().Three different sections, i.e. Line Rendering, Circle Rendering, and Image Rendering have been selected as the benchmarks for extensive analysis of the performance gaps between the two. The results show the performance of with rendering algorithms to display from a single pixel to some large images in the screen on the basis of execution time analysis. LJWJGL is a Java-Binding of OPENGL that enables developing portable, interactive 2D and 3D graphics applications. Keywords: OpenGL,, Rendering, Pixel, Java Bindings. I. INTRODUCTION The Computer Graphics is one of the most effective and commonly used methods to communicate the processed information to the user. It displays the information in the form of graphics objects such as pictures, charts, graphs and diagram instead of simple text. In computer graphics, pictures or graphics objects are presented as a collection of discrete picture elements called pixels. The pixel is the smallest addressable screen element.[4] A. Rendering Rendering is the process of generating an image from a model, by means of a software program. The model is a description of three dimensional objects in a strictly defined language or data structure. It would contain geometry, viewpoint, texture and lighting information. Figure 1. Rendering Process Block Diagram The image is a digital image or raster graphics image. The term may be by analogy with an "artist's rendering" of a scene. 'Rendering' is also used to describe the process of calculating effects in a video editing file to produce final video output B. (Light Weight Java Game Library) is a Java binding for OPNGL API. The Lightweight Java Game Library () is an opensource Java software library for video game developers. It exposes high performance crossplatform libraries commonly used in developing video games and multimedia titles. It provides a way for Java developers to get access to resources that are otherwise unavailable or poorly implemented on the existing Java platform.[3] CSEIT1831191 Received : 15 Jan 2018 Accepted : 05 Feb 2018 January-February-2018 [(3) 1 : 776-781] 776

Figure 2. OpenGL Flow Diagram II. RENDERING OBJECTS In this paper, the rendering is done on linear and non-linear objects. In linear objects, straight line algorithms and for non-linear objects, circle algorithms are analysed. A. Line Drawing A line drawing algorithm is a graphical algorithm for approximating a line segment on discrete graphical media. On discrete media, such as pixel-based displays and printers, line drawing requires such an approximation (in nontrivial cases). Basic algorithms rasterizing lines in one color. A better representation with multiple color gradations requires an advanced process, spatial anti-aliasing. A line connects two points. It is a basic element in graphics. To draw a line, we need two points between which we can draw a line. A.1 LSI Algorithm The Cartesian slope-intercept equation for a straight line is with m representing the slope of the line and b as the y intercept. [5]Given that the two endpoints of a he segment are specified at positions (x1, y1) and (x2, y2), as shown in Fig., we can determine values for the slope m and y intercept b with the following calculations: Figure 3. Drawing points on Graph by Line Equation Y=MX+B Step 1: Calculate dx = x2-x1 dy = y2-y1; m = dy/dx; b = y1-m*x1; Step 2: check if if(m<=1) Then Calculate y=m*x+b For loop x1 to x2 times each iteration Draw pixel(x,y) position Else Calculate x = (1/m)*y+b; For loop y1 to y2 times each iteration Draw pixel(x,y) position Table 1. LSI Rendering through 1 218.690 2 232.882 227.911 3 246.748 4 217.392 5 223.843 in Milliseconds 777

putpixel(round(x), Round(y)); Chart 1. LSI Rendering through A.2 DDA Algorithm The digital differential analyser (DDA) is a scanconversion line algorithm based on calculating either dy or dx. Using dx or dy, We sample the line at unit intervals in one coordinate and determine corresponding integer values nearest the line path for the other coordinate.[6] Step 1 : Get the input of two end points (X0,Y0)(X0,Y0) and (X1,Y1)(X1,Y1). Step 2: Calculate the difference between two end points. dx = X1 - X0 dy = Y1 - Y0 Step 3: Based on the calculated difference in step-2, you need to identify the number of steps to put pixel. If dx > dy, then you need more steps in x coordinate; otherwise in y coordinate. if (absolute(dx) > absolute(dy)) Steps = absolute(dx); else Steps = absolute(dy); Step 4: Calculate the increment in x coordinate and y coordinate. Xincrement = dx / (float) steps; Yincrement = dy / (float) steps; Step 5: Put the pixel by successfully incrementing x and y coordinates accordingly and complete the drawing of the line. for(int v=0; v < Steps; v++) x = x + Xincrement; y = y + Yincrement; 230 225 220 215 210 205 200 Table 2. DDA Rendering through 1 210.320 2 222.683 3 227.246 4 219.858 5 228.048 in Milliseconds 221.631 Chart 2. DDA Rendering through A.3 Bresenham's Line Algorithm The Bresenham algorithm is another incremental scan conversion algorithm. The big advantage of this algorithm is that, it uses only integer calculations. Moving across the x axis in unit intervals and at each step choose between two different y coordinates.[1] Step 1: Input the two end-points of line, storing the left end-point in (x0,y0)(x0,y0). Step 2: Plot the point (x0,y0)(x0,y0). Step 3: Calculate the constants dx, dy, 2dy, and (2dy 2dx) and get the first value for the decision parameter as p0=2dy dx Step 4: At each Xk along the line, starting at k = 0, perform the following test If pk < 0, the next point to plot is (xk+1,yk)and pk+1=pk+2dy Otherwise, 778

pk+1=pk+2dy 2dx Step 5: Repeat step 4 (dx 1) times. For m > 1, find out whether you need to increment x while incrementing y each time. Table 3.Bresenham's Line Rendering through 1 100.419 2 100.257 3 103.189 4 119.704 5 109.648 in Milliseconds 106.6434 Chart 3. Bresenham's Line Rendering through B. Circle Drawing B.1 Circle Equation Drawing The circle is a frequently used component in pictures and graphs, a procedure for generating either full circles or circular arcs is included in most graphics packages. More generally, a single procedure can be provided to display either circular or elliptical curves. Figure 4. Basic Circle Equation Drawing for(x = -r; x <= r; x++) y= SquareRoot of (r * r - (x * x)); Draw Pixel(xc+x,xc+y) forthe upper half DrawPixel(xc+x,yc-y) for the lower half Table 4. Basic Circle Equation Rendering through 1 163.138 2 163.166 3 171.513 170.3376 4 194.679 5 159.192 in Milliseconds A circle is defined as the set of points that are all at a given distance R from a center position (Xc, Yc). This distance relationship is expressed by the Pythagorean Theorem in Cartesian coordinates as (X-Xc) 2 +(Y-Yc) 2 = R 2 Chart 4. Basic Circle Equation Rendering through B.1 Bresenham's Circle Drawing The purpose of Bresenham s circle algorithm is to generate the set of points that approximate a circle on a pixel-based display. We generate the points in the first octant of the circle and then use symmetry to generate the other seven octants. We start at (r, 0). This pixel is chosen trivially. Next we need to find 779

the pixel for the y = 1 row. We must make a decision between two candidate points.[2] 150 100 50 0 in Milliseconds Figure 5. Eight Way Symmetry Step 1: Set X = 0 and Y = R Set D = 3 2R Step 2: Repeat While (X < Y) Call Draw Circle(Xc, Yc, X, Y) Set X = X + 1 If (D < 0) Then D = D + 4X + 6 Else Set Y = Y 1 D = D + 4(X Y) + 10 [End of If] Call Draw Circle(Xc, Yc, X, Y) [End of While] Exit Draw Circle (Xc, Yc, X, Y): Call PutPixel(Xc + X, Yc, + Y) Call PutPixel(Xc - X, Yc, + Y) Call PutPixel(Xc + X, Yc, - Y) Call PutPixel(Xc - X, Yc, - Y) Call PutPixel(Xc + Y, Yc, + X) Call PutPixel(Xc - Y, Yc, + X) Call PutPixel(Xc + Y, Yc, - X) Call PutPixel(Xc - Y, Yc, - X) Exit Table 5. Bresenham's Circle Rendering through 1 77.239 2 42.876 3 98.883 88.1312 4 122.418 5 99.240 Chart 5. Bresenham's Circle Rendering through III. CONCLUSION In this paper, there are two section of different performance analysis on OpenGL. Three algorithms are used to render lines, two algorithms are used to render circles pixel by pixels. In our test and analysis, we measures actual execution time for rendering objects on the screen by Light Weight Java Game Library. By this analysis we can develop large level graphics applications like high definition games and many more. Thus JWJGL, a java programming binding for OpenGL seems to be a better choice for developing games and other graphics applications where achieving as high performance as possible is the main priority. IV. FUTURE WORK Computer graphics is used today in many different areas of industry, business, government, education, entertainment, and most recently, the home. The list of applications is enormous and is growing rapidly as computers with graphics Capabilities become commodity products. OpenGL is presently used to produce both accurate and schematic representations of geographical and other natural phenomena from measurement data. Examples include geographic maps, relief maps, exploration maps for drilling and mining, oceanographic charts, weather maps, contour maps, and population-density maps. These algorithms for object drawings probably to create 2D and 3D graphs of mathematical, physical, and 780

economic functions; histograms, bar and pie charts, task-scheduling charts, inventory and production charts. V. REFERENCES [1]. Development of the Bresenham s Line Algorithm, Alfred L. McKinney, K.K. Agarwal, Department og Computer Science, Louisiana state university in Shreveport, Shreveport, LA 71115 [2]. A Fast Bresenham Type Algorithm For Drawing Circles by John Kennedy Mathematics Department Santa Monica College 1900 Pico Blvd. Santa Monica, CA 90405. [3]. Textures, http://thecodinguniverse.com/lwjgl-textures/ [4]. Computer Graphics, Principles and Practice, Second Edition, by James D.Foley, Andries van Dam, Steven K. Feiner, John F. Hughes, Addison- Wesley [5]. Improved Line Drawing Algorithm: An Approach and Proposal, Muhammad.Usman khan & Prof (Dr) Md.Rizwan Beg, Integral University Lucknow, India. [6]. Prof. Sukhendu Das Dept. of Computer Science and Engineering Indian Institute of Technology, Madras Lecture - 13 Scan Converting Lines, Circles and Ellipses. [7]. OpenGL Programming Guide: The Official Guide to Learning OpenGL, Version 2 by Dave Shreiner [8]. Learning Java Bindings for OpenGL (JOGL) by Gene Davis [9]. Volume Rendering Using OpenGL and Extensions, M. Meissner ; U. Hoffmann ; W. Strasser, IEEE, 1070-2385 781