123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106 |
- #ifndef ANDROID_RS_MESH_H
- #define ANDROID_RS_MESH_H
- #include "rsObjectBase.h"
- namespace android {
- namespace renderscript {
- class Mesh : public ObjectBase {
- public:
- struct Hal {
- mutable void *drv;
- struct State {
-
-
-
- Allocation **vertexBuffers;
- uint32_t vertexBuffersCount;
-
- Allocation **indexBuffers;
- uint32_t indexBuffersCount;
- RsPrimitive *primitives;
- uint32_t primitivesCount;
- };
- State state;
- };
- Hal mHal;
- explicit Mesh(Context *);
- Mesh(Context *, uint32_t vertexBuffersCount, uint32_t primitivesCount);
- ~Mesh();
- virtual void serialize(Context *rsc, OStream *stream) const;
- virtual RsA3DClassID getClassId() const { return RS_A3D_CLASS_ID_MESH; }
- static Mesh *createFromStream(Context *rsc, IStream *stream);
- void init();
- void setVertexBuffer(Allocation *vb, uint32_t index) {
- mVertexBuffers[index].set(vb);
- mHal.state.vertexBuffers[index] = vb;
- }
- void setPrimitive(Allocation *idx, RsPrimitive prim, uint32_t index) {
- mIndexBuffers[index].set(idx);
- mHal.state.indexBuffers[index] = idx;
- mHal.state.primitives[index] = prim;
- }
- void render(Context *) const;
- void renderPrimitive(Context *, uint32_t primIndex) const;
- void renderPrimitiveRange(Context *, uint32_t primIndex, uint32_t start, uint32_t len) const;
- void uploadAll(Context *);
-
- float mBBoxMin[3];
- float mBBoxMax[3];
- void computeBBox(Context *rsc);
- protected:
- ObjectBaseRef<Allocation> *mVertexBuffers;
- ObjectBaseRef<Allocation> *mIndexBuffers;
- bool mInitialized;
- };
- class MeshContext {
- public:
- MeshContext() {
- }
- ~MeshContext() {
- }
- };
- }
- }
- #endif
|