Loading libs/rs/rsMatrix.cpp +7 −2 Original line number Diff line number Diff line Loading @@ -156,4 +156,9 @@ void Matrix::loadFrustum(float l, float r, float b, float t, float n, float f) { m[15]= 0; } void Matrix::vectorMultiply(float *out, const float *in) const { out[0] = (m[0] * in[0]) + (m[4] * in[1]) + (m[8] * in[2]) + m[12]; out[1] = (m[1] * in[0]) + (m[5] * in[1]) + (m[9] * in[2]) + m[13]; out[2] = (m[2] * in[0]) + (m[6] * in[1]) + (m[10] * in[2]) + m[14]; out[3] = (m[3] * in[0]) + (m[7] * in[1]) + (m[11] * in[2]) + m[15]; } libs/rs/rsMatrix.h +4 −2 Original line number Diff line number Diff line Loading @@ -47,6 +47,8 @@ struct Matrix void loadOrtho(float l, float r, float b, float t, float n, float f); void loadFrustum(float l, float r, float b, float t, float n, float f); void vectorMultiply(float *v4out, const float *v3in) const; void multiply(const Matrix *rhs) { Matrix tmp; tmp.loadMultiply(this, rhs); Loading libs/rs/rsProgramVertex.cpp +8 −1 Original line number Diff line number Diff line Loading @@ -121,7 +121,14 @@ void ProgramVertex::setTextureMatrix(const rsc_Matrix *m) const mDirty = true; } void ProgramVertex::transformToScreen(const Context *rsc, float *v4out, const float *v3in) const { float *f = static_cast<float *>(mConstants->getPtr()); Matrix mvp; mvp.loadMultiply((Matrix *)&f[RS_PROGRAM_VERTEX_MODELVIEW_OFFSET], (Matrix *)&f[RS_PROGRAM_VERTEX_PROJECTION_OFFSET]); mvp.vectorMultiply(v4out, v3in); } ProgramVertexState::ProgramVertexState() { Loading libs/rs/rsProgramVertex.h +3 −0 Original line number Diff line number Diff line Loading @@ -43,6 +43,9 @@ public: void setModelviewMatrix(const rsc_Matrix *) const; void setTextureMatrix(const rsc_Matrix *) const; void transformToScreen(const Context *, float *v4out, const float *v3in) const; protected: uint32_t mLightCount; ObjectBaseRef<const Light> mLights[MAX_LIGHTS]; Loading libs/rs/rsScriptC_Lib.cpp +48 −0 Original line number Diff line number Diff line Loading @@ -22,6 +22,8 @@ #include "acc/acc.h" #include "utils/Timers.h" #define GL_GLEXT_PROTOTYPES #include <GLES/gl.h> #include <GLES/glext.h> Loading Loading @@ -744,6 +746,48 @@ static void SC_drawQuad(float x1, float y1, float z1, x4, y4, z4, 0, 0); } static void SC_drawSpriteScreenspace(float x, float y, float z, float w, float h) { GET_TLS(); rsc->setupCheck(); GLint crop[4] = {0, h, w, -h}; glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_CROP_RECT_OES, crop); glDrawTexfOES(x, y, z, w, h); } static void SC_drawSprite(float x, float y, float z, float w, float h) { GET_TLS(); rsc->setupCheck(); float vin[3] = {x, y, z}; float vout[4]; //LOGE("ds in %f %f %f", x, y, z); rsc->getVertex()->transformToScreen(rsc, vout, vin); //LOGE("ds out %f %f %f %f", vout[0], vout[1], vout[2], vout[3]); vout[0] /= vout[3]; vout[1] /= vout[3]; vout[2] /= vout[3]; vout[0] *= rsc->getWidth() / 2; vout[1] *= rsc->getHeight() / 2; vout[0] += rsc->getWidth() / 2; vout[1] += rsc->getHeight() / 2; vout[0] -= w/2; vout[1] -= h/2; //LOGE("ds out2 %f %f %f", vout[0], vout[1], vout[2]); // U, V, W, H GLint crop[4] = {0, h, w, -h}; glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_CROP_RECT_OES, crop); glDrawTexiOES(vout[0], vout[1], 0/*vout[2]*/, w, h); } static void SC_drawRect(float x1, float y1, float x2, float y2, float z) { Loading Loading @@ -1172,6 +1216,10 @@ ScriptCState::SymbolTable_t ScriptCState::gSyms[] = { "void", "(float x1, float y1, float z1, float x2, float y2, float z2, float x3, float y3, float z3, float x4, float y4, float z4)" }, { "drawQuadTexCoords", (void *)&SC_drawQuadTexCoords, "void", "(float x1, float y1, float z1, float u1, float v1, float x2, float y2, float z2, float u2, float v2, float x3, float y3, float z3, float u3, float v3, float x4, float y4, float z4, float u4, float v4)" }, { "drawSprite", (void *)&SC_drawSprite, "void", "(float x, float y, float z, float w, float h)" }, { "drawSpriteScreenspace", (void *)&SC_drawSpriteScreenspace, "void", "(float x, float y, float z, float w, float h)" }, { "drawLine", (void *)&SC_drawLine, "void", "(float x1, float y1, float z1, float x2, float y2, float z2)" }, { "drawPoint", (void *)&SC_drawPoint, Loading Loading
libs/rs/rsMatrix.cpp +7 −2 Original line number Diff line number Diff line Loading @@ -156,4 +156,9 @@ void Matrix::loadFrustum(float l, float r, float b, float t, float n, float f) { m[15]= 0; } void Matrix::vectorMultiply(float *out, const float *in) const { out[0] = (m[0] * in[0]) + (m[4] * in[1]) + (m[8] * in[2]) + m[12]; out[1] = (m[1] * in[0]) + (m[5] * in[1]) + (m[9] * in[2]) + m[13]; out[2] = (m[2] * in[0]) + (m[6] * in[1]) + (m[10] * in[2]) + m[14]; out[3] = (m[3] * in[0]) + (m[7] * in[1]) + (m[11] * in[2]) + m[15]; }
libs/rs/rsMatrix.h +4 −2 Original line number Diff line number Diff line Loading @@ -47,6 +47,8 @@ struct Matrix void loadOrtho(float l, float r, float b, float t, float n, float f); void loadFrustum(float l, float r, float b, float t, float n, float f); void vectorMultiply(float *v4out, const float *v3in) const; void multiply(const Matrix *rhs) { Matrix tmp; tmp.loadMultiply(this, rhs); Loading
libs/rs/rsProgramVertex.cpp +8 −1 Original line number Diff line number Diff line Loading @@ -121,7 +121,14 @@ void ProgramVertex::setTextureMatrix(const rsc_Matrix *m) const mDirty = true; } void ProgramVertex::transformToScreen(const Context *rsc, float *v4out, const float *v3in) const { float *f = static_cast<float *>(mConstants->getPtr()); Matrix mvp; mvp.loadMultiply((Matrix *)&f[RS_PROGRAM_VERTEX_MODELVIEW_OFFSET], (Matrix *)&f[RS_PROGRAM_VERTEX_PROJECTION_OFFSET]); mvp.vectorMultiply(v4out, v3in); } ProgramVertexState::ProgramVertexState() { Loading
libs/rs/rsProgramVertex.h +3 −0 Original line number Diff line number Diff line Loading @@ -43,6 +43,9 @@ public: void setModelviewMatrix(const rsc_Matrix *) const; void setTextureMatrix(const rsc_Matrix *) const; void transformToScreen(const Context *, float *v4out, const float *v3in) const; protected: uint32_t mLightCount; ObjectBaseRef<const Light> mLights[MAX_LIGHTS]; Loading
libs/rs/rsScriptC_Lib.cpp +48 −0 Original line number Diff line number Diff line Loading @@ -22,6 +22,8 @@ #include "acc/acc.h" #include "utils/Timers.h" #define GL_GLEXT_PROTOTYPES #include <GLES/gl.h> #include <GLES/glext.h> Loading Loading @@ -744,6 +746,48 @@ static void SC_drawQuad(float x1, float y1, float z1, x4, y4, z4, 0, 0); } static void SC_drawSpriteScreenspace(float x, float y, float z, float w, float h) { GET_TLS(); rsc->setupCheck(); GLint crop[4] = {0, h, w, -h}; glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_CROP_RECT_OES, crop); glDrawTexfOES(x, y, z, w, h); } static void SC_drawSprite(float x, float y, float z, float w, float h) { GET_TLS(); rsc->setupCheck(); float vin[3] = {x, y, z}; float vout[4]; //LOGE("ds in %f %f %f", x, y, z); rsc->getVertex()->transformToScreen(rsc, vout, vin); //LOGE("ds out %f %f %f %f", vout[0], vout[1], vout[2], vout[3]); vout[0] /= vout[3]; vout[1] /= vout[3]; vout[2] /= vout[3]; vout[0] *= rsc->getWidth() / 2; vout[1] *= rsc->getHeight() / 2; vout[0] += rsc->getWidth() / 2; vout[1] += rsc->getHeight() / 2; vout[0] -= w/2; vout[1] -= h/2; //LOGE("ds out2 %f %f %f", vout[0], vout[1], vout[2]); // U, V, W, H GLint crop[4] = {0, h, w, -h}; glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_CROP_RECT_OES, crop); glDrawTexiOES(vout[0], vout[1], 0/*vout[2]*/, w, h); } static void SC_drawRect(float x1, float y1, float x2, float y2, float z) { Loading Loading @@ -1172,6 +1216,10 @@ ScriptCState::SymbolTable_t ScriptCState::gSyms[] = { "void", "(float x1, float y1, float z1, float x2, float y2, float z2, float x3, float y3, float z3, float x4, float y4, float z4)" }, { "drawQuadTexCoords", (void *)&SC_drawQuadTexCoords, "void", "(float x1, float y1, float z1, float u1, float v1, float x2, float y2, float z2, float u2, float v2, float x3, float y3, float z3, float u3, float v3, float x4, float y4, float z4, float u4, float v4)" }, { "drawSprite", (void *)&SC_drawSprite, "void", "(float x, float y, float z, float w, float h)" }, { "drawSpriteScreenspace", (void *)&SC_drawSpriteScreenspace, "void", "(float x, float y, float z, float w, float h)" }, { "drawLine", (void *)&SC_drawLine, "void", "(float x1, float y1, float z1, float x2, float y2, float z2)" }, { "drawPoint", (void *)&SC_drawPoint, Loading