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