From 54c0ec14e016e4a1bf3ceab40ed6ca5447da4725 Mon Sep 17 00:00:00 2001 From: Jason Sams Date: Mon, 30 Nov 2009 14:49:55 -0800 Subject: Beging GL2 user shaders. Switch master to using GL2 by default. --- libs/rs/rsProgramVertex.cpp | 32 +++++++++++++++++++++----------- 1 file changed, 21 insertions(+), 11 deletions(-) (limited to 'libs/rs/rsProgramVertex.cpp') diff --git a/libs/rs/rsProgramVertex.cpp b/libs/rs/rsProgramVertex.cpp index 1776b02b..482739c 100644 --- a/libs/rs/rsProgramVertex.cpp +++ b/libs/rs/rsProgramVertex.cpp @@ -117,18 +117,24 @@ void ProgramVertex::createShader() mShader.append("varying vec4 varColor;\n"); mShader.append("varying vec4 varTex0;\n"); - mShader.append("void main() {\n"); - mShader.append(" gl_Position = uni_MVP * attrib_Position;\n"); - mShader.append(" varColor = attrib_Color;\n"); - if (mTextureMatrixEnable) { - mShader.append(" varTex0 = uni_TexMatrix * attrib_T0;\n"); + if (mUserShader.length() > 1) { + mShader.append(mUserShader); } else { - mShader.append(" varTex0 = attrib_T0;\n"); + mShader.append("void main() {\n"); + mShader.append(" gl_Position = uni_MVP * attrib_Position;\n"); + mShader.append(" gl_PointSize = attrib_PointSize.x;\n"); + + mShader.append(" varColor = attrib_Color;\n"); + if (mTextureMatrixEnable) { + mShader.append(" varTex0 = uni_TexMatrix * attrib_T0;\n"); + } else { + mShader.append(" varTex0 = attrib_T0;\n"); + } + //mShader.append(" pos.x = pos.x / 480.0;\n"); + //mShader.append(" pos.y = pos.y / 800.0;\n"); + //mShader.append(" gl_Position = pos;\n"); + mShader.append("}\n"); } - //mShader.append(" pos.x = pos.x / 480.0;\n"); - //mShader.append(" pos.y = pos.y / 800.0;\n"); - //mShader.append(" gl_Position = pos;\n"); - mShader.append("}\n"); } void ProgramVertex::setupGL2(const Context *rsc, ProgramVertexState *state, ShaderCache *sc) @@ -211,7 +217,6 @@ void ProgramVertex::init(Context *rsc) createShader(); } - /////////////////////////////////////////////////////////////////////// ProgramVertexState::ProgramVertexState() @@ -294,6 +299,11 @@ void rsi_ProgramVertexSetTextureMatrixEnable(Context *rsc, bool enable) rsc->mStateVertex.mPV->setTextureMatrixEnable(enable); } +void rsi_ProgramVertexSetShader(Context *rsc, const char *txt, uint32_t len) +{ + rsc->mStateVertex.mPV->setShader(txt, len); +} + void rsi_ProgramVertexAddLight(Context *rsc, RsLight light) { rsc->mStateVertex.mPV->addLight(static_cast(light)); -- cgit v1.1