Latest Movie :
Home » » Write a Program in c/c++ using Open GL that draws Digital Signal/Wave

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;
}



Share this article :

Post a Comment

poower
 
Support : Creating Website | mayank | Mas Template
Copyright © 2009. Auditor Link - All Rights Reserved
Template Created by Creating Website Published by salman
Proudly powered by videos