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