0% found this document useful (0 votes)
2 views2 pages

Lab6

Uploaded by

kwllaSa21
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views2 pages

Lab6

Uploaded by

kwllaSa21
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Lab – 6: (Line Drawing – Bresenham’s Line Algorithm)

Write a program using WebGL to implement bresenham’s line drawing algorithm.

Step 1 − The program should accept two points, the starting point (x1, y1) and the ending point
(x2, y2) as an input. To accomplish this, you have to create four input boxes as shown in the
screenshot below.

Step 2 − Create a button with click event. When the user clicks the draw button, the program will
execute a function called drawLine.

Step 3 − The drawLine function should follow the bresenham’s line drawing algorithm
explained in chapter 5.
Step 4 − Create and compile Shader programs
We write vertex shader and fragment shader programs, compile them, and create a combined
program by linking these two programs.
Step 5 − Associate the shader programs with buffer objects
We associate the buffer objects and the combined shader program.
Step 6 − Drawing the required object

Exercise:

Modify the sample program provided (drawBresenham.html) so that it can handle the following
scenarios:

If m > 1 If m = 1

Reference

Interactive Computer Graphics: A Top Down Approach with WebGL

You might also like