Begin implementing SimpleMesh and fix some bugs with refcounting and java object destruction tracking.
diff --git a/rsScriptC_Lib.cpp b/rsScriptC_Lib.cpp
index 87ddf58..ecd8373 100644
--- a/rsScriptC_Lib.cpp
+++ b/rsScriptC_Lib.cpp
@@ -89,10 +89,10 @@
glBindBuffer(GL_ARRAY_BUFFER, tm->mBufferObjects[0]);
glBufferData(GL_ARRAY_BUFFER, tm->mVertexDataSize, tm->mVertexData, GL_STATIC_DRAW);
glBindBuffer(GL_ARRAY_BUFFER, 0);
-
+
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, tm->mBufferObjects[1]);
glBufferData(GL_ELEMENT_ARRAY_BUFFER, tm->mIndexDataSize, tm->mIndexData, GL_STATIC_DRAW);
- glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
+ glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
}
static uint32_t SC_loadU32(uint32_t bank, uint32_t offset)
@@ -189,17 +189,17 @@
static float SC_maxf(float a, float b)
{
- return a > b ? a : b;
+ return a > b ? a : b;
}
static float SC_minf(float a, float b)
{
- return a < b ? a : b;
+ return a < b ? a : b;
}
static float SC_sqrf(float v)
{
- return v * v;
+ return v * v;
}
static int SC_sqr(int v)
@@ -211,7 +211,7 @@
{
float x = x2 - x1;
float y = y2 - y1;
- return sqrtf(x * x + y * y);
+ return sqrtf(x * x + y * y);
}
static float SC_distf3(float x1, float y1, float z1, float x2, float y2, float z2)
@@ -219,7 +219,7 @@
float x = x2 - x1;
float y = y2 - y1;
float z = z2 - z1;
- return sqrtf(x * x + y * y + z * z);
+ return sqrtf(x * x + y * y + z * z);
}
static float SC_magf2(float a, float b)
@@ -234,12 +234,12 @@
static float SC_radf(float degrees)
{
- return degrees * DEG_TO_RAD;
+ return degrees * DEG_TO_RAD;
}
static float SC_degf(float radians)
{
- return radians * RAD_TO_DEG;
+ return radians * RAD_TO_DEG;
}
static float SC_lerpf(float start, float stop, float amount)
@@ -282,10 +282,10 @@
static uint32_t SC_minute()
{
GET_TLS();
-
+
time_t rawtime;
time(&rawtime);
-
+
if (sc->mEnviroment.mTimeZone) {
struct tm timeinfo;
localtime_tz(&rawtime, &timeinfo, sc->mEnviroment.mTimeZone);
@@ -295,15 +295,15 @@
timeinfo = localtime(&rawtime);
return timeinfo->tm_min;
}
-}
+}
static uint32_t SC_hour()
{
GET_TLS();
-
+
time_t rawtime;
time(&rawtime);
-
+
if (sc->mEnviroment.mTimeZone) {
struct tm timeinfo;
localtime_tz(&rawtime, &timeinfo, sc->mEnviroment.mTimeZone);
@@ -318,10 +318,10 @@
static uint32_t SC_day()
{
GET_TLS();
-
+
time_t rawtime;
time(&rawtime);
-
+
if (sc->mEnviroment.mTimeZone) {
struct tm timeinfo;
localtime_tz(&rawtime, &timeinfo, sc->mEnviroment.mTimeZone);
@@ -331,15 +331,15 @@
timeinfo = localtime(&rawtime);
return timeinfo->tm_mday;
}
-}
+}
static uint32_t SC_month()
{
GET_TLS();
-
+
time_t rawtime;
time(&rawtime);
-
+
if (sc->mEnviroment.mTimeZone) {
struct tm timeinfo;
localtime_tz(&rawtime, &timeinfo, sc->mEnviroment.mTimeZone);
@@ -349,15 +349,15 @@
timeinfo = localtime(&rawtime);
return timeinfo->tm_mon;
}
-}
+}
static uint32_t SC_year()
{
GET_TLS();
-
+
time_t rawtime;
time(&rawtime);
-
+
if (sc->mEnviroment.mTimeZone) {
struct tm timeinfo;
localtime_tz(&rawtime, &timeinfo, sc->mEnviroment.mTimeZone);
@@ -631,6 +631,23 @@
x1, y1, z);
}
+static void SC_drawSimpleMesh(RsSimpleMesh vsm)
+{
+ GET_TLS();
+ SimpleMesh *sm = static_cast<SimpleMesh *>(vsm);
+ rsc->setupCheck();
+ sm->render();
+}
+
+static void SC_drawSimpleMeshRange(RsSimpleMesh vsm, uint32_t start, uint32_t len)
+{
+ GET_TLS();
+ SimpleMesh *sm = static_cast<SimpleMesh *>(vsm);
+ rsc->setupCheck();
+ sm->renderRange(start, len);
+}
+
+
//////////////////////////////////////////////////////////////////////////////
//
//////////////////////////////////////////////////////////////////////////////
@@ -674,18 +691,18 @@
float red = 0.0f;
float green = 0.0f;
float blue = 0.0f;
-
+
float x = h;
float y = s;
float z = b;
-
+
float hf = (x - (int) x) * 6.0f;
int ihf = (int) hf;
float f = hf - ihf;
float pv = z * (1.0f - y);
float qv = z * (1.0f - y * f);
float tv = z * (1.0f - y * (1.0f - f));
-
+
switch (ihf) {
case 0: // Red is the dominant color
red = z;
@@ -718,7 +735,7 @@
blue = qv;
break;
}
-
+
glColor4f(red, green, blue, a);
}
@@ -728,6 +745,12 @@
rsi_AllocationUploadToTexture(rsc, va, baseMipLevel);
}
+static void SC_uploadToBufferObject(RsAllocation va)
+{
+ GET_TLS();
+ rsi_AllocationUploadToBufferObject(rsc, va);
+}
+
static void SC_ClearColor(float r, float g, float b, float a)
{
//LOGE("c %f %f %f %f", r, g, b, a);
@@ -932,6 +955,10 @@
"void", "(int mesh, int start, int count)" },
{ "drawLine", (void *)&SC_drawLine,
"void", "(float x1, float y1, float z1, float x2, float y2, float z2)" },
+ { "drawSimpleMesh", (void *)&SC_drawSimpleMesh,
+ "void", "(int ism)" },
+ { "drawSimpleMeshRange", (void *)&SC_drawSimpleMeshRange,
+ "void", "(int ism, int start, int len)" },
// misc
@@ -954,6 +981,8 @@
{ "uploadToTexture", (void *)&SC_uploadToTexture,
"void", "(int, int)" },
+ { "uploadToBufferObject", (void *)&SC_uploadToBufferObject,
+ "void", "(int)" },
{ "debugF", (void *)&SC_debugF,