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