Last one month I use C++ programming language. This C++ will be completely based on the OOP's ( Object oriented Programming ) Language. Now, I need some code that help to plot a sine wave using a OpenGL between two points in a C++ program.
Last one month I use C++ programming language. This C++ will be completely based on the OOP's ( Object oriented Programming ) Language. Now, I need some code that help to plot a sine wave using a OpenGL between two points in a C++ program.
For doing this complicated task you need to follow the below code.
// all initialization have been done before calling GlDraw()
void GLDraw()
{
int p;
const maximum = 200;
float r;
glColor3f(0.1f, 0.1f, 0.1f);
glPointSire(4);
//If you need to draw points plot
//Draw points
glBegin(GL_POINTS);
for (p=0; p<maximum; p++)
r = sin((float) p/20)
glVertex3d(p, 0, r);
glEnd();
//If you need a lines plot
//Draw lines
glBegin(GL_LINE_STRIP);
for (p=0; p<maximum; p++) {
r = sin((float)p/20);
glVertex3d(p, 0, r)
}
glEnd();
}
this is the special code and it help to compute points coordinates and plot them on the screen.
I use this code and when I try to compile this code, then I found so many error messages. This code also gives the warning messages. Then I read the basic syntax of the code. Hence I found the correct syntax which is present in the OpenGL that is Open Graphics library. This OpenGL is really help to do such complicated task., hence I think you need to read this OpenGlL for doing such complicated task. Use this and solve the error present in this program. This is really help to you for solving the error and also plot the sine wave on it.
I think there will be some code missing in this program and hence this will be gives the problem. Then I suggest you to insert the following code for doing such task. Hence, check the initialization function of the program. This function use to initialize the variable of the program. Then use the init() function and then initialize OpenGl variables. Few method such as
glFrustum(-40, 40, -40, 40, 100, 2500);
glMatrixMode(GL_MODELVIEW);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glTranslated(0, -50, -300);
will be help to make some changes on the code and in the result the sine wave of the program will be display in the different manner. Then use this code and it help to you for solving the problem.
Now the official site of the OpenGL is available on the internet site. Then you need to just use this official site and then it help to run the code. This code is completely based on the graphics and you need to just read the function present in the OpenGL. The site provides the complete function of this code. Then use this site and it will be hope to built the program. This program is to be syntax error free and this will be help to you for solving the problem.
This is the 2D sine wave program and if you want to build the 3D sine wave, then you need to read the official site of the C++ language. This is the best way to solve the problem. Then just read the method as well as the supporting inbuilt function of the C++ and it will be help to you for building the 3D sine wave. Then use this 3D compatible method and it will help to you for solving the problem. The header will be necessary in this program.
Honestly, I will suggest you that many program present over the internet site. This program will be help to generate the sine wave using this OpenGL. You need to execute this code and this will be help to understand the basic syntax of the method. Then check the method syntax and then replace if anything wrong on this code. This will be help to solve the error of the program. The header files of the program must necessary in this code. This header file helps to provide the syntax to the compiler.
Bookmarks