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