瀏覽代碼

* src/math.c src/bitmap.c src/caca.h Removed powf call, added caca_powf, to remove libm depencies and problems on old compilers/linkers.

tags/v0.99.beta14
Jean-Yves Lamoureux jylam 19 年之前
父節點
當前提交
4ce99f0aff
共有 3 個檔案被更改,包括 25 行新增2 行删除
  1. +1
    -2
      src/bitmap.c
  2. +1
    -0
      src/caca.h
  3. +23
    -0
      src/math.c

+ 1
- 2
src/bitmap.c 查看文件

@@ -45,7 +45,6 @@ typedef unsigned int uint32_t;
#include <stdlib.h>
#include <limits.h>
#include <string.h>
#include <math.h>

#include "caca.h"
#include "caca_internals.h"
@@ -338,7 +337,7 @@ void caca_set_bitmap_gamma(struct caca_bitmap *bitmap, float gammaval)
bitmap->gammaval = gammaval;

for(i = 0; i < 4096; i++)
bitmap->gammatab[i] = 4096.0 * powf((float)i / 4096.0, 1.0 / gammaval);
bitmap->gammatab[i] = 4096.0 * caca_powf((float)i / 4096.0, 1.0 / gammaval);
}

/**


+ 1
- 0
src/caca.h 查看文件

@@ -317,6 +317,7 @@ void caca_fill_triangle(int, int, int, int, int, int, char);
* @{ */
int caca_rand(int, int);
unsigned int caca_sqrt(unsigned int);
float caca_powf(float x, float y);
/* @} */

/** \defgroup sprite Sprite handling


+ 23
- 0
src/math.c 查看文件

@@ -78,3 +78,26 @@ unsigned int caca_sqrt(unsigned int a)
return 2 * caca_sqrt(a / 4);
}


/**
* \brief powf substitute (x^y)
* \param x The value to be raised
* \param y The power to raise x of.
* \return \p x raised to the power of \p y
*/

float caca_powf(float x, float y)
{
int i=((int)y);
float r=x;

if(((int)y)==1 || ((int)x)==1)
return x;

i--;
while(i--)
{
r*=x;
}
return r;
}

Loading…
取消
儲存