mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-03 02:15:43 -04:00
get_prepared_textures()
This commit is contained in:
parent
a43de758d2
commit
7d103e9d18
@ -49,6 +49,13 @@
|
||||
#include <algorithm>
|
||||
#include <limits.h>
|
||||
|
||||
#ifdef HAVE_PYTHON
|
||||
#include "py_panda.h"
|
||||
#ifndef CPPPARSER
|
||||
IMPORT_THIS struct Dtool_PyTypedObject Dtool_Texture;
|
||||
#endif
|
||||
#endif // HAVE_PYTHON
|
||||
|
||||
PStatCollector GraphicsStateGuardian::_vertex_buffer_switch_pcollector("Vertex buffer switch:Vertex");
|
||||
PStatCollector GraphicsStateGuardian::_index_buffer_switch_pcollector("Vertex buffer switch:Index");
|
||||
PStatCollector GraphicsStateGuardian::_load_vertex_buffer_pcollector("Draw:Transfer data:Vertex buffer");
|
||||
@ -370,6 +377,58 @@ void GraphicsStateGuardian::
|
||||
restore_gamma() {
|
||||
}
|
||||
|
||||
#ifdef HAVE_PYTHON
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: GraphicsStateGuardian::get_prepared_textures
|
||||
// Access: Published
|
||||
// Description: Returns a Python list of all of the
|
||||
// currently-prepared textures within the GSG.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
PyObject *GraphicsStateGuardian::
|
||||
get_prepared_textures() const {
|
||||
size_t num_textures = _prepared_objects->_prepared_textures.size();
|
||||
PyObject *list = PyList_New(num_textures);
|
||||
|
||||
size_t i = 0;
|
||||
PreparedGraphicsObjects::Textures::const_iterator ti;
|
||||
for (ti = _prepared_objects->_prepared_textures.begin();
|
||||
ti != _prepared_objects->_prepared_textures.end();
|
||||
++ti) {
|
||||
Texture *tex = (*ti)->get_texture();
|
||||
|
||||
PyObject *element =
|
||||
DTool_CreatePyInstanceTyped(tex, Dtool_Texture,
|
||||
true, false, tex->get_type_index());
|
||||
|
||||
PyList_SetItem(list, i, element);
|
||||
++i;
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
#endif // HAVE_PYTHON
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: GraphicsStateGuardian::traverse_prepared_textures
|
||||
// Access: Public
|
||||
// Description: Calls the indicated function on all
|
||||
// currently-prepared textures, or until the callback
|
||||
// function returns false.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void GraphicsStateGuardian::
|
||||
traverse_prepared_textures(GraphicsStateGuardian::TextureCallback *func,
|
||||
void *callback_arg) {
|
||||
PreparedGraphicsObjects::Textures::const_iterator ti;
|
||||
for (ti = _prepared_objects->_prepared_textures.begin();
|
||||
ti != _prepared_objects->_prepared_textures.end();
|
||||
++ti) {
|
||||
bool result = (*func)(*ti,callback_arg);
|
||||
if (!result) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: GraphicsStateGuardian::set_scene
|
||||
// Access: Public
|
||||
@ -1922,25 +1981,6 @@ create_gamma_table (float gamma, unsigned short *red_table, unsigned short *gree
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: GraphicsStateGuardian::traverse_prepared_textures
|
||||
// Access: Public
|
||||
// Description: Calls the indicated function on all
|
||||
// currently-prepared textures, or until the callback
|
||||
// function returns false.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void GraphicsStateGuardian::
|
||||
traverse_prepared_textures(bool (*pertex_callbackfn)(TextureContext *,void *),void *callback_arg) {
|
||||
PreparedGraphicsObjects::Textures::const_iterator ti;
|
||||
for (ti = _prepared_objects->_prepared_textures.begin();
|
||||
ti != _prepared_objects->_prepared_textures.end();
|
||||
++ti) {
|
||||
bool bResult=(*pertex_callbackfn)(*ti,callback_arg);
|
||||
if(!bResult)
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: GraphicsStateGuardian::enable_lighting
|
||||
// Access: Protected, Virtual
|
||||
|
@ -168,7 +168,13 @@ PUBLISHED:
|
||||
|
||||
INLINE void set_texture_quality_override(Texture::QualityLevel quality_level);
|
||||
INLINE Texture::QualityLevel get_texture_quality_override() const;
|
||||
|
||||
|
||||
#ifdef HAVE_PYTHON
|
||||
PyObject *get_prepared_textures() const;
|
||||
#endif
|
||||
typedef bool TextureCallback(TextureContext *tc, void *callback_arg);
|
||||
void traverse_prepared_textures(TextureCallback *func, void *callback_arg);
|
||||
|
||||
public:
|
||||
bool set_scene(SceneSetup *scene_setup);
|
||||
virtual SceneSetup *get_scene() const;
|
||||
@ -280,8 +286,6 @@ public:
|
||||
static void init_frame_pstats();
|
||||
#endif
|
||||
|
||||
void traverse_prepared_textures(bool (*pertex_callbackfn)(TextureContext *,void *),void *callback_arg);
|
||||
|
||||
protected:
|
||||
virtual void enable_lighting(bool enable);
|
||||
virtual void set_ambient_light(const Colorf &color);
|
||||
|
Loading…
x
Reference in New Issue
Block a user