Support signed int vertex data, normalize 16-bit uint colors properly, don't normalize int columns passed to shaders
This commit is contained in:
parent
24ec0d6c46
commit
9303c247b6
|
|
@ -87,6 +87,23 @@ munge_format_impl(const GeomVertexFormat *orig,
|
|||
CLP(GraphicsStateGuardian) *glgsg;
|
||||
DCAST_INTO_R(glgsg, get_gsg(), NULL);
|
||||
|
||||
#ifndef OPENGLES
|
||||
// OpenGL ES 1 does, but regular OpenGL doesn't support GL_BYTE vertices
|
||||
// and texture coordinates.
|
||||
const GeomVertexColumn *vertex_type = orig->get_vertex_column();
|
||||
if (vertex_type != (GeomVertexColumn *)NULL &&
|
||||
vertex_type->get_numeric_type() == NT_int8) {
|
||||
int vertex_array = orig->get_array_with(InternalName::get_vertex());
|
||||
|
||||
PT(GeomVertexArrayFormat) new_array_format = new_format->modify_array(vertex_array);
|
||||
|
||||
// Replace the existing vertex format with the new format.
|
||||
new_array_format->add_column
|
||||
(InternalName::get_vertex(), 3, NT_int16,
|
||||
C_point, vertex_type->get_start(), vertex_type->get_column_alignment());
|
||||
}
|
||||
#endif
|
||||
|
||||
const GeomVertexColumn *color_type = orig->get_color_column();
|
||||
if (color_type != (GeomVertexColumn *)NULL &&
|
||||
color_type->get_numeric_type() == NT_packed_dabc &&
|
||||
|
|
@ -237,6 +254,23 @@ premunge_format_impl(const GeomVertexFormat *orig) {
|
|||
CLP(GraphicsStateGuardian) *glgsg;
|
||||
DCAST_INTO_R(glgsg, get_gsg(), NULL);
|
||||
|
||||
#ifndef OPENGLES
|
||||
// OpenGL ES 1 does, but regular OpenGL doesn't support GL_BYTE vertices
|
||||
// and texture coordinates.
|
||||
const GeomVertexColumn *vertex_type = orig->get_vertex_column();
|
||||
if (vertex_type != (GeomVertexColumn *)NULL &&
|
||||
vertex_type->get_numeric_type() == NT_int8) {
|
||||
int vertex_array = orig->get_array_with(InternalName::get_vertex());
|
||||
|
||||
PT(GeomVertexArrayFormat) new_array_format = new_format->modify_array(vertex_array);
|
||||
|
||||
// Replace the existing vertex format with the new format.
|
||||
new_array_format->add_column
|
||||
(InternalName::get_vertex(), 3, NT_int16,
|
||||
C_point, vertex_type->get_start(), vertex_type->get_column_alignment());
|
||||
}
|
||||
#endif
|
||||
|
||||
const GeomVertexColumn *color_type = orig->get_color_column();
|
||||
if (color_type != (GeomVertexColumn *)NULL &&
|
||||
color_type->get_numeric_type() == NT_packed_dabc &&
|
||||
|
|
|
|||
|
|
@ -1013,8 +1013,9 @@ reset() {
|
|||
#ifdef OPENGLES
|
||||
_supports_packed_dabc = false;
|
||||
#else
|
||||
_supports_packed_dabc = /*gl_support_packed_dabc &&*/
|
||||
has_extension("GL_ARB_vertex_array_bgra") || has_extension("GL_EXT_vertex_array_bgra");
|
||||
_supports_packed_dabc = is_at_least_gl_version(3, 2) ||
|
||||
has_extension("GL_ARB_vertex_array_bgra") ||
|
||||
has_extension("GL_EXT_vertex_array_bgra");
|
||||
#endif
|
||||
|
||||
_supports_multisample =
|
||||
|
|
@ -7370,6 +7371,15 @@ get_numeric_type(Geom::NumericType numeric_type) {
|
|||
case Geom::NT_stdfloat:
|
||||
// Shouldn't happen, display error.
|
||||
break;
|
||||
|
||||
case Geom::NT_int8:
|
||||
return GL_BYTE;
|
||||
|
||||
case Geom::NT_int16:
|
||||
return GL_SHORT;
|
||||
|
||||
case Geom::NT_int32:
|
||||
return GL_INT;
|
||||
}
|
||||
|
||||
GLCAT.error()
|
||||
|
|
|
|||
|
|
@ -1420,9 +1420,10 @@ update_shader_vertex_arrays(ShaderContext *prev, bool force) {
|
|||
GLint p = _glsl_parameter_map[bind._id._seqno];
|
||||
|
||||
int num_elements, element_stride, divisor;
|
||||
bool normalized;
|
||||
if (_glgsg->_data_reader->get_array_info(name, array_reader,
|
||||
num_values, numeric_type,
|
||||
start, stride, divisor,
|
||||
normalized, start, stride, divisor,
|
||||
num_elements, element_stride)) {
|
||||
const unsigned char *client_pointer;
|
||||
if (!_glgsg->setup_array_data(client_pointer, array_reader, force)) {
|
||||
|
|
@ -1440,11 +1441,14 @@ update_shader_vertex_arrays(ShaderContext *prev, bool force) {
|
|||
} else
|
||||
#endif
|
||||
if (numeric_type == GeomEnums::NT_packed_dabc) {
|
||||
// GL_BGRA is a special accepted value available since OpenGL 3.2.
|
||||
// It requires us to pass GL_TRUE for normalized.
|
||||
_glgsg->_glVertexAttribPointer(p, GL_BGRA, GL_UNSIGNED_BYTE,
|
||||
GL_TRUE, stride, client_pointer);
|
||||
} else {
|
||||
_glgsg->_glVertexAttribPointer(p, num_values, _glgsg->get_numeric_type(numeric_type),
|
||||
GL_TRUE, stride, client_pointer);
|
||||
_glgsg->_glVertexAttribPointer(p, num_values,
|
||||
_glgsg->get_numeric_type(numeric_type),
|
||||
normalized, stride, client_pointer);
|
||||
}
|
||||
|
||||
if (_glgsg->_supports_vertex_attrib_divisor) {
|
||||
|
|
|
|||
|
|
@ -101,6 +101,15 @@ operator << (ostream &out, GeomEnums::NumericType numeric_type) {
|
|||
|
||||
case GeomEnums::NT_stdfloat:
|
||||
return out << "stdfloat";
|
||||
|
||||
case GeomEnums::NT_int8:
|
||||
return out << "int8";
|
||||
|
||||
case GeomEnums::NT_int16:
|
||||
return out << "int16";
|
||||
|
||||
case GeomEnums::NT_int32:
|
||||
return out << "int32";
|
||||
}
|
||||
|
||||
return out << "**invalid numeric type (" << (int)numeric_type << ")**";
|
||||
|
|
|
|||
|
|
@ -144,12 +144,12 @@ PUBLISHED:
|
|||
// SM_uniform: all vertices across all faces have the same colors
|
||||
// and normals. It doesn't really matter which ShadeModelAttrib
|
||||
// mode is used to render this primitive.
|
||||
SM_uniform,
|
||||
SM_uniform,
|
||||
|
||||
// SM_smooth: vertices within a single face have different
|
||||
// colors/normals that should be smoothed across the face. This
|
||||
// primitive should be rendered with SmoothModelAttrib::M_smooth.
|
||||
SM_smooth,
|
||||
SM_smooth,
|
||||
|
||||
// SM_flat_(first,last)_vertex: each face within the primitive
|
||||
// might have a different color/normal than the other faces, but
|
||||
|
|
@ -177,12 +177,15 @@ PUBLISHED:
|
|||
enum NumericType {
|
||||
NT_uint8, // An integer 0..255
|
||||
NT_uint16, // An integer 0..65535
|
||||
NT_uint32, // An integer 0..4294967296
|
||||
NT_uint32, // An integer 0..4294967295
|
||||
NT_packed_dcba, // DirectX style, four byte values packed in a uint32
|
||||
NT_packed_dabc, // DirectX packed color order (ARGB)
|
||||
NT_float32, // A single-precision float
|
||||
NT_float64, // A double-precision float
|
||||
NT_stdfloat // Either single- or double-precision, according to vertices-float64.
|
||||
NT_stdfloat, // Either single- or double-precision, according to vertices-float64.
|
||||
NT_int8, // An integer -128..127
|
||||
NT_int16, // An integer -32768..32767
|
||||
NT_int32, // An integer -2147483648..2147483647
|
||||
};
|
||||
|
||||
// The contents determine the semantic meaning of a numeric value
|
||||
|
|
|
|||
|
|
@ -627,20 +627,37 @@ get_format_string(bool pad) const {
|
|||
case NT_uint8:
|
||||
fmt_code = 'B';
|
||||
break;
|
||||
|
||||
case NT_uint16:
|
||||
fmt_code = 'H';
|
||||
break;
|
||||
|
||||
case NT_uint32:
|
||||
case NT_packed_dcba:
|
||||
case NT_packed_dabc:
|
||||
fmt_code = 'I';
|
||||
break;
|
||||
|
||||
case NT_float32:
|
||||
fmt_code = 'f';
|
||||
break;
|
||||
|
||||
case NT_float64:
|
||||
fmt_code = 'd';
|
||||
break;
|
||||
|
||||
case NT_int8:
|
||||
fmt_code = 'b';
|
||||
break;
|
||||
|
||||
case NT_int16:
|
||||
fmt_code = 'h';
|
||||
break;
|
||||
|
||||
case NT_int32:
|
||||
fmt_code = 'i';
|
||||
break;
|
||||
|
||||
default:
|
||||
gobj_cat.error()
|
||||
<< "Unknown numeric type " << column->get_numeric_type() << "!\n";
|
||||
|
|
|
|||
|
|
@ -365,295 +365,3 @@ operator << (ostream &out, const GeomVertexColumn &obj) {
|
|||
obj.output(out);
|
||||
return out;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: GeomVertexColumn::Packer::maybe_scale_color_f
|
||||
// Access: Public
|
||||
// Description: Converts an integer (typically a uint8) value to a
|
||||
// floating-point value. If the contents value
|
||||
// indicates this is a color value, scales it into the
|
||||
// range 0..1 per convention; otherwise leaves it alone.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE float GeomVertexColumn::Packer::
|
||||
maybe_scale_color_f(unsigned int value) {
|
||||
if (_column->get_contents() == C_color) {
|
||||
return (float)value / 255.0f;
|
||||
} else {
|
||||
return (float)value;
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: GeomVertexColumn::Packer::maybe_scale_color_f
|
||||
// Access: Public
|
||||
// Description: Converts a pair of integers into the _v2 member. See
|
||||
// one-parameter maybe_scale_color_f() for more info.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE void GeomVertexColumn::Packer::
|
||||
maybe_scale_color_f(unsigned int a, unsigned int b) {
|
||||
if (_column->get_contents() == C_color) {
|
||||
_v2.set((float)a / 255.0f,
|
||||
(float)b / 255.0f);
|
||||
} else {
|
||||
_v2.set((float)a, (float)b);
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: GeomVertexColumn::Packer::maybe_scale_color_f
|
||||
// Access: Public
|
||||
// Description: Converts a pair of integers into the _v3 member. See
|
||||
// one-parameter maybe_scale_color_f() for more info.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE void GeomVertexColumn::Packer::
|
||||
maybe_scale_color_f(unsigned int a, unsigned int b, unsigned int c) {
|
||||
if (_column->get_contents() == C_color) {
|
||||
_v3.set((float)a / 255.0f,
|
||||
(float)b / 255.0f,
|
||||
(float)c / 255.0f);
|
||||
} else {
|
||||
_v3.set((float)a, (float)b, (float)c);
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: GeomVertexColumn::Packer::maybe_scale_color_f
|
||||
// Access: Public
|
||||
// Description: Converts a pair of integers into the _v4 member. See
|
||||
// one-parameter maybe_scale_color_f() for more info.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE void GeomVertexColumn::Packer::
|
||||
maybe_scale_color_f(unsigned int a, unsigned int b, unsigned int c,
|
||||
unsigned int d) {
|
||||
if (_column->get_contents() == C_color) {
|
||||
_v4.set((float)a / 255.0f,
|
||||
(float)b / 255.0f,
|
||||
(float)c / 255.0f,
|
||||
(float)d / 255.0f);
|
||||
} else {
|
||||
_v4.set((float)a, (float)b, (float)c, (float)d);
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: GeomVertexColumn::Packer::maybe_unscale_color_f
|
||||
// Access: Public
|
||||
// Description: Converts a floating-point value to a uint8 value. If
|
||||
// the contents value indicates this is a color value,
|
||||
// scales it into the range 0..255 per convention;
|
||||
// otherwise leaves it alone.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE unsigned int GeomVertexColumn::Packer::
|
||||
maybe_unscale_color_f(float data) {
|
||||
if (_column->get_contents() == C_color) {
|
||||
return (unsigned int)(data * 255.0f);
|
||||
} else {
|
||||
return (unsigned int)data;
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: GeomVertexColumn::Packer::maybe_unscale_color_f
|
||||
// Access: Public
|
||||
// Description: Converts an LVecBase2f into a pair of uint8
|
||||
// values. See one-parameter maybe_unscale_color_f() for
|
||||
// more info.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE void GeomVertexColumn::Packer::
|
||||
maybe_unscale_color_f(const LVecBase2f &data) {
|
||||
if (_column->get_contents() == C_color) {
|
||||
_a = (unsigned int)(data[0] * 255.0f);
|
||||
_b = (unsigned int)(data[1] * 255.0f);
|
||||
} else {
|
||||
_a = (unsigned int)data[0];
|
||||
_b = (unsigned int)data[1];
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: GeomVertexColumn::Packer::maybe_unscale_color_f
|
||||
// Access: Public
|
||||
// Description: Converts an LVecBase3f into a pair of uint8
|
||||
// values. See one-parameter maybe_unscale_color_f() for
|
||||
// more info.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE void GeomVertexColumn::Packer::
|
||||
maybe_unscale_color_f(const LVecBase3f &data) {
|
||||
if (_column->get_contents() == C_color) {
|
||||
_a = (unsigned int)(data[0] * 255.0f);
|
||||
_b = (unsigned int)(data[1] * 255.0f);
|
||||
_c = (unsigned int)(data[2] * 255.0f);
|
||||
} else {
|
||||
_a = (unsigned int)data[0];
|
||||
_b = (unsigned int)data[1];
|
||||
_c = (unsigned int)data[2];
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: GeomVertexColumn::Packer::maybe_unscale_color_f
|
||||
// Access: Public
|
||||
// Description: Converts an LVecBase4f into a pair of uint8
|
||||
// values. See one-parameter maybe_unscale_color_f() for
|
||||
// more info.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE void GeomVertexColumn::Packer::
|
||||
maybe_unscale_color_f(const LVecBase4f &data) {
|
||||
if (_column->get_contents() == C_color) {
|
||||
_a = (unsigned int)(data[0] * 255.0f);
|
||||
_b = (unsigned int)(data[1] * 255.0f);
|
||||
_c = (unsigned int)(data[2] * 255.0f);
|
||||
_d = (unsigned int)(data[3] * 255.0f);
|
||||
} else {
|
||||
_a = (unsigned int)data[0];
|
||||
_b = (unsigned int)data[1];
|
||||
_c = (unsigned int)data[2];
|
||||
_d = (unsigned int)data[3];
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: GeomVertexColumn::Packer::maybe_scale_color_d
|
||||
// Access: Public
|
||||
// Description: Converts an integer (typically a uint8) value to a
|
||||
// floating-point value. If the contents value
|
||||
// indicates this is a color value, scales it into the
|
||||
// range 0..1 per convention; otherwise leaves it alone.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE double GeomVertexColumn::Packer::
|
||||
maybe_scale_color_d(unsigned int value) {
|
||||
if (_column->get_contents() == C_color) {
|
||||
return (double)value / 255.0;
|
||||
} else {
|
||||
return (double)value;
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: GeomVertexColumn::Packer::maybe_scale_color_d
|
||||
// Access: Public
|
||||
// Description: Converts a pair of integers into the _v2d member. See
|
||||
// one-parameter maybe_scale_color_d() for more info.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE void GeomVertexColumn::Packer::
|
||||
maybe_scale_color_d(unsigned int a, unsigned int b) {
|
||||
if (_column->get_contents() == C_color) {
|
||||
_v2d.set((double)a / 255.0,
|
||||
(double)b / 255.0);
|
||||
} else {
|
||||
_v2d.set((double)a, (double)b);
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: GeomVertexColumn::Packer::maybe_scale_color_d
|
||||
// Access: Public
|
||||
// Description: Converts a pair of integers into the _v3d member. See
|
||||
// one-parameter maybe_scale_color_d() for more info.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE void GeomVertexColumn::Packer::
|
||||
maybe_scale_color_d(unsigned int a, unsigned int b, unsigned int c) {
|
||||
if (_column->get_contents() == C_color) {
|
||||
_v3d.set((double)a / 255.0,
|
||||
(double)b / 255.0,
|
||||
(double)c / 255.0);
|
||||
} else {
|
||||
_v3d.set((double)a, (double)b, (double)c);
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: GeomVertexColumn::Packer::maybe_scale_color_d
|
||||
// Access: Public
|
||||
// Description: Converts a pair of integers into the _v4d member. See
|
||||
// one-parameter maybe_scale_color_d() for more info.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE void GeomVertexColumn::Packer::
|
||||
maybe_scale_color_d(unsigned int a, unsigned int b, unsigned int c,
|
||||
unsigned int d) {
|
||||
if (_column->get_contents() == C_color) {
|
||||
_v4d.set((double)a / 255.0,
|
||||
(double)b / 255.0,
|
||||
(double)c / 255.0,
|
||||
(double)d / 255.0);
|
||||
} else {
|
||||
_v4d.set((double)a, (double)b, (double)c, (double)d);
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: GeomVertexColumn::Packer::maybe_unscale_color_d
|
||||
// Access: Public
|
||||
// Description: Converts a floating-point value to a uint8 value. If
|
||||
// the contents value indicates this is a color value,
|
||||
// scales it into the range 0..255 per convention;
|
||||
// otherwise leaves it alone.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE unsigned int GeomVertexColumn::Packer::
|
||||
maybe_unscale_color_d(double data) {
|
||||
if (_column->get_contents() == C_color) {
|
||||
return (unsigned int)(data * 255.0);
|
||||
} else {
|
||||
return (unsigned int)data;
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: GeomVertexColumn::Packer::maybe_unscale_color_d
|
||||
// Access: Public
|
||||
// Description: Converts an LVecBase2d into a pair of uint8
|
||||
// values. See one-parameter maybe_unscale_color_d() for
|
||||
// more info.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE void GeomVertexColumn::Packer::
|
||||
maybe_unscale_color_d(const LVecBase2d &data) {
|
||||
if (_column->get_contents() == C_color) {
|
||||
_a = (unsigned int)(data[0] * 255.0);
|
||||
_b = (unsigned int)(data[1] * 255.0);
|
||||
} else {
|
||||
_a = (unsigned int)data[0];
|
||||
_b = (unsigned int)data[1];
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: GeomVertexColumn::Packer::maybe_unscale_color_d
|
||||
// Access: Public
|
||||
// Description: Converts an LVecBase3d into a pair of uint8
|
||||
// values. See one-parameter maybe_unscale_color_d() for
|
||||
// more info.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE void GeomVertexColumn::Packer::
|
||||
maybe_unscale_color_d(const LVecBase3d &data) {
|
||||
if (_column->get_contents() == C_color) {
|
||||
_a = (unsigned int)(data[0] * 255.0);
|
||||
_b = (unsigned int)(data[1] * 255.0);
|
||||
_c = (unsigned int)(data[2] * 255.0);
|
||||
} else {
|
||||
_a = (unsigned int)data[0];
|
||||
_b = (unsigned int)data[1];
|
||||
_c = (unsigned int)data[2];
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: GeomVertexColumn::Packer::maybe_unscale_color_d
|
||||
// Access: Public
|
||||
// Description: Converts an LVecBase4d into a pair of uint8
|
||||
// values. See one-parameter maybe_unscale_color_d() for
|
||||
// more info.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE void GeomVertexColumn::Packer::
|
||||
maybe_unscale_color_d(const LVecBase4d &data) {
|
||||
if (_column->get_contents() == C_color) {
|
||||
_a = (unsigned int)(data[0] * 255.0);
|
||||
_b = (unsigned int)(data[1] * 255.0);
|
||||
_c = (unsigned int)(data[2] * 255.0);
|
||||
_d = (unsigned int)(data[3] * 255.0);
|
||||
} else {
|
||||
_a = (unsigned int)data[0];
|
||||
_b = (unsigned int)data[1];
|
||||
_c = (unsigned int)data[2];
|
||||
_d = (unsigned int)data[3];
|
||||
}
|
||||
}
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load Diff
|
|
@ -150,30 +150,6 @@ private:
|
|||
return "Packer";
|
||||
}
|
||||
|
||||
INLINE float maybe_scale_color_f(unsigned int value);
|
||||
INLINE void maybe_scale_color_f(unsigned int a, unsigned int b);
|
||||
INLINE void maybe_scale_color_f(unsigned int a, unsigned int b,
|
||||
unsigned int c);
|
||||
INLINE void maybe_scale_color_f(unsigned int a, unsigned int b,
|
||||
unsigned int c, unsigned int d);
|
||||
|
||||
INLINE unsigned int maybe_unscale_color_f(float data);
|
||||
INLINE void maybe_unscale_color_f(const LVecBase2f &data);
|
||||
INLINE void maybe_unscale_color_f(const LVecBase3f &data);
|
||||
INLINE void maybe_unscale_color_f(const LVecBase4f &data);
|
||||
|
||||
INLINE double maybe_scale_color_d(unsigned int value);
|
||||
INLINE void maybe_scale_color_d(unsigned int a, unsigned int b);
|
||||
INLINE void maybe_scale_color_d(unsigned int a, unsigned int b,
|
||||
unsigned int c);
|
||||
INLINE void maybe_scale_color_d(unsigned int a, unsigned int b,
|
||||
unsigned int c, unsigned int d);
|
||||
|
||||
INLINE unsigned int maybe_unscale_color_d(double data);
|
||||
INLINE void maybe_unscale_color_d(const LVecBase2d &data);
|
||||
INLINE void maybe_unscale_color_d(const LVecBase3d &data);
|
||||
INLINE void maybe_unscale_color_d(const LVecBase4d &data);
|
||||
|
||||
const GeomVertexColumn *_column;
|
||||
LVecBase2f _v2;
|
||||
LVecBase3f _v3;
|
||||
|
|
@ -191,7 +167,7 @@ private:
|
|||
// This is a specialization on the generic Packer that handles
|
||||
// points, which are special because the fourth component, if not
|
||||
// present in the data, is implicitly 1.0; and if it is present,
|
||||
// than any three-component or smaller return is implicitly divided
|
||||
// then any three-component or smaller return is implicitly divided
|
||||
// by the fourth component.
|
||||
class Packer_point : public Packer {
|
||||
public:
|
||||
|
|
@ -199,14 +175,17 @@ private:
|
|||
virtual const LVecBase2f &get_data2f(const unsigned char *pointer);
|
||||
virtual const LVecBase3f &get_data3f(const unsigned char *pointer);
|
||||
virtual const LVecBase4f &get_data4f(const unsigned char *pointer);
|
||||
|
||||
virtual double get_data1d(const unsigned char *pointer);
|
||||
virtual const LVecBase2d &get_data2d(const unsigned char *pointer);
|
||||
virtual const LVecBase3d &get_data3d(const unsigned char *pointer);
|
||||
virtual const LVecBase4d &get_data4d(const unsigned char *pointer);
|
||||
|
||||
virtual void set_data1f(unsigned char *pointer, float data);
|
||||
virtual void set_data2f(unsigned char *pointer, const LVecBase2f &data);
|
||||
virtual void set_data3f(unsigned char *pointer, const LVecBase3f &data);
|
||||
virtual void set_data4f(unsigned char *pointer, const LVecBase4f &data);
|
||||
|
||||
virtual void set_data1d(unsigned char *pointer, double data);
|
||||
virtual void set_data2d(unsigned char *pointer, const LVecBase2d &data);
|
||||
virtual void set_data3d(unsigned char *pointer, const LVecBase3d &data);
|
||||
|
|
@ -219,17 +198,28 @@ private:
|
|||
|
||||
// This is similar to Packer_point, in that the fourth component is
|
||||
// implicitly 1.0 if it is not present in the data, but we never
|
||||
// divide by alpha.
|
||||
// divide by alpha. It also transforms integer colors to the 0-1 range.
|
||||
class Packer_color : public Packer {
|
||||
public:
|
||||
virtual float get_data1f(const unsigned char *pointer);
|
||||
virtual const LVecBase2f &get_data2f(const unsigned char *pointer);
|
||||
virtual const LVecBase3f &get_data3f(const unsigned char *pointer);
|
||||
virtual const LVecBase4f &get_data4f(const unsigned char *pointer);
|
||||
|
||||
virtual double get_data1d(const unsigned char *pointer);
|
||||
virtual const LVecBase2d &get_data2d(const unsigned char *pointer);
|
||||
virtual const LVecBase3d &get_data3d(const unsigned char *pointer);
|
||||
virtual const LVecBase4d &get_data4d(const unsigned char *pointer);
|
||||
|
||||
virtual void set_data1f(unsigned char *pointer, float data);
|
||||
virtual void set_data2f(unsigned char *pointer, const LVecBase2f &data);
|
||||
virtual void set_data3f(unsigned char *pointer, const LVecBase3f &data);
|
||||
virtual void set_data4f(unsigned char *pointer, const LVecBase4f &data);
|
||||
|
||||
virtual void set_data1d(unsigned char *pointer, double data);
|
||||
virtual void set_data2d(unsigned char *pointer, const LVecBase2d &data);
|
||||
virtual void set_data3d(unsigned char *pointer, const LVecBase3d &data);
|
||||
virtual void set_data4d(unsigned char *pointer, const LVecBase4d &data);
|
||||
|
||||
virtual const char *get_name() const {
|
||||
return "Packer_color";
|
||||
|
|
|
|||
|
|
@ -2368,7 +2368,7 @@ get_array_info(const InternalName *name,
|
|||
const GeomVertexArrayDataHandle *&array_reader,
|
||||
int &num_values,
|
||||
GeomVertexDataPipelineReader::NumericType &numeric_type,
|
||||
int &start, int &stride, int &divisor,
|
||||
bool &normalized, int &start, int &stride, int &divisor,
|
||||
int &num_elements, int &element_stride) const {
|
||||
nassertr(_got_array_readers, false);
|
||||
int array_index;
|
||||
|
|
@ -2377,6 +2377,7 @@ get_array_info(const InternalName *name,
|
|||
array_reader = _array_readers[array_index];
|
||||
num_values = column->get_num_values();
|
||||
numeric_type = column->get_numeric_type();
|
||||
normalized = (column->get_contents() == GeomEnums::C_color);
|
||||
start = column->get_start();
|
||||
stride = _cdata->_format->get_array(array_index)->get_stride();
|
||||
divisor = _cdata->_format->get_array(array_index)->get_divisor();
|
||||
|
|
@ -2553,11 +2554,11 @@ set_num_rows(int n) {
|
|||
int num_values = column->get_num_values();
|
||||
|
||||
switch (column->get_numeric_type()) {
|
||||
case NT_packed_dcba:
|
||||
case NT_packed_dabc:
|
||||
case NT_uint8:
|
||||
case NT_uint16:
|
||||
case NT_uint32:
|
||||
case NT_packed_dcba:
|
||||
case NT_packed_dabc:
|
||||
while (pointer < stop) {
|
||||
memset(pointer, 0xff, column->get_total_bytes());
|
||||
pointer += stride;
|
||||
|
|
@ -2585,6 +2586,9 @@ set_num_rows(int n) {
|
|||
break;
|
||||
|
||||
case NT_stdfloat:
|
||||
case NT_int8:
|
||||
case NT_int16:
|
||||
case NT_int32:
|
||||
// Shouldn't have this type in the format.
|
||||
nassertr(false, false);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -453,7 +453,7 @@ public:
|
|||
bool get_array_info(const InternalName *name,
|
||||
const GeomVertexArrayDataHandle *&array_reader,
|
||||
int &num_values, NumericType &numeric_type,
|
||||
int &start, int &stride, int &divisor,
|
||||
bool &normalized, int &start, int &stride, int &divisor,
|
||||
int &num_elements, int &element_stride) const;
|
||||
|
||||
INLINE bool has_vertex() const;
|
||||
|
|
|
|||
|
|
@ -906,20 +906,6 @@ set_data2i(int a, int b) {
|
|||
set_data2i(LVecBase2i(a, b));
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: GeomVertexWriter::set_data2i
|
||||
// Access: Published
|
||||
// Description: Sets the write row to a particular 2-component
|
||||
// value, and advances the write row.
|
||||
//
|
||||
// It is an error for the write row to advance past
|
||||
// the end of data.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE void GeomVertexWriter::
|
||||
set_data2i(const int data[2]) {
|
||||
set_data2i(LVecBase2i(data[0], data[1]));
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: GeomVertexWriter::set_data2i
|
||||
// Access: Published
|
||||
|
|
@ -949,20 +935,6 @@ set_data3i(int a, int b, int c) {
|
|||
set_data3i(LVecBase3i(a, b, c));
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: GeomVertexWriter::set_data3i
|
||||
// Access: Published
|
||||
// Description: Sets the write row to a particular 3-component
|
||||
// value, and advances the write row.
|
||||
//
|
||||
// It is an error for the write row to advance past
|
||||
// the end of data.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE void GeomVertexWriter::
|
||||
set_data3i(const int data[3]) {
|
||||
set_data3i(LVecBase3i(data[0], data[1], data[2]));
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: GeomVertexWriter::set_data3i
|
||||
// Access: Published
|
||||
|
|
@ -992,20 +964,6 @@ set_data4i(int a, int b, int c, int d) {
|
|||
set_data4i(LVecBase4i(a, b, c, d));
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: GeomVertexWriter::set_data4i
|
||||
// Access: Published
|
||||
// Description: Sets the write row to a particular 4-component
|
||||
// value, and advances the write row.
|
||||
//
|
||||
// It is an error for the write row to advance past
|
||||
// the end of data.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE void GeomVertexWriter::
|
||||
set_data4i(const int data[4]) {
|
||||
set_data4i(LVecBase4i(data[0], data[1], data[2], data[3]));
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: GeomVertexWriter::set_data4i
|
||||
// Access: Published
|
||||
|
|
@ -1526,20 +1484,6 @@ add_data2i(int a, int b) {
|
|||
add_data2i(LVecBase2i(a, b));
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: GeomVertexWriter::add_data2i
|
||||
// Access: Published
|
||||
// Description: Sets the write row to a particular 2-component
|
||||
// value, and advances the write row.
|
||||
//
|
||||
// If the write row advances past the end of data,
|
||||
// implicitly adds a new row to the data.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE void GeomVertexWriter::
|
||||
add_data2i(const int data[2]) {
|
||||
add_data2i(LVecBase2i(data[0], data[1]));
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: GeomVertexWriter::add_data2i
|
||||
// Access: Published
|
||||
|
|
@ -1569,20 +1513,6 @@ add_data3i(int a, int b, int c) {
|
|||
add_data3i(LVecBase3i(a, b, c));
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: GeomVertexWriter::add_data3i
|
||||
// Access: Published
|
||||
// Description: Sets the write row to a particular 3-component
|
||||
// value, and advances the write row.
|
||||
//
|
||||
// If the write row advances past the end of data,
|
||||
// implicitly adds a new row to the data.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE void GeomVertexWriter::
|
||||
add_data3i(const int data[3]) {
|
||||
add_data3i(LVecBase3i(data[0], data[1], data[2]));
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: GeomVertexWriter::add_data3i
|
||||
// Access: Published
|
||||
|
|
@ -1612,20 +1542,6 @@ add_data4i(int a, int b, int c, int d) {
|
|||
add_data4i(LVecBase4i(a, b, c, d));
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: GeomVertexWriter::add_data4i
|
||||
// Access: Published
|
||||
// Description: Sets the write row to a particular 4-component
|
||||
// value, and advances the write row.
|
||||
//
|
||||
// If the write row advances past the end of data,
|
||||
// implicitly adds a new row to the data.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE void GeomVertexWriter::
|
||||
add_data4i(const int data[4]) {
|
||||
add_data4i(LVecBase4i(data[0], data[1], data[2], data[3]));
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: GeomVertexWriter::add_data4i
|
||||
// Access: Published
|
||||
|
|
|
|||
|
|
@ -144,13 +144,10 @@ PUBLISHED:
|
|||
|
||||
INLINE void set_data1i(int data);
|
||||
INLINE void set_data2i(int a, int b);
|
||||
INLINE void set_data2i(const int data[2]);
|
||||
INLINE void set_data2i(const LVecBase2i &data);
|
||||
INLINE void set_data3i(int a, int b, int c);
|
||||
INLINE void set_data3i(const int data[3]);
|
||||
INLINE void set_data3i(const LVecBase3i &data);
|
||||
INLINE void set_data4i(int a, int b, int c, int d);
|
||||
INLINE void set_data4i(const int data[4]);
|
||||
INLINE void set_data4i(const LVecBase4i &data);
|
||||
|
||||
INLINE void add_data1f(float data);
|
||||
|
|
@ -185,13 +182,10 @@ PUBLISHED:
|
|||
|
||||
INLINE void add_data1i(int data);
|
||||
INLINE void add_data2i(int a, int b);
|
||||
INLINE void add_data2i(const int data[2]);
|
||||
INLINE void add_data2i(const LVecBase2i &data);
|
||||
INLINE void add_data3i(int a, int b, int c);
|
||||
INLINE void add_data3i(const int data[3]);
|
||||
INLINE void add_data3i(const LVecBase3i &data);
|
||||
INLINE void add_data4i(int a, int b, int c, int d);
|
||||
INLINE void add_data4i(const int data[4]);
|
||||
INLINE void add_data4i(const LVecBase4i &data);
|
||||
|
||||
void output(ostream &out) const;
|
||||
|
|
|
|||
Loading…
Reference in New Issue