Pages

Subscribe:

Write a Program in c/c++ using Open GL that draws Digital Signal/Wave





#include <stdio.h>
#include <conio.h>
#include <iostream.h>
#include <stdlib.h>
#include <glut.h>


#define WINW 800
#define WINL 600

float xmap(int x)
{
 float halfw,fx;
    halfw = (float)WINW/2;
 fx = (x)/halfw;
 return fx;
}

float ymap(int y)
{
 float halfy,fy;
    halfy = (float)WINL/2;
 fy = (y)/halfy;
 return fy;
}


void setup()
{
 glClearColor(0.0f,0.0f,0.0f,0.0f);
 glClear(GL_COLOR_BUFFER_BIT);
 glutSwapBuffers();
}


void display()
{
 int i;
    
 for(i=1;i<=3;i++)
 {
       glBegin(GL_LINE_STRIP);
       glColor3f(1.0f,1.0f,1.0f);

    glVertex3f(xmap(0),ymap(0),0.0f);
    glVertex3f(xmap(0),ymap(100),0.0f);
    glVertex3f(xmap(50),ymap(100),0.0f);
          glVertex3f(xmap(50),ymap(0),0.0f);
          glVertex3f(xmap(150),ymap(0),0.0f);
       glEnd();
    glutSwapBuffers();
    glTranslatef(xmap(150),0.0f,0.0f);
 }
}


int main(int argc,char * argv[])
{
 glutInitDisplayMode(GLUT_RGB | GLUT_DEPTH | GLUT_DOUBLE);
 glutInitWindowSize(WINW,WINL);
 glutCreateWindow("123techguide.blogspot.com");

 setup();
 glutDisplayFunc(display);

 glutMainLoop();
 getch();

 return 0;
}
comments powered by Disqus
 

Listed In

Bloggers - Meet Millions of Bloggers http://Link-exchange.comxa.com
Blog Search: The Source for Blogs Internet Blogs

Disclaimer

The contents in this blog are taken from various sources available over the internet, therefore we do not gurantee of it's accuracy, if you find any of the content in the blog is infringing it's copyright, please do email us on '123techguide@gmail.com' and we will make sure to remove the same from the blog at the earliest.