answersLogoWhite

0

Here is the C code for DDA line drawing...

#include<stdio.h>

#include<conio.h>

#include<graphics.h>

#include<math.h>

void main()

{

int gd, gm;

float x, y, dx, dy, len;

int x1, y1, x2, y2, i;

detectgraph(&gd, &gm);

initgraph(&gd, &gm,"");

printf("\n Enter the coordinates of line : ");

scanf("%d %d %d %d", &x1, &y1, &x2, &y2);

dx = abs(x2-x1);

dy = abs(y2-y1);

if (dx >= dy) len = dx;

else len = dy;

dx = (x2-x1)/len;

dy = (y2-y1)/len;

x = x1 + 0.5;

y = y1 + 0.5;

i = 1;

while (i <= len)

{

putpixel(x, y, 6);

x = x+dx;

y = y+dy;

i++;

}

getch();

}

-Suraj.

User Avatar

Wiki User

16y ago

What else can I help you with?

Related Questions

Where can you find source code of heap sort in OpenGL?

Heap sort is not directly related to OpenGL, as it is a sorting algorithm rather than a graphics API. However, you can find implementations of heap sort in various programming languages on platforms like GitHub or in educational resources about algorithms. If you're looking for sorting within an OpenGL context (e.g., sorting vertices or pixels), you may find relevant code snippets or examples in OpenGL tutorials or graphics programming books that implement sorting algorithms.


Opengl programming source code for pool game?

writ an opengl program for pool game


Color-code for saffron using opengl?

In OpenGL, saffron can be approximated using an RGB color code, typically represented as a bright yellow-orange hue. A common RGB value for saffron is (255, 204, 51), which corresponds to a vibrant yellow with a hint of orange. To use this in OpenGL, you would set the color using glColor3f(1.0f, 0.8f, 0.2f);, normalizing the RGB values to the range of 0.0 to 1.0. Adjustments may be made depending on the desired visual effect or lighting conditions.


The code 11110101101 was received Using Hamming encoding method 2 what is the original code sent?

the code 11110101101 was received using hamming encoding algorithm what was the original code sent


Matlab code for filters using LMS algorithm?

http://www.mathworks.com/matlabcentral/fileexchange/3649


Java source code for median filter algorithm?

research is going on to develop a source code for median filtering using java


What are the ways representing an algorithm?

You can represent an algorithm by three different ways: 1. Pseudo Code 2. Structured flow charts 3. Actual code


How can i find the version of shader i have?

To find the version of the shader you have, you can typically check the graphics API documentation or your graphics card settings. On Windows, you can use tools like DirectX Diagnostic Tool (dxdiag) or OpenGL Extensions Viewer for OpenGL shaders. Alternatively, you can run a shader code snippet that retrieves the version using GLSL (OpenGL) or HLSL (DirectX) commands to print the shader version in your application.


What is the difference between implementation and algorithm?

An algorithm is a instruction for solving a problem. It is typically illustrated using prose, pseudo code or flowcharts, but other methods exist. The algorithm is the "here's how it's going to work" part of the solution. An implementation (of an algorithm) is a specific expression of this algorithm, using a specific programming language or any other suitable means. The implementation is the "here's how I've done it" part of the solution.


Free car competition sample code on opengl animation?

coding for car animation in open gl


Can someone provide the C program for Prim's algorithm?

The C code for Prim's algorithm can be found in the following link. https://sites.google.com/site/itstudentjunction/lab-programming-solutions/data-structures-programs/program-to-find-minimal-spanning-tree-using--prims-algorithm


What is A algorithm in AI?

A algorithm in artificial intelligence is a line of code meant to simulate a human emotion.