Browse Source

Add a way to get access to OpenGL texture index

rdb 8 years ago
parent
commit
85a9cdd052

+ 21 - 0
panda/src/glstuff/glTextureContext_src.cxx

@@ -95,6 +95,27 @@ reset_data() {
 #endif
 }
 
+/**
+ * Returns an implementation-defined handle or pointer that can be used
+ * to interface directly with the underlying API.
+ * Returns 0 if the underlying implementation does not support this.
+ */
+uint64_t CLP(TextureContext)::
+get_native_id() const {
+  return _index;
+}
+
+/**
+ * Similar to get_native_id, but some implementations use a separate
+ * identifier for the buffer object associated with buffer textures.
+ * Returns 0 if the underlying implementation does not support this, or
+ * if this is not a buffer texture.
+ */
+uint64_t CLP(TextureContext)::
+get_native_buffer_id() const {
+  return _buffer;
+}
+
 /**
  *
  */

+ 3 - 0
panda/src/glstuff/glTextureContext_src.h

@@ -33,6 +33,9 @@ public:
   virtual void evict_lru();
   void reset_data();
 
+  virtual uint64_t get_native_id() const;
+  virtual uint64_t get_native_buffer_id() const;
+
 #ifndef OPENGLES
   void make_handle_resident();
   GLuint64 get_handle();

+ 21 - 0
panda/src/gobj/textureContext.cxx

@@ -15,6 +15,27 @@
 
 TypeHandle TextureContext::_type_handle;
 
+/**
+ * Returns an implementation-defined handle or pointer that can be used
+ * to interface directly with the underlying API.
+ * Returns 0 if the underlying implementation does not support this.
+ */
+uint64_t TextureContext::
+get_native_id() const {
+  return 0;
+}
+
+/**
+ * Similar to get_native_id, but some implementations use a separate
+ * identifier for the buffer object associated with buffer textures.
+ * Returns 0 if the underlying implementation does not support this, or
+ * if this is not a buffer texture.
+ */
+uint64_t TextureContext::
+get_native_buffer_id() const {
+  return 0;
+}
+
 /**
  *
  */

+ 2 - 0
panda/src/gobj/textureContext.h

@@ -37,6 +37,8 @@ public:
 PUBLISHED:
   INLINE Texture *get_texture() const;
   INLINE int get_view() const;
+  virtual uint64_t get_native_id() const;
+  virtual uint64_t get_native_buffer_id() const;
 
   INLINE bool was_modified() const;
   INLINE bool was_properties_modified() const;