/*
  Copyright (C) 2010-2011  Charles Pence <charles@charlespence.net>
  Copyright (C) 1996-1997  Id Software, Inc.

  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 3 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, see <http://www.gnu.org/licenses/>.
*/

#include "r_glext.h"

void GL_EndRendering (void);

qboolean R_CullBox (vec3_t mins, vec3_t maxs);
void R_RotateForEntity (entity_t *e);

void GL_MakeAliasModelDisplayLists (model_t *m, aliashdr_t *hdr);

void GL_SubdivideSurface (msurface_t *fa);
void EmitWaterPolys (msurface_t *fa);

void GL_BuildLightmaps (void);
void R_DrawBrushModel (entity_t *e);

void R_StoreEfrags (efrag_t **ppefrag);

extern void R_DrawSky(void);
void R_DrawWaterSurfaces (void);
void R_DrawWorld (void);
void R_DrawParticles (void);
void R_AnimateLight (void);

void R_MarkLights (dlight_t *light, int bit, mnode_t *node);
int R_LightPoint (vec3_t p);

#define ALIAS_BASE_SIZE_RATIO        (1.0 / 11.0)
                    // normalizing factor so player model works out to about
                    //  1 pixel per triangle

#define BACKFACE_EPSILON    0.01


void R_TimeRefresh_f (void);
texture_t *R_TextureAnimation (texture_t *base);

typedef enum {
    pt_static, pt_grav, pt_slowgrav, pt_fire, pt_explode, pt_explode2, pt_blob, pt_blob2
} ptype_t;

typedef struct particle_s
{
    vec3_t        org;
    float        color;
    struct particle_s    *next;
    vec3_t        vel;
    float        ramp;
    float        die;
    ptype_t        type;
} particle_t;

void R_InitParticles (void);
void R_ClearParticles (void);


//====================================================

extern    entity_t    *currententity;
extern    int            r_visframecount;    // ??? what difs?
extern    int            r_framecount;
extern    mplane_t    frustum[4];
extern    int        c_brush_polys, c_alias_polys;


//
// screen size info
//
extern    refdef_t    r_refdef;
extern    mleaf_t        *r_viewleaf, *r_oldviewleaf;
extern    texture_t    *r_notexture_mip;
extern    int        d_lightstylevalue[256];    // 8.8 fraction of base light value

extern    GLuint    particletexture;
extern    GLuint    playertextures[16];

void R_TranslatePlayerSkin (int playernum);
