0% found this document useful (0 votes)
15 views4 pages

Lab Report 3

Uploaded by

dmaa357
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)
15 views4 pages

Lab Report 3

Uploaded by

dmaa357
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/ 4

DEPARTMENT OF COMPUTER SCIENCE AND

ENGINEERING

Lab Report-6

Course Title: Computer Graphics Lab


Course Code: CSE 422

Submitted by

Name: Din Mohammad Al Amin


Id: 201311044
Batch No: 23rd
Semester: 10th
Section: A

Submitted to Submitted to

Sabina Yasmin Ayesha Akter Lima


Assistant professor, Lecturer,
Department of CSE, Department of CSE,
Varendra University Varendra University
Question: Bresenham's Line Generation
Algorithm.

Code:
#include<windows.h>
#include<GL/glut.h>
#include<iostream>
void display()
{
glClear(GL_COLOR_BUFFER_BIT);
glBegin(GL_LINES);
glColor3f(1.0f, 0.0f, 0.0f);
glVertex2f(-1.0,0.0);
glVertex2f(1.0,0.0);
glVertex2f(0.0,1.0);
glVertex2f(0.0,-1.0);
glEnd();
double x1=0.2,y1=0.2,x2=1.0,y2=1.0;
double temp;
if (x1>x2)
{
temp=x1;
x1=x2;
x2=temp;
}
double x=x1;
double y=y1;
double m=(y2-y1)/(x2-x1);
double b=y-(m*x);
while(x<=x2)
{
glPointSize(7.0);
glBegin(GL_POINTS);
glColor3f(1,0,0);
glVertex2f(x,y);
x=x+0.1;
y=(m*x)+b;
glEnd();
glFlush();
}
}
int main(int argc, char *argv[])
{
glutInit(&argc,argv);
glutInitWindowSize(640,480);
glutInitWindowPosition(10,10);
glutInitDisplayMode(GLUT_RGB|GLUT_SINGLE|GLUT_DEPTH);
glutCreateWindow("POINT");
glutDisplayFunc(display);

glutMainLoop();
return EXIT_SUCCESS;
}
Output:

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy