[C con Clase] SDL 2

Hl3 halowin3 en gmail.com
Dom Nov 10 20:48:24 CET 2013


Hola Asdruba, gracias por responder.
Lo acabo de conseguir, dejo aqui el programa por si le puede ayudar a alguien.

#include <stdio.h>
#include <SDL2/SDL.h>
//#include <SDL2/SDL_image.h>
#include<math.h>


#define PI 3.141592
#define SCREEN_WIDTH 640
#define SCREEN_HEIGHT 480

int main(int argc, char **argv){
	int x,y;
	double fx,angulo;
//	Uint8* posicion;
	Uint32 color;
	
	SDL_Window *win = SDL_CreateWindow("y=sin(x)", 100,100, 640, 480, 0);

	
//	SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_INFORMATION,"info", "Window creada",win);	
	SDL_Renderer *ren = SDL_CreateRenderer(win, -1,	SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC);

	/* Create surface */
	SDL_Surface *surface = SDL_CreateRGBSurface(0,SCREEN_WIDTH,SCREEN_HEIGHT,32,0,0,0,0);
	
	//get the pixels
	Uint32 *pixels = (Uint32*)surface->pixels;
	
	/* Lock the surface */
	SDL_LockSurface(surface);
	
	color = SDL_MapRGB(surface->format, 255, 0, 0);
	for(x=0;x<360;x++){
		angulo=x*PI/180;
		fx=240+50*sin(angulo);
		y=round(fx);
		pixels[ ( y * surface->w ) + x ] = color; 
	}
	
	/* Unlock the surface */
	SDL_UnlockSurface(surface);
	
	//imprescindible
	SDL_Texture *tex = SDL_CreateTextureFromSurface(ren, surface);	
	SDL_RenderCopy(ren,tex,NULL,NULL);
	
	//imprescindible
	SDL_RenderPresent(ren);
			
	SDL_Delay(10000);
		
  return 0;

}


Más información sobre la lista de distribución Cconclase