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