Subversion Repositories eduke32

Rev

Rev 5056 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 5056 Rev 5075
Line 26... Line 26...
26
};
26
};
27
#define NUMGLFILTERMODES 6
27
#define NUMGLFILTERMODES 6
28
extern struct glfiltermodes glfiltermodes[NUMGLFILTERMODES];
28
extern struct glfiltermodes glfiltermodes[NUMGLFILTERMODES];
29
29
30
//void phex(char v, char *s);
30
//void phex(char v, char *s);
31
void uploadtexture(int32_t doalloc, int32_t xsiz, int32_t ysiz, int32_t intexfmt, int32_t texfmt, coltype *pic, int32_t tsizx, int32_t tsizy, int32_t dameth);
31
void uploadtexture(int32_t doalloc, vec2_t siz, int32_t intexfmt, int32_t texfmt, coltype *pic, vec2_t tsiz, int32_t dameth);
32
void polymost_drawsprite(int32_t snum);
32
void polymost_drawsprite(int32_t snum);
33
void polymost_drawmaskwall(int32_t damaskwallcnt);
33
void polymost_drawmaskwall(int32_t damaskwallcnt);
34
void polymost_dorotatesprite(int32_t sx, int32_t sy, int32_t z, int16_t a, int16_t picnum,
34
void polymost_dorotatesprite(int32_t sx, int32_t sy, int32_t z, int16_t a, int16_t picnum,
35
                             int8_t dashade, char dapalnum, int32_t dastat, uint8_t daalpha, int32_t cx1, int32_t cy1, int32_t cx2, int32_t cy2, int32_t uniqid);
35
                             int8_t dashade, char dapalnum, int32_t dastat, uint8_t daalpha, int32_t cx1, int32_t cy1, int32_t cx2, int32_t cy2, int32_t uniqid);
