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