1f5597700a4c0a2925a398ff1897ec5b590cebc8
[platform/core/uifw/dali-toolkit.git] / automated-tests / src / dali-toolkit / dali-toolkit-test-utils / test-gl-abstraction.h
1 #ifndef __TEST_GL_ABSTRACTION_H__
2 #define __TEST_GL_ABSTRACTION_H__
3
4 /*
5  * Copyright (c) 2014 Samsung Electronics Co., Ltd.
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  *
19  */
20
21 // EXTERNAL INCLUDES
22 #include <sstream>
23 #include <string>
24 #include <cstring>
25 #include <map>
26 #include <cstdio>
27 #include <cstring> // for strcmp
28
29 // INTERNAL INCLUDES
30 #include <dali/public-api/dali-core.h>
31 #include <dali/integration-api/core.h>
32 #include <dali/integration-api/gl-abstraction.h>
33 #include <dali/integration-api/gl-defines.h>
34 #include "test-trace-call-stack.h"
35
36 namespace Dali
37 {
38
39 static const unsigned int MAX_ATTRIBUTE_CACHE_SIZE = 64;
40 static const char *mStdAttribs[MAX_ATTRIBUTE_CACHE_SIZE] =
41 {
42     "aPosition",    // ATTRIB_POSITION
43     "aNormal",      // ATTRIB_NORMAL
44     "aTexCoord",    // ATTRIB_TEXCOORD
45     "aColor",       // ATTRIB_COLOR
46     "aBoneWeights", // ATTRIB_BONE_WEIGHTS
47     "aBoneIndices"  // ATTRIB_BONE_INDICES
48 };
49
50 class DALI_IMPORT_API TestGlAbstraction: public Dali::Integration::GlAbstraction
51 {
52 public:
53   TestGlAbstraction();
54   ~TestGlAbstraction();
55   void Initialize();
56
57   void PreRender();
58   void PostRender();
59
60   /* OpenGL ES 2.0 */
61
62   inline void ActiveTexture( GLenum textureUnit )
63   {
64     mActiveTextureUnit = textureUnit - GL_TEXTURE0;
65   }
66
67   inline GLenum GetActiveTextureUnit() const
68   {
69     return mActiveTextureUnit + GL_TEXTURE0;
70   }
71
72   inline void AttachShader( GLuint program, GLuint shader )
73   {
74     std::stringstream out;
75     out << program << ", " << shader;
76
77     TraceCallStack::NamedParams namedParams;
78     namedParams["program"] = ToString(program);
79     namedParams["shader"] = ToString(shader);
80     mShaderTrace.PushCall("AttachShader", out.str(), namedParams);
81   }
82
83   inline void BindAttribLocation( GLuint program, GLuint index, const char* name )
84   {
85   }
86
87   inline void BindBuffer( GLenum target, GLuint buffer )
88   {
89   }
90
91   inline void BindFramebuffer( GLenum target, GLuint framebuffer )
92   {
93     //Add 010 bit;
94     mFramebufferStatus |= 2;
95   }
96
97   inline void BindRenderbuffer( GLenum target, GLuint renderbuffer )
98   {
99   }
100
101   /**
102    * This method can be used by test cases, to query the texture IDs that have been bound by BindTexture.
103    * @return A vector containing the IDs that were bound.
104    */
105   inline const std::vector<GLuint>& GetBoundTextures() const
106   {
107     return mBoundTextures;
108   }
109
110   /**
111    * Query the texture IDs that have been bound with BindTexture, with a specific active texture unit.
112    * @param[in] activeTextureUnit The specific active texture unit.
113    * @return A vector containing the IDs that were bound.
114    */
115   inline const std::vector<GLuint>& GetBoundTextures( GLuint activeTextureUnit ) const
116   {
117     return mActiveTextures[ activeTextureUnit - GL_TEXTURE0 ].mBoundTextures;
118   }
119
120   /**
121    * This method can be used by test cases, to clear the record of texture IDs that have been bound by BindTexture.
122    */
123   inline void ClearBoundTextures()
124   {
125     mBoundTextures.clear();
126
127     for( unsigned int i=0; i<MIN_TEXTURE_UNIT_LIMIT; ++i )
128     {
129       mActiveTextures[ i ].mBoundTextures.clear();
130     }
131   }
132
133   inline void BindTexture( GLenum target, GLuint texture )
134   {
135     // Record the bound textures for future checks
136     if( texture )
137     {
138       mBoundTextures.push_back( texture );
139
140       if( mActiveTextureUnit < MIN_TEXTURE_UNIT_LIMIT )
141       {
142         mActiveTextures[ mActiveTextureUnit ].mBoundTextures.push_back( texture );
143       }
144     }
145
146     std::stringstream out;
147     out << target << ", " << texture;
148
149     TraceCallStack::NamedParams namedParams;
150     namedParams["target"] = ToString(target);
151     namedParams["texture"] = ToString(texture);
152
153     mTextureTrace.PushCall("BindTexture", out.str(), namedParams);
154   }
155
156   inline void BlendColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha)
157   {
158     mLastBlendColor.r = red;
159     mLastBlendColor.g = green;
160     mLastBlendColor.b = blue;
161     mLastBlendColor.a = alpha;
162   }
163
164   inline const Vector4& GetLastBlendColor() const
165   {
166     return mLastBlendColor;
167   }
168
169   inline void BlendEquation( GLenum mode )
170   {
171     mLastBlendEquationRgb   = mode;
172     mLastBlendEquationAlpha = mode;
173   }
174
175   inline void BlendEquationSeparate( GLenum modeRgb, GLenum modeAlpha )
176   {
177     mLastBlendEquationRgb   = modeRgb;
178     mLastBlendEquationAlpha = modeAlpha;
179   }
180
181   inline GLenum GetLastBlendEquationRgb() const
182   {
183     return mLastBlendEquationRgb;
184   }
185
186   inline GLenum GetLastBlendEquationAlpha() const
187   {
188     return mLastBlendEquationAlpha;
189   }
190
191   inline void BlendFunc(GLenum sfactor, GLenum dfactor)
192   {
193     mLastBlendFuncSrcRgb = sfactor;
194     mLastBlendFuncDstRgb = dfactor;
195     mLastBlendFuncSrcAlpha = sfactor;
196     mLastBlendFuncDstAlpha = dfactor;
197   }
198
199   inline void BlendFuncSeparate(GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha)
200   {
201     mLastBlendFuncSrcRgb = srcRGB;
202     mLastBlendFuncDstRgb = dstRGB;
203     mLastBlendFuncSrcAlpha = srcAlpha;
204     mLastBlendFuncDstAlpha = dstAlpha;
205   }
206
207   inline GLenum GetLastBlendFuncSrcRgb() const
208   {
209     return mLastBlendFuncSrcRgb;
210   }
211
212   inline GLenum GetLastBlendFuncDstRgb() const
213   {
214     return mLastBlendFuncDstRgb;
215   }
216
217   inline GLenum GetLastBlendFuncSrcAlpha() const
218   {
219     return mLastBlendFuncSrcAlpha;
220   }
221
222   inline GLenum GetLastBlendFuncDstAlpha() const
223   {
224     return mLastBlendFuncDstAlpha;
225   }
226
227   inline void BufferData(GLenum target, GLsizeiptr size, const void* data, GLenum usage)
228   {
229      mBufferDataCalls.push_back(size);
230   }
231
232   inline void BufferSubData(GLenum target, GLintptr offset, GLsizeiptr size, const void* data)
233   {
234      mBufferSubDataCalls.push_back(size);
235   }
236
237   inline GLenum CheckFramebufferStatus(GLenum target)
238   {
239     //If it has the three last bits set to 1 - 111, then the three minimum functions to create a
240     //Framebuffer texture have been called
241     if( mFramebufferStatus == 7 )
242     {
243       return GL_FRAMEBUFFER_COMPLETE;
244     }
245
246     return mCheckFramebufferStatusResult;
247   }
248
249   inline GLenum CheckFramebufferColorAttachment()
250   {
251     return mFramebufferColorAttached;
252   }
253
254   inline GLenum CheckFramebufferDepthAttachment()
255   {
256     return mFramebufferDepthAttached;
257   }
258
259   inline GLenum CheckFramebufferStencilAttachment()
260   {
261     return mFramebufferStencilAttached;
262   }
263
264   inline void Clear(GLbitfield mask)
265   {
266     mClearCount++;
267     mLastClearBitMask = mask;
268   }
269
270   inline void ClearColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha)
271   {
272   }
273
274   inline void ClearDepthf(GLclampf depth)
275   {
276   }
277
278   inline void ClearStencil(GLint s)
279   {
280     std::stringstream out;
281     out << s;
282
283     TraceCallStack::NamedParams namedParams;
284     namedParams["s"] = ToString( s );
285
286     mStencilFunctionTrace.PushCall( "ClearStencil", out.str(), namedParams );
287   }
288
289   inline void ColorMask(GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha)
290   {
291     mColorMaskParams.red = red;
292     mColorMaskParams.green = green;
293     mColorMaskParams.blue = blue;
294     mColorMaskParams.alpha = alpha;
295   }
296
297   inline void CompileShader(GLuint shader)
298   {
299     std::stringstream out;
300     out << shader;
301     TraceCallStack::NamedParams namedParams;
302     namedParams["shader"] = ToString(shader);
303
304     mShaderTrace.PushCall("CompileShader", out.str(), namedParams);
305   }
306
307   inline void CompressedTexImage2D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void* data)
308   {
309     std::stringstream out;
310     out << target<<", "<<level<<", "<<width << ", " << height;
311
312     TraceCallStack::NamedParams namedParams;
313     namedParams["target"] = ToString(target);
314     namedParams["level"] = ToString(level);
315     namedParams["internalformat"] = ToString(internalformat);
316     namedParams["width"] = ToString(width);
317     namedParams["height"] = ToString(height);
318     namedParams["border"] = ToString(border);
319     namedParams["size"] = ToString(imageSize);
320
321     mTextureTrace.PushCall("CompressedTexImage2D", out.str(), namedParams);
322   }
323
324   inline void CompressedTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void* data)
325   {
326     std::stringstream out;
327     out << target << ", "<<level <<", " << xoffset << ", " << yoffset << ", " << width << ", " << height;
328
329     TraceCallStack::NamedParams namedParams;
330     namedParams["target"] = ToString(target);
331     namedParams["level"] = ToString(level);
332     namedParams["xoffset"] = ToString(xoffset);
333     namedParams["yoffset"] = ToString(yoffset);
334     namedParams["width"] = ToString(width);
335     namedParams["height"] = ToString(height);
336     mTextureTrace.PushCall("CompressedTexSubImage2D", out.str(), namedParams);
337   }
338
339   inline void CopyTexImage2D(GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border)
340   {
341   }
342
343   inline void CopyTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height)
344   {
345   }
346
347   inline GLuint CreateProgram(void)
348   {
349     mShaderTrace.PushCall("CreateProgram", "");
350
351     ++mLastProgramIdUsed;
352     mUniforms[mLastProgramIdUsed] = UniformIDMap();
353     return mLastProgramIdUsed;
354   }
355
356   inline GLuint CreateShader(GLenum type)
357   {
358     std::stringstream out;
359     out << type;
360
361     TraceCallStack::NamedParams namedParams;
362     namedParams["type"] = ToString(type);
363     mShaderTrace.PushCall("CreateShader", out.str(), namedParams);
364
365     return ++mLastShaderIdUsed;
366   }
367
368   inline void CullFace(GLenum mode)
369   {
370     std::stringstream out;
371     out << mode;
372
373     TraceCallStack::NamedParams namedParams;
374     namedParams["program"] = ToString(mode);
375
376     mCullFaceTrace.PushCall("CullFace", out.str(), namedParams);
377   }
378
379   inline void DeleteBuffers(GLsizei n, const GLuint* buffers)
380   {
381   }
382
383   inline void DeleteFramebuffers(GLsizei n, const GLuint* framebuffers)
384   {
385   }
386
387   inline void DeleteProgram(GLuint program)
388   {
389     std::stringstream out;
390     out << program;
391
392     TraceCallStack::NamedParams namedParams;
393     namedParams["program"] = ToString(program);
394
395     mShaderTrace.PushCall("DeleteProgram", out.str(), namedParams);
396   }
397
398   inline void DeleteRenderbuffers(GLsizei n, const GLuint* renderbuffers)
399   {
400   }
401
402   inline void DeleteShader(GLuint shader)
403   {
404     std::stringstream out;
405     out << shader;
406
407     TraceCallStack::NamedParams namedParams;
408     namedParams["shader"] = ToString(shader);
409
410     mShaderTrace.PushCall("DeleteShader", out.str(), namedParams);
411   }
412
413   inline void DeleteTextures(GLsizei n, const GLuint* textures)
414   {
415     std::stringstream out;
416     out << n << ", " << textures << " = [";
417
418     TraceCallStack::NamedParams namedParams;
419
420     for(GLsizei i=0; i<n; i++)
421     {
422       out << textures[i] << ", ";
423       std::stringstream paramName;
424       paramName<<"texture["<<i<<"]";
425       namedParams[paramName.str()] = ToString(textures[i]);
426       mDeletedTextureIds.push_back(textures[i]);
427     }
428     out << "]";
429
430     mTextureTrace.PushCall("DeleteTextures", out.str(), namedParams);
431   }
432
433   inline bool CheckNoTexturesDeleted()
434   {
435     return mDeletedTextureIds.size() == 0;
436   }
437
438   inline bool CheckTextureDeleted( GLuint textureId )
439   {
440     bool found = false;
441
442     for(std::vector<GLuint>::iterator iter=mDeletedTextureIds.begin(); iter != mDeletedTextureIds.end(); ++iter)
443     {
444       if(*iter == textureId)
445       {
446         found = true;
447         break;
448       }
449     }
450     return found;
451   }
452
453   inline void ClearDeletedTextures()
454   {
455     mDeletedTextureIds.clear();
456   }
457
458   inline void DepthFunc(GLenum func)
459   {
460     std::stringstream out;
461     out << func;
462
463     TraceCallStack::NamedParams namedParams;
464     namedParams["func"] = ToString(func);
465
466     mDepthFunctionTrace.PushCall("DepthFunc", out.str(), namedParams);
467   }
468
469   inline void DepthMask(GLboolean flag)
470   {
471   }
472
473   inline void DepthRangef(GLclampf zNear, GLclampf zFar)
474   {
475   }
476
477   inline void DetachShader(GLuint program, GLuint shader)
478   {
479     std::stringstream out;
480     out << program << ", " << shader;
481     TraceCallStack::NamedParams namedParams;
482     namedParams["program"] = ToString(program);
483     namedParams["shader"] = ToString(shader);
484     mShaderTrace.PushCall("DetachShader", out.str(), namedParams);
485   }
486
487   inline void Disable(GLenum cap)
488   {
489     std::stringstream out;
490     out << cap;
491     TraceCallStack::NamedParams namedParams;
492     namedParams["cap"] = ToString(cap);
493     mEnableDisableTrace.PushCall("Disable", out.str(), namedParams);
494   }
495
496   inline void DisableVertexAttribArray(GLuint index)
497   {
498     SetVertexAttribArray( index, false );
499   }
500
501   inline void DrawArrays(GLenum mode, GLint first, GLsizei count)
502   {
503     std::stringstream out;
504     out << mode << ", " << first << ", " << count;
505     TraceCallStack::NamedParams namedParams;
506     namedParams["mode"] = ToString(mode);
507     namedParams["first"] = ToString(first);
508     namedParams["count"] = ToString(count);
509     mDrawTrace.PushCall("DrawArrays", out.str(), namedParams);
510   }
511
512   inline void DrawElements(GLenum mode, GLsizei count, GLenum type, const void* indices)
513   {
514     std::stringstream out;
515     out << mode << ", " << count << ", " << type << ", indices";
516
517     TraceCallStack::NamedParams namedParams;
518     namedParams["mode"] = ToString(mode);
519     namedParams["count"] = ToString(count);
520     namedParams["type"] = ToString(type);
521     // Skip void pointers - are they of any use?
522     mDrawTrace.PushCall("DrawElements", out.str(), namedParams);
523   }
524
525   inline void Enable(GLenum cap)
526   {
527     std::stringstream out;
528     out << cap;
529     TraceCallStack::NamedParams namedParams;
530     namedParams["cap"] = ToString(cap);
531     mEnableDisableTrace.PushCall("Enable", out.str(), namedParams);
532   }
533
534   inline void EnableVertexAttribArray(GLuint index)
535   {
536     SetVertexAttribArray( index, true);
537   }
538
539   inline void Finish(void)
540   {
541   }
542
543   inline void Flush(void)
544   {
545   }
546
547   inline void FramebufferRenderbuffer(GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer)
548   {
549     if (attachment == GL_DEPTH_ATTACHMENT)
550     {
551       mFramebufferDepthAttached = true;
552     }
553     else if (attachment == GL_STENCIL_ATTACHMENT)
554     {
555       mFramebufferStencilAttached = true;
556     }
557   }
558
559   inline void FramebufferTexture2D(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level)
560   {
561     //Add 100 bit;
562     mFramebufferStatus |= 4;
563
564     //We check 4 attachment colors
565     if ((attachment == GL_COLOR_ATTACHMENT0) || (attachment == GL_COLOR_ATTACHMENT1) || (attachment == GL_COLOR_ATTACHMENT2)  || (attachment == GL_COLOR_ATTACHMENT4))
566     {
567       mFramebufferColorAttached = true;
568     }
569   }
570
571   inline void FrontFace(GLenum mode)
572   {
573   }
574
575   inline void GenBuffers(GLsizei n, GLuint* buffers)
576   {
577     // avoids an assert in GpuBuffers
578     *buffers = 1u;
579   }
580
581   inline void GenerateMipmap(GLenum target)
582   {
583     std::stringstream out;
584     out<<target;
585     TraceCallStack::NamedParams namedParams;
586     namedParams["target"] = ToString(target);
587
588     mTextureTrace.PushCall("GenerateMipmap", out.str(), namedParams);
589   }
590
591   inline void GenFramebuffers(GLsizei n, GLuint* framebuffers)
592   {
593     for( int i = 0; i < n; i++ )
594     {
595       framebuffers[i] = i + 1;
596     }
597
598     //Add 001 bit, this function needs to be called the first one in the chain
599     mFramebufferStatus = 1;
600   }
601
602   inline void GenRenderbuffers(GLsizei n, GLuint* renderbuffers)
603   {
604     for( int i = 0; i < n; i++ )
605     {
606       renderbuffers[i] = i + 1;
607     }
608   }
609
610   /**
611    * This method can be used by test cases, to manipulate the texture IDs generated by GenTextures.
612    * @param[in] ids A vector containing the next IDs to be generated
613    */
614   inline void SetNextTextureIds( const std::vector<GLuint>& ids )
615   {
616     mNextTextureIds = ids;
617   }
618
619   inline const std::vector<GLuint>& GetNextTextureIds()
620   {
621     return mNextTextureIds;
622   }
623
624   inline void GenTextures(GLsizei count, GLuint* textures)
625   {
626     for( int i=0; i<count; ++i )
627     {
628       if( !mNextTextureIds.empty() )
629       {
630         *(textures+i) = mNextTextureIds[0];
631         mNextTextureIds.erase( mNextTextureIds.begin() );
632       }
633       else
634       {
635         *(textures+i) = ++mLastAutoTextureIdUsed;
636       }
637     }
638
639     TraceCallStack::NamedParams namedParams;
640     namedParams["count"] = ToString(count);
641
642     std::stringstream out;
643     for(int i=0; i<count; i++)
644     {
645       out << textures[i];
646       if(i<count-1)
647       {
648         out << ", ";
649       }
650       std::ostringstream oss;
651       oss<<"indices["<<i<<"]";
652       namedParams[oss.str()] = ToString(textures[i]);
653     }
654
655     mTextureTrace.PushCall("GenTextures", out.str(), namedParams);
656   }
657
658   inline void GetActiveAttrib(GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, char* name)
659   {
660   }
661
662   inline void GetActiveUniform(GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, char* name)
663   {
664     switch(index)
665     {
666       case 0:
667         *length = snprintf(name, bufsize, "sTexture");
668         *type = GL_SAMPLER_2D;
669         *size = 1;
670         break;
671       case 1:
672         *length = snprintf(name, bufsize, "sEffect");
673         *type = GL_SAMPLER_2D;
674         *size = 1;
675         break;
676       case 2:
677         *length = snprintf(name, bufsize, "sGloss");
678         *type = GL_SAMPLER_2D;
679         *size = 1;
680         break;
681       default:
682         break;
683     }
684   }
685
686   inline void GetAttachedShaders(GLuint program, GLsizei maxcount, GLsizei* count, GLuint* shaders)
687   {
688   }
689
690   inline int  GetAttribLocation(GLuint program, const char* name)
691   {
692     std::string attribName(name);
693
694     for( unsigned int i = 0; i < ATTRIB_TYPE_LAST; ++i )
695     {
696       if( mStdAttribs[i] == attribName )
697       {
698         return i;
699       }
700     }
701
702     // 0 is a valid location
703     return 0;
704   }
705
706   inline void GetBooleanv(GLenum pname, GLboolean* params)
707   {
708   }
709
710   inline void GetBufferParameteriv(GLenum target, GLenum pname, GLint* params)
711   {
712   }
713
714   inline GLenum GetError(void)
715   {
716     return mGetErrorResult;
717   }
718
719   inline void GetFloatv(GLenum pname, GLfloat* params)
720   {
721   }
722
723   inline void GetFramebufferAttachmentParameteriv(GLenum target, GLenum attachment, GLenum pname, GLint* params)
724   {
725   }
726
727   inline void GetIntegerv(GLenum pname, GLint* params)
728   {
729     switch( pname )
730     {
731       case GL_MAX_TEXTURE_SIZE:
732         *params = 2048;
733         break;
734       case GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS:
735         *params = 8;
736         break;
737       case GL_NUM_PROGRAM_BINARY_FORMATS_OES:
738         *params = mNumBinaryFormats;
739         break;
740       case GL_PROGRAM_BINARY_FORMATS_OES:
741         *params = mBinaryFormats;
742         break;
743     }
744   }
745
746   inline void GetProgramiv(GLuint program, GLenum pname, GLint* params)
747   {
748     switch( pname )
749     {
750       case GL_LINK_STATUS:
751         *params = mLinkStatus;
752         break;
753       case GL_PROGRAM_BINARY_LENGTH_OES:
754         *params = mProgramBinaryLength;
755         break;
756       case GL_ACTIVE_UNIFORMS:
757         *params = mNumberOfActiveUniforms;
758         break;
759       case GL_ACTIVE_UNIFORM_MAX_LENGTH:
760         *params = 100;
761         break;
762     }
763   }
764
765   inline void GetProgramInfoLog(GLuint program, GLsizei bufsize, GLsizei* length, char* infolog)
766   {
767   }
768
769   inline void GetRenderbufferParameteriv(GLenum target, GLenum pname, GLint* params)
770   {
771   }
772
773   inline void GetShaderiv(GLuint shader, GLenum pname, GLint* params)
774   {
775     switch( pname ) {
776       case GL_COMPILE_STATUS:
777         *params = mCompileStatus;
778         break;
779     }
780   }
781
782   inline void GetShaderInfoLog(GLuint shader, GLsizei bufsize, GLsizei* length, char* infolog)
783   {
784   }
785
786   inline void GetShaderPrecisionFormat(GLenum shadertype, GLenum precisiontype, GLint* range, GLint* precision)
787   {
788   }
789
790   inline const GLubyte* GetString(GLenum name)
791   {
792     return mGetStringResult;
793   }
794
795   inline void GetTexParameterfv(GLenum target, GLenum pname, GLfloat* params)
796   {
797   }
798
799   inline void GetTexParameteriv(GLenum target, GLenum pname, GLint* params)
800   {
801   }
802
803   inline void GetUniformfv(GLuint program, GLint location, GLfloat* params)
804   {
805   }
806
807   inline void GetUniformiv(GLuint program, GLint location, GLint* params)
808   {
809   }
810
811   inline GLint GetUniformLocation(GLuint program, const char* name)
812   {
813     ProgramUniformMap::iterator it = mUniforms.find(program);
814     if( it == mUniforms.end() )
815     {
816       // Not a valid program ID
817       mGetErrorResult = GL_INVALID_OPERATION;
818       return -1;
819     }
820
821     UniformIDMap& uniformIDs = it->second;
822     UniformIDMap::iterator it2 = uniformIDs.find( name );
823     if( it2 == uniformIDs.end() )
824     {
825       // Uniform not found, so add it...
826       uniformIDs[name] = ++mLastUniformIdUsed;
827       return mLastUniformIdUsed;
828     }
829
830     return it2->second;
831   }
832
833   inline void GetVertexAttribfv(GLuint index, GLenum pname, GLfloat* params)
834   {
835   }
836
837   inline void GetVertexAttribiv(GLuint index, GLenum pname, GLint* params)
838   {
839   }
840
841   inline void GetVertexAttribPointerv(GLuint index, GLenum pname, void** pointer)
842   {
843   }
844
845   inline void Hint(GLenum target, GLenum mode)
846   {
847   }
848
849   inline GLboolean IsBuffer(GLuint buffer)
850   {
851     return mIsBufferResult;
852   }
853
854   inline GLboolean IsEnabled(GLenum cap)
855   {
856     return mIsEnabledResult;
857   }
858
859   inline GLboolean IsFramebuffer(GLuint framebuffer)
860   {
861     return mIsFramebufferResult;
862   }
863
864   inline GLboolean IsProgram(GLuint program)
865   {
866     return mIsProgramResult;
867   }
868
869   inline GLboolean IsRenderbuffer(GLuint renderbuffer)
870   {
871     return mIsRenderbufferResult;
872   }
873
874   inline GLboolean IsShader(GLuint shader)
875   {
876     return mIsShaderResult;
877   }
878
879   inline GLboolean IsTexture(GLuint texture)
880   {
881     return mIsTextureResult;
882   }
883
884   inline void LineWidth(GLfloat width)
885   {
886   }
887
888   inline void LinkProgram(GLuint program)
889   {
890     std::stringstream out;
891     out << program;
892
893     TraceCallStack::NamedParams namedParams;
894     namedParams["program"] = ToString(program);
895     mShaderTrace.PushCall("LinkProgram", out.str(), namedParams);
896
897     mNumberOfActiveUniforms=3;
898     GetUniformLocation(program, "sTexture");
899     GetUniformLocation(program, "sEffect");
900     GetUniformLocation(program, "sGloss");
901   }
902
903   inline void PixelStorei(GLenum pname, GLint param)
904   {
905   }
906
907   inline void PolygonOffset(GLfloat factor, GLfloat units)
908   {
909   }
910
911   inline void ReadPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, void* pixels)
912   {
913   }
914
915   inline void ReleaseShaderCompiler(void)
916   {
917   }
918
919   inline void RenderbufferStorage(GLenum target, GLenum internalformat, GLsizei width, GLsizei height)
920   {
921   }
922
923   inline void SampleCoverage(GLclampf value, GLboolean invert)
924   {
925   }
926
927   inline void Scissor(GLint x, GLint y, GLsizei width, GLsizei height)
928   {
929     mScissorParams.x = x;
930     mScissorParams.y = y;
931     mScissorParams.width = width;
932     mScissorParams.height = height;
933   }
934
935   inline void ShaderBinary(GLsizei n, const GLuint* shaders, GLenum binaryformat, const void* binary, GLsizei length)
936   {
937   }
938
939   inline void ShaderSource(GLuint shader, GLsizei count, const char** string, const GLint* length)
940   {
941     std::string stringBuilder;
942     for(int i = 0; i < count; ++i)
943     {
944       stringBuilder += string[i];
945     }
946     mShaderSources[shader] = stringBuilder;
947     mLastShaderCompiled = shader;
948   }
949
950   inline void GetShaderSource(GLuint shader, GLsizei bufsize, GLsizei* length, char* source)
951   {
952     const std::string shaderSource = mShaderSources[shader];
953     if( static_cast<int>(shaderSource.length()) < bufsize )
954     {
955       strcpy(source, shaderSource.c_str());
956       *length = shaderSource.length();
957     }
958     else
959     {
960       *length = bufsize -1;
961       strncpy(source, shaderSource.c_str(), *length);
962       source[*length] = 0x0;
963     }
964   }
965
966   inline std::string GetShaderSource(GLuint shader)
967   {
968     return mShaderSources[shader];
969   }
970
971   inline void StencilFunc(GLenum func, GLint ref, GLuint mask)
972   {
973     std::stringstream out;
974     out << func << ", " << ref << ", " << mask;
975
976     TraceCallStack::NamedParams namedParams;
977     namedParams["func"] = ToString( func );
978     namedParams["ref"] = ToString( ref );
979     namedParams["mask"] = ToString( mask );
980
981     mStencilFunctionTrace.PushCall( "StencilFunc", out.str(), namedParams );
982   }
983
984   inline void StencilFuncSeparate(GLenum face, GLenum func, GLint ref, GLuint mask)
985   {
986     std::stringstream out;
987     out << face << ", " << func << ", " << ref << ", " << mask;
988
989     TraceCallStack::NamedParams namedParams;
990     namedParams["face"] = ToString( face );
991     namedParams["func"] = ToString( func );
992     namedParams["ref"] = ToString( ref );
993     namedParams["mask"] = ToString( mask );
994
995     mStencilFunctionTrace.PushCall( "StencilFuncSeparate", out.str(), namedParams );
996   }
997
998   inline void StencilMask(GLuint mask)
999   {
1000     std::stringstream out;
1001     out << mask;
1002
1003     TraceCallStack::NamedParams namedParams;
1004     namedParams["mask"] = ToString( mask );
1005
1006     mStencilFunctionTrace.PushCall( "StencilMask", out.str(), namedParams );
1007   }
1008
1009   inline void StencilMaskSeparate(GLenum face, GLuint mask)
1010   {
1011     std::stringstream out;
1012     out << face << ", " << mask;
1013
1014     TraceCallStack::NamedParams namedParams;
1015     namedParams["face"] = ToString( face );
1016     namedParams["mask"] = ToString( mask );
1017
1018     mStencilFunctionTrace.PushCall( "StencilMaskSeparate", out.str(), namedParams );
1019   }
1020
1021   inline void StencilOp(GLenum fail, GLenum zfail, GLenum zpass)
1022   {
1023     std::stringstream out;
1024     out << fail << ", " << zfail << ", " << zpass;
1025
1026     TraceCallStack::NamedParams namedParams;
1027     namedParams["fail"] = ToString( fail );
1028     namedParams["zfail"] = ToString( zfail );
1029     namedParams["zpass"] = ToString( zpass );
1030
1031     mStencilFunctionTrace.PushCall( "StencilOp", out.str(), namedParams );
1032   }
1033
1034   inline void StencilOpSeparate(GLenum face, GLenum fail, GLenum zfail, GLenum zpass)
1035   {
1036     std::stringstream out;
1037     out << face << ", " << fail << ", " << zfail << "," << zpass;
1038
1039     TraceCallStack::NamedParams namedParams;
1040     namedParams["face"] = ToString( face );
1041     namedParams["fail"] = ToString( fail );
1042     namedParams["zfail"] = ToString( zfail );
1043     namedParams["zpass"] = ToString( zpass );
1044
1045     mStencilFunctionTrace.PushCall( "StencilOpSeparate", out.str(), namedParams );
1046   }
1047
1048   inline void TexImage2D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void* pixels)
1049   {
1050     std::stringstream out;
1051     out << target<<", "<<level<<", "<<width << ", " << height;
1052
1053     TraceCallStack::NamedParams namedParams;
1054     namedParams["target"] = ToString(target);
1055     namedParams["level"] = ToString(level);
1056     namedParams["internalformat"] = ToString(internalformat);
1057     namedParams["width"] = ToString(width);
1058     namedParams["height"] = ToString(height);
1059     namedParams["border"] = ToString(border);
1060     namedParams["format"] = ToString(format);
1061     namedParams["type"] = ToString(type);
1062
1063     mTextureTrace.PushCall("TexImage2D", out.str(), namedParams);
1064   }
1065
1066   inline void TexParameterf(GLenum target, GLenum pname, GLfloat param)
1067   {
1068     std::stringstream out;
1069     out << target << ", " << pname << ", " << param;
1070
1071     TraceCallStack::NamedParams namedParams;
1072     namedParams["target"] = ToString(target);
1073     namedParams["pname"] = ToString(pname);
1074     namedParams["param"] = ToString(param);
1075
1076     mTexParamaterTrace.PushCall("TexParameterf", out.str(), namedParams);
1077   }
1078
1079   inline void TexParameterfv(GLenum target, GLenum pname, const GLfloat* params)
1080   {
1081     std::stringstream out;
1082     out << target << ", " << pname << ", " << params[0];
1083
1084     TraceCallStack::NamedParams namedParams;
1085     namedParams["target"] = ToString(target);
1086     namedParams["pname"] = ToString(pname);
1087     namedParams["params[0]"] = ToString(params[0]);
1088
1089     mTexParamaterTrace.PushCall("TexParameterfv", out.str(), namedParams);
1090   }
1091
1092   inline void TexParameteri(GLenum target, GLenum pname, GLint param)
1093   {
1094     std::stringstream out;
1095     out << target << ", " << pname << ", " << param;
1096     TraceCallStack::NamedParams namedParams;
1097     namedParams["target"] = ToString(target);
1098     namedParams["pname"] = ToString(pname);
1099     namedParams["param"] = ToString(param);
1100     mTexParamaterTrace.PushCall("TexParameteri", out.str(), namedParams);
1101   }
1102
1103   inline void TexParameteriv(GLenum target, GLenum pname, const GLint* params)
1104   {
1105     std::stringstream out;
1106     out << target << ", " << pname << ", " << params[0];
1107     TraceCallStack::NamedParams namedParams;
1108     namedParams["target"] = ToString(target);
1109     namedParams["pname"] = ToString(pname);
1110     namedParams["params[0]"] = ToString(params[0]);
1111     mTexParamaterTrace.PushCall("TexParameteriv", out.str(), namedParams);
1112   }
1113
1114   inline void TexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void* pixels)
1115   {
1116     std::stringstream out;
1117     out << target << ", "<<level <<", " << xoffset << ", " << yoffset << ", " << width << ", " << height;
1118
1119     TraceCallStack::NamedParams namedParams;
1120     namedParams["target"] = ToString(target);
1121     namedParams["level"] = ToString(level);
1122     namedParams["xoffset"] = ToString(xoffset);
1123     namedParams["yoffset"] = ToString(yoffset);
1124     namedParams["width"] = ToString(width);
1125     namedParams["height"] = ToString(height);
1126     mTextureTrace.PushCall("TexSubImage2D", out.str(), namedParams);
1127   }
1128
1129   inline void Uniform1f(GLint location, GLfloat x)
1130   {
1131     if( ! mProgramUniforms1f.SetUniformValue( mCurrentProgram, location, x ) )
1132     {
1133       mGetErrorResult = GL_INVALID_OPERATION;
1134     }
1135   }
1136
1137   inline void Uniform1fv(GLint location, GLsizei count, const GLfloat* v)
1138   {
1139     for( int i = 0; i < count; ++i )
1140     {
1141       if( ! mProgramUniforms1f.SetUniformValue( mCurrentProgram, location, v[i] ) )
1142       {
1143         mGetErrorResult = GL_INVALID_OPERATION;
1144         break;
1145       }
1146     }
1147   }
1148
1149   inline void Uniform1i(GLint location, GLint x)
1150   {
1151     if( ! mProgramUniforms1i.SetUniformValue( mCurrentProgram, location, x ) )
1152     {
1153       mGetErrorResult = GL_INVALID_OPERATION;
1154     }
1155   }
1156
1157   inline void Uniform1iv(GLint location, GLsizei count, const GLint* v)
1158   {
1159     for( int i = 0; i < count; ++i )
1160     {
1161       if( ! mProgramUniforms1i.SetUniformValue( mCurrentProgram,
1162                                                  location,
1163                                                  v[i] ) )
1164       {
1165         mGetErrorResult = GL_INVALID_OPERATION;
1166         break;
1167       }
1168     }
1169   }
1170
1171   inline void Uniform2f(GLint location, GLfloat x, GLfloat y)
1172   {
1173     if( ! mProgramUniforms2f.SetUniformValue( mCurrentProgram,
1174                                                location,
1175                                                Vector2( x, y ) ) )
1176     {
1177       mGetErrorResult = GL_INVALID_OPERATION;
1178     }
1179   }
1180
1181   inline void Uniform2fv(GLint location, GLsizei count, const GLfloat* v)
1182   {
1183     for( int i = 0; i < count; ++i )
1184     {
1185       if( ! mProgramUniforms2f.SetUniformValue( mCurrentProgram,
1186                                                  location,
1187                                                  Vector2( v[2*i], v[2*i+1] ) ) )
1188       {
1189         mGetErrorResult = GL_INVALID_OPERATION;
1190         break;
1191       }
1192     }
1193   }
1194
1195   inline void Uniform2i(GLint location, GLint x, GLint y)
1196   {
1197   }
1198
1199   inline void Uniform2iv(GLint location, GLsizei count, const GLint* v)
1200   {
1201   }
1202
1203   inline void Uniform3f(GLint location, GLfloat x, GLfloat y, GLfloat z)
1204   {
1205     if( ! mProgramUniforms3f.SetUniformValue( mCurrentProgram,
1206                                                location,
1207                                                Vector3( x, y, z ) ) )
1208     {
1209       mGetErrorResult = GL_INVALID_OPERATION;
1210     }
1211   }
1212
1213   inline void Uniform3fv(GLint location, GLsizei count, const GLfloat* v)
1214   {
1215     for( int i = 0; i < count; ++i )
1216     {
1217       if( ! mProgramUniforms3f.SetUniformValue(
1218           mCurrentProgram,
1219           location,
1220           Vector3( v[3*i], v[3*i+1], v[3*i+2] ) ) )
1221       {
1222         mGetErrorResult = GL_INVALID_OPERATION;
1223         break;
1224       }
1225     }
1226   }
1227
1228   inline void Uniform3i(GLint location, GLint x, GLint y, GLint z)
1229   {
1230   }
1231
1232   inline void Uniform3iv(GLint location, GLsizei count, const GLint* v)
1233   {
1234   }
1235
1236   inline void Uniform4f(GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w)
1237   {
1238     if( ! mProgramUniforms4f.SetUniformValue( mCurrentProgram,
1239                                               location,
1240                                               Vector4( x, y, z, w ) ) )
1241     {
1242       mGetErrorResult = GL_INVALID_OPERATION;
1243     }
1244   }
1245
1246   inline void Uniform4fv(GLint location, GLsizei count, const GLfloat* v)
1247   {
1248     for( int i = 0; i < count; ++i )
1249     {
1250       if( ! mProgramUniforms4f.SetUniformValue(
1251           mCurrentProgram,
1252           location,
1253           Vector4( v[4*i], v[4*i+1], v[4*i+2], v[4*i+3] ) ) )
1254       {
1255         mGetErrorResult = GL_INVALID_OPERATION;
1256         break;
1257       }
1258     }
1259   }
1260
1261   inline void Uniform4i(GLint location, GLint x, GLint y, GLint z, GLint w)
1262   {
1263   }
1264
1265   inline void Uniform4iv(GLint location, GLsizei count, const GLint* v)
1266   {
1267   }
1268
1269   inline void UniformMatrix2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
1270   {
1271   }
1272
1273   inline void UniformMatrix3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
1274   {
1275     for( int i = 0; i < count; ++i )
1276     {
1277       if( ! mProgramUniformsMat3.SetUniformValue(
1278             mCurrentProgram,
1279             location,
1280             Matrix3( value[0], value[1], value[2], value[3], value[4], value[5], value[6], value[7], value[8] ) ) )
1281       {
1282         mGetErrorResult = GL_INVALID_OPERATION;
1283         break;
1284       }
1285     }
1286   }
1287
1288   inline void UniformMatrix4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
1289   {
1290     for( int i = 0; i < count; ++i )
1291     {
1292       if( ! mProgramUniformsMat4.SetUniformValue(
1293           mCurrentProgram,
1294           location,
1295           Matrix( value ) ) )
1296       {
1297         mGetErrorResult = GL_INVALID_OPERATION;
1298         break;
1299       }
1300     }
1301   }
1302
1303   inline void UseProgram(GLuint program)
1304   {
1305     mCurrentProgram = program;
1306   }
1307
1308   inline void ValidateProgram(GLuint program)
1309   {
1310   }
1311
1312   inline void VertexAttrib1f(GLuint indx, GLfloat x)
1313   {
1314   }
1315
1316   inline void VertexAttrib1fv(GLuint indx, const GLfloat* values)
1317   {
1318   }
1319
1320   inline void VertexAttrib2f(GLuint indx, GLfloat x, GLfloat y)
1321   {
1322   }
1323
1324   inline void VertexAttrib2fv(GLuint indx, const GLfloat* values)
1325   {
1326   }
1327
1328   inline void VertexAttrib3f(GLuint indx, GLfloat x, GLfloat y, GLfloat z)
1329   {
1330   }
1331
1332   inline void VertexAttrib3fv(GLuint indx, const GLfloat* values)
1333   {
1334   }
1335
1336   inline void VertexAttrib4f(GLuint indx, GLfloat x, GLfloat y, GLfloat z, GLfloat w)
1337   {
1338   }
1339
1340   inline void VertexAttrib4fv(GLuint indx, const GLfloat* values)
1341   {
1342   }
1343
1344   inline void VertexAttribPointer(GLuint indx, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void* ptr)
1345   {
1346   }
1347
1348   inline void Viewport(GLint x, GLint y, GLsizei width, GLsizei height)
1349   {
1350   }
1351
1352   /* OpenGL ES 3.0 */
1353
1354   inline void ReadBuffer(GLenum mode)
1355   {
1356   }
1357
1358   inline void DrawRangeElements(GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid* indices)
1359   {
1360   }
1361
1362   inline void TexImage3D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid* pixels)
1363   {
1364   }
1365
1366   inline void TexSubImage3D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid* pixels)
1367   {
1368   }
1369
1370   inline void CopyTexSubImage3D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height)
1371   {
1372   }
1373
1374   inline void CompressedTexImage3D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid* data)
1375   {
1376   }
1377
1378   inline void CompressedTexSubImage3D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid* data)
1379   {
1380   }
1381
1382   inline void GenQueries(GLsizei n, GLuint* ids)
1383   {
1384   }
1385
1386   inline void DeleteQueries(GLsizei n, const GLuint* ids)
1387   {
1388   }
1389
1390   inline GLboolean IsQuery(GLuint id)
1391   {
1392     return false;
1393   }
1394
1395   inline void BeginQuery(GLenum target, GLuint id)
1396   {
1397   }
1398
1399   inline void EndQuery(GLenum target)
1400   {
1401   }
1402
1403   inline void GetQueryiv(GLenum target, GLenum pname, GLint* params)
1404   {
1405   }
1406
1407   inline void GetQueryObjectuiv(GLuint id, GLenum pname, GLuint* params)
1408   {
1409   }
1410
1411   inline GLboolean UnmapBuffer(GLenum target)
1412   {
1413     return false;
1414   }
1415
1416   inline void GetBufferPointerv(GLenum target, GLenum pname, GLvoid** params)
1417   {
1418   }
1419
1420   inline void DrawBuffers(GLsizei n, const GLenum* bufs)
1421   {
1422   }
1423
1424   inline void UniformMatrix2x3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
1425   {
1426   }
1427
1428   inline void UniformMatrix3x2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
1429   {
1430   }
1431
1432   inline void UniformMatrix2x4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
1433   {
1434   }
1435
1436   inline void UniformMatrix4x2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
1437   {
1438   }
1439
1440   inline void UniformMatrix3x4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
1441   {
1442   }
1443
1444   inline void UniformMatrix4x3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
1445   {
1446   }
1447
1448   inline void BlitFramebuffer(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter)
1449   {
1450   }
1451
1452   inline void RenderbufferStorageMultisample(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height)
1453   {
1454   }
1455
1456   inline void FramebufferTextureLayer(GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer)
1457   {
1458   }
1459
1460   inline GLvoid* MapBufferRange(GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access)
1461   {
1462     return NULL;
1463   }
1464
1465   inline void FlushMappedBufferRange(GLenum target, GLintptr offset, GLsizeiptr length)
1466   {
1467   }
1468
1469   inline void BindVertexArray(GLuint array)
1470   {
1471   }
1472
1473   inline void DeleteVertexArrays(GLsizei n, const GLuint* arrays)
1474   {
1475   }
1476
1477   inline void GenVertexArrays(GLsizei n, GLuint* arrays)
1478   {
1479   }
1480
1481   inline GLboolean IsVertexArray(GLuint array)
1482   {
1483     return false;
1484   }
1485
1486   inline void GetIntegeri_v(GLenum target, GLuint index, GLint* data)
1487   {
1488   }
1489
1490   inline void BeginTransformFeedback(GLenum primitiveMode)
1491   {
1492   }
1493
1494   inline void EndTransformFeedback(void)
1495   {
1496   }
1497
1498   inline void BindBufferRange(GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size)
1499   {
1500   }
1501
1502   inline void BindBufferBase(GLenum target, GLuint index, GLuint buffer)
1503   {
1504   }
1505
1506   inline void TransformFeedbackVaryings(GLuint program, GLsizei count, const GLchar* const* varyings, GLenum bufferMode)
1507   {
1508   }
1509
1510   inline void GetTransformFeedbackVarying(GLuint program, GLuint index, GLsizei bufSize, GLsizei* length, GLsizei* size, GLenum* type, GLchar* name)
1511   {
1512   }
1513
1514   inline void VertexAttribIPointer(GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid* pointer)
1515   {
1516   }
1517
1518   inline void GetVertexAttribIiv(GLuint index, GLenum pname, GLint* params)
1519   {
1520   }
1521
1522   inline void GetVertexAttribIuiv(GLuint index, GLenum pname, GLuint* params)
1523   {
1524   }
1525
1526   inline void VertexAttribI4i(GLuint index, GLint x, GLint y, GLint z, GLint w)
1527   {
1528   }
1529
1530   inline void VertexAttribI4ui(GLuint index, GLuint x, GLuint y, GLuint z, GLuint w)
1531   {
1532   }
1533
1534   inline void VertexAttribI4iv(GLuint index, const GLint* v)
1535   {
1536   }
1537
1538   inline void VertexAttribI4uiv(GLuint index, const GLuint* v)
1539   {
1540   }
1541
1542   inline void GetUniformuiv(GLuint program, GLint location, GLuint* params)
1543   {
1544   }
1545
1546   inline GLint GetFragDataLocation(GLuint program, const GLchar *name)
1547   {
1548     return -1;
1549   }
1550
1551   inline void Uniform1ui(GLint location, GLuint v0)
1552   {
1553   }
1554
1555   inline void Uniform2ui(GLint location, GLuint v0, GLuint v1)
1556   {
1557   }
1558
1559   inline void Uniform3ui(GLint location, GLuint v0, GLuint v1, GLuint v2)
1560   {
1561   }
1562
1563   inline void Uniform4ui(GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3)
1564   {
1565   }
1566
1567   inline void Uniform1uiv(GLint location, GLsizei count, const GLuint* value)
1568   {
1569   }
1570
1571   inline void Uniform2uiv(GLint location, GLsizei count, const GLuint* value)
1572   {
1573   }
1574
1575   inline void Uniform3uiv(GLint location, GLsizei count, const GLuint* value)
1576   {
1577   }
1578
1579   inline void Uniform4uiv(GLint location, GLsizei count, const GLuint* value)
1580   {
1581   }
1582
1583   inline void ClearBufferiv(GLenum buffer, GLint drawbuffer, const GLint* value)
1584   {
1585   }
1586
1587   inline void ClearBufferuiv(GLenum buffer, GLint drawbuffer, const GLuint* value)
1588   {
1589   }
1590
1591   inline void ClearBufferfv(GLenum buffer, GLint drawbuffer, const GLfloat* value)
1592   {
1593   }
1594
1595   inline void ClearBufferfi(GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil)
1596   {
1597   }
1598
1599   inline const GLubyte* GetStringi(GLenum name, GLuint index)
1600   {
1601     return NULL;
1602   }
1603
1604   inline void CopyBufferSubData(GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size)
1605   {
1606   }
1607
1608   inline void GetUniformIndices(GLuint program, GLsizei uniformCount, const GLchar* const* uniformNames, GLuint* uniformIndices)
1609   {
1610   }
1611
1612   inline void GetActiveUniformsiv(GLuint program, GLsizei uniformCount, const GLuint* uniformIndices, GLenum pname, GLint* params)
1613   {
1614   }
1615
1616   inline GLuint GetUniformBlockIndex(GLuint program, const GLchar* uniformBlockName)
1617   {
1618     return GL_INVALID_INDEX;
1619   }
1620
1621   inline void GetActiveUniformBlockiv(GLuint program, GLuint uniformBlockIndex, GLenum pname, GLint* params)
1622   {
1623   }
1624
1625   inline void GetActiveUniformBlockName(GLuint program, GLuint uniformBlockIndex, GLsizei bufSize, GLsizei* length, GLchar* uniformBlockName)
1626   {
1627   }
1628
1629   inline void UniformBlockBinding(GLuint program, GLuint uniformBlockIndex, GLuint uniformBlockBinding)
1630   {
1631   }
1632
1633   inline void DrawArraysInstanced(GLenum mode, GLint first, GLsizei count, GLsizei instanceCount)
1634   {
1635   }
1636
1637   inline void DrawElementsInstanced(GLenum mode, GLsizei count, GLenum type, const GLvoid* indices, GLsizei instanceCount)
1638   {
1639   }
1640
1641   inline GLsync FenceSync(GLenum condition, GLbitfield flags)
1642   {
1643     return NULL;
1644   }
1645
1646   inline GLboolean IsSync(GLsync sync)
1647   {
1648     return false;
1649   }
1650
1651   inline void DeleteSync(GLsync sync)
1652   {
1653   }
1654
1655   inline GLenum ClientWaitSync(GLsync sync, GLbitfield flags, GLuint64 timeout)
1656   {
1657     return 0;
1658   }
1659
1660   inline void WaitSync(GLsync sync, GLbitfield flags, GLuint64 timeout)
1661   {
1662   }
1663
1664   inline void GetInteger64v(GLenum pname, GLint64* params)
1665   {
1666   }
1667
1668   inline void GetSynciv(GLsync sync, GLenum pname, GLsizei bufSize, GLsizei* length, GLint* values)
1669   {
1670   }
1671
1672   inline void GetInteger64i_v(GLenum target, GLuint index, GLint64* data)
1673   {
1674   }
1675
1676   inline void GetBufferParameteri64v(GLenum target, GLenum pname, GLint64* params)
1677   {
1678   }
1679
1680   inline void GenSamplers(GLsizei count, GLuint* samplers)
1681   {
1682   }
1683
1684   inline void DeleteSamplers(GLsizei count, const GLuint* samplers)
1685   {
1686   }
1687
1688   inline GLboolean IsSampler(GLuint sampler)
1689   {
1690     return false;
1691   }
1692
1693   inline void BindSampler(GLuint unit, GLuint sampler)
1694   {
1695   }
1696
1697   inline void SamplerParameteri(GLuint sampler, GLenum pname, GLint param)
1698   {
1699   }
1700
1701   inline void SamplerParameteriv(GLuint sampler, GLenum pname, const GLint* param)
1702   {
1703   }
1704
1705   inline void SamplerParameterf(GLuint sampler, GLenum pname, GLfloat param)
1706   {
1707   }
1708
1709   inline void SamplerParameterfv(GLuint sampler, GLenum pname, const GLfloat* param)
1710   {
1711   }
1712
1713   inline void GetSamplerParameteriv(GLuint sampler, GLenum pname, GLint* params)
1714   {
1715   }
1716
1717   inline void GetSamplerParameterfv(GLuint sampler, GLenum pname, GLfloat* params)
1718   {
1719   }
1720
1721   inline void VertexAttribDivisor(GLuint index, GLuint divisor)
1722   {
1723   }
1724
1725   inline void BindTransformFeedback(GLenum target, GLuint id)
1726   {
1727   }
1728
1729   inline void DeleteTransformFeedbacks(GLsizei n, const GLuint* ids)
1730   {
1731   }
1732
1733   inline void GenTransformFeedbacks(GLsizei n, GLuint* ids)
1734   {
1735   }
1736
1737   inline GLboolean IsTransformFeedback(GLuint id)
1738   {
1739     return false;
1740   }
1741
1742   inline void PauseTransformFeedback(void)
1743   {
1744   }
1745
1746   inline void ResumeTransformFeedback(void)
1747   {
1748   }
1749
1750   inline void GetProgramBinary(GLuint program, GLsizei bufSize, GLsizei* length, GLenum* binaryFormat, GLvoid* binary)
1751   {
1752     mGetProgramBinaryCalled = true;
1753   }
1754
1755   inline void ProgramBinary(GLuint program, GLenum binaryFormat, const GLvoid* binary, GLsizei length)
1756   {
1757   }
1758
1759   inline void ProgramParameteri(GLuint program, GLenum pname, GLint value)
1760   {
1761   }
1762
1763   inline void InvalidateFramebuffer(GLenum target, GLsizei numAttachments, const GLenum* attachments)
1764   {
1765   }
1766
1767   inline void InvalidateSubFramebuffer(GLenum target, GLsizei numAttachments, const GLenum* attachments, GLint x, GLint y, GLsizei width, GLsizei height)
1768   {
1769   }
1770
1771   inline void TexStorage2D(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height)
1772   {
1773   }
1774
1775   inline void TexStorage3D(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth)
1776   {
1777   }
1778
1779   inline void GetInternalformativ(GLenum target, GLenum internalformat, GLenum pname, GLsizei bufSize, GLint* params)
1780   {
1781   }
1782
1783 public: // TEST FUNCTIONS
1784   inline void SetCompileStatus( GLuint value ) { mCompileStatus = value; }
1785   inline void SetLinkStatus( GLuint value ) { mLinkStatus = value; }
1786   inline void SetGetAttribLocationResult(  int result) { mGetAttribLocationResult = result; }
1787   inline void SetGetErrorResult(  GLenum result) { mGetErrorResult = result; }
1788   inline void SetGetStringResult(  GLubyte* result) { mGetStringResult = result; }
1789   inline void SetIsBufferResult(  GLboolean result) { mIsBufferResult = result; }
1790   inline void SetIsEnabledResult(  GLboolean result) { mIsEnabledResult = result; }
1791   inline void SetIsFramebufferResult(  GLboolean result) { mIsFramebufferResult = result; }
1792   inline void SetIsProgramResult(  GLboolean result) { mIsProgramResult = result; }
1793   inline void SetIsRenderbufferResult(  GLboolean result) { mIsRenderbufferResult = result; }
1794   inline void SetIsShaderResult(  GLboolean result) { mIsShaderResult = result; }
1795   inline void SetIsTextureResult(  GLboolean result) { mIsTextureResult = result; }
1796   inline void SetCheckFramebufferStatusResult(  GLenum result) { mCheckFramebufferStatusResult = result; }
1797   inline void SetNumBinaryFormats( GLint numFormats ) { mNumBinaryFormats = numFormats; }
1798   inline void SetBinaryFormats( GLint binaryFormats ) { mBinaryFormats = binaryFormats; }
1799   inline void SetProgramBinaryLength( GLint length ) { mProgramBinaryLength = length; }
1800
1801   inline bool GetVertexAttribArrayState(GLuint index)
1802   {
1803     if( index >= MAX_ATTRIBUTE_CACHE_SIZE )
1804     {
1805       // out of range
1806       return false;
1807     }
1808     return mVertexAttribArrayState[ index ];
1809   }
1810   inline void ClearVertexAttribArrayChanged() {  mVertexAttribArrayChanged = false; }
1811   inline bool GetVertexAttribArrayChanged()  { return mVertexAttribArrayChanged; }
1812
1813   //Methods for CullFace verification
1814   inline void EnableCullFaceCallTrace(bool enable) { mCullFaceTrace.Enable(enable); }
1815   inline void ResetCullFaceCallStack() { mCullFaceTrace.Reset(); }
1816   inline TraceCallStack& GetCullFaceTrace() { return mCullFaceTrace; }
1817
1818   //Methods for Enable/Disable call verification
1819   inline void EnableEnableDisableCallTrace(bool enable) { mEnableDisableTrace.Enable(enable); }
1820   inline void ResetEnableDisableCallStack() { mEnableDisableTrace.Reset(); }
1821   inline TraceCallStack& GetEnableDisableTrace() { return mEnableDisableTrace; }
1822
1823   //Methods for Shader verification
1824   inline void EnableShaderCallTrace(bool enable) { mShaderTrace.Enable(enable); }
1825   inline void ResetShaderCallStack() { mShaderTrace.Reset(); }
1826   inline TraceCallStack& GetShaderTrace() { return mShaderTrace; }
1827
1828   //Methods for Texture verification
1829   inline void EnableTextureCallTrace(bool enable) { mTextureTrace.Enable(enable); }
1830   inline void ResetTextureCallStack() { mTextureTrace.Reset(); }
1831   inline TraceCallStack& GetTextureTrace() { return mTextureTrace; }
1832
1833   //Methods for Texture verification
1834   inline void EnableTexParameterCallTrace(bool enable) { mTexParamaterTrace.Enable(enable); }
1835   inline void ResetTexParameterCallStack() { mTexParamaterTrace.Reset(); }
1836   inline TraceCallStack& GetTexParameterTrace() { return mTexParamaterTrace; }
1837
1838   //Methods for Draw verification
1839   inline void EnableDrawCallTrace(bool enable) { mDrawTrace.Enable(enable); }
1840   inline void ResetDrawCallStack() { mDrawTrace.Reset(); }
1841   inline TraceCallStack& GetDrawTrace() { return mDrawTrace; }
1842
1843   //Methods for Depth function verification
1844   inline void EnableDepthFunctionCallTrace(bool enable) { mDepthFunctionTrace.Enable(enable); }
1845   inline void ResetDepthFunctionCallStack() { mDepthFunctionTrace.Reset(); }
1846   inline TraceCallStack& GetDepthFunctionTrace() { return mDepthFunctionTrace; }
1847
1848   //Methods for Stencil function verification
1849   inline void EnableStencilFunctionCallTrace(bool enable) { mStencilFunctionTrace.Enable(enable); }
1850   inline void ResetStencilFunctionCallStack() { mStencilFunctionTrace.Reset(); }
1851   inline TraceCallStack& GetStencilFunctionTrace() { return mStencilFunctionTrace; }
1852
1853   template <typename T>
1854   inline bool GetUniformValue( const char* name, T& value ) const
1855   {
1856     for( ProgramUniformMap::const_iterator program_it = mUniforms.begin();
1857           program_it != mUniforms.end();
1858           ++program_it )
1859     {
1860       const UniformIDMap &uniformIDs = program_it->second;
1861
1862       UniformIDMap::const_iterator uniform_it = uniformIDs.find( name );
1863       if( uniform_it != uniformIDs.end() )
1864       {
1865         // found one matching uniform name, lets check the value...
1866         GLuint programId = program_it->first;
1867         GLint uniformId = uniform_it->second;
1868
1869         const ProgramUniformValue<T> &mProgramUniforms = GetProgramUniformsForType( value );
1870         return mProgramUniforms.GetUniformValue( programId, uniformId, value );
1871       }
1872     }
1873     return false;
1874   }
1875
1876
1877   template <typename T>
1878   inline bool CheckUniformValue( const char* name, const T& value ) const
1879   {
1880     for( ProgramUniformMap::const_iterator program_it = mUniforms.begin();
1881           program_it != mUniforms.end();
1882           ++program_it )
1883     {
1884       const UniformIDMap &uniformIDs = program_it->second;
1885
1886       UniformIDMap::const_iterator uniform_it = uniformIDs.find( name );
1887       if( uniform_it != uniformIDs.end() )
1888       {
1889         // found one matching uniform name, lets check the value...
1890         GLuint programId = program_it->first;
1891         GLint uniformId = uniform_it->second;
1892
1893         const ProgramUniformValue<T> &mProgramUniforms = GetProgramUniformsForType( value );
1894         if( mProgramUniforms.CheckUniformValue( programId, uniformId, value ) )
1895         {
1896           // the value matches
1897           return true;
1898         }
1899       }
1900     }
1901
1902     fprintf(stderr, "Not found, printing possible values:\n" );
1903     for( ProgramUniformMap::const_iterator program_it = mUniforms.begin();
1904           program_it != mUniforms.end();
1905           ++program_it )
1906     {
1907       const UniformIDMap &uniformIDs = program_it->second;
1908
1909       UniformIDMap::const_iterator uniform_it = uniformIDs.find( name );
1910       if( uniform_it != uniformIDs.end() )
1911       {
1912         // found one matching uniform name, lets check the value...
1913         GLuint programId = program_it->first;
1914         GLint uniformId = uniform_it->second;
1915
1916         const ProgramUniformValue<T> &mProgramUniforms = GetProgramUniformsForType( value );
1917         T origValue;
1918         if ( mProgramUniforms.GetUniformValue(programId, uniformId, origValue) )
1919         {
1920           std::stringstream out;
1921           out << uniform_it->first << ": " << origValue;
1922           fprintf(stderr, "%s\n", out.str().c_str() );
1923         }
1924       }
1925     }
1926     return false;
1927   }
1928
1929   template <typename T>
1930   inline bool GetUniformValue( GLuint programId, GLuint uniformId, T& outValue) const
1931   {
1932     const ProgramUniformValue<T> &mProgramUniforms = GetProgramUniformsForType( outValue );
1933     return mProgramUniforms.GetUniformValue( programId, uniformId, outValue );
1934   }
1935
1936   inline bool GetUniformIds( const char* name, GLuint& programId, GLuint& uniformId ) const
1937   {
1938     for( ProgramUniformMap::const_iterator program_it = mUniforms.begin();
1939           program_it != mUniforms.end();
1940           ++program_it )
1941     {
1942       const UniformIDMap &uniformIDs = program_it->second;
1943
1944       UniformIDMap::const_iterator uniform_it = uniformIDs.find( name );
1945       if( uniform_it != uniformIDs.end() )
1946       {
1947         programId = program_it->first;
1948         uniformId = uniform_it->second;
1949         return true;
1950       }
1951     }
1952     return false;
1953   }
1954
1955   inline GLuint GetLastShaderCompiled() const
1956   {
1957     return mLastShaderCompiled;
1958   }
1959
1960   inline GLuint GetLastProgramCreated() const
1961   {
1962     return mLastProgramIdUsed;
1963   }
1964
1965   inline GLbitfield GetLastClearMask() const
1966   {
1967     return mLastClearBitMask;
1968   }
1969
1970   enum AttribType
1971   {
1972     ATTRIB_UNKNOWN = -1,
1973     ATTRIB_POSITION,
1974     ATTRIB_NORMAL,
1975     ATTRIB_TEXCOORD,
1976     ATTRIB_COLOR,
1977     ATTRIB_BONE_WEIGHTS,
1978     ATTRIB_BONE_INDICES,
1979     ATTRIB_TYPE_LAST
1980   };
1981
1982   struct ScissorParams
1983   {
1984     GLint x;
1985     GLint y;
1986     GLsizei width;
1987     GLsizei height;
1988
1989     ScissorParams() : x( 0 ), y( 0 ), width( 0 ), height( 0 ) { }
1990   };
1991
1992   // Methods to check scissor tests
1993   inline const ScissorParams& GetScissorParams() const { return mScissorParams; }
1994
1995   struct ColorMaskParams
1996   {
1997     GLboolean red;
1998     GLboolean green;
1999     GLboolean blue;
2000     GLboolean alpha;
2001
2002     ColorMaskParams() : red( true ), green( true ), blue( true ), alpha( true ) { }
2003   };
2004
2005   inline bool GetProgramBinaryCalled() const { return mGetProgramBinaryCalled; }
2006
2007   inline unsigned int GetClearCountCalled() const { return mClearCount; }
2008
2009   inline const ColorMaskParams& GetColorMaskParams() const { return mColorMaskParams; }
2010
2011   typedef std::vector<size_t> BufferDataCalls;
2012   inline const BufferDataCalls& GetBufferDataCalls() const { return mBufferDataCalls; }
2013   inline void ResetBufferDataCalls() { mBufferDataCalls.clear(); }
2014
2015   typedef std::vector<size_t> BufferSubDataCalls;
2016   inline const BufferSubDataCalls& GetBufferSubDataCalls() const { return mBufferSubDataCalls; }
2017   inline void ResetBufferSubDataCalls() { mBufferSubDataCalls.clear(); }
2018
2019 private:
2020   GLuint     mCurrentProgram;
2021   GLuint     mCompileStatus;
2022   BufferDataCalls mBufferDataCalls;
2023   BufferSubDataCalls mBufferSubDataCalls;
2024   GLuint     mLinkStatus;
2025   GLint      mNumberOfActiveUniforms;
2026   GLint      mGetAttribLocationResult;
2027   GLenum     mGetErrorResult;
2028   GLubyte*   mGetStringResult;
2029   GLboolean  mIsBufferResult;
2030   GLboolean  mIsEnabledResult;
2031   GLboolean  mIsFramebufferResult;
2032   GLboolean  mIsProgramResult;
2033   GLboolean  mIsRenderbufferResult;
2034   GLboolean  mIsShaderResult;
2035   GLboolean  mIsTextureResult;
2036   GLenum     mActiveTextureUnit;
2037   GLenum     mCheckFramebufferStatusResult;
2038   GLint      mFramebufferStatus;
2039   GLenum     mFramebufferColorAttached;
2040   GLenum     mFramebufferDepthAttached;
2041   GLenum     mFramebufferStencilAttached;
2042   GLint      mNumBinaryFormats;
2043   GLint      mBinaryFormats;
2044   GLint      mProgramBinaryLength;
2045   bool       mVertexAttribArrayState[MAX_ATTRIBUTE_CACHE_SIZE];
2046   bool       mVertexAttribArrayChanged;                            // whether the vertex attrib array has been changed
2047   bool       mGetProgramBinaryCalled;
2048   typedef std::map< GLuint, std::string> ShaderSourceMap;
2049   ShaderSourceMap mShaderSources;
2050   GLuint     mLastShaderCompiled;
2051   GLbitfield mLastClearBitMask;
2052   unsigned int mClearCount;
2053
2054   Vector4 mLastBlendColor;
2055   GLenum  mLastBlendEquationRgb;
2056   GLenum  mLastBlendEquationAlpha;
2057   GLenum  mLastBlendFuncSrcRgb;
2058   GLenum  mLastBlendFuncDstRgb;
2059   GLenum  mLastBlendFuncSrcAlpha;
2060   GLenum  mLastBlendFuncDstAlpha;
2061
2062   // Data for manipulating the IDs returned by GenTextures
2063   GLuint mLastAutoTextureIdUsed;
2064   std::vector<GLuint> mNextTextureIds;
2065   std::vector<GLuint> mDeletedTextureIds;
2066   std::vector<GLuint> mBoundTextures;
2067
2068   struct ActiveTextureType
2069   {
2070     std::vector<GLuint> mBoundTextures;
2071   };
2072
2073   ActiveTextureType mActiveTextures[ MIN_TEXTURE_UNIT_LIMIT ];
2074
2075   TraceCallStack mCullFaceTrace;
2076   TraceCallStack mEnableDisableTrace;
2077   TraceCallStack mShaderTrace;
2078   TraceCallStack mTextureTrace;
2079   TraceCallStack mTexParamaterTrace;
2080   TraceCallStack mDrawTrace;
2081   TraceCallStack mDepthFunctionTrace;
2082   TraceCallStack mStencilFunctionTrace;
2083
2084   // Shaders & Uniforms
2085   GLuint mLastShaderIdUsed;
2086   GLuint mLastProgramIdUsed;
2087   GLuint mLastUniformIdUsed;
2088   typedef std::map< std::string, GLint > UniformIDMap;
2089   typedef std::map< GLuint, UniformIDMap > ProgramUniformMap;
2090   ProgramUniformMap mUniforms;
2091
2092   template <typename T>
2093   struct ProgramUniformValue : public std::map< GLuint, std::map< GLint, T > >
2094   {
2095   public:
2096     typedef std::map< GLint, T > UniformValueMap;
2097     typedef std::map< GLuint, UniformValueMap > Map;
2098
2099     bool SetUniformValue( GLuint program, GLuint uniform, const T& value )
2100     {
2101       if( program == 0 )
2102       {
2103         return false;
2104       }
2105
2106       typename Map::iterator it = Map::find( program );
2107       if( it == Map::end() )
2108       {
2109         // if its the first uniform for this program add it
2110         std::pair< typename Map::iterator, bool > result =
2111             Map::insert( typename Map::value_type( program, UniformValueMap() ) );
2112         it = result.first;
2113       }
2114
2115       UniformValueMap& uniforms = it->second;
2116       uniforms[uniform] = value;
2117
2118       return true;
2119     }
2120
2121     bool CheckUniformValue( GLuint program, GLuint uniform, const T& value ) const
2122     {
2123       T uniformValue;
2124       if ( GetUniformValue( program, uniform, uniformValue ) )
2125       {
2126         return value == uniformValue;
2127       }
2128
2129       return false;
2130     }
2131
2132     bool GetUniformValue( GLuint program, GLuint uniform, T& value ) const
2133     {
2134       if( program == 0 )
2135       {
2136         return false;
2137       }
2138
2139       typename Map::const_iterator it = Map::find( program );
2140       if( it == Map::end() )
2141       {
2142         // Uniform values always initialised as 0
2143         value = GetZero();
2144         return true;
2145       }
2146
2147       const UniformValueMap& uniforms = it->second;
2148       typename UniformValueMap::const_iterator it2 = uniforms.find( uniform );
2149       if( it2 == uniforms.end() )
2150       {
2151         // Uniform values always initialised as 0
2152         value = GetZero();
2153         return true;
2154       }
2155       value = it2->second;
2156
2157       return true;
2158     }
2159
2160     T GetZero() const;
2161   };
2162   ProgramUniformValue<int> mProgramUniforms1i;
2163   ProgramUniformValue<float> mProgramUniforms1f;
2164   ProgramUniformValue<Vector2> mProgramUniforms2f;
2165   ProgramUniformValue<Vector3> mProgramUniforms3f;
2166   ProgramUniformValue<Vector4> mProgramUniforms4f;
2167   ProgramUniformValue<Matrix> mProgramUniformsMat4;
2168   ProgramUniformValue<Matrix3> mProgramUniformsMat3;
2169
2170   inline const ProgramUniformValue<int>& GetProgramUniformsForType( const int ) const
2171   {
2172     return mProgramUniforms1i;
2173   }
2174   inline const ProgramUniformValue<float>& GetProgramUniformsForType( const float ) const
2175   {
2176     return mProgramUniforms1f;
2177   }
2178   inline const ProgramUniformValue<Vector2>& GetProgramUniformsForType( const Vector2& ) const
2179   {
2180     return mProgramUniforms2f;
2181   }
2182   inline const ProgramUniformValue<Vector3>& GetProgramUniformsForType( const Vector3& ) const
2183   {
2184     return mProgramUniforms3f;
2185   }
2186   inline const ProgramUniformValue<Vector4>& GetProgramUniformsForType( const Vector4& ) const
2187   {
2188     return mProgramUniforms4f;
2189   }
2190   inline const ProgramUniformValue<Matrix>& GetProgramUniformsForType( const Matrix& ) const
2191   {
2192     return mProgramUniformsMat4;
2193   }
2194   inline const ProgramUniformValue<Matrix3>& GetProgramUniformsForType( const Matrix3& ) const
2195   {
2196     return mProgramUniformsMat3;
2197   }
2198   inline void SetVertexAttribArray(GLuint index, bool state)
2199   {
2200     if( index >= MAX_ATTRIBUTE_CACHE_SIZE )
2201     {
2202       // out of range
2203       return;
2204     }
2205     mVertexAttribArrayState[ index ] = state;
2206     mVertexAttribArrayChanged = true;
2207   }
2208
2209   ScissorParams mScissorParams;
2210   ColorMaskParams mColorMaskParams;
2211 };
2212
2213 template <>
2214 inline int TestGlAbstraction::ProgramUniformValue<int>::GetZero() const
2215 {
2216   return 0;
2217 }
2218
2219 template <>
2220 inline float TestGlAbstraction::ProgramUniformValue<float>::GetZero() const
2221 {
2222   return 0.0f;
2223 }
2224
2225 template <>
2226 inline Vector2 TestGlAbstraction::ProgramUniformValue<Vector2>::GetZero() const
2227 {
2228   return Vector2::ZERO;
2229 }
2230
2231 template <>
2232 inline Vector3 TestGlAbstraction::ProgramUniformValue<Vector3>::GetZero() const
2233 {
2234   return Vector3::ZERO;
2235 }
2236
2237 template <>
2238 inline Vector4 TestGlAbstraction::ProgramUniformValue<Vector4>::GetZero() const
2239 {
2240   return Vector4::ZERO;
2241 }
2242
2243 template <>
2244 inline Matrix TestGlAbstraction::ProgramUniformValue<Matrix>::GetZero() const
2245 {
2246   return Matrix();
2247 }
2248
2249 template <>
2250 inline Matrix3 TestGlAbstraction::ProgramUniformValue<Matrix3>::GetZero() const
2251 {
2252   return Matrix3( Matrix() );
2253 }
2254
2255 } // namespace Dali
2256
2257 bool BlendEnabled(const Dali::TraceCallStack& callStack);
2258 bool BlendDisabled(const Dali::TraceCallStack& callStack);
2259
2260
2261
2262
2263 #endif // __TEST_GL_ES_H__