1 #ifndef TEST_GL_ABSTRACTION_H
2 #define TEST_GL_ABSTRACTION_H
5 * Copyright (c) 2016 Samsung Electronics Co., Ltd.
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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.
27 #include <cstring> // for strcmp
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"
39 static const unsigned int MAX_ATTRIBUTE_CACHE_SIZE = 64;
40 static const char *mStdAttribs[MAX_ATTRIBUTE_CACHE_SIZE] =
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
50 class DALI_IMPORT_API TestGlAbstraction: public Dali::Integration::GlAbstraction
62 inline void ActiveTexture( GLenum textureUnit )
64 mActiveTextureUnit = textureUnit - GL_TEXTURE0;
67 inline GLenum GetActiveTextureUnit() const
69 return mActiveTextureUnit + GL_TEXTURE0;
72 inline void AttachShader( GLuint program, GLuint shader )
74 std::stringstream out;
75 out << program << ", " << shader;
77 TraceCallStack::NamedParams namedParams;
78 namedParams["program"] = ToString(program);
79 namedParams["shader"] = ToString(shader);
80 mShaderTrace.PushCall("AttachShader", out.str(), namedParams);
83 inline void BindAttribLocation( GLuint program, GLuint index, const char* name )
87 inline void BindBuffer( GLenum target, GLuint buffer )
91 inline void BindFramebuffer( GLenum target, GLuint framebuffer )
94 mFramebufferStatus |= 2;
97 inline void BindRenderbuffer( GLenum target, GLuint renderbuffer )
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.
105 inline const std::vector<GLuint>& GetBoundTextures() const
107 return mBoundTextures;
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.
115 inline const std::vector<GLuint>& GetBoundTextures( GLuint activeTextureUnit ) const
117 return mActiveTextures[ activeTextureUnit - GL_TEXTURE0 ].mBoundTextures;
121 * This method can be used by test cases, to clear the record of texture IDs that have been bound by BindTexture.
123 inline void ClearBoundTextures()
125 mBoundTextures.clear();
127 for( unsigned int i=0; i<MIN_TEXTURE_UNIT_LIMIT; ++i )
129 mActiveTextures[ i ].mBoundTextures.clear();
133 inline void BindTexture( GLenum target, GLuint texture )
135 // Record the bound textures for future checks
138 mBoundTextures.push_back( texture );
140 if( mActiveTextureUnit < MIN_TEXTURE_UNIT_LIMIT )
142 mActiveTextures[ mActiveTextureUnit ].mBoundTextures.push_back( texture );
146 std::stringstream out;
147 out << target << ", " << texture;
149 TraceCallStack::NamedParams namedParams;
150 namedParams["target"] = ToString(target);
151 namedParams["texture"] = ToString(texture);
153 mTextureTrace.PushCall("BindTexture", out.str(), namedParams);
156 inline void BlendColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha)
158 mLastBlendColor.r = red;
159 mLastBlendColor.g = green;
160 mLastBlendColor.b = blue;
161 mLastBlendColor.a = alpha;
164 inline const Vector4& GetLastBlendColor() const
166 return mLastBlendColor;
169 inline void BlendEquation( GLenum mode )
171 mLastBlendEquationRgb = mode;
172 mLastBlendEquationAlpha = mode;
175 inline void BlendEquationSeparate( GLenum modeRgb, GLenum modeAlpha )
177 mLastBlendEquationRgb = modeRgb;
178 mLastBlendEquationAlpha = modeAlpha;
181 inline GLenum GetLastBlendEquationRgb() const
183 return mLastBlendEquationRgb;
186 inline GLenum GetLastBlendEquationAlpha() const
188 return mLastBlendEquationAlpha;
191 inline void BlendFunc(GLenum sfactor, GLenum dfactor)
193 mLastBlendFuncSrcRgb = sfactor;
194 mLastBlendFuncDstRgb = dfactor;
195 mLastBlendFuncSrcAlpha = sfactor;
196 mLastBlendFuncDstAlpha = dfactor;
199 inline void BlendFuncSeparate(GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha)
201 mLastBlendFuncSrcRgb = srcRGB;
202 mLastBlendFuncDstRgb = dstRGB;
203 mLastBlendFuncSrcAlpha = srcAlpha;
204 mLastBlendFuncDstAlpha = dstAlpha;
207 inline GLenum GetLastBlendFuncSrcRgb() const
209 return mLastBlendFuncSrcRgb;
212 inline GLenum GetLastBlendFuncDstRgb() const
214 return mLastBlendFuncDstRgb;
217 inline GLenum GetLastBlendFuncSrcAlpha() const
219 return mLastBlendFuncSrcAlpha;
222 inline GLenum GetLastBlendFuncDstAlpha() const
224 return mLastBlendFuncDstAlpha;
227 inline void BufferData(GLenum target, GLsizeiptr size, const void* data, GLenum usage)
229 mBufferDataCalls.push_back(size);
232 inline void BufferSubData(GLenum target, GLintptr offset, GLsizeiptr size, const void* data)
234 mBufferSubDataCalls.push_back(size);
237 inline GLenum CheckFramebufferStatus(GLenum target)
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 )
243 return GL_FRAMEBUFFER_COMPLETE;
246 return mCheckFramebufferStatusResult;
249 inline GLenum CheckFramebufferColorAttachment()
251 return mFramebufferColorAttached;
254 inline GLenum CheckFramebufferDepthAttachment()
256 return mFramebufferDepthAttached;
259 inline GLenum CheckFramebufferStencilAttachment()
261 return mFramebufferStencilAttached;
264 inline void Clear(GLbitfield mask)
267 mLastClearBitMask = mask;
270 inline void ClearColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha)
274 inline void ClearDepthf(GLclampf depth)
278 inline void ClearStencil(GLint s)
280 std::stringstream out;
283 TraceCallStack::NamedParams namedParams;
284 namedParams["s"] = ToString( s );
286 mStencilFunctionTrace.PushCall( "ClearStencil", out.str(), namedParams );
289 inline void ColorMask(GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha)
291 mColorMaskParams.red = red;
292 mColorMaskParams.green = green;
293 mColorMaskParams.blue = blue;
294 mColorMaskParams.alpha = alpha;
297 inline void CompileShader(GLuint shader)
299 std::stringstream out;
301 TraceCallStack::NamedParams namedParams;
302 namedParams["shader"] = ToString(shader);
304 mShaderTrace.PushCall("CompileShader", out.str(), namedParams);
307 inline void CompressedTexImage2D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void* data)
309 std::stringstream out;
310 out << target<<", "<<level<<", "<<width << ", " << height;
312 TraceCallStack::NamedParams namedParams;
313 namedParams["target"] = ToString(target);
314 namedParams["level"] = ToString(level);
315 namedParams["internalformat"] = ToString(internalformat);
316 namedParams["width"] = ToString(width);
317 namedParams["height"] = ToString(height);
318 namedParams["border"] = ToString(border);
319 namedParams["size"] = ToString(imageSize);
321 mTextureTrace.PushCall("CompressedTexImage2D", out.str(), namedParams);
324 inline void CompressedTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void* data)
326 std::stringstream out;
327 out << target << ", "<<level <<", " << xoffset << ", " << yoffset << ", " << width << ", " << height;
329 TraceCallStack::NamedParams namedParams;
330 namedParams["target"] = ToString(target);
331 namedParams["level"] = ToString(level);
332 namedParams["xoffset"] = ToString(xoffset);
333 namedParams["yoffset"] = ToString(yoffset);
334 namedParams["width"] = ToString(width);
335 namedParams["height"] = ToString(height);
336 mTextureTrace.PushCall("CompressedTexSubImage2D", out.str(), namedParams);
339 inline void CopyTexImage2D(GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border)
343 inline void CopyTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height)
347 inline GLuint CreateProgram(void)
349 mShaderTrace.PushCall("CreateProgram", "");
351 ++mLastProgramIdUsed;
352 mUniforms[mLastProgramIdUsed] = UniformIDMap();
353 return mLastProgramIdUsed;
356 inline GLuint CreateShader(GLenum type)
358 std::stringstream out;
361 TraceCallStack::NamedParams namedParams;
362 namedParams["type"] = ToString(type);
363 mShaderTrace.PushCall("CreateShader", out.str(), namedParams);
365 return ++mLastShaderIdUsed;
368 inline void CullFace(GLenum mode)
370 std::stringstream out;
373 TraceCallStack::NamedParams namedParams;
374 namedParams["program"] = ToString(mode);
376 mCullFaceTrace.PushCall("CullFace", out.str(), namedParams);
379 inline void DeleteBuffers(GLsizei n, const GLuint* buffers)
383 inline void DeleteFramebuffers(GLsizei n, const GLuint* framebuffers)
387 inline void DeleteProgram(GLuint program)
389 std::stringstream out;
392 TraceCallStack::NamedParams namedParams;
393 namedParams["program"] = ToString(program);
395 mShaderTrace.PushCall("DeleteProgram", out.str(), namedParams);
398 inline void DeleteRenderbuffers(GLsizei n, const GLuint* renderbuffers)
402 inline void DeleteShader(GLuint shader)
404 std::stringstream out;
407 TraceCallStack::NamedParams namedParams;
408 namedParams["shader"] = ToString(shader);
410 mShaderTrace.PushCall("DeleteShader", out.str(), namedParams);
413 inline void DeleteTextures(GLsizei n, const GLuint* textures)
415 std::stringstream out;
416 out << n << ", " << textures << " = [";
418 TraceCallStack::NamedParams namedParams;
420 for(GLsizei i=0; i<n; i++)
422 out << textures[i] << ", ";
423 std::stringstream paramName;
424 paramName<<"texture["<<i<<"]";
425 namedParams[paramName.str()] = ToString(textures[i]);
426 mDeletedTextureIds.push_back(textures[i]);
430 mTextureTrace.PushCall("DeleteTextures", out.str(), namedParams);
433 inline bool CheckNoTexturesDeleted()
435 return mDeletedTextureIds.size() == 0;
438 inline bool CheckTextureDeleted( GLuint textureId )
442 for(std::vector<GLuint>::iterator iter=mDeletedTextureIds.begin(); iter != mDeletedTextureIds.end(); ++iter)
444 if(*iter == textureId)
453 inline void ClearDeletedTextures()
455 mDeletedTextureIds.clear();
458 inline void DepthFunc(GLenum func)
460 std::stringstream out;
463 TraceCallStack::NamedParams namedParams;
464 namedParams["func"] = ToString(func);
466 mDepthFunctionTrace.PushCall("DepthFunc", out.str(), namedParams);
469 inline void DepthMask(GLboolean flag)
471 mLastDepthMask = flag;
474 inline bool GetLastDepthMask() const
476 return mLastDepthMask;
479 inline void DepthRangef(GLclampf zNear, GLclampf zFar)
483 inline void DetachShader(GLuint program, GLuint shader)
485 std::stringstream out;
486 out << program << ", " << shader;
487 TraceCallStack::NamedParams namedParams;
488 namedParams["program"] = ToString(program);
489 namedParams["shader"] = ToString(shader);
490 mShaderTrace.PushCall("DetachShader", out.str(), namedParams);
493 inline void Disable(GLenum cap)
495 std::stringstream out;
497 TraceCallStack::NamedParams namedParams;
498 namedParams["cap"] = ToString(cap);
499 mEnableDisableTrace.PushCall("Disable", out.str(), namedParams);
502 inline void DisableVertexAttribArray(GLuint index)
504 SetVertexAttribArray( index, false );
507 inline void DrawArrays(GLenum mode, GLint first, GLsizei count)
509 std::stringstream out;
510 out << mode << ", " << first << ", " << count;
511 TraceCallStack::NamedParams namedParams;
512 namedParams["mode"] = ToString(mode);
513 namedParams["first"] = ToString(first);
514 namedParams["count"] = ToString(count);
515 mDrawTrace.PushCall("DrawArrays", out.str(), namedParams);
518 inline void DrawElements(GLenum mode, GLsizei count, GLenum type, const void* indices)
520 std::stringstream out;
521 out << mode << ", " << count << ", " << type << ", indices";
523 TraceCallStack::NamedParams namedParams;
524 namedParams["mode"] = ToString(mode);
525 namedParams["count"] = ToString(count);
526 namedParams["type"] = ToString(type);
527 // Skip void pointers - are they of any use?
528 mDrawTrace.PushCall("DrawElements", out.str(), namedParams);
531 inline void Enable(GLenum cap)
533 std::stringstream out;
535 TraceCallStack::NamedParams namedParams;
536 namedParams["cap"] = ToString(cap);
537 mEnableDisableTrace.PushCall("Enable", out.str(), namedParams);
540 inline void EnableVertexAttribArray(GLuint index)
542 SetVertexAttribArray( index, true);
545 inline void Finish(void)
549 inline void Flush(void)
553 inline void FramebufferRenderbuffer(GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer)
555 if (attachment == GL_DEPTH_ATTACHMENT)
557 mFramebufferDepthAttached = true;
559 else if (attachment == GL_STENCIL_ATTACHMENT)
561 mFramebufferStencilAttached = true;
565 inline void FramebufferTexture2D(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level)
568 mFramebufferStatus |= 4;
570 //We check 4 attachment colors
571 if ((attachment == GL_COLOR_ATTACHMENT0) || (attachment == GL_COLOR_ATTACHMENT1) || (attachment == GL_COLOR_ATTACHMENT2) || (attachment == GL_COLOR_ATTACHMENT4))
573 mFramebufferColorAttached = true;
577 inline void FrontFace(GLenum mode)
581 inline void GenBuffers(GLsizei n, GLuint* buffers)
583 // avoids an assert in GpuBuffers
587 inline void GenerateMipmap(GLenum target)
589 std::stringstream out;
591 TraceCallStack::NamedParams namedParams;
592 namedParams["target"] = ToString(target);
594 mTextureTrace.PushCall("GenerateMipmap", out.str(), namedParams);
597 inline void GenFramebuffers(GLsizei n, GLuint* framebuffers)
599 for( int i = 0; i < n; i++ )
601 framebuffers[i] = i + 1;
604 //Add 001 bit, this function needs to be called the first one in the chain
605 mFramebufferStatus = 1;
608 inline void GenRenderbuffers(GLsizei n, GLuint* renderbuffers)
610 for( int i = 0; i < n; i++ )
612 renderbuffers[i] = i + 1;
617 * This method can be used by test cases, to manipulate the texture IDs generated by GenTextures.
618 * @param[in] ids A vector containing the next IDs to be generated
620 inline void SetNextTextureIds( const std::vector<GLuint>& ids )
622 mNextTextureIds = ids;
625 inline const std::vector<GLuint>& GetNextTextureIds()
627 return mNextTextureIds;
630 inline void GenTextures(GLsizei count, GLuint* textures)
632 for( int i=0; i<count; ++i )
634 if( !mNextTextureIds.empty() )
636 *(textures+i) = mNextTextureIds[0];
637 mNextTextureIds.erase( mNextTextureIds.begin() );
641 *(textures+i) = ++mLastAutoTextureIdUsed;
645 TraceCallStack::NamedParams namedParams;
646 namedParams["count"] = ToString(count);
648 std::stringstream out;
649 for(int i=0; i<count; i++)
656 std::ostringstream oss;
657 oss<<"indices["<<i<<"]";
658 namedParams[oss.str()] = ToString(textures[i]);
661 mTextureTrace.PushCall("GenTextures", out.str(), namedParams);
664 inline void GetActiveAttrib(GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, char* name)
668 inline void GetActiveUniform(GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, char* name)
673 *length = snprintf(name, bufsize, "sTexture");
674 *type = GL_SAMPLER_2D;
678 *length = snprintf(name, bufsize, "sEffect");
679 *type = GL_SAMPLER_2D;
683 *length = snprintf(name, bufsize, "sGloss");
684 *type = GL_SAMPLER_2D;
692 inline void GetAttachedShaders(GLuint program, GLsizei maxcount, GLsizei* count, GLuint* shaders)
696 inline int GetAttribLocation(GLuint program, const char* name)
698 std::string attribName(name);
700 for( unsigned int i = 0; i < ATTRIB_TYPE_LAST; ++i )
702 if( mStdAttribs[i] == attribName )
708 // 0 is a valid location
712 inline void GetBooleanv(GLenum pname, GLboolean* params)
716 inline void GetBufferParameteriv(GLenum target, GLenum pname, GLint* params)
720 inline GLenum GetError(void)
722 return mGetErrorResult;
725 inline void GetFloatv(GLenum pname, GLfloat* params)
729 inline void GetFramebufferAttachmentParameteriv(GLenum target, GLenum attachment, GLenum pname, GLint* params)
733 inline void GetIntegerv(GLenum pname, GLint* params)
737 case GL_MAX_TEXTURE_SIZE:
740 case GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS:
743 case GL_NUM_PROGRAM_BINARY_FORMATS_OES:
744 *params = mNumBinaryFormats;
746 case GL_PROGRAM_BINARY_FORMATS_OES:
747 *params = mBinaryFormats;
752 inline void GetProgramiv(GLuint program, GLenum pname, GLint* params)
757 *params = mLinkStatus;
759 case GL_PROGRAM_BINARY_LENGTH_OES:
760 *params = mProgramBinaryLength;
762 case GL_ACTIVE_UNIFORMS:
763 *params = mNumberOfActiveUniforms;
765 case GL_ACTIVE_UNIFORM_MAX_LENGTH:
771 inline void GetProgramInfoLog(GLuint program, GLsizei bufsize, GLsizei* length, char* infolog)
775 inline void GetRenderbufferParameteriv(GLenum target, GLenum pname, GLint* params)
779 inline void GetShaderiv(GLuint shader, GLenum pname, GLint* params)
782 case GL_COMPILE_STATUS:
783 *params = mCompileStatus;
788 inline void GetShaderInfoLog(GLuint shader, GLsizei bufsize, GLsizei* length, char* infolog)
792 inline void GetShaderPrecisionFormat(GLenum shadertype, GLenum precisiontype, GLint* range, GLint* precision)
796 inline const GLubyte* GetString(GLenum name)
798 return mGetStringResult;
801 inline void GetTexParameterfv(GLenum target, GLenum pname, GLfloat* params)
805 inline void GetTexParameteriv(GLenum target, GLenum pname, GLint* params)
809 inline void GetUniformfv(GLuint program, GLint location, GLfloat* params)
813 inline void GetUniformiv(GLuint program, GLint location, GLint* params)
817 inline GLint GetUniformLocation(GLuint program, const char* name)
819 ProgramUniformMap::iterator it = mUniforms.find(program);
820 if( it == mUniforms.end() )
822 // Not a valid program ID
823 mGetErrorResult = GL_INVALID_OPERATION;
827 UniformIDMap& uniformIDs = it->second;
828 UniformIDMap::iterator it2 = uniformIDs.find( name );
829 if( it2 == uniformIDs.end() )
831 // Uniform not found, so add it...
832 uniformIDs[name] = ++mLastUniformIdUsed;
833 return mLastUniformIdUsed;
839 inline void GetVertexAttribfv(GLuint index, GLenum pname, GLfloat* params)
843 inline void GetVertexAttribiv(GLuint index, GLenum pname, GLint* params)
847 inline void GetVertexAttribPointerv(GLuint index, GLenum pname, void** pointer)
851 inline void Hint(GLenum target, GLenum mode)
855 inline GLboolean IsBuffer(GLuint buffer)
857 return mIsBufferResult;
860 inline GLboolean IsEnabled(GLenum cap)
862 return mIsEnabledResult;
865 inline GLboolean IsFramebuffer(GLuint framebuffer)
867 return mIsFramebufferResult;
870 inline GLboolean IsProgram(GLuint program)
872 return mIsProgramResult;
875 inline GLboolean IsRenderbuffer(GLuint renderbuffer)
877 return mIsRenderbufferResult;
880 inline GLboolean IsShader(GLuint shader)
882 return mIsShaderResult;
885 inline GLboolean IsTexture(GLuint texture)
887 return mIsTextureResult;
890 inline void LineWidth(GLfloat width)
894 inline void LinkProgram(GLuint program)
896 std::stringstream out;
899 TraceCallStack::NamedParams namedParams;
900 namedParams["program"] = ToString(program);
901 mShaderTrace.PushCall("LinkProgram", out.str(), namedParams);
903 mNumberOfActiveUniforms=3;
904 GetUniformLocation(program, "sTexture");
905 GetUniformLocation(program, "sEffect");
906 GetUniformLocation(program, "sGloss");
909 inline void PixelStorei(GLenum pname, GLint param)
913 inline void PolygonOffset(GLfloat factor, GLfloat units)
917 inline void ReadPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, void* pixels)
921 inline void ReleaseShaderCompiler(void)
925 inline void RenderbufferStorage(GLenum target, GLenum internalformat, GLsizei width, GLsizei height)
929 inline void SampleCoverage(GLclampf value, GLboolean invert)
933 inline void Scissor(GLint x, GLint y, GLsizei width, GLsizei height)
935 mScissorParams.x = x;
936 mScissorParams.y = y;
937 mScissorParams.width = width;
938 mScissorParams.height = height;
941 inline void ShaderBinary(GLsizei n, const GLuint* shaders, GLenum binaryformat, const void* binary, GLsizei length)
945 inline void ShaderSource(GLuint shader, GLsizei count, const char** string, const GLint* length)
947 std::string stringBuilder;
948 for(int i = 0; i < count; ++i)
950 stringBuilder += string[i];
952 mShaderSources[shader] = stringBuilder;
953 mLastShaderCompiled = shader;
956 inline void GetShaderSource(GLuint shader, GLsizei bufsize, GLsizei* length, char* source)
958 const std::string shaderSource = mShaderSources[shader];
959 if( static_cast<int>(shaderSource.length()) < bufsize )
961 strcpy(source, shaderSource.c_str());
962 *length = shaderSource.length();
966 *length = bufsize -1;
967 strncpy(source, shaderSource.c_str(), *length);
968 source[*length] = 0x0;
972 inline std::string GetShaderSource(GLuint shader)
974 return mShaderSources[shader];
977 inline void StencilFunc(GLenum func, GLint ref, GLuint mask)
979 std::stringstream out;
980 out << func << ", " << ref << ", " << mask;
982 TraceCallStack::NamedParams namedParams;
983 namedParams["func"] = ToString( func );
984 namedParams["ref"] = ToString( ref );
985 namedParams["mask"] = ToString( mask );
987 mStencilFunctionTrace.PushCall( "StencilFunc", out.str(), namedParams );
990 inline void StencilFuncSeparate(GLenum face, GLenum func, GLint ref, GLuint mask)
992 std::stringstream out;
993 out << face << ", " << func << ", " << ref << ", " << mask;
995 TraceCallStack::NamedParams namedParams;
996 namedParams["face"] = ToString( face );
997 namedParams["func"] = ToString( func );
998 namedParams["ref"] = ToString( ref );
999 namedParams["mask"] = ToString( mask );
1001 mStencilFunctionTrace.PushCall( "StencilFuncSeparate", out.str(), namedParams );
1004 inline void StencilMask(GLuint mask)
1006 std::stringstream out;
1009 TraceCallStack::NamedParams namedParams;
1010 namedParams["mask"] = ToString( mask );
1012 mStencilFunctionTrace.PushCall( "StencilMask", out.str(), namedParams );
1015 inline void StencilMaskSeparate(GLenum face, GLuint mask)
1017 std::stringstream out;
1018 out << face << ", " << mask;
1020 TraceCallStack::NamedParams namedParams;
1021 namedParams["face"] = ToString( face );
1022 namedParams["mask"] = ToString( mask );
1024 mStencilFunctionTrace.PushCall( "StencilMaskSeparate", out.str(), namedParams );
1027 inline void StencilOp(GLenum fail, GLenum zfail, GLenum zpass)
1029 std::stringstream out;
1030 out << fail << ", " << zfail << ", " << zpass;
1032 TraceCallStack::NamedParams namedParams;
1033 namedParams["fail"] = ToString( fail );
1034 namedParams["zfail"] = ToString( zfail );
1035 namedParams["zpass"] = ToString( zpass );
1037 mStencilFunctionTrace.PushCall( "StencilOp", out.str(), namedParams );
1040 inline void StencilOpSeparate(GLenum face, GLenum fail, GLenum zfail, GLenum zpass)
1042 std::stringstream out;
1043 out << face << ", " << fail << ", " << zfail << "," << zpass;
1045 TraceCallStack::NamedParams namedParams;
1046 namedParams["face"] = ToString( face );
1047 namedParams["fail"] = ToString( fail );
1048 namedParams["zfail"] = ToString( zfail );
1049 namedParams["zpass"] = ToString( zpass );
1051 mStencilFunctionTrace.PushCall( "StencilOpSeparate", out.str(), namedParams );
1054 inline void TexImage2D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void* pixels)
1056 std::stringstream out;
1057 out << target<<", "<<level<<", "<<width << ", " << height;
1059 TraceCallStack::NamedParams namedParams;
1060 namedParams["target"] = ToString(target);
1061 namedParams["level"] = ToString(level);
1062 namedParams["internalformat"] = ToString(internalformat);
1063 namedParams["width"] = ToString(width);
1064 namedParams["height"] = ToString(height);
1065 namedParams["border"] = ToString(border);
1066 namedParams["format"] = ToString(format);
1067 namedParams["type"] = ToString(type);
1069 mTextureTrace.PushCall("TexImage2D", out.str(), namedParams);
1072 inline void TexParameterf(GLenum target, GLenum pname, GLfloat param)
1074 std::stringstream out;
1075 out << target << ", " << pname << ", " << param;
1077 TraceCallStack::NamedParams namedParams;
1078 namedParams["target"] = ToString(target);
1079 namedParams["pname"] = ToString(pname);
1080 namedParams["param"] = ToString(param);
1082 mTexParamaterTrace.PushCall("TexParameterf", out.str(), namedParams);
1085 inline void TexParameterfv(GLenum target, GLenum pname, const GLfloat* params)
1087 std::stringstream out;
1088 out << target << ", " << pname << ", " << params[0];
1090 TraceCallStack::NamedParams namedParams;
1091 namedParams["target"] = ToString(target);
1092 namedParams["pname"] = ToString(pname);
1093 namedParams["params[0]"] = ToString(params[0]);
1095 mTexParamaterTrace.PushCall("TexParameterfv", out.str(), namedParams);
1098 inline void TexParameteri(GLenum target, GLenum pname, GLint param)
1100 std::stringstream out;
1101 out << target << ", " << pname << ", " << param;
1102 TraceCallStack::NamedParams namedParams;
1103 namedParams["target"] = ToString(target);
1104 namedParams["pname"] = ToString(pname);
1105 namedParams["param"] = ToString(param);
1106 mTexParamaterTrace.PushCall("TexParameteri", out.str(), namedParams);
1109 inline void TexParameteriv(GLenum target, GLenum pname, const GLint* params)
1111 std::stringstream out;
1112 out << target << ", " << pname << ", " << params[0];
1113 TraceCallStack::NamedParams namedParams;
1114 namedParams["target"] = ToString(target);
1115 namedParams["pname"] = ToString(pname);
1116 namedParams["params[0]"] = ToString(params[0]);
1117 mTexParamaterTrace.PushCall("TexParameteriv", out.str(), namedParams);
1120 inline void TexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void* pixels)
1122 std::stringstream out;
1123 out << target << ", "<<level <<", " << xoffset << ", " << yoffset << ", " << width << ", " << height;
1125 TraceCallStack::NamedParams namedParams;
1126 namedParams["target"] = ToString(target);
1127 namedParams["level"] = ToString(level);
1128 namedParams["xoffset"] = ToString(xoffset);
1129 namedParams["yoffset"] = ToString(yoffset);
1130 namedParams["width"] = ToString(width);
1131 namedParams["height"] = ToString(height);
1132 mTextureTrace.PushCall("TexSubImage2D", out.str(), namedParams);
1135 inline void Uniform1f(GLint location, GLfloat x)
1137 if( ! mProgramUniforms1f.SetUniformValue( mCurrentProgram, location, x ) )
1139 mGetErrorResult = GL_INVALID_OPERATION;
1143 inline void Uniform1fv(GLint location, GLsizei count, const GLfloat* v)
1145 for( int i = 0; i < count; ++i )
1147 if( ! mProgramUniforms1f.SetUniformValue( mCurrentProgram, location, v[i] ) )
1149 mGetErrorResult = GL_INVALID_OPERATION;
1155 inline void Uniform1i(GLint location, GLint x)
1157 if( ! mProgramUniforms1i.SetUniformValue( mCurrentProgram, location, x ) )
1159 mGetErrorResult = GL_INVALID_OPERATION;
1163 inline void Uniform1iv(GLint location, GLsizei count, const GLint* v)
1165 for( int i = 0; i < count; ++i )
1167 if( ! mProgramUniforms1i.SetUniformValue( mCurrentProgram,
1171 mGetErrorResult = GL_INVALID_OPERATION;
1177 inline void Uniform2f(GLint location, GLfloat x, GLfloat y)
1179 if( ! mProgramUniforms2f.SetUniformValue( mCurrentProgram,
1183 mGetErrorResult = GL_INVALID_OPERATION;
1187 inline void Uniform2fv(GLint location, GLsizei count, const GLfloat* v)
1189 for( int i = 0; i < count; ++i )
1191 if( ! mProgramUniforms2f.SetUniformValue( mCurrentProgram,
1193 Vector2( v[2*i], v[2*i+1] ) ) )
1195 mGetErrorResult = GL_INVALID_OPERATION;
1201 inline void Uniform2i(GLint location, GLint x, GLint y)
1205 inline void Uniform2iv(GLint location, GLsizei count, const GLint* v)
1209 inline void Uniform3f(GLint location, GLfloat x, GLfloat y, GLfloat z)
1211 if( ! mProgramUniforms3f.SetUniformValue( mCurrentProgram,
1213 Vector3( x, y, z ) ) )
1215 mGetErrorResult = GL_INVALID_OPERATION;
1219 inline void Uniform3fv(GLint location, GLsizei count, const GLfloat* v)
1221 for( int i = 0; i < count; ++i )
1223 if( ! mProgramUniforms3f.SetUniformValue(
1226 Vector3( v[3*i], v[3*i+1], v[3*i+2] ) ) )
1228 mGetErrorResult = GL_INVALID_OPERATION;
1234 inline void Uniform3i(GLint location, GLint x, GLint y, GLint z)
1238 inline void Uniform3iv(GLint location, GLsizei count, const GLint* v)
1242 inline void Uniform4f(GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w)
1244 if( ! mProgramUniforms4f.SetUniformValue( mCurrentProgram,
1246 Vector4( x, y, z, w ) ) )
1248 mGetErrorResult = GL_INVALID_OPERATION;
1252 inline void Uniform4fv(GLint location, GLsizei count, const GLfloat* v)
1254 for( int i = 0; i < count; ++i )
1256 if( ! mProgramUniforms4f.SetUniformValue(
1259 Vector4( v[4*i], v[4*i+1], v[4*i+2], v[4*i+3] ) ) )
1261 mGetErrorResult = GL_INVALID_OPERATION;
1267 inline void Uniform4i(GLint location, GLint x, GLint y, GLint z, GLint w)
1271 inline void Uniform4iv(GLint location, GLsizei count, const GLint* v)
1275 inline void UniformMatrix2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
1279 inline void UniformMatrix3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
1281 for( int i = 0; i < count; ++i )
1283 if( ! mProgramUniformsMat3.SetUniformValue(
1286 Matrix3( value[0], value[1], value[2], value[3], value[4], value[5], value[6], value[7], value[8] ) ) )
1288 mGetErrorResult = GL_INVALID_OPERATION;
1294 inline void UniformMatrix4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
1296 for( int i = 0; i < count; ++i )
1298 if( ! mProgramUniformsMat4.SetUniformValue(
1303 mGetErrorResult = GL_INVALID_OPERATION;
1309 inline void UseProgram(GLuint program)
1311 mCurrentProgram = program;
1314 inline void ValidateProgram(GLuint program)
1318 inline void VertexAttrib1f(GLuint indx, GLfloat x)
1322 inline void VertexAttrib1fv(GLuint indx, const GLfloat* values)
1326 inline void VertexAttrib2f(GLuint indx, GLfloat x, GLfloat y)
1330 inline void VertexAttrib2fv(GLuint indx, const GLfloat* values)
1334 inline void VertexAttrib3f(GLuint indx, GLfloat x, GLfloat y, GLfloat z)
1338 inline void VertexAttrib3fv(GLuint indx, const GLfloat* values)
1342 inline void VertexAttrib4f(GLuint indx, GLfloat x, GLfloat y, GLfloat z, GLfloat w)
1346 inline void VertexAttrib4fv(GLuint indx, const GLfloat* values)
1350 inline void VertexAttribPointer(GLuint indx, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void* ptr)
1354 inline void Viewport(GLint x, GLint y, GLsizei width, GLsizei height)
1360 inline void ReadBuffer(GLenum mode)
1364 inline void DrawRangeElements(GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid* indices)
1368 inline void TexImage3D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid* pixels)
1372 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)
1376 inline void CopyTexSubImage3D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height)
1380 inline void CompressedTexImage3D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid* data)
1384 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)
1388 inline void GenQueries(GLsizei n, GLuint* ids)
1392 inline void DeleteQueries(GLsizei n, const GLuint* ids)
1396 inline GLboolean IsQuery(GLuint id)
1401 inline void BeginQuery(GLenum target, GLuint id)
1405 inline void EndQuery(GLenum target)
1409 inline void GetQueryiv(GLenum target, GLenum pname, GLint* params)
1413 inline void GetQueryObjectuiv(GLuint id, GLenum pname, GLuint* params)
1417 inline GLboolean UnmapBuffer(GLenum target)
1422 inline void GetBufferPointerv(GLenum target, GLenum pname, GLvoid** params)
1426 inline void DrawBuffers(GLsizei n, const GLenum* bufs)
1430 inline void UniformMatrix2x3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
1434 inline void UniformMatrix3x2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
1438 inline void UniformMatrix2x4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
1442 inline void UniformMatrix4x2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
1446 inline void UniformMatrix3x4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
1450 inline void UniformMatrix4x3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
1454 inline void BlitFramebuffer(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter)
1458 inline void RenderbufferStorageMultisample(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height)
1462 inline void FramebufferTextureLayer(GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer)
1466 inline GLvoid* MapBufferRange(GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access)
1471 inline void FlushMappedBufferRange(GLenum target, GLintptr offset, GLsizeiptr length)
1475 inline void BindVertexArray(GLuint array)
1479 inline void DeleteVertexArrays(GLsizei n, const GLuint* arrays)
1483 inline void GenVertexArrays(GLsizei n, GLuint* arrays)
1487 inline GLboolean IsVertexArray(GLuint array)
1492 inline void GetIntegeri_v(GLenum target, GLuint index, GLint* data)
1496 inline void BeginTransformFeedback(GLenum primitiveMode)
1500 inline void EndTransformFeedback(void)
1504 inline void BindBufferRange(GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size)
1508 inline void BindBufferBase(GLenum target, GLuint index, GLuint buffer)
1512 inline void TransformFeedbackVaryings(GLuint program, GLsizei count, const GLchar* const* varyings, GLenum bufferMode)
1516 inline void GetTransformFeedbackVarying(GLuint program, GLuint index, GLsizei bufSize, GLsizei* length, GLsizei* size, GLenum* type, GLchar* name)
1520 inline void VertexAttribIPointer(GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid* pointer)
1524 inline void GetVertexAttribIiv(GLuint index, GLenum pname, GLint* params)
1528 inline void GetVertexAttribIuiv(GLuint index, GLenum pname, GLuint* params)
1532 inline void VertexAttribI4i(GLuint index, GLint x, GLint y, GLint z, GLint w)
1536 inline void VertexAttribI4ui(GLuint index, GLuint x, GLuint y, GLuint z, GLuint w)
1540 inline void VertexAttribI4iv(GLuint index, const GLint* v)
1544 inline void VertexAttribI4uiv(GLuint index, const GLuint* v)
1548 inline void GetUniformuiv(GLuint program, GLint location, GLuint* params)
1552 inline GLint GetFragDataLocation(GLuint program, const GLchar *name)
1557 inline void Uniform1ui(GLint location, GLuint v0)
1561 inline void Uniform2ui(GLint location, GLuint v0, GLuint v1)
1565 inline void Uniform3ui(GLint location, GLuint v0, GLuint v1, GLuint v2)
1569 inline void Uniform4ui(GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3)
1573 inline void Uniform1uiv(GLint location, GLsizei count, const GLuint* value)
1577 inline void Uniform2uiv(GLint location, GLsizei count, const GLuint* value)
1581 inline void Uniform3uiv(GLint location, GLsizei count, const GLuint* value)
1585 inline void Uniform4uiv(GLint location, GLsizei count, const GLuint* value)
1589 inline void ClearBufferiv(GLenum buffer, GLint drawbuffer, const GLint* value)
1593 inline void ClearBufferuiv(GLenum buffer, GLint drawbuffer, const GLuint* value)
1597 inline void ClearBufferfv(GLenum buffer, GLint drawbuffer, const GLfloat* value)
1601 inline void ClearBufferfi(GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil)
1605 inline const GLubyte* GetStringi(GLenum name, GLuint index)
1610 inline void CopyBufferSubData(GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size)
1614 inline void GetUniformIndices(GLuint program, GLsizei uniformCount, const GLchar* const* uniformNames, GLuint* uniformIndices)
1618 inline void GetActiveUniformsiv(GLuint program, GLsizei uniformCount, const GLuint* uniformIndices, GLenum pname, GLint* params)
1622 inline GLuint GetUniformBlockIndex(GLuint program, const GLchar* uniformBlockName)
1624 return GL_INVALID_INDEX;
1627 inline void GetActiveUniformBlockiv(GLuint program, GLuint uniformBlockIndex, GLenum pname, GLint* params)
1631 inline void GetActiveUniformBlockName(GLuint program, GLuint uniformBlockIndex, GLsizei bufSize, GLsizei* length, GLchar* uniformBlockName)
1635 inline void UniformBlockBinding(GLuint program, GLuint uniformBlockIndex, GLuint uniformBlockBinding)
1639 inline void DrawArraysInstanced(GLenum mode, GLint first, GLsizei count, GLsizei instanceCount)
1643 inline void DrawElementsInstanced(GLenum mode, GLsizei count, GLenum type, const GLvoid* indices, GLsizei instanceCount)
1647 inline GLsync FenceSync(GLenum condition, GLbitfield flags)
1652 inline GLboolean IsSync(GLsync sync)
1657 inline void DeleteSync(GLsync sync)
1661 inline GLenum ClientWaitSync(GLsync sync, GLbitfield flags, GLuint64 timeout)
1666 inline void WaitSync(GLsync sync, GLbitfield flags, GLuint64 timeout)
1670 inline void GetInteger64v(GLenum pname, GLint64* params)
1674 inline void GetSynciv(GLsync sync, GLenum pname, GLsizei bufSize, GLsizei* length, GLint* values)
1678 inline void GetInteger64i_v(GLenum target, GLuint index, GLint64* data)
1682 inline void GetBufferParameteri64v(GLenum target, GLenum pname, GLint64* params)
1686 inline void GenSamplers(GLsizei count, GLuint* samplers)
1690 inline void DeleteSamplers(GLsizei count, const GLuint* samplers)
1694 inline GLboolean IsSampler(GLuint sampler)
1699 inline void BindSampler(GLuint unit, GLuint sampler)
1703 inline void SamplerParameteri(GLuint sampler, GLenum pname, GLint param)
1707 inline void SamplerParameteriv(GLuint sampler, GLenum pname, const GLint* param)
1711 inline void SamplerParameterf(GLuint sampler, GLenum pname, GLfloat param)
1715 inline void SamplerParameterfv(GLuint sampler, GLenum pname, const GLfloat* param)
1719 inline void GetSamplerParameteriv(GLuint sampler, GLenum pname, GLint* params)
1723 inline void GetSamplerParameterfv(GLuint sampler, GLenum pname, GLfloat* params)
1727 inline void VertexAttribDivisor(GLuint index, GLuint divisor)
1731 inline void BindTransformFeedback(GLenum target, GLuint id)
1735 inline void DeleteTransformFeedbacks(GLsizei n, const GLuint* ids)
1739 inline void GenTransformFeedbacks(GLsizei n, GLuint* ids)
1743 inline GLboolean IsTransformFeedback(GLuint id)
1748 inline void PauseTransformFeedback(void)
1752 inline void ResumeTransformFeedback(void)
1756 inline void GetProgramBinary(GLuint program, GLsizei bufSize, GLsizei* length, GLenum* binaryFormat, GLvoid* binary)
1758 mGetProgramBinaryCalled = true;
1761 inline void ProgramBinary(GLuint program, GLenum binaryFormat, const GLvoid* binary, GLsizei length)
1765 inline void ProgramParameteri(GLuint program, GLenum pname, GLint value)
1769 inline void InvalidateFramebuffer(GLenum target, GLsizei numAttachments, const GLenum* attachments)
1773 inline void InvalidateSubFramebuffer(GLenum target, GLsizei numAttachments, const GLenum* attachments, GLint x, GLint y, GLsizei width, GLsizei height)
1777 inline void TexStorage2D(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height)
1781 inline void TexStorage3D(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth)
1785 inline void GetInternalformativ(GLenum target, GLenum internalformat, GLenum pname, GLsizei bufSize, GLint* params)
1789 public: // TEST FUNCTIONS
1790 inline void SetCompileStatus( GLuint value ) { mCompileStatus = value; }
1791 inline void SetLinkStatus( GLuint value ) { mLinkStatus = value; }
1792 inline void SetGetAttribLocationResult( int result) { mGetAttribLocationResult = result; }
1793 inline void SetGetErrorResult( GLenum result) { mGetErrorResult = result; }
1794 inline void SetGetStringResult( GLubyte* result) { mGetStringResult = result; }
1795 inline void SetIsBufferResult( GLboolean result) { mIsBufferResult = result; }
1796 inline void SetIsEnabledResult( GLboolean result) { mIsEnabledResult = result; }
1797 inline void SetIsFramebufferResult( GLboolean result) { mIsFramebufferResult = result; }
1798 inline void SetIsProgramResult( GLboolean result) { mIsProgramResult = result; }
1799 inline void SetIsRenderbufferResult( GLboolean result) { mIsRenderbufferResult = result; }
1800 inline void SetIsShaderResult( GLboolean result) { mIsShaderResult = result; }
1801 inline void SetIsTextureResult( GLboolean result) { mIsTextureResult = result; }
1802 inline void SetCheckFramebufferStatusResult( GLenum result) { mCheckFramebufferStatusResult = result; }
1803 inline void SetNumBinaryFormats( GLint numFormats ) { mNumBinaryFormats = numFormats; }
1804 inline void SetBinaryFormats( GLint binaryFormats ) { mBinaryFormats = binaryFormats; }
1805 inline void SetProgramBinaryLength( GLint length ) { mProgramBinaryLength = length; }
1807 inline bool GetVertexAttribArrayState(GLuint index)
1809 if( index >= MAX_ATTRIBUTE_CACHE_SIZE )
1814 return mVertexAttribArrayState[ index ];
1816 inline void ClearVertexAttribArrayChanged() { mVertexAttribArrayChanged = false; }
1817 inline bool GetVertexAttribArrayChanged() { return mVertexAttribArrayChanged; }
1819 //Methods for CullFace verification
1820 inline void EnableCullFaceCallTrace(bool enable) { mCullFaceTrace.Enable(enable); }
1821 inline void ResetCullFaceCallStack() { mCullFaceTrace.Reset(); }
1822 inline TraceCallStack& GetCullFaceTrace() { return mCullFaceTrace; }
1824 //Methods for Enable/Disable call verification
1825 inline void EnableEnableDisableCallTrace(bool enable) { mEnableDisableTrace.Enable(enable); }
1826 inline void ResetEnableDisableCallStack() { mEnableDisableTrace.Reset(); }
1827 inline TraceCallStack& GetEnableDisableTrace() { return mEnableDisableTrace; }
1829 //Methods for Shader verification
1830 inline void EnableShaderCallTrace(bool enable) { mShaderTrace.Enable(enable); }
1831 inline void ResetShaderCallStack() { mShaderTrace.Reset(); }
1832 inline TraceCallStack& GetShaderTrace() { return mShaderTrace; }
1834 //Methods for Texture verification
1835 inline void EnableTextureCallTrace(bool enable) { mTextureTrace.Enable(enable); }
1836 inline void ResetTextureCallStack() { mTextureTrace.Reset(); }
1837 inline TraceCallStack& GetTextureTrace() { return mTextureTrace; }
1839 //Methods for Texture verification
1840 inline void EnableTexParameterCallTrace(bool enable) { mTexParamaterTrace.Enable(enable); }
1841 inline void ResetTexParameterCallStack() { mTexParamaterTrace.Reset(); }
1842 inline TraceCallStack& GetTexParameterTrace() { return mTexParamaterTrace; }
1844 //Methods for Draw verification
1845 inline void EnableDrawCallTrace(bool enable) { mDrawTrace.Enable(enable); }
1846 inline void ResetDrawCallStack() { mDrawTrace.Reset(); }
1847 inline TraceCallStack& GetDrawTrace() { return mDrawTrace; }
1849 //Methods for Depth function verification
1850 inline void EnableDepthFunctionCallTrace(bool enable) { mDepthFunctionTrace.Enable(enable); }
1851 inline void ResetDepthFunctionCallStack() { mDepthFunctionTrace.Reset(); }
1852 inline TraceCallStack& GetDepthFunctionTrace() { return mDepthFunctionTrace; }
1854 //Methods for Stencil function verification
1855 inline void EnableStencilFunctionCallTrace(bool enable) { mStencilFunctionTrace.Enable(enable); }
1856 inline void ResetStencilFunctionCallStack() { mStencilFunctionTrace.Reset(); }
1857 inline TraceCallStack& GetStencilFunctionTrace() { return mStencilFunctionTrace; }
1859 template <typename T>
1860 inline bool GetUniformValue( const char* name, T& value ) const
1862 for( ProgramUniformMap::const_iterator program_it = mUniforms.begin();
1863 program_it != mUniforms.end();
1866 const UniformIDMap &uniformIDs = program_it->second;
1868 UniformIDMap::const_iterator uniform_it = uniformIDs.find( name );
1869 if( uniform_it != uniformIDs.end() )
1871 // found one matching uniform name, lets check the value...
1872 GLuint programId = program_it->first;
1873 GLint uniformId = uniform_it->second;
1875 const ProgramUniformValue<T> &mProgramUniforms = GetProgramUniformsForType( value );
1876 return mProgramUniforms.GetUniformValue( programId, uniformId, value );
1883 template <typename T>
1884 inline bool CheckUniformValue( const char* name, const T& value ) const
1886 for( ProgramUniformMap::const_iterator program_it = mUniforms.begin();
1887 program_it != mUniforms.end();
1890 const UniformIDMap &uniformIDs = program_it->second;
1892 UniformIDMap::const_iterator uniform_it = uniformIDs.find( name );
1893 if( uniform_it != uniformIDs.end() )
1895 // found one matching uniform name, lets check the value...
1896 GLuint programId = program_it->first;
1897 GLint uniformId = uniform_it->second;
1899 const ProgramUniformValue<T> &mProgramUniforms = GetProgramUniformsForType( value );
1900 if( mProgramUniforms.CheckUniformValue( programId, uniformId, value ) )
1902 // the value matches
1908 fprintf(stderr, "Not found, printing possible values:\n" );
1909 for( ProgramUniformMap::const_iterator program_it = mUniforms.begin();
1910 program_it != mUniforms.end();
1913 const UniformIDMap &uniformIDs = program_it->second;
1915 UniformIDMap::const_iterator uniform_it = uniformIDs.find( name );
1916 if( uniform_it != uniformIDs.end() )
1918 // found one matching uniform name, lets check the value...
1919 GLuint programId = program_it->first;
1920 GLint uniformId = uniform_it->second;
1922 const ProgramUniformValue<T> &mProgramUniforms = GetProgramUniformsForType( value );
1924 if ( mProgramUniforms.GetUniformValue(programId, uniformId, origValue) )
1926 std::stringstream out;
1927 out << uniform_it->first << ": " << origValue;
1928 fprintf(stderr, "%s\n", out.str().c_str() );
1935 template <typename T>
1936 inline bool GetUniformValue( GLuint programId, GLuint uniformId, T& outValue) const
1938 const ProgramUniformValue<T> &mProgramUniforms = GetProgramUniformsForType( outValue );
1939 return mProgramUniforms.GetUniformValue( programId, uniformId, outValue );
1942 inline bool GetUniformIds( const char* name, GLuint& programId, GLuint& uniformId ) const
1944 for( ProgramUniformMap::const_iterator program_it = mUniforms.begin();
1945 program_it != mUniforms.end();
1948 const UniformIDMap &uniformIDs = program_it->second;
1950 UniformIDMap::const_iterator uniform_it = uniformIDs.find( name );
1951 if( uniform_it != uniformIDs.end() )
1953 programId = program_it->first;
1954 uniformId = uniform_it->second;
1961 inline GLuint GetLastShaderCompiled() const
1963 return mLastShaderCompiled;
1966 inline GLuint GetLastProgramCreated() const
1968 return mLastProgramIdUsed;
1971 inline GLbitfield GetLastClearMask() const
1973 return mLastClearBitMask;
1978 ATTRIB_UNKNOWN = -1,
1983 ATTRIB_BONE_WEIGHTS,
1984 ATTRIB_BONE_INDICES,
1988 struct ScissorParams
1995 ScissorParams() : x( 0 ), y( 0 ), width( 0 ), height( 0 ) { }
1998 // Methods to check scissor tests
1999 inline const ScissorParams& GetScissorParams() const { return mScissorParams; }
2001 struct ColorMaskParams
2008 ColorMaskParams() : red( true ), green( true ), blue( true ), alpha( true ) { }
2011 inline bool GetProgramBinaryCalled() const { return mGetProgramBinaryCalled; }
2013 inline unsigned int GetClearCountCalled() const { return mClearCount; }
2015 inline const ColorMaskParams& GetColorMaskParams() const { return mColorMaskParams; }
2017 typedef std::vector<size_t> BufferDataCalls;
2018 inline const BufferDataCalls& GetBufferDataCalls() const { return mBufferDataCalls; }
2019 inline void ResetBufferDataCalls() { mBufferDataCalls.clear(); }
2021 typedef std::vector<size_t> BufferSubDataCalls;
2022 inline const BufferSubDataCalls& GetBufferSubDataCalls() const { return mBufferSubDataCalls; }
2023 inline void ResetBufferSubDataCalls() { mBufferSubDataCalls.clear(); }
2026 GLuint mCurrentProgram;
2027 GLuint mCompileStatus;
2028 BufferDataCalls mBufferDataCalls;
2029 BufferSubDataCalls mBufferSubDataCalls;
2031 GLint mNumberOfActiveUniforms;
2032 GLint mGetAttribLocationResult;
2033 GLenum mGetErrorResult;
2034 GLubyte* mGetStringResult;
2035 GLboolean mIsBufferResult;
2036 GLboolean mIsEnabledResult;
2037 GLboolean mIsFramebufferResult;
2038 GLboolean mIsProgramResult;
2039 GLboolean mIsRenderbufferResult;
2040 GLboolean mIsShaderResult;
2041 GLboolean mIsTextureResult;
2042 GLenum mActiveTextureUnit;
2043 GLenum mCheckFramebufferStatusResult;
2044 GLint mFramebufferStatus;
2045 GLenum mFramebufferColorAttached;
2046 GLenum mFramebufferDepthAttached;
2047 GLenum mFramebufferStencilAttached;
2048 GLint mNumBinaryFormats;
2049 GLint mBinaryFormats;
2050 GLint mProgramBinaryLength;
2051 bool mVertexAttribArrayState[MAX_ATTRIBUTE_CACHE_SIZE];
2052 bool mVertexAttribArrayChanged; // whether the vertex attrib array has been changed
2053 bool mGetProgramBinaryCalled;
2054 typedef std::map< GLuint, std::string> ShaderSourceMap;
2055 ShaderSourceMap mShaderSources;
2056 GLuint mLastShaderCompiled;
2057 GLbitfield mLastClearBitMask;
2058 unsigned int mClearCount;
2060 Vector4 mLastBlendColor;
2061 GLenum mLastBlendEquationRgb;
2062 GLenum mLastBlendEquationAlpha;
2063 GLenum mLastBlendFuncSrcRgb;
2064 GLenum mLastBlendFuncDstRgb;
2065 GLenum mLastBlendFuncSrcAlpha;
2066 GLenum mLastBlendFuncDstAlpha;
2068 GLboolean mLastDepthMask;
2070 // Data for manipulating the IDs returned by GenTextures
2071 GLuint mLastAutoTextureIdUsed;
2072 std::vector<GLuint> mNextTextureIds;
2073 std::vector<GLuint> mDeletedTextureIds;
2074 std::vector<GLuint> mBoundTextures;
2076 struct ActiveTextureType
2078 std::vector<GLuint> mBoundTextures;
2081 ActiveTextureType mActiveTextures[ MIN_TEXTURE_UNIT_LIMIT ];
2083 TraceCallStack mCullFaceTrace;
2084 TraceCallStack mEnableDisableTrace;
2085 TraceCallStack mShaderTrace;
2086 TraceCallStack mTextureTrace;
2087 TraceCallStack mTexParamaterTrace;
2088 TraceCallStack mDrawTrace;
2089 TraceCallStack mDepthFunctionTrace;
2090 TraceCallStack mStencilFunctionTrace;
2092 // Shaders & Uniforms
2093 GLuint mLastShaderIdUsed;
2094 GLuint mLastProgramIdUsed;
2095 GLuint mLastUniformIdUsed;
2096 typedef std::map< std::string, GLint > UniformIDMap;
2097 typedef std::map< GLuint, UniformIDMap > ProgramUniformMap;
2098 ProgramUniformMap mUniforms;
2100 template <typename T>
2101 struct ProgramUniformValue : public std::map< GLuint, std::map< GLint, T > >
2104 typedef std::map< GLint, T > UniformValueMap;
2105 typedef std::map< GLuint, UniformValueMap > Map;
2107 bool SetUniformValue( GLuint program, GLuint uniform, const T& value )
2114 typename Map::iterator it = Map::find( program );
2115 if( it == Map::end() )
2117 // if its the first uniform for this program add it
2118 std::pair< typename Map::iterator, bool > result =
2119 Map::insert( typename Map::value_type( program, UniformValueMap() ) );
2123 UniformValueMap& uniforms = it->second;
2124 uniforms[uniform] = value;
2129 bool CheckUniformValue( GLuint program, GLuint uniform, const T& value ) const
2132 if ( GetUniformValue( program, uniform, uniformValue ) )
2134 return value == uniformValue;
2140 bool GetUniformValue( GLuint program, GLuint uniform, T& value ) const
2147 typename Map::const_iterator it = Map::find( program );
2148 if( it == Map::end() )
2150 // Uniform values always initialised as 0
2155 const UniformValueMap& uniforms = it->second;
2156 typename UniformValueMap::const_iterator it2 = uniforms.find( uniform );
2157 if( it2 == uniforms.end() )
2159 // Uniform values always initialised as 0
2163 value = it2->second;
2170 ProgramUniformValue<int> mProgramUniforms1i;
2171 ProgramUniformValue<float> mProgramUniforms1f;
2172 ProgramUniformValue<Vector2> mProgramUniforms2f;
2173 ProgramUniformValue<Vector3> mProgramUniforms3f;
2174 ProgramUniformValue<Vector4> mProgramUniforms4f;
2175 ProgramUniformValue<Matrix> mProgramUniformsMat4;
2176 ProgramUniformValue<Matrix3> mProgramUniformsMat3;
2178 inline const ProgramUniformValue<int>& GetProgramUniformsForType( const int ) const
2180 return mProgramUniforms1i;
2182 inline const ProgramUniformValue<float>& GetProgramUniformsForType( const float ) const
2184 return mProgramUniforms1f;
2186 inline const ProgramUniformValue<Vector2>& GetProgramUniformsForType( const Vector2& ) const
2188 return mProgramUniforms2f;
2190 inline const ProgramUniformValue<Vector3>& GetProgramUniformsForType( const Vector3& ) const
2192 return mProgramUniforms3f;
2194 inline const ProgramUniformValue<Vector4>& GetProgramUniformsForType( const Vector4& ) const
2196 return mProgramUniforms4f;
2198 inline const ProgramUniformValue<Matrix>& GetProgramUniformsForType( const Matrix& ) const
2200 return mProgramUniformsMat4;
2202 inline const ProgramUniformValue<Matrix3>& GetProgramUniformsForType( const Matrix3& ) const
2204 return mProgramUniformsMat3;
2206 inline void SetVertexAttribArray(GLuint index, bool state)
2208 if( index >= MAX_ATTRIBUTE_CACHE_SIZE )
2213 mVertexAttribArrayState[ index ] = state;
2214 mVertexAttribArrayChanged = true;
2217 ScissorParams mScissorParams;
2218 ColorMaskParams mColorMaskParams;
2222 inline int TestGlAbstraction::ProgramUniformValue<int>::GetZero() const
2228 inline float TestGlAbstraction::ProgramUniformValue<float>::GetZero() const
2234 inline Vector2 TestGlAbstraction::ProgramUniformValue<Vector2>::GetZero() const
2236 return Vector2::ZERO;
2240 inline Vector3 TestGlAbstraction::ProgramUniformValue<Vector3>::GetZero() const
2242 return Vector3::ZERO;
2246 inline Vector4 TestGlAbstraction::ProgramUniformValue<Vector4>::GetZero() const
2248 return Vector4::ZERO;
2252 inline Matrix TestGlAbstraction::ProgramUniformValue<Matrix>::GetZero() const
2258 inline Matrix3 TestGlAbstraction::ProgramUniformValue<Matrix3>::GetZero() const
2260 return Matrix3( Matrix() );
2265 bool BlendEnabled(const Dali::TraceCallStack& callStack);
2266 bool BlendDisabled(const Dali::TraceCallStack& callStack);
2269 #endif // TEST_GL_ABSTRACTION_H