36
void polymost_fillpolygon(int32_t npoints);
36
void polymost_fillpolygon(int32_t npoints);
Line 51... Line 51...
51
51
52
extern float curpolygonoffset;
52
extern float curpolygonoffset;
53
53
54
extern float shadescale;
54
extern float shadescale;
55
extern int32_t shadescale_unbounded;
55
extern int32_t shadescale_unbounded;
56
extern float alphahackarray[MAXTILES];
56
extern uint8_t alphahackarray[MAXTILES];
57
57
58
extern int32_t r_usenewshading;
58
extern int32_t r_usenewshading;
59
extern int32_t r_usetileshades;
59
extern int32_t r_usetileshades;
60
extern int32_t r_npotwallmode;
60
extern int32_t r_npotwallmode;
61
61
62
extern int16_t globalpicnum;
62
extern int16_t globalpicnum;
63
extern int32_t globalpal;
63
extern int32_t globalpal;
64
64
65
// Compare with polymer_eligible_for_artmap()
65
// Compare with polymer_eligible_for_artmap()
66
static inline int32_t eligible_for_tileshades(int32_t picnum, int32_t pal)
66
static inline int32_t eligible_for_tileshades(int32_t const picnum, int32_t const pal)
67
{
67
{
68
    return (!usehightile || !hicfindsubst(picnum, pal)) &&
68
    return (!usehightile || !hicfindsubst(picnum, pal)) &&
69
        (!usemodels || md_tilehasmodel(picnum, pal) < 0);
69
        (!usemodels || md_tilehasmodel(picnum, pal) < 0);
70
}
70
}
71
71
72
static inline float getshadefactor(int32_t shade)
72
static inline float getshadefactor(int32_t const shade)
73
{
73
{
74
    int32_t shadebound = (shadescale_unbounded || shade>=numshades) ? numshades : numshades-1;
74
    int32_t const shadebound = (shadescale_unbounded || shade>=numshades) ? numshades : numshades-1;
75
    float clamped_shade = min(max(shade*shadescale, 0), shadebound);
75
    float const clamped_shade = min(max(shade*shadescale, 0), shadebound);
76
76
77
    // 8-bit tiles, i.e. non-hightiles and non-models, don't get additional
77
    // 8-bit tiles, i.e. non-hightiles and non-models, don't get additional
78
    // glColor() shading with r_usetileshades!
78
    // glColor() shading with r_usetileshades!
79
    if (getrendermode() == REND_POLYMOST && r_usetileshades &&
79
    if (getrendermode() == REND_POLYMOST && r_usetileshades &&
80
            !(globalflags & GLOBAL_NO_GL_TILESHADES) &&
80
            !(globalflags & GLOBAL_NO_GL_TILESHADES) &&
Line 84... Line 84...
84
    return ((float)(numshades-clamped_shade))/(float)numshades;
84
    return ((float)(numshades-clamped_shade))/(float)numshades;
85
}
85
}
86
86
87
#define POLYMOST_CHOOSE_FOG_PAL(fogpal, pal) \
87
#define POLYMOST_CHOOSE_FOG_PAL(fogpal, pal) \
88
    ((fogpal) ? (fogpal) : (pal))
88
    ((fogpal) ? (fogpal) : (pal))
89
static inline int32_t get_floor_fogpal(const sectortype *sec)
89
static inline int32_t get_floor_fogpal(tsectortype const * const sec)
90
{
90
{
91
    return POLYMOST_CHOOSE_FOG_PAL(sec->fogpal, sec->floorpal);
91
    return POLYMOST_CHOOSE_FOG_PAL(sec->fogpal, sec->floorpal);
92
}
92
}
93
static inline int32_t get_ceiling_fogpal(const sectortype *sec)
93
static inline int32_t get_ceiling_fogpal(tsectortype const * const sec)
94
{
94
{
95
    return POLYMOST_CHOOSE_FOG_PAL(sec->fogpal, sec->ceilingpal);
95
    return POLYMOST_CHOOSE_FOG_PAL(sec->fogpal, sec->ceilingpal);
96
}
96
}
97
static inline int32_t fogpal_shade(const sectortype *sec, int32_t shade)
97
static inline int32_t fogpal_shade(tsectortype const * const sec, int32_t const shade)
98
{
98
{
99
    // When fogging is due to sector[].fogpal, don't make the fog parameters
99
    // When fogging is due to sector[].fogpal, don't make the fog parameters
100
    // depend on the shade of the object.
100
    // depend on the shade of the object.
101
    return sec->fogpal ? 0 : shade;
101
    return sec->fogpal ? 0 : shade;
102
}
102
}
103
103
104
static inline int check_nonpow2(int32_t x)
104
static inline int check_nonpow2(int32_t const x)
105
{
105
{
106
    return (x > 1 && (x&(x-1)));
106
    return (x > 1 && (x&(x-1)));
107
}
107
}
108
108
109
// Are we using the mode that uploads non-power-of-two wall textures like they
109
// Are we using the mode that uploads non-power-of-two wall textures like they
Line 121... Line 121...
121
        g_loadedMapVersion < 10 &&
121
        g_loadedMapVersion < 10 &&
122
#endif
122
#endif
123
        r_npotwallmode;
123
        r_npotwallmode;
124
}
124
}
125
125
126
static inline float polymost_invsqrt(float x)
126
static inline float polymost_invsqrt_approximation(float x)
127
{
127
{
128
#ifdef B_LITTLE_ENDIAN
128
#ifdef B_LITTLE_ENDIAN
129
    const float haf = x*.5f;
129
    float const haf = x * .5f;
130
    struct conv { union { uint32_t i; float f; } u; } * const n = (struct conv *)&x;
130
    struct conv { union { uint32_t i; float f; } u; } * const n = (struct conv *)&x;
131
    n->u.i = 0x5f3759df-(n->u.i>>1);
131
    n->u.i = 0x5f3759df - (n->u.i >> 1);
132
    return n->u.f*(1.5f-haf*(n->u.f*n->u.f));
132
    return n->u.f * (1.5f - haf * (n->u.f * n->u.f));
133
#else
133
#else
134
    // this is the comment
134
    // this is the comment
Line 142... Line 142...
142
142
143
    DAMETH_WALL = 32,  // signals a texture for a wall (for r_npotwallmode)
143
    DAMETH_WALL = 32,  // signals a texture for a wall (for r_npotwallmode)
144
144
145
    DAMETH_NOCOMPRESS = 4096,
145
    DAMETH_NOCOMPRESS = 4096,
146
    DAMETH_HI = 8192,
146
    DAMETH_HI = 8192,
-
 
147
    DAMETH_NOFIX = 16384,
147
};
148
};
148
149
149
// DAMETH_CLAMPED -> PTH_CLAMPED conversion
150
// DAMETH_CLAMPED -> PTH_CLAMPED conversion
150
#define TO_PTH_CLAMPED(dameth) (((dameth)&DAMETH_CLAMPED)>>2)
151
#define TO_PTH_CLAMPED(dameth) (((dameth)&DAMETH_CLAMPED)>>2)
151
152