regularize NT_packed_8888 into NT_packed_abcd etc.
This commit is contained in:
parent
43768bf3fd
commit
ec8c95c675
|
|
@ -24,8 +24,8 @@
|
|||
////////////////////////////////////////////////////////////////////
|
||||
INLINE DXGeomMunger8::
|
||||
DXGeomMunger8(GraphicsStateGuardian *gsg, const RenderState *state) :
|
||||
StandardMunger(gsg, state, 1, qpGeomVertexDataType::NT_packed_8888,
|
||||
qpGeomVertexDataType::C_argb)
|
||||
StandardMunger(gsg, state, 1, qpGeomVertexDataType::NT_packed_dabc,
|
||||
qpGeomVertexDataType::C_color)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -78,7 +78,7 @@ munge_format_impl(const qpGeomVertexFormat *orig,
|
|||
// space for the index.
|
||||
new_array_format->add_data_type
|
||||
(InternalName::get_transform_index(), 1,
|
||||
qpGeomVertexDataType::NT_packed_8888, qpGeomVertexDataType::C_index);
|
||||
qpGeomVertexDataType::NT_packed_dcba, qpGeomVertexDataType::C_index);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -91,8 +91,8 @@ munge_format_impl(const qpGeomVertexFormat *orig,
|
|||
|
||||
if (color_type != (const qpGeomVertexDataType *)NULL) {
|
||||
new_array_format->add_data_type
|
||||
(InternalName::get_color(), 1, qpGeomVertexDataType::NT_packed_8888,
|
||||
qpGeomVertexDataType::C_argb);
|
||||
(InternalName::get_color(), 1, qpGeomVertexDataType::NT_packed_dabc,
|
||||
qpGeomVertexDataType::C_color);
|
||||
new_format->remove_data_type(color_type->get_name());
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1932,7 +1932,7 @@ make_vertex_data(const EggRenderState *render_state,
|
|||
if (vertex_pool->has_colors()) {
|
||||
array_format->add_data_type
|
||||
(InternalName::get_color(), 1,
|
||||
qpGeomVertexDataType::NT_packed_8888, qpGeomVertexDataType::C_argb);
|
||||
qpGeomVertexDataType::NT_packed_dabc, qpGeomVertexDataType::C_color);
|
||||
}
|
||||
|
||||
vector_string uv_names;
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@
|
|||
INLINE CLP(GeomMunger)::
|
||||
CLP(GeomMunger)(GraphicsStateGuardian *gsg, const RenderState *state) :
|
||||
StandardMunger(gsg, state, 4, qpGeomVertexDataType::NT_uint8,
|
||||
qpGeomVertexDataType::C_rgba),
|
||||
qpGeomVertexDataType::C_color),
|
||||
_gsg(gsg),
|
||||
_texture(state->get_texture()),
|
||||
_tex_gen(state->get_tex_gen())
|
||||
|
|
|
|||
|
|
@ -52,8 +52,7 @@ munge_format_impl(const qpGeomVertexFormat *orig,
|
|||
const qpGeomVertexDataType *color_type =
|
||||
orig->get_data_type(InternalName::get_color());
|
||||
if (color_type != (qpGeomVertexDataType *)NULL &&
|
||||
(color_type->get_numeric_type() == qpGeomVertexDataType::NT_packed_8888 ||
|
||||
color_type->get_contents() != qpGeomVertexDataType::C_rgba)) {
|
||||
color_type->get_numeric_type() == qpGeomVertexDataType::NT_packed_dabc) {
|
||||
// We need to convert the color format; OpenGL doesn't support the
|
||||
// byte order of DirectX's packed ARGB format.
|
||||
int color_array = orig->get_array_with(InternalName::get_color());
|
||||
|
|
@ -63,7 +62,7 @@ munge_format_impl(const qpGeomVertexFormat *orig,
|
|||
// Replace the existing color format with the new format.
|
||||
new_array_format->add_data_type
|
||||
(InternalName::get_color(), 4, qpGeomVertexDataType::NT_uint8,
|
||||
qpGeomVertexDataType::C_rgba, color_type->get_start());
|
||||
qpGeomVertexDataType::C_color, color_type->get_start());
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
|||
|
|
@ -2134,22 +2134,22 @@ begin_draw_primitives(const qpGeom *geom, const qpGeomMunger *munger,
|
|||
}
|
||||
|
||||
const qpGeomVertexArrayData *array_data;
|
||||
int num_components;
|
||||
int num_values;
|
||||
qpGeomVertexDataType::NumericType numeric_type;
|
||||
int start;
|
||||
int stride;
|
||||
|
||||
if (_vertex_data->get_array_info(InternalName::get_vertex(),
|
||||
array_data, num_components, numeric_type,
|
||||
array_data, num_values, numeric_type,
|
||||
start, stride)) {
|
||||
const unsigned char *client_pointer = setup_array_data(array_data);
|
||||
GLP(VertexPointer)(num_components, get_numeric_type(numeric_type),
|
||||
GLP(VertexPointer)(num_values, get_numeric_type(numeric_type),
|
||||
stride, client_pointer + start);
|
||||
GLP(EnableClientState)(GL_VERTEX_ARRAY);
|
||||
}
|
||||
|
||||
if (_vertex_data->get_array_info(InternalName::get_normal(),
|
||||
array_data, num_components, numeric_type,
|
||||
array_data, num_values, numeric_type,
|
||||
start, stride)) {
|
||||
const unsigned char *client_pointer = setup_array_data(array_data);
|
||||
GLP(NormalPointer)(get_numeric_type(numeric_type), stride,
|
||||
|
|
@ -2160,11 +2160,11 @@ begin_draw_primitives(const qpGeom *geom, const qpGeomMunger *munger,
|
|||
}
|
||||
|
||||
if (_vertex_data->get_array_info(InternalName::get_color(),
|
||||
array_data, num_components, numeric_type,
|
||||
array_data, num_values, numeric_type,
|
||||
start, stride) &&
|
||||
numeric_type != qpGeomVertexDataType::NT_packed_8888) {
|
||||
numeric_type != qpGeomVertexDataType::NT_packed_dabc) {
|
||||
const unsigned char *client_pointer = setup_array_data(array_data);
|
||||
GLP(ColorPointer)(num_components, get_numeric_type(numeric_type),
|
||||
GLP(ColorPointer)(num_values, get_numeric_type(numeric_type),
|
||||
stride, client_pointer + start);
|
||||
GLP(EnableClientState)(GL_COLOR_ARRAY);
|
||||
} else {
|
||||
|
|
@ -2189,11 +2189,11 @@ begin_draw_primitives(const qpGeom *geom, const qpGeomMunger *munger,
|
|||
// texcoords issued for it.
|
||||
const InternalName *name = stage->get_texcoord_name();
|
||||
|
||||
if (_vertex_data->get_array_info(name, array_data, num_components,
|
||||
if (_vertex_data->get_array_info(name, array_data, num_values,
|
||||
numeric_type, start, stride)) {
|
||||
// The vertex data does have texcoords for this stage.
|
||||
const unsigned char *client_pointer = setup_array_data(array_data);
|
||||
GLP(TexCoordPointer)(num_components, get_numeric_type(numeric_type),
|
||||
GLP(TexCoordPointer)(num_values, get_numeric_type(numeric_type),
|
||||
stride, client_pointer + start);
|
||||
GLP(EnableClientState)(GL_TEXTURE_COORD_ARRAY);
|
||||
|
||||
|
|
@ -4436,13 +4436,12 @@ get_numeric_type(qpGeomVertexDataType::NumericType numeric_type) {
|
|||
return GL_UNSIGNED_SHORT;
|
||||
|
||||
case qpGeomVertexDataType::NT_uint8:
|
||||
case qpGeomVertexDataType::NT_packed_dcba:
|
||||
case qpGeomVertexDataType::NT_packed_dabc:
|
||||
return GL_UNSIGNED_BYTE;
|
||||
|
||||
case qpGeomVertexDataType::NT_float32:
|
||||
return GL_FLOAT;
|
||||
|
||||
case qpGeomVertexDataType::NT_packed_8888:
|
||||
break;
|
||||
}
|
||||
|
||||
GLCAT.error()
|
||||
|
|
|
|||
|
|
@ -264,13 +264,13 @@ animate_vertices_cull() const {
|
|||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: qpGeomVertexData::pack_8888
|
||||
// Function: qpGeomVertexData::pack_abcd
|
||||
// Access: Public, Static
|
||||
// Description: Packs four values in a DirectX-style NT_packed_8888
|
||||
// Description: Packs four values in a DirectX-style NT_packed_abcd
|
||||
// value.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE PN_uint32 qpGeomVertexData::
|
||||
pack_8888(unsigned int a, unsigned int b,
|
||||
pack_abcd(unsigned int a, unsigned int b,
|
||||
unsigned int c, unsigned int d) {
|
||||
return (((a & 0xff) << 24) |
|
||||
((b & 0xff) << 16) |
|
||||
|
|
@ -279,46 +279,46 @@ pack_8888(unsigned int a, unsigned int b,
|
|||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: qpGeomVertexData::unpack_8888_a
|
||||
// Function: qpGeomVertexData::unpack_abcd_a
|
||||
// Access: Public, Static
|
||||
// Description: Returns the first packed value from a DirectX-style
|
||||
// NT_packed_8888.
|
||||
// NT_packed_abcd.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE unsigned int qpGeomVertexData::
|
||||
unpack_8888_a(PN_uint32 data) {
|
||||
unpack_abcd_a(PN_uint32 data) {
|
||||
return (data >> 24) & 0xff;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: qpGeomVertexData::unpack_8888_b
|
||||
// Function: qpGeomVertexData::unpack_abcd_b
|
||||
// Access: Public, Static
|
||||
// Description: Returns the second packed value from a DirectX-style
|
||||
// NT_packed_8888.
|
||||
// NT_packed_abcd.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE unsigned int qpGeomVertexData::
|
||||
unpack_8888_b(PN_uint32 data) {
|
||||
unpack_abcd_b(PN_uint32 data) {
|
||||
return (data >> 16) & 0xff;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: qpGeomVertexData::unpack_8888_c
|
||||
// Function: qpGeomVertexData::unpack_abcd_c
|
||||
// Access: Public, Static
|
||||
// Description: Returns the third packed value from a DirectX-style
|
||||
// NT_packed_8888.
|
||||
// NT_packed_abcd.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE unsigned int qpGeomVertexData::
|
||||
unpack_8888_c(PN_uint32 data) {
|
||||
unpack_abcd_c(PN_uint32 data) {
|
||||
return (data >> 8) & 0xff;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: qpGeomVertexData::unpack_8888_d
|
||||
// Function: qpGeomVertexData::unpack_abcd_d
|
||||
// Access: Public, Static
|
||||
// Description: Returns the fourth packed value from a DirectX-style
|
||||
// NT_packed_8888.
|
||||
// NT_packed_abcd.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE unsigned int qpGeomVertexData::
|
||||
unpack_8888_d(PN_uint32 data) {
|
||||
unpack_abcd_d(PN_uint32 data) {
|
||||
return data & 0xff;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -515,7 +515,7 @@ copy_from(const qpGeomVertexData &source, bool keep_data_objects) {
|
|||
already_added);
|
||||
}
|
||||
weight.set_data4f(weights);
|
||||
index.set_data4i(indices[3], indices[2], indices[1], indices[0]);
|
||||
index.set_data4i(indices);
|
||||
}
|
||||
} else {
|
||||
// Build a nonindexed transform array. This means we have to
|
||||
|
|
@ -787,9 +787,9 @@ write(ostream &out, int indent_level) const {
|
|||
// Description: A convenience function to collect together the
|
||||
// important parts of the array data for rendering.
|
||||
// Given the name of a data type, fills in the start of
|
||||
// the array, the number of floats for each vertex, the
|
||||
// starting bytes number, and the number of bytes to
|
||||
// increment for each consecutive vertex.
|
||||
// the array, the number of numeric values for each
|
||||
// vertex, the starting bytes number, and the number of
|
||||
// bytes to increment for each consecutive vertex.
|
||||
//
|
||||
// The return value is true if the named array data
|
||||
// exists in this record, or false if it does not (in
|
||||
|
|
@ -798,7 +798,7 @@ write(ostream &out, int indent_level) const {
|
|||
bool qpGeomVertexData::
|
||||
get_array_info(const InternalName *name,
|
||||
const qpGeomVertexArrayData *&array_data,
|
||||
int &num_components,
|
||||
int &num_values,
|
||||
qpGeomVertexDataType::NumericType &numeric_type,
|
||||
int &start, int &stride) const {
|
||||
int array_index;
|
||||
|
|
@ -806,7 +806,7 @@ get_array_info(const InternalName *name,
|
|||
if (_format->get_array_info(name, array_index, data_type)) {
|
||||
CDReader cdata(_cycler);
|
||||
array_data = cdata->_arrays[array_index];
|
||||
num_components = data_type->get_num_components();
|
||||
num_values = data_type->get_num_values();
|
||||
numeric_type = data_type->get_numeric_type();
|
||||
start = data_type->get_start();
|
||||
stride = _format->get_array(array_index)->get_stride();
|
||||
|
|
@ -913,10 +913,10 @@ packed_argb_to_uint8_rgba(unsigned char *to, int to_stride,
|
|||
|
||||
while (num_records > 0) {
|
||||
PN_uint32 dword = *(const PN_uint32 *)from;
|
||||
to[0] = unpack_8888_b(dword);
|
||||
to[1] = unpack_8888_c(dword);
|
||||
to[2] = unpack_8888_d(dword);
|
||||
to[3] = unpack_8888_a(dword);
|
||||
to[0] = unpack_abcd_b(dword);
|
||||
to[1] = unpack_abcd_c(dword);
|
||||
to[2] = unpack_abcd_d(dword);
|
||||
to[3] = unpack_abcd_a(dword);
|
||||
|
||||
to += to_stride;
|
||||
from += from_stride;
|
||||
|
|
@ -942,7 +942,7 @@ uint8_rgba_to_packed_argb(unsigned char *to, int to_stride,
|
|||
}
|
||||
|
||||
while (num_records > 0) {
|
||||
*(PN_uint32 *)to = pack_8888(from[3], from[0], from[1], from[2]);
|
||||
*(PN_uint32 *)to = pack_abcd(from[3], from[0], from[1], from[2]);
|
||||
|
||||
to += to_stride;
|
||||
from += from_stride;
|
||||
|
|
|
|||
|
|
@ -134,16 +134,16 @@ public:
|
|||
|
||||
bool get_array_info(const InternalName *name,
|
||||
const qpGeomVertexArrayData *&array_data,
|
||||
int &num_components,
|
||||
int &num_values,
|
||||
qpGeomVertexDataType::NumericType &numeric_type,
|
||||
int &start, int &stride) const;
|
||||
|
||||
static INLINE PN_uint32 pack_8888(unsigned int a, unsigned int b,
|
||||
static INLINE PN_uint32 pack_abcd(unsigned int a, unsigned int b,
|
||||
unsigned int c, unsigned int d);
|
||||
static INLINE unsigned int unpack_8888_a(PN_uint32 data);
|
||||
static INLINE unsigned int unpack_8888_b(PN_uint32 data);
|
||||
static INLINE unsigned int unpack_8888_c(PN_uint32 data);
|
||||
static INLINE unsigned int unpack_8888_d(PN_uint32 data);
|
||||
static INLINE unsigned int unpack_abcd_a(PN_uint32 data);
|
||||
static INLINE unsigned int unpack_abcd_b(PN_uint32 data);
|
||||
static INLINE unsigned int unpack_abcd_c(PN_uint32 data);
|
||||
static INLINE unsigned int unpack_abcd_d(PN_uint32 data);
|
||||
|
||||
private:
|
||||
CPT(qpGeomVertexData) do_animate_vertices(bool from_app) const;
|
||||
|
|
|
|||
|
|
@ -87,7 +87,7 @@ get_num_components() const {
|
|||
// into each element. This is usually, but not always,
|
||||
// the same thing as get_num_components(); the
|
||||
// difference is in the case of a composite numeric type
|
||||
// like NT_packed_8888, which has four numeric values
|
||||
// like NT_packed_dcba, which has four numeric values
|
||||
// per component.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE int qpGeomVertexDataType::
|
||||
|
|
@ -197,8 +197,8 @@ overlaps_with(int start_byte, int num_bytes) const {
|
|||
////////////////////////////////////////////////////////////////////
|
||||
INLINE bool qpGeomVertexDataType::
|
||||
is_bytewise_equivalent(const qpGeomVertexDataType &other) const {
|
||||
// The _contents are relevant, because they specify such things as
|
||||
// the difference between C_rgba and C_argb.
|
||||
// Not sure if the contents are relevant, but let's say that they
|
||||
// are.
|
||||
return (_num_components == other._num_components &&
|
||||
_numeric_type == other._numeric_type &&
|
||||
_contents == other._contents);
|
||||
|
|
@ -208,28 +208,28 @@ is_bytewise_equivalent(const qpGeomVertexDataType &other) const {
|
|||
// Function: qpGeomVertexDataType::is_packed_argb
|
||||
// Access: Public
|
||||
// Description: Returns true if this data type is the standard
|
||||
// DirectX representation of 4-component color: C_argb,
|
||||
// in NT_packed_8888, with 1 component (4 values).
|
||||
// DirectX representation of 4-component color: C_color,
|
||||
// in NT_packed_dabc, with 1 component (4 values).
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE bool qpGeomVertexDataType::
|
||||
is_packed_argb() const {
|
||||
return (_num_components == 1 &&
|
||||
_numeric_type == NT_packed_8888 &&
|
||||
_contents == C_argb);
|
||||
_numeric_type == NT_packed_dabc &&
|
||||
_contents == C_color);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: qpGeomVertexDataType::is_uint8_rgba
|
||||
// Access: Public
|
||||
// Description: Returns true if this data type is the standard
|
||||
// OpenGL representation of 4-component color: C_rgba,
|
||||
// OpenGL representation of 4-component color: C_color,
|
||||
// in NT_uint8, with 4 components.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE bool qpGeomVertexDataType::
|
||||
is_uint8_rgba() const {
|
||||
return (_num_components == 4 &&
|
||||
_numeric_type == NT_uint8 &&
|
||||
_contents == C_rgba);
|
||||
_contents == C_color);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
|
|
|||
|
|
@ -45,7 +45,8 @@ qpGeomVertexDataType(const InternalName *name, int num_components,
|
|||
_component_bytes = 1;
|
||||
break;
|
||||
|
||||
case NT_packed_8888:
|
||||
case NT_packed_dcba:
|
||||
case NT_packed_dabc:
|
||||
_component_bytes = 4; // sizeof(PN_uint32)
|
||||
_num_values *= 4;
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -37,7 +37,8 @@ PUBLISHED:
|
|||
enum NumericType {
|
||||
NT_uint8, // An integer 0..255
|
||||
NT_uint16, // An integer 0..65535
|
||||
NT_packed_8888, // DirectX style, four byte values packed in a uint32
|
||||
NT_packed_dcba, // DirectX style, four byte values packed in a uint32
|
||||
NT_packed_dabc, // DirectX packed color order (ARGB)
|
||||
NT_float32, // A floating-point number
|
||||
};
|
||||
|
||||
|
|
@ -46,8 +47,7 @@ PUBLISHED:
|
|||
C_point, // A point in 3-space or 4-space
|
||||
C_vector, // A surface normal, tangent, or binormal
|
||||
C_texcoord, // A texture coordinate
|
||||
C_rgba, // RGB or RGBA, OpenGL-style order
|
||||
C_argb, // RGBA, DirectX-style packed color
|
||||
C_color, // 3- or 4-component color, ordered R, G, B, [A]
|
||||
C_index, // An index value into some other table
|
||||
C_morph_delta, // A delta from some base value, defining a blend shape
|
||||
};
|
||||
|
|
|
|||
|
|
@ -680,8 +680,8 @@ Registry() {
|
|||
qpGeomVertexDataType::NT_float32,
|
||||
qpGeomVertexDataType::C_point,
|
||||
InternalName::get_color(), 1,
|
||||
qpGeomVertexDataType::NT_packed_8888,
|
||||
qpGeomVertexDataType::C_argb));
|
||||
qpGeomVertexDataType::NT_packed_dabc,
|
||||
qpGeomVertexDataType::C_color));
|
||||
|
||||
_v3n3cp = register_format(new qpGeomVertexArrayFormat
|
||||
(InternalName::get_vertex(), 3,
|
||||
|
|
@ -691,16 +691,16 @@ Registry() {
|
|||
qpGeomVertexDataType::NT_float32,
|
||||
qpGeomVertexDataType::C_point,
|
||||
InternalName::get_color(), 1,
|
||||
qpGeomVertexDataType::NT_packed_8888,
|
||||
qpGeomVertexDataType::C_argb));
|
||||
qpGeomVertexDataType::NT_packed_dabc,
|
||||
qpGeomVertexDataType::C_color));
|
||||
|
||||
_v3cpt2 = register_format(new qpGeomVertexArrayFormat
|
||||
(InternalName::get_vertex(), 3,
|
||||
qpGeomVertexDataType::NT_float32,
|
||||
qpGeomVertexDataType::C_point,
|
||||
InternalName::get_color(), 1,
|
||||
qpGeomVertexDataType::NT_packed_8888,
|
||||
qpGeomVertexDataType::C_argb,
|
||||
qpGeomVertexDataType::NT_packed_dabc,
|
||||
qpGeomVertexDataType::C_color,
|
||||
InternalName::get_texcoord(), 2,
|
||||
qpGeomVertexDataType::NT_float32,
|
||||
qpGeomVertexDataType::C_texcoord));
|
||||
|
|
@ -713,8 +713,8 @@ Registry() {
|
|||
qpGeomVertexDataType::NT_float32,
|
||||
qpGeomVertexDataType::C_point,
|
||||
InternalName::get_color(), 1,
|
||||
qpGeomVertexDataType::NT_packed_8888,
|
||||
qpGeomVertexDataType::C_argb,
|
||||
qpGeomVertexDataType::NT_packed_dabc,
|
||||
qpGeomVertexDataType::C_color,
|
||||
InternalName::get_texcoord(), 2,
|
||||
qpGeomVertexDataType::NT_float32,
|
||||
qpGeomVertexDataType::C_texcoord));
|
||||
|
|
@ -728,7 +728,7 @@ Registry() {
|
|||
qpGeomVertexDataType::C_point,
|
||||
InternalName::get_color(), 4,
|
||||
qpGeomVertexDataType::NT_uint8,
|
||||
qpGeomVertexDataType::C_rgba));
|
||||
qpGeomVertexDataType::C_color));
|
||||
|
||||
_v3n3c4 = register_format(new qpGeomVertexArrayFormat
|
||||
(InternalName::get_vertex(), 3,
|
||||
|
|
@ -739,7 +739,7 @@ Registry() {
|
|||
qpGeomVertexDataType::C_point,
|
||||
InternalName::get_color(), 4,
|
||||
qpGeomVertexDataType::NT_uint8,
|
||||
qpGeomVertexDataType::C_rgba));
|
||||
qpGeomVertexDataType::C_color));
|
||||
|
||||
_v3c4t2 = register_format(new qpGeomVertexArrayFormat
|
||||
(InternalName::get_vertex(), 3,
|
||||
|
|
@ -747,7 +747,7 @@ Registry() {
|
|||
qpGeomVertexDataType::C_point,
|
||||
InternalName::get_color(), 4,
|
||||
qpGeomVertexDataType::NT_uint8,
|
||||
qpGeomVertexDataType::C_rgba,
|
||||
qpGeomVertexDataType::C_color,
|
||||
InternalName::get_texcoord(), 2,
|
||||
qpGeomVertexDataType::NT_float32,
|
||||
qpGeomVertexDataType::C_texcoord));
|
||||
|
|
@ -761,7 +761,7 @@ Registry() {
|
|||
qpGeomVertexDataType::C_point,
|
||||
InternalName::get_color(), 4,
|
||||
qpGeomVertexDataType::NT_uint8,
|
||||
qpGeomVertexDataType::C_rgba,
|
||||
qpGeomVertexDataType::C_color,
|
||||
InternalName::get_texcoord(), 2,
|
||||
qpGeomVertexDataType::NT_float32,
|
||||
qpGeomVertexDataType::C_texcoord));
|
||||
|
|
|
|||
|
|
@ -401,12 +401,9 @@ inc_pointer() {
|
|||
////////////////////////////////////////////////////////////////////
|
||||
INLINE float qpGeomVertexReader::Reader::
|
||||
maybe_scale_color(unsigned int value) {
|
||||
switch (_data_type->get_contents()) {
|
||||
case qpGeomVertexDataType::C_rgba:
|
||||
case qpGeomVertexDataType::C_argb:
|
||||
if (_data_type->get_contents() == qpGeomVertexDataType::C_color) {
|
||||
return (float)value / 255.0f;
|
||||
|
||||
default:
|
||||
} else {
|
||||
return (float)value;
|
||||
}
|
||||
}
|
||||
|
|
@ -419,16 +416,11 @@ maybe_scale_color(unsigned int value) {
|
|||
////////////////////////////////////////////////////////////////////
|
||||
INLINE void qpGeomVertexReader::Reader::
|
||||
maybe_scale_color(unsigned int a, unsigned int b) {
|
||||
switch (_data_type->get_contents()) {
|
||||
case qpGeomVertexDataType::C_rgba:
|
||||
case qpGeomVertexDataType::C_argb:
|
||||
if (_data_type->get_contents() == qpGeomVertexDataType::C_color) {
|
||||
_v2.set((float)a / 255.0f,
|
||||
(float)b / 255.0f);
|
||||
break;
|
||||
|
||||
default:
|
||||
} else {
|
||||
_v2.set((float)a, (float)b);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -440,17 +432,12 @@ maybe_scale_color(unsigned int a, unsigned int b) {
|
|||
////////////////////////////////////////////////////////////////////
|
||||
INLINE void qpGeomVertexReader::Reader::
|
||||
maybe_scale_color(unsigned int a, unsigned int b, unsigned int c) {
|
||||
switch (_data_type->get_contents()) {
|
||||
case qpGeomVertexDataType::C_rgba:
|
||||
case qpGeomVertexDataType::C_argb:
|
||||
if (_data_type->get_contents() == qpGeomVertexDataType::C_color) {
|
||||
_v3.set((float)a / 255.0f,
|
||||
(float)b / 255.0f,
|
||||
(float)c / 255.0f);
|
||||
break;
|
||||
|
||||
default:
|
||||
} else {
|
||||
_v3.set((float)a, (float)b, (float)c);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -463,18 +450,13 @@ maybe_scale_color(unsigned int a, unsigned int b, unsigned int c) {
|
|||
INLINE void qpGeomVertexReader::Reader::
|
||||
maybe_scale_color(unsigned int a, unsigned int b, unsigned int c,
|
||||
unsigned int d) {
|
||||
switch (_data_type->get_contents()) {
|
||||
case qpGeomVertexDataType::C_rgba:
|
||||
case qpGeomVertexDataType::C_argb:
|
||||
if (_data_type->get_contents() == qpGeomVertexDataType::C_color) {
|
||||
_v4.set((float)a / 255.0f,
|
||||
(float)b / 255.0f,
|
||||
(float)c / 255.0f,
|
||||
(float)d / 255.0f);
|
||||
break;
|
||||
|
||||
default:
|
||||
} else {
|
||||
_v4.set((float)a, (float)b, (float)c, (float)d);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -107,13 +107,22 @@ make_reader() const {
|
|||
}
|
||||
return new Reader_point;
|
||||
|
||||
case qpGeomVertexDataType::C_rgba:
|
||||
case qpGeomVertexDataType::C_color:
|
||||
switch (_data_type->get_numeric_type()) {
|
||||
case qpGeomVertexDataType::NT_uint8:
|
||||
switch (_data_type->get_num_components()) {
|
||||
case 4:
|
||||
return new Reader_rgba_uint8_4;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case qpGeomVertexDataType::NT_packed_dabc:
|
||||
switch (_data_type->get_num_components()) {
|
||||
case 1:
|
||||
return new Reader_argb_packed;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
|
@ -138,22 +147,6 @@ make_reader() const {
|
|||
}
|
||||
return new Reader_color;
|
||||
|
||||
case qpGeomVertexDataType::C_argb:
|
||||
switch (_data_type->get_numeric_type()) {
|
||||
case qpGeomVertexDataType::NT_packed_8888:
|
||||
switch (_data_type->get_num_components()) {
|
||||
case 1:
|
||||
return new Reader_argb_packed_8888;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return new Reader_color;
|
||||
|
||||
default:
|
||||
// Otherwise, we just read it as a generic value.
|
||||
switch (_data_type->get_numeric_type()) {
|
||||
|
|
@ -202,14 +195,16 @@ get_data1f(const unsigned char *pointer) {
|
|||
case qpGeomVertexDataType::NT_uint16:
|
||||
return *(const PN_uint16 *)pointer;
|
||||
|
||||
case qpGeomVertexDataType::NT_packed_8888:
|
||||
case qpGeomVertexDataType::NT_packed_dcba:
|
||||
{
|
||||
PN_uint32 dword = *(const PN_uint32 *)pointer;
|
||||
if (_data_type->get_contents() == qpGeomVertexDataType::C_argb) {
|
||||
return maybe_scale_color(qpGeomVertexData::unpack_8888_b(dword));
|
||||
} else {
|
||||
return maybe_scale_color(qpGeomVertexData::unpack_8888_a(dword));
|
||||
}
|
||||
return maybe_scale_color(qpGeomVertexData::unpack_abcd_d(dword));
|
||||
}
|
||||
|
||||
case qpGeomVertexDataType::NT_packed_dabc:
|
||||
{
|
||||
PN_uint32 dword = *(const PN_uint32 *)pointer;
|
||||
return maybe_scale_color(qpGeomVertexData::unpack_abcd_b(dword));
|
||||
}
|
||||
|
||||
case qpGeomVertexDataType::NT_float32:
|
||||
|
|
@ -243,16 +238,19 @@ get_data2f(const unsigned char *pointer) {
|
|||
}
|
||||
return _v2;
|
||||
|
||||
case qpGeomVertexDataType::NT_packed_8888:
|
||||
case qpGeomVertexDataType::NT_packed_dcba:
|
||||
{
|
||||
PN_uint32 dword = *(const PN_uint32 *)pointer;
|
||||
if (_data_type->get_contents() == qpGeomVertexDataType::C_argb) {
|
||||
maybe_scale_color(qpGeomVertexData::unpack_8888_b(dword),
|
||||
qpGeomVertexData::unpack_8888_c(dword));
|
||||
} else {
|
||||
maybe_scale_color(qpGeomVertexData::unpack_8888_a(dword),
|
||||
qpGeomVertexData::unpack_8888_b(dword));
|
||||
}
|
||||
maybe_scale_color(qpGeomVertexData::unpack_abcd_d(dword),
|
||||
qpGeomVertexData::unpack_abcd_c(dword));
|
||||
}
|
||||
return _v2;
|
||||
|
||||
case qpGeomVertexDataType::NT_packed_dabc:
|
||||
{
|
||||
PN_uint32 dword = *(const PN_uint32 *)pointer;
|
||||
maybe_scale_color(qpGeomVertexData::unpack_abcd_b(dword),
|
||||
qpGeomVertexData::unpack_abcd_c(dword));
|
||||
}
|
||||
return _v2;
|
||||
|
||||
|
|
@ -300,18 +298,21 @@ get_data3f(const unsigned char *pointer) {
|
|||
}
|
||||
return _v3;
|
||||
|
||||
case qpGeomVertexDataType::NT_packed_8888:
|
||||
case qpGeomVertexDataType::NT_packed_dcba:
|
||||
{
|
||||
PN_uint32 dword = *(const PN_uint32 *)pointer;
|
||||
if (_data_type->get_contents() == qpGeomVertexDataType::C_argb) {
|
||||
maybe_scale_color(qpGeomVertexData::unpack_8888_b(dword),
|
||||
qpGeomVertexData::unpack_8888_c(dword),
|
||||
qpGeomVertexData::unpack_8888_d(dword));
|
||||
} else {
|
||||
maybe_scale_color(qpGeomVertexData::unpack_8888_a(dword),
|
||||
qpGeomVertexData::unpack_8888_b(dword),
|
||||
qpGeomVertexData::unpack_8888_c(dword));
|
||||
}
|
||||
maybe_scale_color(qpGeomVertexData::unpack_abcd_d(dword),
|
||||
qpGeomVertexData::unpack_abcd_c(dword),
|
||||
qpGeomVertexData::unpack_abcd_b(dword));
|
||||
}
|
||||
return _v3;
|
||||
|
||||
case qpGeomVertexDataType::NT_packed_dabc:
|
||||
{
|
||||
PN_uint32 dword = *(const PN_uint32 *)pointer;
|
||||
maybe_scale_color(qpGeomVertexData::unpack_abcd_b(dword),
|
||||
qpGeomVertexData::unpack_abcd_c(dword),
|
||||
qpGeomVertexData::unpack_abcd_d(dword));
|
||||
}
|
||||
return _v3;
|
||||
|
||||
|
|
@ -366,20 +367,23 @@ get_data4f(const unsigned char *pointer) {
|
|||
}
|
||||
return _v4;
|
||||
|
||||
case qpGeomVertexDataType::NT_packed_8888:
|
||||
case qpGeomVertexDataType::NT_packed_dcba:
|
||||
{
|
||||
PN_uint32 dword = *(const PN_uint32 *)pointer;
|
||||
if (_data_type->get_contents() == qpGeomVertexDataType::C_argb) {
|
||||
maybe_scale_color(qpGeomVertexData::unpack_8888_b(dword),
|
||||
qpGeomVertexData::unpack_8888_c(dword),
|
||||
qpGeomVertexData::unpack_8888_d(dword),
|
||||
qpGeomVertexData::unpack_8888_a(dword));
|
||||
} else {
|
||||
maybe_scale_color(qpGeomVertexData::unpack_8888_a(dword),
|
||||
qpGeomVertexData::unpack_8888_b(dword),
|
||||
qpGeomVertexData::unpack_8888_c(dword),
|
||||
qpGeomVertexData::unpack_8888_d(dword));
|
||||
}
|
||||
maybe_scale_color(qpGeomVertexData::unpack_abcd_d(dword),
|
||||
qpGeomVertexData::unpack_abcd_c(dword),
|
||||
qpGeomVertexData::unpack_abcd_b(dword),
|
||||
qpGeomVertexData::unpack_abcd_a(dword));
|
||||
}
|
||||
return _v4;
|
||||
|
||||
case qpGeomVertexDataType::NT_packed_dabc:
|
||||
{
|
||||
PN_uint32 dword = *(const PN_uint32 *)pointer;
|
||||
maybe_scale_color(qpGeomVertexData::unpack_abcd_b(dword),
|
||||
qpGeomVertexData::unpack_abcd_c(dword),
|
||||
qpGeomVertexData::unpack_abcd_d(dword),
|
||||
qpGeomVertexData::unpack_abcd_a(dword));
|
||||
}
|
||||
return _v4;
|
||||
|
||||
|
|
@ -409,10 +413,17 @@ get_data1i(const unsigned char *pointer) {
|
|||
case qpGeomVertexDataType::NT_uint16:
|
||||
return *(const PN_uint16 *)pointer;
|
||||
|
||||
case qpGeomVertexDataType::NT_packed_8888:
|
||||
case qpGeomVertexDataType::NT_packed_dcba:
|
||||
{
|
||||
PN_uint32 dword = *(const PN_uint32 *)pointer;
|
||||
return qpGeomVertexData::unpack_8888_a(dword);
|
||||
return qpGeomVertexData::unpack_abcd_d(dword);
|
||||
}
|
||||
break;
|
||||
|
||||
case qpGeomVertexDataType::NT_packed_dabc:
|
||||
{
|
||||
PN_uint32 dword = *(const PN_uint32 *)pointer;
|
||||
return qpGeomVertexData::unpack_abcd_b(dword);
|
||||
}
|
||||
break;
|
||||
|
||||
|
|
@ -451,16 +462,19 @@ get_data2i(const unsigned char *pointer) {
|
|||
}
|
||||
return _i;
|
||||
|
||||
case qpGeomVertexDataType::NT_packed_8888:
|
||||
case qpGeomVertexDataType::NT_packed_dcba:
|
||||
{
|
||||
PN_uint32 dword = *(const PN_uint32 *)pointer;
|
||||
if (_data_type->get_contents() == qpGeomVertexDataType::C_argb) {
|
||||
_i[0] = qpGeomVertexData::unpack_8888_b(dword);
|
||||
_i[1] = qpGeomVertexData::unpack_8888_c(dword);
|
||||
} else {
|
||||
_i[0] = qpGeomVertexData::unpack_8888_a(dword);
|
||||
_i[1] = qpGeomVertexData::unpack_8888_b(dword);
|
||||
}
|
||||
_i[0] = qpGeomVertexData::unpack_abcd_d(dword);
|
||||
_i[1] = qpGeomVertexData::unpack_abcd_c(dword);
|
||||
}
|
||||
return _i;
|
||||
|
||||
case qpGeomVertexDataType::NT_packed_dabc:
|
||||
{
|
||||
PN_uint32 dword = *(const PN_uint32 *)pointer;
|
||||
_i[0] = qpGeomVertexData::unpack_abcd_b(dword);
|
||||
_i[1] = qpGeomVertexData::unpack_abcd_c(dword);
|
||||
}
|
||||
return _i;
|
||||
|
||||
|
|
@ -517,18 +531,21 @@ get_data3i(const unsigned char *pointer) {
|
|||
}
|
||||
return _i;
|
||||
|
||||
case qpGeomVertexDataType::NT_packed_8888:
|
||||
case qpGeomVertexDataType::NT_packed_dcba:
|
||||
{
|
||||
PN_uint32 dword = *(const PN_uint32 *)pointer;
|
||||
if (_data_type->get_contents() == qpGeomVertexDataType::C_argb) {
|
||||
_i[0] = qpGeomVertexData::unpack_8888_b(dword);
|
||||
_i[1] = qpGeomVertexData::unpack_8888_c(dword);
|
||||
_i[2] = qpGeomVertexData::unpack_8888_d(dword);
|
||||
} else {
|
||||
_i[0] = qpGeomVertexData::unpack_8888_a(dword);
|
||||
_i[1] = qpGeomVertexData::unpack_8888_b(dword);
|
||||
_i[2] = qpGeomVertexData::unpack_8888_c(dword);
|
||||
}
|
||||
_i[0] = qpGeomVertexData::unpack_abcd_d(dword);
|
||||
_i[1] = qpGeomVertexData::unpack_abcd_c(dword);
|
||||
_i[2] = qpGeomVertexData::unpack_abcd_b(dword);
|
||||
}
|
||||
return _i;
|
||||
|
||||
case qpGeomVertexDataType::NT_packed_dabc:
|
||||
{
|
||||
PN_uint32 dword = *(const PN_uint32 *)pointer;
|
||||
_i[0] = qpGeomVertexData::unpack_abcd_b(dword);
|
||||
_i[1] = qpGeomVertexData::unpack_abcd_c(dword);
|
||||
_i[2] = qpGeomVertexData::unpack_abcd_d(dword);
|
||||
}
|
||||
return _i;
|
||||
|
||||
|
|
@ -600,20 +617,23 @@ get_data4i(const unsigned char *pointer) {
|
|||
}
|
||||
return _i;
|
||||
|
||||
case qpGeomVertexDataType::NT_packed_8888:
|
||||
case qpGeomVertexDataType::NT_packed_dcba:
|
||||
{
|
||||
PN_uint32 dword = *(const PN_uint32 *)pointer;
|
||||
if (_data_type->get_contents() == qpGeomVertexDataType::C_argb) {
|
||||
_i[0] = qpGeomVertexData::unpack_8888_b(dword);
|
||||
_i[1] = qpGeomVertexData::unpack_8888_c(dword);
|
||||
_i[2] = qpGeomVertexData::unpack_8888_d(dword);
|
||||
_i[3] = qpGeomVertexData::unpack_8888_a(dword);
|
||||
} else {
|
||||
_i[0] = qpGeomVertexData::unpack_8888_a(dword);
|
||||
_i[1] = qpGeomVertexData::unpack_8888_b(dword);
|
||||
_i[2] = qpGeomVertexData::unpack_8888_c(dword);
|
||||
_i[3] = qpGeomVertexData::unpack_8888_d(dword);
|
||||
}
|
||||
_i[0] = qpGeomVertexData::unpack_abcd_d(dword);
|
||||
_i[1] = qpGeomVertexData::unpack_abcd_c(dword);
|
||||
_i[2] = qpGeomVertexData::unpack_abcd_b(dword);
|
||||
_i[3] = qpGeomVertexData::unpack_abcd_a(dword);
|
||||
}
|
||||
return _i;
|
||||
|
||||
case qpGeomVertexDataType::NT_packed_dabc:
|
||||
{
|
||||
PN_uint32 dword = *(const PN_uint32 *)pointer;
|
||||
_i[0] = qpGeomVertexData::unpack_abcd_b(dword);
|
||||
_i[1] = qpGeomVertexData::unpack_abcd_c(dword);
|
||||
_i[2] = qpGeomVertexData::unpack_abcd_d(dword);
|
||||
_i[3] = qpGeomVertexData::unpack_abcd_a(dword);
|
||||
}
|
||||
return _i;
|
||||
|
||||
|
|
@ -718,20 +738,23 @@ get_data4f(const unsigned char *pointer) {
|
|||
}
|
||||
return _v4;
|
||||
|
||||
case qpGeomVertexDataType::NT_packed_8888:
|
||||
case qpGeomVertexDataType::NT_packed_dcba:
|
||||
{
|
||||
PN_uint32 dword = *(const PN_uint32 *)pointer;
|
||||
if (_data_type->get_contents() == qpGeomVertexDataType::C_argb) {
|
||||
maybe_scale_color(qpGeomVertexData::unpack_8888_b(dword),
|
||||
qpGeomVertexData::unpack_8888_c(dword),
|
||||
qpGeomVertexData::unpack_8888_d(dword),
|
||||
qpGeomVertexData::unpack_8888_a(dword));
|
||||
} else {
|
||||
maybe_scale_color(qpGeomVertexData::unpack_8888_a(dword),
|
||||
qpGeomVertexData::unpack_8888_b(dword),
|
||||
qpGeomVertexData::unpack_8888_c(dword),
|
||||
qpGeomVertexData::unpack_8888_d(dword));
|
||||
}
|
||||
maybe_scale_color(qpGeomVertexData::unpack_abcd_d(dword),
|
||||
qpGeomVertexData::unpack_abcd_c(dword),
|
||||
qpGeomVertexData::unpack_abcd_b(dword),
|
||||
qpGeomVertexData::unpack_abcd_a(dword));
|
||||
}
|
||||
return _v4;
|
||||
|
||||
case qpGeomVertexDataType::NT_packed_dabc:
|
||||
{
|
||||
PN_uint32 dword = *(const PN_uint32 *)pointer;
|
||||
maybe_scale_color(qpGeomVertexData::unpack_abcd_b(dword),
|
||||
qpGeomVertexData::unpack_abcd_c(dword),
|
||||
qpGeomVertexData::unpack_abcd_d(dword),
|
||||
qpGeomVertexData::unpack_abcd_a(dword));
|
||||
}
|
||||
return _v4;
|
||||
|
||||
|
|
@ -786,20 +809,23 @@ get_data4f(const unsigned char *pointer) {
|
|||
}
|
||||
return _v4;
|
||||
|
||||
case qpGeomVertexDataType::NT_packed_8888:
|
||||
case qpGeomVertexDataType::NT_packed_dcba:
|
||||
{
|
||||
PN_uint32 dword = *(const PN_uint32 *)pointer;
|
||||
if (_data_type->get_contents() == qpGeomVertexDataType::C_argb) {
|
||||
maybe_scale_color(qpGeomVertexData::unpack_8888_b(dword),
|
||||
qpGeomVertexData::unpack_8888_c(dword),
|
||||
qpGeomVertexData::unpack_8888_d(dword),
|
||||
qpGeomVertexData::unpack_8888_a(dword));
|
||||
} else {
|
||||
maybe_scale_color(qpGeomVertexData::unpack_8888_a(dword),
|
||||
qpGeomVertexData::unpack_8888_b(dword),
|
||||
qpGeomVertexData::unpack_8888_c(dword),
|
||||
qpGeomVertexData::unpack_8888_d(dword));
|
||||
}
|
||||
maybe_scale_color(qpGeomVertexData::unpack_abcd_d(dword),
|
||||
qpGeomVertexData::unpack_abcd_c(dword),
|
||||
qpGeomVertexData::unpack_abcd_b(dword),
|
||||
qpGeomVertexData::unpack_abcd_a(dword));
|
||||
}
|
||||
return _v4;
|
||||
|
||||
case qpGeomVertexDataType::NT_packed_dabc:
|
||||
{
|
||||
PN_uint32 dword = *(const PN_uint32 *)pointer;
|
||||
maybe_scale_color(qpGeomVertexData::unpack_abcd_b(dword),
|
||||
qpGeomVertexData::unpack_abcd_c(dword),
|
||||
qpGeomVertexData::unpack_abcd_d(dword),
|
||||
qpGeomVertexData::unpack_abcd_a(dword));
|
||||
}
|
||||
return _v4;
|
||||
|
||||
|
|
@ -904,17 +930,17 @@ get_data4f(const unsigned char *pointer) {
|
|||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: qpGeomVertexReader::Reader_argb_packed_8888::get_data4f
|
||||
// Function: qpGeomVertexReader::Reader_argb_packed::get_data4f
|
||||
// Access: Public, Virtual
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
const LVecBase4f &qpGeomVertexReader::Reader_argb_packed_8888::
|
||||
const LVecBase4f &qpGeomVertexReader::Reader_argb_packed::
|
||||
get_data4f(const unsigned char *pointer) {
|
||||
PN_uint32 dword = *(const PN_uint32 *)pointer;
|
||||
_v4.set((float)qpGeomVertexData::unpack_8888_b(dword) / 255.0f,
|
||||
(float)qpGeomVertexData::unpack_8888_c(dword) / 255.0f,
|
||||
(float)qpGeomVertexData::unpack_8888_d(dword) / 255.0f,
|
||||
(float)qpGeomVertexData::unpack_8888_a(dword) / 255.0f);
|
||||
_v4.set((float)qpGeomVertexData::unpack_abcd_b(dword) / 255.0f,
|
||||
(float)qpGeomVertexData::unpack_abcd_c(dword) / 255.0f,
|
||||
(float)qpGeomVertexData::unpack_abcd_d(dword) / 255.0f,
|
||||
(float)qpGeomVertexData::unpack_abcd_a(dword) / 255.0f);
|
||||
return _v4;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -210,7 +210,7 @@ private:
|
|||
virtual const LVecBase4f &get_data4f(const unsigned char *pointer);
|
||||
};
|
||||
|
||||
class Reader_argb_packed_8888 : public Reader_color {
|
||||
class Reader_argb_packed : public Reader_color {
|
||||
public:
|
||||
virtual const LVecBase4f &get_data4f(const unsigned char *pointer);
|
||||
};
|
||||
|
|
|
|||
|
|
@ -723,12 +723,9 @@ inc_add_pointer() {
|
|||
////////////////////////////////////////////////////////////////////
|
||||
INLINE unsigned int qpGeomVertexWriter::Writer::
|
||||
maybe_scale_color(float data) {
|
||||
switch (_data_type->get_contents()) {
|
||||
case qpGeomVertexDataType::C_rgba:
|
||||
case qpGeomVertexDataType::C_argb:
|
||||
if (_data_type->get_contents() == qpGeomVertexDataType::C_color) {
|
||||
return (unsigned int)(data * 255.0f);
|
||||
|
||||
default:
|
||||
} else {
|
||||
return (unsigned int)data;
|
||||
}
|
||||
}
|
||||
|
|
@ -742,17 +739,12 @@ maybe_scale_color(float data) {
|
|||
////////////////////////////////////////////////////////////////////
|
||||
INLINE void qpGeomVertexWriter::Writer::
|
||||
maybe_scale_color(const LVecBase2f &data) {
|
||||
switch (_data_type->get_contents()) {
|
||||
case qpGeomVertexDataType::C_rgba:
|
||||
case qpGeomVertexDataType::C_argb:
|
||||
if (_data_type->get_contents() == qpGeomVertexDataType::C_color) {
|
||||
_a = (unsigned int)(data[0] * 255.0f);
|
||||
_b = (unsigned int)(data[1] * 255.0f);
|
||||
break;
|
||||
|
||||
default:
|
||||
} else {
|
||||
_a = (unsigned int)data[0];
|
||||
_b = (unsigned int)data[1];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -765,19 +757,14 @@ maybe_scale_color(const LVecBase2f &data) {
|
|||
////////////////////////////////////////////////////////////////////
|
||||
INLINE void qpGeomVertexWriter::Writer::
|
||||
maybe_scale_color(const LVecBase3f &data) {
|
||||
switch (_data_type->get_contents()) {
|
||||
case qpGeomVertexDataType::C_rgba:
|
||||
case qpGeomVertexDataType::C_argb:
|
||||
if (_data_type->get_contents() == qpGeomVertexDataType::C_color) {
|
||||
_a = (unsigned int)(data[0] * 255.0f);
|
||||
_b = (unsigned int)(data[1] * 255.0f);
|
||||
_c = (unsigned int)(data[2] * 255.0f);
|
||||
break;
|
||||
|
||||
default:
|
||||
} else {
|
||||
_a = (unsigned int)data[0];
|
||||
_b = (unsigned int)data[1];
|
||||
_c = (unsigned int)data[2];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -790,20 +777,15 @@ maybe_scale_color(const LVecBase3f &data) {
|
|||
////////////////////////////////////////////////////////////////////
|
||||
INLINE void qpGeomVertexWriter::Writer::
|
||||
maybe_scale_color(const LVecBase4f &data) {
|
||||
switch (_data_type->get_contents()) {
|
||||
case qpGeomVertexDataType::C_rgba:
|
||||
case qpGeomVertexDataType::C_argb:
|
||||
if (_data_type->get_contents() == qpGeomVertexDataType::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);
|
||||
break;
|
||||
|
||||
default:
|
||||
} else {
|
||||
_a = (unsigned int)data[0];
|
||||
_b = (unsigned int)data[1];
|
||||
_c = (unsigned int)data[2];
|
||||
_d = (unsigned int)data[3];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -97,7 +97,7 @@ make_writer() const {
|
|||
}
|
||||
return new Writer_point;
|
||||
|
||||
case qpGeomVertexDataType::C_rgba:
|
||||
case qpGeomVertexDataType::C_color:
|
||||
switch (_data_type->get_numeric_type()) {
|
||||
case qpGeomVertexDataType::NT_uint8:
|
||||
switch (_data_type->get_num_components()) {
|
||||
|
|
@ -108,26 +108,19 @@ make_writer() const {
|
|||
break;
|
||||
}
|
||||
break;
|
||||
case qpGeomVertexDataType::NT_float32:
|
||||
case qpGeomVertexDataType::NT_packed_dabc:
|
||||
switch (_data_type->get_num_components()) {
|
||||
case 4:
|
||||
return new Writer_rgba_float32_4;
|
||||
case 1:
|
||||
return new Writer_argb_packed;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return new Writer_color;
|
||||
|
||||
case qpGeomVertexDataType::C_argb:
|
||||
switch (_data_type->get_numeric_type()) {
|
||||
case qpGeomVertexDataType::NT_packed_8888:
|
||||
case qpGeomVertexDataType::NT_float32:
|
||||
switch (_data_type->get_num_components()) {
|
||||
case 1:
|
||||
return new Writer_argb_packed_8888;
|
||||
case 4:
|
||||
return new Writer_rgba_float32_4;
|
||||
|
||||
default:
|
||||
break;
|
||||
|
|
@ -184,7 +177,8 @@ set_data1f(unsigned char *pointer, float data) {
|
|||
*(PN_uint16 *)pointer = (unsigned int)data;
|
||||
break;
|
||||
|
||||
case qpGeomVertexDataType::NT_packed_8888:
|
||||
case qpGeomVertexDataType::NT_packed_dcba:
|
||||
case qpGeomVertexDataType::NT_packed_dabc:
|
||||
nassertv(false);
|
||||
break;
|
||||
|
||||
|
|
@ -235,7 +229,8 @@ set_data2f(unsigned char *pointer, const LVecBase2f &data) {
|
|||
}
|
||||
break;
|
||||
|
||||
case qpGeomVertexDataType::NT_packed_8888:
|
||||
case qpGeomVertexDataType::NT_packed_dcba:
|
||||
case qpGeomVertexDataType::NT_packed_dabc:
|
||||
nassertv(false);
|
||||
break;
|
||||
|
||||
|
|
@ -293,7 +288,8 @@ set_data3f(unsigned char *pointer, const LVecBase3f &data) {
|
|||
}
|
||||
break;
|
||||
|
||||
case qpGeomVertexDataType::NT_packed_8888:
|
||||
case qpGeomVertexDataType::NT_packed_dcba:
|
||||
case qpGeomVertexDataType::NT_packed_dabc:
|
||||
nassertv(false);
|
||||
break;
|
||||
|
||||
|
|
@ -354,15 +350,14 @@ set_data4f(unsigned char *pointer, const LVecBase4f &data) {
|
|||
}
|
||||
break;
|
||||
|
||||
case qpGeomVertexDataType::NT_packed_8888:
|
||||
{
|
||||
maybe_scale_color(data);
|
||||
if (_data_type->get_contents() == qpGeomVertexDataType::C_argb) {
|
||||
*(PN_uint32 *)pointer = qpGeomVertexData::pack_8888(_d, _a, _b, _c);
|
||||
} else {
|
||||
*(PN_uint32 *)pointer = qpGeomVertexData::pack_8888(_a, _b, _c, _d);
|
||||
}
|
||||
}
|
||||
case qpGeomVertexDataType::NT_packed_dcba:
|
||||
maybe_scale_color(data);
|
||||
*(PN_uint32 *)pointer = qpGeomVertexData::pack_abcd(_d, _c, _b, _a);
|
||||
break;
|
||||
|
||||
case qpGeomVertexDataType::NT_packed_dabc:
|
||||
maybe_scale_color(data);
|
||||
*(PN_uint32 *)pointer = qpGeomVertexData::pack_abcd(_d, _a, _b, _c);
|
||||
break;
|
||||
|
||||
case qpGeomVertexDataType::NT_float32:
|
||||
|
|
@ -397,7 +392,8 @@ set_data1i(unsigned char *pointer, int a) {
|
|||
*(PN_uint16 *)pointer = a;
|
||||
break;
|
||||
|
||||
case qpGeomVertexDataType::NT_packed_8888:
|
||||
case qpGeomVertexDataType::NT_packed_dcba:
|
||||
case qpGeomVertexDataType::NT_packed_dabc:
|
||||
nassertv(false);
|
||||
break;
|
||||
|
||||
|
|
@ -448,7 +444,8 @@ set_data2i(unsigned char *pointer, int a, int b) {
|
|||
}
|
||||
break;
|
||||
|
||||
case qpGeomVertexDataType::NT_packed_8888:
|
||||
case qpGeomVertexDataType::NT_packed_dcba:
|
||||
case qpGeomVertexDataType::NT_packed_dabc:
|
||||
nassertv(false);
|
||||
break;
|
||||
|
||||
|
|
@ -505,7 +502,8 @@ set_data3i(unsigned char *pointer, int a, int b, int c) {
|
|||
}
|
||||
break;
|
||||
|
||||
case qpGeomVertexDataType::NT_packed_8888:
|
||||
case qpGeomVertexDataType::NT_packed_dcba:
|
||||
case qpGeomVertexDataType::NT_packed_dabc:
|
||||
nassertv(false);
|
||||
break;
|
||||
|
||||
|
|
@ -565,14 +563,12 @@ set_data4i(unsigned char *pointer, int a, int b, int c, int d) {
|
|||
}
|
||||
break;
|
||||
|
||||
case qpGeomVertexDataType::NT_packed_8888:
|
||||
{
|
||||
if (_data_type->get_contents() == qpGeomVertexDataType::C_argb) {
|
||||
*(PN_uint32 *)pointer = qpGeomVertexData::pack_8888(d, a, b, c);
|
||||
} else {
|
||||
*(PN_uint32 *)pointer = qpGeomVertexData::pack_8888(a, b, c, d);
|
||||
}
|
||||
}
|
||||
case qpGeomVertexDataType::NT_packed_dcba:
|
||||
*(PN_uint32 *)pointer = qpGeomVertexData::pack_abcd(d, c, b, a);
|
||||
break;
|
||||
|
||||
case qpGeomVertexDataType::NT_packed_dabc:
|
||||
*(PN_uint32 *)pointer = qpGeomVertexData::pack_abcd(d, a, b, c);
|
||||
break;
|
||||
|
||||
case qpGeomVertexDataType::NT_float32:
|
||||
|
|
@ -671,15 +667,14 @@ set_data4f(unsigned char *pointer, const LVecBase4f &data) {
|
|||
}
|
||||
break;
|
||||
|
||||
case qpGeomVertexDataType::NT_packed_8888:
|
||||
{
|
||||
maybe_scale_color(data);
|
||||
if (_data_type->get_contents() == qpGeomVertexDataType::C_argb) {
|
||||
*(PN_uint32 *)pointer = qpGeomVertexData::pack_8888(_d, _a, _b, _c);
|
||||
} else {
|
||||
*(PN_uint32 *)pointer = qpGeomVertexData::pack_8888(_a, _b, _c, _d);
|
||||
}
|
||||
}
|
||||
case qpGeomVertexDataType::NT_packed_dcba:
|
||||
maybe_scale_color(data);
|
||||
*(PN_uint32 *)pointer = qpGeomVertexData::pack_abcd(_d, _c, _b, _a);
|
||||
break;
|
||||
|
||||
case qpGeomVertexDataType::NT_packed_dabc:
|
||||
maybe_scale_color(data);
|
||||
*(PN_uint32 *)pointer = qpGeomVertexData::pack_abcd(_d, _a, _b, _c);
|
||||
break;
|
||||
|
||||
case qpGeomVertexDataType::NT_float32:
|
||||
|
|
@ -791,13 +786,13 @@ set_data4f(unsigned char *pointer, const LVecBase4f &data) {
|
|||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: qpGeomVertexWriter::Writer_argb_packed_8888::set_data4f
|
||||
// Function: qpGeomVertexWriter::Writer_argb_packed::set_data4f
|
||||
// Access: Public, Virtual
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void qpGeomVertexWriter::Writer_argb_packed_8888::
|
||||
void qpGeomVertexWriter::Writer_argb_packed::
|
||||
set_data4f(unsigned char *pointer, const LVecBase4f &data) {
|
||||
*(PN_uint32 *)pointer = qpGeomVertexData::pack_8888
|
||||
*(PN_uint32 *)pointer = qpGeomVertexData::pack_abcd
|
||||
((unsigned int)(data[3] * 255.0f),
|
||||
(unsigned int)(data[0] * 255.0f),
|
||||
(unsigned int)(data[1] * 255.0f),
|
||||
|
|
|
|||
|
|
@ -223,7 +223,7 @@ private:
|
|||
virtual void set_data4f(unsigned char *pointer, const LVecBase4f &value);
|
||||
};
|
||||
|
||||
class Writer_argb_packed_8888 : public Writer_color {
|
||||
class Writer_argb_packed : public Writer_color {
|
||||
public:
|
||||
virtual void set_data4f(unsigned char *pointer, const LVecBase4f &value);
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in New Issue