mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-02 09:52:27 -04:00
fix texturing issues
This commit is contained in:
parent
b68cd0b513
commit
9787429186
@ -1191,7 +1191,6 @@ begin_draw_primitives(const GeomPipelineReader *geom_reader,
|
||||
}
|
||||
|
||||
_c->zb_fill_tri = fill_tri_funcs[depth_write_state][color_write_state][alpha_test_state][depth_test_state][shading_state][texturing_state];
|
||||
//_c->zb_fill_tri = ZB_fillTriangleFlat_zless;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -224,6 +224,7 @@ begin_flip() {
|
||||
|
||||
XPutImage(_display, _xwindow, _gc, _ximage, 0, 0, 0, 0,
|
||||
_properties.get_x_size(), _properties.get_y_size());
|
||||
XFlush(_display);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
@ -11,19 +11,41 @@
|
||||
|
||||
#define ZB_POINT_Z_FRAC_BITS 14
|
||||
|
||||
#define ZB_POINT_S_MIN ( (1<<13) )
|
||||
#define ZB_POINT_S_MAX ( (1<<22)-(1<<13) )
|
||||
#define ZB_POINT_T_MIN ( (1<<21) )
|
||||
#define ZB_POINT_T_MAX ( (1<<30)-(1<<21) )
|
||||
/* The number of bits for lookup for S and T texture coords. This is
|
||||
based on a fixed texture size of 256x256. */
|
||||
#define ZB_POINT_ST_BITS 8
|
||||
|
||||
/* The number of fractional bits below the S and T texture coords.
|
||||
The more we have, the more precise the texel calculation will be
|
||||
when we zoom into small details of a texture; but the greater
|
||||
chance we'll overflow our 32-bit integer if the T texcoord gets
|
||||
large. */
|
||||
#define ZB_POINT_ST_FRAC_BITS 10
|
||||
|
||||
/* Various parameters and accessors based on the above bits. */
|
||||
#define ZB_POINT_S_LOW ZB_POINT_ST_FRAC_BITS
|
||||
#define ZB_POINT_S_MIN 0
|
||||
#define ZB_POINT_S_MAX (1 << (ZB_POINT_ST_BITS + ZB_POINT_S_LOW))
|
||||
#define ZB_POINT_S_MASK ((1 << (ZB_POINT_ST_BITS + ZB_POINT_S_LOW)) - (1 << ZB_POINT_S_LOW))
|
||||
|
||||
#define ZB_POINT_T_LOW (ZB_POINT_ST_BITS + ZB_POINT_S_LOW)
|
||||
#define ZB_POINT_T_MIN 0
|
||||
#define ZB_POINT_T_MAX (1 << (ZB_POINT_ST_BITS + ZB_POINT_T_LOW))
|
||||
#define ZB_POINT_T_MASK ((1 << (ZB_POINT_ST_BITS + ZB_POINT_T_LOW)) - (1 << ZB_POINT_T_LOW))
|
||||
|
||||
// Returns the index within a 256x256 texture for the given (s, t)
|
||||
// texel.
|
||||
#define ZB_TEXEL(s, t) \
|
||||
((((t) & ZB_POINT_T_MASK) | ((s) & ZB_POINT_S_MASK)) >> ZB_POINT_ST_FRAC_BITS)
|
||||
|
||||
#define ZB_POINT_RED_MIN 0x0000
|
||||
#define ZB_POINT_RED_MAX 0xff00
|
||||
#define ZB_POINT_RED_MAX 0xffff
|
||||
#define ZB_POINT_GREEN_MIN 0x0000
|
||||
#define ZB_POINT_GREEN_MAX 0xff00
|
||||
#define ZB_POINT_GREEN_MAX 0xffff
|
||||
#define ZB_POINT_BLUE_MIN 0x0000
|
||||
#define ZB_POINT_BLUE_MAX 0xff00
|
||||
#define ZB_POINT_BLUE_MAX 0xffff
|
||||
#define ZB_POINT_ALPHA_MIN 0x0000
|
||||
#define ZB_POINT_ALPHA_MAX 0xff00
|
||||
#define ZB_POINT_ALPHA_MAX 0xffff
|
||||
|
||||
/* display modes */
|
||||
#define ZB_MODE_5R6G5B 1 /* true color 16 bits */
|
||||
|
@ -82,7 +82,7 @@ void FNAME(ZB_fillTriangleMapping) (ZBuffer *zb,
|
||||
{ \
|
||||
zz=z >> ZB_POINT_Z_FRAC_BITS; \
|
||||
if (ZCMP(pz[_a], zz)) { \
|
||||
tmp=texture[((t & 0x3FC00000) | (s & 0x3fc000)) >> 14]; \
|
||||
tmp = texture[ZB_TEXEL(s, t)]; \
|
||||
if (ACMP(zb, PIXEL_A(tmp))) { \
|
||||
STORE_PIX(pp[_a], tmp, PIXEL_R(tmp), PIXEL_G(tmp), PIXEL_B(tmp), PIXEL_A(tmp)); \
|
||||
STORE_Z(pz[_a], zz); \
|
||||
@ -118,7 +118,7 @@ void FNAME(ZB_fillTriangleMappingFlat) (ZBuffer *zb,
|
||||
{ \
|
||||
zz=z >> ZB_POINT_Z_FRAC_BITS; \
|
||||
if (ZCMP(pz[_a], zz)) { \
|
||||
tmp=texture[((t & 0x3FC00000) | (s & 0x3fc000)) >> 14]; \
|
||||
tmp = texture[ZB_TEXEL(s, t)]; \
|
||||
int a = oa * PIXEL_A(tmp) >> 16; \
|
||||
if (ACMP(zb, a)) { \
|
||||
STORE_PIX(pp[_a], \
|
||||
@ -159,7 +159,7 @@ void FNAME(ZB_fillTriangleMappingSmooth) (ZBuffer *zb,
|
||||
{ \
|
||||
zz=z >> ZB_POINT_Z_FRAC_BITS; \
|
||||
if (ZCMP(pz[_a], zz)) { \
|
||||
tmp=texture[((t & 0x3FC00000) | (s & 0x3fc000)) >> 14]; \
|
||||
tmp = texture[ZB_TEXEL(s, t)]; \
|
||||
int a = oa1 * PIXEL_A(tmp) >> 16; \
|
||||
if (ACMP(zb, a)) { \
|
||||
STORE_PIX(pp[_a], \
|
||||
@ -216,8 +216,7 @@ void FNAME(ZB_fillTriangleMappingPerspective) (ZBuffer *zb,
|
||||
{ \
|
||||
zz=z >> ZB_POINT_Z_FRAC_BITS; \
|
||||
if (ZCMP(pz[_a], zz)) { \
|
||||
tmp = *(PIXEL *)((char *)texture+ \
|
||||
(((t & 0x3FC00000) | (s & 0x003FC000)) >> (17 - PSZSH))); \
|
||||
tmp = texture[ZB_TEXEL(s, t)]; \
|
||||
if (ACMP(zb, PIXEL_A(tmp))) { \
|
||||
STORE_PIX(pp[_a], tmp, PIXEL_R(tmp), PIXEL_G(tmp), PIXEL_B(tmp), PIXEL_A(tmp)); \
|
||||
STORE_Z(pz[_a], zz); \
|
||||
@ -322,8 +321,7 @@ void FNAME(ZB_fillTriangleMappingPerspectiveFlat) (ZBuffer *zb,
|
||||
{ \
|
||||
zz=z >> ZB_POINT_Z_FRAC_BITS; \
|
||||
if (ZCMP(pz[_a], zz)) { \
|
||||
tmp=*(PIXEL *)((char *)texture+ \
|
||||
(((t & 0x3FC00000) | (s & 0x003FC000)) >> (17 - PSZSH))); \
|
||||
tmp = texture[ZB_TEXEL(s, t)]; \
|
||||
int a = oa * PIXEL_A(tmp) >> 16; \
|
||||
if (ACMP(zb, a)) { \
|
||||
STORE_PIX(pp[_a], \
|
||||
@ -436,8 +434,7 @@ void FNAME(ZB_fillTriangleMappingPerspectiveSmooth) (ZBuffer *zb,
|
||||
{ \
|
||||
zz=z >> ZB_POINT_Z_FRAC_BITS; \
|
||||
if (ZCMP(pz[_a], zz)) { \
|
||||
tmp=*(PIXEL *)((char *)texture+ \
|
||||
(((t & 0x3FC00000) | (s & 0x003FC000)) >> (17 - PSZSH))); \
|
||||
tmp = texture[ZB_TEXEL(s, t)]; \
|
||||
int a = oa1 * PIXEL_A(tmp) >> 16; \
|
||||
if (ACMP(zb, a)) { \
|
||||
STORE_PIX(pp[_a], \
|
||||
|
Loading…
x
Reference in New Issue
Block a user