/****************************************************************************
 *                  postproc.h
 *
 *  Author: Wlodzimierz ABX Skiba (abx@abx.art.pl)
 *
 * from Persistence of Vision(tm) Ray Tracer version 3.6.
 * Copyright 1991-2003 Persistence of Vision Team
 * Copyright 2003-2004 Persistence of Vision Raytracer Pty. Ltd.
 *---------------------------------------------------------------------------
 * NOTICE: This source code file is provided so that users may experiment
 * with enhancements to POV-Ray and to port the software to platforms other
 * than those supported by the POV-Ray developers. There are strict rules
 * regarding how you are permitted to use this file. These rules are contained
 * in the distribution and derivative versions licenses which should have been
 * provided with this file.
 *
 * These licences may be found online, linked from the end-user license
 * agreement that is located at http://www.povray.org/povlegal.html
 *---------------------------------------------------------------------------
 * This program is based on the popular DKB raytracer version 2.12.
 * DKBTrace was originally written by David K. Buck.
 * DKBTrace Ver 2.0-2.12 were written by David K. Buck & Aaron A. Collins.
 *---------------------------------------------------------------------------
 *
 *===========================================================================
 * This file is part of MegaPOV, a modified and unofficial version of POV-Ray
 * For more information on MegaPOV visit our website:
 * http://megapov.inetart.net/
 *===========================================================================
 *
 * $RCSfile: postproc.h,v $
 * $Revision: 1.11 $
 * $Author: chris $
 *
 *****************************************************************************/

#ifndef POSTPROC_H
#define POSTPROC_H
#include "fnpovfpu.h"

#ifdef POST_PROCESS_PATCH

BEGIN_POV_NAMESPACE
/*****************************************************************************
* Global preprocessor defines
******************************************************************************/

enum {
  PP_COLOUR_RED=0,
  PP_COLOUR_GREEN=1,
  PP_COLOUR_BLUE=2,
  PP_COLOUR_ALPHA=3,
  PP_IPOINT_X,
  PP_IPOINT_Y,
  PP_IPOINT_Z,
  PP_INORMAL_X,
  PP_INORMAL_Y,
  PP_INORMAL_Z,
  PP_PNORMAL_X,
  PP_PNORMAL_Y,
  PP_PNORMAL_Z,
  PP_DEPTH,
  PP_U,
  PP_V,
  PP_LAST_INFO
};

/*****************************************************************************
* Global typedefs
******************************************************************************/

typedef struct Post_Process_Struct POST_PROCESS;

struct Post_Process_Struct
{
  int Order;
  FUNCTION_PTR Function[4];
  char *Save_File_Name;
  DBL time;
  POST_PROCESS *next;
  POST_PROCESS *prev;
};

/*****************************************************************************
* Global variables
******************************************************************************/

extern const unsigned int FIRST_INTERNAL_PP_FUNCTION;
extern const unsigned int LAST_INTERNAL_PP_FUNCTION;

extern POST_PROCESS * First_Post_Process;
extern int Post_Process_Index;
extern int Post_Process_Pass;
extern int Post_Process_X;
extern int Post_Process_Y;

/*****************************************************************************
* Global functions
******************************************************************************/

POST_PROCESS *Create_Post_Process();
void Destroy_Post_Process(POST_PROCESS **Post_Process);
void Post_Process_Initialize_Info(DBL *PP_Info);
void Post_Process_Intersection_Info(DBL *PP_Info, INTERSECTION *Best_Intersection);
void Post_Process_Colour_Info(DBL *PP_Info, COLOUR Colour);
void Initialize_Post_Processing();
void Initialize_Post_Processing_Cache(int component);
void Reinitialize_Post_Processing();
void Deinitialize_Post_Processing();
void Save_Post_Process_Info(DBL *PP_Info);
DBL Read_Output(DBL x, DBL y, int Component);
DBL Read_Post_Process(DBL x, DBL y, int PP_Index, int Component);
void Post_Process_Loop(int & Post_Process_Pass,POST_PROCESS *Rendered_Post_Process);

inline DBL Evaluate_Function_UV(FUNCTION funct, UV_VECT fnvec)
{
  POVFPU_SetLocal(U, fnvec[U]);
  POVFPU_SetLocal(V, fnvec[V]);

  return POVFPU_Run(funct);
}
END_POV_NAMESPACE
#endif

#endif
