Kaynağa Gözat

* Added rotozoom (and its 1MB header file)

tags/v0.99.beta14
Jean-Yves Lamoureux jylam 17 yıl önce
ebeveyn
işleme
f03911b212
3 değiştirilmiş dosya ile 116 ekleme ve 2 silme
  1. +1
    -1
      src/Makefile.am
  2. +113
    -1
      src/cacademo.c
  3. +2
    -0
      src/texture.h

+ 1
- 1
src/Makefile.am Dosyayı Görüntüle

@@ -8,7 +8,7 @@ AM_CPPFLAGS = -I$(top_srcdir) -I$(top_srcdir)/cucul -I$(top_srcdir)/caca -DLIBCA
bin_PROGRAMS = cacademo cacafire cacaplay cacaview img2irc $(fcntl_programs)
noinst_PROGRAMS = cacadraw

cacademo_SOURCES = cacademo.c
cacademo_SOURCES = cacademo.c texture.h
cacademo_LDADD = ../caca/libcaca.la ../cucul/libcucul.la
cacademo_LDFLAGS = @MATH_LIBS@



+ 113
- 1
src/cacademo.c Dosyayı Görüntüle

@@ -38,14 +38,16 @@ void metaballs(enum action, cucul_canvas_t *);
void moire(enum action, cucul_canvas_t *);
void langton(enum action, cucul_canvas_t *);
void matrix(enum action, cucul_canvas_t *);
void rotozoom(enum action, cucul_canvas_t *);

void (*fn[])(enum action, cucul_canvas_t *) =
{
plasma,
metaballs,
moire,
//langton,
/*langton,*/
matrix,
rotozoom,
};
#define DEMOS (sizeof(fn)/sizeof(*fn))

@@ -838,3 +840,113 @@ void matrix(enum action action, cucul_canvas_t *cv)
}


#define TEXTURE_SIZE 256
#define TABLE_SIZE 65536

/* 24:8 Fixed point stuff */
#define PRECISION 8

#define FMUL(a, b) (((a)*(b))>>PRECISION)
#define TOFIX(d) ((int)( (d)*(double)(1<<PRECISION) ))
#define TOINT(a) (a>>PRECISION);


#include "texture.h"

void rotozoom(enum action action, cucul_canvas_t *canvas)
{
static cucul_dither_t *dither;
static unsigned int *screen, *save;
static int alphaF, tF;
int scaleF;
static int *texture;
static int *cosTable;
static int *sinTable;
static int *yTable;



/* register is quite a bad idea on CISC, but not on RISC */
register unsigned int x, y;
register unsigned int xxF, yyF, uF, vF, uF_, vF_;
register unsigned int vu, vv;

switch(action)
{
case INIT:

screen = (unsigned int*)malloc(4 * XSIZ * YSIZ
* sizeof(unsigned char));
dither = cucul_create_dither(32,
XSIZ, YSIZ,
XSIZ*4,
0x00FF0000,
0x0000FF00,
0x000000FF,
0x00000000);
save = screen;
texture = (int*) textureByte;

cosTable = malloc(TABLE_SIZE*sizeof(int));
sinTable = malloc(TABLE_SIZE*sizeof(int));
yTable = malloc(TEXTURE_SIZE*sizeof(int));

for(x=0; x<TABLE_SIZE; x++) { /* Cos and Sin tables*/
cosTable[x] = TOFIX(cos(x*(360.0f/(float)TABLE_SIZE)));
sinTable[x] = TOFIX(sin(x*(360.0f/(float)TABLE_SIZE)));
}
for(x=0; x<TEXTURE_SIZE; x++) { /* start of lines offsets */
yTable[x] = x*TEXTURE_SIZE;
}

break;
case PREPARE:
break;
case UPDATE:

alphaF += 4;
tF += 3;
scaleF = (FMUL(sinTable[tF&0xFFFF], TOFIX(3)) + (TOFIX(5)));
xxF = FMUL(cosTable[(alphaF)&0xFFFF], scaleF);
yyF = FMUL(sinTable[(alphaF)&0xFFFF], scaleF);
uF = vF = 0;
uF_ = vF_ = 0;
screen = save;

y = YSIZ;
while(y--) {

x = XSIZ;
while(x--) {

uF+=xxF;
vF+=yyF;

vu = TOINT(uF);
vv = TOINT(vF);
vu&=0xFF; /* ARM doesn't like */
vv&=0xFF; /* chars as local vars */

*screen++ = texture[vu+yTable[vv]];
}

uF = uF_ -= yyF;
vF = vF_ += xxF;
}

break;
case RENDER:
cucul_dither_bitmap(canvas, 0, 0,
cucul_get_canvas_width(canvas),
cucul_get_canvas_height(canvas),
dither, save);
break;
case FREE:
free(cosTable);
free(sinTable);
free(save);
cucul_free_dither(dither);
break;
}

}

+ 2
- 0
src/texture.h
Dosya farkı çok büyük olduğundan ihmal edildi
Dosyayı Görüntüle


Yükleniyor…
İptal
Kaydet