Tags » OpenGL

DDA LIne algorithm using OpenGL

Digital Differential Analyzer (DDA)

<br />#include<GL/glut.h>
#include<stdlib.h>
#include<stdio.h>
float x1,x2,y1,y2;

void display(void)
{
float dy,dx,step,x,y,k,Xin,Yin;
dx=x2-x1;
dy=y2-y1;

if(abs(dx)> abs(dy))
{
step = abs(dx);
}
else
step = abs(dy);

Xin = dx/step;
Yin = dy/step;

x= x1;
y=y1;
glBegin(GL_POINTS);
glVertex2i(x,y);
glEnd();

for (k=1 ;k<=step;k++)
{
x= x + Xin;
y= y + Yin;

glBegin(GL_POINTS);
glVertex2i(x,y);
glEnd();
}


glFlush();
}

void init(void)
{
glClearColor(0.7,0.7,0.7,0.7);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluOrtho2D(-100,100,-100,100);
}

int main(int argc, char** argv) {
printf("Enter the value of x1 : ");
scanf("%f",&x1);
printf("Enter the value of y1 : ");
scanf("%f",&y1);
printf("Enter the value of x2 : ");
scanf("%f",&x2);
printf("Enter the value of y2 : ");
scanf("%f",&y2);

glutInit(&argc, argv);
glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB);
glutInitWindowSize (500, 500);
glutInitWindowPosition (100,100);
glutCreateWindow ("DDA Line Algo");
init();
glutDisplayFunc(display);
glutMainLoop();

return 0;
}

Output :-

Algo

OpenCV and OpenGL using Python

Arkwood was playing with one of those ball on a string attached to a wooden cup thingamajigs. ‘It’s tricky,’ he stated.

‘Not as tricky as computer vision and 3D graphics,’ I retorted. 1,106 more words

Technology

OpenGL Triangle

CLASSIC TRIANGLE WITH OPENGL…

To begin any C++ (or even just C) program, we need to include the headers that contain the function and class definitions that we will use in our program. 1,718 more words

OpenGL

OpenGL Geometry Test

GEOMETRY TESTS WITH OPENGL…

Here i will try to explain you graphical adjustments in opengl. We start with our includes as always: 2,320 more words

OpenGL

OpenGL Sphere World

OUR SPHERE WORLD

To begin any C++ (or even just C) program, we need to include the headers that contain the function and class definitions that we will use in our program. 5,975 more words

OpenGL

OpenGL Giriş

Merhaba; openGL’de bu makalemizde openGL içinde basit(=primitive) tiplerden birisi olan TRIANGLE_FAN kullanarak bir kare çizmeyi ve yön tuşları ile hareket ettirmeyi en temel fonksiyonları kullanarak nasıl gerçekleştirebileceğimize bakacağız. 3,702 more words

OpenGL

OpenGL Blending

BLENDING WITH OPENGL

You’ve already learned that OpenGL rendering places color values in the color buffer under normal circumstances. You also learned that depth values for each fragment are also placed in the depth buffer. 987 more words

OpenGL