Merge "Add support for non-VBO drawing in Meshes."
This commit is contained in:
@@ -8,7 +8,6 @@
|
||||
#include "../../../../scriptc/rs_graphics.rsh"
|
||||
|
||||
static int newPart = 0;
|
||||
|
||||
static float4 partColor;
|
||||
rs_mesh partMesh;
|
||||
|
||||
@@ -19,13 +18,13 @@ typedef struct __attribute__((packed, aligned(4))) Point {
|
||||
} Point_t;
|
||||
Point_t *point;
|
||||
|
||||
#pragma rs export_var(point, partColor, partMesh)
|
||||
#pragma rs export_var(point, partMesh)
|
||||
#pragma rs export_func(addParticles)
|
||||
|
||||
int root() {
|
||||
rsgClearColor(0.f, 0.f, 0.f, 1.f);
|
||||
float height = rsgGetHeight();
|
||||
rs_allocation alloc = rsGetAllocation(point);
|
||||
int size = rsAllocationGetDimX(alloc);
|
||||
const float height = rsgGetHeight();
|
||||
const int size = rsAllocationGetDimX(rsGetAllocation(point));
|
||||
|
||||
Point_t * p = point;
|
||||
for (int ct=0; ct < size; ct++) {
|
||||
@@ -37,13 +36,10 @@ int root() {
|
||||
p++;
|
||||
}
|
||||
|
||||
rsgUploadToBufferObject(alloc);
|
||||
rsgDrawSimpleMesh(partMesh);
|
||||
return 1;
|
||||
}
|
||||
|
||||
#pragma rs export_func(addParticles)
|
||||
|
||||
void addParticles(int rate, float x, float y, int newColor)
|
||||
{
|
||||
if (newColor) {
|
||||
|
||||
Binary file not shown.
@@ -26,20 +26,7 @@ public class ScriptC_Fountain extends ScriptC {
|
||||
super(rs, resources, id, isRoot);
|
||||
}
|
||||
|
||||
private final static int mExportVarIdx_partColor = 0;
|
||||
private Float4 mExportVar_partColor;
|
||||
public void set_partColor(Float4 v) {
|
||||
mExportVar_partColor = v;
|
||||
FieldPacker fp = new FieldPacker(16);
|
||||
fp.addF32(v);
|
||||
setVar(mExportVarIdx_partColor, fp);
|
||||
}
|
||||
|
||||
public Float4 get_partColor() {
|
||||
return mExportVar_partColor;
|
||||
}
|
||||
|
||||
private final static int mExportVarIdx_partMesh = 1;
|
||||
private final static int mExportVarIdx_partMesh = 0;
|
||||
private SimpleMesh mExportVar_partMesh;
|
||||
public void set_partMesh(SimpleMesh v) {
|
||||
mExportVar_partMesh = v;
|
||||
@@ -50,7 +37,7 @@ public class ScriptC_Fountain extends ScriptC {
|
||||
return mExportVar_partMesh;
|
||||
}
|
||||
|
||||
private final static int mExportVarIdx_point = 2;
|
||||
private final static int mExportVarIdx_point = 1;
|
||||
private ScriptField_Point mExportVar_point;
|
||||
public void bind_point(ScriptField_Point v) {
|
||||
mExportVar_point = v;
|
||||
|
||||
@@ -78,6 +78,9 @@ public:
|
||||
|
||||
virtual void uploadCheck(const Context *rsc);
|
||||
|
||||
bool getIsTexture() const {return mIsTexture;}
|
||||
bool getIsBufferObject() const {return mIsVertexBuffer;}
|
||||
|
||||
protected:
|
||||
void sendDirty() const;
|
||||
|
||||
|
||||
@@ -70,7 +70,11 @@ void SimpleMesh::renderRange(Context *rsc, uint32_t start, uint32_t len) const
|
||||
VertexArray va;
|
||||
for (uint32_t ct=0; ct < mVertexTypeCount; ct++) {
|
||||
mVertexBuffers[ct]->uploadCheck(rsc);
|
||||
va.setActiveBuffer(mVertexBuffers[ct]->getBufferObjectID());
|
||||
if (mVertexBuffers[ct]->getIsBufferObject()) {
|
||||
va.setActiveBuffer(mVertexBuffers[ct]->getBufferObjectID());
|
||||
} else {
|
||||
va.setActiveBuffer(mVertexBuffers[ct]->getPtr());
|
||||
}
|
||||
mVertexTypes[ct]->enableGLVertexBuffer(&va);
|
||||
}
|
||||
va.setupGL2(rsc, &rsc->mStateVertexArray, &rsc->mShaderCache);
|
||||
|
||||
@@ -84,6 +84,7 @@ void VertexArray::add(const Attrib &a, uint32_t stride)
|
||||
rsAssert(mCount < RS_MAX_ATTRIBS);
|
||||
mAttribs[mCount].set(a);
|
||||
mAttribs[mCount].buffer = mActiveBuffer;
|
||||
mAttribs[mCount].ptr = mActivePointer;
|
||||
mAttribs[mCount].stride = stride;
|
||||
mCount ++;
|
||||
}
|
||||
@@ -96,16 +97,19 @@ void VertexArray::add(uint32_t type, uint32_t size, uint32_t stride, bool normal
|
||||
mAttribs[mCount].size = size;
|
||||
mAttribs[mCount].offset = offset;
|
||||
mAttribs[mCount].normalized = normalized;
|
||||
mAttribs[mCount].buffer = mActiveBuffer;
|
||||
mAttribs[mCount].stride = stride;
|
||||
mAttribs[mCount].name.setTo(name);
|
||||
|
||||
mAttribs[mCount].buffer = mActiveBuffer;
|
||||
mAttribs[mCount].ptr = mActivePointer;
|
||||
mCount ++;
|
||||
}
|
||||
|
||||
void VertexArray::logAttrib(uint32_t idx, uint32_t slot) const {
|
||||
LOGE("va %i: slot=%i name=%s buf=%i size=%i type=0x%x stride=0x%x norm=%i offset=0x%x", idx, slot,
|
||||
LOGE("va %i: slot=%i name=%s buf=%i ptr=%p size=%i type=0x%x stride=0x%x norm=%i offset=0x%x", idx, slot,
|
||||
mAttribs[idx].name.string(),
|
||||
mAttribs[idx].buffer,
|
||||
mAttribs[idx].ptr,
|
||||
mAttribs[idx].size,
|
||||
mAttribs[idx].type,
|
||||
mAttribs[idx].stride,
|
||||
@@ -154,7 +158,7 @@ void VertexArray::setupGL2(const Context *rsc, class VertexArrayState *state, Sh
|
||||
mAttribs[ct].type,
|
||||
mAttribs[ct].normalized,
|
||||
mAttribs[ct].stride,
|
||||
(void *)mAttribs[ct].offset);
|
||||
mAttribs[ct].ptr + mAttribs[ct].offset);
|
||||
}
|
||||
state->mLastEnableCount = mCount;
|
||||
rsc->checkError("VertexArray::setupGL2 done");
|
||||
|
||||
@@ -37,6 +37,7 @@ public:
|
||||
class Attrib {
|
||||
public:
|
||||
uint32_t buffer;
|
||||
const uint8_t * ptr;
|
||||
uint32_t offset;
|
||||
uint32_t type;
|
||||
uint32_t size;
|
||||
@@ -51,7 +52,15 @@ public:
|
||||
|
||||
|
||||
void clearAll();
|
||||
void setActiveBuffer(uint32_t id) {mActiveBuffer = id;}
|
||||
void setActiveBuffer(uint32_t id) {
|
||||
mActiveBuffer = id;
|
||||
mActivePointer = NULL;
|
||||
}
|
||||
void setActiveBuffer(const void *ptr) {
|
||||
mActiveBuffer = 0;
|
||||
mActivePointer = (const uint8_t *)ptr;
|
||||
}
|
||||
|
||||
void add(const Attrib &, uint32_t stride);
|
||||
//void addLegacy(uint32_t type, uint32_t size, uint32_t stride, bool normalized, uint32_t offset);
|
||||
void add(uint32_t type, uint32_t size, uint32_t stride, bool normalized, uint32_t offset, const char *name);
|
||||
@@ -63,6 +72,7 @@ public:
|
||||
protected:
|
||||
void clear(uint32_t index);
|
||||
uint32_t mActiveBuffer;
|
||||
const uint8_t * mActivePointer;
|
||||
uint32_t mCount;
|
||||
|
||||
Attrib mAttribs[RS_MAX_ATTRIBS];
|
||||
|
||||
Reference in New Issue
Block a user