Merge "C# CustomView Implementation (C++ wrappers, manual bindings, C# wrappers)...
[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
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     mLastDepthMask = flag;
472   }
473
474   inline bool GetLastDepthMask() const
475   {
476     return mLastDepthMask;
477   }
478
479   inline void DepthRangef(GLclampf zNear, GLclampf zFar)
480   {
481   }
482
483   inline void DetachShader(GLuint program, GLuint shader)
484   {
485     std::stringstream out;
486     out << program << ", " << shader;
487     TraceCallStack::NamedParams namedParams;
488     namedParams["program"] = ToString(program);
489     namedParams["shader"] = ToString(shader);
490     mShaderTrace.PushCall("DetachShader", out.str(), namedParams);
491   }
492
493   inline void Disable(GLenum cap)
494   {
495     std::stringstream out;
496     out << cap;
497     TraceCallStack::NamedParams namedParams;
498     namedParams["cap"] = ToString(cap);
499     mEnableDisableTrace.PushCall("Disable", out.str(), namedParams);
500   }
501
502   inline void DisableVertexAttribArray(GLuint index)
503   {
504     SetVertexAttribArray( index, false );
505   }
506
507   inline void DrawArrays(GLenum mode, GLint first, GLsizei count)
508   {
509     std::stringstream out;
510     out << mode << ", " << first << ", " << count;
511     TraceCallStack::NamedParams namedParams;
512     namedParams["mode"] = ToString(mode);
513     namedParams["first"] = ToString(first);
514     namedParams["count"] = ToString(count);
515     mDrawTrace.PushCall("DrawArrays", out.str(), namedParams);
516   }
517
518   inline void DrawElements(GLenum mode, GLsizei count, GLenum type, const void* indices)
519   {
520     std::stringstream out;
521     out << mode << ", " << count << ", " << type << ", indices";
522
523     TraceCallStack::NamedParams namedParams;
524     namedParams["mode"] = ToString(mode);
525     namedParams["count"] = ToString(count);
526     namedParams["type"] = ToString(type);
527     // Skip void pointers - are they of any use?
528     mDrawTrace.PushCall("DrawElements", out.str(), namedParams);
529   }
530
531   inline void Enable(GLenum cap)
532   {
533     std::stringstream out;
534     out << cap;
535     TraceCallStack::NamedParams namedParams;
536     namedParams["cap"] = ToString(cap);
537     mEnableDisableTrace.PushCall("Enable", out.str(), namedParams);
538   }
539
540   inline void EnableVertexAttribArray(GLuint index)
541   {
542     SetVertexAttribArray( index, true);
543   }
544
545   inline void Finish(void)
546   {
547   }
548
549   inline void Flush(void)
550   {
551   }
552
553   inline void FramebufferRenderbuffer(GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer)
554   {
555     if (attachment == GL_DEPTH_ATTACHMENT)
556     {
557       mFramebufferDepthAttached = true;
558     }
559     else if (attachment == GL_STENCIL_ATTACHMENT)
560     {
561       mFramebufferStencilAttached = true;
562     }
563   }
564
565   inline void FramebufferTexture2D(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level)
566   {
567     //Add 100 bit;
568     mFramebufferStatus |= 4;
569
570     //We check 4 attachment colors
571     if ((attachment == GL_COLOR_ATTACHMENT0) || (attachment == GL_COLOR_ATTACHMENT1) || (attachment == GL_COLOR_ATTACHMENT2)  || (attachment == GL_COLOR_ATTACHMENT4))
572     {
573       mFramebufferColorAttached = true;
574     }
575   }
576
577   inline void FrontFace(GLenum mode)
578   {
579   }
580
581   inline void GenBuffers(GLsizei n, GLuint* buffers)
582   {
583     // avoids an assert in GpuBuffers
584     *buffers = 1u;
585   }
586
587   inline void GenerateMipmap(GLenum target)
588   {
589     std::stringstream out;
590     out<<target;
591     TraceCallStack::NamedParams namedParams;
592     namedParams["target"] = ToString(target);
593
594     mTextureTrace.PushCall("GenerateMipmap", out.str(), namedParams);
595   }
596
597   inline void GenFramebuffers(GLsizei n, GLuint* framebuffers)
598   {
599     for( int i = 0; i < n; i++ )
600     {
601       framebuffers[i] = i + 1;
602     }
603
604     //Add 001 bit, this function needs to be called the first one in the chain
605     mFramebufferStatus = 1;
606   }
607
608   inline void GenRenderbuffers(GLsizei n, GLuint* renderbuffers)
609   {
610     for( int i = 0; i < n; i++ )
611     {
612       renderbuffers[i] = i + 1;
613     }
614   }
615
616   /**
617    * This method can be used by test cases, to manipulate the texture IDs generated by GenTextures.
618    * @param[in] ids A vector containing the next IDs to be generated
619    */
620   inline void SetNextTextureIds( const std::vector<GLuint>& ids )
621   {
622     mNextTextureIds = ids;
623   }
624
625   inline const std::vector<GLuint>& GetNextTextureIds()
626   {
627     return mNextTextureIds;
628   }
629
630   inline void GenTextures(GLsizei count, GLuint* textures)
631   {
632     for( int i=0; i<count; ++i )
633     {
634       if( !mNextTextureIds.empty() )
635       {
636         *(textures+i) = mNextTextureIds[0];
637         mNextTextureIds.erase( mNextTextureIds.begin() );
638       }
639       else
640       {
641         *(textures+i) = ++mLastAutoTextureIdUsed;
642       }
643     }
644
645     TraceCallStack::NamedParams namedParams;
646     namedParams["count"] = ToString(count);
647
648     std::stringstream out;
649     for(int i=0; i<count; i++)
650     {
651       out << textures[i];
652       if(i<count-1)
653       {
654         out << ", ";
655       }
656       std::ostringstream oss;
657       oss<<"indices["<<i<<"]";
658       namedParams[oss.str()] = ToString(textures[i]);
659     }
660
661     mTextureTrace.PushCall("GenTextures", out.str(), namedParams);
662   }
663
664   inline void GetActiveAttrib(GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, char* name)
665   {
666   }
667
668   inline void GetActiveUniform(GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, char* name)
669   {
670     switch(index)
671     {
672       case 0:
673         *length = snprintf(name, bufsize, "sTexture");
674         *type = GL_SAMPLER_2D;
675         *size = 1;
676         break;
677       case 1:
678         *length = snprintf(name, bufsize, "sEffect");
679         *type = GL_SAMPLER_2D;
680         *size = 1;
681         break;
682       case 2:
683         *length = snprintf(name, bufsize, "sGloss");
684         *type = GL_SAMPLER_2D;
685         *size = 1;
686         break;
687       default:
688         break;
689     }
690   }
691
692   inline void GetAttachedShaders(GLuint program, GLsizei maxcount, GLsizei* count, GLuint* shaders)
693   {
694   }
695
696   inline int  GetAttribLocation(GLuint program, const char* name)
697   {
698     std::string attribName(name);
699
700     for( unsigned int i = 0; i < ATTRIB_TYPE_LAST; ++i )
701     {
702       if( mStdAttribs[i] == attribName )
703       {
704         return i;
705       }
706     }
707
708     // 0 is a valid location
709     return 0;
710   }
711
712   inline void GetBooleanv(GLenum pname, GLboolean* params)
713   {
714   }
715
716   inline void GetBufferParameteriv(GLenum target, GLenum pname, GLint* params)
717   {
718   }
719
720   inline GLenum GetError(void)
721   {
722     return mGetErrorResult;
723   }
724
725   inline void GetFloatv(GLenum pname, GLfloat* params)
726   {
727   }
728
729   inline void GetFramebufferAttachmentParameteriv(GLenum target, GLenum attachment, GLenum pname, GLint* params)
730   {
731   }
732
733   inline void GetIntegerv(GLenum pname, GLint* params)
734   {
735     switch( pname )
736     {
737       case GL_MAX_TEXTURE_SIZE:
738         *params = 2048;
739         break;
740       case GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS:
741         *params = 8;
742         break;
743       case GL_NUM_PROGRAM_BINARY_FORMATS_OES:
744         *params = mNumBinaryFormats;
745         break;
746       case GL_PROGRAM_BINARY_FORMATS_OES:
747         *params = mBinaryFormats;
748         break;
749     }
750   }
751
752   inline void GetProgramiv(GLuint program, GLenum pname, GLint* params)
753   {
754     switch( pname )
755     {
756       case GL_LINK_STATUS:
757         *params = mLinkStatus;
758         break;
759       case GL_PROGRAM_BINARY_LENGTH_OES:
760         *params = mProgramBinaryLength;
761         break;
762       case GL_ACTIVE_UNIFORMS:
763         *params = mNumberOfActiveUniforms;
764         break;
765       case GL_ACTIVE_UNIFORM_MAX_LENGTH:
766         *params = 100;
767         break;
768     }
769   }
770
771   inline void GetProgramInfoLog(GLuint program, GLsizei bufsize, GLsizei* length, char* infolog)
772   {
773   }
774
775   inline void GetRenderbufferParameteriv(GLenum target, GLenum pname, GLint* params)
776   {
777   }
778
779   inline void GetShaderiv(GLuint shader, GLenum pname, GLint* params)
780   {
781     switch( pname ) {
782       case GL_COMPILE_STATUS:
783         *params = mCompileStatus;
784         break;
785     }
786   }
787
788   inline void GetShaderInfoLog(GLuint shader, GLsizei bufsize, GLsizei* length, char* infolog)
789   {
790   }
791
792   inline void GetShaderPrecisionFormat(GLenum shadertype, GLenum precisiontype, GLint* range, GLint* precision)
793   {
794   }
795
796   inline const GLubyte* GetString(GLenum name)
797   {
798     return mGetStringResult;
799   }
800
801   inline void GetTexParameterfv(GLenum target, GLenum pname, GLfloat* params)
802   {
803   }
804
805   inline void GetTexParameteriv(GLenum target, GLenum pname, GLint* params)
806   {
807   }
808
809   inline void GetUniformfv(GLuint program, GLint location, GLfloat* params)
810   {
811   }
812
813   inline void GetUniformiv(GLuint program, GLint location, GLint* params)
814   {
815   }
816
817   inline GLint GetUniformLocation(GLuint program, const char* name)
818   {
819     ProgramUniformMap::iterator it = mUniforms.find(program);
820     if( it == mUniforms.end() )
821     {
822       // Not a valid program ID
823       mGetErrorResult = GL_INVALID_OPERATION;
824       return -1;
825     }
826
827     UniformIDMap& uniformIDs = it->second;
828     UniformIDMap::iterator it2 = uniformIDs.find( name );
829     if( it2 == uniformIDs.end() )
830     {
831       // Uniform not found, so add it...
832       uniformIDs[name] = ++mLastUniformIdUsed;
833       return mLastUniformIdUsed;
834     }
835
836     return it2->second;
837   }
838
839   inline void GetVertexAttribfv(GLuint index, GLenum pname, GLfloat* params)
840   {
841   }
842
843   inline void GetVertexAttribiv(GLuint index, GLenum pname, GLint* params)
844   {
845   }
846
847   inline void GetVertexAttribPointerv(GLuint index, GLenum pname, void** pointer)
848   {
849   }
850
851   inline void Hint(GLenum target, GLenum mode)
852   {
853   }
854
855   inline GLboolean IsBuffer(GLuint buffer)
856   {
857     return mIsBufferResult;
858   }
859
860   inline GLboolean IsEnabled(GLenum cap)
861   {
862     return mIsEnabledResult;
863   }
864
865   inline GLboolean IsFramebuffer(GLuint framebuffer)
866   {
867     return mIsFramebufferResult;
868   }
869
870   inline GLboolean IsProgram(GLuint program)
871   {
872     return mIsProgramResult;
873   }
874
875   inline GLboolean IsRenderbuffer(GLuint renderbuffer)
876   {
877     return mIsRenderbufferResult;
878   }
879
880   inline GLboolean IsShader(GLuint shader)
881   {
882     return mIsShaderResult;
883   }
884
885   inline GLboolean IsTexture(GLuint texture)
886   {
887     return mIsTextureResult;
888   }
889
890   inline void LineWidth(GLfloat width)
891   {
892   }
893
894   inline void LinkProgram(GLuint program)
895   {
896     std::stringstream out;
897     out << program;
898
899     TraceCallStack::NamedParams namedParams;
900     namedParams["program"] = ToString(program);
901     mShaderTrace.PushCall("LinkProgram", out.str(), namedParams);
902
903     mNumberOfActiveUniforms=3;
904     GetUniformLocation(program, "sTexture");
905     GetUniformLocation(program, "sEffect");
906     GetUniformLocation(program, "sGloss");
907   }
908
909   inline void PixelStorei(GLenum pname, GLint param)
910   {
911   }
912
913   inline void PolygonOffset(GLfloat factor, GLfloat units)
914   {
915   }
916
917   inline void ReadPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, void* pixels)
918   {
919   }
920
921   inline void ReleaseShaderCompiler(void)
922   {
923   }
924
925   inline void RenderbufferStorage(GLenum target, GLenum internalformat, GLsizei width, GLsizei height)
926   {
927   }
928
929   inline void SampleCoverage(GLclampf value, GLboolean invert)
930   {
931   }
932
933   inline void Scissor(GLint x, GLint y, GLsizei width, GLsizei height)
934   {
935     mScissorParams.x = x;
936     mScissorParams.y = y;
937     mScissorParams.width = width;
938     mScissorParams.height = height;
939   }
940
941   inline void ShaderBinary(GLsizei n, const GLuint* shaders, GLenum binaryformat, const void* binary, GLsizei length)
942   {
943   }
944
945   inline void ShaderSource(GLuint shader, GLsizei count, const char** string, const GLint* length)
946   {
947     std::string stringBuilder;
948     for(int i = 0; i < count; ++i)
949     {
950       stringBuilder += string[i];
951     }
952     mShaderSources[shader] = stringBuilder;
953     mLastShaderCompiled = shader;
954   }
955
956   inline void GetShaderSource(GLuint shader, GLsizei bufsize, GLsizei* length, char* source)
957   {
958     const std::string shaderSource = mShaderSources[shader];
959     const int shaderSourceLength = static_cast<int>(shaderSource.length());
960     if( shaderSourceLength < bufsize )
961     {
962       strncpy( source, shaderSource.c_str(), shaderSourceLength );
963       *length = shaderSourceLength;
964     }
965     else
966     {
967       *length = bufsize -1;
968       strncpy(source, shaderSource.c_str(), *length);
969       source[*length] = 0x0;
970     }
971   }
972
973   inline std::string GetShaderSource(GLuint shader)
974   {
975     return mShaderSources[shader];
976   }
977
978   inline void StencilFunc(GLenum func, GLint ref, GLuint mask)
979   {
980     std::stringstream out;
981     out << func << ", " << ref << ", " << mask;
982
983     TraceCallStack::NamedParams namedParams;
984     namedParams["func"] = ToString( func );
985     namedParams["ref"] = ToString( ref );
986     namedParams["mask"] = ToString( mask );
987
988     mStencilFunctionTrace.PushCall( "StencilFunc", out.str(), namedParams );
989   }
990
991   inline void StencilFuncSeparate(GLenum face, GLenum func, GLint ref, GLuint mask)
992   {
993     std::stringstream out;
994     out << face << ", " << func << ", " << ref << ", " << mask;
995
996     TraceCallStack::NamedParams namedParams;
997     namedParams["face"] = ToString( face );
998     namedParams["func"] = ToString( func );
999     namedParams["ref"] = ToString( ref );
1000     namedParams["mask"] = ToString( mask );
1001
1002     mStencilFunctionTrace.PushCall( "StencilFuncSeparate", out.str(), namedParams );
1003   }
1004
1005   inline void StencilMask(GLuint mask)
1006   {
1007     std::stringstream out;
1008     out << mask;
1009
1010     TraceCallStack::NamedParams namedParams;
1011     namedParams["mask"] = ToString( mask );
1012
1013     mStencilFunctionTrace.PushCall( "StencilMask", out.str(), namedParams );
1014   }
1015
1016   inline void StencilMaskSeparate(GLenum face, GLuint mask)
1017   {
1018     std::stringstream out;
1019     out << face << ", " << mask;
1020
1021     TraceCallStack::NamedParams namedParams;
1022     namedParams["face"] = ToString( face );
1023     namedParams["mask"] = ToString( mask );
1024
1025     mStencilFunctionTrace.PushCall( "StencilMaskSeparate", out.str(), namedParams );
1026   }
1027
1028   inline void StencilOp(GLenum fail, GLenum zfail, GLenum zpass)
1029   {
1030     std::stringstream out;
1031     out << fail << ", " << zfail << ", " << zpass;
1032
1033     TraceCallStack::NamedParams namedParams;
1034     namedParams["fail"] = ToString( fail );
1035     namedParams["zfail"] = ToString( zfail );
1036     namedParams["zpass"] = ToString( zpass );
1037
1038     mStencilFunctionTrace.PushCall( "StencilOp", out.str(), namedParams );
1039   }
1040
1041   inline void StencilOpSeparate(GLenum face, GLenum fail, GLenum zfail, GLenum zpass)
1042   {
1043     std::stringstream out;
1044     out << face << ", " << fail << ", " << zfail << "," << zpass;
1045
1046     TraceCallStack::NamedParams namedParams;
1047     namedParams["face"] = ToString( face );
1048     namedParams["fail"] = ToString( fail );
1049     namedParams["zfail"] = ToString( zfail );
1050     namedParams["zpass"] = ToString( zpass );
1051
1052     mStencilFunctionTrace.PushCall( "StencilOpSeparate", out.str(), namedParams );
1053   }
1054
1055   inline void TexImage2D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void* pixels)
1056   {
1057     std::stringstream out;
1058     out << target<<", "<<level<<", "<<width << ", " << height;
1059
1060     TraceCallStack::NamedParams namedParams;
1061     namedParams["target"] = ToString(target);
1062     namedParams["level"] = ToString(level);
1063     namedParams["internalformat"] = ToString(internalformat);
1064     namedParams["width"] = ToString(width);
1065     namedParams["height"] = ToString(height);
1066     namedParams["border"] = ToString(border);
1067     namedParams["format"] = ToString(format);
1068     namedParams["type"] = ToString(type);
1069
1070     mTextureTrace.PushCall("TexImage2D", out.str(), namedParams);
1071   }
1072
1073   inline void TexParameterf(GLenum target, GLenum pname, GLfloat param)
1074   {
1075     std::stringstream out;
1076     out << target << ", " << pname << ", " << param;
1077
1078     TraceCallStack::NamedParams namedParams;
1079     namedParams["target"] = ToString(target);
1080     namedParams["pname"] = ToString(pname);
1081     namedParams["param"] = ToString(param);
1082
1083     mTexParamaterTrace.PushCall("TexParameterf", out.str(), namedParams);
1084   }
1085
1086   inline void TexParameterfv(GLenum target, GLenum pname, const GLfloat* params)
1087   {
1088     std::stringstream out;
1089     out << target << ", " << pname << ", " << params[0];
1090
1091     TraceCallStack::NamedParams namedParams;
1092     namedParams["target"] = ToString(target);
1093     namedParams["pname"] = ToString(pname);
1094     namedParams["params[0]"] = ToString(params[0]);
1095
1096     mTexParamaterTrace.PushCall("TexParameterfv", out.str(), namedParams);
1097   }
1098
1099   inline void TexParameteri(GLenum target, GLenum pname, GLint param)
1100   {
1101     std::stringstream out;
1102     out << target << ", " << pname << ", " << param;
1103     TraceCallStack::NamedParams namedParams;
1104     namedParams["target"] = ToString(target);
1105     namedParams["pname"] = ToString(pname);
1106     namedParams["param"] = ToString(param);
1107     mTexParamaterTrace.PushCall("TexParameteri", out.str(), namedParams);
1108   }
1109
1110   inline void TexParameteriv(GLenum target, GLenum pname, const GLint* params)
1111   {
1112     std::stringstream out;
1113     out << target << ", " << pname << ", " << params[0];
1114     TraceCallStack::NamedParams namedParams;
1115     namedParams["target"] = ToString(target);
1116     namedParams["pname"] = ToString(pname);
1117     namedParams["params[0]"] = ToString(params[0]);
1118     mTexParamaterTrace.PushCall("TexParameteriv", out.str(), namedParams);
1119   }
1120
1121   inline void TexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void* pixels)
1122   {
1123     std::stringstream out;
1124     out << target << ", "<<level <<", " << xoffset << ", " << yoffset << ", " << width << ", " << height;
1125
1126     TraceCallStack::NamedParams namedParams;
1127     namedParams["target"] = ToString(target);
1128     namedParams["level"] = ToString(level);
1129     namedParams["xoffset"] = ToString(xoffset);
1130     namedParams["yoffset"] = ToString(yoffset);
1131     namedParams["width"] = ToString(width);
1132     namedParams["height"] = ToString(height);
1133     mTextureTrace.PushCall("TexSubImage2D", out.str(), namedParams);
1134   }
1135
1136   inline void Uniform1f(GLint location, GLfloat x)
1137   {
1138     if( ! mProgramUniforms1f.SetUniformValue( mCurrentProgram, location, x ) )
1139     {
1140       mGetErrorResult = GL_INVALID_OPERATION;
1141     }
1142   }
1143
1144   inline void Uniform1fv(GLint location, GLsizei count, const GLfloat* v)
1145   {
1146     for( int i = 0; i < count; ++i )
1147     {
1148       if( ! mProgramUniforms1f.SetUniformValue( mCurrentProgram, location, v[i] ) )
1149       {
1150         mGetErrorResult = GL_INVALID_OPERATION;
1151         break;
1152       }
1153     }
1154   }
1155
1156   inline void Uniform1i(GLint location, GLint x)
1157   {
1158     if( ! mProgramUniforms1i.SetUniformValue( mCurrentProgram, location, x ) )
1159     {
1160       mGetErrorResult = GL_INVALID_OPERATION;
1161     }
1162   }
1163
1164   inline void Uniform1iv(GLint location, GLsizei count, const GLint* v)
1165   {
1166     for( int i = 0; i < count; ++i )
1167     {
1168       if( ! mProgramUniforms1i.SetUniformValue( mCurrentProgram,
1169                                                  location,
1170                                                  v[i] ) )
1171       {
1172         mGetErrorResult = GL_INVALID_OPERATION;
1173         break;
1174       }
1175     }
1176   }
1177
1178   inline void Uniform2f(GLint location, GLfloat x, GLfloat y)
1179   {
1180     if( ! mProgramUniforms2f.SetUniformValue( mCurrentProgram,
1181                                                location,
1182                                                Vector2( x, y ) ) )
1183     {
1184       mGetErrorResult = GL_INVALID_OPERATION;
1185     }
1186   }
1187
1188   inline void Uniform2fv(GLint location, GLsizei count, const GLfloat* v)
1189   {
1190     for( int i = 0; i < count; ++i )
1191     {
1192       if( ! mProgramUniforms2f.SetUniformValue( mCurrentProgram,
1193                                                  location,
1194                                                  Vector2( v[2*i], v[2*i+1] ) ) )
1195       {
1196         mGetErrorResult = GL_INVALID_OPERATION;
1197         break;
1198       }
1199     }
1200   }
1201
1202   inline void Uniform2i(GLint location, GLint x, GLint y)
1203   {
1204   }
1205
1206   inline void Uniform2iv(GLint location, GLsizei count, const GLint* v)
1207   {
1208   }
1209
1210   inline void Uniform3f(GLint location, GLfloat x, GLfloat y, GLfloat z)
1211   {
1212     if( ! mProgramUniforms3f.SetUniformValue( mCurrentProgram,
1213                                                location,
1214                                                Vector3( x, y, z ) ) )
1215     {
1216       mGetErrorResult = GL_INVALID_OPERATION;
1217     }
1218   }
1219
1220   inline void Uniform3fv(GLint location, GLsizei count, const GLfloat* v)
1221   {
1222     for( int i = 0; i < count; ++i )
1223     {
1224       if( ! mProgramUniforms3f.SetUniformValue(
1225           mCurrentProgram,
1226           location,
1227           Vector3( v[3*i], v[3*i+1], v[3*i+2] ) ) )
1228       {
1229         mGetErrorResult = GL_INVALID_OPERATION;
1230         break;
1231       }
1232     }
1233   }
1234
1235   inline void Uniform3i(GLint location, GLint x, GLint y, GLint z)
1236   {
1237   }
1238
1239   inline void Uniform3iv(GLint location, GLsizei count, const GLint* v)
1240   {
1241   }
1242
1243   inline void Uniform4f(GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w)
1244   {
1245     if( ! mProgramUniforms4f.SetUniformValue( mCurrentProgram,
1246                                               location,
1247                                               Vector4( x, y, z, w ) ) )
1248     {
1249       mGetErrorResult = GL_INVALID_OPERATION;
1250     }
1251   }
1252
1253   inline void Uniform4fv(GLint location, GLsizei count, const GLfloat* v)
1254   {
1255     for( int i = 0; i < count; ++i )
1256     {
1257       if( ! mProgramUniforms4f.SetUniformValue(
1258           mCurrentProgram,
1259           location,
1260           Vector4( v[4*i], v[4*i+1], v[4*i+2], v[4*i+3] ) ) )
1261       {
1262         mGetErrorResult = GL_INVALID_OPERATION;
1263         break;
1264       }
1265     }
1266   }
1267
1268   inline void Uniform4i(GLint location, GLint x, GLint y, GLint z, GLint w)
1269   {
1270   }
1271
1272   inline void Uniform4iv(GLint location, GLsizei count, const GLint* v)
1273   {
1274   }
1275
1276   inline void UniformMatrix2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
1277   {
1278   }
1279
1280   inline void UniformMatrix3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
1281   {
1282     for( int i = 0; i < count; ++i )
1283     {
1284       if( ! mProgramUniformsMat3.SetUniformValue(
1285             mCurrentProgram,
1286             location,
1287             Matrix3( value[0], value[1], value[2], value[3], value[4], value[5], value[6], value[7], value[8] ) ) )
1288       {
1289         mGetErrorResult = GL_INVALID_OPERATION;
1290         break;
1291       }
1292     }
1293   }
1294
1295   inline void UniformMatrix4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
1296   {
1297     for( int i = 0; i < count; ++i )
1298     {
1299       if( ! mProgramUniformsMat4.SetUniformValue(
1300           mCurrentProgram,
1301           location,
1302           Matrix( value ) ) )
1303       {
1304         mGetErrorResult = GL_INVALID_OPERATION;
1305         break;
1306       }
1307     }
1308   }
1309
1310   inline void UseProgram(GLuint program)
1311   {
1312     mCurrentProgram = program;
1313   }
1314
1315   inline void ValidateProgram(GLuint program)
1316   {
1317   }
1318
1319   inline void VertexAttrib1f(GLuint indx, GLfloat x)
1320   {
1321   }
1322
1323   inline void VertexAttrib1fv(GLuint indx, const GLfloat* values)
1324   {
1325   }
1326
1327   inline void VertexAttrib2f(GLuint indx, GLfloat x, GLfloat y)
1328   {
1329   }
1330
1331   inline void VertexAttrib2fv(GLuint indx, const GLfloat* values)
1332   {
1333   }
1334
1335   inline void VertexAttrib3f(GLuint indx, GLfloat x, GLfloat y, GLfloat z)
1336   {
1337   }
1338
1339   inline void VertexAttrib3fv(GLuint indx, const GLfloat* values)
1340   {
1341   }
1342
1343   inline void VertexAttrib4f(GLuint indx, GLfloat x, GLfloat y, GLfloat z, GLfloat w)
1344   {
1345   }
1346
1347   inline void VertexAttrib4fv(GLuint indx, const GLfloat* values)
1348   {
1349   }
1350
1351   inline void VertexAttribPointer(GLuint indx, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void* ptr)
1352   {
1353   }
1354
1355   inline void Viewport(GLint x, GLint y, GLsizei width, GLsizei height)
1356   {
1357   }
1358
1359   /* OpenGL ES 3.0 */
1360
1361   inline void ReadBuffer(GLenum mode)
1362   {
1363   }
1364
1365   inline void DrawRangeElements(GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid* indices)
1366   {
1367   }
1368
1369   inline void TexImage3D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid* pixels)
1370   {
1371   }
1372
1373   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)
1374   {
1375   }
1376
1377   inline void CopyTexSubImage3D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height)
1378   {
1379   }
1380
1381   inline void CompressedTexImage3D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid* data)
1382   {
1383   }
1384
1385   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)
1386   {
1387   }
1388
1389   inline void GenQueries(GLsizei n, GLuint* ids)
1390   {
1391   }
1392
1393   inline void DeleteQueries(GLsizei n, const GLuint* ids)
1394   {
1395   }
1396
1397   inline GLboolean IsQuery(GLuint id)
1398   {
1399     return false;
1400   }
1401
1402   inline void BeginQuery(GLenum target, GLuint id)
1403   {
1404   }
1405
1406   inline void EndQuery(GLenum target)
1407   {
1408   }
1409
1410   inline void GetQueryiv(GLenum target, GLenum pname, GLint* params)
1411   {
1412   }
1413
1414   inline void GetQueryObjectuiv(GLuint id, GLenum pname, GLuint* params)
1415   {
1416   }
1417
1418   inline GLboolean UnmapBuffer(GLenum target)
1419   {
1420     return false;
1421   }
1422
1423   inline void GetBufferPointerv(GLenum target, GLenum pname, GLvoid** params)
1424   {
1425   }
1426
1427   inline void DrawBuffers(GLsizei n, const GLenum* bufs)
1428   {
1429   }
1430
1431   inline void UniformMatrix2x3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
1432   {
1433   }
1434
1435   inline void UniformMatrix3x2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
1436   {
1437   }
1438
1439   inline void UniformMatrix2x4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
1440   {
1441   }
1442
1443   inline void UniformMatrix4x2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
1444   {
1445   }
1446
1447   inline void UniformMatrix3x4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
1448   {
1449   }
1450
1451   inline void UniformMatrix4x3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
1452   {
1453   }
1454
1455   inline void BlitFramebuffer(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter)
1456   {
1457   }
1458
1459   inline void RenderbufferStorageMultisample(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height)
1460   {
1461   }
1462
1463   inline void FramebufferTextureLayer(GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer)
1464   {
1465   }
1466
1467   inline GLvoid* MapBufferRange(GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access)
1468   {
1469     return NULL;
1470   }
1471
1472   inline void FlushMappedBufferRange(GLenum target, GLintptr offset, GLsizeiptr length)
1473   {
1474   }
1475
1476   inline void BindVertexArray(GLuint array)
1477   {
1478   }
1479
1480   inline void DeleteVertexArrays(GLsizei n, const GLuint* arrays)
1481   {
1482   }
1483
1484   inline void GenVertexArrays(GLsizei n, GLuint* arrays)
1485   {
1486   }
1487
1488   inline GLboolean IsVertexArray(GLuint array)
1489   {
1490     return false;
1491   }
1492
1493   inline void GetIntegeri_v(GLenum target, GLuint index, GLint* data)
1494   {
1495   }
1496
1497   inline void BeginTransformFeedback(GLenum primitiveMode)
1498   {
1499   }
1500
1501   inline void EndTransformFeedback(void)
1502   {
1503   }
1504
1505   inline void BindBufferRange(GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size)
1506   {
1507   }
1508
1509   inline void BindBufferBase(GLenum target, GLuint index, GLuint buffer)
1510   {
1511   }
1512
1513   inline void TransformFeedbackVaryings(GLuint program, GLsizei count, const GLchar* const* varyings, GLenum bufferMode)
1514   {
1515   }
1516
1517   inline void GetTransformFeedbackVarying(GLuint program, GLuint index, GLsizei bufSize, GLsizei* length, GLsizei* size, GLenum* type, GLchar* name)
1518   {
1519   }
1520
1521   inline void VertexAttribIPointer(GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid* pointer)
1522   {
1523   }
1524
1525   inline void GetVertexAttribIiv(GLuint index, GLenum pname, GLint* params)
1526   {
1527   }
1528
1529   inline void GetVertexAttribIuiv(GLuint index, GLenum pname, GLuint* params)
1530   {
1531   }
1532
1533   inline void VertexAttribI4i(GLuint index, GLint x, GLint y, GLint z, GLint w)
1534   {
1535   }
1536
1537   inline void VertexAttribI4ui(GLuint index, GLuint x, GLuint y, GLuint z, GLuint w)
1538   {
1539   }
1540
1541   inline void VertexAttribI4iv(GLuint index, const GLint* v)
1542   {
1543   }
1544
1545   inline void VertexAttribI4uiv(GLuint index, const GLuint* v)
1546   {
1547   }
1548
1549   inline void GetUniformuiv(GLuint program, GLint location, GLuint* params)
1550   {
1551   }
1552
1553   inline GLint GetFragDataLocation(GLuint program, const GLchar *name)
1554   {
1555     return -1;
1556   }
1557
1558   inline void Uniform1ui(GLint location, GLuint v0)
1559   {
1560   }
1561
1562   inline void Uniform2ui(GLint location, GLuint v0, GLuint v1)
1563   {
1564   }
1565
1566   inline void Uniform3ui(GLint location, GLuint v0, GLuint v1, GLuint v2)
1567   {
1568   }
1569
1570   inline void Uniform4ui(GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3)
1571   {
1572   }
1573
1574   inline void Uniform1uiv(GLint location, GLsizei count, const GLuint* value)
1575   {
1576   }
1577
1578   inline void Uniform2uiv(GLint location, GLsizei count, const GLuint* value)
1579   {
1580   }
1581
1582   inline void Uniform3uiv(GLint location, GLsizei count, const GLuint* value)
1583   {
1584   }
1585
1586   inline void Uniform4uiv(GLint location, GLsizei count, const GLuint* value)
1587   {
1588   }
1589
1590   inline void ClearBufferiv(GLenum buffer, GLint drawbuffer, const GLint* value)
1591   {
1592   }
1593
1594   inline void ClearBufferuiv(GLenum buffer, GLint drawbuffer, const GLuint* value)
1595   {
1596   }
1597
1598   inline void ClearBufferfv(GLenum buffer, GLint drawbuffer, const GLfloat* value)
1599   {
1600   }
1601
1602   inline void ClearBufferfi(GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil)
1603   {
1604   }
1605
1606   inline const GLubyte* GetStringi(GLenum name, GLuint index)
1607   {
1608     return NULL;
1609   }
1610
1611   inline void CopyBufferSubData(GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size)
1612   {
1613   }
1614
1615   inline void GetUniformIndices(GLuint program, GLsizei uniformCount, const GLchar* const* uniformNames, GLuint* uniformIndices)
1616   {
1617   }
1618
1619   inline void GetActiveUniformsiv(GLuint program, GLsizei uniformCount, const GLuint* uniformIndices, GLenum pname, GLint* params)
1620   {
1621   }
1622
1623   inline GLuint GetUniformBlockIndex(GLuint program, const GLchar* uniformBlockName)
1624   {
1625     return GL_INVALID_INDEX;
1626   }
1627
1628   inline void GetActiveUniformBlockiv(GLuint program, GLuint uniformBlockIndex, GLenum pname, GLint* params)
1629   {
1630   }
1631
1632   inline void GetActiveUniformBlockName(GLuint program, GLuint uniformBlockIndex, GLsizei bufSize, GLsizei* length, GLchar* uniformBlockName)
1633   {
1634   }
1635
1636   inline void UniformBlockBinding(GLuint program, GLuint uniformBlockIndex, GLuint uniformBlockBinding)
1637   {
1638   }
1639
1640   inline void DrawArraysInstanced(GLenum mode, GLint first, GLsizei count, GLsizei instanceCount)
1641   {
1642   }
1643
1644   inline void DrawElementsInstanced(GLenum mode, GLsizei count, GLenum type, const GLvoid* indices, GLsizei instanceCount)
1645   {
1646   }
1647
1648   inline GLsync FenceSync(GLenum condition, GLbitfield flags)
1649   {
1650     return NULL;
1651   }
1652
1653   inline GLboolean IsSync(GLsync sync)
1654   {
1655     return false;
1656   }
1657
1658   inline void DeleteSync(GLsync sync)
1659   {
1660   }
1661
1662   inline GLenum ClientWaitSync(GLsync sync, GLbitfield flags, GLuint64 timeout)
1663   {
1664     return 0;
1665   }
1666
1667   inline void WaitSync(GLsync sync, GLbitfield flags, GLuint64 timeout)
1668   {
1669   }
1670
1671   inline void GetInteger64v(GLenum pname, GLint64* params)
1672   {
1673   }
1674
1675   inline void GetSynciv(GLsync sync, GLenum pname, GLsizei bufSize, GLsizei* length, GLint* values)
1676   {
1677   }
1678
1679   inline void GetInteger64i_v(GLenum target, GLuint index, GLint64* data)
1680   {
1681   }
1682
1683   inline void GetBufferParameteri64v(GLenum target, GLenum pname, GLint64* params)
1684   {
1685   }
1686
1687   inline void GenSamplers(GLsizei count, GLuint* samplers)
1688   {
1689   }
1690
1691   inline void DeleteSamplers(GLsizei count, const GLuint* samplers)
1692   {
1693   }
1694
1695   inline GLboolean IsSampler(GLuint sampler)
1696   {
1697     return false;
1698   }
1699
1700   inline void BindSampler(GLuint unit, GLuint sampler)
1701   {
1702   }
1703
1704   inline void SamplerParameteri(GLuint sampler, GLenum pname, GLint param)
1705   {
1706   }
1707
1708   inline void SamplerParameteriv(GLuint sampler, GLenum pname, const GLint* param)
1709   {
1710   }
1711
1712   inline void SamplerParameterf(GLuint sampler, GLenum pname, GLfloat param)
1713   {
1714   }
1715
1716   inline void SamplerParameterfv(GLuint sampler, GLenum pname, const GLfloat* param)
1717   {
1718   }
1719
1720   inline void GetSamplerParameteriv(GLuint sampler, GLenum pname, GLint* params)
1721   {
1722   }
1723
1724   inline void GetSamplerParameterfv(GLuint sampler, GLenum pname, GLfloat* params)
1725   {
1726   }
1727
1728   inline void VertexAttribDivisor(GLuint index, GLuint divisor)
1729   {
1730   }
1731
1732   inline void BindTransformFeedback(GLenum target, GLuint id)
1733   {
1734   }
1735
1736   inline void DeleteTransformFeedbacks(GLsizei n, const GLuint* ids)
1737   {
1738   }
1739
1740   inline void GenTransformFeedbacks(GLsizei n, GLuint* ids)
1741   {
1742   }
1743
1744   inline GLboolean IsTransformFeedback(GLuint id)
1745   {
1746     return false;
1747   }
1748
1749   inline void PauseTransformFeedback(void)
1750   {
1751   }
1752
1753   inline void ResumeTransformFeedback(void)
1754   {
1755   }
1756
1757   inline void GetProgramBinary(GLuint program, GLsizei bufSize, GLsizei* length, GLenum* binaryFormat, GLvoid* binary)
1758   {
1759     mGetProgramBinaryCalled = true;
1760   }
1761
1762   inline void ProgramBinary(GLuint program, GLenum binaryFormat, const GLvoid* binary, GLsizei length)
1763   {
1764   }
1765
1766   inline void ProgramParameteri(GLuint program, GLenum pname, GLint value)
1767   {
1768   }
1769
1770   inline void InvalidateFramebuffer(GLenum target, GLsizei numAttachments, const GLenum* attachments)
1771   {
1772   }
1773
1774   inline void InvalidateSubFramebuffer(GLenum target, GLsizei numAttachments, const GLenum* attachments, GLint x, GLint y, GLsizei width, GLsizei height)
1775   {
1776   }
1777
1778   inline void TexStorage2D(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height)
1779   {
1780   }
1781
1782   inline void TexStorage3D(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth)
1783   {
1784   }
1785
1786   inline void GetInternalformativ(GLenum target, GLenum internalformat, GLenum pname, GLsizei bufSize, GLint* params)
1787   {
1788   }
1789
1790 public: // TEST FUNCTIONS
1791   inline void SetCompileStatus( GLuint value ) { mCompileStatus = value; }
1792   inline void SetLinkStatus( GLuint value ) { mLinkStatus = value; }
1793   inline void SetGetAttribLocationResult(  int result) { mGetAttribLocationResult = result; }
1794   inline void SetGetErrorResult(  GLenum result) { mGetErrorResult = result; }
1795   inline void SetGetStringResult(  GLubyte* result) { mGetStringResult = result; }
1796   inline void SetIsBufferResult(  GLboolean result) { mIsBufferResult = result; }
1797   inline void SetIsEnabledResult(  GLboolean result) { mIsEnabledResult = result; }
1798   inline void SetIsFramebufferResult(  GLboolean result) { mIsFramebufferResult = result; }
1799   inline void SetIsProgramResult(  GLboolean result) { mIsProgramResult = result; }
1800   inline void SetIsRenderbufferResult(  GLboolean result) { mIsRenderbufferResult = result; }
1801   inline void SetIsShaderResult(  GLboolean result) { mIsShaderResult = result; }
1802   inline void SetIsTextureResult(  GLboolean result) { mIsTextureResult = result; }
1803   inline void SetCheckFramebufferStatusResult(  GLenum result) { mCheckFramebufferStatusResult = result; }
1804   inline void SetNumBinaryFormats( GLint numFormats ) { mNumBinaryFormats = numFormats; }
1805   inline void SetBinaryFormats( GLint binaryFormats ) { mBinaryFormats = binaryFormats; }
1806   inline void SetProgramBinaryLength( GLint length ) { mProgramBinaryLength = length; }
1807
1808   inline bool GetVertexAttribArrayState(GLuint index)
1809   {
1810     if( index >= MAX_ATTRIBUTE_CACHE_SIZE )
1811     {
1812       // out of range
1813       return false;
1814     }
1815     return mVertexAttribArrayState[ index ];
1816   }
1817   inline void ClearVertexAttribArrayChanged() {  mVertexAttribArrayChanged = false; }
1818   inline bool GetVertexAttribArrayChanged()  { return mVertexAttribArrayChanged; }
1819
1820   //Methods for CullFace verification
1821   inline void EnableCullFaceCallTrace(bool enable) { mCullFaceTrace.Enable(enable); }
1822   inline void ResetCullFaceCallStack() { mCullFaceTrace.Reset(); }
1823   inline TraceCallStack& GetCullFaceTrace() { return mCullFaceTrace; }
1824
1825   //Methods for Enable/Disable call verification
1826   inline void EnableEnableDisableCallTrace(bool enable) { mEnableDisableTrace.Enable(enable); }
1827   inline void ResetEnableDisableCallStack() { mEnableDisableTrace.Reset(); }
1828   inline TraceCallStack& GetEnableDisableTrace() { return mEnableDisableTrace; }
1829
1830   //Methods for Shader verification
1831   inline void EnableShaderCallTrace(bool enable) { mShaderTrace.Enable(enable); }
1832   inline void ResetShaderCallStack() { mShaderTrace.Reset(); }
1833   inline TraceCallStack& GetShaderTrace() { return mShaderTrace; }
1834
1835   //Methods for Texture verification
1836   inline void EnableTextureCallTrace(bool enable) { mTextureTrace.Enable(enable); }
1837   inline void ResetTextureCallStack() { mTextureTrace.Reset(); }
1838   inline TraceCallStack& GetTextureTrace() { return mTextureTrace; }
1839
1840   //Methods for Texture verification
1841   inline void EnableTexParameterCallTrace(bool enable) { mTexParamaterTrace.Enable(enable); }
1842   inline void ResetTexParameterCallStack() { mTexParamaterTrace.Reset(); }
1843   inline TraceCallStack& GetTexParameterTrace() { return mTexParamaterTrace; }
1844
1845   //Methods for Draw verification
1846   inline void EnableDrawCallTrace(bool enable) { mDrawTrace.Enable(enable); }
1847   inline void ResetDrawCallStack() { mDrawTrace.Reset(); }
1848   inline TraceCallStack& GetDrawTrace() { return mDrawTrace; }
1849
1850   //Methods for Depth function verification
1851   inline void EnableDepthFunctionCallTrace(bool enable) { mDepthFunctionTrace.Enable(enable); }
1852   inline void ResetDepthFunctionCallStack() { mDepthFunctionTrace.Reset(); }
1853   inline TraceCallStack& GetDepthFunctionTrace() { return mDepthFunctionTrace; }
1854
1855   //Methods for Stencil function verification
1856   inline void EnableStencilFunctionCallTrace(bool enable) { mStencilFunctionTrace.Enable(enable); }
1857   inline void ResetStencilFunctionCallStack() { mStencilFunctionTrace.Reset(); }
1858   inline TraceCallStack& GetStencilFunctionTrace() { return mStencilFunctionTrace; }
1859
1860   template <typename T>
1861   inline bool GetUniformValue( const char* name, T& value ) const
1862   {
1863     for( ProgramUniformMap::const_iterator program_it = mUniforms.begin();
1864           program_it != mUniforms.end();
1865           ++program_it )
1866     {
1867       const UniformIDMap &uniformIDs = program_it->second;
1868
1869       UniformIDMap::const_iterator uniform_it = uniformIDs.find( name );
1870       if( uniform_it != uniformIDs.end() )
1871       {
1872         // found one matching uniform name, lets check the value...
1873         GLuint programId = program_it->first;
1874         GLint uniformId = uniform_it->second;
1875
1876         const ProgramUniformValue<T> &mProgramUniforms = GetProgramUniformsForType( value );
1877         return mProgramUniforms.GetUniformValue( programId, uniformId, value );
1878       }
1879     }
1880     return false;
1881   }
1882
1883
1884   template <typename T>
1885   inline bool CheckUniformValue( const char* name, const T& value ) const
1886   {
1887     for( ProgramUniformMap::const_iterator program_it = mUniforms.begin();
1888           program_it != mUniforms.end();
1889           ++program_it )
1890     {
1891       const UniformIDMap &uniformIDs = program_it->second;
1892
1893       UniformIDMap::const_iterator uniform_it = uniformIDs.find( name );
1894       if( uniform_it != uniformIDs.end() )
1895       {
1896         // found one matching uniform name, lets check the value...
1897         GLuint programId = program_it->first;
1898         GLint uniformId = uniform_it->second;
1899
1900         const ProgramUniformValue<T> &mProgramUniforms = GetProgramUniformsForType( value );
1901         if( mProgramUniforms.CheckUniformValue( programId, uniformId, value ) )
1902         {
1903           // the value matches
1904           return true;
1905         }
1906       }
1907     }
1908
1909     fprintf(stderr, "Not found, printing possible values:\n" );
1910     for( ProgramUniformMap::const_iterator program_it = mUniforms.begin();
1911           program_it != mUniforms.end();
1912           ++program_it )
1913     {
1914       const UniformIDMap &uniformIDs = program_it->second;
1915
1916       UniformIDMap::const_iterator uniform_it = uniformIDs.find( name );
1917       if( uniform_it != uniformIDs.end() )
1918       {
1919         // found one matching uniform name, lets check the value...
1920         GLuint programId = program_it->first;
1921         GLint uniformId = uniform_it->second;
1922
1923         const ProgramUniformValue<T> &mProgramUniforms = GetProgramUniformsForType( value );
1924         T origValue;
1925         if ( mProgramUniforms.GetUniformValue(programId, uniformId, origValue) )
1926         {
1927           std::stringstream out;
1928           out << uniform_it->first << ": " << origValue;
1929           fprintf(stderr, "%s\n", out.str().c_str() );
1930         }
1931       }
1932     }
1933     return false;
1934   }
1935
1936   template <typename T>
1937   inline bool GetUniformValue( GLuint programId, GLuint uniformId, T& outValue) const
1938   {
1939     const ProgramUniformValue<T> &mProgramUniforms = GetProgramUniformsForType( outValue );
1940     return mProgramUniforms.GetUniformValue( programId, uniformId, outValue );
1941   }
1942
1943   inline bool GetUniformIds( const char* name, GLuint& programId, GLuint& uniformId ) const
1944   {
1945     for( ProgramUniformMap::const_iterator program_it = mUniforms.begin();
1946           program_it != mUniforms.end();
1947           ++program_it )
1948     {
1949       const UniformIDMap &uniformIDs = program_it->second;
1950
1951       UniformIDMap::const_iterator uniform_it = uniformIDs.find( name );
1952       if( uniform_it != uniformIDs.end() )
1953       {
1954         programId = program_it->first;
1955         uniformId = uniform_it->second;
1956         return true;
1957       }
1958     }
1959     return false;
1960   }
1961
1962   inline GLuint GetLastShaderCompiled() const
1963   {
1964     return mLastShaderCompiled;
1965   }
1966
1967   inline GLuint GetLastProgramCreated() const
1968   {
1969     return mLastProgramIdUsed;
1970   }
1971
1972   inline GLbitfield GetLastClearMask() const
1973   {
1974     return mLastClearBitMask;
1975   }
1976
1977   enum AttribType
1978   {
1979     ATTRIB_UNKNOWN = -1,
1980     ATTRIB_POSITION,
1981     ATTRIB_NORMAL,
1982     ATTRIB_TEXCOORD,
1983     ATTRIB_COLOR,
1984     ATTRIB_BONE_WEIGHTS,
1985     ATTRIB_BONE_INDICES,
1986     ATTRIB_TYPE_LAST
1987   };
1988
1989   struct ScissorParams
1990   {
1991     GLint x;
1992     GLint y;
1993     GLsizei width;
1994     GLsizei height;
1995
1996     ScissorParams() : x( 0 ), y( 0 ), width( 0 ), height( 0 ) { }
1997   };
1998
1999   // Methods to check scissor tests
2000   inline const ScissorParams& GetScissorParams() const { return mScissorParams; }
2001
2002   struct ColorMaskParams
2003   {
2004     GLboolean red;
2005     GLboolean green;
2006     GLboolean blue;
2007     GLboolean alpha;
2008
2009     ColorMaskParams() : red( true ), green( true ), blue( true ), alpha( true ) { }
2010   };
2011
2012   inline bool GetProgramBinaryCalled() const { return mGetProgramBinaryCalled; }
2013
2014   inline unsigned int GetClearCountCalled() const { return mClearCount; }
2015
2016   inline const ColorMaskParams& GetColorMaskParams() const { return mColorMaskParams; }
2017
2018   typedef std::vector<size_t> BufferDataCalls;
2019   inline const BufferDataCalls& GetBufferDataCalls() const { return mBufferDataCalls; }
2020   inline void ResetBufferDataCalls() { mBufferDataCalls.clear(); }
2021
2022   typedef std::vector<size_t> BufferSubDataCalls;
2023   inline const BufferSubDataCalls& GetBufferSubDataCalls() const { return mBufferSubDataCalls; }
2024   inline void ResetBufferSubDataCalls() { mBufferSubDataCalls.clear(); }
2025
2026 private:
2027   GLuint     mCurrentProgram;
2028   GLuint     mCompileStatus;
2029   BufferDataCalls mBufferDataCalls;
2030   BufferSubDataCalls mBufferSubDataCalls;
2031   GLuint     mLinkStatus;
2032   GLint      mNumberOfActiveUniforms;
2033   GLint      mGetAttribLocationResult;
2034   GLenum     mGetErrorResult;
2035   GLubyte*   mGetStringResult;
2036   GLboolean  mIsBufferResult;
2037   GLboolean  mIsEnabledResult;
2038   GLboolean  mIsFramebufferResult;
2039   GLboolean  mIsProgramResult;
2040   GLboolean  mIsRenderbufferResult;
2041   GLboolean  mIsShaderResult;
2042   GLboolean  mIsTextureResult;
2043   GLenum     mActiveTextureUnit;
2044   GLenum     mCheckFramebufferStatusResult;
2045   GLint      mFramebufferStatus;
2046   GLenum     mFramebufferColorAttached;
2047   GLenum     mFramebufferDepthAttached;
2048   GLenum     mFramebufferStencilAttached;
2049   GLint      mNumBinaryFormats;
2050   GLint      mBinaryFormats;
2051   GLint      mProgramBinaryLength;
2052   bool       mVertexAttribArrayState[MAX_ATTRIBUTE_CACHE_SIZE];
2053   bool       mVertexAttribArrayChanged;                            // whether the vertex attrib array has been changed
2054   bool       mGetProgramBinaryCalled;
2055   typedef std::map< GLuint, std::string> ShaderSourceMap;
2056   ShaderSourceMap mShaderSources;
2057   GLuint     mLastShaderCompiled;
2058   GLbitfield mLastClearBitMask;
2059   unsigned int mClearCount;
2060
2061   Vector4 mLastBlendColor;
2062   GLenum  mLastBlendEquationRgb;
2063   GLenum  mLastBlendEquationAlpha;
2064   GLenum  mLastBlendFuncSrcRgb;
2065   GLenum  mLastBlendFuncDstRgb;
2066   GLenum  mLastBlendFuncSrcAlpha;
2067   GLenum  mLastBlendFuncDstAlpha;
2068
2069   GLboolean mLastDepthMask;
2070
2071   // Data for manipulating the IDs returned by GenTextures
2072   GLuint mLastAutoTextureIdUsed;
2073   std::vector<GLuint> mNextTextureIds;
2074   std::vector<GLuint> mDeletedTextureIds;
2075   std::vector<GLuint> mBoundTextures;
2076
2077   struct ActiveTextureType
2078   {
2079     std::vector<GLuint> mBoundTextures;
2080   };
2081
2082   ActiveTextureType mActiveTextures[ MIN_TEXTURE_UNIT_LIMIT ];
2083
2084   TraceCallStack mCullFaceTrace;
2085   TraceCallStack mEnableDisableTrace;
2086   TraceCallStack mShaderTrace;
2087   TraceCallStack mTextureTrace;
2088   TraceCallStack mTexParamaterTrace;
2089   TraceCallStack mDrawTrace;
2090   TraceCallStack mDepthFunctionTrace;
2091   TraceCallStack mStencilFunctionTrace;
2092
2093   // Shaders & Uniforms
2094   GLuint mLastShaderIdUsed;
2095   GLuint mLastProgramIdUsed;
2096   GLuint mLastUniformIdUsed;
2097   typedef std::map< std::string, GLint > UniformIDMap;
2098   typedef std::map< GLuint, UniformIDMap > ProgramUniformMap;
2099   ProgramUniformMap mUniforms;
2100
2101   template <typename T>
2102   struct ProgramUniformValue : public std::map< GLuint, std::map< GLint, T > >
2103   {
2104   public:
2105     typedef std::map< GLint, T > UniformValueMap;
2106     typedef std::map< GLuint, UniformValueMap > Map;
2107
2108     bool SetUniformValue( GLuint program, GLuint uniform, const T& value )
2109     {
2110       if( program == 0 )
2111       {
2112         return false;
2113       }
2114
2115       typename Map::iterator it = Map::find( program );
2116       if( it == Map::end() )
2117       {
2118         // if its the first uniform for this program add it
2119         std::pair< typename Map::iterator, bool > result =
2120             Map::insert( typename Map::value_type( program, UniformValueMap() ) );
2121         it = result.first;
2122       }
2123
2124       UniformValueMap& uniforms = it->second;
2125       uniforms[uniform] = value;
2126
2127       return true;
2128     }
2129
2130     bool CheckUniformValue( GLuint program, GLuint uniform, const T& value ) const
2131     {
2132       T uniformValue;
2133       if ( GetUniformValue( program, uniform, uniformValue ) )
2134       {
2135         return value == uniformValue;
2136       }
2137
2138       return false;
2139     }
2140
2141     bool GetUniformValue( GLuint program, GLuint uniform, T& value ) const
2142     {
2143       if( program == 0 )
2144       {
2145         return false;
2146       }
2147
2148       typename Map::const_iterator it = Map::find( program );
2149       if( it == Map::end() )
2150       {
2151         // Uniform values always initialised as 0
2152         value = GetZero();
2153         return true;
2154       }
2155
2156       const UniformValueMap& uniforms = it->second;
2157       typename UniformValueMap::const_iterator it2 = uniforms.find( uniform );
2158       if( it2 == uniforms.end() )
2159       {
2160         // Uniform values always initialised as 0
2161         value = GetZero();
2162         return true;
2163       }
2164       value = it2->second;
2165
2166       return true;
2167     }
2168
2169     T GetZero() const;
2170   };
2171   ProgramUniformValue<int> mProgramUniforms1i;
2172   ProgramUniformValue<float> mProgramUniforms1f;
2173   ProgramUniformValue<Vector2> mProgramUniforms2f;
2174   ProgramUniformValue<Vector3> mProgramUniforms3f;
2175   ProgramUniformValue<Vector4> mProgramUniforms4f;
2176   ProgramUniformValue<Matrix> mProgramUniformsMat4;
2177   ProgramUniformValue<Matrix3> mProgramUniformsMat3;
2178
2179   inline const ProgramUniformValue<int>& GetProgramUniformsForType( const int ) const
2180   {
2181     return mProgramUniforms1i;
2182   }
2183   inline const ProgramUniformValue<float>& GetProgramUniformsForType( const float ) const
2184   {
2185     return mProgramUniforms1f;
2186   }
2187   inline const ProgramUniformValue<Vector2>& GetProgramUniformsForType( const Vector2& ) const
2188   {
2189     return mProgramUniforms2f;
2190   }
2191   inline const ProgramUniformValue<Vector3>& GetProgramUniformsForType( const Vector3& ) const
2192   {
2193     return mProgramUniforms3f;
2194   }
2195   inline const ProgramUniformValue<Vector4>& GetProgramUniformsForType( const Vector4& ) const
2196   {
2197     return mProgramUniforms4f;
2198   }
2199   inline const ProgramUniformValue<Matrix>& GetProgramUniformsForType( const Matrix& ) const
2200   {
2201     return mProgramUniformsMat4;
2202   }
2203   inline const ProgramUniformValue<Matrix3>& GetProgramUniformsForType( const Matrix3& ) const
2204   {
2205     return mProgramUniformsMat3;
2206   }
2207   inline void SetVertexAttribArray(GLuint index, bool state)
2208   {
2209     if( index >= MAX_ATTRIBUTE_CACHE_SIZE )
2210     {
2211       // out of range
2212       return;
2213     }
2214     mVertexAttribArrayState[ index ] = state;
2215     mVertexAttribArrayChanged = true;
2216   }
2217
2218   ScissorParams mScissorParams;
2219   ColorMaskParams mColorMaskParams;
2220 };
2221
2222 template <>
2223 inline int TestGlAbstraction::ProgramUniformValue<int>::GetZero() const
2224 {
2225   return 0;
2226 }
2227
2228 template <>
2229 inline float TestGlAbstraction::ProgramUniformValue<float>::GetZero() const
2230 {
2231   return 0.0f;
2232 }
2233
2234 template <>
2235 inline Vector2 TestGlAbstraction::ProgramUniformValue<Vector2>::GetZero() const
2236 {
2237   return Vector2::ZERO;
2238 }
2239
2240 template <>
2241 inline Vector3 TestGlAbstraction::ProgramUniformValue<Vector3>::GetZero() const
2242 {
2243   return Vector3::ZERO;
2244 }
2245
2246 template <>
2247 inline Vector4 TestGlAbstraction::ProgramUniformValue<Vector4>::GetZero() const
2248 {
2249   return Vector4::ZERO;
2250 }
2251
2252 template <>
2253 inline Matrix TestGlAbstraction::ProgramUniformValue<Matrix>::GetZero() const
2254 {
2255   return Matrix();
2256 }
2257
2258 template <>
2259 inline Matrix3 TestGlAbstraction::ProgramUniformValue<Matrix3>::GetZero() const
2260 {
2261   return Matrix3( Matrix() );
2262 }
2263
2264 } // namespace Dali
2265
2266 bool BlendEnabled(const Dali::TraceCallStack& callStack);
2267 bool BlendDisabled(const Dali::TraceCallStack& callStack);
2268
2269
2270 #endif // TEST_GL_ABSTRACTION_H