Hello world
I am looking for a ready C program that plot a math
curve, say for example y = sin(x); using the SDL library
This is a discussion on curve in C & SDL within the C Programming forums, part of the General Programming Boards category; Hello world I am looking for a ready C program that plot a math curve, say for example y = ...
Hello world
I am looking for a ready C program that plot a math
curve, say for example y = sin(x); using the SDL library
Are you ready enough to have read through the example programs on the SDL home page?
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.
I support http://www.ukip.org/ as the first necessary step to a free Europe.
There's also an SDL forum you can find via the SDL homepage.
C programming resources:
GNU C Function and Macro Index -- glibc reference manual
The C Book -- nice online learner guide
Current ISO draft standard
CCAN -- new CPAN like open source library repository
3 (different) GNU debugger tutorials: #1 -- #2 -- #3
cpwiki -- our wiki on sourceforge
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).
If you just want someone to write the code for you, try "rent-a-coder".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; }
Last edited by MK27; 01-22-2010 at 11:36 AM.
C programming resources:
GNU C Function and Macro Index -- glibc reference manual
The C Book -- nice online learner guide
Current ISO draft standard
CCAN -- new CPAN like open source library repository
3 (different) GNU debugger tutorials: #1 -- #2 -- #3
cpwiki -- our wiki on sourceforge
Oh, well, if it's urgent, then that puts a whole different slant on it.
How To Ask Questions The Smart Way
Rhett
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.
I support http://www.ukip.org/ as the first necessary step to a free Europe.
1 MB excuses, for you Salem and our smart guy, for my bugs; I try later to learn the synthax.
thanks, only , to Epy, but the MathGL is a C++ lib.
Hé smart guy, wait a minute, can you talk the admin to delete few records...