Support rendering without any vertex arrays bound better

This commit is contained in:
rdb 2016-04-21 01:32:13 +02:00
parent 40acfeffb5
commit 6225755230
5 changed files with 21 additions and 6 deletions

View File

@ -2196,7 +2196,10 @@ begin_draw_primitives(const GeomPipelineReader *geom_reader,
bool force) {
_munger = munger;
_data_reader = data_reader;
return _data_reader->has_vertex();
// Always draw if we have a shader, since the shader might use a different
// mechanism for fetching vertex data.
return _data_reader->has_vertex() || (_target_shader && _target_shader->has_shader());
}
/**

View File

@ -2231,7 +2231,8 @@ get_num_primitives() const {
*/
bool GeomPrimitivePipelineReader::
check_valid(const GeomVertexDataPipelineReader *data_reader) const {
if (get_num_vertices() != 0 &&
if (get_num_vertices() != 0 &&
data_reader->get_num_arrays() > 0 &&
get_max_vertex() >= data_reader->get_num_rows()) {
#ifndef NDEBUG

View File

@ -235,6 +235,15 @@ get_morph_delta(size_t n) const {
return _morphs[n]._delta;
}
/**
* Returns a standard vertex format containing no arrays at all, useful for
* pull-style vertex rendering.
*/
INLINE const GeomVertexFormat *GeomVertexFormat::
get_empty() {
return get_registry()->_empty;
}
/**
* Returns a standard vertex format with just a 3-component vertex position.
*/

View File

@ -890,6 +890,8 @@ Registry() {
*/
void GeomVertexFormat::Registry::
make_standard_formats() {
_empty = register_format(new GeomVertexFormat);
_v3 = register_format(new GeomVertexArrayFormat
(InternalName::get_vertex(), 3,
NT_stdfloat, C_point));
@ -1011,10 +1013,6 @@ register_format(GeomVertexFormat *format) {
new_format = (*fi);
if (!new_format->is_registered()) {
new_format->do_register();
if (new_format->get_num_arrays() == 0) {
gobj_cat.warning()
<< "Empty GeomVertexFormat registered.\n";
}
}
}

View File

@ -125,6 +125,8 @@ PUBLISHED:
void write_with_data(ostream &out, int indent_level,
const GeomVertexData *data) const;
INLINE static const GeomVertexFormat *get_empty();
// Some standard vertex formats. No particular requirement to use one of
// these, but the DirectX renderers can use these formats directly, whereas
// any other format will have to be converted first.
@ -227,6 +229,8 @@ private:
Formats _formats;
LightReMutex _lock;
CPT(GeomVertexFormat) _empty;
CPT(GeomVertexFormat) _v3;
CPT(GeomVertexFormat) _v3n3;
CPT(GeomVertexFormat) _v3t2;