Originally Posted by
lazakal
yes Salem , enough to understand the code, my pb is having an urgent need to do numerical analysis, not to start learning SDL.
How are you going to do this, using SDL, without learning SDL? If you are okay with C, I am sure it will not take you more than 4-10 hours to figure this out. If you are no good with C, then just looking at someone else's example will not help you (and I am positive there are a ton of such examples available on the web anyway). Altho actually drawing a 2D curve using trig is dead simple, graphics libraries are not completely trivial to initialize and use.
Since you haven't started yet, I'd recommend openGL instead for stuff like this (just an opinion).
Code:
#include <GL/gl.h>
#include <GL/glu.h>
#include <GL/glut.h>
#include <GL/glext.h>
#include <stdio.h>
#include <math.h>
#define VOL 100
#define GL_PI 3.1415f
void scene() {
GLfloat i;
glClear(GL_COLOR_BUFFER_BIT);
glColor4f(1.0f,0.0f,0.0f,1.0f);
glPointSize(10.0f);
glBegin(GL_POINTS);
glVertex3i(0,0,0);
glEnd();
glColor4f(1.0f,1.0f,1.0f,1.0f);
glPointSize(2.0f);
glBegin(GL_POINTS); /* creates an oval */
for (i=0.0; i<(2.0*GL_PI); i+=0.1) glVertex3f(sin(i)*20.0,cos(i)*10.0,0.0);
glEnd();
glutSwapBuffers();
}
void setup(float R, float G, float B) {
GLdouble N=0-VOL;
glClearColor(R,G,B,1.0f);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(N,VOL,N,VOL,N,VOL);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
}
int main(int argc, char *argv[]) {
glutInit(&argc,argv);
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH);
glutInitWindowSize(600,600);
glutCreateWindow("openGL test");
glutDisplayFunc(scene);
setup(0.0,0.0,0.0);
glutMainLoop();
return 0;
}
If you just want someone to write the code for you, try "rent-a-coder".