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