2002-10-12 11:37:38 +00:00
|
|
|
/**
|
|
|
|
|
* $Id$
|
|
|
|
|
*
|
2008-04-16 22:40:48 +00:00
|
|
|
* ***** BEGIN GPL LICENSE BLOCK *****
|
2002-10-12 11:37:38 +00:00
|
|
|
*
|
|
|
|
|
* 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
|
2008-04-16 22:40:48 +00:00
|
|
|
* of the License, or (at your option) any later version.
|
2002-10-12 11:37:38 +00:00
|
|
|
*
|
|
|
|
|
* 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.
|
|
|
|
|
*
|
|
|
|
|
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
|
|
|
|
|
* All rights reserved.
|
|
|
|
|
*
|
|
|
|
|
* The Original Code is: all of this file.
|
|
|
|
|
*
|
|
|
|
|
* Contributor(s): none yet.
|
|
|
|
|
*
|
2008-04-16 22:40:48 +00:00
|
|
|
* ***** END GPL LICENSE BLOCK *****
|
2002-10-12 11:37:38 +00:00
|
|
|
* Wrappers for the plugin api. This api is up for removal.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/* There are four headers making up the plugin api:
|
|
|
|
|
* - floatpatch.h : Wraps math functions for mips platforms, no code
|
|
|
|
|
* required.
|
|
|
|
|
* - iff.h : Defines, macros and functions for dealing
|
|
|
|
|
* with image buffer things.
|
|
|
|
|
* - plugin.h : Wraps some plugin handling types, accesses noise
|
|
|
|
|
* functions.
|
|
|
|
|
* - util.h : Useful defines, memory management.
|
|
|
|
|
*/
|
|
|
|
|
|
2006-06-16 20:00:00 +00:00
|
|
|
#define PLUGIN_INTERN /* This tells the LIBEXPORT macro to compile with
|
|
|
|
|
dll export set on windows */
|
|
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
#ifdef WIN32
|
2006-03-13 11:42:49 +00:00
|
|
|
#include "blenpluginapi/util.h"
|
2002-10-12 11:37:38 +00:00
|
|
|
#else
|
2005-03-09 19:45:59 +00:00
|
|
|
#include "blenpluginapi/util.h"
|
2002-10-12 11:37:38 +00:00
|
|
|
#endif
|
|
|
|
|
#include "iff.h"
|
|
|
|
|
#include "plugin.h"
|
|
|
|
|
#include "MEM_guardedalloc.h"
|
|
|
|
|
|
|
|
|
|
#include "BLI_blenlib.h" /* util and noise functions */
|
2006-06-16 20:00:00 +00:00
|
|
|
#include "BLI_threads.h" /* For threadsfe guardedalloc malloc/calloc/free */
|
2002-10-12 11:37:38 +00:00
|
|
|
#include "IMB_imbuf.h" /* image buffer stuff */
|
|
|
|
|
|
|
|
|
|
/* -------------------------------------------------------------------------- */
|
|
|
|
|
/* stuff from util.h */
|
|
|
|
|
/* -------------------------------------------------------------------------- */
|
|
|
|
|
|
2006-06-16 20:00:00 +00:00
|
|
|
LIBEXPORT void *mallocN(int len, char *str)
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
|
|
|
|
return MEM_mallocN(len, str);
|
|
|
|
|
}
|
|
|
|
|
|
2006-06-16 20:00:00 +00:00
|
|
|
LIBEXPORT void *callocN(int len, char *str)
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
|
|
|
|
return MEM_callocN(len, str);
|
|
|
|
|
}
|
|
|
|
|
|
2006-06-16 20:00:00 +00:00
|
|
|
LIBEXPORT short freeN(void *vmemh)
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
|
|
|
|
return MEM_freeN(vmemh);
|
|
|
|
|
}
|
|
|
|
|
|
2006-09-06 19:13:23 +00:00
|
|
|
/* these are not needed anymore, mallocN/callocN/freeN is now threadsafe */
|
2006-06-16 20:00:00 +00:00
|
|
|
LIBEXPORT void *mallocT(int len, char *str)
|
|
|
|
|
{
|
2006-09-06 19:13:23 +00:00
|
|
|
return MEM_mallocN(len, str);
|
2006-06-16 20:00:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
LIBEXPORT void *callocT(int len, char *str)
|
|
|
|
|
{
|
2006-09-06 19:13:23 +00:00
|
|
|
return MEM_callocN(len, str);
|
2006-06-16 20:00:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
LIBEXPORT void freeT(void *vmemh)
|
|
|
|
|
{
|
2006-09-06 19:13:23 +00:00
|
|
|
MEM_freeN(vmemh);
|
|
|
|
|
return;
|
2006-06-16 20:00:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
/* -------------------------------------------------------------------------- */
|
|
|
|
|
/* stuff from iff.h */
|
|
|
|
|
/* -------------------------------------------------------------------------- */
|
|
|
|
|
|
2006-06-16 20:00:00 +00:00
|
|
|
LIBEXPORT struct ImBuf *allocImBuf(short x,
|
2002-10-12 11:37:38 +00:00
|
|
|
short y,
|
|
|
|
|
uchar d,
|
|
|
|
|
uint flags,
|
|
|
|
|
uchar bitmap)
|
|
|
|
|
{
|
|
|
|
|
return IMB_allocImBuf(x, y, d, flags, bitmap);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2006-06-16 20:00:00 +00:00
|
|
|
LIBEXPORT struct ImBuf *dupImBuf(struct ImBuf *ib)
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
|
|
|
|
return IMB_dupImBuf(ib);
|
|
|
|
|
}
|
|
|
|
|
|
2006-06-16 20:00:00 +00:00
|
|
|
LIBEXPORT void freeImBuf(struct ImBuf* ib)
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
|
|
|
|
IMB_freeImBuf(ib);
|
|
|
|
|
}
|
|
|
|
|
|
2006-06-16 20:00:00 +00:00
|
|
|
LIBEXPORT short converttocmap(struct ImBuf* ibuf)
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
|
|
|
|
return IMB_converttocmap(ibuf);
|
|
|
|
|
}
|
|
|
|
|
|
2006-06-16 20:00:00 +00:00
|
|
|
LIBEXPORT short saveiff(struct ImBuf *ib,
|
2002-10-12 11:37:38 +00:00
|
|
|
char *c,
|
|
|
|
|
int i)
|
|
|
|
|
{
|
|
|
|
|
return IMB_saveiff(ib, c, i);
|
|
|
|
|
}
|
|
|
|
|
|
2006-06-16 20:00:00 +00:00
|
|
|
LIBEXPORT struct ImBuf *loadiffmem(int *mem,int flags)
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
|
|
|
|
return IMB_loadiffmem(mem, flags);
|
|
|
|
|
}
|
|
|
|
|
|
2006-06-16 20:00:00 +00:00
|
|
|
LIBEXPORT struct ImBuf *loadifffile(int a,
|
2002-10-12 11:37:38 +00:00
|
|
|
int b)
|
|
|
|
|
{
|
|
|
|
|
return IMB_loadifffile(a, b);
|
|
|
|
|
}
|
|
|
|
|
|
2006-06-16 20:00:00 +00:00
|
|
|
LIBEXPORT struct ImBuf *loadiffname(char *n,
|
2002-10-12 11:37:38 +00:00
|
|
|
int flags)
|
|
|
|
|
{
|
|
|
|
|
return IMB_loadiffname(n, flags);
|
|
|
|
|
}
|
|
|
|
|
|
2006-06-16 20:00:00 +00:00
|
|
|
LIBEXPORT struct ImBuf *testiffname(char *n,
|
2002-10-12 11:37:38 +00:00
|
|
|
int flags)
|
|
|
|
|
{
|
|
|
|
|
return IMB_testiffname(n, flags);
|
|
|
|
|
}
|
|
|
|
|
|
2006-06-16 20:00:00 +00:00
|
|
|
LIBEXPORT struct ImBuf *onehalf(struct ImBuf *ib)
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
|
|
|
|
return IMB_onehalf(ib);
|
|
|
|
|
}
|
|
|
|
|
|
2006-06-16 20:00:00 +00:00
|
|
|
LIBEXPORT struct ImBuf *onethird(struct ImBuf *ib)
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
|
|
|
|
return IMB_onethird(ib);
|
|
|
|
|
}
|
|
|
|
|
|
2006-06-16 20:00:00 +00:00
|
|
|
LIBEXPORT struct ImBuf *halflace(struct ImBuf *ib)
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
|
|
|
|
return IMB_halflace(ib);
|
|
|
|
|
}
|
|
|
|
|
|
2006-06-16 20:00:00 +00:00
|
|
|
LIBEXPORT struct ImBuf *half_x(struct ImBuf *ib)
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
|
|
|
|
return IMB_half_x(ib);
|
|
|
|
|
}
|
|
|
|
|
|
2006-06-16 20:00:00 +00:00
|
|
|
LIBEXPORT struct ImBuf *half_y(struct ImBuf *ib)
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
|
|
|
|
return IMB_half_y(ib);
|
|
|
|
|
}
|
|
|
|
|
|
2006-06-16 20:00:00 +00:00
|
|
|
LIBEXPORT struct ImBuf *double_x(struct ImBuf *ib)
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
|
|
|
|
return IMB_double_x(ib);
|
|
|
|
|
}
|
|
|
|
|
|
2006-06-16 20:00:00 +00:00
|
|
|
LIBEXPORT struct ImBuf *double_y(struct ImBuf *ib)
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
|
|
|
|
return IMB_double_y(ib);
|
|
|
|
|
}
|
|
|
|
|
|
2006-06-16 20:00:00 +00:00
|
|
|
LIBEXPORT struct ImBuf *double_fast_x(struct ImBuf *ib)
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
|
|
|
|
return IMB_double_fast_x(ib);
|
|
|
|
|
}
|
|
|
|
|
|
2006-06-16 20:00:00 +00:00
|
|
|
LIBEXPORT struct ImBuf *double_fast_y(struct ImBuf *ib)
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
|
|
|
|
return IMB_double_fast_y(ib);
|
|
|
|
|
}
|
|
|
|
|
|
2006-06-16 20:00:00 +00:00
|
|
|
LIBEXPORT int ispic(char * name)
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
|
|
|
|
return IMB_ispic(name);
|
|
|
|
|
}
|
|
|
|
|
|
2006-06-16 20:00:00 +00:00
|
|
|
LIBEXPORT void dit2(struct ImBuf *ib,
|
2002-10-12 11:37:38 +00:00
|
|
|
short a,
|
|
|
|
|
short b)
|
|
|
|
|
{
|
|
|
|
|
IMB_dit2(ib, a, b);
|
|
|
|
|
}
|
|
|
|
|
|
2006-06-16 20:00:00 +00:00
|
|
|
LIBEXPORT void dit0(struct ImBuf *ib,
|
2002-10-12 11:37:38 +00:00
|
|
|
short a,
|
|
|
|
|
short b)
|
|
|
|
|
{
|
|
|
|
|
IMB_dit0(ib, a, b);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* still the same name */
|
|
|
|
|
/* void (*ditherfunc)(struct ImBuf *, short, short){} */
|
|
|
|
|
|
2006-06-16 20:00:00 +00:00
|
|
|
LIBEXPORT struct ImBuf *scaleImBuf(struct ImBuf *ib,
|
2002-10-12 11:37:38 +00:00
|
|
|
short nx,
|
|
|
|
|
short ny)
|
|
|
|
|
{
|
|
|
|
|
return IMB_scaleImBuf(ib, nx, ny);
|
|
|
|
|
}
|
|
|
|
|
|
2006-06-16 20:00:00 +00:00
|
|
|
LIBEXPORT struct ImBuf *scalefastImBuf(struct ImBuf *ib,
|
2002-10-12 11:37:38 +00:00
|
|
|
short x,
|
|
|
|
|
short y)
|
|
|
|
|
{
|
|
|
|
|
return IMB_scalefastImBuf(ib, x, y);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2006-06-16 20:00:00 +00:00
|
|
|
LIBEXPORT struct ImBuf *scalefieldImBuf(struct ImBuf *ib,
|
2002-10-12 11:37:38 +00:00
|
|
|
short x,
|
|
|
|
|
short y)
|
|
|
|
|
{
|
|
|
|
|
return IMB_scalefieldImBuf(ib, x, y);
|
|
|
|
|
}
|
|
|
|
|
|
2006-06-16 20:00:00 +00:00
|
|
|
LIBEXPORT struct ImBuf *scalefastfieldImBuf(struct ImBuf *ib,
|
2002-10-12 11:37:38 +00:00
|
|
|
short x,
|
|
|
|
|
short y)
|
|
|
|
|
{
|
|
|
|
|
return IMB_scalefastfieldImBuf(ib, x, y);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Extra ones that some NaN (read Ton) plugins use,
|
|
|
|
|
* even though they aren't in the header
|
|
|
|
|
*/
|
2003-04-30 18:38:50 +00:00
|
|
|
|
2006-06-16 20:00:00 +00:00
|
|
|
LIBEXPORT void interlace(struct ImBuf *ibuf)
|
2003-04-30 18:38:50 +00:00
|
|
|
{
|
|
|
|
|
IMB_interlace(ibuf);
|
|
|
|
|
}
|
|
|
|
|
|
2006-06-16 20:00:00 +00:00
|
|
|
LIBEXPORT void gamwarp(struct ImBuf *ibuf, double gamma)
|
2003-04-30 18:38:50 +00:00
|
|
|
{
|
|
|
|
|
IMB_gamwarp(ibuf,gamma);
|
|
|
|
|
}
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2006-06-16 20:00:00 +00:00
|
|
|
LIBEXPORT void de_interlace(struct ImBuf *ib)
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
|
|
|
|
IMB_de_interlace(ib);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* -------------------------------------------------------------------------- */
|
|
|
|
|
/* stuff from plugin.h */
|
|
|
|
|
/* -------------------------------------------------------------------------- */
|
|
|
|
|
|
|
|
|
|
/* These three need to be defined in the plugion itself. The plugin
|
|
|
|
|
* loader looks for these functions to check whether it can use the
|
|
|
|
|
* plugin. For sequences, something similar exists. */
|
|
|
|
|
/* int plugin_tex_getversion(void); */
|
|
|
|
|
/* int plugin_seq_getversion(void); */
|
|
|
|
|
/* void plugin_getinfo(PluginInfo *); */
|
|
|
|
|
|
2006-06-16 20:00:00 +00:00
|
|
|
LIBEXPORT float hnoise(float noisesize,
|
2002-10-12 11:37:38 +00:00
|
|
|
float x,
|
|
|
|
|
float y,
|
|
|
|
|
float z)
|
|
|
|
|
{
|
|
|
|
|
return BLI_hnoise(noisesize, x, y, z);
|
|
|
|
|
}
|
|
|
|
|
|
2006-06-16 20:00:00 +00:00
|
|
|
LIBEXPORT float hnoisep(float noisesize,
|
2002-10-12 11:37:38 +00:00
|
|
|
float x,
|
|
|
|
|
float y,
|
|
|
|
|
float z)
|
|
|
|
|
{
|
|
|
|
|
return BLI_hnoisep(noisesize, x, y, z);
|
|
|
|
|
}
|
|
|
|
|
|
2006-06-16 20:00:00 +00:00
|
|
|
LIBEXPORT float turbulence(float noisesize,
|
2002-10-12 11:37:38 +00:00
|
|
|
float x,
|
|
|
|
|
float y,
|
|
|
|
|
float z,
|
|
|
|
|
int depth)
|
|
|
|
|
{
|
|
|
|
|
return BLI_turbulence(noisesize, x, y, z, depth);
|
|
|
|
|
}
|
|
|
|
|
|
2006-06-16 20:00:00 +00:00
|
|
|
LIBEXPORT float turbulence1(float noisesize,
|
2002-10-12 11:37:38 +00:00
|
|
|
float x,
|
|
|
|
|
float y,
|
|
|
|
|
float z,
|
|
|
|
|
int depth)
|
|
|
|
|
{
|
|
|
|
|
return BLI_turbulence1(noisesize, x, y, z, depth);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* -------------------------------------------------------------------------- */
|
|
|
|
|
|
|
|
|
|
/* Stupid hack - force the inclusion of all of the
|
|
|
|
|
* above functions in the binary by 'using' each one...
|
|
|
|
|
* Otherwise they will not be imported from the archive
|
|
|
|
|
* library on Unix. -zr
|
|
|
|
|
*/
|
2005-03-09 19:45:59 +00:00
|
|
|
int pluginapi_force_ref(void);
|
|
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
int pluginapi_force_ref(void)
|
|
|
|
|
{
|
|
|
|
|
return (int) mallocN +
|
|
|
|
|
(int) callocN +
|
|
|
|
|
(int) freeN +
|
2006-06-16 20:00:00 +00:00
|
|
|
(int) mallocT +
|
|
|
|
|
(int) callocT +
|
|
|
|
|
(int) freeT +
|
2002-10-12 11:37:38 +00:00
|
|
|
(int) allocImBuf +
|
|
|
|
|
(int) dupImBuf +
|
|
|
|
|
(int) freeImBuf +
|
|
|
|
|
(int) converttocmap +
|
|
|
|
|
(int) saveiff +
|
|
|
|
|
(int) loadiffmem +
|
|
|
|
|
(int) loadifffile +
|
|
|
|
|
(int) loadiffname +
|
|
|
|
|
(int) testiffname +
|
|
|
|
|
(int) onehalf +
|
|
|
|
|
(int) onethird +
|
|
|
|
|
(int) halflace +
|
|
|
|
|
(int) half_x +
|
|
|
|
|
(int) half_y +
|
|
|
|
|
(int) double_x +
|
|
|
|
|
(int) double_y +
|
|
|
|
|
(int) double_fast_x +
|
|
|
|
|
(int) double_fast_y +
|
|
|
|
|
(int) ispic +
|
|
|
|
|
(int) dit2 +
|
|
|
|
|
(int) dit0 +
|
|
|
|
|
(int) scaleImBuf +
|
|
|
|
|
(int) scalefastImBuf +
|
|
|
|
|
(int) scalefieldImBuf +
|
|
|
|
|
(int) scalefastfieldImBuf +
|
|
|
|
|
(int) hnoise +
|
|
|
|
|
(int) hnoisep +
|
|
|
|
|
(int) turbulence +
|
|
|
|
|
(int) turbulence1 +
|
|
|
|
|
(int) de_interlace +
|
2003-04-30 18:38:50 +00:00
|
|
|
(int) interlace +
|
Orange branch: OpenEXR finally in Blender!
Credits go to Gernot Ziegler, who originally coded EXR support, and to
Austin Benesh for bringing it further. Kent Mein provided a lot of code
for integrating float buffers in Blender imbuf and ImBuf API cleanup,
and provided Make and Scons and static linking.
At this moment; the EXR libraries are a *dependency*, so you cannot get
the Orange branch compiled without having OpenEXR installed. Get the
(precompiled or sources) stuff from www.openexr.com. Current default is
that the headers and lib resides in /user/local/
Several changes/additions/fixes were added:
- EXR code only supported 'half' format (16 bits per channel). I've added
float writing, but for reading it I need tomorrow. :)
- Quite some clumsy copying of data happened in EXR code.
- cleaned up the api calls already a bit, preparing for more advanced
support
- Zbuffers were saved 16 bits, now 32 bits
- automatic adding of .exr extensions went wrong
Imbuf:
- added proper imbuf->flags and imbuf->mall support for float buffers, it
was created for *each* imbuf. :)
- found bugs for float buffers in scaling and flipping. Code there will
need more checks still
- imbuf also needs to be verified to behave properly when no 32 bits
rect exists (for saving for example)
TODO:
- support internal float images for textures, backbuf, AO probes, and
display in Image window
Hope this commit won't screwup syncing with bf-blender... :/
2006-01-09 00:40:35 +00:00
|
|
|
(int) gamwarp;
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|