Upload
vulliem
View
983
Download
2
Embed Size (px)
DESCRIPTION
OpenGL and C++ programming
Citation preview
Bresenham Line Algorithm Using OpenGL and C++ | CSE ENGINEERS
http://engineersview.wordpress.com/2013/05/21/bresenham-line-algorithm-using-opengl-and-c/[11/02/2014 19:59:53]
CSE ENGINEERSAl Hizbul Bahar
Home OpenGL Bresenham Line Algorithm Using OpenGL and C++
Bresenham Line Algorithm Using OpenGL and C++Posted on May 21, 2013 by Al Hizbul Bahar Leave a comment
Bresenham Line Algorithm Using OpenGL and C++.
// bresenham_line_algorithm.cpp : Defnes the entry point for the console application.
//
#include "stdafx.h"
#include "GL/glut.h";
foat x1,x2,y1,y2,b=0;
void setPixel(int x, int y)
{
Home About Me
PHP cake php JAVA Python WordPress OpenGL Linux/Ubuntu
Follow
Bresenham Line Algorithm Using OpenGL and C++ | CSE ENGINEERS
http://engineersview.wordpress.com/2013/05/21/bresenham-line-algorithm-using-opengl-and-c/[11/02/2014 19:59:53]
glBegin(GL_POINTS);
glVertex2i(x,y);
glEnd();
glFlush();
}
void horizontal()
{
if(x1>x2)
{
foat temp;
temp = x1;
x1 = x2;
x2 = temp;
}
for(foat x=x1; xy2)
{
foat temp;
temp = y1;
y1 = y2;
y2 = temp;
}
for(foat y=y1; yx2)
{
foat temp;
temp = x1;
x1 = x2;
x2 = temp;
temp = y1;
y1 = y2;
Follow CSE ENGINEERS
Get every new post delivered to your Inbox.
Powered by WordPress.com
Bresenham Line Algorithm Using OpenGL and C++ | CSE ENGINEERS
http://engineersview.wordpress.com/2013/05/21/bresenham-line-algorithm-using-opengl-and-c/[11/02/2014 19:59:53]
y2 = temp;
}
int x = x1, y = y1;
int dx = x2-x1;
int dy = y2-y1;
int dT = 2*(dy-dx);
int dS = 2*dy;
int d = 2*dy-dx;
setPixel(x,y);
while(x
Bresenham Line Algorithm Using OpenGL and C++ | CSE ENGINEERS
http://engineersview.wordpress.com/2013/05/21/bresenham-line-algorithm-using-opengl-and-c/[11/02/2014 19:59:53]
setPixel(x,y);
while(x
Bresenham Line Algorithm Using OpenGL and C++ | CSE ENGINEERS
http://engineersview.wordpress.com/2013/05/21/bresenham-line-algorithm-using-opengl-and-c/[11/02/2014 19:59:53]
{
x++;
d = d+dT;
}
setPixel(x,y);
}
setPixel(x2,y2);
}
void bresenham4()
{
if(y1>y2)
{
foat temp;
temp = x1;
x1 = x2;
x2 = temp;
temp = y1;
y1 = y2;
y2 = temp;
}
int x = x1, y = y1;
int dx = x2-x1;
int dy = y2-y1;
int dT = 2*(dy+dx);
int dS = 2*dx;
int d = -(2*dy+dx);
setPixel(x,y);
while(y
Bresenham Line Algorithm Using OpenGL and C++ | CSE ENGINEERS
http://engineersview.wordpress.com/2013/05/21/bresenham-line-algorithm-using-opengl-and-c/[11/02/2014 19:59:53]
void myMouse(int button, int state, int x, int y)
{
if(button == GLUT_LEFT_BUTTON && state == GLUT_DOWN)
{
if(b==0)
{
x1 = x;
y1 = 480-y;
b = 1;
}
else if(b==1)
{
x2 = x;
y2 = 480-y;
b = 0;
if(y1==y2) horizontal();
else if(x1==x2) vertical();
foat m = (y2-y1)/(x2-x1);
if(0-1) bresenham2();
else if(1m) bresenham4();
}
}
}
void myDisplay(void)
{
glClearColor(1.0,1.0,1.0,0.0);
glColor3f(1.0,0.0,0.0);
gluOrtho2D(0.0,640.0,0.0,480.0);
glClear(GL_COLOR_BUFFER_BIT);
glutMouseFunc(myMouse);
glFlush();
}
int _tmain(int argc, char** argv)
{
glutInitWindowSize(640,480);
glutInitWindowPosition(100, 100);
glutCreateWindow ("A simple Line");
glutDisplayFunc(myDisplay);
glutMainLoop ( );
Bresenham Line Algorithm Using OpenGL and C++ | CSE ENGINEERS
http://engineersview.wordpress.com/2013/05/21/bresenham-line-algorithm-using-opengl-and-c/[11/02/2014 19:59:53]
Bresenham Circle Algorithm Using OpenGL and C++
Car Workshop(Multi Server Queuing) Simulation Using Java
return 0;
}
To get complete code and project contact with me through email , mobile. You may commented below as your requirement.
Share this:
Twitter Facebook
About Al Hizbul Bahar
Junior Software Engineer at Nascenia IT , Dhaka , Bangladesh
Tagged with: Bresenham algorithm, OpenGL
Posted in OpenGL
Leave a Reply
Related
DDA Line Drawing Algorithm Using OpenGL and C++
Bresenham Circle Algorithm Using OpenGL and C++
Lexical Analysis in Compiler Design Using Java
In "OpenGL" In "OpenGL" In "JAVA"
Bresenham Line Algorithm Using OpenGL and C++ | CSE ENGINEERS
http://engineersview.wordpress.com/2013/05/21/bresenham-line-algorithm-using-opengl-and-c/[11/02/2014 19:59:53]
ArchivesJanuary 2014December 2013November 2013September 2013July 2013June 2013May 2013April 2013
My Cloud
Algorithm array banker's algorithm Binary Search Bresenham algorithm c++ cakephp Compiler country array cpu scheduling data insert Factorial Fibonacci First Follow framework GCD image to binary ip address java Javascript lamp Lexical Analysis linux comm linux command MANET Multi Server nam ns2 OpenGL OS paypal php php framework prime Prime number Pyramid python shortest path simulation single server sql ubuntu12.04 user login user registration validation wirelessnetwork wordpress youtube
Popular Posts & PagesCPU Scheduling Algorithm using JavaBresenham Line Algorithm Using OpenGL and C++Install ns2 in Ubuntu 12.04 LTSImage to binary and binary to image conversion in phpSimple registration in CakePHPBanker's Algorithm Using JavaDDA Line Drawing Algorithm Using OpenGL and C++Simulation of Single Server Queuing SystemUser Login in CakePHPBresenham Circle Algorithm Using OpenGL and C++
CSE Engineers
CSE Engineers
Bresenham Line Algorithm Using OpenGL and C++ | CSE ENGINEERS
http://engineersview.wordpress.com/2013/05/21/bresenham-line-algorithm-using-opengl-and-c/[11/02/2014 19:59:53]
2014 CSE ENGINEERS Blog at WordPress.com.| The Responsive Theme.
102 people like CSE Engineers.
Facebook social plugin
Like
wordpress.comBresenham Line Algorithm Using OpenGL and C++ | CSE ENGINEERS
11c2luZy1vcGVuZ2wtYW5kLWMvAA==: form3: email: Enter your email addressinput0: comment:
11c2luZy1vcGVuZ2wtYW5kLWMvAA==: form1: s: search here submit:
ZhbHNlJmZvcmNlX3dhbGw9ZmFsc2UA: form0: button0: