/***************************************************************************
* Copyright (C) 2008 by Lorenzo La Porta *
* lorelapo@gmail.com *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <stdio.h>
#include <stdlib.h>
#include <SDL.h>
#include "SDL_gfxPrimitives.h"
#include <math.h>
#define WIDTH 800
#define HEIGHT 600
#define BPP 4
#define DEPTH 32
#define SIGMA 10
#define R 26
#define B (8./3.)
float x=10., y=10., z=10., t=0., k=10.;
void repaint(SDL_Surface *srf)
{
float tx, ty, tz;
tx=x;
ty=y;
tz=z;
x=tx+0.01*SIGMA*(ty-tx);
y=ty+0.01*(-x*z+R*x-y);
z=tz+0.01*(x*y-B*z);
t+=0.01;
lineRGBA(srf,(int)(tx*k)+WIDTH/2,HEIGHT/2-(int)(ty*k),(int)(x*k)+WIDTH/2,HEIGHT/2-(int)(y*k),0xFF-(int)(t*11.0),0xFF-(int)(t*10.0),0xFF-(int)(t),0xFF-(int)(t*9.1));
}
int main(int argc, char* argv[])
{
SDL_Surface *screen;
SDL_Event event;
int keypress = 0;
if (SDL_Init(SDL_INIT_VIDEO) < 0 ) return 1;
if (!(screen = SDL_SetVideoMode(WIDTH, HEIGHT, DEPTH, SDL_HWACCEL/*|SDL_FULLSCREEN*/|SDL_HWSURFACE)))
{
SDL_Quit();
return 1;
}
while(!keypress)
{
repaint(screen);
SDL_Flip(screen);
while(SDL_PollEvent(&event))
{
switch (event.type)
{
case SDL_QUIT:
keypress = 1;
break;
case SDL_KEYDOWN:
switch(event.key.keysym.sym)
{
case SDLK_ESCAPE:
keypress = 1;
break;
case SDLK_F11:
SDL_WM_ToggleFullScreen(screen);
break;
default:
printf("Reached unknown keydown event.\n");
}
break;
default:
;
}
}
}
SDL_SaveBMP(screen,"SDLscreenONEXITSAVE.bmp");
SDL_FreeSurface(screen);
SDL_Quit();
return 0;
}