diff options
author | Android (Google) Code Review <android-gerrit@google.com> | 2009-08-06 22:53:05 -0700 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2009-08-06 22:53:05 -0700 |
commit | 4c35e2c59afa28f9ed3fab1788570ef933f29b1a (patch) | |
tree | e6aaf863feb9e9ba495ea5211d21dd6357b5430d /libs/rs/rsScriptC_Lib.cpp | |
parent | bce3ab90c74c994da53d8bcbc841fab22bd981b4 (diff) | |
parent | b62627ea336db2a4f423596c2a0f482f91690fd7 (diff) |
Merge change 20400
* changes:
Add lighting to animated water ripples.
Diffstat (limited to 'libs/rs/rsScriptC_Lib.cpp')
-rw-r--r-- | libs/rs/rsScriptC_Lib.cpp | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/libs/rs/rsScriptC_Lib.cpp b/libs/rs/rsScriptC_Lib.cpp index b7c66e2a3348..b17121f5527f 100644 --- a/libs/rs/rsScriptC_Lib.cpp +++ b/libs/rs/rsScriptC_Lib.cpp @@ -75,6 +75,25 @@ static int32_t* SC_loadArrayI32(uint32_t bank, uint32_t offset) return i + offset; } +static float* SC_loadTriangleMeshVerticesF(RsTriangleMesh mesh) +{ + TriangleMesh *tm = static_cast<TriangleMesh *>(mesh); + void *vp = tm->mVertexData; + float *f = static_cast<float *>(vp); + return f; +} + +static void SC_updateTriangleMesh(RsTriangleMesh mesh) +{ + TriangleMesh *tm = static_cast<TriangleMesh *>(mesh); + 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); +} static uint32_t SC_loadU32(uint32_t bank, uint32_t offset) { @@ -584,6 +603,36 @@ static void SC_color(float r, float g, float b, float a) glColor4f(r, g, b, a); } +static void SC_ambient(float r, float g, float b, float a) +{ + GLfloat params[] = { r, g, b, a }; + glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, params); +} + +static void SC_diffuse(float r, float g, float b, float a) +{ + GLfloat params[] = { r, g, b, a }; + glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, params); +} + +static void SC_specular(float r, float g, float b, float a) +{ + GLfloat params[] = { r, g, b, a }; + glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, params); +} + +static void SC_emission(float r, float g, float b, float a) +{ + GLfloat params[] = { r, g, b, a }; + glMaterialfv(GL_FRONT_AND_BACK, GL_EMISSION, params); +} + +static void SC_shininess(float r, float g, float b, float a) +{ + GLfloat params[] = { r, g, b, a }; + glMaterialfv(GL_FRONT_AND_BACK, GL_SHININESS, params); +} + static void SC_hsb(float h, float s, float b, float a) { float red = 0.0f; @@ -712,6 +761,10 @@ ScriptCState::SymbolTable_t ScriptCState::gSyms[] = { "void", "(int, int, float *)" }, { "storeMatrix", (void *)&SC_storeMatrix, "void", "(int, int, float *)" }, + { "loadTriangleMeshVerticesF", (void *)&SC_loadTriangleMeshVerticesF, + "float*", "(int)" }, + { "updateTriangleMesh", (void *)&SC_updateTriangleMesh, + "void", "(int)" }, // math { "sinf", (void *)&sinf, @@ -859,6 +912,16 @@ ScriptCState::SymbolTable_t ScriptCState::gSyms[] = { "void", "(float, float, float, float)" }, { "hsb", (void *)&SC_hsb, "void", "(float, float, float, float)" }, + { "ambient", (void *)&SC_ambient, + "void", "(float, float, float, float)" }, + { "diffuse", (void *)&SC_diffuse, + "void", "(float, float, float, float)" }, + { "specular", (void *)&SC_specular, + "void", "(float, float, float, float)" }, + { "emission", (void *)&SC_emission, + "void", "(float, float, float, float)" }, + { "shininess", (void *)&SC_shininess, + "void", "(float, float, float, float)" }, { "uploadToTexture", (void *)&SC_uploadToTexture, "void", "(int, int)" }, |