@@ -26,7 +26,8 @@ bool TextureCoordF::operator==(const TextureCoordF &other) const
2626}
2727
2828GLES1State::GLES1State ()
29- : mVertexArrayEnabled (false ),
29+ : mGLState (nullptr ),
30+ mVertexArrayEnabled (false ),
3031 mNormalArrayEnabled(false ),
3132 mColorArrayEnabled(false ),
3233 mPointSizeArrayEnabled(false ),
@@ -59,8 +60,10 @@ GLES1State::GLES1State()
5960GLES1State::~GLES1State () = default ;
6061
6162// Taken from the GLES 1.x spec which specifies all initial state values.
62- void GLES1State::initialize (const Context *context)
63+ void GLES1State::initialize (const Context *context, const State *state )
6364{
65+ mGLState = state;
66+
6467 const Caps &caps = context->getCaps ();
6568
6669 mTexUnitEnables .resize (caps.maxMultitextureUnits );
@@ -97,12 +100,12 @@ void GLES1State::initialize(const Context *context)
97100
98101 mTextureEnvironments .resize (caps.maxMultitextureUnits );
99102
100- mProjMatrices . resize (caps. maxProjectionMatrixStackDepth );
101- mModelviewMatrices . resize (caps. maxModelviewMatrixStackDepth );
103+ mModelviewMatrices . push_back ( angle::Mat4 () );
104+ mProjectionMatrices . push_back ( angle::Mat4 () );
102105 mTextureMatrices .resize (caps.maxMultitextureUnits );
103- for (auto &textureMatrixStack : mTextureMatrices )
106+ for (auto &stack : mTextureMatrices )
104107 {
105- textureMatrixStack. resize (caps. maxTextureMatrixStackDepth );
108+ stack. push_back ( angle::Mat4 () );
106109 }
107110
108111 mMaterial .ambient = {0 .2f , 0 .2f , 0 .2f , 1 .0f };
@@ -210,4 +213,48 @@ MatrixType GLES1State::getMatrixMode() const
210213 return mMatrixMode ;
211214}
212215
216+ void GLES1State::pushMatrix ()
217+ {
218+ auto &stack = currentMatrixStack ();
219+ stack.push_back (stack.back ());
220+ }
221+
222+ void GLES1State::popMatrix ()
223+ {
224+ auto &stack = currentMatrixStack ();
225+ stack.pop_back ();
226+ }
227+
228+ GLES1State::MatrixStack &GLES1State::currentMatrixStack ()
229+ {
230+ switch (mMatrixMode )
231+ {
232+ case MatrixType::Modelview:
233+ return mModelviewMatrices ;
234+ case MatrixType::Projection:
235+ return mProjectionMatrices ;
236+ case MatrixType::Texture:
237+ return mTextureMatrices [mGLState ->getActiveSampler ()];
238+ default :
239+ UNREACHABLE ();
240+ return mModelviewMatrices ;
241+ }
242+ }
243+
244+ const GLES1State::MatrixStack &GLES1State::currentMatrixStack () const
245+ {
246+ switch (mMatrixMode )
247+ {
248+ case MatrixType::Modelview:
249+ return mModelviewMatrices ;
250+ case MatrixType::Projection:
251+ return mProjectionMatrices ;
252+ case MatrixType::Texture:
253+ return mTextureMatrices [mGLState ->getActiveSampler ()];
254+ default :
255+ UNREACHABLE ();
256+ return mModelviewMatrices ;
257+ }
258+ }
259+
213260} // namespace gl
0 commit comments